Fix module lines in several luadoc files
[project/luci.git] / doc / modules / luci.ip.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html>
4 <head>
5     <title>Reference</title>
6     <link rel="stylesheet" href="../luadoc.css" type="text/css" />
7         <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
8 </head>
9
10 <body>
11 <div id="container">
12
13 <div id="product">
14         <div id="product_logo"></div>
15         <div id="product_name"><big><b></b></big></div>
16         <div id="product_description"></div>
17 </div> <!-- id="product" -->
18
19 <div id="main">
20
21 <div id="navigation">
22
23
24 <h1>LuaDoc</h1>
25 <ul>
26         
27         <li><a href="../index.html">Index</a></li>
28         
29 </ul>
30
31
32 <!-- Module list -->
33
34 <h1>Modules</h1>
35 <ul>
36
37         <li>
38                 <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
39         </li>
40
41         <li>
42                 <a href="../modules/luci.http.protocol.html">luci.http.protocol</a>
43         </li>
44
45         <li>
46                 <a href="../modules/luci.http.protocol.conditionals.html">luci.http.protocol.conditionals</a>
47         </li>
48
49         <li>
50                 <a href="../modules/luci.http.protocol.date.html">luci.http.protocol.date</a>
51         </li>
52
53         <li>
54                 <a href="../modules/luci.http.protocol.mime.html">luci.http.protocol.mime</a>
55         </li>
56
57         <li>
58                 <a href="../modules/luci.i18n.html">luci.i18n</a>
59         </li>
60
61         <li><strong>luci.ip</strong></li>
62         
63         <li>
64                 <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
65         </li>
66
67         <li>
68                 <a href="../modules/luci.jsonc.html">luci.jsonc</a>
69         </li>
70
71         <li>
72                 <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
73         </li>
74
75         <li>
76                 <a href="../modules/luci.sys.init.html">luci.sys.init</a>
77         </li>
78
79         <li>
80                 <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
81         </li>
82
83         <li>
84                 <a href="../modules/luci.sys.net.html">luci.sys.net</a>
85         </li>
86
87         <li>
88                 <a href="../modules/luci.sys.process.html">luci.sys.process</a>
89         </li>
90
91         <li>
92                 <a href="../modules/luci.sys.user.html">luci.sys.user</a>
93         </li>
94
95         <li>
96                 <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
97         </li>
98
99         <li>
100                 <a href="../modules/nixio.html">nixio</a>
101         </li>
102
103         <li>
104                 <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
105         </li>
106
107         <li>
108                 <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
109         </li>
110
111         <li>
112                 <a href="../modules/nixio.File.html">nixio.File</a>
113         </li>
114
115         <li>
116                 <a href="../modules/nixio.README.html">nixio.README</a>
117         </li>
118
119         <li>
120                 <a href="../modules/nixio.Socket.html">nixio.Socket</a>
121         </li>
122
123         <li>
124                 <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
125         </li>
126
127         <li>
128                 <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
129         </li>
130
131         <li>
132                 <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
133         </li>
134
135         <li>
136                 <a href="../modules/nixio.bin.html">nixio.bin</a>
137         </li>
138
139         <li>
140                 <a href="../modules/nixio.bit.html">nixio.bit</a>
141         </li>
142
143         <li>
144                 <a href="../modules/nixio.crypto.html">nixio.crypto</a>
145         </li>
146
147         <li>
148                 <a href="../modules/nixio.fs.html">nixio.fs</a>
149         </li>
150
151 </ul>
152
153
154
155 <!-- File list -->
156
157
158
159
160
161
162
163 </div><!-- id="navigation" -->
164
165 <div id="content">
166
167 <h1>Class <code>luci.ip</code></h1>
168
169 <p>
170  LuCI IP calculation and netlink access library.</p>
171
172
173
174
175
176
177
178 <h2>Functions</h2>
179 <table class="function_list">
180
181         <tr>
182         <td class="name" nowrap><a href="#new">new</a>&nbsp;(address, netmask)</td>
183         <td class="summary">
184  
185 Construct a new luci.ip.cidr instance and autodetect the address family.</td>
186         </tr>
187
188         <tr>
189         <td class="name" nowrap><a href="#IPv4">IPv4</a>&nbsp;(address, netmask)</td>
190         <td class="summary">
191  
192 Construct a new IPv4 luci.ip.cidr instance.</td>
193         </tr>
194
195         <tr>
196         <td class="name" nowrap><a href="#IPv6">IPv6</a>&nbsp;(address, netmask)</td>
197         <td class="summary">
198  
199 Construct a new IPv6 luci.ip.cidr instance.</td>
200         </tr>
201
202         <tr>
203         <td class="name" nowrap><a href="#route">route</a>&nbsp;(address)</td>
204         <td class="summary">
205  
206 Determine the route leading to the given destination.</td>
207         </tr>
208
209         <tr>
210         <td class="name" nowrap><a href="#routes">routes</a>&nbsp;(filter, callback)</td>
211         <td class="summary">
212  
213 Fetch all routes, optionally matching the given criteria.</td>
214         </tr>
215
216         <tr>
217         <td class="name" nowrap><a href="#neighbors">neighbors</a>&nbsp;(filter, callback)</td>
218         <td class="summary">
219  
220 Fetches entries from the IPv4 ARP and IPv6 neighbour kernel table </td>
221         </tr>
222
223         <tr>
224         <td class="name" nowrap><a href="#link">link</a>&nbsp;(device)</td>
225         <td class="summary">
226  
227 Fetch basic device information </td>
228         </tr>
229
230 </table>
231
232
233
234
235
236
237 <br/>
238 <br/>
239
240
241 <h2><a name="functions"></a>Functions</h2>
242 <dl class="function">
243
244
245
246 <dt><a name="new"></a><strong>new</strong>&nbsp;(address, netmask)</dt>
247 <dd>
248
249  
250 Construct a new luci.ip.cidr instance and autodetect the address family. 
251 Throws an error if the given strings do not represent a valid address or 
252 if the given optional netmask is of a different family.
253
254
255 <h3>Parameters</h3>
256 <ul>
257         
258         <li>
259           address: String containing a valid IPv4 or IPv6 address, optionally 
260 with prefix size (CIDR notation) or netmask separated by slash.
261         </li>
262         
263         <li>
264           netmask: String containing a valid IPv4 or IPv6 netmask or number 
265 containing a prefix size in bits (<code>0..32</code> for IPv4, 
266 <code>0..128</code> for IPv6). Overrides mask embedded in the first argument 
267 if specified. (optional)
268         </li>
269         
270 </ul>
271
272
273
274
275 <h3>Usage:</h3>
276 <pre>addr = luci.ip.new("10.24.0.1/24") 
277 addr = luci.ip.new("10.24.0.1/255.255.255.0") 
278 addr = luci.ip.new("10.24.0.1", "255.255.255.0")        -- separate netmask 
279 addr = luci.ip.new("10.24.0.1/24", 16)                  -- override netmask 
280  
281 addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/64") 
282 addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/ffff:ffff:ffff:ffff::") 
283 addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17", "ffff:ffff:ffff:ffff::") 
284 addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/64", 128) -- override netmask</pre>
285
286
287
288 <h3>Return value:</h3>
289 A <code>luci.ip.cidr</code> object representing the given 
290 address/mask range.
291
292
293
294 <h3>See also:</h3>
295 <ul>
296         
297         <li><a href="#IPv4">
298                 IPv4
299         </a>
300         
301         <li><a href="#IPv6">
302                 IPv6
303         </a>
304         
305 </ul>
306
307 </dd>
308
309
310
311
312 <dt><a name="IPv4"></a><strong>IPv4</strong>&nbsp;(address, netmask)</dt>
313 <dd>
314
315  
316 Construct a new IPv4 luci.ip.cidr instance. 
317 Throws an error if the given string does not represent a valid IPv4 address or 
318 if the given optional netmask is of a different family.
319
320
321 <h3>Parameters</h3>
322 <ul>
323         
324         <li>
325           address: String containing a valid IPv4, optionally with prefix size 
326 (CIDR notation) or netmask separated by slash.
327         </li>
328         
329         <li>
330           netmask: String containing a valid IPv4 netmask or number 
331 containing a prefix size between <code>0</code> and <code>32</code> bit. 
332 Overrides mask embedded in the first argument if specified. (optional)
333         </li>
334         
335 </ul>
336
337
338
339
340 <h3>Usage:</h3>
341 <pre>addr = luci.ip.new("10.24.0.1/24") 
342 addr = luci.ip.new("10.24.0.1/255.255.255.0") 
343 addr = luci.ip.new("10.24.0.1", "255.255.255.0")        -- separate netmask 
344 addr = luci.ip.new("10.24.0.1/24", 16)                  -- override netmask</pre>
345
346
347
348 <h3>Return value:</h3>
349 A <code>luci.ip.cidr</code> object representing the given IPv4 range.
350
351
352
353 <h3>See also:</h3>
354 <ul>
355         
356         <li><a href="#IPv6">
357                 IPv6
358         </a>
359         
360 </ul>
361
362 </dd>
363
364
365
366
367 <dt><a name="IPv6"></a><strong>IPv6</strong>&nbsp;(address, netmask)</dt>
368 <dd>
369
370  
371 Construct a new IPv6 luci.ip.cidr instance. 
372 Throws an error if the given string does not represent a valid IPv6 address or 
373 if the given optional netmask is of a different family.
374
375
376 <h3>Parameters</h3>
377 <ul>
378         
379         <li>
380           address: String containing a valid IPv6, optionally with prefix size 
381 (CIDR notation) or netmask separated by slash.
382         </li>
383         
384         <li>
385           netmask: String containing a valid IPv4 netmask or number 
386 containing a prefix size between <code>0</code> and <code>128</code> bit. 
387 Overrides mask embedded in the first argument if specified. (optional)
388         </li>
389         
390 </ul>
391
392
393
394
395 <h3>Usage:</h3>
396 <pre>addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/64") 
397 addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/ffff:ffff:ffff:ffff::") 
398 addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17", "ffff:ffff:ffff:ffff::") 
399 addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/64", 128) -- override netmask</pre>
400
401
402
403 <h3>Return value:</h3>
404 A <code>luci.ip.cidr</code> object representing the given IPv6 range.
405
406
407
408 <h3>See also:</h3>
409 <ul>
410         
411         <li><a href="#IPv4">
412                 IPv4
413         </a>
414         
415 </ul>
416
417 </dd>
418
419
420
421
422 <dt><a name="route"></a><strong>route</strong>&nbsp;(address)</dt>
423 <dd>
424
425  
426 Determine the route leading to the given destination.
427
428
429 <h3>Parameters</h3>
430 <ul>
431         
432         <li>
433           address: A <code>luci.ip.cidr</code> instance or a string containing 
434 a valid IPv4 or IPv6 range as specified by <code>luci.ip.new()</code>.
435         </li>
436         
437 </ul>
438
439
440
441
442 <h3>Usage:</h3>
443 <ul> 
444 <li>Find default gateway by getting route to Google's public NS server 
445 <pre>rt = luci.ip.route("8.8.8.8") 
446 if rt ~= nil then 
447         print("gateway is", rt.gw) 
448 end</pre></li> 
449 <li>Determine IPv6 upstream interface <pre>rt = luci.ip.route("2001::/7") 
450 if rt ~= nil then 
451         print("ipv6 upstream device is", rt.dev) 
452 end</pre></li> 
453 </ul>
454
455
456
457 <h3>Return value:</h3>
458 <p>Table containing the fields described below.</p> 
459 <table id="routetable"> 
460 <tr><th>Field</th><th>Description</th></tr> 
461 <tr><td><code>type</code><td> 
462   <p>Route type with one of the following numeric values:</p> 
463   <table> 
464   <tr> 
465         <td><code>1</code></td> 
466         <td><code>RTN_UNICAST</code> - Gateway or direct route</td> 
467   </tr> 
468   <tr> 
469         <td><code>2</code></td> 
470         <td><code>RTN_LOCAL</code> - Accept locally</td> 
471   </tr> 
472   <tr> 
473         <td><code>3</code></td> 
474         <td><code>RTN_BROADCAST</code> - 
475             Accept locally as broadcast send as broadcast</td> 
476   </tr> 
477   <tr> 
478         <td><code>4</code></td> 
479         <td><code>RTN_ANYCAST</code> - 
480         Accept locally as broadcast but send as unicast</td> 
481   </tr> 
482   <tr> 
483         <td><code>5</code></td> 
484         <td><code>RTN_MULTICAST</code> - Multicast route</td> 
485   </tr> 
486   </table> 
487 </td></tr> 
488 <tr> 
489   <td><code>family</code></td> 
490   <td>Number containing the route family, <code>4</code> for IPv4 or 
491       <code>6</code> for IPv6</td> 
492 </tr> 
493 <tr> 
494   <td><code>dest</code></td> 
495   <td>Destination <code>luci.ip.cidr</code> instance</td> 
496 </tr> 
497 <tr> 
498   <td><code>gw</code></td> 
499   <td>Gateway <code>luci.ip.cidr</code> instance (optional)</td> 
500 </tr> 
501 <tr> 
502   <td><code>from</code></td> 
503   <td>Source address <code>luci.ip.cidr</code> instance (optional)</td> 
504 </tr> 
505 <tr> 
506   <td><code>src</code></td> 
507   <td>Preferred source <code>luci.ip.cidr</code> instance (optional)</td> 
508 </tr> 
509 <tr> 
510   <td><code>dev</code></td> 
511   <td>String containing the name of the outgoing interface</td> 
512 </tr> 
513 <tr> 
514   <td><code>iif</code></td> 
515   <td>String containing the name of the incoming interface (optional)</td> 
516 </tr> 
517 <tr> 
518   <td><code>table</code></td> 
519   <td>Number of the associated routing table (<code>0..65535</code>)</td> 
520 </tr> 
521 <tr> 
522   <td><code>proto</code></td> 
523   <td>Number of the associated routing protocol</td> 
524 </tr> 
525 <tr> 
526   <td><code>scope</code></td> 
527   <td>Number describing the scope of the route, most commonly 
528       <code>0</code> for global or <code>253</code> for on-link</td> 
529 </tr> 
530 <tr> 
531   <td><code>metric</code></td> 
532   <td>Number describing the route metric (optional)</td> 
533 </tr> 
534 <tr> 
535   <td><code>expires</code></td> 
536   <td>Number of seconds the prefix is valid (IPv6 only, optional)</td> 
537 </tr> 
538 <tr> 
539   <td><code>error</code></td> 
540   <td>Route destination error code (optional)</td> 
541 </tr> 
542 </table>
543
544
545
546 <h3>See also:</h3>
547 <ul>
548         
549         <li><a href="#routes">
550                 routes
551         </a>
552         
553 </ul>
554
555 </dd>
556
557
558
559
560 <dt><a name="routes"></a><strong>routes</strong>&nbsp;(filter, callback)</dt>
561 <dd>
562
563  
564 Fetch all routes, optionally matching the given criteria.
565
566
567 <h3>Parameters</h3>
568 <ul>
569         
570         <li>
571           filter: <p>Table containing one or more of the possible filter 
572 critera described below (optional)</p><table> 
573 <tr><th>Field</th><th>Description</th></tr> 
574 <tr><td><code>family</code></td><td> 
575  Number describing the address family to return - <code>4</code> selects 
576  IPv4 routes, <code>6</code> IPv6 ones. Any other value selects both. 
577 </td></tr> 
578 <tr><td><code>iif</code></td><td> 
579  String containing the incoming route interface to match. 
580 </td></tr> 
581 <tr><td><code>oif</code></td><td> 
582  String containing the outgoing route interface to match. 
583 </td></tr> 
584 <tr><td><code>type</code></td><td> 
585  Numeric type to match, e.g. <code>1</code> for unicast. 
586 </td></tr> 
587 <tr><td><code>scope</code></td><td> 
588  Numeric scope to match, e.g. <code>253</code> for onlink. 
589 </td></tr> 
590 <tr><td><code>proto</code></td><td> 
591  Numeric protocol to match, e.g. <code>2</code> for boot. 
592 </td></tr> 
593 <tr><td><code>table</code></td><td> 
594  Numeric routing table to match (<code>0..65535</code>). 
595 </td></tr> 
596 <tr><td><code>gw</code></td><td> 
597  String containing the gateway address to match. Can be in any notation 
598  specified by <code>luci.ip.new()</code>. Prefix matching is performed when 
599  comparing the routes, e.g. "192.168.1.0/24" would select routes with gateway 
600  addresses <code>192.168.1.1 .. 192.168.1.255</code>. 
601 </td></tr> 
602 <tr><td><code>dest</code></td><td> 
603  String containing the destination to match. Prefix matching is performed. 
604 </td></tr> 
605 <tr><td><code>from</code></td><td> 
606  String containing the source address to match. Prefix matching is performed. 
607 </td></tr> 
608 <tr><td><code>src</code></td><td> 
609  String containing the preferred source address to match. 
610  Prefix matching is performed. 
611 </td></tr> 
612 <tr><td><code>dest_exact</code></td><td> 
613  String containing the destination to match. Exact matching is performed, 
614  e.g. <code>dest = "0.0.0.0/0"</code> would match <em>any</em> IPv4 route 
615  while <code>dest_exact = "0.0.0.0/0"</code> will <em>only</em> match the 
616  default route. 
617 </td></tr> 
618 <tr><td><code>from_exact</code></td><td> 
619  String containing the source address to match. Exact matching is performed. 
620 </td></tr> 
621 </table>
622         </li>
623         
624         <li>
625           callback: <p>Callback function to invoke for each found route 
626 instead of returning one table of route objects (optional)</p>
627         </li>
628         
629 </ul>
630
631
632
633
634 <h3>Usage:</h3>
635 <ul> 
636 <li>Find all IPv4 default routes: 
637 <pre>luci.ip.routes({ dest_exact = "0.0.0.0/0" }, function(rt) 
638         print(rt.type, rt.gw, rt.dev) 
639 end)</pre></li> 
640 <li>Find all global IPv6 prefixes on the current system: 
641 <pre>luci.ip.routes({ from = "2001::/7" }, function(rt) 
642         print(rt.from) 
643 end)</pre></li> 
644 <li>Fetch all IPv4 routes: 
645 <pre>routes = luci.ip.routes({ family = 4 }) 
646 for _, rt in ipairs(routes) do 
647         print(rt.dest, rt.gw, rt.dev) 
648 end</pre></li> 
649 </ul>
650
651
652
653 <h3>Return value:</h3>
654 If no callback function is provided, a table of routes 
655 <a href="#routetable">as specified by <code>luci.ip.route()</code></a> 
656 is returned. If a callback function is given, it is invoked for each route 
657 and nothing is returned.
658
659
660
661 <h3>See also:</h3>
662 <ul>
663         
664         <li><a href="#route">
665                 route
666         </a>
667         
668 </ul>
669
670 </dd>
671
672
673
674
675 <dt><a name="neighbors"></a><strong>neighbors</strong>&nbsp;(filter, callback)</dt>
676 <dd>
677
678  
679 Fetches entries from the IPv4 ARP and IPv6 neighbour kernel table
680
681
682 <h3>Parameters</h3>
683 <ul>
684         
685         <li>
686           filter: <p>Table containing one or more of the possible filter 
687 critera described below (optional)</p><table> 
688 <tr><th>Field</th><th>Description</th></tr> 
689 <tr><td><code>family</code></td><td> 
690  Number describing the address family to return - <code>4</code> selects 
691  IPv4 ARP, <code>6</code> select IPv6 neighbour entries. Any other value 
692  selects both. 
693 </td></tr> 
694 <tr><td><code>dev</code></td><td> 
695  String containing the associated interface to match. 
696 </td></tr> 
697 <tr><td><code>dest</code></td><td> 
698  String containing the associated address to match. Can be in any notation 
699  specified by <code>luci.ip.new()</code>. Prefix matching is performed when 
700  comparing the addresses, e.g. "192.168.1.0/24" would select ARP entries 
701  for <code>192.168.1.1 .. 192.168.1.255</code>. 
702 </td></tr> 
703 <tr><td><code>mac</code></td><td> 
704  String containing MAC address to match. 
705 </td></tr> 
706 </table>
707         </li>
708         
709         <li>
710           callback: <p>Callback function to invoke for each found neighbour 
711 entry instead of returning one table of neighbour entries (optional)</p>
712         </li>
713         
714 </ul>
715
716
717
718
719 <h3>Usage:</h3>
720 <ul> 
721 <li>Find all ARP neighbours in the LAN: 
722 <pre>luci.ip.neighbors({ dest = "192.168.0.0/16" }, function(n) 
723         print(n.dest, n.mac) 
724 end)</pre></li> 
725 <li>Find all active IPv6 addresses of host with given MAC: 
726 <pre>luci.ip.neighbors({ family = 6, mac = "00:21:63:75:aa:17" }, 
727         function(n) 
728                 print(n.dest) 
729         end)</pre></li> 
730 </ul>
731
732
733
734 <h3>Return value:</h3>
735 If no callback function is provided, a table of neighbour entries 
736 is returned. If a callback function is given, it is invoked for each entry 
737 and nothing is returned. 
738  
739 A neighbour entry is a table containing the following fields: 
740  
741 <table> 
742 <tr><th>Field</th><th>Description</th></tr> 
743 <tr> 
744   <td><code>family</code></td> 
745   <td>Number containing the neighbour entry family, <code>4</code> for IPv4 
746       ARP or <code>6</code> for IPv6 NDP</td> 
747 </tr> 
748 <tr> 
749   <td><code>dev</code></td> 
750   <td>String containing the associated device of the neighbour entry</td> 
751 </tr> 
752 <tr> 
753   <td><code>dest</code></td> 
754   <td>IP address <code>luci.ip.cidr</code> instance</td> 
755 </tr> 
756 <tr> 
757   <td><code>mac</code></td> 
758   <td>String containing the associated MAC address</td> 
759 </tr> 
760 <tr> 
761   <td><code>router</code></td> 
762   <td>Boolean "true" if the neighbour entry is a router (IPv6, optional)</td> 
763 </tr> 
764 <tr> 
765   <td><code>proxy</code></td> 
766   <td>Boolean "true" if this is a proxy entry (optional)</td> 
767 </tr> 
768 <tr> 
769   <td><code>incomplete</code></td> 
770   <td>Boolean "true" if the entry is in incomplete state (optional)</td> 
771 </tr> 
772 <tr> 
773   <td><code>reachable</code></td> 
774   <td>Boolean "true" if the entry is in reachable state (optional)</td> 
775 </tr> 
776 <tr> 
777   <td><code>stale</code></td> 
778   <td>Boolean "true" if the entry is stale (optional)</td> 
779 </tr> 
780 <tr> 
781   <td><code>delay</code></td> 
782   <td>Boolean "true" if the entry is delayed (optional)</td> 
783 </tr> 
784 <tr> 
785   <td><code>probe</code></td> 
786   <td>Boolean "true" if the entry is in probe state (optional)</td> 
787 </tr> 
788 <tr> 
789   <td><code>failed</code></td> 
790   <td>Boolean "true" if the entry is in failed state (optional)</td> 
791 </tr> 
792 <tr> 
793   <td><code>noarp</code></td> 
794   <td>Boolean "true" if the entry is not caused by NDP or 
795       ARP (optional)</td> 
796 </tr> 
797 <tr> 
798   <td><code>permanent</code></td> 
799   <td>Boolean "true" if the entry was statically configured from 
800       userspace (optional)</td> 
801 </tr> 
802 </table>
803
804
805
806 </dd>
807
808
809
810
811 <dt><a name="link"></a><strong>link</strong>&nbsp;(device)</dt>
812 <dd>
813
814  
815 Fetch basic device information
816
817
818 <h3>Parameters</h3>
819 <ul>
820         
821         <li>
822           device: String containing the network device to query
823         </li>
824         
825 </ul>
826
827
828
829
830 <h3>Usage:</h3>
831 <ul> 
832 <li>Test whether device br-lan exists: 
833 <pre>print(luci.ip.link("br-lan").name ~= nil) 
834 </pre></li> 
835 <li>Query MAC address of eth0: 
836 <pre>print(luci.ip.link("eth0").mac) 
837 </pre></li> 
838 </ul>
839
840
841
842 <h3>Return value:</h3>
843 If the given interface is found, a table containing the fields 
844 described below is returned, else an empty table. 
845  
846 <table> 
847 <tr><th>Field</th><th>Description</th></tr> 
848 <tr> 
849   <td><code>up</code></td> 
850   <td>Boolean indicating whether the device is in IFF_RUNNING state</td> 
851 </tr> 
852 <tr> 
853   <td><code>type</code></td> 
854   <td>Numeric value indicating the type of the device, e.g. <code>1</code> 
855       for ethernet.</td> 
856 </tr> 
857 <tr> 
858   <td><code>name</code></td> 
859   <td>String containing the name of the device</td> 
860 </tr> 
861 <tr> 
862   <td><code>master</code></td> 
863   <td>If queried device is a bridge port, string containing the name of 
864       parent bridge device (optional)</td> 
865 </tr> 
866 <tr> 
867   <td><code>mtu</code></td> 
868   <td>Number containing the current MTU of the device</td> 
869 </tr> 
870 <tr> 
871   <td><code>qlen</code></td> 
872   <td>Number containing the TX queue length of the device</td> 
873 </tr> 
874 <tr> 
875   <td><code>mac</code></td> 
876   <td>String containing the link local address of the device in 
877       dotted hex notation</td> 
878 </tr> 
879 </table>
880
881
882
883 </dd>
884
885
886 </dl>
887
888
889
890
891
892 </div> <!-- id="content" -->
893
894 </div> <!-- id="main" -->
895
896 <div id="about">
897         <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
898 </div> <!-- id="about" -->
899
900 </div> <!-- id="container" -->
901 </body>
902 </html>