• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback, Callback } from "./@ohos.base";
17import http from "./@ohos.net.http";
18import socket from "./@ohos.net.socket";
19
20/**
21 * Provides interfaces to manage and use data networks.
22 * @namespace connection
23 * @syscap SystemCapability.Communication.NetManager.Core
24 * @since 8
25 */
26/**
27 * Provides interfaces to manage and use data networks.
28 * @namespace connection
29 * @syscap SystemCapability.Communication.NetManager.Core
30 * @crossplatform
31 * @since 10
32 */
33declare namespace connection {
34  type HttpRequest = http.HttpRequest;
35  type TCPSocket = socket.TCPSocket;
36  type UDPSocket = socket.UDPSocket;
37
38  /**
39   * Create a network connection with optional netSpecifier and timeout.
40   * @param { NetSpecifier } netSpecifier Indicates the network specifier. See {@link NetSpecifier}.
41   * @param { number } timeout The time in milliseconds to attempt looking for a suitable network before
42   * {@link NetConnection#netUnavailable} is called.
43   * @returns { NetConnection } the NetConnection of the NetSpecifier.
44   * @syscap SystemCapability.Communication.NetManager.Core
45   * @since 8
46   */
47  /**
48   * Create a network connection with optional netSpecifier and timeout.
49   * @param { NetSpecifier } netSpecifier Indicates the network specifier. See {@link NetSpecifier}.
50   * @param { number } timeout The time in milliseconds to attempt looking for a suitable network before
51   * {@link NetConnection#netUnavailable} is called.
52   * @returns { NetConnection } the NetConnection of the NetSpecifier.
53   * @syscap SystemCapability.Communication.NetManager.Core
54   * @crossplatform
55   * @since 10
56   */
57  function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection;
58
59  /**
60   * Obtains the data network that is activated by default.
61   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
62   * @permission ohos.permission.GET_NETWORK_INFO
63   * @param { AsyncCallback<NetHandle> } callback Returns the {@link NetHandle} object;
64   * returns {@code null} if the default network is not activated.
65   * @throws { BusinessError } 201 - Permission denied.
66   * @throws { BusinessError } 401 - Parameter error.
67   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
68   * @throws { BusinessError } 2100003 - System internal error.
69   * @syscap SystemCapability.Communication.NetManager.Core
70   * @since 8
71   */
72  function getDefaultNet(callback: AsyncCallback<NetHandle>): void;
73
74  /**
75   * Obtains the data network that is activated by default.
76   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
77   * @permission ohos.permission.GET_NETWORK_INFO
78   * @returns { Promise<NetHandle> } The promise returned by the function.
79   * @throws { BusinessError } 201 - Permission denied.
80   * @throws { BusinessError } 401 - Parameter error.
81   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
82   * @throws { BusinessError } 2100003 - System internal error.
83   * @syscap SystemCapability.Communication.NetManager.Core
84   * @since 8
85   */
86  function getDefaultNet(): Promise<NetHandle>;
87
88  /**
89   * Obtains the data network that is activated by default.
90   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
91   * @permission ohos.permission.GET_NETWORK_INFO
92   * @returns { NetHandle } if the default network is not activated.
93   * @throws { BusinessError } 201 - Permission denied.
94   * @throws { BusinessError } 401 - Parameter error.
95   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
96   * @throws { BusinessError } 2100003 - System internal error.
97   * @syscap SystemCapability.Communication.NetManager.Core
98   * @since 9
99   */
100  function getDefaultNetSync(): NetHandle;
101
102  /**
103   * Obtains the list of data networks that are activated.
104   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
105   * @permission ohos.permission.GET_NETWORK_INFO
106   * @param { AsyncCallback<Array<NetHandle>> } callback Returns the {@link NetHandle} object; returns {@code null} if no network is activated.
107   * @throws { BusinessError } 201 - Permission denied.
108   * @throws { BusinessError } 401 - Parameter error.
109   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
110   * @throws { BusinessError } 2100003 - System internal error.
111   * @syscap SystemCapability.Communication.NetManager.Core
112   * @since 8
113   */
114  function getAllNets(callback: AsyncCallback<Array<NetHandle>>): void;
115
116  /**
117   * Obtains the list of data networks that are activated.
118   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
119   * @permission ohos.permission.GET_NETWORK_INFO
120   * @returns { Promise<Array<NetHandle>> } The promise returned by the function.
121   * @throws { BusinessError } 201 - Permission denied.
122   * @throws { BusinessError } 401 - Parameter error.
123   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
124   * @throws { BusinessError } 2100003 - System internal error.
125   * @syscap SystemCapability.Communication.NetManager.Core
126   * @since 8
127   */
128  function getAllNets(): Promise<Array<NetHandle>>;
129
130  /**
131   * Queries the connection properties of a network.
132   * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
133   * @permission ohos.permission.GET_NETWORK_INFO
134   * @param { NetHandle } netHandle Indicates the network to be queried.
135   * @param { AsyncCallback<ConnectionProperties> } callback Returns the {@link ConnectionProperties} object.
136   * @throws { BusinessError } 201 - Permission denied.
137   * @throws { BusinessError } 401 - Parameter error.
138   * @throws { BusinessError } 2100001 - Invalid parameter value.
139   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
140   * @throws { BusinessError } 2100003 - System internal error.
141   * @syscap SystemCapability.Communication.NetManager.Core
142   * @since 8
143   */
144  function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback<ConnectionProperties>): void;
145
146  /**
147   * Queries the connection properties of a network.
148   * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
149   * @permission ohos.permission.GET_NETWORK_INFO
150   * @param { NetHandle } netHandle Indicates the network to be queried.
151   * @returns { Promise<ConnectionProperties> } The promise returned by the function.
152   * @throws { BusinessError } 201 - Permission denied.
153   * @throws { BusinessError } 401 - Parameter error.
154   * @throws { BusinessError } 2100001 - Invalid parameter value.
155   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
156   * @throws { BusinessError } 2100003 - System internal error.
157   * @syscap SystemCapability.Communication.NetManager.Core
158   * @since 8
159   */
160  function getConnectionProperties(netHandle: NetHandle): Promise<ConnectionProperties>;
161
162  /**
163   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
164   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
165   * @permission ohos.permission.GET_NETWORK_INFO
166   * @param { NetHandle } netHandle Indicates the handle. See {@link NetHandle}.
167   * @param { AsyncCallback<NetCapabilities> } callback Returns {@link NetCapabilities}; returns {@code null} if {@code handle} is invalid.
168   * @throws { BusinessError } 201 - Permission denied.
169   * @throws { BusinessError } 401 - Parameter error.
170   * @throws { BusinessError } 2100001 - Invalid parameter value.
171   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
172   * @throws { BusinessError } 2100003 - System internal error.
173   * @syscap SystemCapability.Communication.NetManager.Core
174   * @since 8
175   */
176  function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback<NetCapabilities>): void;
177
178  /**
179   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
180   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
181   * @permission ohos.permission.GET_NETWORK_INFO
182   * @param { NetHandle } netHandle Indicates the handle. See {@link NetHandle}.
183   * @returns { Promise<NetCapabilities> } The promise returned by the function.
184   * @throws { BusinessError } 201 - Permission denied.
185   * @throws { BusinessError } 401 - Parameter error.
186   * @throws { BusinessError } 2100001 - Invalid parameter value.
187   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
188   * @throws { BusinessError } 2100003 - System internal error.
189   * @syscap SystemCapability.Communication.NetManager.Core
190   * @since 8
191   */
192  function getNetCapabilities(netHandle: NetHandle): Promise<NetCapabilities>;
193
194  /**
195   * Checks whether data traffic usage on the current network is metered.
196   * @permission ohos.permission.GET_NETWORK_INFO
197   * @param { AsyncCallback<boolean> } callback Returns {@code true} if data traffic usage on the current network is metered;
198   * returns {@code false} otherwise.
199   * @throws { BusinessError } 201 - Permission denied.
200   * @throws { BusinessError } 401 - Parameter error.
201   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
202   * @throws { BusinessError } 2100003 - System internal error.
203   * @syscap SystemCapability.Communication.NetManager.Core
204   * @since 9
205   */
206  function isDefaultNetMetered(callback: AsyncCallback<boolean>): void;
207
208  /**
209   * Checks whether data traffic usage on the current network is metered.
210   * @permission ohos.permission.GET_NETWORK_INFO
211   * @returns { Promise<boolean> } the promise returned by the function.
212   * @throws { BusinessError } 201 - Permission denied.
213   * @throws { BusinessError } 401 - Parameter error.
214   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
215   * @throws { BusinessError } 2100003 - System internal error.
216   * @syscap SystemCapability.Communication.NetManager.Core
217   * @since 9
218   */
219  function isDefaultNetMetered(): Promise<boolean>;
220
221  /**
222   * Checks whether the default data network is activated.
223   * @permission ohos.permission.GET_NETWORK_INFO
224   * @param { AsyncCallback<boolean> } callback Returns {@code true} if the default data network is activated;
225   * returns {@code false} otherwise.
226   * @throws { BusinessError } 201 - Permission denied.
227   * @throws { BusinessError } 401 - Parameter error.
228   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
229   * @throws { BusinessError } 2100003 - System internal error.
230   * @syscap SystemCapability.Communication.NetManager.Core
231   * @since 8
232   */
233  /**
234   * Checks whether the default data network is activated.
235   * @permission ohos.permission.GET_NETWORK_INFO
236   * @param { AsyncCallback<boolean> } callback Returns {@code true} if the default data network is activated;
237   * returns {@code false} otherwise.
238   * @throws { BusinessError } 201 - Permission denied.
239   * @throws { BusinessError } 401 - Parameter error.
240   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
241   * @throws { BusinessError } 2100003 - System internal error.
242   * @syscap SystemCapability.Communication.NetManager.Core
243   * @crossplatform
244   * @since 10
245   */
246  function hasDefaultNet(callback: AsyncCallback<boolean>): void;
247
248  /**
249   * Checks whether the default data network is activated.
250   * @permission ohos.permission.GET_NETWORK_INFO
251   * @returns { Promise<boolean> } The promise returned by the function.
252   * @throws { BusinessError } 201 - Permission denied.
253   * @throws { BusinessError } 401 - Parameter error.
254   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
255   * @throws { BusinessError } 2100003 - System internal error.
256   * @syscap SystemCapability.Communication.NetManager.Core
257   * @since 8
258   */
259  /**
260   * Checks whether the default data network is activated.
261   * @permission ohos.permission.GET_NETWORK_INFO
262   * @returns { Promise<boolean> } The promise returned by the function.
263   * @throws { BusinessError } 201 - Permission denied.
264   * @throws { BusinessError } 401 - Parameter error.
265   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
266   * @throws { BusinessError } 2100003 - System internal error.
267   * @syscap SystemCapability.Communication.NetManager.Core
268   * @crossplatform
269   * @since 10
270   */
271  function hasDefaultNet(): Promise<boolean>;
272
273  /**
274   * Enables the airplane mode for a device.
275   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
276   * @permission ohos.permission.CONNECTIVITY_INTERNAL
277   * @param { AsyncCallback<void> } callback - the callback of enableAirplaneMode.
278   * @throws { BusinessError } 201 - Permission denied.
279   * @throws { BusinessError } 202 - Non-system applications use system APIs.
280   * @throws { BusinessError } 401 - Parameter error.
281   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
282   * @throws { BusinessError } 2100003 - System internal error.
283   * @syscap SystemCapability.Communication.NetManager.Core
284   * @systemapi Hide this for inner system use. Only used for system app.
285   * @since 8
286   */
287  function enableAirplaneMode(callback: AsyncCallback<void>): void;
288
289  /**
290   * Enables the airplane mode for a device.
291   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
292   * @permission ohos.permission.CONNECTIVITY_INTERNAL
293   * @returns { Promise<void> } The promise returned by the function.
294   * @throws { BusinessError } 201 - Permission denied.
295   * @throws { BusinessError } 202 - Non-system applications use system APIs.
296   * @throws { BusinessError } 401 - Parameter error.
297   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
298   * @throws { BusinessError } 2100003 - System internal error.
299   * @syscap SystemCapability.Communication.NetManager.Core
300   * @systemapi Hide this for inner system use. Only used for system app.
301   * @since 8
302   */
303  function enableAirplaneMode(): Promise<void>;
304
305  /**
306   * Disables the airplane mode for a device.
307   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
308   * @permission ohos.permission.CONNECTIVITY_INTERNAL
309   * @param { AsyncCallback<void> } callback - the callback of disableAirplaneMode.
310   * @throws { BusinessError } 201 - Permission denied.
311   * @throws { BusinessError } 202 - Non-system applications use system APIs.
312   * @throws { BusinessError } 401 - Parameter error.
313   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
314   * @throws { BusinessError } 2100003 - System internal error.
315   * @syscap SystemCapability.Communication.NetManager.Core
316   * @systemapi Hide this for inner system use. Only used for system app.
317   * @since 8
318   */
319  function disableAirplaneMode(callback: AsyncCallback<void>): void;
320
321  /**
322   * Disables the airplane mode for a device.
323   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
324   * @permission ohos.permission.CONNECTIVITY_INTERNAL
325   * @returns { Promise<void> } The promise returned by the function.
326   * @throws { BusinessError } 201 - Permission denied.
327   * @throws { BusinessError } 202 - Non-system applications use system APIs.
328   * @throws { BusinessError } 401 - Parameter error.
329   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
330   * @throws { BusinessError } 2100003 - System internal error.
331   * @syscap SystemCapability.Communication.NetManager.Core
332   * @systemapi Hide this for inner system use. Only used for system app.
333   * @since 8
334   */
335  function disableAirplaneMode(): Promise<void>;
336
337  /**
338   * Reports the network state is connected.
339   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
340   * @param { NetHandle } netHandle Indicates the network whose state is to be reported.
341   * @param { AsyncCallback<void> } callback - the callback of reportNetConnected.
342   * @throws { BusinessError } 201 - Permission denied.
343   * @throws { BusinessError } 401 - Parameter error.
344   * @throws { BusinessError } 2100001 - Invalid parameter value.
345   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
346   * @throws { BusinessError } 2100003 - System internal error.
347   * @syscap SystemCapability.Communication.NetManager.Core
348   * @since 8
349   */
350  function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): void;
351
352  /**
353   * Reports the network state is connected.
354   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
355   * @param { NetHandle } netHandle Indicates the network whose state is to be reported.
356   * @returns { Promise<void> } The promise returned by the function.
357   * @throws { BusinessError } 201 - Permission denied.
358   * @throws { BusinessError } 401 - Parameter error.
359   * @throws { BusinessError } 2100001 - Invalid parameter value.
360   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
361   * @throws { BusinessError } 2100003 - System internal error.
362   * @syscap SystemCapability.Communication.NetManager.Core
363   * @since 8
364   */
365  function reportNetConnected(netHandle: NetHandle): Promise<void>;
366
367  /**
368   * Reports the network state is disconnected.
369   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
370   * @param { NetHandle } netHandle Indicates the network whose state is to be reported.
371   * @param { AsyncCallback<void> } callback - the callback of reportNetDisconnected.
372   * @throws { BusinessError } 201 - Permission denied.
373   * @throws { BusinessError } 401 - Parameter error.
374   * @throws { BusinessError } 2100001 - Invalid parameter value.
375   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
376   * @throws { BusinessError } 2100003 - System internal error.
377   * @syscap SystemCapability.Communication.NetManager.Core
378   * @since 8
379   */
380  function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>): void;
381
382  /**
383   * Reports the network state is disconnected.
384   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
385   * @param { NetHandle } netHandle Indicates the network whose state is to be reported.
386   * @returns { Promise<void> } The promise returned by the function.
387   * @throws { BusinessError } 201 - Permission denied.
388   * @throws { BusinessError } 401 - Parameter error.
389   * @throws { BusinessError } 2100001 - Invalid parameter value.
390   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
391   * @throws { BusinessError } 2100003 - System internal error.
392   * @syscap SystemCapability.Communication.NetManager.Core
393   * @since 8
394   */
395  function reportNetDisconnected(netHandle: NetHandle): Promise<void>;
396
397  /**
398   * Resolves the host name to obtain all IP addresses based on the default data network.
399   * @permission ohos.permission.INTERNET
400   * @param { string } host Indicates the host name or the domain.
401   * @param { AsyncCallback<Array<NetAddress>> } callback Returns the NetAddress list.
402   * @throws { BusinessError } 201 - Permission denied.
403   * @throws { BusinessError } 401 - Parameter error.
404   * @throws { BusinessError } 2100001 - Invalid parameter value.
405   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
406   * @throws { BusinessError } 2100003 - System internal error.
407   * @syscap SystemCapability.Communication.NetManager.Core
408   * @since 8
409   */
410  function getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
411
412  /**
413   * Resolves the host name to obtain all IP addresses based on the default data network.
414   * @permission ohos.permission.INTERNET
415   * @param { string } host Indicates the host name or the domain.
416   * @returns { Promise<Array<NetAddress>> } The promise returned by the function.
417   * @throws { BusinessError } 201 - Permission denied.
418   * @throws { BusinessError } 401 - Parameter error.
419   * @throws { BusinessError } 2100001 - Invalid parameter value.
420   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
421   * @throws { BusinessError } 2100003 - System internal error.
422   * @syscap SystemCapability.Communication.NetManager.Core
423   * @since 8
424   */
425  function getAddressesByName(host: string): Promise<Array<NetAddress>>;
426
427  /**
428   * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
429   * @param { AsyncCallback<NetHandle> } callback Returns the {@link NetHandle} bound to the process;
430   * returns {@code null} if no {@link NetHandle} is bound to the process.For details, see {@link NetHandle}.
431   * @throws { BusinessError } 401 - Parameter error.
432   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
433   * @throws { BusinessError } 2100003 - System internal error.
434   * @syscap SystemCapability.Communication.NetManager.Core
435   * @since 9
436   */
437  function getAppNet(callback: AsyncCallback<NetHandle>): void;
438
439  /**
440   * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
441   * @returns { Promise<NetHandle> } the promise returned by the function.
442   * @throws { BusinessError } 401 - Parameter error.
443   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
444   * @throws { BusinessError } 2100003 - System internal error.
445   * @syscap SystemCapability.Communication.NetManager.Core
446   * @since 9
447   */
448  function getAppNet(): Promise<NetHandle>;
449
450  /**
451   * Binds a process to {@code NetHandle}.
452   * <p>All the sockets created from the process will be bound to the {@code NetHandle},
453   * and the resolution of all host names will be managed by the {@code NetHandle}.</p>
454   * @permission ohos.permission.INTERNET
455   * @param { NetHandle } netHandle Indicates the handle. For details, see {@link NetHandle}.
456   * @param { AsyncCallback<void> } callback Returns the callback of setAppNet.
457   * @throws { BusinessError } 201 - Permission denied.
458   * @throws { BusinessError } 401 - Parameter error.
459   * @throws { BusinessError } 2100001 - Invalid parameter value.
460   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
461   * @throws { BusinessError } 2100003 - System internal error.
462   * @syscap SystemCapability.Communication.NetManager.Core
463   * @since 9
464   */
465  function setAppNet(netHandle: NetHandle, callback: AsyncCallback<void>): void;
466
467  /**
468   * Binds a process to {@code NetHandle}.
469   * <p>All the sockets created from the process will be bound to the {@code NetHandle},
470   * and the resolution of all host names will be managed by the {@code NetHandle}.</p>
471   * @permission ohos.permission.INTERNET
472   * @param { NetHandle } netHandle Indicates the handle. For details, see {@link NetHandle}.
473   * @returns { Promise<void> } the promise returned by the function.
474   * @throws { BusinessError } 201 - Permission denied.
475   * @throws { BusinessError } 401 - Parameter error.
476   * @throws { BusinessError } 2100001 - Invalid parameter value.
477   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
478   * @throws { BusinessError } 2100003 - System internal error.
479   * @syscap SystemCapability.Communication.NetManager.Core
480   * @since 9
481   */
482  function setAppNet(netHandle: NetHandle): Promise<void>;
483
484  /**
485   * Obtains the network independent global {@link HttpProxy} proxy settings.
486   * @param { AsyncCallback<HttpProxy> } callback Returns the proxy settings. For details, see {@link HttpProxy}.
487   * @throws { BusinessError } 401 - Parameter error.
488   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
489   * @throws { BusinessError } 2100003 - System internal error.
490   * @syscap SystemCapability.Communication.NetManager.Core
491   * @systemapi Hide this for inner system use.
492   * @since 10
493   */
494  function getGlobalHttpProxy(callback: AsyncCallback<HttpProxy>): void;
495
496  /**
497   * Obtains the network independent global {@link HttpProxy} proxy settings.
498   * @returns { Promise<HttpProxy> } the promise returned by the function.
499   * @throws { BusinessError } 401 - Parameter error.
500   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
501   * @throws { BusinessError } 2100003 - System internal error.
502   * @syscap SystemCapability.Communication.NetManager.Core
503   * @systemapi Hide this for inner system use.
504   * @since 10
505   */
506  function getGlobalHttpProxy(): Promise<HttpProxy>;
507
508  /**
509   * Set a network independent global {@link HttpProxy} proxy settings.
510   * @permission ohos.permission.CONNECTIVITY_INTERNAL
511   * @param { HttpProxy } httpProxy Indicates the global proxy settings. For details, see {@link HttpProxy}.
512   * @param { AsyncCallback<void> } callback Returns the callback of setGlobalHttpProxy.
513   * @throws { BusinessError } 201 - Permission denied.
514   * @throws { BusinessError } 401 - Parameter error.
515   * @throws { BusinessError } 2100001 - Invalid parameter value.
516   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
517   * @throws { BusinessError } 2100003 - System internal error.
518   * @syscap SystemCapability.Communication.NetManager.Core
519   * @systemapi Hide this for inner system use.
520   * @since 10
521   */
522  function setGlobalHttpProxy(httpProxy: HttpProxy, callback: AsyncCallback<void>): void;
523
524  /**
525   * Set a network independent global {@link HttpProxy} proxy settings.
526   * @permission ohos.permission.CONNECTIVITY_INTERNAL
527   * @param { HttpProxy } httpProxy Indicates the global proxy settings. For details, see {@link HttpProxy}.
528   * @returns { Promise<void> } the promise returned by the function.
529   * @throws { BusinessError } 201 - Permission denied.
530   * @throws { BusinessError } 401 - Parameter error.
531   * @throws { BusinessError } 2100001 - Invalid parameter value.
532   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
533   * @throws { BusinessError } 2100003 - System internal error.
534   * @syscap SystemCapability.Communication.NetManager.Core
535   * @systemapi Hide this for inner system use.
536   * @since 10
537   */
538  function setGlobalHttpProxy(httpProxy: HttpProxy): Promise<void>;
539
540  /**
541   * Obtains the default {@link HttpProxy} proxy settings.
542   *
543   * If a global proxy is set, the global proxy parameters are returned.
544   * If the process is bound to a {@link NetHandle} using {@link setAppNet},
545   * the {@link NetHandle} proxy settings are returned.
546   * In other cases, the proxy settings of default network are returned.
547   *
548   * @param { AsyncCallback<HttpProxy> } callback Returns the default {@link HttpProxy} settings.
549   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
550   * @throws { BusinessError } 2100003 - System internal error.
551   * @syscap SystemCapability.Communication.NetManager.Core
552   * @since 10
553   */
554  function getDefaultHttpProxy(callback: AsyncCallback<HttpProxy>): void;
555
556  /**
557   * Obtains the default {@link HttpProxy} proxy settings.
558   *
559   * If a global proxy is set, the global proxy parameters are returned.
560   * If the process is bound to a {@link NetHandle} using {@link setAppNet},
561   * the {@link NetHandle} proxy settings are returned.
562   * In other cases, the proxy settings of default network are returned.
563   *
564   * @returns { Promise<HttpProxy> } the promise returned by the function.
565   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
566   * @throws { BusinessError } 2100003 - System internal error.
567   * @syscap SystemCapability.Communication.NetManager.Core
568   * @since 10
569   */
570  function getDefaultHttpProxy(): Promise<HttpProxy>;
571
572  /**
573   * Represents the network connection handle.
574   * @interface NetConnection
575   * @syscap SystemCapability.Communication.NetManager.Core
576   * @since 8
577   */
578  /**
579   * Represents the network connection handle.
580   * @interface NetConnection
581   * @syscap SystemCapability.Communication.NetManager.Core
582   * @crossplatform
583   * @since 10
584   */
585  export interface NetConnection {
586    /**
587     * Registers a listener for netAvailable events.
588     * @param { 'netAvailable' } type Indicates Event name.
589     * @param { Callback<NetHandle> } callback - the callback of on.
590     * @syscap SystemCapability.Communication.NetManager.Core
591     * @since 8
592     */
593    /**
594     * Registers a listener for netAvailable events.
595     * @param { 'netAvailable' } type Indicates Event name.
596     * @param { Callback<NetHandle> } callback - the callback of on.
597     * @syscap SystemCapability.Communication.NetManager.Core
598     * @crossplatform
599     * @since 10
600     */
601    on(type: 'netAvailable', callback: Callback<NetHandle>): void;
602
603    /**
604     * Registers a listener for netBlockStatusChange events.
605     * @param { 'netBlockStatusChange' } type Indicates Event name.
606     * @param { Callback<{ netHandle: NetHandle, blocked: boolean }> } callback - the callback of on.
607     * @syscap SystemCapability.Communication.NetManager.Core
608     * @since 8
609     */
610    on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void;
611
612    /**
613     * Registers a listener for **netCapabilitiesChange** events.
614     * @param { 'netCapabilitiesChange' } type Indicates Event name.
615     * @param { Callback<{ netHandle: NetHandle, netCap: NetCapabilities }> } callback - the callback of on.
616     * @syscap SystemCapability.Communication.NetManager.Core
617     * @since 8
618     */
619    /**
620     * Registers a listener for **netCapabilitiesChange** events.
621     * @param { 'netCapabilitiesChange' } type Indicates Event name.
622     * @param { Callback<{ netHandle: NetHandle, netCap: NetCapabilities }> } callback - the callback of on.
623     * @syscap SystemCapability.Communication.NetManager.Core
624     * @crossplatform
625     * @since 10
626     */
627    on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void;
628
629    /**
630     * Registers a listener for netConnectionPropertiesChange events.
631     * @param { 'netConnectionPropertiesChange' } type Indicates Event name.
632     * @param { Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }> } callback - the callback of on.
633     * @syscap SystemCapability.Communication.NetManager.Core
634     * @since 8
635     */
636    on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void;
637
638    /**
639     * Registers a listener for **netLost** events.
640     * @param { 'netLost' } type Indicates Event name.
641     * @param { Callback<NetHandle> } callback - the callback of on.
642     * @syscap SystemCapability.Communication.NetManager.Core
643     * @since 8
644     */
645    /**
646     * Registers a listener for **netLost** events.
647     * @param { 'netLost' } type Indicates Event name.
648     * @param { Callback<NetHandle> } callback - the callback of on.
649     * @syscap SystemCapability.Communication.NetManager.Core
650     * @crossplatform
651     * @since 10
652     */
653    on(type: 'netLost', callback: Callback<NetHandle>): void;
654
655    /**
656     * Registers a listener for netUnavailable events.
657     * @param { 'netUnavailable' } type Indicates Event name.
658     * @param { Callback<void> } callback - the callback of on.
659     * @syscap SystemCapability.Communication.NetManager.Core
660     * @since 8
661     */
662    /**
663     * Registers a listener for netUnavailable events.
664     * @param { 'netUnavailable' } type Indicates Event name.
665     * @param { Callback<void> } callback - the callback of on.
666     * @syscap SystemCapability.Communication.NetManager.Core
667     * @crossplatform
668     * @since 10
669     */
670    on(type: 'netUnavailable', callback: Callback<void>): void;
671
672    /**
673     * Receives status change notifications of a specified network.
674     * @permission ohos.permission.GET_NETWORK_INFO
675     * @param { AsyncCallback<void> } callback - the callback of register.
676     * @throws { BusinessError } 201 - Permission denied.
677     * @throws { BusinessError } 401 - Parameter error.
678     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
679     * @throws { BusinessError } 2100003 - System internal error.
680     * @throws { BusinessError } 2101008 - The same callback exists.
681     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum.
682     * @syscap SystemCapability.Communication.NetManager.Core
683     * @since 8
684     */
685    /**
686     * Receives status change notifications of a specified network.
687     * @permission ohos.permission.GET_NETWORK_INFO
688     * @param { AsyncCallback<void> } callback - the callback of register.
689     * @throws { BusinessError } 201 - Permission denied.
690     * @throws { BusinessError } 401 - Parameter error.
691     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
692     * @throws { BusinessError } 2100003 - System internal error.
693     * @throws { BusinessError } 2101008 - The same callback exists.
694     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum.
695     * @syscap SystemCapability.Communication.NetManager.Core
696     * @crossplatform
697     * @since 10
698     */
699    register(callback: AsyncCallback<void>): void;
700
701    /**
702     * Cancels listening for network status changes.
703     * @param { AsyncCallback<void> } callback - the callback of unregister.
704     * @throws { BusinessError } 201 - Permission denied.
705     * @throws { BusinessError } 401 - Parameter error.
706     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
707     * @throws { BusinessError } 2100003 - System internal error.
708     * @throws { BusinessError } 2101007 - The callback is not exists.
709     * @syscap SystemCapability.Communication.NetManager.Core
710     * @since 8
711     */
712    /**
713     * Cancels listening for network status changes.
714     * @param { AsyncCallback<void> } callback - the callback of unregister.
715     * @throws { BusinessError } 201 - Permission denied.
716     * @throws { BusinessError } 401 - Parameter error.
717     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
718     * @throws { BusinessError } 2100003 - System internal error.
719     * @throws { BusinessError } 2101007 - The callback is not exists.
720     * @syscap SystemCapability.Communication.NetManager.Core
721     * @crossplatform
722     * @since 10
723     */
724    unregister(callback: AsyncCallback<void>): void;
725  }
726
727  /**
728   * Provides an instance that bear data network capabilities.
729   * @interface NetSpecifier
730   * @syscap SystemCapability.Communication.NetManager.Core
731   * @since 8
732   */
733  export interface NetSpecifier {
734    /**
735     * The transmission capacity and support of the network's global proxy storage data network.
736     * @type {NetCapabilities}
737     * @syscap SystemCapability.Communication.NetManager.Core
738     * @since 8
739     */
740    netCapabilities: NetCapabilities;
741
742    /**
743     * Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1).
744     * @type {?string}
745     * @syscap SystemCapability.Communication.NetManager.Core
746     * @since 8
747     */
748    bearerPrivateIdentifier?: string;
749  }
750
751  /**
752   * Defines the handle of the data network.
753   * @interface NetHandle
754   * @syscap SystemCapability.Communication.NetManager.Core
755   * @since 8
756   */
757  /**
758   * Defines the handle of the data network.
759   * @interface NetHandle
760   * @syscap SystemCapability.Communication.NetManager.Core
761   * @crossplatform
762   * @since 10
763   */
764  export interface NetHandle {
765    /**
766     * Network ID, a value of 0 means that there is no default network, and the other values must be greater than or equal to 100.
767     * @type {number}
768     * @syscap SystemCapability.Communication.NetManager.Core
769     * @since 8
770     */
771    /**
772     * Network ID, a value of 0 means that there is no default network, and the other values must be greater than or equal to 100.
773     * @type {number}
774     * @syscap SystemCapability.Communication.NetManager.Core
775     * @crossplatform
776     * @since 10
777     */
778    netId: number;
779
780    /**
781     * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
782     * the socket will use this network, without being subject to {@link setAppNet}.</p>
783     * Before using this method, ensure that the socket is disconnected.
784     * @param { TCPSocket | UDPSocket } socketParam Indicates the TCPSocket or UDPSocket object.
785     * @param { AsyncCallback<void> } callback - the callback of bindSocket.
786     * @throws { BusinessError } 401 - Parameter error.
787     * @throws { BusinessError } 2100001 - Invalid parameter value.
788     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
789     * @throws { BusinessError } 2100003 - System internal error.
790     * @syscap SystemCapability.Communication.NetManager.Core
791     * @since 9
792     */
793    bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback<void>): void;
794
795    /**
796     * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
797     * the socket will use this network, without being subject to {@link setAppNet}.</p>
798     * Before using this method, ensure that the socket is disconnected.
799     * @param { TCPSocket | UDPSocket } socketParam Indicates the TCPSocket or UDPSocket object.
800     * @returns { Promise<void> } the promise returned by the function.
801     * @throws { BusinessError } 401 - Parameter error.
802     * @throws { BusinessError } 2100001 - Invalid parameter value.
803     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
804     * @throws { BusinessError } 2100003 - System internal error.
805     * @syscap SystemCapability.Communication.NetManager.Core
806     * @since 9
807     */
808    bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void>;
809
810    /**
811     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
812     * @permission ohos.permission.INTERNET
813     * @param { string } host Indicates the host name or the domain.
814     * @param { AsyncCallback<Array<NetAddress>> } callback Returns the NetAddress list.
815     * @throws { BusinessError } 201 - Permission denied.
816     * @throws { BusinessError } 401 - Parameter error.
817     * @throws { BusinessError } 2100001 - Invalid parameter value.
818     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
819     * @throws { BusinessError } 2100003 - System internal error.
820     * @syscap SystemCapability.Communication.NetManager.Core
821     * @since 8
822     */
823    getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
824
825    /**
826     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
827     * @permission ohos.permission.INTERNET
828     * @param { string } host Indicates the host name or the domain.
829     * @returns { Promise<Array<NetAddress>> } The promise returned by the function.
830     * @throws { BusinessError } 201 - Permission denied.
831     * @throws { BusinessError } 401 - Parameter error.
832     * @throws { BusinessError } 2100001 - Invalid parameter value.
833     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
834     * @throws { BusinessError } 2100003 - System internal error.
835     * @syscap SystemCapability.Communication.NetManager.Core
836     * @since 8
837     */
838    getAddressesByName(host: string): Promise<Array<NetAddress>>;
839
840    /**
841     * Resolves a host name to obtain the first IP address based on the specified NetHandle.
842     * @permission ohos.permission.INTERNET
843     * @param { string } host Indicates the host name or the domain.
844     * @param { AsyncCallback<NetAddress> } callback Returns the first NetAddress.
845     * @throws { BusinessError } 201 - Permission denied.
846     * @throws { BusinessError } 401 - Parameter error.
847     * @throws { BusinessError } 2100001 - Invalid parameter value.
848     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
849     * @throws { BusinessError } 2100003 - System internal error.
850     * @syscap SystemCapability.Communication.NetManager.Core
851     * @since 8
852     */
853    getAddressByName(host: string, callback: AsyncCallback<NetAddress>): void;
854
855    /**
856     * Resolves a host name to obtain the first IP address based on the specified NetHandle.
857     * @permission ohos.permission.INTERNET
858     * @param { string } host Indicates the host name or the domain.
859     * @returns { Promise<NetAddress> } The promise returned by the function.
860     * @throws { BusinessError } 201 - Permission denied.
861     * @throws { BusinessError } 401 - Parameter error.
862     * @throws { BusinessError } 2100001 - Invalid parameter value.
863     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
864     * @throws { BusinessError } 2100003 - System internal error.
865     * @syscap SystemCapability.Communication.NetManager.Core
866     * @since 8
867     */
868    getAddressByName(host: string): Promise<NetAddress>;
869  }
870
871  /**
872   * Defines the network capability set.
873   * @interface NetCapabilities
874   * @syscap SystemCapability.Communication.NetManager.Core
875   * @since 8
876   */
877  /**
878   * Defines the network capability set.
879   * @interface NetCapabilities
880   * @syscap SystemCapability.Communication.NetManager.Core
881   * @crossplatform
882   * @since 10
883   */
884  export interface NetCapabilities {
885    /**
886     * Uplink (device-to-network) bandwidth.
887     * @type {?number}
888     * @syscap SystemCapability.Communication.NetManager.Core
889     * @since 8
890     */
891    linkUpBandwidthKbps?: number;
892
893    /**
894     * Downstream (network-to-device) bandwidth.
895     * @type {?number}
896     * @syscap SystemCapability.Communication.NetManager.Core
897     * @since 8
898     */
899    linkDownBandwidthKbps?: number;
900
901    /**
902     * Network-specific capabilities.
903     * @type {?Array<NetCap>}
904     * @syscap SystemCapability.Communication.NetManager.Core
905     * @since 8
906     */
907    networkCap?: Array<NetCap>;
908
909    /**
910     * Network type.
911     * @type {Array<NetBearType>}
912     * @syscap SystemCapability.Communication.NetManager.Core
913     * @since 8
914     */
915    /**
916     * Network type.
917     * @type {Array<NetBearType>}
918     * @syscap SystemCapability.Communication.NetManager.Core
919     * @crossplatform
920     * @since 10
921     */
922    bearerTypes: Array<NetBearType>;
923  }
924
925  /**
926   * Defines the network capability.
927   * @enum {number}
928   * @syscap SystemCapability.Communication.NetManager.Core
929   * @since 8
930   */
931  export enum NetCap {
932    /**
933     * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
934     * @syscap SystemCapability.Communication.NetManager.Core
935     * @since 8
936     */
937    NET_CAPABILITY_MMS = 0,
938
939    /**
940     * Indicates that the network traffic is not metered.
941     * @syscap SystemCapability.Communication.NetManager.Core
942     * @since 8
943     */
944    NET_CAPABILITY_NOT_METERED = 11,
945
946    /**
947     * Indicates that the network can access the Internet.
948     * @syscap SystemCapability.Communication.NetManager.Core
949     * @since 8
950     */
951    NET_CAPABILITY_INTERNET = 12,
952
953    /**
954     * Indicates that the network does not use a VPN.
955     * @syscap SystemCapability.Communication.NetManager.Core
956     * @since 8
957     */
958    NET_CAPABILITY_NOT_VPN = 15,
959
960    /**
961     * Indicates that the network is available.
962     * @syscap SystemCapability.Communication.NetManager.Core
963     * @since 8
964     */
965    NET_CAPABILITY_VALIDATED = 16,
966  }
967
968  /**
969   * Enumerates network types.
970   * @enum {number}
971   * @syscap SystemCapability.Communication.NetManager.Core
972   * @since 8
973   */
974  /**
975   * Enumerates network types.
976   * @enum {number}
977   * @syscap SystemCapability.Communication.NetManager.Core
978   * @crossplatform
979   * @since 10
980   */
981  export enum NetBearType {
982    /**
983     * Indicates that the network is based on a cellular network.
984     * @syscap SystemCapability.Communication.NetManager.Core
985     * @since 8
986     */
987    /**
988     * Indicates that the network is based on a cellular network.
989     * @syscap SystemCapability.Communication.NetManager.Core
990     * @crossplatform
991     * @since 10
992     */
993    BEARER_CELLULAR = 0,
994
995    /**
996     * Indicates that the network is based on a Wi-Fi network.
997     * @syscap SystemCapability.Communication.NetManager.Core
998     * @since 8
999     */
1000    /**
1001     * Indicates that the network is based on a Wi-Fi network.
1002     * @syscap SystemCapability.Communication.NetManager.Core
1003     * @crossplatform
1004     * @since 10
1005     */
1006    BEARER_WIFI = 1,
1007
1008    /**
1009     * Indicates that the network is an Ethernet network.
1010     * @syscap SystemCapability.Communication.NetManager.Core
1011     * @since 8
1012     */
1013    BEARER_ETHERNET = 3,
1014  }
1015
1016  /**
1017   * Defines the network connection properties.
1018   * @interface ConnectionProperties
1019   * @syscap SystemCapability.Communication.NetManager.Core
1020   * @since 8
1021   */
1022  export interface ConnectionProperties {
1023    /**
1024     * Network card name.
1025     * @type {string}
1026     * @syscap SystemCapability.Communication.NetManager.Core
1027     * @since 8
1028     */
1029    interfaceName: string;
1030    /**
1031     * Domain. The default value is "".
1032     * @type {string}
1033     * @syscap SystemCapability.Communication.NetManager.Core
1034     * @since 8
1035     */
1036    domains: string;
1037    /**
1038     * Link information.
1039     * @type {Array<LinkAddress>}
1040     * @syscap SystemCapability.Communication.NetManager.Core
1041     * @since 8
1042     */
1043    linkAddresses: Array<LinkAddress>;
1044
1045    /**
1046     * Network address, refer to [NetAddress].
1047     * @type {Array<NetAddress>}
1048     * @syscap SystemCapability.Communication.NetManager.Core
1049     * @since 8
1050     */
1051    dnses: Array<NetAddress>;
1052
1053    /**
1054     * Routing information.
1055     * @type {Array<RouteInfo>}
1056     * @syscap SystemCapability.Communication.NetManager.Core
1057     * @since 8
1058     */
1059    routes: Array<RouteInfo>;
1060
1061    /**
1062     * Maximum transmission unit.
1063     * @type {number}
1064     * @syscap SystemCapability.Communication.NetManager.Core
1065     * @since 8
1066     */
1067    mtu: number;
1068  }
1069
1070  /**
1071   * Defines network route information.
1072   * @interface RouteInfo
1073   * @syscap SystemCapability.Communication.NetManager.Core
1074   * @since 8
1075   */
1076  export interface RouteInfo {
1077    /**
1078     * Network card name.
1079     * @type {string}
1080     * @syscap SystemCapability.Communication.NetManager.Core
1081     * @since 8
1082     */
1083    interface: string;
1084
1085    /**
1086     * Destination Address
1087     * @type {LinkAddress}
1088     * @syscap SystemCapability.Communication.NetManager.Core
1089     * @since 8
1090     */
1091    destination: LinkAddress;
1092
1093    /**
1094     * Gateway address.
1095     * @type {NetAddress}
1096     * @syscap SystemCapability.Communication.NetManager.Core
1097     * @since 8
1098     */
1099    gateway: NetAddress;
1100
1101    /**
1102     * Whether a gateway is present.
1103     * @type {boolean}
1104     * @syscap SystemCapability.Communication.NetManager.Core
1105     * @since 8
1106     */
1107    hasGateway: boolean;
1108
1109    /**
1110     * Whether the route is the default route.
1111     * @type {boolean}
1112     * @syscap SystemCapability.Communication.NetManager.Core
1113     * @since 8
1114     */
1115    isDefaultRoute: boolean;
1116  }
1117
1118  /**
1119   * Defines network link information.
1120   * @interface LinkAddress
1121   * @syscap SystemCapability.Communication.NetManager.Core
1122   * @since 8
1123   */
1124  export interface LinkAddress {
1125    /**
1126     * Link address.
1127     * @type {NetAddress}
1128     * @syscap SystemCapability.Communication.NetManager.Core
1129     * @since 8
1130     */
1131    address: NetAddress;
1132    /**
1133     * The length of the link address prefix.
1134     * @type {number}
1135     * @syscap SystemCapability.Communication.NetManager.Core
1136     * @since 8
1137     */
1138    prefixLength: number;
1139  }
1140
1141  /**
1142   * Defines a network address.
1143   * @interface NetAddress
1144   * @syscap SystemCapability.Communication.NetManager.Core
1145   * @since 8
1146   */
1147  export interface NetAddress {
1148    /**
1149     * Network address.
1150     * @type {string}
1151     * @syscap SystemCapability.Communication.NetManager.Core
1152     * @since 8
1153     */
1154    address: string;
1155
1156    /**
1157     * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1.
1158     * @type {?number}
1159     * @syscap SystemCapability.Communication.NetManager.Core
1160     * @since 8
1161     */
1162    family?: number;
1163
1164    /**
1165     * Port number. The value ranges from 0 to 65535.
1166     * @type {?number}
1167     * @syscap SystemCapability.Communication.NetManager.Core
1168     * @since 8
1169     */
1170    port?: number;
1171  }
1172
1173  /**
1174   * Network Global Proxy Configuration Information.
1175   * @interface HttpProxy
1176   * @syscap SystemCapability.Communication.NetManager.Core
1177   * @since 10
1178   */
1179  export interface HttpProxy {
1180    /**
1181     * Proxy server host name.
1182     * @type {string}
1183     * @syscap SystemCapability.Communication.NetManager.Core
1184     * @since 10
1185     */
1186    host: string;
1187
1188    /**
1189     * Host port.
1190     * @type {number}
1191     * @syscap SystemCapability.Communication.NetManager.Core
1192     * @since 10
1193     */
1194    port: number;
1195
1196    /**
1197     * Do not use a blocking list for proxy servers.
1198     * @type {Array<string>}
1199     * @syscap SystemCapability.Communication.NetManager.Core
1200     * @since 10
1201     */
1202    exclusionList: Array<string>;
1203  }
1204}
1205
1206export default connection;