mirror of
https://github.com/openharmony/interface_sdk_c.git
synced 2026-08-26 18:56:40 -04:00
!69 Add OH_NetConn_GetAllNets interface to NDK
Merge pull request !69 from Aurora/master
This commit is contained in:
@@ -20,10 +20,16 @@ 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 = [
|
||||
"include/net_connection.h",
|
||||
"include/net_connection_type.h",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
#include "net_connection_type.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -75,6 +77,47 @@ 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);
|
||||
|
||||
/**
|
||||
* @brief Registers a custom DNS resolver.
|
||||
*
|
||||
* @param resolver Pointer to the custom DNS resolver.
|
||||
* @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 OHOS_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver);
|
||||
|
||||
/**
|
||||
* @brief Unregisters a custom DNS resolver.
|
||||
*
|
||||
* @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 OHOS_NetConn_UnregisterDnsResolver(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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 NetConnection
|
||||
* @{
|
||||
*
|
||||
* @brief Provides the data structures for the C APIs of the network connection module for network management.
|
||||
*
|
||||
* @since 11
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file net_connection_type.h
|
||||
* @brief Defines the data structures for the C APIs of the network connection module.
|
||||
*
|
||||
* @library libnet_connection.so
|
||||
* @syscap SystemCapability.Communication.NetManager.Core
|
||||
* @since 11
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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;
|
||||
|
||||
/*
|
||||
* @brief Pointer to the custom DNS resolver.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @since 11
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef int (*OH_NetConn_CustomDnsResolver)(const char *host, const char *serv,
|
||||
const struct addrinfo *hint, struct addrinfo **res);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif /* NATIVE_NET_CONN_TYPE_H */
|
||||
@@ -1,10 +1,22 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"first_introduced": "11",
|
||||
"name": "OHOS_NetConn_RegisterDnsResolver"
|
||||
},
|
||||
{
|
||||
"first_introduced": "11",
|
||||
"name": "OHOS_NetConn_UnregisterDnsResolver"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user