+
+
+Return the request content if the request was of unknown type.
+
+
+
+
+
+
+
+
+
Return values:
+
+
+
HTTP request body
+
+
HTTP request body length
+
+
+
+
+
+
+
+
+
+
+
formvalue (name, noparse)
+
+
+
+Get a certain HTTP input value or a table of all input values.
+
+
+
+
Parameters
+
+
+
+ name: Name of the GET or POST variable to fetch
+
+
+
+ noparse: Don't parse POST data before getting the value
+
+
+
+
+
+
+
+
+
+
Return value:
+HTTP input value or table of all input value
+
+
+
+
+
+
+
+
+
formvaluetable (prefix)
+
+
+
+Get a table of all HTTP input values with a certain prefix.
+
+
+
+
Parameters
+
+
+
+ prefix: Prefix
+
+
+
+
+
+
+
+
+
+
Return value:
+Table of all HTTP input values with given prefix
+
+
+
+
+
+
+
+
+
getcookie (name)
+
+
+
+Get the value of a certain HTTP-Cookie.
+
+
+
+
Parameters
+
+
+
+ name: Cookie Name
+
+
+
+
+
+
+
+
+
+
Return value:
+String containing cookie data
+
+
+
+
+
+
+
+
+
getenv (name)
+
+
+
+Get the value of a certain HTTP environment variable
+
+or the environment table itself.
+
+
+
Parameters
+
+
+
+ name: Environment variable
+
+
+
+
+
+
+
+
+
+
Return value:
+HTTP environment value or environment table
+
+
+
+
+
+
+
+
+
header (key, value)
+
+
+
+Send a HTTP-Header.
+
+
+
+
Parameters
+
+
+
+ key: Header key
+
+
+
+ value: Header value
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
prepare_content (mime)
+
+
+
+Set the mime type of following content data.
+
+
+
+
Parameters
+
+
+
+ mime: Mimetype of following content
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
redirect (url)
+
+
+
+Redirects the client to a new URL and closes the connection.
+
+
+
+
Parameters
+
+
+
+ url: Target URL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setfilehandler (callback)
+
+
+
+Set a handler function for incoming user file uploads.
+
+
+
+
Parameters
+
+
+
+ callback: Handler function
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
source ()
+
+
+
+Get the RAW HTTP input source
+
+
+
+
+
+
+
+
+
Return value:
+HTTP LTN12 source
+
+
+
+
+
+
+
+
+
splice (fp, size)
+
+
+
+Splice data from a filedescriptor to the client.
+
+
+
+
Parameters
+
+
+
+ fp: File descriptor
+
+
+
+ size: Bytes to splice (optional)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
status (code, message)
+
+
+
+Set the HTTP status code and status message.
+
+
+
+
Parameters
+
+
+
+ code: Status code
+
+
+
+ message: Status message
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
write (content, src_err)
+
+
+
+Send a chunk of content data to the client.
+
+This function is as a valid LTN12 sink.
+If the content chunk is nil this function will automatically invoke close.
+
+
+
+
+
+Create a new section and initialize it with data.
+
+
+
+
Parameters
+
+
+
+ config: UCI config
+
+
+
+ type: UCI section type
+
+
+
+ name: UCI section name (optional)
+
+
+
+ values: Table of key - value pairs to initialize the section with
+
+
+
+
+
+
+
+
+
+
Return value:
+Name of created section
+
+
+
+
+
+
+
+
+
Cursor:set (config, section, option, value)
+
+
+
+Set a value or create a named section.
+
+
+
+
Parameters
+
+
+
+ config: UCI config
+
+
+
+ section: UCI section name
+
+
+
+ option: UCI option or UCI section type
+
+
+
+ value: UCI value or nil if you want to create a section
+
+
+
+
+
+
+
+
+
+
Return value:
+Boolean whether operation succeeded
+
+
+
+
+
+
+
+
+
Cursor:set_confdir (directory)
+
+
+
+Set the configuration directory.
+
+
+
+
Parameters
+
+
+
+ directory: UCI configuration directory
+
+
+
+
+
+
+
+
+
+
Return value:
+Boolean whether operation succeeded
+
+
+
+
+
+
+
+
+
Cursor:set_list (config, section, option, value)
+
+
+
+Set given values as list.
+
+
+
+
Parameters
+
+
+
+ config: UCI config
+
+
+
+ section: UCI section name
+
+
+
+ option: UCI option
+
+
+
+ value: UCI value
+
+
+
+
+
+
+
+
+
+
Return value:
+Boolean whether operation succeeded
+
+
+
+
+
+
+
+
+
Cursor:set_savedir (directory)
+
+
+
+Set the directory for uncommited changes.
+
+
+
+
Parameters
+
+
+
+ directory: UCI changes directory
+
+
+
+
+
+
+
+
+
+
Return value:
+Boolean whether operation succeeded
+
+
+
+
+
+
+
+
+
Cursor:substate ()
+
+
+
+Create a sub-state of this cursor. The sub-state is tied to the parent
+
+curser, means it the parent unloads or loads configs, the sub state will
+do so as well.
+
+
+
+
+
+
+
+
Return value:
+UCI state cursor tied to the parent cursor
+
+
+
+
+
+
+
+
+
Cursor:tset (config, section, values)
+
+
+
+Updated the data of a section using data from a table.
+
+
+
+
Parameters
+
+
+
+ config: UCI config
+
+
+
+ section: UCI section name (optional)
+
+
+
+ values: Table of key - value pairs to update the section with
+
+
+
+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:
+
+
+
String containg the value of the specified variable
+
+
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
+
+
+
+
+
+
+
+
+
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
+
+
+
+
@@ -346,229 +299,6 @@ Returns the current system uptime stats.
-
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:
-
-
-
String containg the value of the specified variable
-
-
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 ()
@@ -820,107 +550,6 @@ Table of tables with properties of the corresponding routes.
-
-
-
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
-
-
-
-
+
+Return a key, value iterator for the given table.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Functions
+
+
+
+
+
append (src, ...)
+
+
+
+Appends numerically indexed tables or single objects to a given table.
+
+
+
+
Parameters
+
+
+
+ src: Target table
+
+
+
+ ...: Objects to insert
+
+
+
+
+
+
+
+
+
+
Return value:
+Target table
+
+
+
+
+
+
+
+
+
bigendian ()
+
+
+
+Test whether the current system is operating in big endian mode.
+
+
+
+
+
+
+
+
+
Return value:
+Boolean value indicating whether system is big endian
+
+
+
+
+
+
+
+
+
class (base)
+
+
+
+Create a Class object (Python-style object model).
+
+The class object can be instantiated by calling itself.
+Any class functions or shared parameters can be attached to this object.
+Attaching a table to the class object makes this table shared between
+all instances of this class. For object parameters use the __init__ function.
+Classes can inherit member functions and values from a base class.
+Class can be instantiated by calling them. All parameters will be passed
+to the __init__ function of this class - if such a function exists.
+The __init__ function must be used to set any object parameters that are not shared
+with other objects of this class. Any return values will be ignored.
+
+
+
Parameters
+
+
+
+ base: The base class to inherit from (optional)
+
+
+
+Clones the given object and return it's copy.
+
+
+
+
Parameters
+
+
+
+ object: Table value to clone
+
+
+
+ deep: Boolean indicating whether to do recursive cloning
+
+
+
+
+
+
+
+
+
+
Return value:
+Cloned table value
+
+
+
+
+
+
+
+
+
cmatch (str, pattern)
+
+
+
+Count the occurences of given substring in given string.
+
+
+
+
Parameters
+
+
+
+ str: String to search in
+
+
+
+ pattern: String containing pattern to find
+
+
+
+
+
+
+
+
+
+
Return value:
+Number of found occurences
+
+
+
+
+
+
+
+
+
combine (tbl1, tbl2, ...)
+
+
+
+Combines two or more numerically indexed tables and single objects into one table.
+
+
+
+
Parameters
+
+
+
+ tbl1: Table value to combine
+
+
+
+ tbl2: Table value to combine
+
+
+
+ ...: More tables to combine
+
+
+
+
+
+
+
+
+
+
Return value:
+Table value containing all values of given tables
+
+
+
+
+
+
+
+
+
contains (table, value)
+
+
+
+Checks whether the given table contains the given value.
+
+
+
+
Parameters
+
+
+
+ table: Table value
+
+
+
+ value: Value to search within the given table
+
+
+
+
+
+
+
+
+
+
Return value:
+number indicating the first index at which the given value occurs
+ within table or false.
+
+
+
+
+
+
+
+
+
copcall (f, ...)
+
+
+
+This is a coroutine-safe drop-in replacement for Lua's "pcall"-function
+
+
+
+
Parameters
+
+
+
+ f: Lua function to be called protected
+
+
+
+ ...: Parameters passed to the function
+
+
+
+
+
+
+
+
+
+
Return value:
+A boolean whether the function call succeeded and the returns
+ values of the function or the error object
+
+
+
+
+
+
+
+
+
coxpcall (f, err, ...)
+
+
+
+This is a coroutine-safe drop-in replacement for Lua's "xpcall"-function
+
+
+
+
Parameters
+
+
+
+ f: Lua function to be called protected
+
+
+
+ err: Custom error handler
+
+
+
+ ...: Parameters passed to the function
+
+
+
+
+
+
+
+
+
+
Return value:
+A boolean whether the function call succeeded and the return
+ values of either the function or the error handler
+
+
+
+
+
+
+
+
+
dtable ()
+
+
+
+Create a dynamic table which automatically creates subtables.
+
+
+
+
+
+
+
+
+
Return value:
+Dynamic Table
+
+
+
+
+
+
+
+
+
dumptable (t, maxdepth)
+
+
+
+Recursively dumps a table to stdout, useful for testing and debugging.
+
+
+
+
Parameters
+
+
+
+ t: Table value to dump
+
+
+
+ maxdepth: Maximum depth
+
+
+
+
+
+
+
+
+
+
Return value:
+Always nil
+
+
+
+
+
+
+
+
+
exec (command)
+
+
+
+Execute given commandline and gather stdout.
+
+
+
+
Parameters
+
+
+
+ command: String containing command to execute
+
+
+
+
+
+
+
+
+
+
Return value:
+String containing the command's stdout
+
+
+
+
+
+
+
+
+
execi (command)
+
+
+
+Return a line-buffered iterator over the output of given command.
+
+
+
+
Parameters
+
+
+
+ command: String containing the command to execute
+
+
+
+
+
+
+
+
+
+
Return value:
+Iterator
+
+
+
+
+
+
+
+
+
get_bytecode (val)
+
+
+
+Return the current runtime bytecode of the given data. The byte code
+
+will be stripped before it is returned.
+
+
+
Parameters
+
+
+
+ val: Value to return as bytecode
+
+
+
+
+
+
+
+
+
+
Return value:
+String value containing the bytecode of the given data
+
+
+
+
+
+
+
+
+
imatch (val)
+
+
+
+Return a matching iterator for the given value. The iterator will return
+
+one token per invocation, the tokens are separated by whitespace. If the
+input value is a table, it is transformed into a string first. A nil value
+will result in a valid interator which aborts with the first invocation.
+
+
+
Parameters
+
+
+
+ val: The value to scan (table, string or nil)
+
+
+
+
+
+
+
+
+
+
Return value:
+Iterator which returns one token per call
+
+
+
+
+
+
+
+
+
instanceof (object, class)
+
+
+
+Test whether the given object is an instance of the given class.
+
+
+
+
Parameters
+
+
+
+ object: Object instance
+
+
+
+ class: Class object to test against
+
+
+
+
+
+
+
+
+
+
Return value:
+Boolean indicating whether the object is an instance
+
+
+
+
+
+
+Retrieve all keys of given associative table.
+
+
+
+
Parameters
+
+
+
+ t: Table to extract keys from
+
+
+
+
+
+
+
+
+
+
Return value:
+Sorted table containing the keys
+
+
+
+
+
+
+
+
+
kspairs (t)
+
+
+
+Return a key, value iterator for the given table.
+
+The table pairs are sorted by key.
+
+
+
Parameters
+
+
+
+ t: The table to iterate
+
+
+
+
+
+
+
+
+
+
Return value:
+Function value containing the corresponding iterator
+
+
+
+
+
+
+
+
+
libpath ()
+
+
+
+Returns the absolute path to LuCI base directory.
+
+
+
+
+
+
+
+
+
Return value:
+String containing the directory path
+
+
+
+
+
+
+
+
+
parse_units (ustr)
+
+
+
+Parse certain units from the given string and return the canonical integer
+
+value or 0 if the unit is unknown. Upper- or lower case is irrelevant.
+Recognized units are:
+ o "y" - one year (60*60*24*366)
+ o "m" - one month (60*60*24*31)
+ o "w" - one week (60*60*24*7)
+ o "d" - one day (60*60*24)
+ o "h" - one hour (60*60)
+ o "min" - one minute (60)
+ o "kb" - one kilobyte (1024)
+ o "mb" - one megabyte (1024*1024)
+ o "gb" - one gigabyte (1024*1024*1024)
+ o "kib" - one si kilobyte (1000)
+ o "mib" - one si megabyte (1000*1000)
+ o "gib" - one si gigabyte (1000*1000*1000)
+
+
+
Parameters
+
+
+
+ ustr: String containing a numerical value with trailing unit
+
+
+
+
+
+
+
+
+
+
Return value:
+Number containing the canonical value
+
+
+
+
+
+
+
+
+
pcdata (value)
+
+
+
+Create valid XML PCDATA from given string.
+
+
+
+
Parameters
+
+
+
+ value: String value containing the data to escape
+
+
+
+
+
+
+
+
+
+
Return value:
+String value containing the escaped data
+
+
+
+
+
+
+
+
+
perror (obj)
+
+
+
+Write given object to stderr.
+
+
+
+
Parameters
+
+
+
+ obj: Value to write to stderr
+
+
+
+
+
+
+
+
+
+
Return value:
+Boolean indicating whether the write operation was successful
+
+
+
+
+
+
+
+
+
restore_data (str)
+
+
+
+Restore data previously serialized with serialize_data().
+
+
+
+
Parameters
+
+
+
+ str: String containing the data to restore
+
+
+
+
+
+
+
+
+
+
Return value:
+Value containing the restored data structure
+
+
+
+
+ writer: A function to write a chunk of JSON data (optional)
+
+
+
+
+
+
+
+
+
+
Return value:
+String containing the JSON if called without write callback
+
+
+
+
+
+
+
+
+
spairs (t, f)
+
+
+
+Return a key, value iterator which returns the values sorted according to
+
+the provided callback function.
+
+
+
Parameters
+
+
+
+ t: The table to iterate
+
+
+
+ f: A callback function to decide the order of elements
+
+
+
+
+
+
+
+
+
+
Return value:
+Function value containing the corresponding iterator
+
+
+
+
+
+
+
+
+
split (str, pat, max, regex)
+
+
+
+Splits given string on a defined separator sequence and return a table
+
+containing the resulting substrings. The optional max parameter specifies
+the number of bytes to process, regardless of the actual length of the given
+string. The optional last parameter, regex, specifies whether the separator
+sequence is interpreted as regular expression.
+
+
+
Parameters
+
+
+
+ str: String value containing the data to split up
+
+
+
+ pat: String with separator pattern (optional, defaults to "\n")
+
+
+
+ max: Maximum times to split (optional)
+
+
+
+ regex: Boolean indicating whether to interpret the separator
+ pattern as regular expression (optional, default is false)
+
+
+
+
+
+
+
+
+
+
Return value:
+Table containing the resulting substrings
+
+
+
+
+
+
+
+
+
strip_bytecode (code)
+
+
+
+Strips unnescessary lua bytecode from given string. Information like line
+
+numbers and debugging numbers will be discarded. Original version by
+Peter Cawley (http://lua-users.org/lists/lua-l/2008-02/msg01158.html)
+
+
+
Parameters
+
+
+
+ code: String value containing the original lua byte code
+
+
+
+
+
+
+
+
+
+
Return value:
+String value containing the stripped lua byte code
+
+
+
+
+
+
+
+
+
striptags (value)
+
+
+
+Strip HTML tags from given string.
+
+
+
+
Parameters
+
+
+
+ value: String containing the HTML text
+
+
+
+
+
+
+
+
+
+
Return value:
+String with HTML tags stripped of
+
+
+
+
+
+
+
+
+
threadlocal ()
+
+
+
+Create a new or get an already existing thread local store associated with
+
+the current active coroutine. A thread local store is private a table object
+whose values can't be accessed from outside of the running coroutine.
+
+
+
+
+
+
+
+
Return value:
+Table value representing the corresponding thread local store
+
+
+
+
+
+
+
+
+
trim (str)
+
+
+
+Remove leading and trailing whitespace from given string value.
+
+
+
+
Parameters
+
+
+
+ str: String value containing whitespace padded data
+
+
+
+
+
+
+
+
+
+
Return value:
+String value with leading and trailing space removed
+
+
+
+
+
+
+
+
+
ubus (object, method, values)
+
+
+
+Issue an ubus call.
+
+
+
+
Parameters
+
+
+
+ object: String containing the ubus object to call
+
+
+
+ method: String containing the ubus method to call
+
+
+
+ values: Table containing the values to pass
+
+
+
+
+
+
+
+
+
+
Return value:
+Table containin the ubus result
+
+
+
+
+
+
+
+
+
update (t, updates)
+
+
+
+Update values in given table with the values from the second given table.
+
+Both table are - in fact - merged together.
+
+
+
Parameters
+
+
+
+ t: Table which should be updated
+
+
+
+ updates: Table containing the values to update
+
+
+
+
+
+
+
+
+
+
Return value:
+Always nil
+
+
+
+
+
+
+
+
+
vspairs (t)
+
+
+
+Return a key, value iterator for the given table.
+
+The table pairs are sorted by value.
+
+
+
Parameters
+
+
+
+ t: The table to iterate
+
+
+
+
+
+
+
+
+
+
Return value:
+Function value containing the corresponding iterator
+
+
+
+