1# NetConnection 2 3 4## Overview 5 6Provides the C APIs of the network connection module for network management. 7 8**Since**: 11 9 10 11## Summary 12 13 14### File 15 16| Name| Description| 17| -------- | -------- | 18| [net_connection.h](net__connection_8h.md) | Provides the C APIs of the network connection module for network management.<br>**File to include**: \<network\/netmanager\/net_connection.h\>| 19| [net_connection_type.h](net__connection__type_8h.md) | Declares the structs for the C APIs of the network connection module.<br>**File to include**: \<network\/netmanager\/net_connection_type.h\>| 20 21 22### Structs 23 24| Name| Description| 25| -------- | -------- | 26| [NetConn_NetHandle](_net_conn___net_handle.md) | Network ID.| 27| [NetConn_NetCapabilities](_net_conn___net_capabilities.md) | Network capability set.| 28| [NetConn_NetAddr](_net_conn___net_addr.md) | Network address.| 29| [NetConn_Route](_net_conn___route.md) | Route configuration.| 30| [NetConn_HttpProxy](_net_conn___http_proxy.md) | Proxy configuration.| 31| [NetConn_ConnectionProperties](_net_conn___connection_properties.md) | Network connection information.| 32| [NetConn_NetHandleList](_net_conn___net_handle_list.md) | Network list.| 33| [NetConn_NetConnCallback](_net_conn___net_conn_callback.md) | Defines network status callbacks.| 34| [NetConn_NetSpecifier](_net_conn___net_specifier.md) | Defines the network feature set, including a network capability set and a network ID.| 35 36 37### Macros 38 39| Name| Description| 40| -------- | -------- | 41| **NETCONN_MAX_NET_SIZE** | 32 | 42| **NETCONN_MAX_BEARER_TYPE_SIZE** | 32 | 43| **NETCONN_MAX_CAP_SIZE** | 32 | 44| **NETCONN_MAX_ADDR_SIZE** | 32 | 45| **NETCONN_MAX_ROUTE_SIZE** | 64 | 46| **NETCONN_MAX_EXCLUSION_SIZE** | 256 | 47| **NETCONN_MAX_STR_LEN** | 256 | 48 49 50### Types 51 52| Name| Description| 53| -------- | -------- | 54| [NetConn_NetCap](#netconn_netcap) | Network capability set.| 55| [NetConn_NetBearerType](#netconn_netbearertype) | Network carrier type.| 56| [NetConn_NetHandle](#netconn_nethandle) | Network ID.| 57| [NetConn_NetCapabilities](#netconn_netcapabilities) | Network capability set.| 58| [NetConn_NetAddr](#netconn_netaddr) | Network address.| 59| [NetConn_Route](#netconn_route) | Route configuration.| 60| [NetConn_HttpProxy](#netconn_httpproxy) | Proxy configuration.| 61| [NetConn_ConnectionProperties](#netconn_connectionproperties) | Network connection information.| 62| [NetConn_NetHandleList](#netconn_nethandlelist) | Network list.| 63| (\*[OH_NetConn_CustomDnsResolver](#oh_netconn_customdnsresolver)) (const char \*host, const char \*serv, const struct addrinfo \*hint, struct addrinfo \*\*res) | Pointer to the custom DNS resolver.| 64| [NetConn_NetConnCallback](#netconn_netconncallback) | Defines network status callbacks.| 65| [NetConn_NetSpecifier](#netconn_netspecifier) | Defines the network feature set, including a network capability set and a network ID.| 66 67### Enums 68 69| Name| Description| 70| -------- | -------- | 71| [NetConn_NetCap](#netconn_netcap) {<br>NETCONN_NET_CAPABILITY_MMS = 0,<br>NETCONN_NET_CAPABILITY_NOT_METERED = 11,<br>NETCONN_NET_CAPABILITY_INTERNET = 12,<br>NETCONN_NET_CAPABILITY_NOT_VPN = 15,<br>NETCONN_NET_CAPABILITY_VALIDATED = 16<br>} | Network capability set.| 72| [NetConn_NetBearerType](#netconn_netbearertype) {<br>NETCONN_BEARER_CELLULAR = 0,<br>NETCONN_BEARER_WIFI = 1,<br>NETCONN_BEARER_ETHERNET = 3<br>NETCONN_BEARER_VPN = 4<br>} | Network carrier type.| 73 74 75### Functions 76 77| Name| Description| 78| -------- | -------- | 79| [OH_NetConn_HasDefaultNet](#oh_netconn_hasdefaultnet) (int32_t \*hasDefaultNet) | Checks whether a default activated data network is available.| 80| [OH_NetConn_GetDefaultNet](#oh_netconn_getdefaultnet) ([NetConn_NetHandle](_net_conn___net_handle.md) \*netHandle) | Obtains the default activated data network.| 81| [OH_NetConn_IsDefaultNetMetered](#oh_netconn_isdefaultnetmetered) (int32_t \*isMetered) | Checks whether data traffic usage on the current network is metered.| 82| [OH_NetConn_GetConnectionProperties](#oh_netconn_getconnectionproperties) ([NetConn_NetHandle](_net_conn___net_handle.md) \*netHandle, [NetConn_ConnectionProperties](_net_conn___connection_properties.md) \*prop) | Obtains the link information of a data network.| 83| [OH_NetConn_GetNetCapabilities](#oh_netconn_getnetcapabilities) ([NetConn_NetHandle](_net_conn___net_handle.md) \*netHandle, [NetConn_NetCapabilities](_net_conn___net_capabilities.md) \*netCapacities) | Obtains the capabilities of a data network.| 84| [OH_NetConn_GetDefaultHttpProxy](#oh_netconn_getdefaulthttpproxy) ([NetConn_HttpProxy](_net_conn___http_proxy.md) \*httpProxy) | Obtains the default network proxy.| 85| [OH_NetConn_GetAddrInfo](#oh_netconn_getaddrinfo) (char \*host, char \*serv, struct addrinfo \*hint, struct addrinfo \*\*res, int32_t netId) | Obtains the DNS result using **netId**.| 86| [OH_NetConn_FreeDnsResult](#oh_netconn_freednsresult) (struct addrinfo \*res) | Releases the DNS query result.| 87| [OH_NetConn_GetAllNets](#oh_netconn_getallnets) ([NetConn_NetHandleList](_net_conn___net_handle_list.md) \*netHandleList) | Obtains all activated data networks.| 88| [OHOS_NetConn_RegisterDnsResolver](#ohos_netconn_registerdnsresolver-deprecated) ([OH_NetConn_CustomDnsResolver](#oh_netconn_customdnsresolver) resolver) | Registers a custom DNS resolver.| 89| [OHOS_NetConn_UnregisterDnsResolver](#ohos_netconn_unregisterdnsresolver-deprecated) (void) | Unregisters a custom DNS resolver.| 90| [OH_NetConn_RegisterDnsResolver](#oh_netconn_registerdnsresolver) ([OH_NetConn_CustomDnsResolver](#oh_netconn_customdnsresolver) resolver) | Registers a custom DNS resolver.| 91| [OH_NetConn_UnregisterDnsResolver](#oh_netconn_unregisterdnsresolver) (void) | Unregisters a custom DNS resolver.| 92| [OH_NetConn_BindSocket](#oh_netconn_bindsocket) (int32_t socketFd, [NetConn_NetHandle](_net_conn___net_handle.md) \*netHandle) | Binds a socket to the specified network.| 93| [OH_NetConn_SetAppHttpProxy](#oh_netconn_setapphttpproxy) ([NetConn_HttpProxy](_net_conn___http_proxy.md) \*httpProxy) | Sets the application-level HTTP proxy information.| 94| [OH_NetConn_RegisterAppHttpProxyCallback](#oh_netconn_registerapphttpproxycallback) ([OH_NetConn_AppHttpProxyChange](#oh_netconn_apphttpproxychange) appHttpProxyChange, uint32_t \*callbackId) | Registers a listener for application-level proxy changes.| 95| [OH_NetConn_UnregisterAppHttpProxyCallback](#oh_netconn_unregisterapphttpproxycallback) (uint32_t callbackId) | Unregisters the listener for application-level proxy changes.| 96| [OH_NetConn_RegisterNetConnCallback](#oh_netconn_registernetconncallback) ([NetConn_NetSpecifier](_net_conn___net_specifier.md) \*specifier, [NetConn_NetConnCallback](_net_conn___net_conn_callback.md) \*netConnCallback, uint32_t timeoutMS, uint32_t \*callbackId) | Registers a callback for network status changes.| 97| [OH_NetConn_RegisterDefaultNetConnCallback](#oh_netconn_registerdefaultnetconncallback) ([NetConn_NetConnCallback](_net_conn___net_conn_callback.md) \*netConnCallback, uint32_t \*callbackId) | Registers a callback for status changes of the default network.| 98| [OH_NetConn_UnregisterNetConnCallback](#oh_netconn_unregisternetconncallback) (uint32_t callbackId) | Unregisters the callback for network status changes.| 99 100 101## Type Description 102 103 104### NetConn_ConnectionProperties 105 106``` 107typedef struct NetConn_ConnectionProperties NetConn_ConnectionProperties 108``` 109 110**Description** 111 112Network connection information. 113 114**Since**: 11 115 116 117### NetConn_HttpProxy 118 119``` 120typedef struct NetConn_HttpProxy NetConn_HttpProxy 121``` 122 123**Description** 124 125Proxy configuration. 126 127**Since**: 11 128 129 130### NetConn_NetAddr 131 132``` 133typedef struct NetConn_NetAddr NetConn_NetAddr 134``` 135 136**Description** 137 138Network address. 139 140**Since**: 11 141 142 143### NetConn_NetBearerType 144 145``` 146typedef enum NetConn_NetBearerType NetConn_NetBearerType 147``` 148 149**Description** 150 151Network carrier type. 152 153**Since**: 11 154 155 156### NetConn_NetCap 157 158``` 159typedef enum NetConn_NetCap NetConn_NetCap 160``` 161 162**Description** 163 164Network capability set. 165 166**Since**: 11 167 168 169### NetConn_NetCapabilities 170 171``` 172typedef struct NetConn_NetCapabilities NetConn_NetCapabilities 173``` 174 175**Description** 176 177Network capability set. 178 179**Since**: 11 180 181 182### NetConn_NetHandle 183 184``` 185typedef struct NetConn_NetHandle NetConn_NetHandle 186``` 187 188**Description** 189 190Network ID. 191 192**Since**: 11 193 194 195### NetConn_NetHandleList 196 197``` 198typedef struct NetConn_NetHandleList NetConn_NetHandleList 199``` 200 201**Description** 202 203Network list. 204 205**Since**: 11 206 207 208### NetConn_Route 209 210``` 211typedef struct NetConn_Route NetConn_Route 212``` 213 214**Description** 215 216Route configuration. 217 218**Since**: 11 219 220 221### OH_NetConn_CustomDnsResolver 222 223``` 224typedef int(* OH_NetConn_CustomDnsResolver) (const char *host, const char *serv, const struct addrinfo *hint, struct addrinfo **res) 225``` 226 227**Description** 228 229Pointer to the custom DNS resolver. 230 231**Since**: 11 232 233**Parameters** 234 235| Name| Description| 236| -------- | -------- | 237| host | Host name.| 238| serv | Service name.| 239| hint | Pointer to the addrinfo structure.| 240| res | DNS query result, which is in the format of linked lists.| 241 242 243### OH_NetConn_AppHttpProxyChange 244 245``` 246typedef void(* OH_NetConn_AppHttpProxyChange) (NetConn_HttpProxy *proxy) 247``` 248 249**Description** 250 251Defines the callback for application-level proxy changes. 252 253**Since**: 12 254 255**Parameters** 256 257| Name| Description| 258| -------- | -------- | 259| proxy | Proxy configuration information (probably a null pointer).| 260 261 262### NetConn_NetConnCallback 263 264``` 265typedef struct NetConn_NetConnCallback NetConn_NetConnCallback 266``` 267 268**Description** 269 270Defines network status callbacks. 271 272**Since**: 12 273 274 275### NetConn_NetSpecifier 276 277``` 278typedef struct NetConn_NetSpecifier NetConn_NetSpecifier 279``` 280 281**Description** 282 283Defines the network feature set, including a network capability set and a network ID. 284 285**Since**: 12 286 287 288## Enum Description 289 290 291### NetConn_NetBearerType 292 293``` 294enum NetConn_NetBearerType 295``` 296 297**Description** 298 299Network carrier type. 300 301**Since**: 11 302 303| Value | Description | 304| ------------------------| ----------------------- | 305| NETCONN_BEARER_CELLULAR | Cellular network. | 306| NETCONN_BEARER_WIFI | Wi-Fi. | 307| NETCONN_BEARER_BLUETOOTH | Bluetooth.<br>**Since**: 12| 308| NETCONN_BEARER_ETHERNET | Ethernet. | 309| NETCONN_BEARER_VPN | Virtual private network.<br>**Since**: 12| 310 311 312### NetConn_NetCap 313 314``` 315enum NetConn_NetCap 316``` 317 318**Description** 319 320Network capability set. 321 322**Since**: 11 323 324| Value| Description| 325| -------- | -------- | 326| NETCONN_NET_CAPABILITY_MMS | MMS.| 327| NETCONN_NET_CAPABILITY_NOT_METERED | Non-metered network.| 328| NETCONN_NET_CAPABILITY_INTERNET | Internet.| 329| NETCONN_NET_CAPABILITY_NOT_VPN | Non-VPN.| 330| NETCONN_NET_CAPABILITY_VALIDATED | Verified.| 331| NETCONN_NET_CAPABILITY_CHECKING_CONNECTIVITY | Connectivity check.<br>**Since**: 12| 332 333 334## Function Description 335 336 337### OH_NetConn_FreeDnsResult() 338 339``` 340int32_t OH_NetConn_FreeDnsResult (struct addrinfo * res) 341``` 342 343**Description** 344 345Releases the DNS query result. 346 347**System capability**: SystemCapability.Communication.NetManager.Core 348 349**Since**: 11 350 351**Parameters** 352 353| Name| Description| 354| -------- | -------- | 355| res | Header of the DNS query result, which is in the format of linked lists.| 356 357**Returns** 358 359**0**: success. 360 361**201**: no permission. 362 363**401**: parameter error. 364 365**2100002**: failed to connect to the service. 366 367**2100003**: internal error. 368 369**Required permissions**: 370 371ohos.permission.INTERNET 372 373 374### OH_NetConn_GetAddrInfo() 375 376``` 377int32_t OH_NetConn_GetAddrInfo (char * host, char * serv, struct addrinfo * hint, struct addrinfo ** res, int32_t netId ) 378``` 379 380**Description** 381 382Obtains the DNS result using **netId**. 383 384**System capability**: SystemCapability.Communication.NetManager.Core 385 386**Since**: 11 387 388**Parameters** 389 390| Name| Description| 391| -------- | -------- | 392| host | Host name.| 393| serv | Service name.| 394| hint | Pointer to the addrinfo structure.| 395| res | DNS query result, which is in the format of linked lists.| 396| netId | If **netId** is set to **0**, the default **netid** is used for query.| 397 398**Returns** 399 400**0**: success. 401 402**201**: no permission. 403 404**401**: parameter error. 405 406**2100002**: failed to connect to the service. 407 408**2100003**: internal error. 409 410**Required permissions**: 411 412ohos.permission.INTERNET 413 414 415### OH_NetConn_GetAllNets() 416 417``` 418int32_t OH_NetConn_GetAllNets (NetConn_NetHandleList * netHandleList) 419``` 420 421**Description** 422 423Obtains all activated data networks. 424 425**System capability**: SystemCapability.Communication.NetManager.Core 426 427**Since**: 11 428 429**Parameters** 430 431| Name| Description| 432| -------- | -------- | 433| netHandleList | Network information list.| 434 435**Returns** 436 437**0**: success. 438 439**201**: no permission. 440 441**401**: parameter error. 442 443**2100002**: failed to connect to the service. 444 445**2100003**: internal error. 446 447**Required permissions**: 448 449ohos.permission.GET_NETWORK_INFO 450 451 452### OH_NetConn_GetConnectionProperties() 453 454``` 455int32_t OH_NetConn_GetConnectionProperties (NetConn_NetHandle * netHandle, NetConn_ConnectionProperties * prop ) 456``` 457 458**Description** 459 460Obtains the link information of a data network. 461 462**System capability**: SystemCapability.Communication.NetManager.Core 463 464**Since**: 11 465 466**Parameters** 467 468| Name| Description| 469| -------- | -------- | 470| nethandle | Network ID.| 471| prop | Link information.| 472 473**Returns** 474 475**0**: success. 476 477**201**: no permission. 478 479**401**: parameter error. 480 481**2100002**: failed to connect to the service. 482 483**2100003**: internal error. 484 485**Required permissions**: 486 487ohos.permission.GET_NETWORK_INFO 488 489 490### OH_NetConn_GetDefaultHttpProxy() 491 492``` 493int32_t OH_NetConn_GetDefaultHttpProxy (NetConn_HttpProxy * httpProxy) 494``` 495 496**Description** 497 498Obtains the default network proxy. 499 500**System capability**: SystemCapability.Communication.NetManager.Core 501 502**Since**: 11 503 504**Parameters** 505 506| Name| Description| 507| -------- | -------- | 508| httpProxy | Proxy configuration.| 509 510**Returns** 511 512**0**: success. 513 514**201**: no permission. 515 516**401**: parameter error. 517 518**2100002**: failed to connect to the service. 519 520**2100003**: internal error. 521 522 523### OH_NetConn_GetDefaultNet() 524 525``` 526int32_t OH_NetConn_GetDefaultNet (NetConn_NetHandle * netHandle) 527``` 528 529**Description** 530 531Obtains the default activated data network. 532 533**System capability**: SystemCapability.Communication.NetManager.Core 534 535**Since**: 11 536 537**Parameters** 538 539| Name| Description| 540| -------- | -------- | 541| netHandle | Network ID.| 542 543**Returns** 544 545**0**: success. 546 547**201**: no permission. 548 549**401**: parameter error. 550 551**2100002**: failed to connect to the service. 552 553**2100003**: internal error. 554 555**Required permissions**: 556 557ohos.permission.GET_NETWORK_INFO 558 559 560### OH_NetConn_GetNetCapabilities() 561 562``` 563int32_t OH_NetConn_GetNetCapabilities (NetConn_NetHandle * netHandle, NetConn_NetCapabilities * netCapacities ) 564``` 565 566**Description** 567 568Obtains the capabilities of a data network. 569 570**System capability**: SystemCapability.Communication.NetManager.Core 571 572**Since**: 11 573 574**Parameters** 575 576| Name| Description| 577| -------- | -------- | 578| netHandle | Network ID.| 579| netCapacities | Capability set.| 580 581**Returns** 582 583**0**: success. 584 585**201**: no permission. 586 587**401**: parameter error. 588 589**2100002**: failed to connect to the service. 590 591**2100003**: internal error. 592 593**Required permissions**: 594 595ohos.permission.GET_NETWORK_INFO 596 597 598### OH_NetConn_HasDefaultNet() 599 600``` 601int32_t OH_NetConn_HasDefaultNet (int32_t * hasDefaultNet) 602``` 603 604**Description** 605 606Checks whether a default activated data network is available. 607 608**System capability**: SystemCapability.Communication.NetManager.Core 609 610**Since**: 11 611 612**Parameters** 613 614| Name| Description| 615| -------- | -------- | 616| hasDefaultNet | Whether there is a default network.| 617 618**Returns** 619 620**0**: success. 621 622**201**: no permission. 623 624**401**: parameter error. 625 626**2100002**: failed to connect to the service. 627 628**2100003**: internal error. 629 630**Required permissions**: 631 632ohos.permission.GET_NETWORK_INFO 633 634 635### OH_NetConn_IsDefaultNetMetered() 636 637``` 638int32_t OH_NetConn_IsDefaultNetMetered (int32_t * isMetered) 639``` 640 641**Description** 642 643Checks whether metering is enabled for the default data network. 644 645**System capability**: SystemCapability.Communication.NetManager.Core 646 647**Since**: 11 648 649**Parameters** 650 651| Name| Description| 652| -------- | -------- | 653| isMetered | Whether metering is enabled.| 654 655**Returns** 656 657**0**: success. 658 659**201**: no permission. 660 661**401**: parameter error. 662 663**2100002**: failed to connect to the service. 664 665**2100003**: internal error. 666 667**Required permissions**: 668 669ohos.permission.GET_NETWORK_INFO 670 671 672### OHOS_NetConn_RegisterDnsResolver() <sup>(deprecated)</sup> 673 674``` 675int32_t OHOS_NetConn_RegisterDnsResolver (OH_NetConn_CustomDnsResolver resolver) 676``` 677 678**Description** 679 680Registers a custom DNS resolver. 681 682**System capability**: SystemCapability.Communication.NetManager.Core 683 684**Since**: 11 685 686**Deprecated from**: 13 687 688**Substitute API**: [OH_NetConn_RegisterDnsResolver](#oh_netconn_registerdnsresolver) 689 690**Parameters** 691 692| Name| Description| 693| -------- | -------- | 694| resolver | Pointer to the custom DNS resolver.| 695 696**Returns** 697 698**0**: success. 699 700**201**: no permission. 701 702**401**: parameter error. 703 704**2100002**: failed to connect to the service. 705 706**2100003**: internal error. 707 708**Required permissions**: 709 710ohos.permission.INTERNET 711 712 713### OHOS_NetConn_UnregisterDnsResolver() <sup>(deprecated)</sup> 714 715``` 716int32_t OHOS_NetConn_UnregisterDnsResolver (void ) 717``` 718 719**Description** 720 721Unregisters a custom DNS resolver. 722 723**System capability**: SystemCapability.Communication.NetManager.Core 724 725**Since**: 11 726 727**Deprecated from**: 13 728 729**Substitute API**: [OH_NetConn_UnregisterDnsResolver](#oh_netconn_unregisterdnsresolver) 730 731**Returns** 732 733**0**: success. 734 735**201**: no permission. 736 737**401**: parameter error. 738 739**2100002**: failed to connect to the service. 740 741**2100003**: internal error. 742 743**Required permissions**: 744 745ohos.permission.INTERNET 746 747 748### OH_NetConn_RegisterDnsResolver() 749 750``` 751int32_t OH_NetConn_RegisterDnsResolver (OH_NetConn_CustomDnsResolver resolver) 752``` 753 754**Description** 755 756Registers a custom DNS resolver. 757 758**System capability**: SystemCapability.Communication.NetManager.Core 759 760**Since**: 13 761 762**Parameters** 763 764| Name| Description| 765| -------- | -------- | 766| resolver | Pointer to the custom DNS resolver.| 767 768**Returns** 769 770**0**: success. 771 772**201**: no permission. 773 774**401**: parameter error. 775 776**2100002**: failed to connect to the service. 777 778**2100003**: internal error. 779 780**Required permissions**: 781 782ohos.permission.INTERNET 783 784 785### OH_NetConn_UnregisterDnsResolver() 786 787``` 788int32_t OH_NetConn_UnregisterDnsResolver (void ) 789``` 790 791**Description** 792 793Unregisters a custom DNS resolver. 794 795**System capability**: SystemCapability.Communication.NetManager.Core 796 797**Since**: 13 798 799**Returns** 800 801**0**: success. 802 803**201**: no permission. 804 805**401**: parameter error. 806 807**2100002**: failed to connect to the service. 808 809**2100003**: internal error. 810 811**Required permissions**: 812 813ohos.permission.INTERNET 814 815 816### OH_NetConn_BindSocket() 817 818``` 819int32_t OH_NetConn_BindSocket (int32_t socketFd, NetConn_NetHandle * netHandle) 820``` 821 822**Description** 823 824Binds a socket to the specified network. 825 826**System capability**: SystemCapability.Communication.NetManager.Core 827 828**Since**: 12 829 830**Parameters** 831 832| Name| Description| 833| -------- | -------- | 834| socketFd | File descriptor of the socket created by the user.| 835| netHandle | Network ID.| 836 837**Returns** 838 839**0**: success. 840 841**401**: parameter error. 842 843**2100002**: failed to connect to the service. 844 845**2100003**: internal error. 846 847 848### OH_NetConn_SetAppHttpProxy() 849 850``` 851int32_t OH_NetConn_SetAppHttpProxy(NetConn_HttpProxy *httpProxy) 852``` 853 854**Description** 855 856Sets the application-level proxy configuration. 857 858**System capability**: SystemCapability.Communication.NetManager.Core 859 860**Since**: 12 861 862**Parameters** 863 864| Name| Description| 865| -------- | -------- | 866| httpProxy | Application-level proxy configuration.| 867 868**Returns** 869 870**0**: success. 871 872**401**: parameter error. 873 874 875### OH_NetConn_RegisterAppHttpProxyCallback() 876 877``` 878int32_t OH_NetConn_RegisterAppHttpProxyCallback(OH_NetConn_AppHttpProxyChange appHttpProxyChange, uint32_t *callbackId) 879``` 880 881**Description** 882 883Registers a callback for application-level proxy changes. 884 885**System capability**: SystemCapability.Communication.NetManager.Core 886 887**Since**: 12 888 889**Parameters** 890 891| Name| Description| 892| -------- | -------- | 893| appHttpProxyChange | Pointer to the callback for application-level proxy changes.| 894| callbackId | Callback ID.| 895 896**Returns** 897 898**0**: success. 899 900**401**: parameter error. 901 902 903### OH_NetConn_UnregisterAppHttpProxyCallback() 904 905``` 906void OH_NetConn_UnregisterAppHttpProxyCallback(uint32_t callbackId) 907``` 908 909**Description** 910 911Unregisters the callback for application-level proxy changes. 912 913**System capability**: SystemCapability.Communication.NetManager.Core 914 915**Since**: 12 916 917**Parameters** 918 919| Name| Description| 920| -------- | -------- | 921| callbackId | Callback ID, which is obtained during registration.| 922 923 924### OH_NetConn_RegisterNetConnCallback() 925 926``` 927int32_t OH_NetConn_RegisterNetConnCallback(NetConn_NetSpecifier *specifier, NetConn_NetConnCallback *netConnCallback, uint32_t timeout, uint32_t *callbackId) 928``` 929 930**Description** 931 932Registers a callback to for status changes of the specified network. 933 934**System capability**: SystemCapability.Communication.NetManager.Core 935 936**Since**: 12 937 938**Parameters** 939 940| Name| Description| 941| -------- | -------- | 942| specifier | Network feature set.| 943| netConnCallback | Registered callbacks.| 944| timeout | Waiting time, in milliseconds. The value **0** indicates infinite waiting.| 945| callbackId | Callback IDs.| 946 947**Returns** 948 949**0**: success. 950 951**201**: no permission. 952 953**401**: parameter error. 954 955**2100002**: failed to connect to the service. 956 957**2100003**: internal error. 958 959**2101008**: The callback has been registered. 960 961**2101022**: The maximum number of requests is exceeded. 962 963**Required permissions**: 964 965ohos.permission.GET_NETWORK_INFO 966 967 968### OH_NetConn_RegisterDefaultNetConnCallback() 969 970``` 971int32_t OH_NetConn_RegisterDefaultNetConnCallback(NetConn_NetConnCallback *netConnCallback, uint32_t *callbackId) 972``` 973 974**Description** 975 976Registers a callback to for status changes of the default network. 977 978**System capability**: SystemCapability.Communication.NetManager.Core 979 980**Since**: 12 981 982**Parameters** 983 984| Name| Description| 985| -------- | -------- | 986| netConnCallback | Registered callbacks.| 987| callbackId | Callback IDs.| 988 989**Returns** 990 991**0**: success. 992 993**201**: no permission. 994 995**401**: parameter error. 996 997**2100002**: failed to connect to the service. 998 999**2100003**: internal error. 1000 1001**2101008**: The callback has been registered. 1002 1003**2101022**: The maximum number of requests is exceeded. 1004 1005**Required permissions**: 1006 1007ohos.permission.GET_NETWORK_INFO 1008 1009 1010### OH_NetConn_UnregisterNetConnCallback() 1011 1012``` 1013int32_t OH_NetConn_UnregisterNetConnCallback(uint32_t callBackId) 1014``` 1015 1016**Description** 1017 1018Unregisters the callback for network status changes. 1019 1020**System capability**: SystemCapability.Communication.NetManager.Core 1021 1022**Since**: 12 1023 1024**Parameters** 1025 1026| Name| Description| 1027| -------- | -------- | 1028| callBackId | Callback ID.| 1029 1030**Returns** 1031 1032**0**: success. 1033 1034**201**: no permission. 1035 1036**401**: parameter error. 1037 1038**2100002**: failed to connect to the service. 1039 1040**2100003**: internal error. 1041 1042**2101007**: The corresponding callback is not found. 1043 1044**Required permissions**: 1045 1046ohos.permission.GET_NETWORK_INFO 1047