From 854e583edd80842416a808a3060ca39ecad2c905 Mon Sep 17 00:00:00 2001 From: SubmarinePhantom Date: Mon, 13 Nov 2023 15:49:06 +0800 Subject: [PATCH 1/4] Add GetAllNets interface to interface_sdk_c Signed-off-by: SubmarinePhantom --- network/netmanager/BUILD.gn | 17 +++- network/netmanager/include/net_connection.h | 14 ++++ .../include/net_connection_adapter.h | 30 ++++++++ .../netmanager/include/net_connection_type.h | 77 +++++++++++++++++++ network/netmanager/libnet_connection.ndk.json | 8 +- 5 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 network/netmanager/include/net_connection_adapter.h create mode 100644 network/netmanager/include/net_connection_type.h diff --git a/network/netmanager/BUILD.gn b/network/netmanager/BUILD.gn index 339128a89..76bf9683d 100644 --- a/network/netmanager/BUILD.gn +++ b/network/netmanager/BUILD.gn @@ -20,10 +20,23 @@ ohos_ndk_library("libnet_connection") { ndk_description_file = "./libnet_connection.ndk.json" min_compact_version = "1" system_capability = "SystemCapability.Communication.NetManager.Core" - system_capability_headers = [ "./include/net_connection.h" ] + system_capability_headers = [ + "network/netmanager/net_connection.h", + "network/netmanager/net_connection_type.h", + ] } ohos_ndk_headers("netconn_header") { dest_dir = "$ndk_headers_out_dir/network/netmanager" - sources = [ "./include/net_connection.h" ] + sources = [ + "network/netmanager/net_connection.h", + "network/netmanager/net_connection_type.h", + ] } + + + + + + + diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index a1b069d78..ba44118dc 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -75,6 +75,20 @@ int32_t OH_NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, st */ int32_t OH_NetConn_FreeDnsResult(struct addrinfo *res); +/** + * @brief Queries all activated data networks. + * + * @param netHandleList Network handle that stores the network ID list. + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.GET_NETWORK_INFO + * @syscap SystemCapability.Communication.NetManager.Core + * @since 11 + * @version 1.0 + */ +int32_t OH_NetConn_GetAllNets(OH_NetConn_NetHandleList *netHandleList); + #ifdef __cplusplus } #endif diff --git a/network/netmanager/include/net_connection_adapter.h b/network/netmanager/include/net_connection_adapter.h new file mode 100644 index 000000000..534f11379 --- /dev/null +++ b/network/netmanager/include/net_connection_adapter.h @@ -0,0 +1,30 @@ +/* +* 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_ADAPTER_H +#define NATIVE_NET_CONN_ADAPTER_H + +#include "http_proxy.h" +#include "net_connection_type.h" +#include "net_all_capabilities.h" +#include "net_handle.h" +#include "net_link_info.h" +#include "refbase.h" + +namespace OHOS::NetManagerStandard { + +int32_t Conv2NetHandleList(std::list> &netHandleObjList, OH_NetConn_NetHandleList *netHandleList); + +} // namespace OHOS::NetManagerStandard +#endif /* NATIVE_NET_CONN_ADAPTER_H */ \ No newline at end of file diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h new file mode 100644 index 000000000..890c59aeb --- /dev/null +++ b/network/netmanager/include/net_connection_type.h @@ -0,0 +1,77 @@ +/* +* 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_TYPE_H +#define NATIVE_NET_CONN_TYPE_H + +/** +* @addtogroup NetConn +* @{ +* +* @brief Provides the data structures for the C APIs of the network connection module for network management. +* +* @since 11 +* @version 1.0 +*/ + +/** +* @file native_net_conn_type.h +* @brief Defines the data structures for the C APIs of the network connection module. +* +* @library libnetconn_ndk.z.so +* @syscap SystemCapability.Communication.NetManager.Core +* @since 11 +* @version 1.0 +* +*/ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define OH_NETCONN_MAX_NET_SIZE 32 + +/** +* @brief Defines the network handle. +* +* @since 11 +* @version 1.0 +*/ +typedef struct OH_NetConn_NetHandle { + /** Network ID */ + int32_t netId; +} OH_NetConn_NetHandle; + +/** +* @brief Defines the network handle list. +* +* @since 11 +* @version 1.0 +*/ +typedef struct OH_NetConn_NetHandleList { + /** Network handle list */ + OH_NetConn_NetHandle netHandles[OH_NETCONN_MAX_NET_SIZE]; + /** Actual size of the network handle list */ + int32_t netHandleListSize; +} OH_NetConn_NetHandleList; + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* NATIVE_NET_CONN_TYPE_H */ \ No newline at end of file diff --git a/network/netmanager/libnet_connection.ndk.json b/network/netmanager/libnet_connection.ndk.json index 2c5ac35b0..a7c090088 100644 --- a/network/netmanager/libnet_connection.ndk.json +++ b/network/netmanager/libnet_connection.ndk.json @@ -1,10 +1,14 @@ [ { - "first_introdeced":"11", + "first_introduced": "11", "name": "OH_NetConn_GetAddrInfo" }, { - "first_introdeced":"11", + "first_introduced": "11", "name": "OH_NetConn_FreeDnsResult" + }, + { + "first_introduced": "11", + "name": "OH_NetConn_GetAllNets" } ] \ No newline at end of file -- Gitee From 611dfa0cc0361038b8655fbcebc09510437706ae Mon Sep 17 00:00:00 2001 From: SubmarinePhantom Date: Mon, 13 Nov 2023 19:04:45 +0800 Subject: [PATCH 2/4] update Signed-off-by: SubmarinePhantom --- network/netmanager/BUILD.gn | 9 +----- .../include/net_connection_adapter.h | 30 ------------------- .../netmanager/include/net_connection_type.h | 4 +-- 3 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 network/netmanager/include/net_connection_adapter.h diff --git a/network/netmanager/BUILD.gn b/network/netmanager/BUILD.gn index 76bf9683d..68e6ca372 100644 --- a/network/netmanager/BUILD.gn +++ b/network/netmanager/BUILD.gn @@ -32,11 +32,4 @@ ohos_ndk_headers("netconn_header") { "network/netmanager/net_connection.h", "network/netmanager/net_connection_type.h", ] -} - - - - - - - +} \ No newline at end of file diff --git a/network/netmanager/include/net_connection_adapter.h b/network/netmanager/include/net_connection_adapter.h deleted file mode 100644 index 534f11379..000000000 --- a/network/netmanager/include/net_connection_adapter.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -* 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_ADAPTER_H -#define NATIVE_NET_CONN_ADAPTER_H - -#include "http_proxy.h" -#include "net_connection_type.h" -#include "net_all_capabilities.h" -#include "net_handle.h" -#include "net_link_info.h" -#include "refbase.h" - -namespace OHOS::NetManagerStandard { - -int32_t Conv2NetHandleList(std::list> &netHandleObjList, OH_NetConn_NetHandleList *netHandleList); - -} // namespace OHOS::NetManagerStandard -#endif /* NATIVE_NET_CONN_ADAPTER_H */ \ No newline at end of file diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h index 890c59aeb..adbb7866e 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -27,10 +27,10 @@ */ /** -* @file native_net_conn_type.h +* @file net_connection_type.h * @brief Defines the data structures for the C APIs of the network connection module. * -* @library libnetconn_ndk.z.so +* @library libnet_connection.so * @syscap SystemCapability.Communication.NetManager.Core * @since 11 * @version 1.0 -- Gitee From b4c21281c0cf860a4dcad6220ea4dba8cd51bd22 Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 13 Nov 2023 11:17:13 +0000 Subject: [PATCH 3/4] update network/netmanager/include/net_connection_type.h. Signed-off-by: Aurora --- network/netmanager/include/net_connection_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h index adbb7866e..d8daf78d0 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -17,7 +17,7 @@ #define NATIVE_NET_CONN_TYPE_H /** -* @addtogroup NetConn +* @addtogroup NetConnection * @{ * * @brief Provides the data structures for the C APIs of the network connection module for network management. -- Gitee From 29431409964fb9519d9a67b5b975258cec87a6f8 Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 13 Nov 2023 11:34:50 +0000 Subject: [PATCH 4/4] update network/netmanager/include/net_connection_type.h. Signed-off-by: Aurora --- network/netmanager/include/net_connection_type.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h index d8daf78d0..e18a9310f 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -52,8 +52,8 @@ extern "C" { * @version 1.0 */ typedef struct OH_NetConn_NetHandle { - /** Network ID */ - int32_t netId; + /** Network ID */ + int32_t netId; } OH_NetConn_NetHandle; /** @@ -63,10 +63,10 @@ typedef struct OH_NetConn_NetHandle { * @version 1.0 */ typedef struct OH_NetConn_NetHandleList { - /** Network handle list */ - OH_NetConn_NetHandle netHandles[OH_NETCONN_MAX_NET_SIZE]; - /** Actual size of the network handle list */ - int32_t netHandleListSize; + /** Network handle list */ + OH_NetConn_NetHandle netHandles[OH_NETCONN_MAX_NET_SIZE]; + /** Actual size of the network handle list */ + int32_t netHandleListSize; } OH_NetConn_NetHandleList; #ifdef __cplusplus -- Gitee