diff --git a/network/netmanager/BUILD.gn b/network/netmanager/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..339128a891e1f4a9ddefb86af94878ae759a4939 --- /dev/null +++ b/network/netmanager/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//foundation/communication/netmanager_base/netmanager_base_config.gni") + +ohos_ndk_library("libnet_connection") { + output_name = "net_connection" + output_extension = "so" + ndk_description_file = "./libnet_connection.ndk.json" + min_compact_version = "1" + system_capability = "SystemCapability.Communication.NetManager.Core" + system_capability_headers = [ "./include/net_connection.h" ] +} + +ohos_ndk_headers("netconn_header") { + dest_dir = "$ndk_headers_out_dir/network/netmanager" + sources = [ "./include/net_connection.h" ] +} diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h new file mode 100644 index 0000000000000000000000000000000000000000..a1b069d78dba62c881f4ede61efc0ee2a845d394 --- /dev/null +++ b/network/netmanager/include/net_connection.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_NET_CONN_API_H +#define NATIVE_NET_CONN_API_H + +/** + * @addtogroup NetConnection + * @{ + * + * @brief Provide C interface for the data network connection module of network management. + * + * @since 11 + * @version 1.0 + */ + +/** + * @file net_connection.h + * + * @brief Provide C interface for the data network connection module of network management. + * + * @syscap SystemCapability.Communication.NetManager.Core + * @library libnet_connection.so + * @since 11 + * @version 1.0 + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get DNS result with netId. + * + * @param host The host name to query. + * @param serv Service name. + * @param hint Pointer to the addrinfo structure. + * @param res Store DNS query results and return them in a linked list format. + * @param netId DNS query netId, 0 is used for default netid query. + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.INTERNET + * @syscap SystemCapability.Communication.NetManager.Core + * @since 11 + * @version 1.0 +*/ +int32_t OH_NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, struct addrinfo **res, int32_t netId); + +/** + * @brief Free DNS result. + * + * @param res DNS query result chain header. + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.INTERNET + * @syscap SystemCapability.Communication.NetManager.Core + * @since 11 + * @version 1.0 +*/ +int32_t OH_NetConn_FreeDnsResult(struct addrinfo *res); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* NATIVE_NET_CONN_API_H */ diff --git a/network/netmanager/libnet_connection.ndk.json b/network/netmanager/libnet_connection.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..2c5ac35b01057bf0db84f462c2f4ec819acc31c3 --- /dev/null +++ b/network/netmanager/libnet_connection.ndk.json @@ -0,0 +1,10 @@ +[ + { + "first_introdeced":"11", + "name": "OH_NetConn_GetAddrInfo" + }, + { + "first_introdeced":"11", + "name": "OH_NetConn_FreeDnsResult" + } +] \ No newline at end of file