82fcea474fe012e3eccad701efba7914f392a0e1
[project/luci.git] / doc / modules / luci.sys.net.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>
62                 <a href="../modules/luci.ip.html">luci.ip</a>
63         </li>
64
65         <li>
66                 <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
67         </li>
68
69         <li>
70                 <a href="../modules/luci.jsonc.html">luci.jsonc</a>
71         </li>
72
73         <li>
74                 <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
75         </li>
76
77         <li>
78                 <a href="../modules/luci.sys.init.html">luci.sys.init</a>
79         </li>
80
81         <li>
82                 <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
83         </li>
84
85         <li><strong>luci.sys.net</strong></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.sys.net</code></h1>
168
169 <p>
170  
171 LuCI system utilities / network related functions. 
172 </p>
173
174
175
176
177
178
179
180 <h2>Functions</h2>
181 <table class="function_list">
182
183         <tr>
184         <td class="name" nowrap><a href="#call">call</a>&nbsp;(...)</td>
185         <td class="summary">
186  
187 Execute a given shell command and return the error code 
188  </td>
189         </tr>
190
191         <tr>
192         <td class="name" nowrap><a href="#dmesg">dmesg</a>&nbsp;()</td>
193         <td class="summary">
194  
195 Retrieves the output of the "dmesg" command.</td>
196         </tr>
197
198         <tr>
199         <td class="name" nowrap><a href="#exec">exec</a>&nbsp;(command)</td>
200         <td class="summary">
201  
202 Execute a given shell command and capture its standard output 
203  </td>
204         </tr>
205
206         <tr>
207         <td class="name" nowrap><a href="#getenv">getenv</a>&nbsp;(var)</td>
208         <td class="summary">
209  
210 Retrieve environment variables.</td>
211         </tr>
212
213         <tr>
214         <td class="name" nowrap><a href="#hostname">hostname</a>&nbsp;(String)</td>
215         <td class="summary">
216  
217 Get or set the current hostname.</td>
218         </tr>
219
220         <tr>
221         <td class="name" nowrap><a href="#httpget">httpget</a>&nbsp;(url, stream, target)</td>
222         <td class="summary">
223  
224 Returns the contents of a documented referred by an URL.</td>
225         </tr>
226
227         <tr>
228         <td class="name" nowrap><a href="#mounts">mounts</a>&nbsp;()</td>
229         <td class="summary">
230  
231 Retrieve information about currently mounted file systems.</td>
232         </tr>
233
234         <tr>
235         <td class="name" nowrap><a href="#net.arptable">arptable</a>&nbsp;()</td>
236         <td class="summary">
237  
238 Returns the current arp-table entries as two-dimensional table.</td>
239         </tr>
240
241         <tr>
242         <td class="name" nowrap><a href="#net.conntrack">conntrack</a>&nbsp;()</td>
243         <td class="summary">
244  
245 Returns conntrack information 
246  </td>
247         </tr>
248
249         <tr>
250         <td class="name" nowrap><a href="#net.deviceinfo">deviceinfo</a>&nbsp;()</td>
251         <td class="summary">
252  
253 Return information about available network interfaces.</td>
254         </tr>
255
256         <tr>
257         <td class="name" nowrap><a href="#net.devices">devices</a>&nbsp;()</td>
258         <td class="summary">
259  
260 Determine the names of available network interfaces.</td>
261         </tr>
262
263         <tr>
264         <td class="name" nowrap><a href="#net.ipv4_hints">ipv4_hints</a>&nbsp;()</td>
265         <td class="summary">
266  
267 Returns a two-dimensional table of IPv4 address hints.</td>
268         </tr>
269
270         <tr>
271         <td class="name" nowrap><a href="#net.ipv6_hints">ipv6_hints</a>&nbsp;()</td>
272         <td class="summary">
273  
274 Returns a two-dimensional table of IPv6 address hints.</td>
275         </tr>
276
277         <tr>
278         <td class="name" nowrap><a href="#net.mac_hints">mac_hints</a>&nbsp;()</td>
279         <td class="summary">
280  
281 Returns a two-dimensional table of mac address hints.</td>
282         </tr>
283
284         <tr>
285         <td class="name" nowrap><a href="#net.pingtest">pingtest</a>&nbsp;(host)</td>
286         <td class="summary">
287  
288 Tests whether the given host responds to ping probes.</td>
289         </tr>
290
291         <tr>
292         <td class="name" nowrap><a href="#net.routes">routes</a>&nbsp;()</td>
293         <td class="summary">
294  
295 Returns the current kernel routing table entries.</td>
296         </tr>
297
298         <tr>
299         <td class="name" nowrap><a href="#net.routes6">routes6</a>&nbsp;()</td>
300         <td class="summary">
301  
302 Returns the current ipv6 kernel routing table entries.</td>
303         </tr>
304
305         <tr>
306         <td class="name" nowrap><a href="#reboot">reboot</a>&nbsp;()</td>
307         <td class="summary">
308  
309 Initiate a system reboot.</td>
310         </tr>
311
312         <tr>
313         <td class="name" nowrap><a href="#syslog">syslog</a>&nbsp;()</td>
314         <td class="summary">
315  
316 Retrieves the output of the "logread" command.</td>
317         </tr>
318
319         <tr>
320         <td class="name" nowrap><a href="#uniqueid">uniqueid</a>&nbsp;(bytes)</td>
321         <td class="summary">
322  
323 Generates a random id with specified length.</td>
324         </tr>
325
326         <tr>
327         <td class="name" nowrap><a href="#uptime">uptime</a>&nbsp;()</td>
328         <td class="summary">
329  
330 Returns the current system uptime stats.</td>
331         </tr>
332
333 </table>
334
335
336
337
338
339
340 <br/>
341 <br/>
342
343
344 <h2><a name="functions"></a>Functions</h2>
345 <dl class="function">
346
347
348
349 <dt><a name="call"></a><strong>call</strong>&nbsp;(...)</dt>
350 <dd>
351
352  
353 Execute a given shell command and return the error code 
354
355
356
357 <h3>Parameters</h3>
358 <ul>
359         
360         <li>
361           ...: Command to call
362         </li>
363         
364 </ul>
365
366
367
368
369
370
371 <h3>Return value:</h3>
372 Error code of the command
373
374
375
376 </dd>
377
378
379
380
381 <dt><a name="dmesg"></a><strong>dmesg</strong>&nbsp;()</dt>
382 <dd>
383
384  
385 Retrieves the output of the "dmesg" command. 
386
387
388
389
390
391
392
393
394 <h3>Return value:</h3>
395 String containing the current log buffer
396
397
398
399 </dd>
400
401
402
403
404 <dt><a name="exec"></a><strong>exec</strong>&nbsp;(command)</dt>
405 <dd>
406
407  
408 Execute a given shell command and capture its standard output 
409
410
411
412 <h3>Parameters</h3>
413 <ul>
414         
415         <li>
416           command: Command to call
417         </li>
418         
419 </ul>
420
421
422
423
424
425
426 <h3>Return value:</h3>
427 String containg the return the output of the command
428
429
430
431 </dd>
432
433
434
435
436 <dt><a name="getenv"></a><strong>getenv</strong>&nbsp;(var)</dt>
437 <dd>
438
439  
440 Retrieve environment variables. If no variable is given then a table 
441  
442 containing the whole environment is returned otherwise this function returns 
443 the corresponding string value for the given name or nil if no such variable 
444 exists.
445
446
447 <h3>Parameters</h3>
448 <ul>
449         
450         <li>
451           var: Name of the environment variable to retrieve (optional)
452         </li>
453         
454 </ul>
455
456
457
458
459
460
461 <h3>Return values:</h3>
462 <ol>
463         
464         <li>String containg the value of the specified variable
465         
466         <li>Table containing all variables if no variable name is given
467         
468 </ol>
469
470
471
472 </dd>
473
474
475
476
477 <dt><a name="hostname"></a><strong>hostname</strong>&nbsp;(String)</dt>
478 <dd>
479
480  
481 Get or set the current hostname. 
482
483
484
485 <h3>Parameters</h3>
486 <ul>
487         
488         <li>
489           String: containing a new hostname to set (optional)
490         </li>
491         
492 </ul>
493
494
495
496
497
498
499 <h3>Return value:</h3>
500 String containing the system hostname
501
502
503
504 </dd>
505
506
507
508
509 <dt><a name="httpget"></a><strong>httpget</strong>&nbsp;(url, stream, target)</dt>
510 <dd>
511
512  
513 Returns the contents of a documented referred by an URL. 
514
515
516
517 <h3>Parameters</h3>
518 <ul>
519         
520         <li>
521           url: The URL to retrieve
522         </li>
523         
524         <li>
525           stream: Return a stream instead of a buffer
526         </li>
527         
528         <li>
529           target: Directly write to target file name
530         </li>
531         
532 </ul>
533
534
535
536
537
538
539 <h3>Return value:</h3>
540 String containing the contents of given the URL
541
542
543
544 </dd>
545
546
547
548
549 <dt><a name="mounts"></a><strong>mounts</strong>&nbsp;()</dt>
550 <dd>
551
552  
553 Retrieve information about currently mounted file systems. 
554
555
556
557
558
559
560
561
562 <h3>Return value:</h3>
563 Table containing mount information
564
565
566
567 </dd>
568
569
570
571
572 <dt><a name="net.arptable"></a><strong>arptable</strong>&nbsp;()</dt>
573 <dd>
574
575  
576 Returns the current arp-table entries as two-dimensional table. 
577
578
579
580
581
582
583
584
585 <h3>Return value:</h3>
586 Table of table containing the current arp entries. 
587                         The following fields are defined for arp entry objects: 
588                         { "IP address", "HW address", "HW type", "Flags", "Mask", "Device" }
589
590
591
592 </dd>
593
594
595
596
597 <dt><a name="net.conntrack"></a><strong>conntrack</strong>&nbsp;()</dt>
598 <dd>
599
600  
601 Returns conntrack information 
602
603
604
605
606
607
608
609
610 <h3>Return value:</h3>
611 Table with the currently tracked IP connections
612
613
614
615 </dd>
616
617
618
619
620 <dt><a name="net.deviceinfo"></a><strong>deviceinfo</strong>&nbsp;()</dt>
621 <dd>
622
623  
624 Return information about available network interfaces. 
625
626
627
628
629
630
631
632
633 <h3>Return value:</h3>
634 Table containing all current interface names and their information
635
636
637
638 </dd>
639
640
641
642
643 <dt><a name="net.devices"></a><strong>devices</strong>&nbsp;()</dt>
644 <dd>
645
646  
647 Determine the names of available network interfaces. 
648
649
650
651
652
653
654
655
656 <h3>Return value:</h3>
657 Table containing all current interface names
658
659
660
661 </dd>
662
663
664
665
666 <dt><a name="net.ipv4_hints"></a><strong>ipv4_hints</strong>&nbsp;()</dt>
667 <dd>
668
669  
670 Returns a two-dimensional table of IPv4 address hints. 
671
672
673
674
675
676
677
678
679 <h3>Return value:</h3>
680 Table of table containing known hosts from various sources. 
681          Each entry contains the values in the following order: 
682          [ "ip", "name" ]
683
684
685
686 </dd>
687
688
689
690
691 <dt><a name="net.ipv6_hints"></a><strong>ipv6_hints</strong>&nbsp;()</dt>
692 <dd>
693
694  
695 Returns a two-dimensional table of IPv6 address hints. 
696
697
698
699
700
701
702
703
704 <h3>Return value:</h3>
705 Table of table containing known hosts from various sources. 
706          Each entry contains the values in the following order: 
707          [ "ip", "name" ]
708
709
710
711 </dd>
712
713
714
715
716 <dt><a name="net.mac_hints"></a><strong>mac_hints</strong>&nbsp;()</dt>
717 <dd>
718
719  
720 Returns a two-dimensional table of mac address hints. 
721
722
723
724
725
726
727
728
729 <h3>Return value:</h3>
730 Table of table containing known hosts from various sources. 
731          Each entry contains the values in the following order: 
732          [ "mac", "name" ]
733
734
735
736 </dd>
737
738
739
740
741 <dt><a name="net.pingtest"></a><strong>pingtest</strong>&nbsp;(host)</dt>
742 <dd>
743
744  
745 Tests whether the given host responds to ping probes. 
746
747
748
749 <h3>Parameters</h3>
750 <ul>
751         
752         <li>
753           host: String containing a hostname or IPv4 address
754         </li>
755         
756 </ul>
757
758
759
760
761
762
763 <h3>Return value:</h3>
764 Number containing 0 on success and >= 1 on error
765
766
767
768 </dd>
769
770
771
772
773 <dt><a name="net.routes"></a><strong>routes</strong>&nbsp;()</dt>
774 <dd>
775
776  
777 Returns the current kernel routing table entries. 
778
779
780
781
782
783
784
785
786 <h3>Return value:</h3>
787 Table of tables with properties of the corresponding routes. 
788                         The following fields are defined for route entry tables: 
789                         { "dest", "gateway", "metric", "refcount", "usecount", "irtt", 
790                           "flags", "device" }
791
792
793
794 </dd>
795
796
797
798
799 <dt><a name="net.routes6"></a><strong>routes6</strong>&nbsp;()</dt>
800 <dd>
801
802  
803 Returns the current ipv6 kernel routing table entries. 
804
805
806
807
808
809
810
811
812 <h3>Return value:</h3>
813 Table of tables with properties of the corresponding routes. 
814                         The following fields are defined for route entry tables: 
815                         { "source", "dest", "nexthop", "metric", "refcount", "usecount", 
816                           "flags", "device" }
817
818
819
820 </dd>
821
822
823
824
825 <dt><a name="reboot"></a><strong>reboot</strong>&nbsp;()</dt>
826 <dd>
827
828  
829 Initiate a system reboot. 
830
831
832
833
834
835
836
837
838 <h3>Return value:</h3>
839 Return value of os.execute()
840
841
842
843 </dd>
844
845
846
847
848 <dt><a name="syslog"></a><strong>syslog</strong>&nbsp;()</dt>
849 <dd>
850
851  
852 Retrieves the output of the "logread" command. 
853
854
855
856
857
858
859
860
861 <h3>Return value:</h3>
862 String containing the current log buffer
863
864
865
866 </dd>
867
868
869
870
871 <dt><a name="uniqueid"></a><strong>uniqueid</strong>&nbsp;(bytes)</dt>
872 <dd>
873
874  
875 Generates a random id with specified length. 
876
877
878
879 <h3>Parameters</h3>
880 <ul>
881         
882         <li>
883           bytes: Number of bytes for the unique id
884         </li>
885         
886 </ul>
887
888
889
890
891
892
893 <h3>Return value:</h3>
894 String containing hex encoded id
895
896
897
898 </dd>
899
900
901
902
903 <dt><a name="uptime"></a><strong>uptime</strong>&nbsp;()</dt>
904 <dd>
905
906  
907 Returns the current system uptime stats. 
908
909
910
911
912
913
914
915
916 <h3>Return value:</h3>
917 String containing total uptime in seconds
918
919
920
921 </dd>
922
923
924 </dl>
925
926
927
928
929
930 </div> <!-- id="content" -->
931
932 </div> <!-- id="main" -->
933
934 <div id="about">
935         <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>
936 </div> <!-- id="about" -->
937
938 </div> <!-- id="container" -->
939 </body>
940 </html>