Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
figures/ | 12-May-2024 | - | ||||
frameworks/ | 12-May-2024 | - | 9,500 | 7,034 | ||
interfaces/ | 12-May-2024 | - | 3,880 | 1,612 | ||
sa_profile/ | 12-May-2024 | - | 97 | 58 | ||
services/ | 12-May-2024 | - | 13,039 | 10,447 | ||
test/ | 12-May-2024 | - | 8,568 | 6,669 | ||
utils/ | 12-May-2024 | - | 460 | 305 | ||
.gitignore | D | 12-May-2024 | 23 | 2 | 2 | |
BUILD.gn | D | 12-May-2024 | 2.3 KiB | 71 | 64 | |
LICENSE | D | 12-May-2024 | 9.9 KiB | 177 | 150 | |
OAT.xml | D | 12-May-2024 | 4.2 KiB | 67 | 15 | |
README.md | D | 12-May-2024 | 977 | 37 | 25 | |
README_zh.md | D | 12-May-2024 | 9.8 KiB | 163 | 134 | |
bundle.json | D | 12-May-2024 | 4.5 KiB | 112 | 111 | |
netmanager_ext_config.gni | D | 12-May-2024 | 3.7 KiB | 102 | 85 |
README.md
1# communication_netmanager_standard 2 3#### Description 4{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} 5 6#### Software Architecture 7Software architecture description 8 9#### Installation 10 111. xxxx 122. xxxx 133. xxxx 14 15#### Instructions 16 171. xxxx 182. xxxx 193. xxxx 20 21#### Contribution 22 231. Fork the repository 242. Create Feat_xxx branch 253. Commit your code 264. Create Pull Request 27 28 29#### Gitee Feature 30 311. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md 322. Gitee blog [blog.gitee.com](https://blog.gitee.com) 333. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) 344. The most valuable open source project [GVP](https://gitee.com/gvp) 355. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) 366. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) 37
README_zh.md
1# Net Manager<a name="EN-US_TOPIC_0000001105058232"></a> 2 3- [简介](#简介) 4- [目录](#目录) 5- [约束](#约束) 6- [接口说明](#接口说明) 7- [使用说明](#使用说明) 8- [相关仓](#相关仓) 9 10 11 12## 简介 13 14网络管理介绍: 15 16 网络管理主要分为连接管理、策略管理、流量管理、网络共享、VPN管理以及以太网连接等模块,其中连接管理、策略管理、流量管理为基础服务,归档在netmanager_base仓,以太网连接、网络共享、VPN管理三个模块为可裁剪扩展模块,归档在netmanager_ext仓,netmanager_ext编译构建依赖netmanager_base库内容。如图1:网络管理架构图; 17 18**图 1** 网络管理架构图 19 20 21 22## 目录 23 24``` 25foundation/communication/netmanager_ext/ 26├─figures #README用于的png图片 27├─frameworks #框架层目录 28│ ├─js #js接口实现 29│ └─native #C++接口实现 30├─interfaces #C++接口头文件 31│ ├─innerkits #部件间的内部接口 32│ └─kits #对应用提供的接口(例如JS接口) 33├─sa_profile #SA服务配置文件 34├─services #C++内部实现 35│ ├─ethernetmanager #以太网模块 36│ └─networksharemanager #网络共享模块 37├─test #单元测试代码 38│ ├─ethernetmanager #以太网模块单元测试 39│ └─networkshare #网络共享模块单元测试 40└─utils #核心服务工具代码目录 41 ├─event_report #核心服务事件工具目录 42 └─log #核心服务日志工具目录 43``` 44 45## 约束 46 47- 开发语言:C++ JS 48 49## 接口说明 50 51| 类型 | 接口 | 功能说明 | 52| ---- | ---- | ---- | 53| ohos.net.ethernet | function setIfaceConfig\(iface: string, ic: InterfaceConfiguration, callback: AsyncCallback<void\>\): void; |设置网络接口配置信息,调用callback | 54| ohos.net.ethernet | function setIfaceConfig\(iface: string, ic: InterfaceConfiguration\): Promise<void\>; |设置网络接口配置信息,返回Promise | 55| ohos.net.ethernet | function getIfaceConfig\(iface: string, callback: AsyncCallback<InterfaceConfiguration\>\): void; |获取网络接口配置信息,调用callback | 56| ohos.net.ethernet | function getIfaceConfig\(iface: string\): Promise<InterfaceConfiguration\>; |获取网络接口配置信息,返回Promise | 57| ohos.net.ethernet | function isIfaceActive\(iface?: string, callback: AsyncCallback<number\>\): void; |判断接口是否已激活,调用callback | 58| ohos.net.ethernet | function isIfaceActive\(iface?: string\): Promise<number\>; |判断接口是否已激活,返回Promise | 59| ohos.net.ethernet | function getAllActiveIfaces\(callback: AsyncCallback<Array\<string\>\>\): void; |获取活动的网络接口,调用callback | 60| ohos.net.ethernet | function getAllActiveIfaces\(\): Promise<Array\<string\>\>; |获取活动的网络接口,返回Promise | 61| ohos.net.sharing | function isSharingSupported(callback: AsyncCallback\<boolean>): void; | 获取当前系统是否支持网络共享,调用callback | 62| ohos.net.sharing | function isSharingSupported(): Promise\<boolean>; | 获取当前系统是否支持网络共享,返回promise | 63| ohos.net.sharing | function isSharing(callback: AsyncCallback\<boolean>): void; | 获取当前共享状态,调用callback | 64| ohos.net.sharing | function isSharing(): Promise\<boolean>; | 获取当前共享状态,返回promise | 65| ohos.net.sharing | function startSharing(type: SharingIfaceType, callback: AsyncCallback\<void>): void; | 开启共享,type为共享类型,目前支持Wifi热点、蓝牙、USB,调用callback | 66| ohos.net.sharing | function startSharing(type: SharingIfaceType): Promise\<void>; | 开启共享,type为共享类型,目前支持Wifi热点、蓝牙、USB,返回promise | 67| ohos.net.sharing | function stopSharing(type: SharingIfaceType, callback: AsyncCallback\<void>): void; | 停止指定类型共享,type为共享类型,包括Wifi热点、蓝牙、USB,调用callback | 68| ohos.net.sharing | function stopSharing(type: SharingIfaceType): Promise\<void>; | 停止指定类型共享,type为共享类型,包括Wifi热点、蓝牙、USB,返回promise | 69| ohos.net.sharing | function getStatsRxBytes(callback: AsyncCallback\<number>): void; | 获取共享接收数据量,单位KB,调用callback | 70| ohos.net.sharing | function getStatsRxBytes(): Promise\<number>; | 获取共享接收数据量,单位KB,返回promise | 71| ohos.net.sharing | function getStatsTxBytes(callback: AsyncCallback\<number>): void; | 获取共享发送数据量,单位KB,调用callback | 72| ohos.net.sharing | function getStatsTxBytes(): Promise\<number>; | 获取共享发送数据量,单位KB,返回promise | 73| ohos.net.sharing | function getStatsTotalBytes(callback: AsyncCallback\<number>): void; | 获取共享总数据流量,单位KB,调用callback | 74| ohos.net.sharing | function getStatsTotalBytes(): Promise\<number>; | 获取共享总数据流量,单位KB,返回promise | 75| ohos.net.sharing | function getSharingIfaces(state: SharingIfaceState, callback: AsyncCallback\<Array\<string>>): void; | 获取指定状态的网卡名称,state为状态,包括正在共享、可共享、共享错误,调用callback | 76| ohos.net.sharing | function getSharingIfaces(state: SharingIfaceState): Promise\<Array\<string>>; | 获取指定状态的网卡名称,state为状态,包括正在共享、可共享、共享错误,返回promise | 77| ohos.net.sharing | function getSharingState(type: SharingIfaceType, callback: AsyncCallback\<SharingIfaceState>): void; | 获取指定类型共享状态,type为类型,目前支持Wifi热点、蓝牙、USB,调用callback | 78| ohos.net.sharing | function getSharingState(type: SharingIfaceType): Promise\<SharingIfaceState>; | 获取指定类型共享状态,type为类型,目前支持Wifi热点、蓝牙、USB,返回promise | 79| ohos.net.sharing | function getSharableRegexes(type: SharingIfaceType, callback: AsyncCallback\<Array\<string>>): void; | 获取与指定类型匹配的网卡正则表达式列表,type为类型,目前支持Wifi热点、蓝牙、USB,调用callback | 80| ohos.net.sharing | function getSharableRegexes(type: SharingIfaceType): Promise\<Array\<string>>; | 获取与指定类型匹配的网卡正则表达式列表,type为类型,目前支持Wifi热点、蓝牙、USB,返回promise | 81| ohos.net.sharing | function on(type: 'sharingStateChange', callback: Callback\<boolean>): void; | 注册共享状态改变监听 | 82| ohos.net.sharing | function off(type: 'sharingStateChange', callback?: Callback\<boolean>): void; | 注销共享状态改变监听 | 83| ohos.net.sharing | unction on(type: 'interfaceSharingStateChange', callback: Callback\<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; | 注册指定网卡共享状态改变监听 | 84| ohos.net.sharing | function off(type: 'interfaceSharingStateChange', callback?: Callback\<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; | 注销指定网卡共享状态改变监听 | 85| ohos.net.sharing | function on(type: 'sharingUpstreamChange', callback: Callback\<NetHandle>): void; | 注册上行网卡改变监听 | 86| ohos.net.sharing | function off(type: 'sharingUpstreamChange', callback?: Callback\<NetHandle>): void; | 注销上行网卡改变监听 | 87 88## 接口使用说明 89 90### 设置网络接口配置信息 91 92* 示例 93 ```javascript 94 import ethernet from '@ohos.net.ethernet' 95 ``` 96 ```javascript 97 ethernet.setIfaceConfig("eth0", {mode:ethernet.STATIC,ipAddr:"192.168.1.123", routeAddr:"192.168.1.1", 98 gateAddr:"192.168.1.1", maskAddr:"255.255.255.0", dnsAddr0:"1.1.1.1", dnsAddr1:"2.2.2.2"}, 99 (error) => { 100 if (error) { 101 console.log("setIfaceConfig callback error = " + error); 102 } else { 103 console.log("setIfaceConfig callback ok "); 104 } 105 }); 106 ``` 107 108### 获取网络接口配置信息 109 110* 示例 111 ```javascript 112 import ethernet from '@ohos.net.ethernet' 113 ``` 114 ```javascript 115 ethernet.getIfaceConfig("eth0", (error, value) => { 116 if (error) { 117 console.log("getIfaceConfig callback error = " + error); 118 } else { 119 console.log("getIfaceConfig callback mode = " + value.mode); 120 console.log("getIfaceConfig callback ipAddr = " + value.ipAddr); 121 console.log("getIfaceConfig callback routeAddr = " + value.routeAddr); 122 console.log("getIfaceConfig callback gateAddr = " + value.gateAddr); 123 console.log("getIfaceConfig callback maskAddr = " + value.maskAddr); 124 console.log("getIfaceConfig callback dns0Addr = " + value.dns0Addr); 125 console.log("getIfaceConfig callback dns1Addr = " + value.dns1Addr); 126 } 127 }); 128 ``` 129 130### 开始网络共享 131 132* 示例 133 ```javascript 134 import sharing from '@ohos.net.sharing' 135 ``` 136 ```javascript 137 sharing.startSharing(this.sharingType,(err)=>{ 138 this.callBack(err); 139 }) 140 ``` 141 142### 停止网络共享 143 144* 示例 145 ```javascript 146 import sharing from '@ohos.net.sharing' 147 ``` 148 ```javascript 149 sharing.stopSharing(this.sharingType,(err)=>{ 150 this.callBack(err); 151 }) 152 ``` 153 154## 相关仓 155 156[网络管理子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md) 157 158**communication_netmanager_ext** 159 160[communication_netmanager_base](https://gitee.com/openharmony/communication_netmanager_base) 161 162[communication_netstack](https://gitee.com/openharmony/communication_netstack) 163