From a9f20abdbf4bb83b4409329dfd8b7fd04ebb17f8 Mon Sep 17 00:00:00 2001 From: "liuxiyao223@huawei.com" Date: Tue, 5 Dec 2023 10:11:47 +0800 Subject: [PATCH 1/9] Add interfaces to NDK Signed-off-by: liuxiyao223@huawei.com --- network/netmanager/include/net_connection.h | 83 +++++++++- .../netmanager/include/net_connection_type.h | 149 +++++++++++++++++- 2 files changed, 229 insertions(+), 3 deletions(-) diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index 02b937057..9bdaf50ae 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -45,6 +45,85 @@ extern "C" { #endif +/** + * @brief Query whether there is a data network activated by default + * + * @param hasDefaultNet Is there a default network + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.GET_NETWORK_INFO + * @since 11 + * @version 1.0 +*/ +int32_t OH_NetConn_HasDefaultNet(int32_t *hasDefaultNet); + +/** + * @brief Get the activated default data network + * + * @param netHandle Store network ID + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.GET_NETWORK_INFO + * @since 11 + * @version 1.0 + */ +int32_t OH_NetConn_GetDefaultNet(OH_NetConn_NetHandle *netHandle); + +/** + * @brief Check whether the default data network records traffic + * + * @param isMetered Activate now + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.GET_NETWORK_INFO + * @since 11 + * @version 1.0 + */ +int32_t OH_NetConn_IsDefaultNetMetered(int32_t *isMetered); + +/** + * @brief Query the link information of a data network + * + * @param netHandle Store network ID + * @param info Store link information + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.GET_NETWORK_INFO + * @since 11 + * @version 1.0 + */ +int32_t OH_NetConn_GetConnectionProperties(OH_NetConn_NetHandle *netHandle, NetConn_NetLinkInfo *info); + +/** + * @brief Query the capability set of a network + * + * @param netHandle Store network ID + * @param netAllCapacities storage capability set + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.GET_NETWORK_INFO + * @since 11 + * @version 1.0 + */ +int32_t OH_NetConn_GetNetCapabilities(OH_NetConn_NetHandle *netHandle, NetConn_NetAllCapabilities *netAllCapacities); + +/** + * @brief Query the default network proxy + * + * @param httpProxy Store proxy configuration information + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @since 11 + * @version 1.0 + */ +int32_t OH_NetConn_GetDefaultHttpProxy(NetConn_HttpProxy *httpProxy); + /** * @brief Get DNS result with netId. * @@ -61,7 +140,7 @@ extern "C" { * @since 11 * @version 1.0 */ -int32_t OH_NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, struct addrinfo **res, int32_t netId); +int32_t NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, struct addrinfo **res, int32_t netId); /** * @brief Free DNS result. @@ -123,4 +202,4 @@ int32_t OHOS_NetConn_UnregisterDnsResolver(void); #endif /** @} */ -#endif /* NATIVE_NET_CONN_API_H */ +#endif /* NATIVE_NET_CONN_API_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 17cfc24eb..259ed570c 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -44,6 +44,48 @@ extern "C" { #endif #define OH_NETCONN_MAX_NET_SIZE 32 +#define OH_NETCONN_MAX_NET_SIZE 32 +#define OH_NETCONN_MAX_BEAR_TYPE_SIZE 32 +#define OH_NETCONN_MAX_CAP_SIZE 32 +#define OH_NETCONN_MAX_ADDR_SIZE 32 +#define OH_NETCONN_MAX_ROUTE_SIZE 64 +#define OH_NETCONN_MAX_EXCLUSION_SIZE 256 +#define OH_NETCONN_MAX_STR_LEN 256 + +/** +* @brief Defines network capabilities. +* +* @since 10 +* @version 1.0 +*/ + +typedef enum NetConn_NetCap { + /* MMS */ + OH_NETCONN_NET_CAPABILITY_MMS = 0, + /* Not Metered */ + OH_NETCONN_NET_CAPABILITY_NOT_METERED = 11, + /* Internet */ + OH_NETCONN_NET_CAPABILITY_INTERNET = 12, + /* Not VPN */ + OH_NETCONN_NET_CAPABILITY_NOT_VPN = 15, + /* Validated */ + OH_NETCONN_NET_CAPABILITY_VALIDATED = 16, +} NetConn_NetCap; + +/** + * @brief Defines network bearer types. + * + * @since 11 + * @version 1.0 + */ +typedef enum NetConn_NetBearType { + /** Cellular network */ + OH_NETCONN_BEARER_CELLULAR = 0, + /** WIFI */ + OH_NETCONN_BEARER_WIFI = 1, + /** Ethernet */ + OH_NETCONN_BEARER_ETHERNET = 3, +} NetConn_NetBearType; /** * @brief Defines the network handle. @@ -56,6 +98,111 @@ typedef struct OH_NetConn_NetHandle { int32_t netId; } OH_NetConn_NetHandle; +/** + * @brief Defines all network capabilities. + * + * @since 11 + * @version 1.0 + */ +typedef struct NetConn_NetAllCapabilities { + /** Uplink bandwidth */ + uint32_t linkUpBandwidthKbps; + /** Downlink bandwidth */ + uint32_t linkDownBandwidthKbps; + /** Network capability list */ + NetConn_NetCap netCaps[OH_NETCONN_MAX_CAP_SIZE]; + /** Actual size of the network capability list */ + int32_t netCapsSize; + /** Bearer type list */ + NetConn_NetBearType bearerTypes[OH_NETCONN_MAX_BEAR_TYPE_SIZE]; + /** Actual size of the bearer type list */ + int32_t bearerTypesSize; +} NetConn_NetAllCapabilities; + +/** + * @brief Defines the network address. + * + * @since 11 + * @version 1.0 + */ +typedef struct NetConn_INetAddr { + /** Network address family */ + uint8_t family; + /** Prefix length */ + uint8_t prefixlen; + /** Port number */ + uint8_t port; + /** Address */ + char address[OH_NETCONN_MAX_STR_LEN]; +} NetConn_INetAddr; + +/** + * @brief Defines the route configuration information. + * + * @since 11 + * @version 1.0 + */ +typedef struct NetConn_Route { + /** Network interface */ + char iface[OH_NETCONN_MAX_STR_LEN]; + /** Destination address */ + NetConn_INetAddr destination; + /** Gateway address */ + NetConn_INetAddr gateway; + /** Gateway exists or not */ + int32_t hasGateway; + /** Default route or not */ + int32_t isDefaultRoute; +} NetConn_Route; + +/** + * @brief Defines the proxy configuration information. + * + * @since 11 + * @version 1.0 + */ +typedef struct NetConn_HttpProxy { + /** Host name */ + char host[OH_NETCONN_MAX_STR_LEN]; + /** Exclusion list of proxy servers */ + char exclusionList[OH_NETCONN_MAX_EXCLUSION_SIZE][OH_NETCONN_MAX_STR_LEN]; + /** Actual size of the exclusion list */ + int32_t exclusionListSize; + /** Port number */ + uint16_t port; +} NetConn_HttpProxy; + +/** + * @brief Defines the network link information. + * + * @since 11 + * @version 1.0 + */ +typedef struct NetConn_NetLinkInfo { + /** Network interface name */ + char ifaceName[OH_NETCONN_MAX_STR_LEN]; + /** Domain name of the network connection */ + char domain[OH_NETCONN_MAX_STR_LEN]; + /** TCP buffer size */ + char tcpBufferSizes[OH_NETCONN_MAX_STR_LEN]; + /** MTU */ + uint16_t mtu; + /** Address list */ + NetConn_INetAddr netAddrList[OH_NETCONN_MAX_ADDR_SIZE]; + /** Actual size of the address list */ + int32_t netAddrListSize; + /** DNS list */ + NetConn_INetAddr dnsList[OH_NETCONN_MAX_ADDR_SIZE]; + /** Actual size of the DNS list */ + int32_t dnsListSize; + /** Route list */ + NetConn_Route routeList[OH_NETCONN_MAX_ROUTE_SIZE]; + /** Actual size of the route list */ + int32_t routeListSize; + /** HTTP proxy information */ + NetConn_HttpProxy httpProxy; +} NetConn_NetLinkInfo; + /** * @brief Defines the network handle list. * @@ -81,7 +228,7 @@ typedef struct OH_NetConn_NetHandleList { * @version 1.0 */ typedef int (*OH_NetConn_CustomDnsResolver)(const char *host, const char *serv, - const struct addrinfo *hint, struct addrinfo **res); + const struct addrinfo *hint, struct addrinfo **res); #ifdef __cplusplus } -- Gitee From 089e6a0d7af6d05dc172aaddec949ddf555b1e76 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 5 Dec 2023 02:53:24 +0000 Subject: [PATCH 2/9] update network/netmanager/include/net_connection.h. Signed-off-by: Aurora --- network/netmanager/include/net_connection.h | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index 9bdaf50ae..3f585d67a 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -46,46 +46,49 @@ extern "C" { #endif /** - * @brief Query whether there is a data network activated by default + * @brief Query whether there is a data network activated by default. * * @param hasDefaultNet Is there a default network * @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_HasDefaultNet(int32_t *hasDefaultNet); /** - * @brief Get the activated default data network + * @brief Get the activated default data network. * * @param netHandle Store network ID * @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_GetDefaultNet(OH_NetConn_NetHandle *netHandle); /** - * @brief Check whether the default data network records traffic + * @brief Check whether the default data network is a metered network. * - * @param isMetered Activate now + * @param isMetered 1:true, 0:false * @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_IsDefaultNetMetered(int32_t *isMetered); /** - * @brief Query the link information of a data network + * @brief Query the link information of a data network. * * @param netHandle Store network ID * @param info Store link information @@ -93,13 +96,14 @@ int32_t OH_NetConn_IsDefaultNetMetered(int32_t *isMetered); * 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_GetConnectionProperties(OH_NetConn_NetHandle *netHandle, NetConn_NetLinkInfo *info); /** - * @brief Query the capability set of a network + * @brief Query the capability set of a network. * * @param netHandle Store network ID * @param netAllCapacities storage capability set @@ -107,18 +111,20 @@ int32_t OH_NetConn_GetConnectionProperties(OH_NetConn_NetHandle *netHandle, NetC * 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_GetNetCapabilities(OH_NetConn_NetHandle *netHandle, NetConn_NetAllCapabilities *netAllCapacities); /** - * @brief Query the default network proxy + * @brief Query the default HTTP proxy. * * @param httpProxy Store proxy configuration information * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. + * @syscap SystemCapability.Communication.NetManager.Core * @since 11 * @version 1.0 */ @@ -140,7 +146,7 @@ int32_t OH_NetConn_GetDefaultHttpProxy(NetConn_HttpProxy *httpProxy); * @since 11 * @version 1.0 */ -int32_t NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, struct addrinfo **res, int32_t netId); +int32_t OH_NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, struct addrinfo **res, int32_t netId); /** * @brief Free DNS result. -- Gitee From 8f0148709d784661b6427673676294dbf76cf9b8 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 5 Dec 2023 02:54:14 +0000 Subject: [PATCH 3/9] update network/netmanager/include/net_connection_type.h. Signed-off-by: Aurora --- network/netmanager/include/net_connection_type.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h index 259ed570c..81819d0cf 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -55,7 +55,7 @@ extern "C" { /** * @brief Defines network capabilities. * -* @since 10 +* @since 11 * @version 1.0 */ @@ -228,7 +228,7 @@ typedef struct OH_NetConn_NetHandleList { * @version 1.0 */ typedef int (*OH_NetConn_CustomDnsResolver)(const char *host, const char *serv, - const struct addrinfo *hint, struct addrinfo **res); + const struct addrinfo *hint, struct addrinfo **res); #ifdef __cplusplus } -- Gitee From 6e2eea47c7ca80106d509852acdd1141afe6a10b Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 5 Dec 2023 02:57:03 +0000 Subject: [PATCH 4/9] update network/netmanager/libnet_connection.ndk.json. Signed-off-by: Aurora --- network/netmanager/libnet_connection.ndk.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/network/netmanager/libnet_connection.ndk.json b/network/netmanager/libnet_connection.ndk.json index fdac6cc66..b6c76dfa9 100644 --- a/network/netmanager/libnet_connection.ndk.json +++ b/network/netmanager/libnet_connection.ndk.json @@ -11,6 +11,22 @@ "first_introduced": "11", "name": "OH_NetConn_GetAllNets" }, + { + "first_introduced": "11", + "name": "OH_NetConn_HasDefaultNet" + }, + { + "first_introduced": "11", + "name": "OH_NetConn_GetDefaultNet" + }, + { + "first_introduced": "11", + "name": "OH_NetConn_GetConnectionProperties" + }, + { + "first_introduced": "11", + "name": "OH_NetConn_GetNetCapabilities" + }, { "first_introduced": "11", "name": "OHOS_NetConn_RegisterDnsResolver" -- Gitee From 0326cc8d525fe6ebec6d380f40dfc5b6727ea876 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 5 Dec 2023 03:00:08 +0000 Subject: [PATCH 5/9] update network/netmanager/libnet_connection.ndk.json. Signed-off-by: Aurora --- network/netmanager/libnet_connection.ndk.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/network/netmanager/libnet_connection.ndk.json b/network/netmanager/libnet_connection.ndk.json index b6c76dfa9..284e7ad50 100644 --- a/network/netmanager/libnet_connection.ndk.json +++ b/network/netmanager/libnet_connection.ndk.json @@ -15,6 +15,10 @@ "first_introduced": "11", "name": "OH_NetConn_HasDefaultNet" }, + { + "first_introduced": "11", + "name": "OH_NetConn_IsDefaultNetMetered" + }, { "first_introduced": "11", "name": "OH_NetConn_GetDefaultNet" @@ -27,6 +31,10 @@ "first_introduced": "11", "name": "OH_NetConn_GetNetCapabilities" }, + { + "first_introduced": "11", + "name": "OH_NetConn_GetDefaultHttpProxy" + }, { "first_introduced": "11", "name": "OHOS_NetConn_RegisterDnsResolver" -- Gitee From ce57eba20399b24ef47cb357acab3fb6db21a7d5 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 5 Dec 2023 03:05:29 +0000 Subject: [PATCH 6/9] update network/netmanager/include/net_connection.h. Signed-off-by: Aurora --- network/netmanager/include/net_connection.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index 3f585d67a..1738bd5fc 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -48,7 +48,7 @@ extern "C" { /** * @brief Query whether there is a data network activated by default. * - * @param hasDefaultNet Is there a default network + * @param hasDefaultNet Is there a default network. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -62,7 +62,7 @@ int32_t OH_NetConn_HasDefaultNet(int32_t *hasDefaultNet); /** * @brief Get the activated default data network. * - * @param netHandle Store network ID + * @param netHandle Store network ID. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -76,7 +76,7 @@ int32_t OH_NetConn_GetDefaultNet(OH_NetConn_NetHandle *netHandle); /** * @brief Check whether the default data network is a metered network. * - * @param isMetered 1:true, 0:false + * @param isMetered 1:true, 0:false. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -90,8 +90,8 @@ int32_t OH_NetConn_IsDefaultNetMetered(int32_t *isMetered); /** * @brief Query the link information of a data network. * - * @param netHandle Store network ID - * @param info Store link information + * @param netHandle Store network ID. + * @param info Store link information. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -105,8 +105,8 @@ int32_t OH_NetConn_GetConnectionProperties(OH_NetConn_NetHandle *netHandle, NetC /** * @brief Query the capability set of a network. * - * @param netHandle Store network ID - * @param netAllCapacities storage capability set + * @param netHandle Store network ID. + * @param netAllCapacities storage capability set. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -120,7 +120,7 @@ int32_t OH_NetConn_GetNetCapabilities(OH_NetConn_NetHandle *netHandle, NetConn_N /** * @brief Query the default HTTP proxy. * - * @param httpProxy Store proxy configuration information + * @param httpProxy Store proxy configuration information. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. -- Gitee From caf3f4a1e90e1611ae3a22d1f70759251e41e703 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 5 Dec 2023 03:59:43 +0000 Subject: [PATCH 7/9] update network/netmanager/include/net_connection.h. Signed-off-by: Aurora --- network/netmanager/include/net_connection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index 1738bd5fc..e6e409b48 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -67,7 +67,7 @@ int32_t OH_NetConn_HasDefaultNet(int32_t *hasDefaultNet); * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. * @permission ohos.permission.GET_NETWORK_INFO - * @syscap SystemCapability.Communication.NetManager.Core + * @syscap SystemCapability.Communication.NetManager.Core * @since 11 * @version 1.0 */ -- Gitee From 89600b0d244559446024052747a026f9af71beef Mon Sep 17 00:00:00 2001 From: "liuxiyao223@huawei.com" Date: Wed, 6 Dec 2023 11:13:41 +0800 Subject: [PATCH 8/9] update Signed-off-by: liuxiyao223@huawei.com --- network/netmanager/include/net_connection.h | 46 ++--- .../netmanager/include/net_connection_type.h | 189 +++++++++--------- 2 files changed, 116 insertions(+), 119 deletions(-) diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index e6e409b48..7a64821bc 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -46,9 +46,9 @@ extern "C" { #endif /** - * @brief Query whether there is a data network activated by default. + * @brief Checks whether a default activated data network is available. * - * @param hasDefaultNet Is there a default network. + * @param hasDefaultNet Pointer to the result that specifies whether a default activated data network is available. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -56,13 +56,13 @@ extern "C" { * @syscap SystemCapability.Communication.NetManager.Core * @since 11 * @version 1.0 -*/ + */ int32_t OH_NetConn_HasDefaultNet(int32_t *hasDefaultNet); /** - * @brief Get the activated default data network. + * @brief Obtains the default activated data network. * - * @param netHandle Store network ID. + * @param netHandle Pointer to the network handle that contains the network ID. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -71,12 +71,12 @@ int32_t OH_NetConn_HasDefaultNet(int32_t *hasDefaultNet); * @since 11 * @version 1.0 */ -int32_t OH_NetConn_GetDefaultNet(OH_NetConn_NetHandle *netHandle); +int32_t OH_NetConn_GetDefaultNet(NetConn_NetHandle *netHandle); /** - * @brief Check whether the default data network is a metered network. + * @brief Checks whether metering is enabled for the default data network. * - * @param isMetered 1:true, 0:false. + * @param isMetered Pointer to the result that specifies whether metering is enabled. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -88,10 +88,10 @@ int32_t OH_NetConn_GetDefaultNet(OH_NetConn_NetHandle *netHandle); int32_t OH_NetConn_IsDefaultNetMetered(int32_t *isMetered); /** - * @brief Query the link information of a data network. + * @brief Obtains the connection properties of a data network. * - * @param netHandle Store network ID. - * @param info Store link information. + * @param netHandle Pointer to the network handle that contains the network ID. + * @param prop Pointer to the connection properties. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -100,13 +100,13 @@ int32_t OH_NetConn_IsDefaultNetMetered(int32_t *isMetered); * @since 11 * @version 1.0 */ -int32_t OH_NetConn_GetConnectionProperties(OH_NetConn_NetHandle *netHandle, NetConn_NetLinkInfo *info); +int32_t OH_NetConn_GetConnectionProperties(NetConn_NetHandle *netHandle, NetConn_ConnectionProperties *prop); /** - * @brief Query the capability set of a network. + * @brief Obtains the capabilities of a data network. * - * @param netHandle Store network ID. - * @param netAllCapacities storage capability set. + * @param netHandle Pointer to the network handle that contains the network ID. + * @param netCapacities Pointer to the network capabilities. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -115,12 +115,12 @@ int32_t OH_NetConn_GetConnectionProperties(OH_NetConn_NetHandle *netHandle, NetC * @since 11 * @version 1.0 */ -int32_t OH_NetConn_GetNetCapabilities(OH_NetConn_NetHandle *netHandle, NetConn_NetAllCapabilities *netAllCapacities); +int32_t OH_NetConn_GetNetCapabilities(NetConn_NetHandle *netHandle, NetConn_NetCapabilities *netCapacities); /** - * @brief Query the default HTTP proxy. + * @brief Obtains the default http proxy. * - * @param httpProxy Store proxy configuration information. + * @param httpProxy Pointer to the HTTP proxy. * @return 0 - Success. 201 - Missing permissions. * 401 - Parameter error. 2100002 - Unable to connect to service. * 2100003 - Internal error. @@ -145,7 +145,7 @@ int32_t OH_NetConn_GetDefaultHttpProxy(NetConn_HttpProxy *httpProxy); * @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); /** @@ -159,7 +159,7 @@ int32_t OH_NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, st * @syscap SystemCapability.Communication.NetManager.Core * @since 11 * @version 1.0 -*/ + */ int32_t OH_NetConn_FreeDnsResult(struct addrinfo *res); /** @@ -174,7 +174,7 @@ int32_t OH_NetConn_FreeDnsResult(struct addrinfo *res); * @since 11 * @version 1.0 */ -int32_t OH_NetConn_GetAllNets(OH_NetConn_NetHandleList *netHandleList); +int32_t OH_NetConn_GetAllNets(NetConn_NetHandleList *netHandleList); /** * @brief Registers a custom DNS resolver. @@ -187,7 +187,7 @@ int32_t OH_NetConn_GetAllNets(OH_NetConn_NetHandleList *netHandleList); * @syscap SystemCapability.Communication.NetManager.Core * @since 11 * @version 1.0 -*/ + */ int32_t OHOS_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver); /** @@ -200,7 +200,7 @@ int32_t OHOS_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver); * @syscap SystemCapability.Communication.NetManager.Core * @since 11 * @version 1.0 -*/ + */ int32_t OHOS_NetConn_UnregisterDnsResolver(void); #ifdef __cplusplus diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h index 81819d0cf..f26c48ed9 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -1,41 +1,41 @@ /* -* 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. -*/ + * 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 -*/ + * @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 -* -*/ + * @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 @@ -43,33 +43,31 @@ extern "C" { #endif -#define OH_NETCONN_MAX_NET_SIZE 32 -#define OH_NETCONN_MAX_NET_SIZE 32 -#define OH_NETCONN_MAX_BEAR_TYPE_SIZE 32 -#define OH_NETCONN_MAX_CAP_SIZE 32 -#define OH_NETCONN_MAX_ADDR_SIZE 32 -#define OH_NETCONN_MAX_ROUTE_SIZE 64 -#define OH_NETCONN_MAX_EXCLUSION_SIZE 256 -#define OH_NETCONN_MAX_STR_LEN 256 +#define NETCONN_MAX_NET_SIZE 32 +#define NETCONN_MAX_BEARER_TYPE_SIZE 32 +#define NETCONN_MAX_CAP_SIZE 32 +#define NETCONN_MAX_ADDR_SIZE 32 +#define NETCONN_MAX_ROUTE_SIZE 64 +#define NETCONN_MAX_EXCLUSION_SIZE 256 +#define NETCONN_MAX_STR_LEN 256 /** -* @brief Defines network capabilities. -* -* @since 11 -* @version 1.0 -*/ - + * @brief Defines network capabilities. + * + * @since 11 + * @version 1.0 + */ typedef enum NetConn_NetCap { - /* MMS */ - OH_NETCONN_NET_CAPABILITY_MMS = 0, - /* Not Metered */ - OH_NETCONN_NET_CAPABILITY_NOT_METERED = 11, - /* Internet */ - OH_NETCONN_NET_CAPABILITY_INTERNET = 12, - /* Not VPN */ - OH_NETCONN_NET_CAPABILITY_NOT_VPN = 15, - /* Validated */ - OH_NETCONN_NET_CAPABILITY_VALIDATED = 16, + /** MMS */ + NETCONN_NET_CAPABILITY_MMS = 0, + /** Not Metered */ + NETCONN_NET_CAPABILITY_NOT_METERED = 11, + /** Internet */ + NETCONN_NET_CAPABILITY_INTERNET = 12, + /** Not VPN */ + NETCONN_NET_CAPABILITY_NOT_VPN = 15, + /** Validated */ + NETCONN_NET_CAPABILITY_VALIDATED = 16, } NetConn_NetCap; /** @@ -78,25 +76,25 @@ typedef enum NetConn_NetCap { * @since 11 * @version 1.0 */ -typedef enum NetConn_NetBearType { +typedef enum NetConn_NetBearerType { /** Cellular network */ - OH_NETCONN_BEARER_CELLULAR = 0, + NETCONN_BEARER_CELLULAR = 0, /** WIFI */ - OH_NETCONN_BEARER_WIFI = 1, + NETCONN_BEARER_WIFI = 1, /** Ethernet */ - OH_NETCONN_BEARER_ETHERNET = 3, -} NetConn_NetBearType; + NETCONN_BEARER_ETHERNET = 3, +} NetConn_NetBearerType; /** -* @brief Defines the network handle. -* -* @since 11 -* @version 1.0 -*/ -typedef struct OH_NetConn_NetHandle { + * @brief Defines the network handle. + * + * @since 11 + * @version 1.0 + */ +typedef struct NetConn_NetHandle { /** Network ID */ int32_t netId; -} OH_NetConn_NetHandle; +} NetConn_NetHandle; /** * @brief Defines all network capabilities. @@ -104,20 +102,20 @@ typedef struct OH_NetConn_NetHandle { * @since 11 * @version 1.0 */ -typedef struct NetConn_NetAllCapabilities { +typedef struct NetConn_NetCapabilities { /** Uplink bandwidth */ uint32_t linkUpBandwidthKbps; /** Downlink bandwidth */ uint32_t linkDownBandwidthKbps; /** Network capability list */ - NetConn_NetCap netCaps[OH_NETCONN_MAX_CAP_SIZE]; + NetConn_NetCap netCaps[NETCONN_MAX_CAP_SIZE]; /** Actual size of the network capability list */ int32_t netCapsSize; /** Bearer type list */ - NetConn_NetBearType bearerTypes[OH_NETCONN_MAX_BEAR_TYPE_SIZE]; + NetConn_NetBearerType bearerTypes[NETCONN_MAX_BEARER_TYPE_SIZE]; /** Actual size of the bearer type list */ int32_t bearerTypesSize; -} NetConn_NetAllCapabilities; +} NetConn_NetCapabilities; /** * @brief Defines the network address. @@ -125,7 +123,7 @@ typedef struct NetConn_NetAllCapabilities { * @since 11 * @version 1.0 */ -typedef struct NetConn_INetAddr { +typedef struct NetConn_NetAddr { /** Network address family */ uint8_t family; /** Prefix length */ @@ -133,8 +131,8 @@ typedef struct NetConn_INetAddr { /** Port number */ uint8_t port; /** Address */ - char address[OH_NETCONN_MAX_STR_LEN]; -} NetConn_INetAddr; + char address[NETCONN_MAX_STR_LEN]; +} NetConn_NetAddr; /** * @brief Defines the route configuration information. @@ -144,11 +142,11 @@ typedef struct NetConn_INetAddr { */ typedef struct NetConn_Route { /** Network interface */ - char iface[OH_NETCONN_MAX_STR_LEN]; + char iface[NETCONN_MAX_STR_LEN]; /** Destination address */ - NetConn_INetAddr destination; + NetConn_NetAddr destination; /** Gateway address */ - NetConn_INetAddr gateway; + NetConn_NetAddr gateway; /** Gateway exists or not */ int32_t hasGateway; /** Default route or not */ @@ -163,9 +161,9 @@ typedef struct NetConn_Route { */ typedef struct NetConn_HttpProxy { /** Host name */ - char host[OH_NETCONN_MAX_STR_LEN]; + char host[NETCONN_MAX_STR_LEN]; /** Exclusion list of proxy servers */ - char exclusionList[OH_NETCONN_MAX_EXCLUSION_SIZE][OH_NETCONN_MAX_STR_LEN]; + char exclusionList[NETCONN_MAX_EXCLUSION_SIZE][NETCONN_MAX_STR_LEN]; /** Actual size of the exclusion list */ int32_t exclusionListSize; /** Port number */ @@ -178,45 +176,45 @@ typedef struct NetConn_HttpProxy { * @since 11 * @version 1.0 */ -typedef struct NetConn_NetLinkInfo { +typedef struct NetConn_ConnectionProperties { /** Network interface name */ - char ifaceName[OH_NETCONN_MAX_STR_LEN]; + char ifaceName[NETCONN_MAX_STR_LEN]; /** Domain name of the network connection */ - char domain[OH_NETCONN_MAX_STR_LEN]; + char domain[NETCONN_MAX_STR_LEN]; /** TCP buffer size */ - char tcpBufferSizes[OH_NETCONN_MAX_STR_LEN]; + char tcpBufferSizes[NETCONN_MAX_STR_LEN]; /** MTU */ uint16_t mtu; /** Address list */ - NetConn_INetAddr netAddrList[OH_NETCONN_MAX_ADDR_SIZE]; + NetConn_NetAddr netAddrList[NETCONN_MAX_ADDR_SIZE]; /** Actual size of the address list */ int32_t netAddrListSize; /** DNS list */ - NetConn_INetAddr dnsList[OH_NETCONN_MAX_ADDR_SIZE]; + NetConn_NetAddr dnsList[NETCONN_MAX_ADDR_SIZE]; /** Actual size of the DNS list */ int32_t dnsListSize; /** Route list */ - NetConn_Route routeList[OH_NETCONN_MAX_ROUTE_SIZE]; + NetConn_Route routeList[NETCONN_MAX_ROUTE_SIZE]; /** Actual size of the route list */ int32_t routeListSize; /** HTTP proxy information */ NetConn_HttpProxy httpProxy; -} NetConn_NetLinkInfo; +} NetConn_ConnectionProperties; /** -* @brief Defines the network handle list. -* -* @since 11 -* @version 1.0 -*/ -typedef struct OH_NetConn_NetHandleList { + * @brief Defines the network handle list. + * + * @since 11 + * @version 1.0 + */ +typedef struct NetConn_NetHandleList { /** Network handle list */ - OH_NetConn_NetHandle netHandles[OH_NETCONN_MAX_NET_SIZE]; + NetConn_NetHandle netHandles[NETCONN_MAX_NET_SIZE]; /** Actual size of the network handle list */ int32_t netHandleListSize; -} OH_NetConn_NetHandleList; +} NetConn_NetHandleList; -/* +/** * @brief Pointer to the custom DNS resolver. * * @param host The host name to query. @@ -229,7 +227,6 @@ typedef struct OH_NetConn_NetHandleList { */ typedef int (*OH_NetConn_CustomDnsResolver)(const char *host, const char *serv, const struct addrinfo *hint, struct addrinfo **res); - #ifdef __cplusplus } #endif -- Gitee From 3ceda4f07c2615b085afa83e8d50145f8de257a3 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 19 Dec 2023 03:58:54 +0000 Subject: [PATCH 9/9] 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 f26c48ed9..2455ac8e2 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -171,7 +171,7 @@ typedef struct NetConn_HttpProxy { } NetConn_HttpProxy; /** - * @brief Defines the network link information. + * @brief Defines the network connection properties. * * @since 11 * @version 1.0 -- Gitee