net_connection_type.h
Overview
Provides the C APIs of the network connection module for network management.
File to include: <network/netmanager/net_connection_type.h>
Library: libnet_connection.so
System capability: SystemCapability.Communication.NetManager.Core
Since: 11
Related module: NetConnection
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| NetConn_NetHandle | NetConn_NetHandle | Network ID. |
| NetConn_NetCapabilities | NetConn_NetCapabilities | Network capability set. |
| NetConn_NetAddr | NetConn_NetAddr | Network address. |
| NetConn_Route | NetConn_Route | Route configuration. |
| NetConn_HttpProxy | NetConn_HttpProxy | Proxy configuration. |
| NetConn_ConnectionProperties | NetConn_ConnectionProperties | Network connection properties. |
| NetConn_NetHandleList | NetConn_NetHandleList | Network list. |
| NetConn_NetSpecifier | NetConn_NetSpecifier | Network feature sets. |
| NetConn_NetConnCallback | NetConn_NetConnCallback | Network status callback. |
| NetConn_ProbeResultInfo | NetConn_ProbeResultInfo | Probe result. |
| NetConn_TraceRouteOption | NetConn_TraceRouteOption | Network trace route options. |
| NetConn_TraceRouteInfo | NetConn_TraceRouteInfo | Trace route information. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| NetConn_NetCap | NetConn_NetCap | Network capability set. |
| NetConn_NetBearerType | NetConn_NetBearerType | Network carrier type. |
| NetConn_ErrorCode | NetConn_ErrorCode | Network connection error code. |
| NetConn_PacketsType | NetConn_PacketsType | Trace route packet type. |
Macros
| Name | Description |
|---|---|
| NETCONN_MAX_RTT_NUM 4 | Length of the rtt array of the NetConn_ProbeResultInfo member variable. Since: 11 |
| NETCONN_MAX_NET_SIZE 32 | Length of the netHandles array of the NetConn_NetHandleList member variable. Since: 11 |
| NETCONN_MAX_BEARER_TYPE_SIZE 32 | Length of the bearerTypes array of the NetConn_NetCapabilities member variable. Since: 11 |
| NETCONN_MAX_CAP_SIZE 32 | Length of the netCaps array of the NetConn_NetCapabilities member variable. Since: 11 |
| NETCONN_MAX_ADDR_SIZE 32 | Length of the netAddrList and dnsList arrays of the NetConn_ConnectionProperties member variable. Since: 11 |
| NETCONN_MAX_ROUTE_SIZE 64 | Length of routeList array of NetConn_ConnectionProperties member variable. Since: 11 |
| NETCONN_MAX_EXCLUSION_SIZE 256 | Length of the exclusionList array of NetConn_HttpProxy member variable. Since: 11 |
| NETCONN_MAX_STR_LEN 256 | Length of the host array of NetConn_HttpProxy member variable. Since: 11 |
Functions
| Name | typedef Keyword | Description |
|---|---|---|
| typedef int (*OH_NetConn_CustomDnsResolver)(const char *host, const char *serv,const struct addrinfo *hint, struct addrinfo **res) | OH_NetConn_CustomDnsResolver | Pointer to the custom DNS resolver. |
| typedef void (*OH_NetConn_AppHttpProxyChange)(NetConn_HttpProxy *proxy) | OH_NetConn_AppHttpProxyChange | Callback invoked when the HTTP proxy information of the application changes. |
| typedef void (*OH_NetConn_NetworkAvailable)(NetConn_NetHandle *netHandle) | OH_NetConn_NetworkAvailable | Callback invoked when the network is available. |
| typedef void (*OH_NetConn_NetCapabilitiesChange)(NetConn_NetHandle *netHandle,NetConn_NetCapabilities *netCapabilities) | OH_NetConn_NetCapabilitiesChange | Callback invoked when the network capabilities change. |
| typedef void (*OH_NetConn_NetConnectionPropertiesChange)(NetConn_NetHandle *netHandle,NetConn_ConnectionProperties *connConnetionProperties) | OH_NetConn_NetConnectionPropertiesChange | Callback invoked when network connection properties change. |
| typedef void (*OH_NetConn_NetLost)(NetConn_NetHandle *netHandle) | OH_NetConn_NetLost | Callback invoked when the network is disconnected. |
| typedef void (*OH_NetConn_NetUnavailable)(void) | OH_NetConn_NetUnavailable | Callback invoked when the network is unavailable. This callback is triggered when the network is not activated within the specified timeout interval. If the timeout interval is not set, this callback is not triggered. |
| typedef void (*OH_NetConn_NetBlockStatusChange)(NetConn_NetHandle *netHandle, bool blocked) | OH_NetConn_NetBlockStatusChange | Callback invoked when the network blocking status changes. |
Enum Description
NetConn_NetCap
enum NetConn_NetCap
Description
Enumerates the network capabilities.
Since: 11
| Enum Item | Description |
|---|---|
| NETCONN_NET_CAPABILITY_MMS = 0 | MMS. |
| NETCONN_NET_CAPABILITY_NOT_METERED = 11 | Non-metered network. |
| NETCONN_NET_CAPABILITY_INTERNET = 12 | Internet. |
| NETCONN_NET_CAPABILITY_NOT_VPN = 15 | Non-VPN. |
| NETCONN_NET_CAPABILITY_VALIDATED = 16 | Verified. |
| NETCONN_NET_CAPABILITY_PORTAL = 17 | Portal. Since: 12 |
| NETCONN_NET_CAPABILITY_CHECKING_CONNECTIVITY = 31 | Connectivity check. Since: 12 |
NetConn_NetBearerType
enum NetConn_NetBearerType
Description
Enumerates the network carrier types.
Since: 11
| Enum Item | Description |
|---|---|
| NETCONN_BEARER_CELLULAR = 0 | Cellular network. |
| NETCONN_BEARER_WIFI = 1 | Wi-Fi. |
| NETCONN_BEARER_BLUETOOTH = 2 | Bluetooth. Since: 12 |
| NETCONN_BEARER_ETHERNET = 3 | Ethernet. |
| NETCONN_BEARER_VPN = 4 | VPN. Since: 12 |
NetConn_ErrorCode
enum NetConn_ErrorCode
Description
Enumerates network connection error codes.
Since: 15
| Enum Item | Description |
|---|---|
| NETCONN_SUCCESS = 0 | Success. |
| NETCONN_PERMISSION_DENIED = 201 | Missing permissions. |
| NETCONN_PARAMETER_ERROR = 401 | Invalid parameter. |
| NETCONN_OPERATION_FAILED = 2100002 | Service connection failure. |
| NETCONN_INTERNAL_ERROR = 2100003 | Internal error.1. Memory-related error, for example, insufficient memory, memory data copy failure, or memory request failure.2. Null pointer, for example, access to a released memory pointer. |
NetConn_PacketsType
enum NetConn_PacketsType
Description
Enumerates trace route packet types.
Since: 20
| Enum Item | Description |
|---|---|
| NETCONN_PACKETS_ICMP = 0 | Internet Control Message Protocol. |
| NETCONN_PACKETS_UDP = 1 | User Datagram Protocol. |
Function Description
OH_NetConn_CustomDnsResolver()
typedef int (*OH_NetConn_CustomDnsResolver)(const char *host, const char *serv,const struct addrinfo *hint, struct addrinfo **res)
Description
Defines the pointer to the custom DNS resolver.
Since: 11
Parameters
| Name | Description |
|---|---|
| const char *host | Host name. |
| const char *serv | Service name. |
| const struct addrinfo *hint | Pointer to the addrinfo structure. |
| struct addrinfo **res | DNS query result, which is in the format of linked lists. |
OH_NetConn_AppHttpProxyChange()
typedef void (*OH_NetConn_AppHttpProxyChange)(NetConn_HttpProxy *proxy)
Description
Defines the callback invoked when the HTTP proxy information of the application changes.
Since: 12
Parameters
| Name | Description |
|---|---|
| NetConn_HttpProxy *proxy | Proxy configuration information (probably a null pointer). |
OH_NetConn_NetworkAvailable()
typedef void (*OH_NetConn_NetworkAvailable)(NetConn_NetHandle *netHandle)
Description
Defines the callback invoked when the network is available.
Since: 12
Parameters
| Name | Description |
|---|---|
| NetConn_NetHandle *netHandle | Network handle. |
OH_NetConn_NetCapabilitiesChange()
typedef void (*OH_NetConn_NetCapabilitiesChange)(NetConn_NetHandle *netHandle,NetConn_NetCapabilities *netCapabilities)
Description
Defines the callback invoked when the network capabilities change.
Since: 12
Parameters
| Name | Description |
|---|---|
| NetConn_NetHandle *netHandle | Network handle. |
| NetConn_NetCapabilities *netCapabilities | Network capability set. |
OH_NetConn_NetConnectionPropertiesChange()
typedef void (*OH_NetConn_NetConnectionPropertiesChange)(NetConn_NetHandle *netHandle,NetConn_ConnectionProperties *connConnetionProperties)
Description
Defines the callback invoked when network connection properties change.
Since: 12
Parameters
| Name | Description |
|---|---|
| NetConn_NetHandle *netHandle | Network handle. |
| NetConn_ConnectionProperties *connConnetionProperties | Network connection properties. |
OH_NetConn_NetLost()
typedef void (*OH_NetConn_NetLost)(NetConn_NetHandle *netHandle)
Description
Defines the callback invoked when the network is disconnected.
Since: 12
Parameters
| Name | Description |
|---|---|
| NetConn_NetHandle *netHandle | Network handle. |
OH_NetConn_NetUnavailable()
typedef void (*OH_NetConn_NetUnavailable)(void)
Description
Defines the callback invoked when the network is unavailable. This callback is triggered when the network is not activated within the specified timeout interval. If the timeout interval is not set, this callback is not triggered.
Since: 12
OH_NetConn_NetBlockStatusChange()
typedef void (*OH_NetConn_NetBlockStatusChange)(NetConn_NetHandle *netHandle, bool blocked)
Description
Defines the callback invoked when the network blocking status changes.
Since: 12
Parameters
| Name | Description |
|---|---|
| NetConn_NetHandle *netHandle | Network handle. |
| bool blocked | Whether the network is blocked. The value true indicates that the network is blocked, and the value false indicates the opposite. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-netconnection-netconn-connectionproperties
openharmony 鸿蒙 errorcode-net-mdns
openharmony 鸿蒙 js-apis-net-ethernet-sys
openharmony 鸿蒙 errorcode-net-http
openharmony 鸿蒙 capi-netstack-http-proxy
openharmony 鸿蒙 js-apis-system-fetch
openharmony 鸿蒙 errorcode-kernel
openharmony 鸿蒙 capi-netstack-netstack-certblob