• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.enterprise.networkManager (Network Management) (System API)
2
3The **networkManager** module provides APIs for network management of enterprise devices, including obtaining the device IP address and MAC address.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> - The APIs of this module can be used only in the stage model.
10>
11> - The APIs of this module can be called only by a [device administrator application](../../mdm/mdm-kit-guide.md#introduction) that is [enabled](js-apis-enterprise-adminManager-sys.md#adminmanagerenableadmin-2).
12>
13> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.enterprise.networkManager](js-apis-enterprise-networkManager.md).
14
15## Modules to Import
16
17```ts
18import { networkManager } from '@kit.MDMKit';
19```
20
21## networkManager.getAllNetworkInterfaces
22
23getAllNetworkInterfaces(admin: Want, callback: AsyncCallback<Array<string>>): void
24
25Obtains all activated wired network interfaces. This API uses an asynchronous callback to return the result.
26
27**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO
28
29**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
30
31
32**Parameters**
33
34| Name     | Type                                      | Mandatory  | Description                      |
35| -------- | ---------------------------------------- | ---- | ------------------------------- |
36| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)     | Yes   | EnterpriseAdminExtensionAbility.           |
37| callback | AsyncCallback<Array<string>>            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is an array of network ports obtained. If the operation fails, **err** is an error object.    |
38
39**Error codes**
40
41For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
42
43| ID| Error Message                                                                      |
44| ------- | ---------------------------------------------------------------------------- |
45| 9200001 | The application is not an administrator application of the device.            |
46| 9200002 | The administrator application does not have permission to manage the device. |
47| 201 | Permission verification failed. The application does not have the permission required to call the API. |
48| 202 | Permission verification failed. A non-system application calls a system API. |
49| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
50
51**Example**
52
53```ts
54import { Want } from '@kit.AbilityKit';
55
56let wantTemp: Want = {
57  bundleName: 'com.example.myapplication',
58  abilityName: 'EntryAbility',
59};
60
61networkManager.getAllNetworkInterfaces(wantTemp, (err, result) => {
62  if (err) {
63    console.error(`Failed to get all network interfaces. Code: ${err.code}, message: ${err.message}`);
64    return;
65  }
66  console.info(`Succeeded in getting all network interfaces, result : ${JSON.stringify(result)}`);
67});
68```
69
70## networkManager.getAllNetworkInterfaces
71
72getAllNetworkInterfaces(admin: Want): Promise<Array<string>>
73
74Obtains all activated wired network interfaces. This API uses a promise to return the result.
75
76**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO
77
78**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
79
80
81**Parameters**
82
83| Name| Type                                                   | Mandatory| Description                  |
84| ------ | ------------------------------------------------------- | ---- | ---------------------- |
85| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.|
86
87**Return value**
88
89| Type                  | Description                     |
90| --------------------- | ------------------------- |
91| Promise<Array<string>> | Promise used to return the names of all activated wired network interfaces.|
92
93**Error codes**
94
95For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
96
97| ID| Error Message                                                                    |
98| ------- | ---------------------------------------------------------------------------- |
99| 9200001 | The application is not an administrator application of the device.            |
100| 9200002 | The administrator application does not have permission to manage the device. |
101| 201 | Permission verification failed. The application does not have the permission required to call the API. |
102| 202 | Permission verification failed. A non-system application calls a system API. |
103| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
104
105**Example**
106
107```ts
108import { Want } from '@kit.AbilityKit';
109import { BusinessError } from '@kit.BasicServicesKit';
110
111let wantTemp: Want = {
112  bundleName: 'com.example.myapplication',
113  abilityName: 'EntryAbility',
114};
115
116networkManager.getAllNetworkInterfaces(wantTemp).then((result) => {
117  console.info(`Succeeded in getting all network interfaces, result : ${JSON.stringify(result)}`);
118}).catch((err: BusinessError) => {
119  console.error(`Failed to get all network interfaces. Code: ${err.code}, message: ${err.message}`);
120});
121```
122
123## networkManager.getIpAddress
124
125getIpAddress(admin: Want, networkInterface: string, callback: AsyncCallback<string>): void
126
127Obtains the device IP address based on the network interface. This API uses an asynchronous callback to return the result.
128
129**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO
130
131**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
132
133
134**Parameters**
135
136| Name     | Type                                      | Mandatory  | Description                      |
137| -------- | ---------------------------------------- | ---- | ------------------------------- |
138| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)     | Yes   | EnterpriseAdminExtensionAbility.           |
139| networkInterface    | string     | Yes   | Network port.                 |
140| callback | AsyncCallback<string>            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the IP address obtained. If the operation fails, **err** is an error object.      |
141
142**Error codes**
143
144For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
145
146| ID| Error Message                                                                      |
147| ------- | ---------------------------------------------------------------------------- |
148| 9200001 | The application is not an administrator application of the device.            |
149| 9200002 | The administrator application does not have permission to manage the device. |
150| 201 | Permission verification failed. The application does not have the permission required to call the API. |
151| 202 | Permission verification failed. A non-system application calls a system API. |
152| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
153
154**Example**
155
156```ts
157import { Want } from '@kit.AbilityKit';
158
159let wantTemp: Want = {
160  bundleName: 'com.example.myapplication',
161  abilityName: 'EntryAbility',
162};
163
164networkManager.getIpAddress(wantTemp, 'eth0', (err, result) => {
165  if (err) {
166    console.error(`Failed to get ip address. Code: ${err.code}, message: ${err.message}`);
167    return;
168  }
169  console.info(`Succeeded in getting ip address, result : ${result}`);
170});
171```
172
173## networkManager.getIpAddress
174
175getIpAddress(admin: Want, networkInterface: string): Promise<string>
176
177Obtains the device IP address based on the network interface. This API uses a promise to return the result.
178
179**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO
180
181**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
182
183
184**Parameters**
185
186| Name  | Type                                 | Mandatory  | Description     |
187| ----- | ----------------------------------- | ---- | ------- |
188| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes   | EnterpriseAdminExtensionAbility.|
189| networkInterface    | string     | Yes   | Network port.                 |
190
191**Return value**
192
193| Type                  | Description                     |
194| --------------------- | ------------------------- |
195| Promise<string> | Promise used to return the device IP address obtained. |
196
197**Error codes**
198
199For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
200
201| ID| Error Message                                                                    |
202| ------- | ---------------------------------------------------------------------------- |
203| 9200001 | The application is not an administrator application of the device.            |
204| 9200002 | The administrator application does not have permission to manage the device. |
205| 201 | Permission verification failed. The application does not have the permission required to call the API. |
206| 202 | Permission verification failed. A non-system application calls a system API. |
207| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
208
209**Example**
210
211```ts
212import { Want } from '@kit.AbilityKit';
213import { BusinessError } from '@kit.BasicServicesKit';
214
215let wantTemp: Want = {
216  bundleName: 'com.example.myapplication',
217  abilityName: 'EntryAbility',
218};
219
220networkManager.getIpAddress(wantTemp, 'eth0').then((result) => {
221  console.info(`Succeeded in getting ip address, result : ${result}`);
222}).catch((err: BusinessError) => {
223  console.error(`Failed to get ip address. Code: ${err.code}, message: ${err.message}`);
224});
225```
226
227## networkManager.getMac
228
229getMac(admin: Want, networkInterface: string, callback: AsyncCallback<string>): void
230
231Obtains the MAC address of a device based on the network interface. This API uses an asynchronous callback to return the result.
232
233**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO
234
235**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
236
237
238**Parameters**
239
240| Name     | Type                                      | Mandatory  | Description                      |
241| -------- | ---------------------------------------- | ---- | ------------------------------- |
242| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes   | EnterpriseAdminExtensionAbility.           |
243| networkInterface    | string     | Yes   | Network port.                 |
244| callback | AsyncCallback<string>            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the MAC address obtained. If the operation fails, **err** is an error object.      |
245
246**Error codes**
247
248For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
249
250| ID| Error Message                                                                      |
251| ------- | ---------------------------------------------------------------------------- |
252| 9200001 | The application is not an administrator application of the device.            |
253| 9200002 | The administrator application does not have permission to manage the device. |
254| 201 | Permission verification failed. The application does not have the permission required to call the API. |
255| 202 | Permission verification failed. A non-system application calls a system API. |
256| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
257
258**Example**
259
260```ts
261import { Want } from '@kit.AbilityKit';
262
263let wantTemp: Want = {
264  bundleName: 'com.example.myapplication',
265  abilityName: 'EntryAbility',
266};
267
268networkManager.getMac(wantTemp, 'eth0', (err, result) => {
269  if (err) {
270    console.error(`Failed to get mac. Code: ${err.code}, message: ${err.message}`);
271    return;
272  }
273  console.info(`Succeeded in getting mac, result : ${result}`);
274});
275```
276
277## networkManager.getMac
278
279getMac(admin: Want, networkInterface: string): Promise\<string>
280
281Obtains the MAC address of a device based on the network interface. This API uses a promise to return the result.
282
283**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO
284
285**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
286
287
288**Parameters**
289
290| Name  | Type                                 | Mandatory  | Description     |
291| ----- | ----------------------------------- | ---- | ------- |
292| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes   | EnterpriseAdminExtensionAbility.|
293| networkInterface    | string     | Yes   | Network port.                 |
294
295**Return value**
296
297| Type                  | Description                     |
298| --------------------- | ------------------------- |
299| Promise&lt;string&gt; | Promise used to return the device MAC address obtained. |
300
301**Error codes**
302
303For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
304
305| ID| Error Message                                                                    |
306| ------- | ---------------------------------------------------------------------------- |
307| 9200001 | The application is not an administrator application of the device.            |
308| 9200002 | The administrator application does not have permission to manage the device. |
309| 201 | Permission verification failed. The application does not have the permission required to call the API. |
310| 202 | Permission verification failed. A non-system application calls a system API. |
311| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
312
313**Example**
314
315```ts
316import { Want } from '@kit.AbilityKit';
317import { BusinessError } from '@kit.BasicServicesKit';
318
319let wantTemp: Want = {
320  bundleName: 'com.example.myapplication',
321  abilityName: 'EntryAbility',
322};
323
324networkManager.getMac(wantTemp, 'eth0').then((result) => {
325  console.info(`Succeeded in getting mac, result : ${result}`);
326}).catch((err: BusinessError) => {
327  console.error(`Failed to get mac. Code: ${err.code}, message: ${err.message}`);
328});
329```
330
331## networkManager.isNetworkInterfaceDisabled
332
333isNetworkInterfaceDisabled(admin: Want, networkInterface: string, callback: AsyncCallback&lt;boolean&gt;): void
334
335Queries whether a specified network interface is disabled. This API uses an asynchronous callback to return the result.
336
337**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO
338
339**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
340
341
342**Parameters**
343
344| Name     | Type                                      | Mandatory  | Description                      |
345| -------- | ---------------------------------------- | ---- | ------------------------------- |
346| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes   | EnterpriseAdminExtensionAbility.           |
347| networkInterface    | string     | Yes   | Network port.                 |
348| callback | AsyncCallback&lt;boolean&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**, and **data** indicates whether the network port is disabled. The value **true** means the network port is disabled; and **false** means the opposite. If the operation fails, **err** is an error object.      |
349
350**Error codes**
351
352For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
353
354| ID| Error Message                                                                      |
355| ------- | ---------------------------------------------------------------------------- |
356| 9200001 | The application is not an administrator application of the device.            |
357| 9200002 | The administrator application does not have permission to manage the device. |
358| 201 | Permission verification failed. The application does not have the permission required to call the API. |
359| 202 | Permission verification failed. A non-system application calls a system API. |
360| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
361
362**Example**
363
364```ts
365import { Want } from '@kit.AbilityKit';
366
367let wantTemp: Want = {
368  bundleName: 'com.example.myapplication',
369  abilityName: 'EntryAbility',
370};
371
372networkManager.isNetworkInterfaceDisabled(wantTemp, 'eth0', (err, result) => {
373  if (err) {
374    console.error(`Failed to query network interface is disabled or not. Code: ${err.code}, message: ${err.message}`);
375    return;
376  }
377  console.info(`Succeeded in querying network interface is disabled or not, result : ${result}`);
378});
379```
380
381## networkManager.isNetworkInterfaceDisabled
382
383isNetworkInterfaceDisabled(admin: Want, networkInterface: string): Promise&lt;boolean&gt;
384
385Queries whether a specified network interface is disabled. This API uses a promise to return the result.
386
387**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO
388
389**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
390
391
392**Parameters**
393
394| Name  | Type                                 | Mandatory  | Description     |
395| ----- | ----------------------------------- | ---- | ------- |
396| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes   | EnterpriseAdminExtensionAbility.|
397| networkInterface    | string     | Yes   | Network port.                 |
398
399**Return value**
400
401| Type                  | Description                     |
402| --------------------- | ------------------------- |
403| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the network port is disabled, and the value **false** means the opposite. |
404
405**Error codes**
406
407For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
408
409| ID| Error Message                                                                    |
410| ------- | ---------------------------------------------------------------------------- |
411| 9200001 | The application is not an administrator application of the device.            |
412| 9200002 | The administrator application does not have permission to manage the device. |
413| 201 | Permission verification failed. The application does not have the permission required to call the API. |
414| 202 | Permission verification failed. A non-system application calls a system API. |
415| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
416
417**Example**
418
419```ts
420import { Want } from '@kit.AbilityKit';
421import { BusinessError } from '@kit.BasicServicesKit';
422
423let wantTemp: Want = {
424  bundleName: 'com.example.myapplication',
425  abilityName: 'EntryAbility',
426};
427
428networkManager.isNetworkInterfaceDisabled(wantTemp, 'eth0').then((result) => {
429  console.info(`Succeeded in querying network interface is disabled or not, result : ${result}`);
430}).catch((err: BusinessError) => {
431  console.error(`Failed to query network interface is disabled or not. Code: ${err.code}, message: ${err.message}`);
432});
433```
434
435## networkManager.setNetworkInterfaceDisabled
436
437setNetworkInterfaceDisabled(admin: Want, networkInterface: string, isDisabled: boolean, callback: AsyncCallback&lt;void&gt;): void
438
439Disables a network interface. This API uses an asynchronous callback to return the result.
440
441**Required permissions**: ohos.permission.ENTERPRISE_SET_NETWORK
442
443**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
444
445
446**Parameters**
447
448| Name     | Type                                      | Mandatory  | Description                      |
449| -------- | ---------------------------------------- | ---- | ------------------------------- |
450| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes   | EnterpriseAdminExtensionAbility.           |
451| networkInterface    | string     | Yes   | Network port.                 |
452| isDisabled    | boolean     | Yes   | Network port status to set. The value **true** means to disable the network port, and **false** means to enable the network port.                 |
453| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
454
455**Error codes**
456
457For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
458
459| ID| Error Message                                                                    |
460| ------- | ---------------------------------------------------------------------------- |
461| 9200001 | The application is not an administrator application of the device.           |
462| 9200002 | The administrator application does not have permission to manage the device. |
463| 201 | Permission verification failed. The application does not have the permission required to call the API. |
464| 202 | Permission verification failed. A non-system application calls a system API. |
465| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
466
467**Example**
468
469```ts
470import { Want } from '@kit.AbilityKit';
471
472let wantTemp: Want = {
473  bundleName: 'com.example.myapplication',
474  abilityName: 'EntryAbility',
475};
476
477networkManager.setNetworkInterfaceDisabled(wantTemp, 'eth0', true, (err) => {
478  if (err) {
479    console.error(`Failed to set network interface disabled. Code: ${err.code}, message: ${err.message}`);
480    return;
481  }
482  console.info(`Succeeded in setting network interface disabled`);
483});
484```
485
486## networkManager.setNetworkInterfaceDisabled
487
488setNetworkInterfaceDisabled(admin: Want, networkInterface: string, isDisabled: boolean): Promise&lt;void&gt;
489
490Disables a network interface. This API uses a promise to return the result.
491
492**Required permissions**: ohos.permission.ENTERPRISE_SET_NETWORK
493
494**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
495
496
497**Parameters**
498
499| Name  | Type                                 | Mandatory  | Description     |
500| ----- | ----------------------------------- | ---- | ------- |
501| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes   | EnterpriseAdminExtensionAbility.|
502| networkInterface    | string     | Yes   | Network port.                 |
503| isDisabled    | boolean     | Yes   | Network port status to set. The value **true** means to disable the network port, and **false** means to enable the network port.                 |
504
505**Return value**
506
507| Type                  | Description                     |
508| --------------------- | ------------------------- |
509| Promise&lt;void&gt; | Promise that returns no value. An error object is thrown if the network port fails to be disabled.|
510
511**Error codes**
512
513For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
514
515| ID| Error Message                                                                    |
516| ------- | ---------------------------------------------------------------------------- |
517| 9200001 | The application is not an administrator application of the device.           |
518| 9200002 | The administrator application does not have permission to manage the device. |
519| 201 | Permission verification failed. The application does not have the permission required to call the API. |
520| 202 | Permission verification failed. A non-system application calls a system API. |
521| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
522
523**Example**
524
525```ts
526import { Want } from '@kit.AbilityKit';
527import { BusinessError } from '@kit.BasicServicesKit';
528
529let wantTemp: Want = {
530  bundleName: 'com.example.myapplication',
531  abilityName: 'EntryAbility',
532};
533
534networkManager.setNetworkInterfaceDisabled(wantTemp, 'eth0', true).then(() => {
535  console.info(`Succeeded in setting network interface disabled`);
536}).catch((err: BusinessError) => {
537  console.error(`Failed to set network interface disabled. Code: ${err.code}, message: ${err.message}`);
538});
539```
540
541## networkManager.setGlobalProxy
542
543setGlobalProxy(admin: Want, httpProxy: connection.HttpProxy, callback: AsyncCallback\<void>): void
544
545Sets the global network proxy. This API uses an asynchronous callback to return the result.
546
547**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
548
549**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
550
551
552**Parameters**
553
554| Name     | Type                                      | Mandatory  | Description                      |
555| -------- | ---------------------------------------- | ---- | ------------------------------- |
556| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes   | EnterpriseAdminExtensionAbility.           |
557| httpProxy    | [connection.HttpProxy](../apis-network-kit/js-apis-net-connection.md#httpproxy10)     | Yes   | Global HTTP proxy to set.                 |
558| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
559
560**Error codes**
561
562For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
563
564| ID| Error Message                                                                    |
565| ------- | ---------------------------------------------------------------------------- |
566| 9200001 | The application is not an administrator application of the device.           |
567| 9200002 | The administrator application does not have permission to manage the device. |
568| 201 | Permission verification failed. The application does not have the permission required to call the API. |
569| 202 | Permission verification failed. A non-system application calls a system API. |
570| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
571
572**Example**
573
574```ts
575import { Want } from '@kit.AbilityKit';
576import { connection } from '@kit.NetworkKit';
577
578let wantTemp: Want = {
579  bundleName: 'com.example.myapplication',
580  abilityName: 'EntryAbility',
581};
582let exclusionStr: string = "192.168,baidu.com"
583let exclusionArray: Array<string> = exclusionStr.split(',');
584let httpProxy: connection.HttpProxy = {
585  host: "192.168.xx.xxx",
586  port: 8080,
587  exclusionList: exclusionArray
588};
589
590networkManager.setGlobalProxy(wantTemp, httpProxy, (err) => {
591  if (err) {
592    console.error(`Failed to set network global proxy. Code: ${err.code}, message: ${err.message}`);
593    return;
594  }
595  console.info(`Succeeded in setting network global proxy`);
596});
597```
598
599## networkManager.setGlobalProxy
600
601setGlobalProxy(admin: Want, httpProxy: connection.HttpProxy): Promise\<void>
602
603Sets the global network proxy. This API uses an asynchronous promise to return the result.
604
605**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
606
607**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
608
609
610**Parameters**
611
612| Name  | Type                                 | Mandatory  | Description     |
613| ----- | ----------------------------------- | ---- | ------- |
614| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes   | EnterpriseAdminExtensionAbility.|
615| httpProxy    | [connection.HttpProxy](../apis-network-kit/js-apis-net-connection.md#httpproxy10)     | Yes   | Global HTTP proxy to set.                 |
616
617**Return value**
618
619| Type                  | Description                     |
620| --------------------- | ------------------------- |
621| Promise&lt;void&gt; | Promise that returns no value. An error object will be thrown if the operation fails.|
622
623**Error codes**
624
625For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
626
627| ID| Error Message                                                                    |
628| ------- | ---------------------------------------------------------------------------- |
629| 9200001 | The application is not an administrator application of the device.           |
630| 9200002 | The administrator application does not have permission to manage the device. |
631| 201 | Permission verification failed. The application does not have the permission required to call the API. |
632| 202 | Permission verification failed. A non-system application calls a system API. |
633| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
634
635**Example**
636
637```ts
638import { Want } from '@kit.AbilityKit';
639import { BusinessError } from '@kit.BasicServicesKit';
640import { connection } from '@kit.NetworkKit';
641
642let wantTemp: Want = {
643  bundleName: 'com.example.myapplication',
644  abilityName: 'EntryAbility',
645};
646let exclusionStr: string = "192.168,baidu.com"
647let exclusionArray: Array<string> = exclusionStr.split(',');
648let httpProxy: connection.HttpProxy = {
649  host: "192.168.xx.xxx",
650  port: 8080,
651  exclusionList: exclusionArray
652};
653
654networkManager.setGlobalProxy(wantTemp, httpProxy).then(() => {
655  console.info(`Succeeded in setting network global proxy`);
656}).catch((err: BusinessError) => {
657  console.error(`Failed to set network global proxy. Code: ${err.code}, message: ${err.message}`);
658});
659```
660
661## networkManager.getGlobalProxy
662
663getGlobalProxy(admin: Want, callback: AsyncCallback\<connection.HttpProxy>): void
664
665Obtains the global network proxy. This API uses an asynchronous callback to return the result.
666
667**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
668
669**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
670
671
672**Parameters**
673
674| Name     | Type                                      | Mandatory  | Description                      |
675| -------- | ---------------------------------------- | ---- | ------------------------------- |
676| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes   | EnterpriseAdminExtensionAbility.           |
677| callback | AsyncCallback&lt;[connection.HttpProxy](../apis-network-kit/js-apis-net-connection.md#httpproxy10)&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
678
679**Error codes**
680
681For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
682
683| ID| Error Message                                                                    |
684| ------- | ---------------------------------------------------------------------------- |
685| 9200001 | The application is not an administrator application of the device.           |
686| 9200002 | The administrator application does not have permission to manage the device. |
687| 201 | Permission verification failed. The application does not have the permission required to call the API. |
688| 202 | Permission verification failed. A non-system application calls a system API. |
689| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
690
691**Example**
692
693```ts
694import { Want } from '@kit.AbilityKit';
695
696let wantTemp: Want = {
697  bundleName: 'com.example.myapplication',
698  abilityName: 'EntryAbility',
699};
700
701networkManager.getGlobalProxy(wantTemp, (err, result) => {
702  if (err) {
703    console.error(`Failed to get network global proxy. Code: ${err.code}, message: ${err.message}`);
704    return;
705  }
706  console.info(`Succeeded in getting network global proxy, result : ${JSON.stringify(result)}`);
707});
708```
709
710## networkManager.getGlobalProxy
711
712getGlobalProxy(admin: Want): Promise\<connection.HttpProxy>
713
714Obtains the global network proxy. This API uses an asynchronous promise to return the result.
715
716**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
717
718**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
719
720
721**Parameters**
722
723| Name| Type                                                   | Mandatory| Description                  |
724| ------ | ------------------------------------------------------- | ---- | ---------------------- |
725| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.|
726
727**Return value**
728
729| Type                  | Description                     |
730| --------------------- | ------------------------- |
731| Promise&lt;[connection.HttpProxy](../apis-network-kit/js-apis-net-connection.md#httpproxy10)&gt; | Promise used to return the global HTTP proxy information obtained. |
732
733**Error codes**
734
735For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
736
737| ID| Error Message                                                                    |
738| ------- | ---------------------------------------------------------------------------- |
739| 9200001 | The application is not an administrator application of the device.           |
740| 9200002 | The administrator application does not have permission to manage the device. |
741| 201 | Permission verification failed. The application does not have the permission required to call the API. |
742| 202 | Permission verification failed. A non-system application calls a system API. |
743| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
744
745**Example**
746
747```ts
748import { Want } from '@kit.AbilityKit';
749import { BusinessError } from '@kit.BasicServicesKit';
750
751let wantTemp: Want = {
752  bundleName: 'com.example.myapplication',
753  abilityName: 'EntryAbility',
754};
755
756networkManager.getGlobalProxy(wantTemp).then(() => {
757  console.info(`Succeeded in getting network global proxy`);
758}).catch((err: BusinessError) => {
759  console.error(`Failed to get network global proxy. Code: ${err.code}, message: ${err.message}`);
760});
761```
762
763## networkManager.addIptablesFilterRule
764
765addIptablesFilterRule(admin: Want, filterRule: AddFilterRule, callback: AsyncCallback\<void>): void
766
767Adds a network packet filtering rule for the device. Only IPv4 is supported. This API uses an asynchronous callback to return the result.
768
769**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
770
771**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
772
773
774**Parameters**
775
776| Name     | Type                                      | Mandatory  | Description                      |
777| -------- | ---------------------------------------- | ---- | ------------------------------- |
778| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes   | EnterpriseAdminExtensionAbility.           |
779| filterRule    | [AddFilterRule](#addfilterrule)     | Yes   | Network packet filtering rule to add.                 |
780| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
781
782**Error codes**
783
784For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
785
786| ID| Error Message                                                                    |
787| ------- | ---------------------------------------------------------------------------- |
788| 9200001 | The application is not an administrator application of the device.           |
789| 9200002 | The administrator application does not have permission to manage the device. |
790| 201 | Permission verification failed. The application does not have the permission required to call the API. |
791| 202 | Permission verification failed. A non-system application calls a system API. |
792| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
793
794**Example**
795
796```ts
797import { Want } from '@kit.AbilityKit';
798
799let wantTemp: Want = {
800  bundleName: 'com.example.myapplication',
801  abilityName: 'EntryAbility',
802};
803let filterRule: networkManager.AddFilterRule = {
804  "ruleNo": 1,
805  "srcAddr": "192.168.1.1-192.168.255.255",
806  "destAddr": "10.1.1.1",
807  "srcPort": "8080",
808  "destPort": "8080",
809  "uid": "9696",
810  "method": networkManager.AddMethod.APPEND,
811  "direction": networkManager.Direction.OUTPUT,
812  "action": networkManager.Action.DENY,
813  "protocol": networkManager.Protocol.UDP,
814}
815
816networkManager.addIptablesFilterRule(wantTemp, filterRule, (err) => {
817  if (err) {
818    console.error(`Failed to set iptables filter rule. Code: ${err.code}, message: ${err.message}`);
819    return;
820  }
821  console.info(`Succeeded in setting iptables filter rule`);
822});
823```
824
825## networkManager.addIptablesFilterRule
826
827addIptablesFilterRule(admin: Want, filterRule: AddFilterRule): Promise\<void>
828
829Adds a network packet filtering rule for the device. Only IPv4 is supported. This API uses a promise to return the result.
830
831**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
832
833**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
834
835
836**Parameters**
837
838| Name  | Type                                 | Mandatory  | Description     |
839| ----- | ----------------------------------- | ---- | ------- |
840| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes   | EnterpriseAdminExtensionAbility.|
841| filterRule    | [AddFilterRule](#addfilterrule)     | Yes   | Network packet filtering rule to add.                 |
842
843**Return value**
844
845| Type                  | Description                     |
846| --------------------- | ------------------------- |
847| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
848
849**Error codes**
850
851For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
852
853| ID| Error Message                                                                    |
854| ------- | ---------------------------------------------------------------------------- |
855| 9200001 | The application is not an administrator application of the device.           |
856| 9200002 | The administrator application does not have permission to manage the device. |
857| 201 | Permission verification failed. The application does not have the permission required to call the API. |
858| 202 | Permission verification failed. A non-system application calls a system API. |
859| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
860
861**Example**
862
863```ts
864import { Want } from '@kit.AbilityKit';
865import { BusinessError } from '@kit.BasicServicesKit';
866
867let wantTemp: Want = {
868  bundleName: 'com.example.myapplication',
869  abilityName: 'EntryAbility',
870};
871let filterRule: networkManager.AddFilterRule = {
872  "ruleNo": 1,
873  "srcAddr": "192.168.1.1-192.168.255.255",
874  "destAddr": "10.1.1.1",
875  "srcPort": "8080",
876  "destPort": "8080",
877  "uid": "9696",
878  "method": networkManager.AddMethod.APPEND,
879  "direction": networkManager.Direction.OUTPUT,
880  "action": networkManager.Action.DENY,
881  "protocol": networkManager.Protocol.UDP,
882}
883
884networkManager.addIptablesFilterRule(wantTemp, filterRule).then(() => {
885  console.info(`Succeeded in setting iptables filter rule`);
886}).catch((err: BusinessError) => {
887  console.error(`Failed to set iptables filter rule. Code: ${err.code}, message: ${err.message}`);
888});
889```
890
891## networkManager.removeIptablesFilterRule
892
893removeIptablesFilterRule(admin: Want, filterRule: RemoveFilterRule, callback: AsyncCallback\<void>): void
894
895Removes the network packet filtering rule. Only IPv4 is supported. This API uses an asynchronous callback to return the result.
896
897**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
898
899**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
900
901
902**Parameters**
903
904| Name     | Type                                      | Mandatory  | Description                      |
905| -------- | ---------------------------------------- | ---- | ------------------------------- |
906| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes   | EnterpriseAdminExtensionAbility.           |
907| filterRule    | [RemoveFilterRule](#removefilterrule)     | Yes   | Network packet filtering rule to remove.                 |
908| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
909
910**Error codes**
911
912For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
913
914| ID| Error Message                                                                    |
915| ------- | ---------------------------------------------------------------------------- |
916| 9200001 | The application is not an administrator application of the device.           |
917| 9200002 | The administrator application does not have permission to manage the device. |
918| 201 | Permission verification failed. The application does not have the permission required to call the API. |
919| 202 | Permission verification failed. A non-system application calls a system API. |
920| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
921
922**Example**
923
924```ts
925import { Want } from '@kit.AbilityKit';
926
927let wantTemp: Want = {
928  bundleName: 'com.example.myapplication',
929  abilityName: 'EntryAbility',
930};
931let filterRule: networkManager.RemoveFilterRule = {
932  "srcAddr": "192.168.1.1-192.168.255.255",
933  "destAddr": "10.1.1.1",
934  "srcPort": "8080",
935  "destPort": "8080",
936  "uid": "9696",
937  "direction": networkManager.Direction.OUTPUT,
938  "action": networkManager.Action.DENY,
939  "protocol": networkManager.Protocol.UDP,
940}
941
942networkManager.removeIptablesFilterRule(wantTemp, filterRule, (err) => {
943  if (err) {
944    console.error(`Failed to remove iptables filter rule. Code: ${err.code}, message: ${err.message}`);
945    return;
946  }
947  console.info(`Succeeded in removing iptables filter rule`);
948});
949```
950
951## networkManager.removeIptablesFilterRule
952
953removeIptablesFilterRule(admin: Want, filterRule: RemoveFilterRule): Promise\<void>
954
955Removes the network packet filtering rule. Only IPv4 is supported. This API uses a promise to return the result.
956
957**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
958
959**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
960
961
962**Parameters**
963
964| Name  | Type                                 | Mandatory  | Description     |
965| ----- | ----------------------------------- | ---- | ------- |
966| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes   | EnterpriseAdminExtensionAbility.|
967| filterRule    | [RemoveFilterRule](#removefilterrule)     | Yes   | Network packet filtering rule to remove.                 |
968
969**Return value**
970
971| Type                  | Description                     |
972| --------------------- | ------------------------- |
973| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
974
975**Error codes**
976
977For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
978
979| ID| Error Message                                                                    |
980| ------- | ---------------------------------------------------------------------------- |
981| 9200001 | The application is not an administrator application of the device.           |
982| 9200002 | The administrator application does not have permission to manage the device. |
983| 201 | Permission verification failed. The application does not have the permission required to call the API. |
984| 202 | Permission verification failed. A non-system application calls a system API. |
985| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
986
987**Example**
988
989```ts
990import { Want } from '@kit.AbilityKit';
991import { BusinessError } from '@kit.BasicServicesKit';
992
993let wantTemp: Want = {
994  bundleName: 'com.example.myapplication',
995  abilityName: 'EntryAbility',
996};
997let filterRule: networkManager.RemoveFilterRule = {
998  "srcAddr": "192.168.1.1-192.168.255.255",
999  "destAddr": "10.1.1.1",
1000  "srcPort": "8080",
1001  "destPort": "8080",
1002  "uid": "9696",
1003  "direction": networkManager.Direction.OUTPUT,
1004  "action": networkManager.Action.DENY,
1005  "protocol": networkManager.Protocol.UDP,
1006}
1007
1008networkManager.removeIptablesFilterRule(wantTemp, filterRule).then(() => {
1009  console.info(`Succeeded in removing iptables filter rule`);
1010}).catch((err: BusinessError) => {
1011  console.error(`Failed to remove iptables filter rule. Code: ${err.code}, message: ${err.message}`);
1012});
1013```
1014
1015## networkManager.listIptablesFilterRules
1016
1017listIptablesFilterRules(admin: Want, callback: AsyncCallback\<string>): void
1018
1019Obtains the network packet filtering rule. Only IPv4 is supported. This API uses an asynchronous callback to return the result.
1020
1021**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
1022
1023**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1024
1025
1026**Parameters**
1027
1028| Name     | Type                                      | Mandatory  | Description                      |
1029| -------- | ---------------------------------------- | ---- | ------------------------------- |
1030| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes   | EnterpriseAdminExtensionAbility.           |
1031| callback | AsyncCallback&lt;string&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1032
1033**Error codes**
1034
1035For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
1036
1037| ID| Error Message                                                                    |
1038| ------- | ---------------------------------------------------------------------------- |
1039| 9200001 | The application is not an administrator application of the device.           |
1040| 9200002 | The administrator application does not have permission to manage the device. |
1041| 201 | Permission verification failed. The application does not have the permission required to call the API. |
1042| 202 | Permission verification failed. A non-system application calls a system API. |
1043| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1044
1045**Example**
1046
1047```ts
1048import { Want } from '@kit.AbilityKit';
1049
1050let wantTemp: Want = {
1051  bundleName: 'com.example.myapplication',
1052  abilityName: 'EntryAbility',
1053};
1054
1055networkManager.listIptablesFilterRules(wantTemp, (err, result) => {
1056  if (err) {
1057    console.error(`Failed to get iptables filter rule. Code: ${err.code}, message: ${err.message}`);
1058    return;
1059  }
1060  console.info(`Succeeded in getting iptables filter rule, result : ${result}`);
1061});
1062```
1063
1064## networkManager.listIptablesFilterRules
1065
1066listIptablesFilterRules(admin: Want): Promise\<string>
1067
1068Obtains the network packet filtering rule. Only IPv4 is supported. This API uses a promise to return the result.
1069
1070**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK
1071
1072**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1073
1074
1075**Parameters**
1076
1077| Name| Type                                                   | Mandatory| Description                  |
1078| ------ | ------------------------------------------------------- | ---- | ---------------------- |
1079| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.|
1080
1081**Return value**
1082
1083| Type                  | Description                     |
1084| --------------------- | ------------------------- |
1085| Promise&lt;string&gt; | Promise used to return the network packet filtering rules obtained.|
1086
1087**Error codes**
1088
1089For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
1090
1091| ID| Error Message                                                                    |
1092| ------- | ---------------------------------------------------------------------------- |
1093| 9200001 | The application is not an administrator application of the device.           |
1094| 9200002 | The administrator application does not have permission to manage the device. |
1095| 201 | Permission verification failed. The application does not have the permission required to call the API. |
1096| 202 | Permission verification failed. A non-system application calls a system API. |
1097| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1098
1099**Example**
1100
1101```ts
1102import { Want } from '@kit.AbilityKit';
1103import { BusinessError } from '@kit.BasicServicesKit';
1104
1105let wantTemp: Want = {
1106  bundleName: 'com.example.myapplication',
1107  abilityName: 'EntryAbility',
1108};
1109
1110networkManager.listIptablesFilterRules(wantTemp).then((result) => {
1111  console.info(`Succeeded in getting iptables filter rule, result: ${result}`);
1112}).catch((err: BusinessError) => {
1113  console.error(`Failed to remove iptables filter rule. Code: ${err.code}, message: ${err.message}`);
1114});
1115```
1116
1117## AddFilterRule
1118
1119Network packet filtering rule to add.
1120
1121**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1122
1123
1124| Name        | Type    | Read-Only| Optional| Description                           |
1125| ----------- | --------| ---- | ---- | ------------------------------- |
1126| ruleNo        | number    | No  | Yes| Sequence number of the rule.|
1127| srcAddr | string   | No  | Yes| Source IP address.|
1128| destAddr        | string    | No  | Yes| Destination IP address.|
1129| srcPort | string   | No  | Yes| Port of the source IP address.|
1130| destPort        | string    | No  | Yes| Port of the destination IP address.|
1131| uid | string   | No  | Yes| UID of the application.|
1132| method        | [AddMethod](#addmethod)    | No  | No| Method used to add the data packets.|
1133| direction | [Direction](js-apis-enterprise-networkManager.md#direction) | No  | No| Direction chains to which the rule applies.|
1134| action        | [Action](js-apis-enterprise-networkManager.md#action) | No  | No| Action to take, that is, receive or discard the data packets.|
1135| protocol | [Protocol](js-apis-enterprise-networkManager.md#protocol) | No  | Yes|Network protocol.|
1136
1137## RemoveFilterRule
1138
1139Network packet filtering rule to remove.
1140
1141**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1142
1143
1144| Name        | Type    | Read-Only| Optional| Description                           |
1145| ----------- | --------| ---- | ---- | ------------------------------ |
1146| srcAddr | string   | No  | Yes| Source IP address.|
1147| destAddr        | string    | No  | Yes| Destination IP address.|
1148| srcPort | string   | No  | Yes| Port of the source IP address.|
1149| destPort        | string    | No   | Yes| Port of the destination IP address.|
1150| uid | string   | No   | Yes| UID of the application.|
1151| direction | [Direction](js-apis-enterprise-networkManager.md#direction) | No   | No| Direction chains to which the rule applies.|
1152| action        | [Action](js-apis-enterprise-networkManager.md#action) | No   | Yes| Action to take, that is, receive or discard the data packets.|
1153| protocol | [Protocol](js-apis-enterprise-networkManager.md#protocol) | No   | Yes| Network protocol.|
1154
1155## AddMethod
1156
1157Enumerates the methods used to add the network packets.
1158
1159**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1160
1161
1162| Name| Value| Description|
1163| -------- | -------- | -------- |
1164| APPEND | 0 | Append the packet.|
1165| INSERT | 1 | Insert the packet.|
1166