5 <title>Source: network.js</title>
8 <script src="scripts/prettify/prettify.js"></script>
9 <script src="scripts/prettify/lang-css.js"></script>
10 <script src="scripts/jquery.min.js"></script>
12 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
14 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
15 <link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css">
16 <link type="text/css" rel="stylesheet" href="styles/jaguar.css">
20 var config = {"monospaceLinks":true,"cleverLinks":true,"default":{"outputSourceFiles":true}};
27 <div id="wrap" class="clearfix">
29 <div class="navigation">
30 <h3 class="applicationName"><a href="index.html"></a></h3>
33 <input id="search" type="text" class="form-control input-sm" placeholder="Search Documentations">
37 <li class="item" data-name="LuCI">
39 <a href="LuCI.html">LuCI</a>
42 <ul class="members itemMembers">
44 <span class="subtitle">Members</span>
46 <li data-name="LuCI#Class"><a href="LuCI.html#Class">Class</a></li>
48 <li data-name="LuCI#dom"><a href="LuCI.html#dom">dom</a></li>
50 <li data-name="LuCI#env"><a href="LuCI.html#env">env</a></li>
52 <li data-name="LuCI#Poll"><a href="LuCI.html#Poll">Poll</a></li>
54 <li data-name="LuCI#Request"><a href="LuCI.html#Request">Request</a></li>
56 <li data-name="LuCI#view"><a href="LuCI.html#view">view</a></li>
59 <ul class="typedefs itemMembers">
61 <span class="subtitle">Typedefs</span>
63 <li data-name="LuCI.requestCallbackFn"><a href="LuCI.html#.requestCallbackFn">requestCallbackFn</a></li>
66 <ul class="typedefs itemMembers">
69 <ul class="methods itemMembers">
71 <span class="subtitle">Methods</span>
73 <li data-name="LuCI#bind"><a href="LuCI.html#bind">bind</a></li>
75 <li data-name="LuCI#error"><a href="LuCI.html#error">error</a></li>
77 <li data-name="LuCI#get"><a href="LuCI.html#get">get</a></li>
79 <li data-name="LuCI#halt"><a href="LuCI.html#halt">halt</a></li>
81 <li data-name="LuCI#hasSystemFeature"><a href="LuCI.html#hasSystemFeature">hasSystemFeature</a></li>
83 <li data-name="LuCI#isObject"><a href="LuCI.html#isObject">isObject</a></li>
85 <li data-name="LuCI#location"><a href="LuCI.html#location">location</a></li>
87 <li data-name="LuCI#media"><a href="LuCI.html#media">media</a></li>
89 <li data-name="LuCI#path"><a href="LuCI.html#path">path</a></li>
91 <li data-name="LuCI#poll"><a href="LuCI.html#poll">poll</a></li>
93 <li data-name="LuCI#post"><a href="LuCI.html#post">post</a></li>
95 <li data-name="LuCI#raise"><a href="LuCI.html#raise">raise</a></li>
97 <li data-name="LuCI#require"><a href="LuCI.html#require">require</a></li>
99 <li data-name="LuCI#resolveDefault"><a href="LuCI.html#resolveDefault">resolveDefault</a></li>
101 <li data-name="LuCI#resource"><a href="LuCI.html#resource">resource</a></li>
103 <li data-name="LuCI#run"><a href="LuCI.html#run">run</a></li>
105 <li data-name="LuCI#sortedKeys"><a href="LuCI.html#sortedKeys">sortedKeys</a></li>
107 <li data-name="LuCI#stop"><a href="LuCI.html#stop">stop</a></li>
109 <li data-name="LuCI#toArray"><a href="LuCI.html#toArray">toArray</a></li>
111 <li data-name="LuCI#url"><a href="LuCI.html#url">url</a></li>
114 <ul class="events itemMembers">
119 <li class="item" data-name="LuCI.baseclass">
121 <a href="LuCI.baseclass.html">LuCI.baseclass</a>
124 <ul class="members itemMembers">
127 <ul class="typedefs itemMembers">
130 <ul class="typedefs itemMembers">
133 <ul class="methods itemMembers">
135 <span class="subtitle">Methods</span>
137 <li data-name="LuCI.baseclass.extend"><a href="LuCI.baseclass.html#.extend">extend</a></li>
139 <li data-name="LuCI.baseclass.instantiate"><a href="LuCI.baseclass.html#.instantiate">instantiate</a></li>
141 <li data-name="LuCI.baseclass.isSubclass"><a href="LuCI.baseclass.html#.isSubclass">isSubclass</a></li>
143 <li data-name="LuCI.baseclass.singleton"><a href="LuCI.baseclass.html#.singleton">singleton</a></li>
145 <li data-name="LuCI.baseclass#super"><a href="LuCI.baseclass.html#super">super</a></li>
147 <li data-name="LuCI.baseclass#varargs"><a href="LuCI.baseclass.html#varargs">varargs</a></li>
150 <ul class="events itemMembers">
155 <li class="item" data-name="LuCI.dom">
157 <a href="LuCI.dom.html">LuCI.dom</a>
160 <ul class="members itemMembers">
163 <ul class="typedefs itemMembers">
165 <span class="subtitle">Typedefs</span>
167 <li data-name="LuCI.dom~ignoreCallbackFn"><a href="LuCI.dom.html#~ignoreCallbackFn">ignoreCallbackFn</a></li>
170 <ul class="typedefs itemMembers">
173 <ul class="methods itemMembers">
175 <span class="subtitle">Methods</span>
177 <li data-name="LuCI.dom#append"><a href="LuCI.dom.html#append">append</a></li>
179 <li data-name="LuCI.dom#attr"><a href="LuCI.dom.html#attr">attr</a></li>
181 <li data-name="LuCI.dom#bindClassInstance"><a href="LuCI.dom.html#bindClassInstance">bindClassInstance</a></li>
183 <li data-name="LuCI.dom#callClassMethod"><a href="LuCI.dom.html#callClassMethod">callClassMethod</a></li>
185 <li data-name="LuCI.dom#content"><a href="LuCI.dom.html#content">content</a></li>
187 <li data-name="LuCI.dom#create"><a href="LuCI.dom.html#create">create</a></li>
189 <li data-name="LuCI.dom#data"><a href="LuCI.dom.html#data">data</a></li>
191 <li data-name="LuCI.dom#elem"><a href="LuCI.dom.html#elem">elem</a></li>
193 <li data-name="LuCI.dom#findClassInstance"><a href="LuCI.dom.html#findClassInstance">findClassInstance</a></li>
195 <li data-name="LuCI.dom#isEmpty"><a href="LuCI.dom.html#isEmpty">isEmpty</a></li>
197 <li data-name="LuCI.dom#matches"><a href="LuCI.dom.html#matches">matches</a></li>
199 <li data-name="LuCI.dom#parent"><a href="LuCI.dom.html#parent">parent</a></li>
201 <li data-name="LuCI.dom#parse"><a href="LuCI.dom.html#parse">parse</a></li>
204 <ul class="events itemMembers">
209 <li class="item" data-name="LuCI.fs">
211 <a href="LuCI.fs.html">LuCI.fs</a>
214 <ul class="members itemMembers">
217 <ul class="typedefs itemMembers">
219 <span class="subtitle">Typedefs</span>
221 <li data-name="LuCI.fs.FileExecResult"><a href="LuCI.fs.html#.FileExecResult">FileExecResult</a></li>
223 <li data-name="LuCI.fs.FileStatEntry"><a href="LuCI.fs.html#.FileStatEntry">FileStatEntry</a></li>
226 <ul class="typedefs itemMembers">
229 <ul class="methods itemMembers">
231 <span class="subtitle">Methods</span>
233 <li data-name="LuCI.fs#exec"><a href="LuCI.fs.html#exec">exec</a></li>
235 <li data-name="LuCI.fs#exec_direct"><a href="LuCI.fs.html#exec_direct">exec_direct</a></li>
237 <li data-name="LuCI.fs#lines"><a href="LuCI.fs.html#lines">lines</a></li>
239 <li data-name="LuCI.fs#list"><a href="LuCI.fs.html#list">list</a></li>
241 <li data-name="LuCI.fs#read"><a href="LuCI.fs.html#read">read</a></li>
243 <li data-name="LuCI.fs#read_direct"><a href="LuCI.fs.html#read_direct">read_direct</a></li>
245 <li data-name="LuCI.fs#remove"><a href="LuCI.fs.html#remove">remove</a></li>
247 <li data-name="LuCI.fs#stat"><a href="LuCI.fs.html#stat">stat</a></li>
249 <li data-name="LuCI.fs#trimmed"><a href="LuCI.fs.html#trimmed">trimmed</a></li>
251 <li data-name="LuCI.fs#write"><a href="LuCI.fs.html#write">write</a></li>
254 <ul class="events itemMembers">
259 <li class="item" data-name="LuCI.headers">
261 <a href="LuCI.headers.html">LuCI.headers</a>
264 <ul class="members itemMembers">
267 <ul class="typedefs itemMembers">
270 <ul class="typedefs itemMembers">
273 <ul class="methods itemMembers">
275 <span class="subtitle">Methods</span>
277 <li data-name="LuCI.headers#get"><a href="LuCI.headers.html#get">get</a></li>
279 <li data-name="LuCI.headers#has"><a href="LuCI.headers.html#has">has</a></li>
282 <ul class="events itemMembers">
287 <li class="item" data-name="LuCI.network">
289 <a href="LuCI.network.html">LuCI.network</a>
292 <ul class="members itemMembers">
295 <ul class="typedefs itemMembers">
297 <span class="subtitle">Typedefs</span>
299 <li data-name="LuCI.network.SwitchTopology"><a href="LuCI.network.html#.SwitchTopology">SwitchTopology</a></li>
301 <li data-name="LuCI.network.WifiEncryption"><a href="LuCI.network.html#.WifiEncryption">WifiEncryption</a></li>
303 <li data-name="LuCI.network.WifiPeerEntry"><a href="LuCI.network.html#.WifiPeerEntry">WifiPeerEntry</a></li>
305 <li data-name="LuCI.network.WifiRateEntry"><a href="LuCI.network.html#.WifiRateEntry">WifiRateEntry</a></li>
307 <li data-name="LuCI.network.WifiScanResult"><a href="LuCI.network.html#.WifiScanResult">WifiScanResult</a></li>
310 <ul class="typedefs itemMembers">
313 <ul class="methods itemMembers">
315 <span class="subtitle">Methods</span>
317 <li data-name="LuCI.network#addNetwork"><a href="LuCI.network.html#addNetwork">addNetwork</a></li>
319 <li data-name="LuCI.network#addWifiNetwork"><a href="LuCI.network.html#addWifiNetwork">addWifiNetwork</a></li>
321 <li data-name="LuCI.network#deleteNetwork"><a href="LuCI.network.html#deleteNetwork">deleteNetwork</a></li>
323 <li data-name="LuCI.network#deleteWifiNetwork"><a href="LuCI.network.html#deleteWifiNetwork">deleteWifiNetwork</a></li>
325 <li data-name="LuCI.network#flushCache"><a href="LuCI.network.html#flushCache">flushCache</a></li>
327 <li data-name="LuCI.network#formatWifiEncryption"><a href="LuCI.network.html#formatWifiEncryption">formatWifiEncryption</a></li>
329 <li data-name="LuCI.network#getDevice"><a href="LuCI.network.html#getDevice">getDevice</a></li>
331 <li data-name="LuCI.network#getDevices"><a href="LuCI.network.html#getDevices">getDevices</a></li>
333 <li data-name="LuCI.network#getDSLModemType"><a href="LuCI.network.html#getDSLModemType">getDSLModemType</a></li>
335 <li data-name="LuCI.network#getHostHints"><a href="LuCI.network.html#getHostHints">getHostHints</a></li>
337 <li data-name="LuCI.network#getIfnameOf"><a href="LuCI.network.html#getIfnameOf">getIfnameOf</a></li>
339 <li data-name="LuCI.network#getNetwork"><a href="LuCI.network.html#getNetwork">getNetwork</a></li>
341 <li data-name="LuCI.network#getNetworks"><a href="LuCI.network.html#getNetworks">getNetworks</a></li>
343 <li data-name="LuCI.network#getProtocol"><a href="LuCI.network.html#getProtocol">getProtocol</a></li>
345 <li data-name="LuCI.network#getProtocols"><a href="LuCI.network.html#getProtocols">getProtocols</a></li>
347 <li data-name="LuCI.network#getSwitchTopologies"><a href="LuCI.network.html#getSwitchTopologies">getSwitchTopologies</a></li>
349 <li data-name="LuCI.network#getWAN6Networks"><a href="LuCI.network.html#getWAN6Networks">getWAN6Networks</a></li>
351 <li data-name="LuCI.network#getWANNetworks"><a href="LuCI.network.html#getWANNetworks">getWANNetworks</a></li>
353 <li data-name="LuCI.network#getWifiDevice"><a href="LuCI.network.html#getWifiDevice">getWifiDevice</a></li>
355 <li data-name="LuCI.network#getWifiDevices"><a href="LuCI.network.html#getWifiDevices">getWifiDevices</a></li>
357 <li data-name="LuCI.network#getWifiNetwork"><a href="LuCI.network.html#getWifiNetwork">getWifiNetwork</a></li>
359 <li data-name="LuCI.network#getWifiNetworks"><a href="LuCI.network.html#getWifiNetworks">getWifiNetworks</a></li>
361 <li data-name="LuCI.network#isIgnoredDevice"><a href="LuCI.network.html#isIgnoredDevice">isIgnoredDevice</a></li>
363 <li data-name="LuCI.network#maskToPrefix"><a href="LuCI.network.html#maskToPrefix">maskToPrefix</a></li>
365 <li data-name="LuCI.network#prefixToMask"><a href="LuCI.network.html#prefixToMask">prefixToMask</a></li>
367 <li data-name="LuCI.network#registerErrorCode"><a href="LuCI.network.html#registerErrorCode">registerErrorCode</a></li>
369 <li data-name="LuCI.network#registerPatternVirtual"><a href="LuCI.network.html#registerPatternVirtual">registerPatternVirtual</a></li>
371 <li data-name="LuCI.network#registerProtocol"><a href="LuCI.network.html#registerProtocol">registerProtocol</a></li>
373 <li data-name="LuCI.network#renameNetwork"><a href="LuCI.network.html#renameNetwork">renameNetwork</a></li>
376 <ul class="events itemMembers">
381 <li class="item" data-name="LuCI.network.Device">
383 <a href="LuCI.network.Device.html">LuCI.network.Device</a>
386 <ul class="members itemMembers">
389 <ul class="typedefs itemMembers">
392 <ul class="typedefs itemMembers">
395 <ul class="methods itemMembers">
397 <span class="subtitle">Methods</span>
399 <li data-name="LuCI.network.Device#getBridgeID"><a href="LuCI.network.Device.html#getBridgeID">getBridgeID</a></li>
401 <li data-name="LuCI.network.Device#getBridgeSTP"><a href="LuCI.network.Device.html#getBridgeSTP">getBridgeSTP</a></li>
403 <li data-name="LuCI.network.Device#getI18n"><a href="LuCI.network.Device.html#getI18n">getI18n</a></li>
405 <li data-name="LuCI.network.Device#getIP6Addrs"><a href="LuCI.network.Device.html#getIP6Addrs">getIP6Addrs</a></li>
407 <li data-name="LuCI.network.Device#getIPAddrs"><a href="LuCI.network.Device.html#getIPAddrs">getIPAddrs</a></li>
409 <li data-name="LuCI.network.Device#getMAC"><a href="LuCI.network.Device.html#getMAC">getMAC</a></li>
411 <li data-name="LuCI.network.Device#getMTU"><a href="LuCI.network.Device.html#getMTU">getMTU</a></li>
413 <li data-name="LuCI.network.Device#getName"><a href="LuCI.network.Device.html#getName">getName</a></li>
415 <li data-name="LuCI.network.Device#getNetwork"><a href="LuCI.network.Device.html#getNetwork">getNetwork</a></li>
417 <li data-name="LuCI.network.Device#getNetworks"><a href="LuCI.network.Device.html#getNetworks">getNetworks</a></li>
419 <li data-name="LuCI.network.Device#getPorts"><a href="LuCI.network.Device.html#getPorts">getPorts</a></li>
421 <li data-name="LuCI.network.Device#getRXBytes"><a href="LuCI.network.Device.html#getRXBytes">getRXBytes</a></li>
423 <li data-name="LuCI.network.Device#getRXPackets"><a href="LuCI.network.Device.html#getRXPackets">getRXPackets</a></li>
425 <li data-name="LuCI.network.Device#getShortName"><a href="LuCI.network.Device.html#getShortName">getShortName</a></li>
427 <li data-name="LuCI.network.Device#getTXBytes"><a href="LuCI.network.Device.html#getTXBytes">getTXBytes</a></li>
429 <li data-name="LuCI.network.Device#getTXPackets"><a href="LuCI.network.Device.html#getTXPackets">getTXPackets</a></li>
431 <li data-name="LuCI.network.Device#getType"><a href="LuCI.network.Device.html#getType">getType</a></li>
433 <li data-name="LuCI.network.Device#getTypeI18n"><a href="LuCI.network.Device.html#getTypeI18n">getTypeI18n</a></li>
435 <li data-name="LuCI.network.Device#getWifiNetwork"><a href="LuCI.network.Device.html#getWifiNetwork">getWifiNetwork</a></li>
437 <li data-name="LuCI.network.Device#isBridge"><a href="LuCI.network.Device.html#isBridge">isBridge</a></li>
439 <li data-name="LuCI.network.Device#isBridgePort"><a href="LuCI.network.Device.html#isBridgePort">isBridgePort</a></li>
441 <li data-name="LuCI.network.Device#isUp"><a href="LuCI.network.Device.html#isUp">isUp</a></li>
444 <ul class="events itemMembers">
449 <li class="item" data-name="LuCI.network.Hosts">
451 <a href="LuCI.network.Hosts.html">LuCI.network.Hosts</a>
454 <ul class="members itemMembers">
457 <ul class="typedefs itemMembers">
460 <ul class="typedefs itemMembers">
463 <ul class="methods itemMembers">
465 <span class="subtitle">Methods</span>
467 <li data-name="LuCI.network.Hosts#getHostnameByIP6Addr"><a href="LuCI.network.Hosts.html#getHostnameByIP6Addr">getHostnameByIP6Addr</a></li>
469 <li data-name="LuCI.network.Hosts#getHostnameByIPAddr"><a href="LuCI.network.Hosts.html#getHostnameByIPAddr">getHostnameByIPAddr</a></li>
471 <li data-name="LuCI.network.Hosts#getHostnameByMACAddr"><a href="LuCI.network.Hosts.html#getHostnameByMACAddr">getHostnameByMACAddr</a></li>
473 <li data-name="LuCI.network.Hosts#getIP6AddrByMACAddr"><a href="LuCI.network.Hosts.html#getIP6AddrByMACAddr">getIP6AddrByMACAddr</a></li>
475 <li data-name="LuCI.network.Hosts#getIPAddrByMACAddr"><a href="LuCI.network.Hosts.html#getIPAddrByMACAddr">getIPAddrByMACAddr</a></li>
477 <li data-name="LuCI.network.Hosts#getMACAddrByIP6Addr"><a href="LuCI.network.Hosts.html#getMACAddrByIP6Addr">getMACAddrByIP6Addr</a></li>
479 <li data-name="LuCI.network.Hosts#getMACAddrByIPAddr"><a href="LuCI.network.Hosts.html#getMACAddrByIPAddr">getMACAddrByIPAddr</a></li>
481 <li data-name="LuCI.network.Hosts#getMACHints"><a href="LuCI.network.Hosts.html#getMACHints">getMACHints</a></li>
484 <ul class="events itemMembers">
489 <li class="item" data-name="LuCI.network.Protocol">
491 <a href="LuCI.network.Protocol.html">LuCI.network.Protocol</a>
494 <ul class="members itemMembers">
497 <ul class="typedefs itemMembers">
500 <ul class="typedefs itemMembers">
503 <ul class="methods itemMembers">
505 <span class="subtitle">Methods</span>
507 <li data-name="LuCI.network.Protocol#addDevice"><a href="LuCI.network.Protocol.html#addDevice">addDevice</a></li>
509 <li data-name="LuCI.network.Protocol#containsDevice"><a href="LuCI.network.Protocol.html#containsDevice">containsDevice</a></li>
511 <li data-name="LuCI.network.Protocol#deleteConfiguration"><a href="LuCI.network.Protocol.html#deleteConfiguration">deleteConfiguration</a></li>
513 <li data-name="LuCI.network.Protocol#deleteDevice"><a href="LuCI.network.Protocol.html#deleteDevice">deleteDevice</a></li>
515 <li data-name="LuCI.network.Protocol#get"><a href="LuCI.network.Protocol.html#get">get</a></li>
517 <li data-name="LuCI.network.Protocol#getDevice"><a href="LuCI.network.Protocol.html#getDevice">getDevice</a></li>
519 <li data-name="LuCI.network.Protocol#getDevices"><a href="LuCI.network.Protocol.html#getDevices">getDevices</a></li>
521 <li data-name="LuCI.network.Protocol#getDNS6Addrs"><a href="LuCI.network.Protocol.html#getDNS6Addrs">getDNS6Addrs</a></li>
523 <li data-name="LuCI.network.Protocol#getDNSAddrs"><a href="LuCI.network.Protocol.html#getDNSAddrs">getDNSAddrs</a></li>
525 <li data-name="LuCI.network.Protocol#getErrors"><a href="LuCI.network.Protocol.html#getErrors">getErrors</a></li>
527 <li data-name="LuCI.network.Protocol#getExpiry"><a href="LuCI.network.Protocol.html#getExpiry">getExpiry</a></li>
529 <li data-name="LuCI.network.Protocol#getGateway6Addr"><a href="LuCI.network.Protocol.html#getGateway6Addr">getGateway6Addr</a></li>
531 <li data-name="LuCI.network.Protocol#getGatewayAddr"><a href="LuCI.network.Protocol.html#getGatewayAddr">getGatewayAddr</a></li>
533 <li data-name="LuCI.network.Protocol#getI18n"><a href="LuCI.network.Protocol.html#getI18n">getI18n</a></li>
535 <li data-name="LuCI.network.Protocol#getIfname"><a href="LuCI.network.Protocol.html#getIfname">getIfname</a></li>
537 <li data-name="LuCI.network.Protocol#getIP6Addr"><a href="LuCI.network.Protocol.html#getIP6Addr">getIP6Addr</a></li>
539 <li data-name="LuCI.network.Protocol#getIP6Addrs"><a href="LuCI.network.Protocol.html#getIP6Addrs">getIP6Addrs</a></li>
541 <li data-name="LuCI.network.Protocol#getIP6Prefix"><a href="LuCI.network.Protocol.html#getIP6Prefix">getIP6Prefix</a></li>
543 <li data-name="LuCI.network.Protocol#getIPAddr"><a href="LuCI.network.Protocol.html#getIPAddr">getIPAddr</a></li>
545 <li data-name="LuCI.network.Protocol#getIPAddrs"><a href="LuCI.network.Protocol.html#getIPAddrs">getIPAddrs</a></li>
547 <li data-name="LuCI.network.Protocol#getL2Device"><a href="LuCI.network.Protocol.html#getL2Device">getL2Device</a></li>
549 <li data-name="LuCI.network.Protocol#getL3Device"><a href="LuCI.network.Protocol.html#getL3Device">getL3Device</a></li>
551 <li data-name="LuCI.network.Protocol#getMetric"><a href="LuCI.network.Protocol.html#getMetric">getMetric</a></li>
553 <li data-name="LuCI.network.Protocol#getName"><a href="LuCI.network.Protocol.html#getName">getName</a></li>
555 <li data-name="LuCI.network.Protocol#getNetmask"><a href="LuCI.network.Protocol.html#getNetmask">getNetmask</a></li>
557 <li data-name="LuCI.network.Protocol#getOpkgPackage"><a href="LuCI.network.Protocol.html#getOpkgPackage">getOpkgPackage</a></li>
559 <li data-name="LuCI.network.Protocol#getProtocol"><a href="LuCI.network.Protocol.html#getProtocol">getProtocol</a></li>
561 <li data-name="LuCI.network.Protocol#getType"><a href="LuCI.network.Protocol.html#getType">getType</a></li>
563 <li data-name="LuCI.network.Protocol#getUptime"><a href="LuCI.network.Protocol.html#getUptime">getUptime</a></li>
565 <li data-name="LuCI.network.Protocol#getZoneName"><a href="LuCI.network.Protocol.html#getZoneName">getZoneName</a></li>
567 <li data-name="LuCI.network.Protocol#isAlias"><a href="LuCI.network.Protocol.html#isAlias">isAlias</a></li>
569 <li data-name="LuCI.network.Protocol#isBridge"><a href="LuCI.network.Protocol.html#isBridge">isBridge</a></li>
571 <li data-name="LuCI.network.Protocol#isDynamic"><a href="LuCI.network.Protocol.html#isDynamic">isDynamic</a></li>
573 <li data-name="LuCI.network.Protocol#isEmpty"><a href="LuCI.network.Protocol.html#isEmpty">isEmpty</a></li>
575 <li data-name="LuCI.network.Protocol#isFloating"><a href="LuCI.network.Protocol.html#isFloating">isFloating</a></li>
577 <li data-name="LuCI.network.Protocol#isInstalled"><a href="LuCI.network.Protocol.html#isInstalled">isInstalled</a></li>
579 <li data-name="LuCI.network.Protocol#isUp"><a href="LuCI.network.Protocol.html#isUp">isUp</a></li>
581 <li data-name="LuCI.network.Protocol#isVirtual"><a href="LuCI.network.Protocol.html#isVirtual">isVirtual</a></li>
583 <li data-name="LuCI.network.Protocol#set"><a href="LuCI.network.Protocol.html#set">set</a></li>
586 <ul class="events itemMembers">
591 <li class="item" data-name="LuCI.network.WifiDevice">
593 <a href="LuCI.network.WifiDevice.html">LuCI.network.WifiDevice</a>
596 <ul class="members itemMembers">
599 <ul class="typedefs itemMembers">
602 <ul class="typedefs itemMembers">
605 <ul class="methods itemMembers">
607 <span class="subtitle">Methods</span>
609 <li data-name="LuCI.network.WifiDevice#addWifiNetwork"><a href="LuCI.network.WifiDevice.html#addWifiNetwork">addWifiNetwork</a></li>
611 <li data-name="LuCI.network.WifiDevice#deleteWifiNetwork"><a href="LuCI.network.WifiDevice.html#deleteWifiNetwork">deleteWifiNetwork</a></li>
613 <li data-name="LuCI.network.WifiDevice#get"><a href="LuCI.network.WifiDevice.html#get">get</a></li>
615 <li data-name="LuCI.network.WifiDevice#getHTModes"><a href="LuCI.network.WifiDevice.html#getHTModes">getHTModes</a></li>
617 <li data-name="LuCI.network.WifiDevice#getHWModes"><a href="LuCI.network.WifiDevice.html#getHWModes">getHWModes</a></li>
619 <li data-name="LuCI.network.WifiDevice#getI18n"><a href="LuCI.network.WifiDevice.html#getI18n">getI18n</a></li>
621 <li data-name="LuCI.network.WifiDevice#getName"><a href="LuCI.network.WifiDevice.html#getName">getName</a></li>
623 <li data-name="LuCI.network.WifiDevice#getScanList"><a href="LuCI.network.WifiDevice.html#getScanList">getScanList</a></li>
625 <li data-name="LuCI.network.WifiDevice#getWifiNetwork"><a href="LuCI.network.WifiDevice.html#getWifiNetwork">getWifiNetwork</a></li>
627 <li data-name="LuCI.network.WifiDevice#getWifiNetworks"><a href="LuCI.network.WifiDevice.html#getWifiNetworks">getWifiNetworks</a></li>
629 <li data-name="LuCI.network.WifiDevice#isDisabled"><a href="LuCI.network.WifiDevice.html#isDisabled">isDisabled</a></li>
631 <li data-name="LuCI.network.WifiDevice#isUp"><a href="LuCI.network.WifiDevice.html#isUp">isUp</a></li>
633 <li data-name="LuCI.network.WifiDevice#set"><a href="LuCI.network.WifiDevice.html#set">set</a></li>
636 <ul class="events itemMembers">
641 <li class="item" data-name="LuCI.network.WifiNetwork">
643 <a href="LuCI.network.WifiNetwork.html">LuCI.network.WifiNetwork</a>
646 <ul class="members itemMembers">
649 <ul class="typedefs itemMembers">
652 <ul class="typedefs itemMembers">
655 <ul class="methods itemMembers">
657 <span class="subtitle">Methods</span>
659 <li data-name="LuCI.network.WifiNetwork#disconnectClient"><a href="LuCI.network.WifiNetwork.html#disconnectClient">disconnectClient</a></li>
661 <li data-name="LuCI.network.WifiNetwork#get"><a href="LuCI.network.WifiNetwork.html#get">get</a></li>
663 <li data-name="LuCI.network.WifiNetwork#getActiveBSSID"><a href="LuCI.network.WifiNetwork.html#getActiveBSSID">getActiveBSSID</a></li>
665 <li data-name="LuCI.network.WifiNetwork#getActiveEncryption"><a href="LuCI.network.WifiNetwork.html#getActiveEncryption">getActiveEncryption</a></li>
667 <li data-name="LuCI.network.WifiNetwork#getActiveMode"><a href="LuCI.network.WifiNetwork.html#getActiveMode">getActiveMode</a></li>
669 <li data-name="LuCI.network.WifiNetwork#getActiveModeI18n"><a href="LuCI.network.WifiNetwork.html#getActiveModeI18n">getActiveModeI18n</a></li>
671 <li data-name="LuCI.network.WifiNetwork#getActiveSSID"><a href="LuCI.network.WifiNetwork.html#getActiveSSID">getActiveSSID</a></li>
673 <li data-name="LuCI.network.WifiNetwork#getAssocList"><a href="LuCI.network.WifiNetwork.html#getAssocList">getAssocList</a></li>
675 <li data-name="LuCI.network.WifiNetwork#getBitRate"><a href="LuCI.network.WifiNetwork.html#getBitRate">getBitRate</a></li>
677 <li data-name="LuCI.network.WifiNetwork#getBSSID"><a href="LuCI.network.WifiNetwork.html#getBSSID">getBSSID</a></li>
679 <li data-name="LuCI.network.WifiNetwork#getChannel"><a href="LuCI.network.WifiNetwork.html#getChannel">getChannel</a></li>
681 <li data-name="LuCI.network.WifiNetwork#getCountryCode"><a href="LuCI.network.WifiNetwork.html#getCountryCode">getCountryCode</a></li>
683 <li data-name="LuCI.network.WifiNetwork#getDevice"><a href="LuCI.network.WifiNetwork.html#getDevice">getDevice</a></li>
685 <li data-name="LuCI.network.WifiNetwork#getFrequency"><a href="LuCI.network.WifiNetwork.html#getFrequency">getFrequency</a></li>
687 <li data-name="LuCI.network.WifiNetwork#getI18n"><a href="LuCI.network.WifiNetwork.html#getI18n">getI18n</a></li>
689 <li data-name="LuCI.network.WifiNetwork#getID"><a href="LuCI.network.WifiNetwork.html#getID">getID</a></li>
691 <li data-name="LuCI.network.WifiNetwork#getIfname"><a href="LuCI.network.WifiNetwork.html#getIfname">getIfname</a></li>
693 <li data-name="LuCI.network.WifiNetwork#getMeshID"><a href="LuCI.network.WifiNetwork.html#getMeshID">getMeshID</a></li>
695 <li data-name="LuCI.network.WifiNetwork#getMode"><a href="LuCI.network.WifiNetwork.html#getMode">getMode</a></li>
697 <li data-name="LuCI.network.WifiNetwork#getName"><a href="LuCI.network.WifiNetwork.html#getName">getName</a></li>
699 <li data-name="LuCI.network.WifiNetwork#getNetwork"><a href="LuCI.network.WifiNetwork.html#getNetwork">getNetwork</a></li>
701 <li data-name="LuCI.network.WifiNetwork#getNetworkNames"><a href="LuCI.network.WifiNetwork.html#getNetworkNames">getNetworkNames</a></li>
703 <li data-name="LuCI.network.WifiNetwork#getNetworks"><a href="LuCI.network.WifiNetwork.html#getNetworks">getNetworks</a></li>
705 <li data-name="LuCI.network.WifiNetwork#getNoise"><a href="LuCI.network.WifiNetwork.html#getNoise">getNoise</a></li>
707 <li data-name="LuCI.network.WifiNetwork#getShortName"><a href="LuCI.network.WifiNetwork.html#getShortName">getShortName</a></li>
709 <li data-name="LuCI.network.WifiNetwork#getSignal"><a href="LuCI.network.WifiNetwork.html#getSignal">getSignal</a></li>
711 <li data-name="LuCI.network.WifiNetwork#getSignalLevel"><a href="LuCI.network.WifiNetwork.html#getSignalLevel">getSignalLevel</a></li>
713 <li data-name="LuCI.network.WifiNetwork#getSignalPercent"><a href="LuCI.network.WifiNetwork.html#getSignalPercent">getSignalPercent</a></li>
715 <li data-name="LuCI.network.WifiNetwork#getSSID"><a href="LuCI.network.WifiNetwork.html#getSSID">getSSID</a></li>
717 <li data-name="LuCI.network.WifiNetwork#getTXPower"><a href="LuCI.network.WifiNetwork.html#getTXPower">getTXPower</a></li>
719 <li data-name="LuCI.network.WifiNetwork#getTXPowerOffset"><a href="LuCI.network.WifiNetwork.html#getTXPowerOffset">getTXPowerOffset</a></li>
721 <li data-name="LuCI.network.WifiNetwork#getWifiDevice"><a href="LuCI.network.WifiNetwork.html#getWifiDevice">getWifiDevice</a></li>
723 <li data-name="LuCI.network.WifiNetwork#getWifiDeviceName"><a href="LuCI.network.WifiNetwork.html#getWifiDeviceName">getWifiDeviceName</a></li>
725 <li data-name="LuCI.network.WifiNetwork#isClientDisconnectSupported"><a href="LuCI.network.WifiNetwork.html#isClientDisconnectSupported">isClientDisconnectSupported</a></li>
727 <li data-name="LuCI.network.WifiNetwork#isDisabled"><a href="LuCI.network.WifiNetwork.html#isDisabled">isDisabled</a></li>
729 <li data-name="LuCI.network.WifiNetwork#isUp"><a href="LuCI.network.WifiNetwork.html#isUp">isUp</a></li>
731 <li data-name="LuCI.network.WifiNetwork#set"><a href="LuCI.network.WifiNetwork.html#set">set</a></li>
734 <ul class="events itemMembers">
739 <li class="item" data-name="LuCI.poll">
741 <a href="LuCI.poll.html">LuCI.poll</a>
744 <ul class="members itemMembers">
747 <ul class="typedefs itemMembers">
750 <ul class="typedefs itemMembers">
753 <ul class="methods itemMembers">
755 <span class="subtitle">Methods</span>
757 <li data-name="LuCI.poll#active"><a href="LuCI.poll.html#active">active</a></li>
759 <li data-name="LuCI.poll#add"><a href="LuCI.poll.html#add">add</a></li>
761 <li data-name="LuCI.poll#remove"><a href="LuCI.poll.html#remove">remove</a></li>
763 <li data-name="LuCI.poll#start"><a href="LuCI.poll.html#start">start</a></li>
765 <li data-name="LuCI.poll#stop"><a href="LuCI.poll.html#stop">stop</a></li>
768 <ul class="events itemMembers">
773 <li class="item" data-name="LuCI.request">
775 <a href="LuCI.request.html">LuCI.request</a>
778 <ul class="members itemMembers">
781 <ul class="typedefs itemMembers">
783 <span class="subtitle">Typedefs</span>
785 <li data-name="LuCI.request.interceptorFn"><a href="LuCI.request.html#.interceptorFn">interceptorFn</a></li>
787 <li data-name="LuCI.request.RequestOptions"><a href="LuCI.request.html#.RequestOptions">RequestOptions</a></li>
790 <ul class="typedefs itemMembers">
793 <ul class="methods itemMembers">
795 <span class="subtitle">Methods</span>
797 <li data-name="LuCI.request#addInterceptor"><a href="LuCI.request.html#addInterceptor">addInterceptor</a></li>
799 <li data-name="LuCI.request#expandURL"><a href="LuCI.request.html#expandURL">expandURL</a></li>
801 <li data-name="LuCI.request#get"><a href="LuCI.request.html#get">get</a></li>
803 <li data-name="LuCI.request#post"><a href="LuCI.request.html#post">post</a></li>
805 <li data-name="LuCI.request#removeInterceptor"><a href="LuCI.request.html#removeInterceptor">removeInterceptor</a></li>
807 <li data-name="LuCI.request#request"><a href="LuCI.request.html#request">request</a></li>
810 <ul class="events itemMembers">
815 <li class="item" data-name="LuCI.request.poll">
817 <a href="LuCI.request.poll.html">LuCI.request.poll</a>
820 <ul class="members itemMembers">
823 <ul class="typedefs itemMembers">
825 <span class="subtitle">Typedefs</span>
827 <li data-name="LuCI.request.poll~callbackFn"><a href="LuCI.request.poll.html#~callbackFn">callbackFn</a></li>
830 <ul class="typedefs itemMembers">
833 <ul class="methods itemMembers">
835 <span class="subtitle">Methods</span>
837 <li data-name="LuCI.request.poll#active"><a href="LuCI.request.poll.html#active">active</a></li>
839 <li data-name="LuCI.request.poll#add"><a href="LuCI.request.poll.html#add">add</a></li>
841 <li data-name="LuCI.request.poll#remove"><a href="LuCI.request.poll.html#remove">remove</a></li>
843 <li data-name="LuCI.request.poll#start"><a href="LuCI.request.poll.html#start">start</a></li>
845 <li data-name="LuCI.request.poll#stop"><a href="LuCI.request.poll.html#stop">stop</a></li>
848 <ul class="events itemMembers">
853 <li class="item" data-name="LuCI.response">
855 <a href="LuCI.response.html">LuCI.response</a>
858 <ul class="members itemMembers">
860 <span class="subtitle">Members</span>
862 <li data-name="LuCI.response#duration"><a href="LuCI.response.html#duration">duration</a></li>
864 <li data-name="LuCI.response#headers"><a href="LuCI.response.html#headers">headers</a></li>
866 <li data-name="LuCI.response#ok"><a href="LuCI.response.html#ok">ok</a></li>
868 <li data-name="LuCI.response#status"><a href="LuCI.response.html#status">status</a></li>
870 <li data-name="LuCI.response#statusText"><a href="LuCI.response.html#statusText">statusText</a></li>
872 <li data-name="LuCI.response#url"><a href="LuCI.response.html#url">url</a></li>
875 <ul class="typedefs itemMembers">
878 <ul class="typedefs itemMembers">
881 <ul class="methods itemMembers">
883 <span class="subtitle">Methods</span>
885 <li data-name="LuCI.response#blob"><a href="LuCI.response.html#blob">blob</a></li>
887 <li data-name="LuCI.response#clone"><a href="LuCI.response.html#clone">clone</a></li>
889 <li data-name="LuCI.response#json"><a href="LuCI.response.html#json">json</a></li>
891 <li data-name="LuCI.response#text"><a href="LuCI.response.html#text">text</a></li>
894 <ul class="events itemMembers">
899 <li class="item" data-name="LuCI.rpc">
901 <a href="LuCI.rpc.html">LuCI.rpc</a>
904 <ul class="members itemMembers">
907 <ul class="typedefs itemMembers">
909 <span class="subtitle">Typedefs</span>
911 <li data-name="LuCI.rpc.DeclareOptions"><a href="LuCI.rpc.html#.DeclareOptions">DeclareOptions</a></li>
913 <li data-name="LuCI.rpc~filterFn"><a href="LuCI.rpc.html#~filterFn">filterFn</a></li>
915 <li data-name="LuCI.rpc~interceptorFn"><a href="LuCI.rpc.html#~interceptorFn">interceptorFn</a></li>
917 <li data-name="LuCI.rpc~invokeFn"><a href="LuCI.rpc.html#~invokeFn">invokeFn</a></li>
920 <ul class="typedefs itemMembers">
923 <ul class="methods itemMembers">
925 <span class="subtitle">Methods</span>
927 <li data-name="LuCI.rpc#addInterceptor"><a href="LuCI.rpc.html#addInterceptor">addInterceptor</a></li>
929 <li data-name="LuCI.rpc#declare"><a href="LuCI.rpc.html#declare">declare</a></li>
931 <li data-name="LuCI.rpc#getBaseURL"><a href="LuCI.rpc.html#getBaseURL">getBaseURL</a></li>
933 <li data-name="LuCI.rpc#getSessionID"><a href="LuCI.rpc.html#getSessionID">getSessionID</a></li>
935 <li data-name="LuCI.rpc#getStatusText"><a href="LuCI.rpc.html#getStatusText">getStatusText</a></li>
937 <li data-name="LuCI.rpc#list"><a href="LuCI.rpc.html#list">list</a></li>
939 <li data-name="LuCI.rpc#removeInterceptor"><a href="LuCI.rpc.html#removeInterceptor">removeInterceptor</a></li>
941 <li data-name="LuCI.rpc#setBaseURL"><a href="LuCI.rpc.html#setBaseURL">setBaseURL</a></li>
943 <li data-name="LuCI.rpc#setSessionID"><a href="LuCI.rpc.html#setSessionID">setSessionID</a></li>
946 <ul class="events itemMembers">
951 <li class="item" data-name="LuCI.uci">
953 <a href="LuCI.uci.html">LuCI.uci</a>
956 <ul class="members itemMembers">
959 <ul class="typedefs itemMembers">
961 <span class="subtitle">Typedefs</span>
963 <li data-name="LuCI.uci.ChangeRecord"><a href="LuCI.uci.html#.ChangeRecord">ChangeRecord</a></li>
965 <li data-name="LuCI.uci.SectionObject"><a href="LuCI.uci.html#.SectionObject">SectionObject</a></li>
967 <li data-name="LuCI.uci~sectionsFn"><a href="LuCI.uci.html#~sectionsFn">sectionsFn</a></li>
970 <ul class="typedefs itemMembers">
973 <ul class="methods itemMembers">
975 <span class="subtitle">Methods</span>
977 <li data-name="LuCI.uci#add"><a href="LuCI.uci.html#add">add</a></li>
979 <li data-name="LuCI.uci#apply"><a href="LuCI.uci.html#apply">apply</a></li>
981 <li data-name="LuCI.uci#changes"><a href="LuCI.uci.html#changes">changes</a></li>
983 <li data-name="LuCI.uci#createSID"><a href="LuCI.uci.html#createSID">createSID</a></li>
985 <li data-name="LuCI.uci#get"><a href="LuCI.uci.html#get">get</a></li>
987 <li data-name="LuCI.uci#get_first"><a href="LuCI.uci.html#get_first">get_first</a></li>
989 <li data-name="LuCI.uci#load"><a href="LuCI.uci.html#load">load</a></li>
991 <li data-name="LuCI.uci#move"><a href="LuCI.uci.html#move">move</a></li>
993 <li data-name="LuCI.uci#remove"><a href="LuCI.uci.html#remove">remove</a></li>
995 <li data-name="LuCI.uci#resolveSID"><a href="LuCI.uci.html#resolveSID">resolveSID</a></li>
997 <li data-name="LuCI.uci#save"><a href="LuCI.uci.html#save">save</a></li>
999 <li data-name="LuCI.uci#sections"><a href="LuCI.uci.html#sections">sections</a></li>
1001 <li data-name="LuCI.uci#set"><a href="LuCI.uci.html#set">set</a></li>
1003 <li data-name="LuCI.uci#set_first"><a href="LuCI.uci.html#set_first">set_first</a></li>
1005 <li data-name="LuCI.uci#unload"><a href="LuCI.uci.html#unload">unload</a></li>
1007 <li data-name="LuCI.uci#unset"><a href="LuCI.uci.html#unset">unset</a></li>
1009 <li data-name="LuCI.uci#unset_first"><a href="LuCI.uci.html#unset_first">unset_first</a></li>
1012 <ul class="events itemMembers">
1017 <li class="item" data-name="LuCI.ui">
1018 <span class="title">
1019 <a href="LuCI.ui.html">LuCI.ui</a>
1022 <ul class="members itemMembers">
1025 <ul class="typedefs itemMembers">
1027 <span class="subtitle">Typedefs</span>
1029 <li data-name="LuCI.ui.FileUploadReply"><a href="LuCI.ui.html#.FileUploadReply">FileUploadReply</a></li>
1032 <ul class="typedefs itemMembers">
1035 <ul class="methods itemMembers">
1037 <span class="subtitle">Methods</span>
1039 <li data-name="LuCI.ui#addNotification"><a href="LuCI.ui.html#addNotification">addNotification</a></li>
1041 <li data-name="LuCI.ui#addValidator"><a href="LuCI.ui.html#addValidator">addValidator</a></li>
1043 <li data-name="LuCI.ui#awaitReconnect"><a href="LuCI.ui.html#awaitReconnect">awaitReconnect</a></li>
1045 <li data-name="LuCI.ui#createHandlerFn"><a href="LuCI.ui.html#createHandlerFn">createHandlerFn</a></li>
1047 <li data-name="LuCI.ui#hideIndicator"><a href="LuCI.ui.html#hideIndicator">hideIndicator</a></li>
1049 <li data-name="LuCI.ui#hideModal"><a href="LuCI.ui.html#hideModal">hideModal</a></li>
1051 <li data-name="LuCI.ui#instantiateView"><a href="LuCI.ui.html#instantiateView">instantiateView</a></li>
1053 <li data-name="LuCI.ui#itemlist"><a href="LuCI.ui.html#itemlist">itemlist</a></li>
1055 <li data-name="LuCI.ui#pingDevice"><a href="LuCI.ui.html#pingDevice">pingDevice</a></li>
1057 <li data-name="LuCI.ui#showIndicator"><a href="LuCI.ui.html#showIndicator">showIndicator</a></li>
1059 <li data-name="LuCI.ui#showModal"><a href="LuCI.ui.html#showModal">showModal</a></li>
1061 <li data-name="LuCI.ui#uploadFile"><a href="LuCI.ui.html#uploadFile">uploadFile</a></li>
1064 <ul class="events itemMembers">
1069 <li class="item" data-name="LuCI.ui.AbstractElement">
1070 <span class="title">
1071 <a href="LuCI.ui.AbstractElement.html">LuCI.ui.AbstractElement</a>
1074 <ul class="members itemMembers">
1077 <ul class="typedefs itemMembers">
1079 <span class="subtitle">Typedefs</span>
1081 <li data-name="LuCI.ui.AbstractElement.InitOptions"><a href="LuCI.ui.AbstractElement.html#.InitOptions">InitOptions</a></li>
1084 <ul class="typedefs itemMembers">
1087 <ul class="methods itemMembers">
1089 <span class="subtitle">Methods</span>
1091 <li data-name="LuCI.ui.AbstractElement#getValue"><a href="LuCI.ui.AbstractElement.html#getValue">getValue</a></li>
1093 <li data-name="LuCI.ui.AbstractElement#isValid"><a href="LuCI.ui.AbstractElement.html#isValid">isValid</a></li>
1095 <li data-name="LuCI.ui.AbstractElement#registerEvents"><a href="LuCI.ui.AbstractElement.html#registerEvents">registerEvents</a></li>
1097 <li data-name="LuCI.ui.AbstractElement#render"><a href="LuCI.ui.AbstractElement.html#render">render</a></li>
1099 <li data-name="LuCI.ui.AbstractElement#setChangeEvents"><a href="LuCI.ui.AbstractElement.html#setChangeEvents">setChangeEvents</a></li>
1101 <li data-name="LuCI.ui.AbstractElement#setUpdateEvents"><a href="LuCI.ui.AbstractElement.html#setUpdateEvents">setUpdateEvents</a></li>
1103 <li data-name="LuCI.ui.AbstractElement#setValue"><a href="LuCI.ui.AbstractElement.html#setValue">setValue</a></li>
1105 <li data-name="LuCI.ui.AbstractElement#triggerValidation"><a href="LuCI.ui.AbstractElement.html#triggerValidation">triggerValidation</a></li>
1108 <ul class="events itemMembers">
1113 <li class="item" data-name="LuCI.ui.changes">
1114 <span class="title">
1115 <a href="LuCI.ui.changes.html">LuCI.ui.changes</a>
1118 <ul class="members itemMembers">
1121 <ul class="typedefs itemMembers">
1124 <ul class="typedefs itemMembers">
1127 <ul class="methods itemMembers">
1129 <span class="subtitle">Methods</span>
1131 <li data-name="LuCI.ui.changes#apply"><a href="LuCI.ui.changes.html#apply">apply</a></li>
1133 <li data-name="LuCI.ui.changes#displayChanges"><a href="LuCI.ui.changes.html#displayChanges">displayChanges</a></li>
1135 <li data-name="LuCI.ui.changes#renderChangeIndicator"><a href="LuCI.ui.changes.html#renderChangeIndicator">renderChangeIndicator</a></li>
1137 <li data-name="LuCI.ui.changes#revert"><a href="LuCI.ui.changes.html#revert">revert</a></li>
1139 <li data-name="LuCI.ui.changes#setIndicator"><a href="LuCI.ui.changes.html#setIndicator">setIndicator</a></li>
1142 <ul class="events itemMembers">
1147 <li class="item" data-name="LuCI.ui.Checkbox">
1148 <span class="title">
1149 <a href="LuCI.ui.Checkbox.html">LuCI.ui.Checkbox</a>
1152 <ul class="members itemMembers">
1155 <ul class="typedefs itemMembers">
1157 <span class="subtitle">Typedefs</span>
1159 <li data-name="LuCI.ui.Checkbox.InitOptions"><a href="LuCI.ui.Checkbox.html#.InitOptions">InitOptions</a></li>
1162 <ul class="typedefs itemMembers">
1165 <ul class="methods itemMembers">
1167 <span class="subtitle">Methods</span>
1169 <li data-name="LuCI.ui.Checkbox#getValue"><a href="LuCI.ui.Checkbox.html#getValue">getValue</a></li>
1171 <li data-name="LuCI.ui.Checkbox#isChecked"><a href="LuCI.ui.Checkbox.html#isChecked">isChecked</a></li>
1173 <li data-name="LuCI.ui.Checkbox#isValid"><a href="LuCI.ui.Checkbox.html#isValid">isValid</a></li>
1175 <li data-name="LuCI.ui.Checkbox#registerEvents"><a href="LuCI.ui.Checkbox.html#registerEvents">registerEvents</a></li>
1177 <li data-name="LuCI.ui.Checkbox#render"><a href="LuCI.ui.Checkbox.html#render">render</a></li>
1179 <li data-name="LuCI.ui.Checkbox#setChangeEvents"><a href="LuCI.ui.Checkbox.html#setChangeEvents">setChangeEvents</a></li>
1181 <li data-name="LuCI.ui.Checkbox#setUpdateEvents"><a href="LuCI.ui.Checkbox.html#setUpdateEvents">setUpdateEvents</a></li>
1183 <li data-name="LuCI.ui.Checkbox#setValue"><a href="LuCI.ui.Checkbox.html#setValue">setValue</a></li>
1185 <li data-name="LuCI.ui.Checkbox#triggerValidation"><a href="LuCI.ui.Checkbox.html#triggerValidation">triggerValidation</a></li>
1188 <ul class="events itemMembers">
1193 <li class="item" data-name="LuCI.ui.Combobox">
1194 <span class="title">
1195 <a href="LuCI.ui.Combobox.html">LuCI.ui.Combobox</a>
1198 <ul class="members itemMembers">
1201 <ul class="typedefs itemMembers">
1203 <span class="subtitle">Typedefs</span>
1205 <li data-name="LuCI.ui.Combobox.InitOptions"><a href="LuCI.ui.Combobox.html#.InitOptions">InitOptions</a></li>
1208 <ul class="typedefs itemMembers">
1211 <ul class="methods itemMembers">
1213 <span class="subtitle">Methods</span>
1215 <li data-name="LuCI.ui.Combobox#addChoices"><a href="LuCI.ui.Combobox.html#addChoices">addChoices</a></li>
1217 <li data-name="LuCI.ui.Combobox#clearChoices"><a href="LuCI.ui.Combobox.html#clearChoices">clearChoices</a></li>
1219 <li data-name="LuCI.ui.Combobox#closeAllDropdowns"><a href="LuCI.ui.Combobox.html#closeAllDropdowns">closeAllDropdowns</a></li>
1221 <li data-name="LuCI.ui.Combobox#isValid"><a href="LuCI.ui.Combobox.html#isValid">isValid</a></li>
1223 <li data-name="LuCI.ui.Combobox#registerEvents"><a href="LuCI.ui.Combobox.html#registerEvents">registerEvents</a></li>
1225 <li data-name="LuCI.ui.Combobox#setChangeEvents"><a href="LuCI.ui.Combobox.html#setChangeEvents">setChangeEvents</a></li>
1227 <li data-name="LuCI.ui.Combobox#setUpdateEvents"><a href="LuCI.ui.Combobox.html#setUpdateEvents">setUpdateEvents</a></li>
1229 <li data-name="LuCI.ui.Combobox#triggerValidation"><a href="LuCI.ui.Combobox.html#triggerValidation">triggerValidation</a></li>
1232 <ul class="events itemMembers">
1237 <li class="item" data-name="LuCI.ui.ComboButton">
1238 <span class="title">
1239 <a href="LuCI.ui.ComboButton.html">LuCI.ui.ComboButton</a>
1242 <ul class="members itemMembers">
1245 <ul class="typedefs itemMembers">
1247 <span class="subtitle">Typedefs</span>
1249 <li data-name="LuCI.ui.ComboButton.InitOptions"><a href="LuCI.ui.ComboButton.html#.InitOptions">InitOptions</a></li>
1252 <ul class="typedefs itemMembers">
1255 <ul class="methods itemMembers">
1257 <span class="subtitle">Methods</span>
1259 <li data-name="LuCI.ui.ComboButton#addChoices"><a href="LuCI.ui.ComboButton.html#addChoices">addChoices</a></li>
1261 <li data-name="LuCI.ui.ComboButton#clearChoices"><a href="LuCI.ui.ComboButton.html#clearChoices">clearChoices</a></li>
1263 <li data-name="LuCI.ui.ComboButton#closeAllDropdowns"><a href="LuCI.ui.ComboButton.html#closeAllDropdowns">closeAllDropdowns</a></li>
1265 <li data-name="LuCI.ui.ComboButton#isValid"><a href="LuCI.ui.ComboButton.html#isValid">isValid</a></li>
1267 <li data-name="LuCI.ui.ComboButton#registerEvents"><a href="LuCI.ui.ComboButton.html#registerEvents">registerEvents</a></li>
1269 <li data-name="LuCI.ui.ComboButton#setChangeEvents"><a href="LuCI.ui.ComboButton.html#setChangeEvents">setChangeEvents</a></li>
1271 <li data-name="LuCI.ui.ComboButton#setUpdateEvents"><a href="LuCI.ui.ComboButton.html#setUpdateEvents">setUpdateEvents</a></li>
1273 <li data-name="LuCI.ui.ComboButton#triggerValidation"><a href="LuCI.ui.ComboButton.html#triggerValidation">triggerValidation</a></li>
1276 <ul class="events itemMembers">
1281 <li class="item" data-name="LuCI.ui.Dropdown">
1282 <span class="title">
1283 <a href="LuCI.ui.Dropdown.html">LuCI.ui.Dropdown</a>
1286 <ul class="members itemMembers">
1289 <ul class="typedefs itemMembers">
1291 <span class="subtitle">Typedefs</span>
1293 <li data-name="LuCI.ui.Dropdown.InitOptions"><a href="LuCI.ui.Dropdown.html#.InitOptions">InitOptions</a></li>
1296 <ul class="typedefs itemMembers">
1299 <ul class="methods itemMembers">
1301 <span class="subtitle">Methods</span>
1303 <li data-name="LuCI.ui.Dropdown#addChoices"><a href="LuCI.ui.Dropdown.html#addChoices">addChoices</a></li>
1305 <li data-name="LuCI.ui.Dropdown#clearChoices"><a href="LuCI.ui.Dropdown.html#clearChoices">clearChoices</a></li>
1307 <li data-name="LuCI.ui.Dropdown#closeAllDropdowns"><a href="LuCI.ui.Dropdown.html#closeAllDropdowns">closeAllDropdowns</a></li>
1309 <li data-name="LuCI.ui.Dropdown#getValue"><a href="LuCI.ui.Dropdown.html#getValue">getValue</a></li>
1311 <li data-name="LuCI.ui.Dropdown#isValid"><a href="LuCI.ui.Dropdown.html#isValid">isValid</a></li>
1313 <li data-name="LuCI.ui.Dropdown#registerEvents"><a href="LuCI.ui.Dropdown.html#registerEvents">registerEvents</a></li>
1315 <li data-name="LuCI.ui.Dropdown#render"><a href="LuCI.ui.Dropdown.html#render">render</a></li>
1317 <li data-name="LuCI.ui.Dropdown#setChangeEvents"><a href="LuCI.ui.Dropdown.html#setChangeEvents">setChangeEvents</a></li>
1319 <li data-name="LuCI.ui.Dropdown#setUpdateEvents"><a href="LuCI.ui.Dropdown.html#setUpdateEvents">setUpdateEvents</a></li>
1321 <li data-name="LuCI.ui.Dropdown#setValue"><a href="LuCI.ui.Dropdown.html#setValue">setValue</a></li>
1323 <li data-name="LuCI.ui.Dropdown#triggerValidation"><a href="LuCI.ui.Dropdown.html#triggerValidation">triggerValidation</a></li>
1326 <ul class="events itemMembers">
1331 <li class="item" data-name="LuCI.ui.DynamicList">
1332 <span class="title">
1333 <a href="LuCI.ui.DynamicList.html">LuCI.ui.DynamicList</a>
1336 <ul class="members itemMembers">
1339 <ul class="typedefs itemMembers">
1341 <span class="subtitle">Typedefs</span>
1343 <li data-name="LuCI.ui.DynamicList.InitOptions"><a href="LuCI.ui.DynamicList.html#.InitOptions">InitOptions</a></li>
1346 <ul class="typedefs itemMembers">
1349 <ul class="methods itemMembers">
1351 <span class="subtitle">Methods</span>
1353 <li data-name="LuCI.ui.DynamicList#addChoices"><a href="LuCI.ui.DynamicList.html#addChoices">addChoices</a></li>
1355 <li data-name="LuCI.ui.DynamicList#clearChoices"><a href="LuCI.ui.DynamicList.html#clearChoices">clearChoices</a></li>
1357 <li data-name="LuCI.ui.DynamicList#getValue"><a href="LuCI.ui.DynamicList.html#getValue">getValue</a></li>
1359 <li data-name="LuCI.ui.DynamicList#isValid"><a href="LuCI.ui.DynamicList.html#isValid">isValid</a></li>
1361 <li data-name="LuCI.ui.DynamicList#registerEvents"><a href="LuCI.ui.DynamicList.html#registerEvents">registerEvents</a></li>
1363 <li data-name="LuCI.ui.DynamicList#render"><a href="LuCI.ui.DynamicList.html#render">render</a></li>
1365 <li data-name="LuCI.ui.DynamicList#setChangeEvents"><a href="LuCI.ui.DynamicList.html#setChangeEvents">setChangeEvents</a></li>
1367 <li data-name="LuCI.ui.DynamicList#setUpdateEvents"><a href="LuCI.ui.DynamicList.html#setUpdateEvents">setUpdateEvents</a></li>
1369 <li data-name="LuCI.ui.DynamicList#setValue"><a href="LuCI.ui.DynamicList.html#setValue">setValue</a></li>
1371 <li data-name="LuCI.ui.DynamicList#triggerValidation"><a href="LuCI.ui.DynamicList.html#triggerValidation">triggerValidation</a></li>
1374 <ul class="events itemMembers">
1379 <li class="item" data-name="LuCI.ui.FileUpload">
1380 <span class="title">
1381 <a href="LuCI.ui.FileUpload.html">LuCI.ui.FileUpload</a>
1384 <ul class="members itemMembers">
1387 <ul class="typedefs itemMembers">
1389 <span class="subtitle">Typedefs</span>
1391 <li data-name="LuCI.ui.FileUpload.InitOptions"><a href="LuCI.ui.FileUpload.html#.InitOptions">InitOptions</a></li>
1394 <ul class="typedefs itemMembers">
1397 <ul class="methods itemMembers">
1399 <span class="subtitle">Methods</span>
1401 <li data-name="LuCI.ui.FileUpload#getValue"><a href="LuCI.ui.FileUpload.html#getValue">getValue</a></li>
1403 <li data-name="LuCI.ui.FileUpload#isValid"><a href="LuCI.ui.FileUpload.html#isValid">isValid</a></li>
1405 <li data-name="LuCI.ui.FileUpload#registerEvents"><a href="LuCI.ui.FileUpload.html#registerEvents">registerEvents</a></li>
1407 <li data-name="LuCI.ui.FileUpload#render"><a href="LuCI.ui.FileUpload.html#render">render</a></li>
1409 <li data-name="LuCI.ui.FileUpload#setChangeEvents"><a href="LuCI.ui.FileUpload.html#setChangeEvents">setChangeEvents</a></li>
1411 <li data-name="LuCI.ui.FileUpload#setUpdateEvents"><a href="LuCI.ui.FileUpload.html#setUpdateEvents">setUpdateEvents</a></li>
1413 <li data-name="LuCI.ui.FileUpload#setValue"><a href="LuCI.ui.FileUpload.html#setValue">setValue</a></li>
1415 <li data-name="LuCI.ui.FileUpload#triggerValidation"><a href="LuCI.ui.FileUpload.html#triggerValidation">triggerValidation</a></li>
1418 <ul class="events itemMembers">
1423 <li class="item" data-name="LuCI.ui.Hiddenfield">
1424 <span class="title">
1425 <a href="LuCI.ui.Hiddenfield.html">LuCI.ui.Hiddenfield</a>
1428 <ul class="members itemMembers">
1431 <ul class="typedefs itemMembers">
1434 <ul class="typedefs itemMembers">
1437 <ul class="methods itemMembers">
1439 <span class="subtitle">Methods</span>
1441 <li data-name="LuCI.ui.Hiddenfield#getValue"><a href="LuCI.ui.Hiddenfield.html#getValue">getValue</a></li>
1443 <li data-name="LuCI.ui.Hiddenfield#isValid"><a href="LuCI.ui.Hiddenfield.html#isValid">isValid</a></li>
1445 <li data-name="LuCI.ui.Hiddenfield#registerEvents"><a href="LuCI.ui.Hiddenfield.html#registerEvents">registerEvents</a></li>
1447 <li data-name="LuCI.ui.Hiddenfield#render"><a href="LuCI.ui.Hiddenfield.html#render">render</a></li>
1449 <li data-name="LuCI.ui.Hiddenfield#setChangeEvents"><a href="LuCI.ui.Hiddenfield.html#setChangeEvents">setChangeEvents</a></li>
1451 <li data-name="LuCI.ui.Hiddenfield#setUpdateEvents"><a href="LuCI.ui.Hiddenfield.html#setUpdateEvents">setUpdateEvents</a></li>
1453 <li data-name="LuCI.ui.Hiddenfield#setValue"><a href="LuCI.ui.Hiddenfield.html#setValue">setValue</a></li>
1455 <li data-name="LuCI.ui.Hiddenfield#triggerValidation"><a href="LuCI.ui.Hiddenfield.html#triggerValidation">triggerValidation</a></li>
1458 <ul class="events itemMembers">
1463 <li class="item" data-name="LuCI.ui.Select">
1464 <span class="title">
1465 <a href="LuCI.ui.Select.html">LuCI.ui.Select</a>
1468 <ul class="members itemMembers">
1471 <ul class="typedefs itemMembers">
1473 <span class="subtitle">Typedefs</span>
1475 <li data-name="LuCI.ui.Select.InitOptions"><a href="LuCI.ui.Select.html#.InitOptions">InitOptions</a></li>
1478 <ul class="typedefs itemMembers">
1481 <ul class="methods itemMembers">
1483 <span class="subtitle">Methods</span>
1485 <li data-name="LuCI.ui.Select#getValue"><a href="LuCI.ui.Select.html#getValue">getValue</a></li>
1487 <li data-name="LuCI.ui.Select#isValid"><a href="LuCI.ui.Select.html#isValid">isValid</a></li>
1489 <li data-name="LuCI.ui.Select#registerEvents"><a href="LuCI.ui.Select.html#registerEvents">registerEvents</a></li>
1491 <li data-name="LuCI.ui.Select#render"><a href="LuCI.ui.Select.html#render">render</a></li>
1493 <li data-name="LuCI.ui.Select#setChangeEvents"><a href="LuCI.ui.Select.html#setChangeEvents">setChangeEvents</a></li>
1495 <li data-name="LuCI.ui.Select#setUpdateEvents"><a href="LuCI.ui.Select.html#setUpdateEvents">setUpdateEvents</a></li>
1497 <li data-name="LuCI.ui.Select#setValue"><a href="LuCI.ui.Select.html#setValue">setValue</a></li>
1499 <li data-name="LuCI.ui.Select#triggerValidation"><a href="LuCI.ui.Select.html#triggerValidation">triggerValidation</a></li>
1502 <ul class="events itemMembers">
1507 <li class="item" data-name="LuCI.ui.tabs">
1508 <span class="title">
1509 <a href="LuCI.ui.tabs.html">LuCI.ui.tabs</a>
1512 <ul class="members itemMembers">
1515 <ul class="typedefs itemMembers">
1518 <ul class="typedefs itemMembers">
1521 <ul class="methods itemMembers">
1523 <span class="subtitle">Methods</span>
1525 <li data-name="LuCI.ui.tabs#initTabGroup"><a href="LuCI.ui.tabs.html#initTabGroup">initTabGroup</a></li>
1527 <li data-name="LuCI.ui.tabs#isEmptyPane"><a href="LuCI.ui.tabs.html#isEmptyPane">isEmptyPane</a></li>
1530 <ul class="events itemMembers">
1535 <li class="item" data-name="LuCI.ui.Textarea">
1536 <span class="title">
1537 <a href="LuCI.ui.Textarea.html">LuCI.ui.Textarea</a>
1540 <ul class="members itemMembers">
1543 <ul class="typedefs itemMembers">
1545 <span class="subtitle">Typedefs</span>
1547 <li data-name="LuCI.ui.Textarea.InitOptions"><a href="LuCI.ui.Textarea.html#.InitOptions">InitOptions</a></li>
1550 <ul class="typedefs itemMembers">
1553 <ul class="methods itemMembers">
1555 <span class="subtitle">Methods</span>
1557 <li data-name="LuCI.ui.Textarea#getValue"><a href="LuCI.ui.Textarea.html#getValue">getValue</a></li>
1559 <li data-name="LuCI.ui.Textarea#isValid"><a href="LuCI.ui.Textarea.html#isValid">isValid</a></li>
1561 <li data-name="LuCI.ui.Textarea#registerEvents"><a href="LuCI.ui.Textarea.html#registerEvents">registerEvents</a></li>
1563 <li data-name="LuCI.ui.Textarea#render"><a href="LuCI.ui.Textarea.html#render">render</a></li>
1565 <li data-name="LuCI.ui.Textarea#setChangeEvents"><a href="LuCI.ui.Textarea.html#setChangeEvents">setChangeEvents</a></li>
1567 <li data-name="LuCI.ui.Textarea#setUpdateEvents"><a href="LuCI.ui.Textarea.html#setUpdateEvents">setUpdateEvents</a></li>
1569 <li data-name="LuCI.ui.Textarea#setValue"><a href="LuCI.ui.Textarea.html#setValue">setValue</a></li>
1571 <li data-name="LuCI.ui.Textarea#triggerValidation"><a href="LuCI.ui.Textarea.html#triggerValidation">triggerValidation</a></li>
1574 <ul class="events itemMembers">
1579 <li class="item" data-name="LuCI.ui.Textfield">
1580 <span class="title">
1581 <a href="LuCI.ui.Textfield.html">LuCI.ui.Textfield</a>
1584 <ul class="members itemMembers">
1587 <ul class="typedefs itemMembers">
1589 <span class="subtitle">Typedefs</span>
1591 <li data-name="LuCI.ui.Textfield.InitOptions"><a href="LuCI.ui.Textfield.html#.InitOptions">InitOptions</a></li>
1594 <ul class="typedefs itemMembers">
1597 <ul class="methods itemMembers">
1599 <span class="subtitle">Methods</span>
1601 <li data-name="LuCI.ui.Textfield#getValue"><a href="LuCI.ui.Textfield.html#getValue">getValue</a></li>
1603 <li data-name="LuCI.ui.Textfield#isValid"><a href="LuCI.ui.Textfield.html#isValid">isValid</a></li>
1605 <li data-name="LuCI.ui.Textfield#registerEvents"><a href="LuCI.ui.Textfield.html#registerEvents">registerEvents</a></li>
1607 <li data-name="LuCI.ui.Textfield#render"><a href="LuCI.ui.Textfield.html#render">render</a></li>
1609 <li data-name="LuCI.ui.Textfield#setChangeEvents"><a href="LuCI.ui.Textfield.html#setChangeEvents">setChangeEvents</a></li>
1611 <li data-name="LuCI.ui.Textfield#setUpdateEvents"><a href="LuCI.ui.Textfield.html#setUpdateEvents">setUpdateEvents</a></li>
1613 <li data-name="LuCI.ui.Textfield#setValue"><a href="LuCI.ui.Textfield.html#setValue">setValue</a></li>
1615 <li data-name="LuCI.ui.Textfield#triggerValidation"><a href="LuCI.ui.Textfield.html#triggerValidation">triggerValidation</a></li>
1618 <ul class="events itemMembers">
1623 <li class="item" data-name="LuCI.view">
1624 <span class="title">
1625 <a href="LuCI.view.html">LuCI.view</a>
1628 <ul class="members itemMembers">
1631 <ul class="typedefs itemMembers">
1634 <ul class="typedefs itemMembers">
1637 <ul class="methods itemMembers">
1639 <span class="subtitle">Methods</span>
1641 <li data-name="LuCI.view#addFooter"><a href="LuCI.view.html#addFooter">addFooter</a></li>
1643 <li data-name="LuCI.view#handleReset"><a href="LuCI.view.html#handleReset">handleReset</a></li>
1645 <li data-name="LuCI.view#handleSave"><a href="LuCI.view.html#handleSave">handleSave</a></li>
1647 <li data-name="LuCI.view#handleSaveApply"><a href="LuCI.view.html#handleSaveApply">handleSaveApply</a></li>
1649 <li data-name="LuCI.view#load"><a href="LuCI.view.html#load">load</a></li>
1651 <li data-name="LuCI.view#render"><a href="LuCI.view.html#render">render</a></li>
1654 <ul class="events itemMembers">
1659 <li class="item" data-name="LuCI.xhr">
1660 <span class="title">
1661 <a href="LuCI.xhr.html">LuCI.xhr</a>
1664 <ul class="members itemMembers">
1667 <ul class="typedefs itemMembers">
1670 <ul class="typedefs itemMembers">
1673 <ul class="methods itemMembers">
1675 <span class="subtitle">Methods</span>
1677 <li data-name="LuCI.xhr#abort"><a href="LuCI.xhr.html#abort">abort</a></li>
1679 <li data-name="LuCI.xhr#busy"><a href="LuCI.xhr.html#busy">busy</a></li>
1681 <li data-name="LuCI.xhr#cancel"><a href="LuCI.xhr.html#cancel">cancel</a></li>
1683 <li data-name="LuCI.xhr#get"><a href="LuCI.xhr.html#get">get</a></li>
1685 <li data-name="LuCI.xhr#post"><a href="LuCI.xhr.html#post">post</a></li>
1687 <li data-name="LuCI.xhr#send_form"><a href="LuCI.xhr.html#send_form">send_form</a></li>
1690 <ul class="events itemMembers">
1698 <h1 class="page-title" data-filename="network.js.html">Source: network.js</h1>
1705 <pre id="source-code" class="prettyprint source "><code>'use strict';
1708 'require validation';
1709 'require baseclass';
1712 var proto_errors = {
1713 CONNECT_FAILED: _('Connection attempt failed'),
1714 INVALID_ADDRESS: _('IP address is invalid'),
1715 INVALID_GATEWAY: _('Gateway address is invalid'),
1716 INVALID_LOCAL_ADDRESS: _('Local IP address is invalid'),
1717 MISSING_ADDRESS: _('IP address is missing'),
1718 MISSING_PEER_ADDRESS: _('Peer address is missing'),
1719 NO_DEVICE: _('Network device is not present'),
1720 NO_IFACE: _('Unable to determine device name'),
1721 NO_IFNAME: _('Unable to determine device name'),
1722 NO_WAN_ADDRESS: _('Unable to determine external IP address'),
1723 NO_WAN_LINK: _('Unable to determine upstream interface'),
1724 PEER_RESOLVE_FAIL: _('Unable to resolve peer host name'),
1725 PIN_FAILED: _('PIN code rejected')
1728 var iface_patterns_ignore = [
1744 var iface_patterns_wireless = [
1751 var iface_patterns_virtual = [ ];
1753 var callLuciNetworkDevices = rpc.declare({
1755 method: 'getNetworkDevices',
1759 var callLuciWirelessDevices = rpc.declare({
1761 method: 'getWirelessDevices',
1765 var callLuciBoardJSON = rpc.declare({
1767 method: 'getBoardJSON'
1770 var callLuciHostHints = rpc.declare({
1772 method: 'getHostHints',
1776 var callIwinfoAssoclist = rpc.declare({
1778 method: 'assoclist',
1779 params: [ 'device', 'mac' ],
1780 expect: { results: [] }
1783 var callIwinfoScan = rpc.declare({
1786 params: [ 'device' ],
1788 expect: { results: [] }
1791 var callNetworkInterfaceDump = rpc.declare({
1792 object: 'network.interface',
1794 expect: { 'interface': [] }
1797 var callNetworkProtoHandlers = rpc.declare({
1799 method: 'get_proto_handlers',
1808 function getProtocolHandlers(cache) {
1809 return callNetworkProtoHandlers().then(function(protos) {
1810 /* Register "none" protocol */
1811 if (!protos.hasOwnProperty('none'))
1812 Object.assign(protos, { none: { no_device: false } });
1814 /* Hack: emulate relayd protocol */
1815 if (!protos.hasOwnProperty('relay'))
1816 Object.assign(protos, { relay: { no_device: true } });
1818 Object.assign(_protospecs, protos);
1820 return Promise.all(Object.keys(protos).map(function(p) {
1821 return Promise.resolve(L.require('protocol.%s'.format(p))).catch(function(err) {
1822 if (L.isObject(err) && err.name != 'NetworkError')
1825 })).then(function() {
1828 }).catch(function() {
1833 function getWifiStateBySid(sid) {
1834 var s = uci.get('wireless', sid);
1836 if (s != null && s['.type'] == 'wifi-iface') {
1837 for (var radioname in _state.radios) {
1838 for (var i = 0; i < _state.radios[radioname].interfaces.length; i++) {
1839 var netstate = _state.radios[radioname].interfaces[i];
1841 if (typeof(netstate.section) != 'string')
1844 var s2 = uci.get('wireless', netstate.section);
1846 if (s2 != null && s['.type'] == s2['.type'] && s['.name'] == s2['.name']) {
1847 if (s2['.anonymous'] == false && netstate.section.charAt(0) == '@')
1850 return [ radioname, _state.radios[radioname], netstate ];
1859 function getWifiStateByIfname(ifname) {
1860 for (var radioname in _state.radios) {
1861 for (var i = 0; i < _state.radios[radioname].interfaces.length; i++) {
1862 var netstate = _state.radios[radioname].interfaces[i];
1864 if (typeof(netstate.ifname) != 'string')
1867 if (netstate.ifname == ifname)
1868 return [ radioname, _state.radios[radioname], netstate ];
1875 function isWifiIfname(ifname) {
1876 for (var i = 0; i < iface_patterns_wireless.length; i++)
1877 if (iface_patterns_wireless[i].test(ifname))
1883 function getWifiSidByNetid(netid) {
1884 var m = /^(\w+)\.network(\d+)$/.exec(netid);
1886 var sections = uci.sections('wireless', 'wifi-iface');
1887 for (var i = 0, n = 0; i < sections.length; i++) {
1888 if (sections[i].device != m[1])
1892 return sections[i]['.name'];
1899 function getWifiSidByIfname(ifname) {
1900 var sid = getWifiSidByNetid(ifname);
1905 var res = getWifiStateByIfname(ifname);
1907 if (res != null && L.isObject(res[2]) && typeof(res[2].section) == 'string')
1908 return res[2].section;
1913 function getWifiNetidBySid(sid) {
1914 var s = uci.get('wireless', sid);
1915 if (s != null && s['.type'] == 'wifi-iface') {
1916 var radioname = s.device;
1917 if (typeof(s.device) == 'string') {
1918 var i = 0, netid = null, sections = uci.sections('wireless', 'wifi-iface');
1919 for (var i = 0, n = 0; i < sections.length; i++) {
1920 if (sections[i].device != s.device)
1925 if (sections[i]['.name'] != s['.name'])
1928 return [ '%s.network%d'.format(s.device, n), s.device ];
1937 function getWifiNetidByNetname(name) {
1938 var sections = uci.sections('wireless', 'wifi-iface');
1939 for (var i = 0; i < sections.length; i++) {
1940 if (typeof(sections[i].network) != 'string')
1943 var nets = sections[i].network.split(/\s+/);
1944 for (var j = 0; j < nets.length; j++) {
1945 if (nets[j] != name)
1948 return getWifiNetidBySid(sections[i]['.name']);
1955 function isVirtualIfname(ifname) {
1956 for (var i = 0; i < iface_patterns_virtual.length; i++)
1957 if (iface_patterns_virtual[i].test(ifname))
1963 function isIgnoredIfname(ifname) {
1964 for (var i = 0; i < iface_patterns_ignore.length; i++)
1965 if (iface_patterns_ignore[i].test(ifname))
1971 function appendValue(config, section, option, value) {
1972 var values = uci.get(config, section, option),
1973 isArray = Array.isArray(values),
1976 if (isArray == false)
1977 values = L.toArray(values);
1979 if (values.indexOf(value) == -1) {
1984 uci.set(config, section, option, isArray ? values : values.join(' '));
1989 function removeValue(config, section, option, value) {
1990 var values = uci.get(config, section, option),
1991 isArray = Array.isArray(values),
1994 if (isArray == false)
1995 values = L.toArray(values);
1997 for (var i = values.length - 1; i >= 0; i--) {
1998 if (values[i] == value) {
1999 values.splice(i, 1);
2004 if (values.length > 0)
2005 uci.set(config, section, option, isArray ? values : values.join(' '));
2007 uci.unset(config, section, option);
2012 function prefixToMask(bits, v6) {
2013 var w = v6 ? 128 : 32,
2019 for (var i = 0; i < w / 16; i++) {
2020 var b = Math.min(16, bits);
2021 m.push((0xffff << (16 - b)) & 0xffff);
2026 return String.prototype.format.apply('%x:%x:%x:%x:%x:%x:%x:%x', m).replace(/:0(?::0)+$/, '::');
2028 return '%d.%d.%d.%d'.format(m[0] >>> 8, m[0] & 0xff, m[1] >>> 8, m[1] & 0xff);
2031 function maskToPrefix(mask, v6) {
2032 var m = v6 ? validation.parseIPv6(mask) : validation.parseIPv4(mask);
2039 for (var i = 0, z = false; i < m.length; i++) {
2042 while (!z && (m[i] & (v6 ? 0x8000 : 0x80))) {
2043 m[i] = (m[i] << 1) & (v6 ? 0xffff : 0xff);
2054 function initNetworkState(refresh) {
2055 if (_state == null || refresh) {
2056 _init = _init || Promise.all([
2057 L.resolveDefault(callNetworkInterfaceDump(), []),
2058 L.resolveDefault(callLuciBoardJSON(), {}),
2059 L.resolveDefault(callLuciNetworkDevices(), {}),
2060 L.resolveDefault(callLuciWirelessDevices(), {}),
2061 L.resolveDefault(callLuciHostHints(), {}),
2062 getProtocolHandlers(),
2063 uci.load(['network', 'wireless', 'luci'])
2064 ]).then(function(data) {
2065 var netifd_ifaces = data[0],
2066 board_json = data[1],
2067 luci_devs = data[2];
2070 isTunnel: {}, isBridge: {}, isSwitch: {}, isWifi: {},
2071 ifaces: netifd_ifaces, radios: data[3], hosts: data[4],
2072 netdevs: {}, bridges: {}, switches: {}, hostapd: {}
2075 for (var name in luci_devs) {
2076 var dev = luci_devs[name];
2078 if (isVirtualIfname(name))
2079 s.isTunnel[name] = true;
2081 if (!s.isTunnel[name] && isIgnoredIfname(name))
2084 s.netdevs[name] = s.netdevs[name] || {
2094 wireless: dev.wireless,
2099 if (Array.isArray(dev.ipaddrs))
2100 for (var i = 0; i < dev.ipaddrs.length; i++)
2101 s.netdevs[name].ipaddrs.push(dev.ipaddrs[i].address + '/' + dev.ipaddrs[i].netmask);
2103 if (Array.isArray(dev.ip6addrs))
2104 for (var i = 0; i < dev.ip6addrs.length; i++)
2105 s.netdevs[name].ip6addrs.push(dev.ip6addrs[i].address + '/' + dev.ip6addrs[i].netmask);
2108 for (var name in luci_devs) {
2109 var dev = luci_devs[name];
2121 for (var i = 0; dev.ports && i < dev.ports.length; i++) {
2122 var subdev = s.netdevs[dev.ports[i]];
2127 b.ifnames.push(subdev);
2131 s.bridges[name] = b;
2132 s.isBridge[name] = true;
2135 if (L.isObject(board_json.switch)) {
2136 for (var switchname in board_json.switch) {
2137 var layout = board_json.switch[switchname],
2144 if (L.isObject(layout) && Array.isArray(layout.ports)) {
2145 for (var i = 0, port; (port = layout.ports[i]) != null; i++) {
2146 if (typeof(port) == 'object' && typeof(port.num) == 'number' &&
2147 (typeof(port.role) == 'string' || typeof(port.device) == 'string')) {
2150 role: port.role || 'cpu',
2151 index: (port.index != null) ? port.index : port.num
2154 if (port.device != null) {
2155 spec.device = port.device;
2156 spec.tagged = spec.need_tag;
2157 netdevs[port.num] = port.device;
2162 if (port.role != null)
2163 nports[port.role] = (nports[port.role] || 0) + 1;
2167 ports.sort(function(a, b) {
2168 if (a.role != b.role)
2169 return (a.role < b.role) ? -1 : 1;
2171 return (a.index - b.index);
2174 for (var i = 0, port; (port = ports[i]) != null; i++) {
2175 if (port.role != role) {
2181 port.label = 'CPU (%s)'.format(port.device);
2182 else if (nports[role] > 1)
2183 port.label = '%s %d'.format(role.toUpperCase(), pnum++);
2185 port.label = role.toUpperCase();
2191 s.switches[switchname] = {
2199 if (L.isObject(board_json.dsl) && L.isObject(board_json.dsl.modem)) {
2200 s.hasDSLModem = board_json.dsl.modem;
2207 if (L.isObject(s.radios))
2208 for (var radio in s.radios)
2209 if (L.isObject(s.radios[radio]) && Array.isArray(s.radios[radio].interfaces))
2210 for (var i = 0; i < s.radios[radio].interfaces.length; i++)
2211 if (L.isObject(s.radios[radio].interfaces[i]) && s.radios[radio].interfaces[i].ifname)
2212 objects.push('hostapd.%s'.format(s.radios[radio].interfaces[i].ifname));
2214 return (objects.length ? L.resolveDefault(rpc.list.apply(rpc, objects), {}) : Promise.resolve({})).then(function(res) {
2215 for (var k in res) {
2216 var m = k.match(/^hostapd\.(.+)$/);
2218 s.hostapd[m[1]] = res[k];
2221 return (_state = s);
2226 return (_state != null ? Promise.resolve(_state) : _init);
2229 function ifnameOf(obj) {
2230 if (obj instanceof Protocol)
2231 return obj.getIfname();
2232 else if (obj instanceof Device)
2233 return obj.getName();
2234 else if (obj instanceof WifiDevice)
2235 return obj.getName();
2236 else if (obj instanceof WifiNetwork)
2237 return obj.getIfname();
2238 else if (typeof(obj) == 'string')
2239 return obj.replace(/:.+$/, '');
2244 function networkSort(a, b) {
2245 return a.getName() > b.getName();
2248 function deviceSort(a, b) {
2249 var typeWeigth = { wifi: 2, alias: 3 },
2250 weightA = typeWeigth[a.getType()] || 1,
2251 weightB = typeWeigth[b.getType()] || 1;
2253 if (weightA != weightB)
2254 return weightA - weightB;
2256 return a.getName() > b.getName();
2259 function formatWifiEncryption(enc) {
2260 if (!L.isObject(enc))
2266 var ciphers = Array.isArray(enc.ciphers)
2267 ? enc.ciphers.map(function(c) { return c.toUpperCase() }) : [ 'NONE' ];
2269 if (Array.isArray(enc.wep)) {
2270 var has_open = false,
2273 for (var i = 0; i < enc.wep.length; i++)
2274 if (enc.wep[i] == 'open')
2276 else if (enc.wep[i] == 'shared')
2279 if (has_open && has_shared)
2280 return 'WEP Open/Shared (%s)'.format(ciphers.join(', '));
2282 return 'WEP Open System (%s)'.format(ciphers.join(', '));
2283 else if (has_shared)
2284 return 'WEP Shared Auth (%s)'.format(ciphers.join(', '));
2289 if (Array.isArray(enc.wpa)) {
2291 suites = Array.isArray(enc.authentication)
2292 ? enc.authentication.map(function(a) { return a.toUpperCase() }) : [ 'NONE' ];
2294 for (var i = 0; i < enc.wpa.length; i++)
2295 switch (enc.wpa[i]) {
2297 versions.push('WPA');
2301 versions.push('WPA%d'.format(enc.wpa[i]));
2305 if (versions.length > 1)
2306 return 'mixed %s %s (%s)'.format(versions.join('/'), suites.join(', '), ciphers.join(', '));
2308 return '%s %s (%s)'.format(versions[0], suites.join(', '), ciphers.join(', '));
2314 function enumerateNetworks() {
2315 var uciInterfaces = uci.sections('network', 'interface'),
2318 for (var i = 0; i < uciInterfaces.length; i++)
2319 networks[uciInterfaces[i]['.name']] = this.instantiateNetwork(uciInterfaces[i]['.name']);
2321 for (var i = 0; i < _state.ifaces.length; i++)
2322 if (networks[_state.ifaces[i].interface] == null)
2323 networks[_state.ifaces[i].interface] =
2324 this.instantiateNetwork(_state.ifaces[i].interface, _state.ifaces[i].proto);
2328 for (var network in networks)
2329 if (networks.hasOwnProperty(network))
2330 rv.push(networks[network]);
2332 rv.sort(networkSort);
2338 var Hosts, Network, Protocol, Device, WifiDevice, WifiNetwork;
2346 * The `LuCI.network` class combines data from multiple `ubus` apis to
2347 * provide an abstraction of the current network configuration state.
2349 * It provides methods to enumerate interfaces and devices, to query
2350 * current configuration details and to manipulate settings.
2352 Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
2354 * Converts the given prefix size in bits to a netmask.
2358 * @param {number} bits
2359 * The prefix size in bits.
2361 * @param {boolean} [v6=false]
2362 * Whether to convert the bits value into an IPv4 netmask (`false`) or
2363 * an IPv6 netmask (`true`).
2365 * @returns {null|string}
2366 * Returns a string containing the netmask corresponding to the bit count
2367 * or `null` when the given amount of bits exceeds the maximum possible
2368 * value of `32` for IPv4 or `128` for IPv6.
2370 prefixToMask: prefixToMask,
2373 * Converts the given netmask to a prefix size in bits.
2377 * @param {string} netmask
2378 * The netmask to convert into a bit count.
2380 * @param {boolean} [v6=false]
2381 * Whether to parse the given netmask as IPv4 (`false`) or IPv6 (`true`)
2384 * @returns {null|number}
2385 * Returns the number of prefix bits contained in the netmask or `null`
2386 * if the given netmask value was invalid.
2388 maskToPrefix: maskToPrefix,
2391 * An encryption entry describes active wireless encryption settings
2392 * such as the used key management protocols, active ciphers and
2393 * protocol versions.
2395 * @typedef {Object<string, boolean|Array<number|string>>} LuCI.network.WifiEncryption
2396 * @memberof LuCI.network
2398 * @property {boolean} enabled
2399 * Specifies whether any kind of encryption, such as `WEP` or `WPA` is
2400 * enabled. If set to `false`, then no encryption is active and the
2401 * corresponding network is open.
2403 * @property {string[]} [wep]
2404 * When the `wep` property exists, the network uses WEP encryption.
2405 * In this case, the property is set to an array of active WEP modes
2406 * which might be either `open`, `shared` or both.
2408 * @property {number[]} [wpa]
2409 * When the `wpa` property exists, the network uses WPA security.
2410 * In this case, the property is set to an array containing the WPA
2411 * protocol versions used, e.g. `[ 1, 2 ]` for WPA/WPA2 mixed mode or
2412 * `[ 3 ]` for WPA3-SAE.
2414 * @property {string[]} [authentication]
2415 * The `authentication` property only applies to WPA encryption and
2416 * is defined when the `wpa` property is set as well. It points to
2417 * an array of active authentication suites used by the network, e.g.
2418 * `[ "psk" ]` for a WPA(2)-PSK network or `[ "psk", "sae" ]` for
2419 * mixed WPA2-PSK/WPA3-SAE encryption.
2421 * @property {string[]} [ciphers]
2422 * If either WEP or WPA encryption is active, then the `ciphers`
2423 * property will be set to an array describing the active encryption
2424 * ciphers used by the network, e.g. `[ "tkip", "ccmp" ]` for a
2425 * WPA/WPA2-PSK mixed network or `[ "wep-40", "wep-104" ]` for an
2430 * Converts a given {@link LuCI.network.WifiEncryption encryption entry}
2431 * into a human readable string such as `mixed WPA/WPA2 PSK (TKIP, CCMP)`
2432 * or `WPA3 SAE (CCMP)`.
2436 * @param {LuCI.network.WifiEncryption} encryption
2437 * The wireless encryption entry to convert.
2439 * @returns {null|string}
2440 * Returns the description string for the given encryption entry or
2441 * `null` if the given entry was invalid.
2443 formatWifiEncryption: formatWifiEncryption,
2446 * Flushes the local network state cache and fetches updated information
2447 * from the remote `ubus` apis.
2449 * @returns {Promise<Object>}
2450 * Returns a promise resolving to the internal network state object.
2452 flushCache: function() {
2453 initNetworkState(true);
2458 * Instantiates the given {@link LuCI.network.Protocol Protocol} backend,
2459 * optionally using the given network name.
2461 * @param {string} protoname
2462 * The protocol backend to use, e.g. `static` or `dhcp`.
2464 * @param {string} [netname=__dummy__]
2465 * The network name to use for the instantiated protocol. This should be
2466 * usually set to one of the interfaces described in /etc/config/network
2467 * but it is allowed to omit it, e.g. to query protocol capabilities
2468 * without the need for an existing interface.
2470 * @returns {null|LuCI.network.Protocol}
2471 * Returns the instantiated protocol backend class or `null` if the given
2472 * protocol isn't known.
2474 getProtocol: function(protoname, netname) {
2475 var v = _protocols[protoname];
2477 return new v(netname || '__dummy__');
2483 * Obtains instances of all known {@link LuCI.network.Protocol Protocol}
2486 * @returns {Array<LuCI.network.Protocol>}
2487 * Returns an array of protocol class instances.
2489 getProtocols: function() {
2492 for (var protoname in _protocols)
2493 rv.push(new _protocols[protoname]('__dummy__'));
2499 * Registers a new {@link LuCI.network.Protocol Protocol} subclass
2500 * with the given methods and returns the resulting subclass value.
2502 * This functions internally calls
2503 * {@link LuCI.Class.extend Class.extend()} on the `Network.Protocol`
2506 * @param {string} protoname
2507 * The name of the new protocol to register.
2509 * @param {Object<string, *>} methods
2510 * The member methods and values of the new `Protocol` subclass to
2511 * be passed to {@link LuCI.Class.extend Class.extend()}.
2513 * @returns {LuCI.network.Protocol}
2514 * Returns the new `Protocol` subclass.
2516 registerProtocol: function(protoname, methods) {
2517 var spec = L.isObject(_protospecs) ? _protospecs[protoname] : null;
2518 var proto = Protocol.extend(Object.assign({
2519 getI18n: function() {
2523 isFloating: function() {
2527 isVirtual: function() {
2528 return (L.isObject(spec) && spec.no_device == true);
2531 renderFormOptions: function(section) {
2535 __init__: function(name) {
2539 getProtocol: function() {
2544 _protocols[protoname] = proto;
2550 * Registers a new regular expression pattern to recognize
2551 * virtual interfaces.
2553 * @param {RegExp} pat
2554 * A `RegExp` instance to match a virtual interface name
2555 * such as `6in4-wan` or `tun0`.
2557 registerPatternVirtual: function(pat) {
2558 iface_patterns_virtual.push(pat);
2562 * Registers a new human readable translation string for a `Protocol`
2565 * @param {string} code
2566 * The `ubus` protocol error code to register a translation for, e.g.
2569 * @param {string} message
2570 * The message to use as translation for the given protocol error code.
2572 * @returns {boolean}
2573 * Returns `true` if the error code description has been added or `false`
2574 * if either the arguments were invalid or if there already was a
2575 * description for the given code.
2577 registerErrorCode: function(code, message) {
2578 if (typeof(code) == 'string' &&
2579 typeof(message) == 'string' &&
2580 !proto_errors.hasOwnProperty(code)) {
2581 proto_errors[code] = message;
2589 * Adds a new network of the given name and update it with the given
2590 * uci option values.
2592 * If a network with the given name already exist but is empty, then
2593 * this function will update its option, otherwise it will do nothing.
2595 * @param {string} name
2596 * The name of the network to add. Must be in the format `[a-zA-Z0-9_]+`.
2598 * @param {Object<string, string|string[]>} [options]
2599 * An object of uci option values to set on the new network or to
2600 * update in an existing, empty network.
2602 * @returns {Promise<null|LuCI.network.Protocol>}
2603 * Returns a promise resolving to the `Protocol` subclass instance
2604 * describing the added network or resolving to `null` if the name
2605 * was invalid or if a non-empty network of the given name already
2608 addNetwork: function(name, options) {
2609 return this.getNetwork(name).then(L.bind(function(existingNetwork) {
2610 if (name != null && /^[a-zA-Z0-9_]+$/.test(name) && existingNetwork == null) {
2611 var sid = uci.add('network', 'interface', name);
2614 if (L.isObject(options))
2615 for (var key in options)
2616 if (options.hasOwnProperty(key))
2617 uci.set('network', sid, key, options[key]);
2619 return this.instantiateNetwork(sid);
2622 else if (existingNetwork != null && existingNetwork.isEmpty()) {
2623 if (L.isObject(options))
2624 for (var key in options)
2625 if (options.hasOwnProperty(key))
2626 existingNetwork.set(key, options[key]);
2628 return existingNetwork;
2634 * Get a {@link LuCI.network.Protocol Protocol} instance describing
2635 * the network with the given name.
2637 * @param {string} name
2638 * The logical interface name of the network get, e.g. `lan` or `wan`.
2640 * @returns {Promise<null|LuCI.network.Protocol>}
2641 * Returns a promise resolving to a
2642 * {@link LuCI.network.Protocol Protocol} subclass instance describing
2643 * the network or `null` if the network did not exist.
2645 getNetwork: function(name) {
2646 return initNetworkState().then(L.bind(function() {
2647 var section = (name != null) ? uci.get('network', name) : null;
2649 if (section != null && section['.type'] == 'interface') {
2650 return this.instantiateNetwork(name);
2652 else if (name != null) {
2653 for (var i = 0; i < _state.ifaces.length; i++)
2654 if (_state.ifaces[i].interface == name)
2655 return this.instantiateNetwork(name, _state.ifaces[i].proto);
2663 * Gets an array containing all known networks.
2665 * @returns {Promise<Array<LuCI.network.Protocol>>}
2666 * Returns a promise resolving to a name-sorted array of
2667 * {@link LuCI.network.Protocol Protocol} subclass instances
2668 * describing all known networks.
2670 getNetworks: function() {
2671 return initNetworkState().then(L.bind(enumerateNetworks, this));
2675 * Deletes the given network and its references from the network and
2676 * firewall configuration.
2678 * @param {string} name
2679 * The name of the network to delete.
2681 * @returns {Promise<boolean>}
2682 * Returns a promise resolving to either `true` if the network and
2683 * references to it were successfully deleted from the configuration or
2684 * `false` if the given network could not be found.
2686 deleteNetwork: function(name) {
2687 var requireFirewall = Promise.resolve(L.require('firewall')).catch(function() {}),
2688 network = this.instantiateNetwork(name);
2690 return Promise.all([ requireFirewall, initNetworkState() ]).then(function(res) {
2691 var uciInterface = uci.get('network', name),
2694 if (uciInterface != null && uciInterface['.type'] == 'interface') {
2695 return Promise.resolve(network ? network.deleteConfiguration() : null).then(function() {
2696 uci.remove('network', name);
2698 uci.sections('luci', 'ifstate', function(s) {
2699 if (s.interface == name)
2700 uci.remove('luci', s['.name']);
2703 uci.sections('network', 'alias', function(s) {
2704 if (s.interface == name)
2705 uci.remove('network', s['.name']);
2708 uci.sections('network', 'route', function(s) {
2709 if (s.interface == name)
2710 uci.remove('network', s['.name']);
2713 uci.sections('network', 'route6', function(s) {
2714 if (s.interface == name)
2715 uci.remove('network', s['.name']);
2718 uci.sections('wireless', 'wifi-iface', function(s) {
2719 var networks = L.toArray(s.network).filter(function(network) { return network != name });
2721 if (networks.length > 0)
2722 uci.set('wireless', s['.name'], 'network', networks.join(' '));
2724 uci.unset('wireless', s['.name'], 'network');
2728 return firewall.deleteNetwork(name).then(function() { return true });
2731 }).catch(function() {
2741 * Rename the given network and its references to a new name.
2743 * @param {string} oldName
2744 * The current name of the network.
2746 * @param {string} newName
2747 * The name to rename the network to, must be in the format
2750 * @returns {Promise<boolean>}
2751 * Returns a promise resolving to either `true` if the network was
2752 * successfully renamed or `false` if the new name was invalid, if
2753 * a network with the new name already exists or if the network to
2754 * rename could not be found.
2756 renameNetwork: function(oldName, newName) {
2757 return initNetworkState().then(function() {
2758 if (newName == null || !/^[a-zA-Z0-9_]+$/.test(newName) || uci.get('network', newName) != null)
2761 var oldNetwork = uci.get('network', oldName);
2763 if (oldNetwork == null || oldNetwork['.type'] != 'interface')
2766 var sid = uci.add('network', 'interface', newName);
2768 for (var key in oldNetwork)
2769 if (oldNetwork.hasOwnProperty(key) && key.charAt(0) != '.')
2770 uci.set('network', sid, key, oldNetwork[key]);
2772 uci.sections('luci', 'ifstate', function(s) {
2773 if (s.interface == oldName)
2774 uci.set('luci', s['.name'], 'interface', newName);
2777 uci.sections('network', 'alias', function(s) {
2778 if (s.interface == oldName)
2779 uci.set('network', s['.name'], 'interface', newName);
2782 uci.sections('network', 'route', function(s) {
2783 if (s.interface == oldName)
2784 uci.set('network', s['.name'], 'interface', newName);
2787 uci.sections('network', 'route6', function(s) {
2788 if (s.interface == oldName)
2789 uci.set('network', s['.name'], 'interface', newName);
2792 uci.sections('wireless', 'wifi-iface', function(s) {
2793 var networks = L.toArray(s.network).map(function(network) { return (network == oldName ? newName : network) });
2795 if (networks.length > 0)
2796 uci.set('wireless', s['.name'], 'network', networks.join(' '));
2799 uci.remove('network', oldName);
2806 * Get a {@link LuCI.network.Device Device} instance describing the
2807 * given network device.
2809 * @param {string} name
2810 * The name of the network device to get, e.g. `eth0` or `br-lan`.
2812 * @returns {Promise<null|LuCI.network.Device>}
2813 * Returns a promise resolving to the `Device` instance describing
2814 * the network device or `null` if the given device name could not
2817 getDevice: function(name) {
2818 return initNetworkState().then(L.bind(function() {
2822 if (_state.netdevs.hasOwnProperty(name) || isWifiIfname(name))
2823 return this.instantiateDevice(name);
2825 var netid = getWifiNetidBySid(name);
2827 return this.instantiateDevice(netid[0]);
2834 * Get a sorted list of all found network devices.
2836 * @returns {Promise<Array<LuCI.network.Device>>}
2837 * Returns a promise resolving to a sorted array of `Device` class
2838 * instances describing the network devices found on the system.
2840 getDevices: function() {
2841 return initNetworkState().then(L.bind(function() {
2844 /* find simple devices */
2845 var uciInterfaces = uci.sections('network', 'interface');
2846 for (var i = 0; i < uciInterfaces.length; i++) {
2847 var ifnames = L.toArray(uciInterfaces[i].ifname);
2849 for (var j = 0; j < ifnames.length; j++) {
2850 if (ifnames[j].charAt(0) == '@')
2853 if (isIgnoredIfname(ifnames[j]) || isVirtualIfname(ifnames[j]) || isWifiIfname(ifnames[j]))
2856 devices[ifnames[j]] = this.instantiateDevice(ifnames[j]);
2860 for (var ifname in _state.netdevs) {
2861 if (devices.hasOwnProperty(ifname))
2864 if (isIgnoredIfname(ifname) || isWifiIfname(ifname))
2867 if (_state.netdevs[ifname].wireless)
2870 devices[ifname] = this.instantiateDevice(ifname);
2873 /* find VLAN devices */
2874 var uciSwitchVLANs = uci.sections('network', 'switch_vlan');
2875 for (var i = 0; i < uciSwitchVLANs.length; i++) {
2876 if (typeof(uciSwitchVLANs[i].ports) != 'string' ||
2877 typeof(uciSwitchVLANs[i].device) != 'string' ||
2878 !_state.switches.hasOwnProperty(uciSwitchVLANs[i].device))
2881 var ports = uciSwitchVLANs[i].ports.split(/\s+/);
2882 for (var j = 0; j < ports.length; j++) {
2883 var m = ports[j].match(/^(\d+)([tu]?)$/);
2887 var netdev = _state.switches[uciSwitchVLANs[i].device].netdevs[m[1]];
2891 if (!devices.hasOwnProperty(netdev))
2892 devices[netdev] = this.instantiateDevice(netdev);
2894 _state.isSwitch[netdev] = true;
2899 var vid = uciSwitchVLANs[i].vid || uciSwitchVLANs[i].vlan;
2900 vid = (vid != null ? +vid : null);
2902 if (vid == null || vid < 0 || vid > 4095)
2905 var vlandev = '%s.%d'.format(netdev, vid);
2907 if (!devices.hasOwnProperty(vlandev))
2908 devices[vlandev] = this.instantiateDevice(vlandev);
2910 _state.isSwitch[vlandev] = true;
2914 /* find wireless interfaces */
2915 var uciWifiIfaces = uci.sections('wireless', 'wifi-iface'),
2918 for (var i = 0; i < uciWifiIfaces.length; i++) {
2919 if (typeof(uciWifiIfaces[i].device) != 'string')
2922 networkCount[uciWifiIfaces[i].device] = (networkCount[uciWifiIfaces[i].device] || 0) + 1;
2924 var netid = '%s.network%d'.format(uciWifiIfaces[i].device, networkCount[uciWifiIfaces[i].device]);
2926 devices[netid] = this.instantiateDevice(netid);
2931 for (var netdev in devices)
2932 if (devices.hasOwnProperty(netdev))
2933 rv.push(devices[netdev]);
2935 rv.sort(deviceSort);
2942 * Test if a given network device name is in the list of patterns for
2943 * device names to ignore.
2945 * Ignored device names are usually Linux network devices which are
2946 * spawned implicitly by kernel modules such as `tunl0` or `hwsim0`
2947 * and which are unsuitable for use in network configuration.
2949 * @param {string} name
2950 * The device name to test.
2952 * @returns {boolean}
2953 * Returns `true` if the given name is in the ignore pattern list,
2954 * else returns `false`.
2956 isIgnoredDevice: function(name) {
2957 return isIgnoredIfname(name);
2961 * Get a {@link LuCI.network.WifiDevice WifiDevice} instance describing
2962 * the given wireless radio.
2964 * @param {string} devname
2965 * The configuration name of the wireless radio to lookup, e.g. `radio0`
2966 * for the first mac80211 phy on the system.
2968 * @returns {Promise<null|LuCI.network.WifiDevice>}
2969 * Returns a promise resolving to the `WifiDevice` instance describing
2970 * the underlying radio device or `null` if the wireless radio could not
2973 getWifiDevice: function(devname) {
2974 return initNetworkState().then(L.bind(function() {
2975 var existingDevice = uci.get('wireless', devname);
2977 if (existingDevice == null || existingDevice['.type'] != 'wifi-device')
2980 return this.instantiateWifiDevice(devname, _state.radios[devname] || {});
2985 * Obtain a list of all configured radio devices.
2987 * @returns {Promise<Array<LuCI.network.WifiDevice>>}
2988 * Returns a promise resolving to an array of `WifiDevice` instances
2989 * describing the wireless radios configured in the system.
2990 * The order of the array corresponds to the order of the radios in
2991 * the configuration.
2993 getWifiDevices: function() {
2994 return initNetworkState().then(L.bind(function() {
2995 var uciWifiDevices = uci.sections('wireless', 'wifi-device'),
2998 for (var i = 0; i < uciWifiDevices.length; i++) {
2999 var devname = uciWifiDevices[i]['.name'];
3000 rv.push(this.instantiateWifiDevice(devname, _state.radios[devname] || {}));
3008 * Get a {@link LuCI.network.WifiNetwork WifiNetwork} instance describing
3009 * the given wireless network.
3011 * @param {string} netname
3012 * The name of the wireless network to lookup. This may be either an uci
3013 * configuration section ID, a network ID in the form `radio#.network#`
3014 * or a Linux network device name like `wlan0` which is resolved to the
3015 * corresponding configuration section through `ubus` runtime information.
3017 * @returns {Promise<null|LuCI.network.WifiNetwork>}
3018 * Returns a promise resolving to the `WifiNetwork` instance describing
3019 * the wireless network or `null` if the corresponding network could not
3022 getWifiNetwork: function(netname) {
3023 return initNetworkState()
3024 .then(L.bind(this.lookupWifiNetwork, this, netname));
3028 * Get an array of all {@link LuCI.network.WifiNetwork WifiNetwork}
3029 * instances describing the wireless networks present on the system.
3031 * @returns {Promise<Array<LuCI.network.WifiNetwork>>}
3032 * Returns a promise resolving to an array of `WifiNetwork` instances
3033 * describing the wireless networks. The array will be empty if no networks
3036 getWifiNetworks: function() {
3037 return initNetworkState().then(L.bind(function() {
3038 var wifiIfaces = uci.sections('wireless', 'wifi-iface'),
3041 for (var i = 0; i < wifiIfaces.length; i++)
3042 rv.push(this.lookupWifiNetwork(wifiIfaces[i]['.name']));
3044 rv.sort(function(a, b) {
3045 return (a.getID() > b.getID());
3053 * Adds a new wireless network to the configuration and sets its options
3054 * to the provided values.
3056 * @param {Object<string, string|string[]>} options
3057 * The options to set for the newly added wireless network. This object
3058 * must at least contain a `device` property which is set to the radio
3059 * name the new network belongs to.
3061 * @returns {Promise<null|LuCI.network.WifiNetwork>}
3062 * Returns a promise resolving to a `WifiNetwork` instance describing
3063 * the newly added wireless network or `null` if the given options
3064 * were invalid or if the associated radio device could not be found.
3066 addWifiNetwork: function(options) {
3067 return initNetworkState().then(L.bind(function() {
3068 if (options == null ||
3069 typeof(options) != 'object' ||
3070 typeof(options.device) != 'string')
3073 var existingDevice = uci.get('wireless', options.device);
3074 if (existingDevice == null || existingDevice['.type'] != 'wifi-device')
3077 /* XXX: need to add a named section (wifinet#) here */
3078 var sid = uci.add('wireless', 'wifi-iface');
3079 for (var key in options)
3080 if (options.hasOwnProperty(key))
3081 uci.set('wireless', sid, key, options[key]);
3083 var radioname = existingDevice['.name'],
3084 netid = getWifiNetidBySid(sid) || [];
3086 return this.instantiateWifiNetwork(sid, radioname, _state.radios[radioname], netid[0], null);
3091 * Deletes the given wireless network from the configuration.
3093 * @param {string} netname
3094 * The name of the network to remove. This may be either a
3095 * network ID in the form `radio#.network#` or a Linux network device
3096 * name like `wlan0` which is resolved to the corresponding configuration
3097 * section through `ubus` runtime information.
3099 * @returns {Promise<boolean>}
3100 * Returns a promise resolving to `true` if the wireless network has been
3101 * successfully deleted from the configuration or `false` if it could not
3104 deleteWifiNetwork: function(netname) {
3105 return initNetworkState().then(L.bind(function() {
3106 var sid = getWifiSidByIfname(netname);
3111 uci.remove('wireless', sid);
3117 getStatusByRoute: function(addr, mask) {
3118 return initNetworkState().then(L.bind(function() {
3121 for (var i = 0; i < _state.ifaces.length; i++) {
3122 if (!Array.isArray(_state.ifaces[i].route))
3125 for (var j = 0; j < _state.ifaces[i].route.length; j++) {
3126 if (typeof(_state.ifaces[i].route[j]) != 'object' ||
3127 typeof(_state.ifaces[i].route[j].target) != 'string' ||
3128 typeof(_state.ifaces[i].route[j].mask) != 'number')
3131 if (_state.ifaces[i].route[j].table)
3134 if (_state.ifaces[i].route[j].target != addr ||
3135 _state.ifaces[i].route[j].mask != mask)
3138 rv.push(_state.ifaces[i]);
3147 getStatusByAddress: function(addr) {
3148 return initNetworkState().then(L.bind(function() {
3151 for (var i = 0; i < _state.ifaces.length; i++) {
3152 if (Array.isArray(_state.ifaces[i]['ipv4-address']))
3153 for (var j = 0; j < _state.ifaces[i]['ipv4-address'].length; j++)
3154 if (typeof(_state.ifaces[i]['ipv4-address'][j]) == 'object' &&
3155 _state.ifaces[i]['ipv4-address'][j].address == addr)
3156 return _state.ifaces[i];
3158 if (Array.isArray(_state.ifaces[i]['ipv6-address']))
3159 for (var j = 0; j < _state.ifaces[i]['ipv6-address'].length; j++)
3160 if (typeof(_state.ifaces[i]['ipv6-address'][j]) == 'object' &&
3161 _state.ifaces[i]['ipv6-address'][j].address == addr)
3162 return _state.ifaces[i];
3164 if (Array.isArray(_state.ifaces[i]['ipv6-prefix-assignment']))
3165 for (var j = 0; j < _state.ifaces[i]['ipv6-prefix-assignment'].length; j++)
3166 if (typeof(_state.ifaces[i]['ipv6-prefix-assignment'][j]) == 'object' &&
3167 typeof(_state.ifaces[i]['ipv6-prefix-assignment'][j]['local-address']) == 'object' &&
3168 _state.ifaces[i]['ipv6-prefix-assignment'][j]['local-address'].address == addr)
3169 return _state.ifaces[i];
3177 * Get IPv4 wan networks.
3179 * This function looks up all networks having a default `0.0.0.0/0` route
3180 * and returns them as array.
3182 * @returns {Promise<Array<LuCI.network.Protocol>>}
3183 * Returns a promise resolving to an array of `Protocol` subclass
3184 * instances describing the found default route interfaces.
3186 getWANNetworks: function() {
3187 return this.getStatusByRoute('0.0.0.0', 0).then(L.bind(function(statuses) {
3188 var rv = [], seen = {};
3190 for (var i = 0; i < statuses.length; i++) {
3191 if (!seen.hasOwnProperty(statuses[i].interface)) {
3192 rv.push(this.instantiateNetwork(statuses[i].interface, statuses[i].proto));
3193 seen[statuses[i].interface] = true;
3202 * Get IPv6 wan networks.
3204 * This function looks up all networks having a default `::/0` route
3205 * and returns them as array.
3207 * @returns {Promise<Array<LuCI.network.Protocol>>}
3208 * Returns a promise resolving to an array of `Protocol` subclass
3209 * instances describing the found IPv6 default route interfaces.
3211 getWAN6Networks: function() {
3212 return this.getStatusByRoute('::', 0).then(L.bind(function(statuses) {
3213 var rv = [], seen = {};
3215 for (var i = 0; i < statuses.length; i++) {
3216 if (!seen.hasOwnProperty(statuses[i].interface)) {
3217 rv.push(this.instantiateNetwork(statuses[i].interface, statuses[i].proto));
3218 seen[statuses[i].interface] = true;
3227 * Describes an swconfig switch topology by specifying the CPU
3228 * connections and external port labels of a switch.
3230 * @typedef {Object<string, Object|Array>} SwitchTopology
3231 * @memberof LuCI.network
3233 * @property {Object<number, string>} netdevs
3234 * The `netdevs` property points to an object describing the CPU port
3235 * connections of the switch. The numeric key of the enclosed object is
3236 * the port number, the value contains the Linux network device name the
3237 * port is hardwired to.
3239 * @property {Array<Object<string, boolean|number|string>>} ports
3240 * The `ports` property points to an array describing the populated
3241 * ports of the switch in the external label order. Each array item is
3242 * an object containg the following keys:
3243 * - `num` - the internal switch port number
3244 * - `label` - the label of the port, e.g. `LAN 1` or `CPU (eth0)`
3245 * - `device` - the connected Linux network device name (CPU ports only)
3246 * - `tagged` - a boolean indicating whether the port must be tagged to
3247 * function (CPU ports only)
3251 * Returns the topologies of all swconfig switches found on the system.
3253 * @returns {Promise<Object<string, LuCI.network.SwitchTopology>>}
3254 * Returns a promise resolving to an object containing the topologies
3255 * of each switch. The object keys correspond to the name of the switches
3256 * such as `switch0`, the values are
3257 * {@link LuCI.network.SwitchTopology SwitchTopology} objects describing
3260 getSwitchTopologies: function() {
3261 return initNetworkState().then(function() {
3262 return _state.switches;
3267 instantiateNetwork: function(name, proto) {
3271 proto = (proto == null ? uci.get('network', name, 'proto') : proto);
3273 var protoClass = _protocols[proto] || Protocol;
3274 return new protoClass(name);
3278 instantiateDevice: function(name, network, extend) {
3280 return new (Device.extend(extend))(name, network);
3282 return new Device(name, network);
3286 instantiateWifiDevice: function(radioname, radiostate) {
3287 return new WifiDevice(radioname, radiostate);
3291 instantiateWifiNetwork: function(sid, radioname, radiostate, netid, netstate, hostapd) {
3292 return new WifiNetwork(sid, radioname, radiostate, netid, netstate, hostapd);
3296 lookupWifiNetwork: function(netname) {
3297 var sid, res, netid, radioname, radiostate, netstate;
3299 sid = getWifiSidByNetid(netname);
3302 res = getWifiStateBySid(sid);
3304 radioname = res ? res[0] : null;
3305 radiostate = res ? res[1] : null;
3306 netstate = res ? res[2] : null;
3309 res = getWifiStateByIfname(netname);
3313 radiostate = res[1];
3315 sid = netstate.section;
3316 netid = L.toArray(getWifiNetidBySid(sid))[0];
3319 res = getWifiStateBySid(netname);
3323 radiostate = res[1];
3326 netid = L.toArray(getWifiNetidBySid(sid))[0];
3329 res = getWifiNetidBySid(netname);
3340 return this.instantiateWifiNetwork(sid || netname, radioname,
3341 radiostate, netid, netstate,
3342 netstate ? _state.hostapd[netstate.ifname] : null);
3346 * Obtains the the network device name of the given object.
3348 * @param {LuCI.network.Protocol|LuCI.network.Device|LuCI.network.WifiDevice|LuCI.network.WifiNetwork|string} obj
3349 * The object to get the device name from.
3351 * @returns {null|string}
3352 * Returns a string containing the device name or `null` if the given
3353 * object could not be converted to a name.
3355 getIfnameOf: function(obj) {
3356 return ifnameOf(obj);
3360 * Queries the internal DSL modem type from board information.
3362 * @returns {Promise<null|string>}
3363 * Returns a promise resolving to the type of the internal modem
3364 * (e.g. `vdsl`) or to `null` if no internal modem is present.
3366 getDSLModemType: function() {
3367 return initNetworkState().then(function() {
3368 return _state.hasDSLModem ? _state.hasDSLModem.type : null;
3373 * Queries aggregated information about known hosts.
3375 * This function aggregates information from various sources such as
3376 * DHCP lease databases, ARP and IPv6 neighbour entries, wireless
3377 * association list etc. and returns a {@link LuCI.network.Hosts Hosts}
3378 * class instance describing the found hosts.
3380 * @returns {Promise<LuCI.network.Hosts>}
3381 * Returns a `Hosts` instance describing host known on the system.
3383 getHostHints: function() {
3384 return initNetworkState().then(function() {
3385 return new Hosts(_state.hosts);
3392 * @memberof LuCI.network
3396 * The `LuCI.network.Hosts` class encapsulates host information aggregated
3397 * from multiple sources and provides convenience functions to access the
3398 * host information by different criteria.
3400 Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
3401 __init__: function(hosts) {
3406 * Lookup the hostname associated with the given MAC address.
3408 * @param {string} mac
3409 * The MAC address to lookup.
3411 * @returns {null|string}
3412 * Returns the hostname associated with the given MAC or `null` if
3413 * no matching host could be found or if no hostname is known for
3414 * the corresponding host.
3416 getHostnameByMACAddr: function(mac) {
3417 return this.hosts[mac] ? this.hosts[mac].name : null;
3421 * Lookup the IPv4 address associated with the given MAC address.
3423 * @param {string} mac
3424 * The MAC address to lookup.
3426 * @returns {null|string}
3427 * Returns the IPv4 address associated with the given MAC or `null` if
3428 * no matching host could be found or if no IPv4 address is known for
3429 * the corresponding host.
3431 getIPAddrByMACAddr: function(mac) {
3432 return this.hosts[mac] ? this.hosts[mac].ipv4 : null;
3436 * Lookup the IPv6 address associated with the given MAC address.
3438 * @param {string} mac
3439 * The MAC address to lookup.
3441 * @returns {null|string}
3442 * Returns the IPv6 address associated with the given MAC or `null` if
3443 * no matching host could be found or if no IPv6 address is known for
3444 * the corresponding host.
3446 getIP6AddrByMACAddr: function(mac) {
3447 return this.hosts[mac] ? this.hosts[mac].ipv6 : null;
3451 * Lookup the hostname associated with the given IPv4 address.
3453 * @param {string} ipaddr
3454 * The IPv4 address to lookup.
3456 * @returns {null|string}
3457 * Returns the hostname associated with the given IPv4 or `null` if
3458 * no matching host could be found or if no hostname is known for
3459 * the corresponding host.
3461 getHostnameByIPAddr: function(ipaddr) {
3462 for (var mac in this.hosts)
3463 if (this.hosts[mac].ipv4 == ipaddr && this.hosts[mac].name != null)
3464 return this.hosts[mac].name;
3469 * Lookup the MAC address associated with the given IPv4 address.
3471 * @param {string} ipaddr
3472 * The IPv4 address to lookup.
3474 * @returns {null|string}
3475 * Returns the MAC address associated with the given IPv4 or `null` if
3476 * no matching host could be found or if no MAC address is known for
3477 * the corresponding host.
3479 getMACAddrByIPAddr: function(ipaddr) {
3480 for (var mac in this.hosts)
3481 if (this.hosts[mac].ipv4 == ipaddr)
3487 * Lookup the hostname associated with the given IPv6 address.
3489 * @param {string} ipaddr
3490 * The IPv6 address to lookup.
3492 * @returns {null|string}
3493 * Returns the hostname associated with the given IPv6 or `null` if
3494 * no matching host could be found or if no hostname is known for
3495 * the corresponding host.
3497 getHostnameByIP6Addr: function(ip6addr) {
3498 for (var mac in this.hosts)
3499 if (this.hosts[mac].ipv6 == ip6addr && this.hosts[mac].name != null)
3500 return this.hosts[mac].name;
3505 * Lookup the MAC address associated with the given IPv6 address.
3507 * @param {string} ipaddr
3508 * The IPv6 address to lookup.
3510 * @returns {null|string}
3511 * Returns the MAC address associated with the given IPv6 or `null` if
3512 * no matching host could be found or if no MAC address is known for
3513 * the corresponding host.
3515 getMACAddrByIP6Addr: function(ip6addr) {
3516 for (var mac in this.hosts)
3517 if (this.hosts[mac].ipv6 == ip6addr)
3523 * Return an array of (MAC address, name hint) tuples sorted by
3526 * @param {boolean} [preferIp6=false]
3527 * Whether to prefer IPv6 addresses (`true`) or IPv4 addresses (`false`)
3528 * as name hint when no hostname is known for a specific MAC address.
3530 * @returns {Array<Array<string>>}
3531 * Returns an array of arrays containing a name hint for each found
3532 * MAC address on the system. The array is sorted ascending by MAC.
3534 * Each item of the resulting array is a two element array with the
3535 * MAC being the first element and the name hint being the second
3536 * element. The name hint is either the hostname, an IPv4 or an IPv6
3537 * address related to the MAC address.
3539 * If no hostname but both IPv4 and IPv6 addresses are known, the
3540 * `preferIP6` flag specifies whether the IPv6 or the IPv4 address
3543 getMACHints: function(preferIp6) {
3545 for (var mac in this.hosts) {
3546 var hint = this.hosts[mac].name ||
3547 this.hosts[mac][preferIp6 ? 'ipv6' : 'ipv4'] ||
3548 this.hosts[mac][preferIp6 ? 'ipv4' : 'ipv6'];
3550 rv.push([mac, hint]);
3552 return rv.sort(function(a, b) { return a[0] > b[0] });
3558 * @memberof LuCI.network
3562 * The `Network.Protocol` class serves as base for protocol specific
3563 * subclasses which describe logical UCI networks defined by `config
3564 * interface` sections in `/etc/config/network`.
3566 Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
3567 __init__: function(name) {
3571 _get: function(opt) {
3572 var val = uci.get('network', this.sid, opt);
3574 if (Array.isArray(val))
3575 return val.join(' ');
3580 _ubus: function(field) {
3581 for (var i = 0; i < _state.ifaces.length; i++) {
3582 if (_state.ifaces[i].interface != this.sid)
3585 return (field != null ? _state.ifaces[i][field] : _state.ifaces[i]);
3590 * Read the given UCI option value of this network.
3592 * @param {string} opt
3593 * The UCI option name to read.
3595 * @returns {null|string|string[]}
3596 * Returns the UCI option value or `null` if the requested option is
3599 get: function(opt) {
3600 return uci.get('network', this.sid, opt);
3604 * Set the given UCI option of this network to the given value.
3606 * @param {string} opt
3607 * The name of the UCI option to set.
3609 * @param {null|string|string[]} val
3610 * The value to set or `null` to remove the given option from the
3613 set: function(opt, val) {
3614 return uci.set('network', this.sid, opt, val);
3618 * Get the associared Linux network device of this network.
3620 * @returns {null|string}
3621 * Returns the name of the associated network device or `null` if
3622 * it could not be determined.
3624 getIfname: function() {
3627 if (this.isFloating())
3628 ifname = this._ubus('l3_device');
3630 ifname = this._ubus('device') || this._ubus('l3_device');
3635 var res = getWifiNetidByNetname(this.sid);
3636 return (res != null ? res[0] : null);
3640 * Get the name of this network protocol class.
3642 * This function will be overwritten by subclasses created by
3643 * {@link LuCI.network#registerProtocol Network.registerProtocol()}.
3647 * Returns the name of the network protocol implementation, e.g.
3648 * `static` or `dhcp`.
3650 getProtocol: function() {
3655 * Return a human readable description for the protcol, such as
3656 * `Static address` or `DHCP client`.
3658 * This function should be overwritten by subclasses.
3662 * Returns the description string.
3664 getI18n: function() {
3665 switch (this.getProtocol()) {
3666 case 'none': return _('Unmanaged');
3667 case 'static': return _('Static address');
3668 case 'dhcp': return _('DHCP client');
3669 default: return _('Unknown');
3674 * Get the type of the underlying interface.
3676 * This function actually is a convenience wrapper around
3677 * `proto.get("type")` and is mainly used by other `LuCI.network` code
3678 * to check whether the interface is declared as bridge in UCI.
3680 * @returns {null|string}
3681 * Returns the value of the `type` option of the associated logical
3682 * interface or `null` if no `type` option is set.
3684 getType: function() {
3685 return this._get('type');
3689 * Get the name of the associated logical interface.
3692 * Returns the logical interface name, such as `lan` or `wan`.
3694 getName: function() {
3699 * Get the uptime of the logical interface.
3702 * Returns the uptime of the associated interface in seconds.
3704 getUptime: function() {
3705 return this._ubus('uptime') || 0;
3709 * Get the logical interface expiry time in seconds.
3711 * For protocols that have a concept of a lease, such as DHCP or
3712 * DHCPv6, this function returns the remaining time in seconds
3713 * until the lease expires.
3716 * Returns the amount of seconds until the lease expires or `-1`
3717 * if it isn't applicable to the associated protocol.
3719 getExpiry: function() {
3720 var u = this._ubus('uptime'),
3721 d = this._ubus('data');
3723 if (typeof(u) == 'number' && d != null &&
3724 typeof(d) == 'object' && typeof(d.leasetime) == 'number') {
3725 var r = d.leasetime - (u % d.leasetime);
3726 return (r > 0 ? r : 0);
3733 * Get the metric value of the logical interface.
3736 * Returns the current metric value used for device and network
3737 * routes spawned by the associated logical interface.
3739 getMetric: function() {
3740 return this._ubus('metric') || 0;
3744 * Get the requested firewall zone name of the logical interface.
3746 * Some protocol implementations request a specific firewall zone
3747 * to trigger inclusion of their resulting network devices into the
3748 * firewall rule set.
3750 * @returns {null|string}
3751 * Returns the requested firewall zone name as published in the
3752 * `ubus` runtime information or `null` if the remote protocol
3753 * handler didn't request a zone.
3755 getZoneName: function() {
3756 var d = this._ubus('data');
3758 if (L.isObject(d) && typeof(d.zone) == 'string')
3765 * Query the first (primary) IPv4 address of the logical interface.
3767 * @returns {null|string}
3768 * Returns the primary IPv4 address registered by the protocol handler
3769 * or `null` if no IPv4 addresses were set.
3771 getIPAddr: function() {
3772 var addrs = this._ubus('ipv4-address');
3773 return ((Array.isArray(addrs) && addrs.length) ? addrs[0].address : null);
3777 * Query all IPv4 addresses of the logical interface.
3779 * @returns {string[]}
3780 * Returns an array of IPv4 addresses in CIDR notation which have been
3781 * registered by the protocol handler. The order of the resulting array
3782 * follows the order of the addresses in `ubus` runtime information.
3784 getIPAddrs: function() {
3785 var addrs = this._ubus('ipv4-address'),
3788 if (Array.isArray(addrs))
3789 for (var i = 0; i < addrs.length; i++)
3790 rv.push('%s/%d'.format(addrs[i].address, addrs[i].mask));
3796 * Query the first (primary) IPv4 netmask of the logical interface.
3798 * @returns {null|string}
3799 * Returns the netmask of the primary IPv4 address registered by the
3800 * protocol handler or `null` if no IPv4 addresses were set.
3802 getNetmask: function() {
3803 var addrs = this._ubus('ipv4-address');
3804 if (Array.isArray(addrs) && addrs.length)
3805 return prefixToMask(addrs[0].mask, false);
3809 * Query the gateway (nexthop) of the default route associated with
3810 * this logical interface.
3813 * Returns a string containing the IPv4 nexthop address of the associated
3814 * default route or `null` if no default route was found.
3816 getGatewayAddr: function() {
3817 var routes = this._ubus('route');
3819 if (Array.isArray(routes))
3820 for (var i = 0; i < routes.length; i++)
3821 if (typeof(routes[i]) == 'object' &&
3822 routes[i].target == '0.0.0.0' &&
3823 routes[i].mask == 0)
3824 return routes[i].nexthop;
3830 * Query the IPv4 DNS servers associated with the logical interface.
3832 * @returns {string[]}
3833 * Returns an array of IPv4 DNS servers registered by the remote
3836 getDNSAddrs: function() {
3837 var addrs = this._ubus('dns-server'),
3840 if (Array.isArray(addrs))
3841 for (var i = 0; i < addrs.length; i++)
3842 if (!/:/.test(addrs[i]))
3849 * Query the first (primary) IPv6 address of the logical interface.
3851 * @returns {null|string}
3852 * Returns the primary IPv6 address registered by the protocol handler
3853 * in CIDR notation or `null` if no IPv6 addresses were set.
3855 getIP6Addr: function() {
3856 var addrs = this._ubus('ipv6-address');
3858 if (Array.isArray(addrs) && L.isObject(addrs[0]))
3859 return '%s/%d'.format(addrs[0].address, addrs[0].mask);
3861 addrs = this._ubus('ipv6-prefix-assignment');
3863 if (Array.isArray(addrs) && L.isObject(addrs[0]) && L.isObject(addrs[0]['local-address']))
3864 return '%s/%d'.format(addrs[0]['local-address'].address, addrs[0]['local-address'].mask);
3870 * Query all IPv6 addresses of the logical interface.
3872 * @returns {string[]}
3873 * Returns an array of IPv6 addresses in CIDR notation which have been
3874 * registered by the protocol handler. The order of the resulting array
3875 * follows the order of the addresses in `ubus` runtime information.
3877 getIP6Addrs: function() {
3878 var addrs = this._ubus('ipv6-address'),
3881 if (Array.isArray(addrs))
3882 for (var i = 0; i < addrs.length; i++)
3883 if (L.isObject(addrs[i]))
3884 rv.push('%s/%d'.format(addrs[i].address, addrs[i].mask));
3886 addrs = this._ubus('ipv6-prefix-assignment');
3888 if (Array.isArray(addrs))
3889 for (var i = 0; i < addrs.length; i++)
3890 if (L.isObject(addrs[i]) && L.isObject(addrs[i]['local-address']))
3891 rv.push('%s/%d'.format(addrs[i]['local-address'].address, addrs[i]['local-address'].mask));
3897 * Query the gateway (nexthop) of the IPv6 default route associated with
3898 * this logical interface.
3901 * Returns a string containing the IPv6 nexthop address of the associated
3902 * default route or `null` if no default route was found.
3904 getGateway6Addr: function() {
3905 var routes = this._ubus('route');
3907 if (Array.isArray(routes))
3908 for (var i = 0; i < routes.length; i++)
3909 if (typeof(routes[i]) == 'object' &&
3910 routes[i].target == '::' &&
3911 routes[i].mask == 0)
3912 return routes[i].nexthop;
3918 * Query the IPv6 DNS servers associated with the logical interface.
3920 * @returns {string[]}
3921 * Returns an array of IPv6 DNS servers registered by the remote
3924 getDNS6Addrs: function() {
3925 var addrs = this._ubus('dns-server'),
3928 if (Array.isArray(addrs))
3929 for (var i = 0; i < addrs.length; i++)
3930 if (/:/.test(addrs[i]))
3937 * Query the routed IPv6 prefix associated with the logical interface.
3939 * @returns {null|string}
3940 * Returns the routed IPv6 prefix registered by the remote protocol
3941 * handler or `null` if no prefix is present.
3943 getIP6Prefix: function() {
3944 var prefixes = this._ubus('ipv6-prefix');
3946 if (Array.isArray(prefixes) && L.isObject(prefixes[0]))
3947 return '%s/%d'.format(prefixes[0].address, prefixes[0].mask);
3953 * Query interface error messages published in `ubus` runtime state.
3955 * Interface errors are emitted by remote protocol handlers if the setup
3956 * of the underlying logical interface failed, e.g. due to bad
3957 * configuration or network connectivity issues.
3959 * This function will translate the found error codes to human readable
3960 * messages using the descriptions registered by
3961 * {@link LuCI.network#registerErrorCode Network.registerErrorCode()}
3962 * and fall back to `"Unknown error (%s)"` where `%s` is replaced by the
3963 * error code in case no translation can be found.
3965 * @returns {string[]}
3966 * Returns an array of translated interface error messages.
3968 getErrors: function() {
3969 var errors = this._ubus('errors'),
3972 if (Array.isArray(errors)) {
3973 for (var i = 0; i < errors.length; i++) {
3974 if (!L.isObject(errors[i]) || typeof(errors[i].code) != 'string')
3978 rv.push(proto_errors[errors[i].code] || _('Unknown error (%s)').format(errors[i].code));
3986 * Checks whether the underlying logical interface is declared as bridge.
3988 * @returns {boolean}
3989 * Returns `true` when the interface is declared with `option type bridge`
3990 * and when the associated protocol implementation is not marked virtual
3991 * or `false` when the logical interface is no bridge.
3993 isBridge: function() {
3994 return (!this.isVirtual() && this.getType() == 'bridge');
3998 * Get the name of the opkg package providing the protocol functionality.
4000 * This function should be overwritten by protocol specific subclasses.
4005 * Returns the name of the opkg package required for the protocol to
4006 * function, e.g. `odhcp6c` for the `dhcpv6` prototocol.
4008 getOpkgPackage: function() {
4013 * Checks whether the protocol functionality is installed.
4015 * This function exists for compatibility with old code, it always
4021 * @returns {boolean}
4022 * Returns `true` if the protocol support is installed, else `false`.
4024 isInstalled: function() {
4029 * Checks whether this protocol is "virtual".
4031 * A "virtual" protocol is a protocol which spawns its own interfaces
4032 * on demand instead of using existing physical interfaces.
4034 * Examples for virtual protocols are `6in4` which `gre` spawn tunnel
4035 * network device on startup, examples for non-virtual protcols are
4036 * `dhcp` or `static` which apply IP configuration to existing interfaces.
4038 * This function should be overwritten by subclasses.
4040 * @returns {boolean}
4041 * Returns a boolean indicating whether the underlying protocol spawns
4042 * dynamic interfaces (`true`) or not (`false`).
4044 isVirtual: function() {
4049 * Checks whether this protocol is "floating".
4051 * A "floating" protocol is a protocol which spawns its own interfaces
4052 * on demand, like a virtual one but which relies on an existinf lower
4053 * level interface to initiate the connection.
4055 * An example for such a protocol is "pppoe".
4057 * This function exists for backwards compatibility with older code
4058 * but should not be used anymore.
4061 * @returns {boolean}
4062 * Returns a boolean indicating whether this protocol is floating (`true`)
4065 isFloating: function() {
4070 * Checks whether this logical interface is dynamic.
4072 * A dynamic interface is an interface which has been created at runtime,
4073 * e.g. as sub-interface of another interface, but which is not backed by
4074 * any user configuration. Such dynamic interfaces cannot be edited but
4075 * only brought down or restarted.
4077 * @returns {boolean}
4078 * Returns a boolean indicating whether this interface is dynamic (`true`)
4081 isDynamic: function() {
4082 return (this._ubus('dynamic') == true);
4086 * Checks whether this interface is an alias interface.
4088 * Alias interfaces are interfaces layering on top of another interface
4089 * and are denoted by a special `@interfacename` notation in the
4090 * underlying `ifname` option.
4092 * @returns {null|string}
4093 * Returns the name of the parent interface if this logical interface
4094 * is an alias or `null` if it is not an alias interface.
4096 isAlias: function() {
4097 var ifnames = L.toArray(uci.get('network', this.sid, 'ifname')),
4100 for (var i = 0; i < ifnames.length; i++)
4101 if (ifnames[i].charAt(0) == '@')
4102 parent = ifnames[i].substr(1);
4103 else if (parent != null)
4110 * Checks whether this logical interface is "empty", meaning that ut
4111 * has no network devices attached.
4113 * @returns {boolean}
4114 * Returns `true` if this logical interface is empty, else `false`.
4116 isEmpty: function() {
4117 if (this.isFloating())
4121 ifname = this._get('ifname');
4123 if (ifname != null && ifname.match(/\S+/))
4126 if (empty == true && getWifiNetidBySid(this.sid) != null)
4133 * Checks whether this logical interface is configured and running.
4135 * @returns {boolean}
4136 * Returns `true` when the interface is active or `false` when it is not.
4139 return (this._ubus('up') == true);
4143 * Add the given network device to the logical interface.
4145 * @param {LuCI.network.Protocol|LuCI.network.Device|LuCI.network.WifiDevice|LuCI.network.WifiNetwork|string} device
4146 * The object or device name to add to the logical interface. In case the
4147 * given argument is not a string, it is resolved though the
4148 * {@link LuCI.network#getIfnameOf Network.getIfnameOf()} function.
4150 * @returns {boolean}
4151 * Returns `true` if the device name has been added or `false` if any
4152 * argument was invalid, if the device was already part of the logical
4153 * interface or if the logical interface is virtual.
4155 addDevice: function(ifname) {
4156 ifname = ifnameOf(ifname);
4158 if (ifname == null || this.isFloating())
4161 var wif = getWifiSidByIfname(ifname);
4164 return appendValue('wireless', wif, 'network', this.sid);
4166 return appendValue('network', this.sid, 'ifname', ifname);
4170 * Remove the given network device from the logical interface.
4172 * @param {LuCI.network.Protocol|LuCI.network.Device|LuCI.network.WifiDevice|LuCI.network.WifiNetwork|string} device
4173 * The object or device name to remove from the logical interface. In case
4174 * the given argument is not a string, it is resolved though the
4175 * {@link LuCI.network#getIfnameOf Network.getIfnameOf()} function.
4177 * @returns {boolean}
4178 * Returns `true` if the device name has been added or `false` if any
4179 * argument was invalid, if the device was already part of the logical
4180 * interface or if the logical interface is virtual.
4182 deleteDevice: function(ifname) {
4185 ifname = ifnameOf(ifname);
4187 if (ifname == null || this.isFloating())
4190 var wif = getWifiSidByIfname(ifname);
4193 rv = removeValue('wireless', wif, 'network', this.sid);
4195 if (removeValue('network', this.sid, 'ifname', ifname))
4202 * Returns the Linux network device associated with this logical
4205 * @returns {LuCI.network.Device}
4206 * Returns a `Network.Device` class instance representing the
4207 * expected Linux network device according to the configuration.
4209 getDevice: function() {
4210 if (this.isVirtual()) {
4211 var ifname = '%s-%s'.format(this.getProtocol(), this.sid);
4212 _state.isTunnel[this.getProtocol() + '-' + this.sid] = true;
4213 return Network.prototype.instantiateDevice(ifname, this);
4215 else if (this.isBridge()) {
4216 var ifname = 'br-%s'.format(this.sid);
4217 _state.isBridge[ifname] = true;
4218 return new Device(ifname, this);
4221 var ifnames = L.toArray(uci.get('network', this.sid, 'ifname'));
4223 for (var i = 0; i < ifnames.length; i++) {
4224 var m = ifnames[i].match(/^([^:/]+)/);
4225 return ((m && m[1]) ? Network.prototype.instantiateDevice(m[1], this) : null);
4228 ifname = getWifiNetidByNetname(this.sid);
4230 return (ifname != null ? Network.prototype.instantiateDevice(ifname[0], this) : null);
4235 * Returns the layer 2 linux network device currently associated
4236 * with this logical interface.
4238 * @returns {LuCI.network.Device}
4239 * Returns a `Network.Device` class instance representing the Linux
4240 * network device currently associated with the logical interface.
4242 getL2Device: function() {
4243 var ifname = this._ubus('device');
4244 return (ifname != null ? Network.prototype.instantiateDevice(ifname, this) : null);
4248 * Returns the layer 3 linux network device currently associated
4249 * with this logical interface.
4251 * @returns {LuCI.network.Device}
4252 * Returns a `Network.Device` class instance representing the Linux
4253 * network device currently associated with the logical interface.
4255 getL3Device: function() {
4256 var ifname = this._ubus('l3_device');
4257 return (ifname != null ? Network.prototype.instantiateDevice(ifname, this) : null);
4261 * Returns a list of network sub-devices associated with this logical
4264 * @returns {null|Array<LuCI.network.Device>}
4265 * Returns an array of of `Network.Device` class instances representing
4266 * the sub-devices attached to this logical interface or `null` if the
4267 * logical interface does not support sub-devices, e.g. because it is
4268 * virtual and not a bridge.
4270 getDevices: function() {
4273 if (!this.isBridge() && !(this.isVirtual() && !this.isFloating()))
4276 var ifnames = L.toArray(uci.get('network', this.sid, 'ifname'));
4278 for (var i = 0; i < ifnames.length; i++) {
4279 if (ifnames[i].charAt(0) == '@')
4282 var m = ifnames[i].match(/^([^:/]+)/);
4284 rv.push(Network.prototype.instantiateDevice(m[1], this));
4287 var uciWifiIfaces = uci.sections('wireless', 'wifi-iface');
4289 for (var i = 0; i < uciWifiIfaces.length; i++) {
4290 if (typeof(uciWifiIfaces[i].device) != 'string')
4293 var networks = L.toArray(uciWifiIfaces[i].network);
4295 for (var j = 0; j < networks.length; j++) {
4296 if (networks[j] != this.sid)
4299 var netid = getWifiNetidBySid(uciWifiIfaces[i]['.name']);
4302 rv.push(Network.prototype.instantiateDevice(netid[0], this));
4306 rv.sort(deviceSort);
4312 * Checks whether this logical interface contains the given device
4315 * @param {LuCI.network.Protocol|LuCI.network.Device|LuCI.network.WifiDevice|LuCI.network.WifiNetwork|string} device
4316 * The object or device name to check. In case the given argument is not
4317 * a string, it is resolved though the
4318 * {@link LuCI.network#getIfnameOf Network.getIfnameOf()} function.
4320 * @returns {boolean}
4321 * Returns `true` when this logical interface contains the given network
4322 * device or `false` if not.
4324 containsDevice: function(ifname) {
4325 ifname = ifnameOf(ifname);
4329 else if (this.isVirtual() && '%s-%s'.format(this.getProtocol(), this.sid) == ifname)
4331 else if (this.isBridge() && 'br-%s'.format(this.sid) == ifname)
4334 var ifnames = L.toArray(uci.get('network', this.sid, 'ifname'));
4336 for (var i = 0; i < ifnames.length; i++) {
4337 var m = ifnames[i].match(/^([^:/]+)/);
4338 if (m != null && m[1] == ifname)
4342 var wif = getWifiSidByIfname(ifname);
4345 var networks = L.toArray(uci.get('wireless', wif, 'network'));
4347 for (var i = 0; i < networks.length; i++)
4348 if (networks[i] == this.sid)
4356 * Cleanup related configuration entries.
4358 * This function will be invoked if an interface is about to be removed
4359 * from the configuration and is responsible for performing any required
4360 * cleanup tasks, such as unsetting uci entries in related configurations.
4362 * It should be overwritten by protocol specific subclasses.
4366 * @returns {*|Promise<*>}
4367 * This function may return a promise which is awaited before the rest of
4368 * the configuration is removed. Any non-promise return value and any
4369 * resolved promise value is ignored. If the returned promise is rejected,
4370 * the interface removal will be aborted.
4372 deleteConfiguration: function() {}
4377 * @memberof LuCI.network
4381 * A `Network.Device` class instance represents an underlying Linux network
4382 * device and allows querying device details such as packet statistics or MTU.
4384 Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
4385 __init__: function(ifname, network) {
4386 var wif = getWifiSidByIfname(ifname);
4389 var res = getWifiStateBySid(wif) || [],
4390 netid = getWifiNetidBySid(wif) || [];
4392 this.wif = new WifiNetwork(wif, res[0], res[1], netid[0], res[2], { ifname: ifname });
4393 this.ifname = this.wif.getIfname();
4396 this.ifname = this.ifname || ifname;
4397 this.dev = _state.netdevs[this.ifname];
4398 this.network = network;
4401 _devstate: function(/* ... */) {
4404 for (var i = 0; i < arguments.length; i++)
4406 rv = rv[arguments[i]];
4414 * Get the name of the network device.
4417 * Returns the name of the device, e.g. `eth0` or `wlan0`.
4419 getName: function() {
4420 return (this.wif != null ? this.wif.getIfname() : this.ifname);
4424 * Get the MAC address of the device.
4426 * @returns {null|string}
4427 * Returns the MAC address of the device or `null` if not applicable,
4428 * e.g. for non-ethernet tunnel devices.
4430 getMAC: function() {
4431 var mac = this._devstate('macaddr');
4432 return mac ? mac.toUpperCase() : null;
4436 * Get the MTU of the device.
4439 * Returns the MTU of the device.
4441 getMTU: function() {
4442 return this._devstate('mtu');
4446 * Get the IPv4 addresses configured on the device.
4448 * @returns {string[]}
4449 * Returns an array of IPv4 address strings.
4451 getIPAddrs: function() {
4452 var addrs = this._devstate('ipaddrs');
4453 return (Array.isArray(addrs) ? addrs : []);
4457 * Get the IPv6 addresses configured on the device.
4459 * @returns {string[]}
4460 * Returns an array of IPv6 address strings.
4462 getIP6Addrs: function() {
4463 var addrs = this._devstate('ip6addrs');
4464 return (Array.isArray(addrs) ? addrs : []);
4468 * Get the type of the device..
4471 * Returns a string describing the type of the network device:
4472 * - `alias` if it is an abstract alias device (`@` notation)
4473 * - `wifi` if it is a wireless interface (e.g. `wlan0`)
4474 * - `bridge` if it is a bridge device (e.g. `br-lan`)
4475 * - `tunnel` if it is a tun or tap device (e.g. `tun0`)
4476 * - `vlan` if it is a vlan device (e.g. `eth0.1`)
4477 * - `switch` if it is a switch device (e.g.`eth1` connected to switch0)
4478 * - `ethernet` for all other device types
4480 getType: function() {
4481 if (this.ifname != null && this.ifname.charAt(0) == '@')
4483 else if (this.wif != null || isWifiIfname(this.ifname))
4485 else if (_state.isBridge[this.ifname])
4487 else if (_state.isTunnel[this.ifname])
4489 else if (this.ifname.indexOf('.') > -1)
4491 else if (_state.isSwitch[this.ifname])
4498 * Get a short description string for the device.
4501 * Returns the device name for non-wifi devices or a string containing
4502 * the operation mode and SSID for wifi devices.
4504 getShortName: function() {
4505 if (this.wif != null)
4506 return this.wif.getShortName();
4512 * Get a long description string for the device.
4515 * Returns a string containing the type description and device name
4516 * for non-wifi devices or operation mode and ssid for wifi ones.
4518 getI18n: function() {
4519 if (this.wif != null) {
4520 return '%s: %s "%s"'.format(
4521 _('Wireless Network'),
4522 this.wif.getActiveMode(),
4523 this.wif.getActiveSSID() || this.wif.getActiveBSSID() || this.wif.getID() || '?');
4526 return '%s: "%s"'.format(this.getTypeI18n(), this.getName());
4530 * Get a string describing the device type.
4533 * Returns a string describing the type, e.g. "Wireless Adapter" or
4536 getTypeI18n: function() {
4537 switch (this.getType()) {
4539 return _('Alias Interface');
4542 return _('Wireless Adapter');
4548 return _('Ethernet Switch');
4551 return (_state.isSwitch[this.ifname] ? _('Switch VLAN') : _('Software VLAN'));
4554 return _('Tunnel Interface');
4557 return _('Ethernet Adapter');
4562 * Get the associated bridge ports of the device.
4564 * @returns {null|Array<LuCI.network.Device>}
4565 * Returns an array of `Network.Device` instances representing the ports
4566 * (slave interfaces) of the bridge or `null` when this device isn't
4569 getPorts: function() {
4570 var br = _state.bridges[this.ifname],
4573 if (br == null || !Array.isArray(br.ifnames))
4576 for (var i = 0; i < br.ifnames.length; i++)
4577 rv.push(Network.prototype.instantiateDevice(br.ifnames[i].name));
4579 rv.sort(deviceSort);
4587 * @returns {null|string}
4588 * Returns the ID of this network bridge or `null` if this network
4589 * device is not a Linux bridge.
4591 getBridgeID: function() {
4592 var br = _state.bridges[this.ifname];
4593 return (br != null ? br.id : null);
4597 * Get the bridge STP setting
4599 * @returns {boolean}
4600 * Returns `true` when this device is a Linux bridge and has `stp`
4601 * enabled, else `false`.
4603 getBridgeSTP: function() {
4604 var br = _state.bridges[this.ifname];
4605 return (br != null ? !!br.stp : false);
4609 * Checks whether this device is up.
4611 * @returns {boolean}
4612 * Returns `true` when the associated device is running pr `false`
4613 * when it is down or absent.
4616 var up = this._devstate('flags', 'up');
4619 up = (this.getType() == 'alias');
4625 * Checks whether this device is a Linux bridge.
4627 * @returns {boolean}
4628 * Returns `true` when the network device is present and a Linux bridge,
4631 isBridge: function() {
4632 return (this.getType() == 'bridge');
4636 * Checks whether this device is part of a Linux bridge.
4638 * @returns {boolean}
4639 * Returns `true` when this network device is part of a bridge,
4642 isBridgePort: function() {
4643 return (this._devstate('bridge') != null);
4647 * Get the amount of transmitted bytes.
4650 * Returns the amount of bytes transmitted by the network device.
4652 getTXBytes: function() {
4653 var stat = this._devstate('stats');
4654 return (stat != null ? stat.tx_bytes || 0 : 0);
4658 * Get the amount of received bytes.
4661 * Returns the amount of bytes received by the network device.
4663 getRXBytes: function() {
4664 var stat = this._devstate('stats');
4665 return (stat != null ? stat.rx_bytes || 0 : 0);
4669 * Get the amount of transmitted packets.
4672 * Returns the amount of packets transmitted by the network device.
4674 getTXPackets: function() {
4675 var stat = this._devstate('stats');
4676 return (stat != null ? stat.tx_packets || 0 : 0);
4680 * Get the amount of received packets.
4683 * Returns the amount of packets received by the network device.
4685 getRXPackets: function() {
4686 var stat = this._devstate('stats');
4687 return (stat != null ? stat.rx_packets || 0 : 0);
4691 * Get the primary logical interface this device is assigned to.
4693 * @returns {null|LuCI.network.Protocol}
4694 * Returns a `Network.Protocol` instance representing the logical
4695 * interface this device is attached to or `null` if it is not
4696 * assigned to any logical interface.
4698 getNetwork: function() {
4699 return this.getNetworks()[0];
4703 * Get the logical interfaces this device is assigned to.
4705 * @returns {Array<LuCI.network.Protocol>}
4706 * Returns an array of `Network.Protocol` instances representing the
4707 * logical interfaces this device is assigned to.
4709 getNetworks: function() {
4710 if (this.networks == null) {
4713 var networks = enumerateNetworks.apply(L.network);
4715 for (var i = 0; i < networks.length; i++)
4716 if (networks[i].containsDevice(this.ifname) || networks[i].getIfname() == this.ifname)
4717 this.networks.push(networks[i]);
4719 this.networks.sort(networkSort);
4722 return this.networks;
4726 * Get the related wireless network this device is related to.
4728 * @returns {null|LuCI.network.WifiNetwork}
4729 * Returns a `Network.WifiNetwork` instance representing the wireless
4730 * network corresponding to this network device or `null` if this device
4731 * is not a wireless device.
4733 getWifiNetwork: function() {
4734 return (this.wif != null ? this.wif : null);
4740 * @memberof LuCI.network
4744 * A `Network.WifiDevice` class instance represents a wireless radio device
4745 * present on the system and provides wireless capability information as
4746 * well as methods for enumerating related wireless networks.
4748 WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
4749 __init__: function(name, radiostate) {
4750 var uciWifiDevice = uci.get('wireless', name);
4752 if (uciWifiDevice != null &&
4753 uciWifiDevice['.type'] == 'wifi-device' &&
4754 uciWifiDevice['.name'] != null) {
4755 this.sid = uciWifiDevice['.name'];
4758 this.sid = this.sid || name;
4766 ubus: function(/* ... */) {
4767 var v = this._ubusdata;
4769 for (var i = 0; i < arguments.length; i++)
4771 v = v[arguments[i]];
4779 * Read the given UCI option value of this wireless device.
4781 * @param {string} opt
4782 * The UCI option name to read.
4784 * @returns {null|string|string[]}
4785 * Returns the UCI option value or `null` if the requested option is
4788 get: function(opt) {
4789 return uci.get('wireless', this.sid, opt);
4793 * Set the given UCI option of this network to the given value.
4795 * @param {string} opt
4796 * The name of the UCI option to set.
4798 * @param {null|string|string[]} val
4799 * The value to set or `null` to remove the given option from the
4802 set: function(opt, value) {
4803 return uci.set('wireless', this.sid, opt, value);
4807 * Checks whether this wireless radio is disabled.
4809 * @returns {boolean}
4810 * Returns `true` when the wireless radio is marked as disabled in `ubus`
4811 * runtime state or when the `disabled` option is set in the corresponding
4812 * UCI configuration.
4814 isDisabled: function() {
4815 return this.ubus('dev', 'disabled') || this.get('disabled') == '1';
4819 * Get the configuration name of this wireless radio.
4822 * Returns the UCI section name (e.g. `radio0`) of the corresponding
4823 * radio configuration which also serves as unique logical identifier
4824 * for the wireless phy.
4826 getName: function() {
4831 * Gets a list of supported hwmodes.
4833 * The hwmode values describe the frequency band and wireless standard
4834 * versions supported by the wireless phy.
4836 * @returns {string[]}
4837 * Returns an array of valid hwmode values for this radio. Currently
4838 * known mode values are:
4839 * - `a` - Legacy 802.11a mode, 5 GHz, up to 54 Mbit/s
4840 * - `b` - Legacy 802.11b mode, 2.4 GHz, up to 11 Mbit/s
4841 * - `g` - Legacy 802.11g mode, 2.4 GHz, up to 54 Mbit/s
4842 * - `n` - IEEE 802.11n mode, 2.4 or 5 GHz, up to 600 Mbit/s
4843 * - `ac` - IEEE 802.11ac mode, 5 GHz, up to 6770 Mbit/s
4845 getHWModes: function() {
4846 var hwmodes = this.ubus('dev', 'iwinfo', 'hwmodes');
4847 return Array.isArray(hwmodes) ? hwmodes : [ 'b', 'g' ];
4851 * Gets a list of supported htmodes.
4853 * The htmode values describe the wide-frequency options supported by
4856 * @returns {string[]}
4857 * Returns an array of valid htmode values for this radio. Currently
4858 * known mode values are:
4859 * - `HT20` - applicable to IEEE 802.11n, 20 MHz wide channels
4860 * - `HT40` - applicable to IEEE 802.11n, 40 MHz wide channels
4861 * - `VHT20` - applicable to IEEE 802.11ac, 20 MHz wide channels
4862 * - `VHT40` - applicable to IEEE 802.11ac, 40 MHz wide channels
4863 * - `VHT80` - applicable to IEEE 802.11ac, 80 MHz wide channels
4864 * - `VHT160` - applicable to IEEE 802.11ac, 160 MHz wide channels
4866 getHTModes: function() {
4867 var htmodes = this.ubus('dev', 'iwinfo', 'htmodes');
4868 return (Array.isArray(htmodes) && htmodes.length) ? htmodes : null;
4872 * Get a string describing the wireless radio hardware.
4875 * Returns the description string.
4877 getI18n: function() {
4878 var hw = this.ubus('dev', 'iwinfo', 'hardware'),
4879 type = L.isObject(hw) ? hw.name : null;
4881 if (this.ubus('dev', 'iwinfo', 'type') == 'wl')
4884 var hwmodes = this.getHWModes(),
4887 hwmodes.sort(function(a, b) {
4888 return (a.length != b.length ? a.length > b.length : a > b);
4891 modestr = hwmodes.join('');
4893 return '%s 802.11%s Wireless Controller (%s)'.format(type || 'Generic', modestr, this.getName());
4897 * A wireless scan result object describes a neighbouring wireless
4898 * network found in the vincinity.
4900 * @typedef {Object<string, number|string|LuCI.network.WifiEncryption>} WifiScanResult
4901 * @memberof LuCI.network
4903 * @property {string} ssid
4904 * The SSID / Mesh ID of the network.
4906 * @property {string} bssid
4907 * The BSSID if the network.
4909 * @property {string} mode
4910 * The operation mode of the network (`Master`, `Ad-Hoc`, `Mesh Point`).
4912 * @property {number} channel
4913 * The wireless channel of the network.
4915 * @property {number} signal
4916 * The received signal strength of the network in dBm.
4918 * @property {number} quality
4919 * The numeric quality level of the signal, can be used in conjunction
4920 * with `quality_max` to calculate a quality percentage.
4922 * @property {number} quality_max
4923 * The maximum possible quality level of the signal, can be used in
4924 * conjunction with `quality` to calculate a quality percentage.
4926 * @property {LuCI.network.WifiEncryption} encryption
4927 * The encryption used by the wireless network.
4931 * Trigger a wireless scan on this radio device and obtain a list of
4934 * @returns {Promise<Array<LuCI.network.WifiScanResult>>}
4935 * Returns a promise resolving to an array of scan result objects
4936 * describing the networks found in the vincinity.
4938 getScanList: function() {
4939 return callIwinfoScan(this.sid);
4943 * Check whether the wireless radio is marked as up in the `ubus`
4946 * @returns {boolean}
4947 * Returns `true` when the radio device is up, else `false`.
4950 if (L.isObject(_state.radios[this.sid]))
4951 return (_state.radios[this.sid].up == true);
4957 * Get the wifi network of the given name belonging to this radio device
4959 * @param {string} network
4960 * The name of the wireless network to lookup. This may be either an uci
4961 * configuration section ID, a network ID in the form `radio#.network#`
4962 * or a Linux network device name like `wlan0` which is resolved to the
4963 * corresponding configuration section through `ubus` runtime information.
4965 * @returns {Promise<LuCI.network.WifiNetwork>}
4966 * Returns a promise resolving to a `Network.WifiNetwork` instance
4967 * representing the wireless network and rejecting with `null` if
4968 * the given network could not be found or is not associated with
4969 * this radio device.
4971 getWifiNetwork: function(network) {
4972 return Network.prototype.getWifiNetwork(network).then(L.bind(function(networkInstance) {
4973 var uciWifiIface = (networkInstance.sid ? uci.get('wireless', networkInstance.sid) : null);
4975 if (uciWifiIface == null || uciWifiIface['.type'] != 'wifi-iface' || uciWifiIface.device != this.sid)
4976 return Promise.reject();
4978 return networkInstance;
4983 * Get all wireless networks associated with this wireless radio device.
4985 * @returns {Promise<Array<LuCI.network.WifiNetwork>>}
4986 * Returns a promise resolving to an array of `Network.WifiNetwork`
4987 * instances respresenting the wireless networks associated with this
4990 getWifiNetworks: function() {
4991 return Network.prototype.getWifiNetworks().then(L.bind(function(networks) {
4994 for (var i = 0; i < networks.length; i++)
4995 if (networks[i].getWifiDeviceName() == this.getName())
4996 rv.push(networks[i]);
5003 * Adds a new wireless network associated with this radio device to the
5004 * configuration and sets its options to the provided values.
5006 * @param {Object<string, string|string[]>} [options]
5007 * The options to set for the newly added wireless network.
5009 * @returns {Promise<null|LuCI.network.WifiNetwork>}
5010 * Returns a promise resolving to a `WifiNetwork` instance describing
5011 * the newly added wireless network or `null` if the given options
5014 addWifiNetwork: function(options) {
5015 if (!L.isObject(options))
5018 options.device = this.sid;
5020 return Network.prototype.addWifiNetwork(options);
5024 * Deletes the wireless network with the given name associated with this
5027 * @param {string} network
5028 * The name of the wireless network to lookup. This may be either an uci
5029 * configuration section ID, a network ID in the form `radio#.network#`
5030 * or a Linux network device name like `wlan0` which is resolved to the
5031 * corresponding configuration section through `ubus` runtime information.
5033 * @returns {Promise<boolean>}
5034 * Returns a promise resolving to `true` when the wireless network was
5035 * successfully deleted from the configuration or `false` when the given
5036 * network could not be found or if the found network was not associated
5037 * with this wireless radio device.
5039 deleteWifiNetwork: function(network) {
5042 if (network instanceof WifiNetwork) {
5046 var uciWifiIface = uci.get('wireless', network);
5048 if (uciWifiIface == null || uciWifiIface['.type'] != 'wifi-iface')
5049 sid = getWifiSidByIfname(network);
5052 if (sid == null || uci.get('wireless', sid, 'device') != this.sid)
5053 return Promise.resolve(false);
5055 uci.delete('wireless', network);
5057 return Promise.resolve(true);
5063 * @memberof LuCI.network
5067 * A `Network.WifiNetwork` instance represents a wireless network (vif)
5068 * configured on top of a radio device and provides functions for querying
5069 * the runtime state of the network. Most radio devices support multiple
5070 * such networks in parallel.
5072 WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */ {
5073 __init__: function(sid, radioname, radiostate, netid, netstate, hostapd) {
5084 ubus: function(/* ... */) {
5085 var v = this._ubusdata;
5087 for (var i = 0; i < arguments.length; i++)
5089 v = v[arguments[i]];
5097 * Read the given UCI option value of this wireless network.
5099 * @param {string} opt
5100 * The UCI option name to read.
5102 * @returns {null|string|string[]}
5103 * Returns the UCI option value or `null` if the requested option is
5106 get: function(opt) {
5107 return uci.get('wireless', this.sid, opt);
5111 * Set the given UCI option of this network to the given value.
5113 * @param {string} opt
5114 * The name of the UCI option to set.
5116 * @param {null|string|string[]} val
5117 * The value to set or `null` to remove the given option from the
5120 set: function(opt, value) {
5121 return uci.set('wireless', this.sid, opt, value);
5125 * Checks whether this wireless network is disabled.
5127 * @returns {boolean}
5128 * Returns `true` when the wireless radio is marked as disabled in `ubus`
5129 * runtime state or when the `disabled` option is set in the corresponding
5130 * UCI configuration.
5132 isDisabled: function() {
5133 return this.ubus('dev', 'disabled') || this.get('disabled') == '1';
5137 * Get the configured operation mode of the wireless network.
5140 * Returns the configured operation mode. Possible values are:
5141 * - `ap` - Master (Access Point) mode
5142 * - `sta` - Station (client) mode
5143 * - `adhoc` - Ad-Hoc (IBSS) mode
5144 * - `mesh` - Mesh (IEEE 802.11s) mode
5145 * - `monitor` - Monitor mode
5147 getMode: function() {
5148 return this.ubus('net', 'config', 'mode') || this.get('mode') || 'ap';
5152 * Get the configured SSID of the wireless network.
5154 * @returns {null|string}
5155 * Returns the configured SSID value or `null` when this network is
5158 getSSID: function() {
5159 if (this.getMode() == 'mesh')
5162 return this.ubus('net', 'config', 'ssid') || this.get('ssid');
5166 * Get the configured Mesh ID of the wireless network.
5168 * @returns {null|string}
5169 * Returns the configured mesh ID value or `null` when this network
5170 * is not in mesh mode.
5172 getMeshID: function() {
5173 if (this.getMode() != 'mesh')
5176 return this.ubus('net', 'config', 'mesh_id') || this.get('mesh_id');
5180 * Get the configured BSSID of the wireless network.
5182 * @returns {null|string}
5183 * Returns the BSSID value or `null` if none has been specified.
5185 getBSSID: function() {
5186 return this.ubus('net', 'config', 'bssid') || this.get('bssid');
5190 * Get the names of the logical interfaces this wireless network is
5193 * @returns {string[]}
5194 * Returns an array of logical interface names.
5196 getNetworkNames: function() {
5197 return L.toArray(this.ubus('net', 'config', 'network') || this.get('network'));
5201 * Get the internal network ID of this wireless network.
5203 * The network ID is a LuCI specific identifer in the form
5204 * `radio#.network#` to identify wireless networks by their corresponding
5205 * radio and network index numbers.
5208 * Returns the LuCI specific network ID.
5215 * Get the configuration ID of this wireless network.
5218 * Returns the corresponding UCI section ID of the network.
5220 getName: function() {
5225 * Get the Linux network device name.
5227 * @returns {null|string}
5228 * Returns the current Linux network device name as resolved from
5229 * `ubus` runtime information or `null` if this network has no
5230 * associated network device, e.g. when not configured or up.
5232 getIfname: function() {
5233 var ifname = this.ubus('net', 'ifname') || this.ubus('net', 'iwinfo', 'ifname');
5235 if (ifname == null || ifname.match(/^(wifi|radio)\d/))
5236 ifname = this.netid;
5242 * Get the name of the corresponding wifi radio device.
5244 * @returns {null|string}
5245 * Returns the name of the radio device this network is configured on
5246 * or `null` if it cannot be determined.
5248 getWifiDeviceName: function() {
5249 return this.ubus('radio') || this.get('device');
5253 * Get the corresponding wifi radio device.
5255 * @returns {null|LuCI.network.WifiDevice}
5256 * Returns a `Network.WifiDevice` instance representing the corresponding
5257 * wifi radio device or `null` if the related radio device could not be
5260 getWifiDevice: function() {
5261 var radioname = this.getWifiDeviceName();
5263 if (radioname == null)
5264 return Promise.reject();
5266 return Network.prototype.getWifiDevice(radioname);
5270 * Check whether the radio network is up.
5272 * This function actually queries the up state of the related radio
5273 * device and assumes this network to be up as well when the parent
5274 * radio is up. This is due to the fact that OpenWrt does not control
5275 * virtual interfaces individually but within one common hostapd
5278 * @returns {boolean}
5279 * Returns `true` when the network is up, else `false`.
5282 var device = this.getDevice();
5287 return device.isUp();
5291 * Query the current operation mode from runtime information.
5294 * Returns the human readable mode name as reported by `ubus` runtime
5295 * state. Possible returned values are:
5307 getActiveMode: function() {
5308 var mode = this.ubus('net', 'iwinfo', 'mode') || this.ubus('net', 'config', 'mode') || this.get('mode') || 'ap';
5311 case 'ap': return 'Master';
5312 case 'sta': return 'Client';
5313 case 'adhoc': return 'Ad-Hoc';
5314 case 'mesh': return 'Mesh';
5315 case 'monitor': return 'Monitor';
5316 default: return mode;
5321 * Query the current operation mode from runtime information as
5322 * translated string.
5325 * Returns the translated, human readable mode name as reported by
5326 *`ubus` runtime state.
5328 getActiveModeI18n: function() {
5329 var mode = this.getActiveMode();
5332 case 'Master': return _('Master');
5333 case 'Client': return _('Client');
5334 case 'Ad-Hoc': return _('Ad-Hoc');
5335 case 'Mash': return _('Mesh');
5336 case 'Monitor': return _('Monitor');
5337 default: return mode;
5342 * Query the current SSID from runtime information.
5345 * Returns the current SSID or Mesh ID as reported by `ubus` runtime
5348 getActiveSSID: function() {
5349 return this.ubus('net', 'iwinfo', 'ssid') || this.ubus('net', 'config', 'ssid') || this.get('ssid');
5353 * Query the current BSSID from runtime information.
5356 * Returns the current BSSID or Mesh ID as reported by `ubus` runtime
5359 getActiveBSSID: function() {
5360 return this.ubus('net', 'iwinfo', 'bssid') || this.ubus('net', 'config', 'bssid') || this.get('bssid');
5364 * Query the current encryption settings from runtime information.
5367 * Returns a string describing the current encryption or `-` if the the
5368 * encryption state could not be found in `ubus` runtime information.
5370 getActiveEncryption: function() {
5371 return formatWifiEncryption(this.ubus('net', 'iwinfo', 'encryption')) || '-';
5375 * A wireless peer entry describes the properties of a remote wireless
5376 * peer associated with a local network.
5378 * @typedef {Object<string, boolean|number|string|LuCI.network.WifiRateEntry>} WifiPeerEntry
5379 * @memberof LuCI.network
5381 * @property {string} mac
5382 * The MAC address (BSSID).
5384 * @property {number} signal
5385 * The received signal strength.
5387 * @property {number} [signal_avg]
5388 * The average signal strength if supported by the driver.
5390 * @property {number} [noise]
5391 * The current noise floor of the radio. May be `0` or absent if not
5392 * supported by the driver.
5394 * @property {number} inactive
5395 * The amount of milliseconds the peer has been inactive, e.g. due
5398 * @property {number} connected_time
5399 * The amount of milliseconds the peer is associated to this network.
5401 * @property {number} [thr]
5402 * The estimated throughput of the peer, May be `0` or absent if not
5403 * supported by the driver.
5405 * @property {boolean} authorized
5406 * Specifies whether the peer is authorized to associate to this network.
5408 * @property {boolean} authenticated
5409 * Specifies whether the peer completed authentication to this network.
5411 * @property {string} preamble
5412 * The preamble mode used by the peer. May be `long` or `short`.
5414 * @property {boolean} wme
5415 * Specifies whether the peer supports WME/WMM capabilities.
5417 * @property {boolean} mfp
5418 * Specifies whether management frame protection is active.
5420 * @property {boolean} tdls
5421 * Specifies whether TDLS is active.
5423 * @property {number} [mesh llid]
5424 * The mesh LLID, may be `0` or absent if not applicable or supported
5427 * @property {number} [mesh plid]
5428 * The mesh PLID, may be `0` or absent if not applicable or supported
5431 * @property {string} [mesh plink]
5432 * The mesh peer link state description, may be an empty string (`''`)
5433 * or absent if not applicable or supported by the driver.
5435 * The following states are known:
5445 * @property {number} [mesh local PS]
5446 * The local powersafe mode for the peer link, may be an empty
5447 * string (`''`) or absent if not applicable or supported by
5450 * The following modes are known:
5451 * - `ACTIVE` (no power save)
5456 * @property {number} [mesh peer PS]
5457 * The remote powersafe mode for the peer link, may be an empty
5458 * string (`''`) or absent if not applicable or supported by
5461 * The following modes are known:
5462 * - `ACTIVE` (no power save)
5467 * @property {number} [mesh non-peer PS]
5468 * The powersafe mode for all non-peer neigbours, may be an empty
5469 * string (`''`) or absent if not applicable or supported by the driver.
5471 * The following modes are known:
5472 * - `ACTIVE` (no power save)
5477 * @property {LuCI.network.WifiRateEntry} rx
5478 * Describes the receiving wireless rate from the peer.
5480 * @property {LuCI.network.WifiRateEntry} tx
5481 * Describes the transmitting wireless rate to the peer.
5485 * A wireless rate entry describes the properties of a wireless
5486 * transmission rate to or from a peer.
5488 * @typedef {Object<string, boolean|number>} WifiRateEntry
5489 * @memberof LuCI.network
5491 * @property {number} [drop_misc]
5492 * The amount of received misc. packages that have been dropped, e.g.
5493 * due to corruption or missing authentication. Only applicable to
5496 * @property {number} packets
5497 * The amount of packets that have been received or sent.
5499 * @property {number} bytes
5500 * The amount of bytes that have been received or sent.
5502 * @property {number} [failed]
5503 * The amount of failed tranmission attempts. Only applicable to
5506 * @property {number} [retries]
5507 * The amount of retried transmissions. Only applicable to transmit
5510 * @property {boolean} is_ht
5511 * Specifies whether this rate is an HT (IEEE 802.11n) rate.
5513 * @property {boolean} is_vht
5514 * Specifies whether this rate is an VHT (IEEE 802.11ac) rate.
5516 * @property {number} mhz
5517 * The channel width in MHz used for the transmission.
5519 * @property {number} rate
5520 * The bitrate in bit/s of the transmission.
5522 * @property {number} [mcs]
5523 * The MCS index of the used transmission rate. Only applicable to
5526 * @property {number} [40mhz]
5527 * Specifies whether the tranmission rate used 40MHz wide channel.
5528 * Only applicable to HT or VHT rates.
5530 * Note: this option exists for backwards compatibility only and its
5531 * use is discouraged. The `mhz` field should be used instead to
5532 * determine the channel width.
5534 * @property {boolean} [short_gi]
5535 * Specifies whether a short guard interval is used for the transmission.
5536 * Only applicable to HT or VHT rates.
5538 * @property {number} [nss]
5539 * Specifies the number of spatial streams used by the transmission.
5540 * Only applicable to VHT rates.
5544 * Fetch the list of associated peers.
5546 * @returns {Promise<Array<LuCI.network.WifiPeerEntry>>}
5547 * Returns a promise resolving to an array of wireless peers associated
5548 * with this network.
5550 getAssocList: function() {
5551 return callIwinfoAssoclist(this.getIfname());
5555 * Query the current operating frequency of the wireless network.
5557 * @returns {null|string}
5558 * Returns the current operating frequency of the network from `ubus`
5559 * runtime information in GHz or `null` if the information is not
5562 getFrequency: function() {
5563 var freq = this.ubus('net', 'iwinfo', 'frequency');
5565 if (freq != null && freq > 0)
5566 return '%.03f'.format(freq / 1000);
5572 * Query the current average bitrate of all peers associated to this
5575 * @returns {null|number}
5576 * Returns the average bit rate among all peers associated to the network
5577 * as reported by `ubus` runtime information or `null` if the information
5580 getBitRate: function() {
5581 var rate = this.ubus('net', 'iwinfo', 'bitrate');
5583 if (rate != null && rate > 0)
5584 return (rate / 1000);
5590 * Query the current wireless channel.
5592 * @returns {null|number}
5593 * Returns the wireless channel as reported by `ubus` runtime information
5594 * or `null` if it cannot be determined.
5596 getChannel: function() {
5597 return this.ubus('net', 'iwinfo', 'channel') || this.ubus('dev', 'config', 'channel') || this.get('channel');
5601 * Query the current wireless signal.
5603 * @returns {null|number}
5604 * Returns the wireless signal in dBm as reported by `ubus` runtime
5605 * information or `null` if it cannot be determined.
5607 getSignal: function() {
5608 return this.ubus('net', 'iwinfo', 'signal') || 0;
5612 * Query the current radio noise floor.
5615 * Returns the radio noise floor in dBm as reported by `ubus` runtime
5616 * information or `0` if it cannot be determined.
5618 getNoise: function() {
5619 return this.ubus('net', 'iwinfo', 'noise') || 0;
5623 * Query the current country code.
5626 * Returns the wireless country code as reported by `ubus` runtime
5627 * information or `00` if it cannot be determined.
5629 getCountryCode: function() {
5630 return this.ubus('net', 'iwinfo', 'country') || this.ubus('dev', 'config', 'country') || '00';
5634 * Query the current radio TX power.
5636 * @returns {null|number}
5637 * Returns the wireless network transmit power in dBm as reported by
5638 * `ubus` runtime information or `null` if it cannot be determined.
5640 getTXPower: function() {
5641 return this.ubus('net', 'iwinfo', 'txpower');
5645 * Query the radio TX power offset.
5647 * Some wireless radios have a fixed power offset, e.g. due to the
5648 * use of external amplifiers.
5651 * Returns the wireless network transmit power offset in dBm as reported
5652 * by `ubus` runtime information or `0` if there is no offset, or if it
5653 * cannot be determined.
5655 getTXPowerOffset: function() {
5656 return this.ubus('net', 'iwinfo', 'txpower_offset') || 0;
5660 * Calculate the current signal.
5664 * Returns the calculated signal level, which is the difference between
5665 * noise and signal (SNR), divided by 5.
5667 getSignalLevel: function(signal, noise) {
5668 if (this.getActiveBSSID() == '00:00:00:00:00:00')
5671 signal = signal || this.getSignal();
5672 noise = noise || this.getNoise();
5674 if (signal < 0 && noise < 0) {
5675 var snr = -1 * (noise - signal);
5676 return Math.floor(snr / 5);
5683 * Calculate the current signal quality percentage.
5686 * Returns the calculated signal quality in percent. The value is
5687 * calculated from the `quality` and `quality_max` indicators reported
5688 * by `ubus` runtime state.
5690 getSignalPercent: function() {
5691 var qc = this.ubus('net', 'iwinfo', 'quality') || 0,
5692 qm = this.ubus('net', 'iwinfo', 'quality_max') || 0;
5694 if (qc > 0 && qm > 0)
5695 return Math.floor((100 / qm) * qc);
5701 * Get a short description string for this wireless network.
5704 * Returns a string describing this network, consisting of the
5705 * active operation mode, followed by either the SSID, BSSID or
5706 * internal network ID, depending on which information is available.
5708 getShortName: function() {
5709 return '%s "%s"'.format(
5710 this.getActiveModeI18n(),
5711 this.getActiveSSID() || this.getActiveBSSID() || this.getID());
5715 * Get a description string for this wireless network.
5718 * Returns a string describing this network, consisting of the
5719 * term `Wireless Network`, followed by the active operation mode,
5720 * the SSID, BSSID or internal network ID and the Linux network device
5721 * name, depending on which information is available.
5723 getI18n: function() {
5724 return '%s: %s "%s" (%s)'.format(
5725 _('Wireless Network'),
5726 this.getActiveModeI18n(),
5727 this.getActiveSSID() || this.getActiveBSSID() || this.getID(),
5732 * Get the primary logical interface this wireless network is attached to.
5734 * @returns {null|LuCI.network.Protocol}
5735 * Returns a `Network.Protocol` instance representing the logical
5736 * interface or `null` if this network is not attached to any logical
5739 getNetwork: function() {
5740 return this.getNetworks()[0];
5744 * Get the logical interfaces this wireless network is attached to.
5746 * @returns {Array<LuCI.network.Protocol>}
5747 * Returns an array of `Network.Protocol` instances representing the
5748 * logical interfaces this wireless network is attached to.
5750 getNetworks: function() {
5751 var networkNames = this.getNetworkNames(),
5754 for (var i = 0; i < networkNames.length; i++) {
5755 var uciInterface = uci.get('network', networkNames[i]);
5757 if (uciInterface == null || uciInterface['.type'] != 'interface')
5760 networks.push(Network.prototype.instantiateNetwork(networkNames[i]));
5763 networks.sort(networkSort);
5769 * Get the associated Linux network device.
5771 * @returns {LuCI.network.Device}
5772 * Returns a `Network.Device` instance representing the Linux network
5773 * device associted with this wireless network.
5775 getDevice: function() {
5776 return Network.prototype.instantiateDevice(this.getIfname());
5780 * Check whether this wifi network supports deauthenticating clients.
5782 * @returns {boolean}
5783 * Returns `true` when this wifi network instance supports forcibly
5784 * deauthenticating clients, otherwise `false`.
5786 isClientDisconnectSupported: function() {
5787 return L.isObject(this.ubus('hostapd', 'del_client'));
5791 * Forcibly disconnect the given client from the wireless network.
5793 * @param {string} mac
5794 * The MAC address of the client to disconnect.
5796 * @param {boolean} [deauth=false]
5797 * Specifies whether to deauthenticate (`true`) or disassociate (`false`)
5800 * @param {number} [reason=1]
5801 * Specifies the IEEE 802.11 reason code to disassoc/deauth the client
5802 * with. Default is `1` which corresponds to `Unspecified reason`.
5804 * @param {number} [ban_time=0]
5805 * Specifies the amount of milliseconds to ban the client from
5806 * reconnecting. By default, no ban time is set which allows the client
5807 * to reassociate / reauthenticate immediately.
5809 * @returns {Promise<number>}
5810 * Returns a promise resolving to the underlying ubus call result code
5811 * which is typically `0`, even for not existing MAC addresses.
5812 * The promise might reject with an error in case invalid arguments
5815 disconnectClient: function(mac, deauth, reason, ban_time) {
5816 if (reason == null || reason == 0)
5822 return rpc.declare({
5823 object: 'hostapd.%s'.format(this.getIfname()),
5824 method: 'del_client',
5825 params: [ 'addr', 'deauth', 'reason', 'ban_time' ]
5826 })(mac, deauth, reason, ban_time);
5843 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Fri Apr 03 2020 13:28:08 GMT+0200 (Central European Summer Time)
5847 <script>prettyPrint();</script>
5848 <script src="scripts/jaguar.js"></script>