• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# net_connection.h
2
3## Overview
4
5Provides the C APIs of the network connection module for network management.
6
7**File to include**: <network/netmanager/net_connection.h>
8
9**Library**: libnet_connection.so
10
11**System capability**: SystemCapability.Communication.NetManager.Core
12
13**Since**: 11
14
15**Related module**: [NetConnection](capi-netconnection.md)
16
17## Summary
18
19### Functions
20
21| Name| Description|
22| -- | -- |
23| [int32_t OH_NetConn_HasDefaultNet(int32_t *hasDefaultNet)](#oh_netconn_hasdefaultnet) | Checks whether a default activated data network is available.|
24| [int32_t OH_NetConn_GetDefaultNet(NetConn_NetHandle *netHandle)](#oh_netconn_getdefaultnet) | Obtains the default activated data network.|
25| [int32_t OH_NetConn_IsDefaultNetMetered(int32_t *isMetered)](#oh_netconn_isdefaultnetmetered) | Checks whether data traffic usage on the current network is metered.|
26| [int32_t OH_NetConn_GetConnectionProperties(NetConn_NetHandle *netHandle, NetConn_ConnectionProperties *prop)](#oh_netconn_getconnectionproperties) | Obtains the link information of a data network.|
27| [int32_t OH_NetConn_GetNetCapabilities(NetConn_NetHandle *netHandle, NetConn_NetCapabilities *netCapabilities)](#oh_netconn_getnetcapabilities) | Obtains the capabilities of a data network.|
28| [int32_t OH_NetConn_GetDefaultHttpProxy(NetConn_HttpProxy *httpProxy)](#oh_netconn_getdefaulthttpproxy) | Obtains the default network proxy.|
29| [int32_t OH_NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, struct addrinfo **res, int32_t netId)](#oh_netconn_getaddrinfo) | Obtains the DNS result based on the specified **netId**.|
30| [int32_t OH_NetConn_FreeDnsResult(struct addrinfo *res)](#oh_netconn_freednsresult) | Releases the DNS query result.|
31| [int32_t OH_NetConn_GetAllNets(NetConn_NetHandleList *netHandleList)](#oh_netconn_getallnets) | Obtains all activated data networks.|
32| [int32_t OHOS_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver)](#ohos_netconn_registerdnsresolver) | Registers a custom DNS resolver.|
33| [int32_t OHOS_NetConn_UnregisterDnsResolver(void)](#ohos_netconn_unregisterdnsresolver) | Unregisters a custom DNS resolver.|
34| [int32_t OH_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver)](#oh_netconn_registerdnsresolver) | Registers a custom DNS resolver.|
35| [int32_t OH_NetConn_UnregisterDnsResolver(void)](#oh_netconn_unregisterdnsresolver) | Unregisters a custom DNS resolver.|
36| [int32_t OH_NetConn_BindSocket(int32_t socketFd, NetConn_NetHandle *netHandle)](#oh_netconn_bindsocket) | Binds a socket to the specified network.|
37| [int32_t OH_NetConn_SetAppHttpProxy(NetConn_HttpProxy *httpProxy)](#oh_netconn_setapphttpproxy) | Sets an HTTP proxy for the current application.|
38| [int32_t OH_NetConn_RegisterAppHttpProxyCallback(OH_NetConn_AppHttpProxyChange appHttpProxyChange, uint32_t *callbackId)](#oh_netconn_registerapphttpproxycallback) | Registers a callback for application-level HTTP proxy changes.|
39| [void OH_NetConn_UnregisterAppHttpProxyCallback(uint32_t callbackId)](#oh_netconn_unregisterapphttpproxycallback) | Unregisters the callback for HTTP proxy changes of the application.|
40| [int32_t OH_NetConn_RegisterNetConnCallback(NetConn_NetSpecifier *specifier, NetConn_NetConnCallback *netConnCallback,uint32_t timeout, uint32_t *callbackId)](#oh_netconn_registernetconncallback) | Registers a callback for network status changes.|
41| [int32_t OH_NetConn_RegisterDefaultNetConnCallback(NetConn_NetConnCallback *netConnCallback, uint32_t *callbackId)](#oh_netconn_registerdefaultnetconncallback) | Registers a callback for status changes of the default network.|
42| [int32_t OH_NetConn_UnregisterNetConnCallback(uint32_t callBackId)](#oh_netconn_unregisternetconncallback) | Unregisters the callback for network status changes.|
43| [NetConn_ErrorCode OH_NetConn_SetPacUrl(const char *pacUrl)](#oh_netconn_setpacurl) | Sets the URL of the system-level proxy auto-config (PAC) script.|
44| [NetConn_ErrorCode OH_NetConn_GetPacUrl(char *pacUrl)](#oh_netconn_getpacurl) | Obtains the URL of the system-level PAC script.|
45| [int32_t OH_NetConn_QueryProbeResult(char *destination, int32_t duration, NetConn_ProbeResultInfo *probeResultInfo)](#oh_netconn_queryproberesult) | Queries network probe results.|
46| [int32_t OH_NetConn_QueryTraceRoute(char *destination, NetConn_TraceRouteOption *option,NetConn_TraceRouteInfo *traceRouteInfo)](#oh_netconn_querytraceroute) | Queries network trace route information.|
47
48
49## Function Description
50
51### OH_NetConn_HasDefaultNet()
52
53```
54int32_t OH_NetConn_HasDefaultNet(int32_t *hasDefaultNet)
55```
56
57**Description**
58
59Checks whether a default activated data network is available.
60
61**System capability**: SystemCapability.Communication.NetManager.Core
62
63**Required permissions**: ohos.permission.GET_NETWORK_INFO
64
65**Since**: 11
66
67
68**Parameters**
69
70| Name| Description|
71| -- | -- |
72| int32_t *hasDefaultNet | Whether there is a default network.|
73
74**Returns**
75
76| Type| Description|
77| -- | -- |
78| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
79
80### OH_NetConn_GetDefaultNet()
81
82```
83int32_t OH_NetConn_GetDefaultNet(NetConn_NetHandle *netHandle)
84```
85
86**Description**
87
88Obtains the default activated data network.
89
90**System capability**: SystemCapability.Communication.NetManager.Core
91
92**Required permissions**: ohos.permission.GET_NETWORK_INFO
93
94**Since**: 11
95
96
97**Parameters**
98
99| Name| Description|
100| -- | -- |
101| [NetConn_NetHandle](capi-netconnection-netconn-nethandle.md) *netHandle | Network ID.|
102
103**Returns**
104
105| Type| Description|
106| -- | -- |
107| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
108
109### OH_NetConn_IsDefaultNetMetered()
110
111```
112int32_t OH_NetConn_IsDefaultNetMetered(int32_t *isMetered)
113```
114
115**Description**
116
117Checks whether metering is enabled for the default data network.
118
119**System capability**: SystemCapability.Communication.NetManager.Core
120
121**Required permissions**: ohos.permission.GET_NETWORK_INFO
122
123**Since**: 11
124
125
126**Parameters**
127
128| Name| Description|
129| -- | -- |
130| int32_t *isMetered | Whether metering is enabled.|
131
132**Returns**
133
134| Type| Description|
135| -- | -- |
136| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
137
138### OH_NetConn_GetConnectionProperties()
139
140```
141int32_t OH_NetConn_GetConnectionProperties(NetConn_NetHandle *netHandle, NetConn_ConnectionProperties *prop)
142```
143
144**Description**
145
146Obtains the link information of a data network.
147
148**System capability**: SystemCapability.Communication.NetManager.Core
149
150**Required permissions**: ohos.permission.GET_NETWORK_INFO
151
152**Since**: 11
153
154
155**Parameters**
156
157| Name| Description|
158| -- | -- |
159| [NetConn_NetHandle](capi-netconnection-netconn-nethandle.md) *netHandle | Network ID.|
160| [NetConn_ConnectionProperties](capi-netconnection-netconn-connectionproperties.md) *prop | Link information.|
161
162**Returns**
163
164| Type| Description|
165| -- | -- |
166| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
167
168### OH_NetConn_GetNetCapabilities()
169
170```
171int32_t OH_NetConn_GetNetCapabilities(NetConn_NetHandle *netHandle, NetConn_NetCapabilities *netCapabilities)
172```
173
174**Description**
175
176Obtains the capabilities of a data network.
177
178**System capability**: SystemCapability.Communication.NetManager.Core
179
180**Required permissions**: ohos.permission.GET_NETWORK_INFO
181
182**Since**: 11
183
184
185**Parameters**
186
187| Name                                                                    | Description|
188|-------------------------------------------------------------------------| -- |
189| [NetConn_NetHandle](capi-netconnection-netconn-nethandle.md) *netHandle | Network ID.|
190| [NetConn_NetCapabilities](capi-netconnection-netconn-netcapabilities.md) *netCapabilities                            | Capability set.|
191
192**Returns**
193
194| Type| Description|
195| -- | -- |
196| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
197
198### OH_NetConn_GetDefaultHttpProxy()
199
200```
201int32_t OH_NetConn_GetDefaultHttpProxy(NetConn_HttpProxy *httpProxy)
202```
203
204**Description**
205
206Obtains the default network proxy.
207
208**System capability**: SystemCapability.Communication.NetManager.Core
209
210**Since**: 11
211
212
213**Parameters**
214
215| Name| Description|
216| -- | -- |
217| [NetConn_HttpProxy](capi-netconnection-netconn-httpproxy.md) *httpProxy | Proxy configuration.|
218
219**Returns**
220
221| Type| Description|
222| -- | -- |
223| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
224
225### OH_NetConn_GetAddrInfo()
226
227```
228int32_t OH_NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, struct addrinfo **res, int32_t netId)
229```
230
231**Description**
232
233Obtains the DNS result based on the specified **netId**.
234
235**System capability**: SystemCapability.Communication.NetManager.Core
236
237**Required permission**: ohos.permission.INTERNET
238
239**Since**: 11
240
241
242**Parameters**
243
244| Name| Description|
245| -- | -- |
246| char *host | Host name.|
247| char *serv | Service name.|
248| struct addrinfo *hint | Pointer to the addrinfo structure.|
249| struct addrinfo **res | DNS query result, which is in the format of linked lists.|
250| int32_t netId | If **netId** is set to **0**, the default **netid** is used for query.|
251
252**Returns**
253
254| Type| Description|
255| -- | -- |
256| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
257
258### OH_NetConn_FreeDnsResult()
259
260```
261int32_t OH_NetConn_FreeDnsResult(struct addrinfo *res)
262```
263
264**Description**
265
266Releases the DNS query result.
267
268**System capability**: SystemCapability.Communication.NetManager.Core
269
270**Required permission**: ohos.permission.INTERNET
271
272**Since**: 11
273
274
275**Parameters**
276
277| Name| Description|
278| -- | -- |
279| struct addrinfo *res | Header of the DNS query result, which is in the format of linked lists.|
280
281**Returns**
282
283| Type| Description|
284| -- | -- |
285| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
286
287### OH_NetConn_GetAllNets()
288
289```
290int32_t OH_NetConn_GetAllNets(NetConn_NetHandleList *netHandleList)
291```
292
293**Description**
294
295Obtains all activated data networks.
296
297**System capability**: SystemCapability.Communication.NetManager.Core
298
299**Required permissions**: ohos.permission.GET_NETWORK_INFO
300
301**Since**: 11
302
303
304**Parameters**
305
306| Name| Description|
307| -- | -- |
308| [NetConn_NetHandleList](capi-netconnection-netconn-nethandlelist.md) *netHandleList | Network information list.|
309
310**Returns**
311
312| Type| Description|
313| -- | -- |
314| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
315
316### OHOS_NetConn_RegisterDnsResolver()
317
318```
319int32_t OHOS_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver)
320```
321
322**Description**
323
324Registers a custom DNS resolver.
325
326**System capability**: SystemCapability.Communication.NetManager.Core
327
328**Required permission**: ohos.permission.INTERNET
329
330**Since**: 11
331
332**Deprecated from**: 13
333
334**Substitute**: OH_NetConn_RegisterDnsResolver
335
336
337**Parameters**
338
339| Name| Description|
340| -- | -- |
341| [OH_NetConn_CustomDnsResolver](capi-net-connection-type-h.md#oh_netconn_customdnsresolver) resolver | Pointer to the custom DNS resolver.|
342
343**Returns**
344
345| Type| Description|
346| -- | -- |
347| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
348
349### OHOS_NetConn_UnregisterDnsResolver()
350
351```
352int32_t OHOS_NetConn_UnregisterDnsResolver(void)
353```
354
355**Description**
356
357Unregisters a custom DNS resolver.
358
359**System capability**: SystemCapability.Communication.NetManager.Core
360
361**Required permission**: ohos.permission.INTERNET
362
363**Since**: 11
364
365**Deprecated from**: 13
366
367**Substitute**: OH_NetConn_UnregisterDnsResolver
368
369**Returns**
370
371| Type| Description|
372| -- | -- |
373| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
374
375### OH_NetConn_RegisterDnsResolver()
376
377```
378int32_t OH_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver)
379```
380
381**Description**
382
383Registers a custom DNS resolver.
384
385**System capability**: SystemCapability.Communication.NetManager.Core
386
387**Required permission**: ohos.permission.INTERNET
388
389**Since**: 13
390
391
392**Parameters**
393
394| Name| Description|
395| -- | -- |
396| Pointer to the custom DNS resolver.|  |
397
398**Returns**
399
400| Type| Description|
401| -- | -- |
402| int32_t | Result code.<br>         **NETMANAGER_EXT_SUCCESS**: Operation success.<br>         **NETMANAGER_ERR_PERMISSION_DENIED**: Permission denied.<br>         **NETMANAGER_ERR_PARAMETER_ERROR**: Parameter error. Enter a correct parameter.|
403
404### OH_NetConn_UnregisterDnsResolver()
405
406```
407int32_t OH_NetConn_UnregisterDnsResolver(void)
408```
409
410**Description**
411
412Unregisters a custom DNS resolver.
413
414**System capability**: SystemCapability.Communication.NetManager.Core
415
416**Required permission**: ohos.permission.INTERNET
417
418**Since**: 13
419
420**Returns**
421
422| Type| Description|
423| -- | -- |
424| int32_t | **0**: Success. **201**: Missing permissions.<br>         **401**: Parameter error. **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
425
426### OH_NetConn_BindSocket()
427
428```
429int32_t OH_NetConn_BindSocket(int32_t socketFd, NetConn_NetHandle *netHandle)
430```
431
432**Description**
433
434Binds a socket to the specified network.
435
436**System capability**: SystemCapability.Communication.NetManager.Core
437
438**Since**: 12
439
440
441**Parameters**
442
443| Name| Description|
444| -- | -- |
445| int32_t socketFd | Socket constructed by the user.|
446| [NetConn_NetHandle](capi-netconnection-netconn-nethandle.md) *netHandle | Pointer to the network handle containing the network ID.|
447
448**Returns**
449
450| Type| Description|
451| -- | -- |
452| int32_t | **0**: Success.<br>         **401**: Parameter error.<br>         **2100002**: Service connection failure.<br>         **2100003**: Internal error.|
453
454### OH_NetConn_SetAppHttpProxy()
455
456```
457int32_t OH_NetConn_SetAppHttpProxy(NetConn_HttpProxy *httpProxy)
458```
459
460**Description**
461
462Sets an HTTP proxy for the current application.
463
464**System capability**: SystemCapability.Communication.NetManager.Core
465
466**Since**: 12
467
468
469**Parameters**
470
471| Name| Description|
472| -- | -- |
473| [NetConn_HttpProxy](capi-netconnection-netconn-httpproxy.md) *httpProxy | HTTP proxy to set.|
474
475**Returns**
476
477| Type| Description|
478| -- | -- |
479| int32_t | **0**: Success.<br>         **401**: Parameter error.|
480
481### OH_NetConn_RegisterAppHttpProxyCallback()
482
483```
484int32_t OH_NetConn_RegisterAppHttpProxyCallback(OH_NetConn_AppHttpProxyChange appHttpProxyChange, uint32_t *callbackId)
485```
486
487**Description**
488
489Registers a callback for HTTP proxy changes of the application.
490
491**System capability**: SystemCapability.Communication.NetManager.Core
492
493**Since**: 12
494
495
496**Parameters**
497
498| Name| Description|
499| -- | -- |
500| [OH_NetConn_AppHttpProxyChange](capi-net-connection-type-h.md#oh_netconn_apphttpproxychange) appHttpProxyChange | Callback to register.|
501| uint32_t *callbackId | ID of the registered callback.|
502
503**Returns**
504
505| Type| Description|
506| -- | -- |
507| int32_t | **0**: Success.<br>         **401**: Parameter error.|
508
509### OH_NetConn_UnregisterAppHttpProxyCallback()
510
511```
512void OH_NetConn_UnregisterAppHttpProxyCallback(uint32_t callbackId)
513```
514
515**Description**
516
517Unregisters the callback for HTTP proxy changes of the application.
518
519**System capability**: SystemCapability.Communication.NetManager.Core
520
521**Since**: 12
522
523
524**Parameters**
525
526| Name| Description|
527| -- | -- |
528| uint32_t callbackId | ID of the callback to unregister.|
529
530### OH_NetConn_RegisterNetConnCallback()
531
532```
533int32_t OH_NetConn_RegisterNetConnCallback(NetConn_NetSpecifier *specifier, NetConn_NetConnCallback *netConnCallback,uint32_t timeout, uint32_t *callbackId)
534```
535
536**Description**
537
538Registers a callback for network status changes.
539
540**System capability**: SystemCapability.Communication.NetManager.Core
541
542**Required permissions**: ohos.permission.GET_NETWORK_INFO
543
544**Since**: 12
545
546
547**Parameters**
548
549| Name| Description|
550| -- | -- |
551| netSpecifier | Network feature set.|
552| callback | Registered callbacks.|
553| uint32_t timeout | Timeout duration, in milliseconds. The value **0** indicates infinite waiting.|
554| uint32_t *callbackId | Callback IDs.|
555
556**Returns**
557
558| Type| Description|
559| -- | -- |
560| int32_t | **0**: Success.<br>         **201**: Missing permissions.<br>         **401**: Parameter error.<br>         **2100002**: Service connection failure.<br>         **2100003**: Internal error.<br>         **2101008**: Callback already registered.<br>         **2101022**: Maximum number of requests exceeded.|
561
562### OH_NetConn_RegisterDefaultNetConnCallback()
563
564```
565int32_t OH_NetConn_RegisterDefaultNetConnCallback(NetConn_NetConnCallback *netConnCallback, uint32_t *callbackId)
566```
567
568**Description**
569
570Registers a callback for status changes of the default network.
571
572**System capability**: SystemCapability.Communication.NetManager.Core
573
574**Required permissions**: ohos.permission.GET_NETWORK_INFO
575
576**Since**: 12
577
578
579**Parameters**
580
581| Name| Description|
582| -- | -- |
583| callback | Registered callbacks.|
584| uint32_t *callbackId | Callback IDs.|
585
586**Returns**
587
588| Type| Description|
589| -- | -- |
590| int32_t | **0**: Success.<br>         **201**: Missing permissions.<br>         **401**: Parameter error.<br>         **2100002**: Service connection failure.<br>         **2100003**: Internal error.<br>         **2101008**: Callback already registered.<br>         **2101022**: Maximum number of requests exceeded.|
591
592### OH_NetConn_UnregisterNetConnCallback()
593
594```
595int32_t OH_NetConn_UnregisterNetConnCallback(uint32_t callBackId)
596```
597
598**Description**
599
600Unregisters the callback for network status changes.
601
602**System capability**: SystemCapability.Communication.NetManager.Core
603
604**Required permissions**: ohos.permission.GET_NETWORK_INFO
605
606**Since**: 12
607
608
609**Parameters**
610
611| Name| Description|
612| -- | -- |
613| uint32_t callBackId | ID of the callback to unregister.|
614
615**Returns**
616
617| Type| Description|
618| -- | -- |
619| int32_t | **0**: Success.<br>         **201**: Missing permissions.<br>         **401**: Parameter error.<br>         **2100002**: Service connection failure.<br>         **2100003**: Internal error.<br>         **2101007**: Callback not exist.|
620
621### OH_NetConn_SetPacUrl()
622
623```
624NetConn_ErrorCode OH_NetConn_SetPacUrl(const char *pacUrl)
625```
626
627**Description**
628
629Sets the URL of the system-level proxy auto-config (PAC) script.
630
631**Required permissions**: ohos.permission.SET_PAC_URL
632
633**Since**: 15
634
635
636**Parameters**
637
638| Name| Description|
639| -- | -- |
640| const char *pacUrl | Address of the PAC script.|
641
642**Returns**
643
644| Type| Description|
645| -- | -- |
646| [NetConn_ErrorCode](capi-net-connection-type-h.md#netconn_errorcode) | Result code defined in [NetConn_ErrorCode](capi-net-connection-type-h.md#netconn_errorcode).<br>         [NETCONN_SUCCESS](capi-net-connection-type-h.md#netconn_errorcode): success.<br>         [NETCONN_PERMISSION_DENIED](capi-net-connection-type-h.md#netconn_errorcode): permission denied.<br>         [NETCONN_PARAMETER_ERROR](capi-net-connection-type-h.md#netconn_errorcode): parameter error.<br>         [NETCONN_OPERATION_FAILED](capi-net-connection-type-h.md#netconn_errorcode): unable to connect to the service.<br>         [NETCONN_INTERNAL_ERROR](capi-net-connection-type-h.md#netconn_errorcode): internal error.|
647
648### OH_NetConn_GetPacUrl()
649
650```
651NetConn_ErrorCode OH_NetConn_GetPacUrl(char *pacUrl)
652```
653
654**Description**
655
656Obtains the URL of the system-level PAC script.
657
658**Since**: 15
659
660
661**Parameters**
662
663| Name| Description|
664| -- | -- |
665| char *pacUrl | URL of the PAC script.|
666
667**Returns**
668
669| Type| Description|
670| -- | -- |
671| [NetConn_ErrorCode](capi-net-connection-type-h.md#netconn_errorcode) | Result code defined in [NetConn_ErrorCode](capi-net-connection-type-h.md#netconn_errorcode).<br>         [NETCONN_SUCCESS](capi-net-connection-type-h.md#netconn_errorcode): success.<br>         [NETCONN_PARAMETER_ERROR](capi-net-connection-type-h.md#netconn_errorcode): parameter error.<br>         [NETCONN_OPERATION_FAILED](capi-net-connection-type-h.md#netconn_errorcode): unable to connect to the service.<br>         [NETCONN_INTERNAL_ERROR](capi-net-connection-type-h.md#netconn_errorcode): internal error.|
672
673### OH_NetConn_QueryProbeResult()
674
675```
676int32_t OH_NetConn_QueryProbeResult(char *destination, int32_t duration, NetConn_ProbeResultInfo *probeResultInfo)
677```
678
679**Description**
680
681Queries network probe results.
682
683**Required permission**: ohos.permission.INTERNET
684
685**Since**: 20
686
687
688**Parameters**
689
690| Name| Description|
691| -- | -- |
692| char *destination | Destination address.|
693| int32_t duration | Probe duration. in seconds.|
694| [NetConn_ProbeResultInfo](capi-netconnection-netconn-proberesultinfo.md) *probeResultInfo | Packet loss rate and round-trip time (RTT).|
695
696**Returns**
697
698| Type| Description|
699| -- | -- |
700| int32_t | **0**: Success.<br>         **201**: Missing permissions.<br>         **401**: Parameter error.<br>         **2100003**: Internal error.|
701
702### OH_NetConn_QueryTraceRoute()
703
704```
705int32_t OH_NetConn_QueryTraceRoute(char *destination, NetConn_TraceRouteOption *option,NetConn_TraceRouteInfo *traceRouteInfo)
706```
707
708**Description**
709
710Queries network trace route information.
711
712**Required permissions**: ohos.permission.INTERNET, ohos.permission.LOCATION, and ohos.permission.ACCESS_TRACE_ROUTE_INFO
713
714**Since**: 20
715
716
717**Parameters**
718
719| Name| Description|
720| -- | -- |
721| char *destination | Destination address.|
722| [NetConn_TraceRouteOption](capi-netconnection-netconn-tracerouteoption.md) *option | Route options.|
723| [NetConn_TraceRouteInfo](capi-netconnection-netconn-tracerouteinfo.md) *traceRouteInfo | Route result.|
724
725**Returns**
726
727| Type| Description|
728| -- | -- |
729| int32_t | **0**: Success.<br>         **201**: Missing permissions.|
730