Class luci.sys.net

LuCI system utilities / network related functions.

Functions

call (...) Execute a given shell command and return the error code
dmesg () Retrieves the output of the "dmesg" command.
exec (command) Execute a given shell command and capture its standard output
getenv (var) Retrieve environment variables.
hostname (String) Get or set the current hostname.
httpget (url, stream, target) Returns the contents of a documented referred by an URL.
mounts () Retrieve information about currently mounted file systems.
arptable () Returns the current arp-table entries as two-dimensional table.
conntrack () Returns conntrack information
deviceinfo () Return information about available network interfaces.
devices () Determine the names of available network interfaces.
ipv4_hints () Returns a two-dimensional table of IPv4 address hints.
ipv6_hints () Returns a two-dimensional table of IPv6 address hints.
mac_hints () Returns a two-dimensional table of mac address hints.
pingtest (host) Tests whether the given host responds to ping probes.
routes () Returns the current kernel routing table entries.
routes6 () Returns the current ipv6 kernel routing table entries.
reboot () Initiate a system reboot.
syslog () Retrieves the output of the "logread" command.
uniqueid (bytes) Generates a random id with specified length.
uptime () Returns the current system uptime stats.


Functions

call (...)
Execute a given shell command and return the error code

Parameters

  • ...: Command to call

Return value:

Error code of the command
dmesg ()
Retrieves the output of the "dmesg" command.

Return value:

String containing the current log buffer
exec (command)
Execute a given shell command and capture its standard output

Parameters

  • command: Command to call

Return value:

String containg the return the output of the command
getenv (var)
Retrieve environment variables. If no variable is given then a table containing the whole environment is returned otherwise this function returns the corresponding string value for the given name or nil if no such variable exists.

Parameters

  • var: Name of the environment variable to retrieve (optional)

Return values:

  1. String containg the value of the specified variable
  2. Table containing all variables if no variable name is given
hostname (String)
Get or set the current hostname.

Parameters

  • String: containing a new hostname to set (optional)

Return value:

String containing the system hostname
httpget (url, stream, target)
Returns the contents of a documented referred by an URL.

Parameters

  • url: The URL to retrieve
  • stream: Return a stream instead of a buffer
  • target: Directly write to target file name

Return value:

String containing the contents of given the URL
mounts ()
Retrieve information about currently mounted file systems.

Return value:

Table containing mount information
arptable ()
Returns the current arp-table entries as two-dimensional table.

Return value:

Table of table containing the current arp entries. The following fields are defined for arp entry objects: { "IP address", "HW address", "HW type", "Flags", "Mask", "Device" }
conntrack ()
Returns conntrack information

Return value:

Table with the currently tracked IP connections
deviceinfo ()
Return information about available network interfaces.

Return value:

Table containing all current interface names and their information
devices ()
Determine the names of available network interfaces.

Return value:

Table containing all current interface names
ipv4_hints ()
Returns a two-dimensional table of IPv4 address hints.

Return value:

Table of table containing known hosts from various sources. Each entry contains the values in the following order: [ "ip", "name" ]
ipv6_hints ()
Returns a two-dimensional table of IPv6 address hints.

Return value:

Table of table containing known hosts from various sources. Each entry contains the values in the following order: [ "ip", "name" ]
mac_hints ()
Returns a two-dimensional table of mac address hints.

Return value:

Table of table containing known hosts from various sources. Each entry contains the values in the following order: [ "mac", "name" ]
pingtest (host)
Tests whether the given host responds to ping probes.

Parameters

  • host: String containing a hostname or IPv4 address

Return value:

Number containing 0 on success and >= 1 on error
routes ()
Returns the current kernel routing table entries.

Return value:

Table of tables with properties of the corresponding routes. The following fields are defined for route entry tables: { "dest", "gateway", "metric", "refcount", "usecount", "irtt", "flags", "device" }
routes6 ()
Returns the current ipv6 kernel routing table entries.

Return value:

Table of tables with properties of the corresponding routes. The following fields are defined for route entry tables: { "source", "dest", "nexthop", "metric", "refcount", "usecount", "flags", "device" }
reboot ()
Initiate a system reboot.

Return value:

Return value of os.execute()
syslog ()
Retrieves the output of the "logread" command.

Return value:

String containing the current log buffer
uniqueid (bytes)
Generates a random id with specified length.

Parameters

  • bytes: Number of bytes for the unique id

Return value:

String containing hex encoded id
uptime ()
Returns the current system uptime stats.

Return value:

String containing total uptime in seconds

Valid XHTML 1.0!