From baa727de93db009f90d70a80a9861758a24eae77 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 5 Nov 2019 10:27:59 +0100 Subject: docs: rename documentation folder to docs Signed-off-by: Jo-Philipp Wich --- docs/CBI.md | 246 + docs/JsonRpcHowTo.md | 66 + docs/LAR.md | 87 + docs/LMO.md | 144 + docs/LuCI-0.10.md | 202 + docs/Modules.md | 94 + docs/ModulesHowTo.md | 153 + docs/Templates.md | 65 + docs/ThemesHowTo.md | 76 + docs/api/index.html | 426 ++ docs/api/luadoc.css | 285 + docs/api/modules/luci.dispatcher.html | 1145 ++++ docs/api/modules/luci.http.conditionals.html | 552 ++ docs/api/modules/luci.http.date.html | 406 ++ docs/api/modules/luci.http.html | 1267 ++++ docs/api/modules/luci.http.mime.html | 322 + docs/api/modules/luci.i18n.html | 391 ++ docs/api/modules/luci.ip.cidr.html | 1511 +++++ docs/api/modules/luci.ip.html | 1217 ++++ docs/api/modules/luci.json.html | 594 ++ docs/api/modules/luci.jsonc.html | 393 ++ docs/api/modules/luci.jsonc.parser.html | 491 ++ docs/api/modules/luci.model.ipkg.html | 730 ++ docs/api/modules/luci.model.uci.html | 1631 +++++ docs/api/modules/luci.rpcc.html | 324 + docs/api/modules/luci.rpcc.ruci.html | 277 + docs/api/modules/luci.sys.html | 641 ++ docs/api/modules/luci.sys.init.html | 512 ++ docs/api/modules/luci.sys.iptparser.html | 462 ++ docs/api/modules/luci.sys.net.html | 597 ++ docs/api/modules/luci.sys.process.html | 519 ++ docs/api/modules/luci.sys.user.html | 412 ++ docs/api/modules/luci.sys.wifi.html | 280 + docs/api/modules/luci.util.html | 1830 +++++ docs/api/modules/nixio.CHANGELOG.html | 286 + docs/api/modules/nixio.CryptoHash.html | 312 + docs/api/modules/nixio.File.html | 669 ++ docs/api/modules/nixio.README.html | 370 + docs/api/modules/nixio.Socket.html | 1029 +++ docs/api/modules/nixio.TLSContext.html | 475 ++ docs/api/modules/nixio.TLSSocket.html | 571 ++ docs/api/modules/nixio.UnifiedIO.html | 763 +++ docs/api/modules/nixio.bin.html | 423 ++ docs/api/modules/nixio.bit.html | 740 ++ docs/api/modules/nixio.crypto.html | 315 + docs/api/modules/nixio.fs.html | 1558 +++++ docs/api/modules/nixio.html | 2401 +++++++ docs/i18n.md | 19 + docs/jsapi/LuCI.Class.html | 2322 +++++++ docs/jsapi/LuCI.Headers.html | 1495 +++++ docs/jsapi/LuCI.Network.Device.html | 3440 ++++++++++ docs/jsapi/LuCI.Network.Hosts.html | 2421 +++++++ docs/jsapi/LuCI.Network.Protocol.html | 5394 +++++++++++++++ docs/jsapi/LuCI.Network.WifiDevice.html | 2787 ++++++++ docs/jsapi/LuCI.Network.WifiNetwork.html | 4908 ++++++++++++++ docs/jsapi/LuCI.Network.html | 7032 ++++++++++++++++++++ docs/jsapi/LuCI.Poll.html | 1878 ++++++ docs/jsapi/LuCI.Request.html | 2774 ++++++++ docs/jsapi/LuCI.Request.poll.html | 1997 ++++++ docs/jsapi/LuCI.Response.html | 1855 ++++++ docs/jsapi/LuCI.XHR.html | 2047 ++++++ docs/jsapi/LuCI.dom.html | 3878 +++++++++++ docs/jsapi/LuCI.fs.html | 2987 +++++++++ docs/jsapi/LuCI.html | 5023 ++++++++++++++ docs/jsapi/LuCI.rpc.html | 3225 +++++++++ docs/jsapi/LuCI.uci.html | 4773 +++++++++++++ docs/jsapi/LuCI.view.html | 2083 ++++++ docs/jsapi/fonts/OpenSans-Bold-webfont.eot | Bin 0 -> 19544 bytes docs/jsapi/fonts/OpenSans-Bold-webfont.svg | 1830 +++++ docs/jsapi/fonts/OpenSans-Bold-webfont.woff | Bin 0 -> 22432 bytes docs/jsapi/fonts/OpenSans-BoldItalic-webfont.eot | Bin 0 -> 20133 bytes docs/jsapi/fonts/OpenSans-BoldItalic-webfont.svg | 1830 +++++ docs/jsapi/fonts/OpenSans-BoldItalic-webfont.woff | Bin 0 -> 23048 bytes docs/jsapi/fonts/OpenSans-Italic-webfont.eot | Bin 0 -> 20265 bytes docs/jsapi/fonts/OpenSans-Italic-webfont.svg | 1830 +++++ docs/jsapi/fonts/OpenSans-Italic-webfont.woff | Bin 0 -> 23188 bytes docs/jsapi/fonts/OpenSans-Light-webfont.eot | Bin 0 -> 19514 bytes docs/jsapi/fonts/OpenSans-Light-webfont.svg | 1831 +++++ docs/jsapi/fonts/OpenSans-Light-webfont.woff | Bin 0 -> 22248 bytes docs/jsapi/fonts/OpenSans-LightItalic-webfont.eot | Bin 0 -> 20535 bytes docs/jsapi/fonts/OpenSans-LightItalic-webfont.svg | 1835 +++++ docs/jsapi/fonts/OpenSans-LightItalic-webfont.woff | Bin 0 -> 23400 bytes docs/jsapi/fonts/OpenSans-Regular-webfont.eot | Bin 0 -> 19836 bytes docs/jsapi/fonts/OpenSans-Regular-webfont.svg | 1831 +++++ docs/jsapi/fonts/OpenSans-Regular-webfont.woff | Bin 0 -> 22660 bytes docs/jsapi/fs.js.html | 350 + docs/jsapi/index.html | 1131 ++++ docs/jsapi/luci.js.html | 3125 +++++++++ docs/jsapi/network.js.html | 4038 +++++++++++ docs/jsapi/rpc.js.html | 528 ++ docs/jsapi/scripts/linenumber.js | 25 + docs/jsapi/scripts/prettify/Apache-License-2.0.txt | 202 + docs/jsapi/scripts/prettify/lang-css.js | 2 + docs/jsapi/scripts/prettify/prettify.js | 28 + docs/jsapi/styles/jsdoc-default.css | 358 + docs/jsapi/styles/prettify-jsdoc.css | 111 + docs/jsapi/styles/prettify-tomorrow.css | 132 + docs/jsapi/uci.js.html | 994 +++ 98 files changed, 112609 insertions(+) create mode 100644 docs/CBI.md create mode 100644 docs/JsonRpcHowTo.md create mode 100644 docs/LAR.md create mode 100644 docs/LMO.md create mode 100644 docs/LuCI-0.10.md create mode 100644 docs/Modules.md create mode 100644 docs/ModulesHowTo.md create mode 100644 docs/Templates.md create mode 100644 docs/ThemesHowTo.md create mode 100644 docs/api/index.html create mode 100644 docs/api/luadoc.css create mode 100644 docs/api/modules/luci.dispatcher.html create mode 100644 docs/api/modules/luci.http.conditionals.html create mode 100644 docs/api/modules/luci.http.date.html create mode 100644 docs/api/modules/luci.http.html create mode 100644 docs/api/modules/luci.http.mime.html create mode 100644 docs/api/modules/luci.i18n.html create mode 100644 docs/api/modules/luci.ip.cidr.html create mode 100644 docs/api/modules/luci.ip.html create mode 100644 docs/api/modules/luci.json.html create mode 100644 docs/api/modules/luci.jsonc.html create mode 100644 docs/api/modules/luci.jsonc.parser.html create mode 100644 docs/api/modules/luci.model.ipkg.html create mode 100644 docs/api/modules/luci.model.uci.html create mode 100644 docs/api/modules/luci.rpcc.html create mode 100644 docs/api/modules/luci.rpcc.ruci.html create mode 100644 docs/api/modules/luci.sys.html create mode 100644 docs/api/modules/luci.sys.init.html create mode 100644 docs/api/modules/luci.sys.iptparser.html create mode 100644 docs/api/modules/luci.sys.net.html create mode 100644 docs/api/modules/luci.sys.process.html create mode 100644 docs/api/modules/luci.sys.user.html create mode 100644 docs/api/modules/luci.sys.wifi.html create mode 100644 docs/api/modules/luci.util.html create mode 100644 docs/api/modules/nixio.CHANGELOG.html create mode 100644 docs/api/modules/nixio.CryptoHash.html create mode 100644 docs/api/modules/nixio.File.html create mode 100644 docs/api/modules/nixio.README.html create mode 100644 docs/api/modules/nixio.Socket.html create mode 100644 docs/api/modules/nixio.TLSContext.html create mode 100644 docs/api/modules/nixio.TLSSocket.html create mode 100644 docs/api/modules/nixio.UnifiedIO.html create mode 100644 docs/api/modules/nixio.bin.html create mode 100644 docs/api/modules/nixio.bit.html create mode 100644 docs/api/modules/nixio.crypto.html create mode 100644 docs/api/modules/nixio.fs.html create mode 100644 docs/api/modules/nixio.html create mode 100644 docs/i18n.md create mode 100644 docs/jsapi/LuCI.Class.html create mode 100644 docs/jsapi/LuCI.Headers.html create mode 100644 docs/jsapi/LuCI.Network.Device.html create mode 100644 docs/jsapi/LuCI.Network.Hosts.html create mode 100644 docs/jsapi/LuCI.Network.Protocol.html create mode 100644 docs/jsapi/LuCI.Network.WifiDevice.html create mode 100644 docs/jsapi/LuCI.Network.WifiNetwork.html create mode 100644 docs/jsapi/LuCI.Network.html create mode 100644 docs/jsapi/LuCI.Poll.html create mode 100644 docs/jsapi/LuCI.Request.html create mode 100644 docs/jsapi/LuCI.Request.poll.html create mode 100644 docs/jsapi/LuCI.Response.html create mode 100644 docs/jsapi/LuCI.XHR.html create mode 100644 docs/jsapi/LuCI.dom.html create mode 100644 docs/jsapi/LuCI.fs.html create mode 100644 docs/jsapi/LuCI.html create mode 100644 docs/jsapi/LuCI.rpc.html create mode 100644 docs/jsapi/LuCI.uci.html create mode 100644 docs/jsapi/LuCI.view.html create mode 100644 docs/jsapi/fonts/OpenSans-Bold-webfont.eot create mode 100644 docs/jsapi/fonts/OpenSans-Bold-webfont.svg create mode 100644 docs/jsapi/fonts/OpenSans-Bold-webfont.woff create mode 100644 docs/jsapi/fonts/OpenSans-BoldItalic-webfont.eot create mode 100644 docs/jsapi/fonts/OpenSans-BoldItalic-webfont.svg create mode 100644 docs/jsapi/fonts/OpenSans-BoldItalic-webfont.woff create mode 100644 docs/jsapi/fonts/OpenSans-Italic-webfont.eot create mode 100644 docs/jsapi/fonts/OpenSans-Italic-webfont.svg create mode 100644 docs/jsapi/fonts/OpenSans-Italic-webfont.woff create mode 100644 docs/jsapi/fonts/OpenSans-Light-webfont.eot create mode 100644 docs/jsapi/fonts/OpenSans-Light-webfont.svg create mode 100644 docs/jsapi/fonts/OpenSans-Light-webfont.woff create mode 100644 docs/jsapi/fonts/OpenSans-LightItalic-webfont.eot create mode 100644 docs/jsapi/fonts/OpenSans-LightItalic-webfont.svg create mode 100644 docs/jsapi/fonts/OpenSans-LightItalic-webfont.woff create mode 100644 docs/jsapi/fonts/OpenSans-Regular-webfont.eot create mode 100644 docs/jsapi/fonts/OpenSans-Regular-webfont.svg create mode 100644 docs/jsapi/fonts/OpenSans-Regular-webfont.woff create mode 100644 docs/jsapi/fs.js.html create mode 100644 docs/jsapi/index.html create mode 100644 docs/jsapi/luci.js.html create mode 100644 docs/jsapi/network.js.html create mode 100644 docs/jsapi/rpc.js.html create mode 100644 docs/jsapi/scripts/linenumber.js create mode 100644 docs/jsapi/scripts/prettify/Apache-License-2.0.txt create mode 100644 docs/jsapi/scripts/prettify/lang-css.js create mode 100644 docs/jsapi/scripts/prettify/prettify.js create mode 100644 docs/jsapi/styles/jsdoc-default.css create mode 100644 docs/jsapi/styles/prettify-jsdoc.css create mode 100644 docs/jsapi/styles/prettify-tomorrow.css create mode 100644 docs/jsapi/uci.js.html (limited to 'docs') diff --git a/docs/CBI.md b/docs/CBI.md new file mode 100644 index 000000000..933380d22 --- /dev/null +++ b/docs/CBI.md @@ -0,0 +1,246 @@ + +# CBI models +are Lua files describing the structure of an UCI config file and the resulting HTML form to be evaluated by the CBI parser.
+All CBI model files must return an object of type **luci.cbi.Map**.
+For a commented example of a CBI model, see the [Writing Modules tutorial](ModulesHowTo.md#cbimodels). + +The scope of a CBI model file is automatically extended by the contents of the module **luci.cbi** and the _translate_ function from **luci.i18n** + +This Reference covers **the basics** of the CBI system. + + +## class Map (_config, title, description_) +This is the root object of the model. + +* **config:** configuration filename to be mapped, see [UCI documentation](https://openwrt.org/docs/guide-user/base-system/uci) and the files in /etc/config +* **title:** title shown in the UI +* **description:** description shown in the UI + +#### function :section (_sectionclass_, ...) +Creates a new section +* **sectionclass**: a class object of the section +* _additional parameters passed to the constructor of the section class_ + +---- + +## class NamedSection (_name, type, title, description_) +An object describing an UCI section selected by the name.
+To instantiate use: `Map:section(NamedSection, "name", "type", "title", "description")` + +* **name:** UCI section name +* **type:** UCI section type +* **title:** The title shown in the UI +* **description:** description shown in the UI + +#### function :option(_optionclass_, ...) +Creates a new option +* **optionclass:** a class object of the section +* _additional parameters passed to the constructor of the option class_ + +#### property .addremove = false +Allows the user to remove and recreate the configuration section. + +#### property .dynamic = false +Marks this section as dynamic. Dynamic sections can contain an undefinded number of completely userdefined options. + +#### property .optional = true +Parse optional options + +---- + +## class TypedSection (_type, title, description_) +An object describing a group of UCI sections selected by their type.
+To instantiate use: `Map:section(TypedSection, "type", "title", "description")` +* **type:** UCI section type +* **title:** The title shown in the UI +* **description:** description shown in the UI + +#### function :option(_optionclass_, ...) +Creates a new option + **optionclass:** a class object of the section + _additional parameters passed to the constructor of the option class_ + +#### function :depends(_key, value_) +Only select those sections where _key == value_
+If you call this function several times the dependencies will be linked with **"or"** + +#### function .filter(_self, section_) -abstract- +You can override this function to filter certain sections that will not be parsed. +The filter function will be called for every section that should be parsed and returns **nil** for sections that should be filtered. For all other sections it should return the section name as given in the second parameter. + +#### property .addremove = false +Allows the user to remove and recreate the configuration section + +#### property .dynamic = false +Marks this section as dynamic. Dynamic sections can contain an undefinded number of completely userdefined options. + +#### property .optional = true +Parse optional options + +#### property .anonymous = false +Do not show UCI section names + +---- + +## class Value (_option, title, description_) +An object describing an option in a section of a UCI File. Creates a standard text field in the formular.
+To instantiate use: `NamedSection:option(Value, "option", "title", "description")`
+ or `TypedSection:option(Value, "option", "title", "description")` +* **option:** UCI option name +* **title:** The title shown in the UI +* **description:** description shown in the UI + +#### function :depends(key, value) +Only show this option field if another option _key_ is set to _value_ in the same section.
+If you call this function several times the dependencies will be linked with **"or"** + +#### function :value(key, value) +Convert this text field into a combobox if possible and add a selection option. + +#### property .default = nil +The default value + +#### property .maxlength = nil +The maximum inputlength (of chars) of the value + +#### property .optional = false +Marks this option as optional, implies .rmempty = true + +#### property .rmempty = true +Removes this option from the configuration file when the user enters an empty value + +#### property .size = nil +The maximum number of chars displayed by form field + +---- + +## class ListValue (_option, title, description_) +An object describing an option in a section of a UCI File.
+Creates a list box or list of radio (for selecting one of many choices) in the formular.
+To instantiate use: `NamedSection:option(ListValue, "option", "title", "description")`
+or `TypedSection:option(ListValue, "option", "title", "description")` +* **option:** UCI option name +* **title:** The title shown in the UI +* **description:** description shown in the UI + +#### function :depends(key, value) +Only show this option field if another option _key_ is set to _value_ in the same section.
+If you call this function several times the dependencies will be linked with **"or"** + +#### function :value(_key, value_) +Adds an entry to the selection list + +#### property .widget = "select" +**"select"** shows a selection list, **"radio"** shows a list of radio buttons inside form + +#### property .default = nil +The default value + +#### property .optional = false +Marks this option as optional, implies .rmempty = true + +#### property .rmempty = true +Removes this option from the configuration file when the user enters an empty value + +#### property .size = nil +The size of the form field + +---- + +## class Flag (_option, title, description_) +An object describing an option with two possible values in a section of a UCI File.
+Creates a checkbox field in the formular.
+To instantiate use: `NamedSection:option(Flag, "option", ""title", "description")`
+ or `TypedSection:option(Flag, "option", "title", "description")` +* **option:** UCI option name +* **title:** The title shown in the UI +* **description:** description shown in the UI + +#### function :depends (_key, value_) +Only show this option field if another option _key_ is set to _value_ in the same section.
+If you call this function several times the dependencies will be linked with **"or"** + +#### property .default = nil +The default value + +#### property .disabled = 0 +the value that should be set if the checkbox is unchecked + +#### property .enabled = 1 +the value that should be set if the checkbox is checked + +#### property .optional = false +Marks this option as optional, implies .rmempty = true + +#### property .rmempty = true +Removes this option from the configuration file when the user enters an empty value + +---- + +## class MultiValue (_option'', ''title'', ''description_) +An object describing an option in a section of a UCI File.
+Creates a list of checkboxed or a multiselectable list as form fields.
+To instantiate use: `NamedSection:option(MultiValue, "option", ""title", "description")`
+ or `TypedSection:option(MultiValue, "option", "title", "description")` +* **option:** UCI option name +* **title:** The title shown in the UI +* **description:** description shown in the UI + +#### function :depends (_key, value_) +Only show this option field if another option _key_ is set to _value_ in the same section.
+If you call this function several times the dependencies will be linked with **"or"** + +#### function :value(_key, value_) +Adds an entry to the list + +#### property .widget = "checkbox" +**"select"** shows a selection list, **"checkbox"** shows a list of checkboxes inside form + +#### property .delimiter = " " +The string which will be used to delimit the values inside stored option + +#### property .default = nil +The default value + +#### property .optional = false +Marks this option as optional, implies .rmempty = true + +#### property .rmempty = true +Removes this option from the configuration file when the user enters an empty value + +#### property .size = nil +The size of the form field (only used if property _.widget = "select"_) + +---- + +## class StaticList (_option, title, description_) +Similar to the MultiValue, but stores selected Values into a UCI list instead of a character-separated option. + +---- + +## class DynamicList (_option, title, description_) +A extensible list of user-defined values. Stores Values into a UCI list + +---- + +## class DummyValue (_option, title, description_) +Creates a readonly text in the form. !It writes no data to UCI!
+To instantiate use: `NamedSection:option(DummyValue, "option", ""title", "description")`
+ or `TypedSection:option(DummyValue, "option", "title", "description")` +* **option:** UCI option name +* **title:** The title shown in the UI +* **description:** description shown in the UI + +#### property :depends (_key, value_) +Only show this option field if another option _key_ is set to _value_ in the same section.
+If you call this function several times the dependencies will be linked with **"or"** + +---- + +## class TextValue (_option, title, description_) +An object describing a multi-line textbox in a section in a non-UCI form. + +---- + +## class Button (_option, title, description_) +An object describing a Button in a section in a non-UCI form. diff --git a/docs/JsonRpcHowTo.md b/docs/JsonRpcHowTo.md new file mode 100644 index 000000000..76d61f86e --- /dev/null +++ b/docs/JsonRpcHowTo.md @@ -0,0 +1,66 @@ +LuCI provides some of its libraries to external applications through a JSON-RPC API. +This Howto shows how to use it and provides information about available functions. + + +# Basics +LuCI comes with an efficient JSON De-/Encoder together with a JSON-RPC-Server which implements the *JSON-RPC 1.0_' and 2.0 (partly) specifications. The LuCI JSON-RPC server offers several independent APIs. Therefore you have to use '_different URLs for every exported library*. +Assuming your LuCI-Installation can be reached through */cgi-bin/luci_' any exported library can be reached via '''/cgi-bin/luci/rpc/''LIBRARY_*. + + +# Authentication +Most exported libraries will require a valid authentication to be called with. If you get an *HTTP 403 Forbidden_' status code you are probably missing a valid authentication token. To get such a token you have to call the function '''login''' of the RPC-Library '''auth'''. Following our example from above this login function would be provided at '_/cgi-bin/luci/rpc/auth*. The function accepts 2 parameters: username and password (of a valid user account on the host system) and returns an authentication token. + +If you want to call any exported library which requires an authentication token you have to *append it as an URL parameter _auth''''' to the RPC-Server URL. So instead of calling '''/cgi-bin/luci/rpc/''LIBRARY''''' you have to call '''/cgi-bin/luci/rpc/''LIBRARY''?auth=''TOKEN_*. + +If your JSON-RPC client is Cookie-aware (like most browsers are) you will receive the authentication token also with a session cookie and probably don't have to append it to the RPC-Server URL. + + +# Exported Libraries +## uci +The UCI-Library */rpc/uci* offers functionality to interact with the Universal Configuration Interface. +*Exported Functions:* +* [(string) add(config, type)](http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.add) +* [(integer) apply(config)](http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.apply) +* [http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.changes (object) changes([config])] +* [(boolean) commit(config)](http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.commit) +* [http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.delete (boolean) delete(config, section[, option])] +* [http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.delete_all (boolean) delete_all(config[, type])] +* [http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.foreach (array) foreach(config[, type])] +* [http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.get (mixed) get(config, section[, option])] +* [http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.get_all (object) get_all(config[, section])] +* [http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.get (mixed) get_state(config, section[, option])] +* [(boolean) revert(config)](http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.revert) +* [(name) section(config, type, name, values)](http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.section) +* [(boolean) set(config, section, option, value)](http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.set) +* [(boolean) tset(config, section, values)](http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.tset) + +## uvl +The UVL-Library */rpc/uvl* offers functionality to validate UCI files and get schemes describing UCI files. +*Exported Functions:* +* [(array) get_scheme(scheme)](http://luci.subsignal.org/api/luci/modules/luci.uvl.html#UVL.get_scheme) +* [(array) validate(config, section, option)](http://luci.subsignal.org/api/luci/modules/luci.uvl.html#UVL.validate) +* [(array) validate_config(config)](http://luci.subsignal.org/api/luci/modules/luci.uvl.html#UVL.validate_config) +* [(array) validate_section(config, section)](http://luci.subsignal.org/api/luci/modules/luci.uvl.html#UVL.validate_section) +* [(array) validate(config, section, option)](http://luci.subsignal.org/api/luci/modules/luci.uvl.html#UVL.validate_option) + +## fs +The Filesystem library */rpc/fs* offers functionality to interact with the filesystem on the host machine. +*Exported Functions:* + +* [Complete luci.fs library](http://luci.subsignal.org/api/luci/modules/luci.fs.html) +*Note:* All functions are exported as they are except for _readfile'' which encodes its return value in base64 and ''writefile'' which only accepts base64 encoded data as second argument. Note that both functions will only be available when the ''luasocket_ packet is installed on the hostsystem. + +## sys +The System library */rpc/sys* offers functionality to interact with the operating system on the host machine. +*Exported Functions:* +* [Complete luci.sys library](http://luci.subsignal.org/api/luci/modules/luci.sys.html) +* [Complete luci.sys.group library](http://luci.subsignal.org/api/luci/modules/luci.sys.group.html) with prefix *group.* +* [Complete luci.sys.net library](http://luci.subsignal.org/api/luci/modules/luci.sys.net.html) with prefix *net.* +* [Complete luci.sys.process library](http://luci.subsignal.org/api/luci/modules/luci.sys.process.html) with prefix *process.* +* [Complete luci.sys.user library](http://luci.subsignal.org/api/luci/modules/luci.sys.user.html) with prefix *user.* +* [Complete luci.sys.wifi library](http://luci.subsignal.org/api/luci/modules/luci.sys.wifi.html) with prefix *wifi.* + +## ipkg +The IPKG library */rpc/ipkg* offers functionality to interact with the package manager (IPKG or OPKG) on the host machine. +*Exported Functions:* +* [Complete luci.model.ipkg library](http://luci.subsignal.org/api/luci/modules/luci.model.ipkg.html) diff --git a/docs/LAR.md b/docs/LAR.md new file mode 100644 index 000000000..457b076f9 --- /dev/null +++ b/docs/LAR.md @@ -0,0 +1,87 @@ +LAR is a simple archive format to pack multiple lua source files and arbitrary other resources into a single file. + + +# Format Specification + +A LAR archive file is divided into two parts: the payload and the index lookup table. +All segments of the archive are 4 Byte aligned to ease reading and processing of the format. +All integers are stored in network byte order, so an implementation has to use htonl() and htons() to properly read them. + +Schema: + + + + > + + + + > + + ... + + + + > + > + + + + + > + + + + + > + + ... + + + + + > + > + + + + + +# Processing + +In order to process an LAR archive, an implementation would have to do the following steps: + +## Read Index + +1. Locate and open the archive file +1. Seek to end of file - 4 bytes +1. Read 32bit index offset and swap from network to native byte order +1. Seek to index offset, calculate index length: filesize - index offset - 4 +1. Initialize a linked list for index table entries +1. Read each index entry until the index length is reached, read and byteswap 4 * 32bit int and 2 * 16bit int +1. Seek to begin of file + +## Read Member + +1. Read the archive index +1. Iterate through the linked index list, perform the following steps for each entry +1. Seek to the specified file path offset +1. Read as much bytes as specified in the file path length into a buffer +1. Compare the contents of the buffer against the path of the searched member +1. If buffer and searched path are equal, seek to the specified file data offset +1. Read data until the file data length is reached, return +1. Select the next index table entry and repeat from step 3, if there is no next entry then return + +# Reference implementation + +A reference implementation can be found here: +http://luci.subsignal.org/trac/browser/luci/trunk/contrib/lar + +The lar.pl script is a simple packer for LAR archives and cli.c provides a utility to list and dump packed LAR archives. diff --git a/docs/LMO.md b/docs/LMO.md new file mode 100644 index 000000000..961a45ba8 --- /dev/null +++ b/docs/LMO.md @@ -0,0 +1,144 @@ +LMO is a simple binary format to pack language strings into a more efficient form. Although it's suitable to store any kind of key-value table, it's only used for the LuCI *.po based translation system at the moment. The abbreviation "LMO" stands for "Lua Machine Objects" in the style of the GNU gettext *.mo format. + + +# Format Specification + +A LMO file is divided into two parts: the payload and the index lookup table. +All segments of the file are 4 Byte aligned to ease reading and processing of the format. +Only unsigned 32bit integers are used and stored in network byte order, so an implementation has to use htonl() to properly read them. + +Schema: + + + + + + ... + + + > + + + + + + > + + + + + + > + + ... + + + + + + > + > + + + > + + + +# Processing + +In order to process a LMO file, an implementation would have to do the following steps: + +## Read Index + +1. Locate and open the archive file +1. Seek to end of file - 4 bytes (sizeof(uint32_t)) +1. Read 32bit index offset and swap from network to native byte order +1. Seek to index offset, calculate index length: filesize - index offset - 4 +1. Initialize a linked list for index table entries +1. Read each index entry until the index length is reached, read and byteswap 4 * uint32_t for each step +1. Seek to begin of file + +## Read Entry + +1. Calculate the unsigned 32bit hash of the entries key value (see "Hash Function" section below) +1. Obtain the archive index +1. Iterate through the linked index list, perform the following steps for each entry: + 1. Compare the entry hash value with the calculated hash from step 1 + 2. If the hash values are equal proceed with step 4 + 3. Select the next entry and repeat from step 3.1 +1. Seek to the file offset specified in the selected entry +1. Read as much bytes as specified in the entry length into a buffer +1. Return the buffer value + +# Hash Function + +The current LuCI-LMO implementation uses the "Super Fast Hash" function which was kindly put in the public domain by it's original author. See http://www.azillionmonkeys.com/qed/hash.html for details. Below is the C-Implementation of this function: + + + #if (defined(__GNUC__) && defined(__i386__)) + #define sfh_get16(d) (*((const uint16_t *) (d))) + #else + #define sfh_get16(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ + +(uint32_t)(((const uint8_t *)(d))[0]) ) + #endif + + uint32_t sfh_hash(const char * data, int len) + { + uint32_t hash = len, tmp; + int rem; + + if (len <= NULL) return 0; + + rem = len & 3; + len >>= 2; + + /* Main loop */ + for (;len > 0; len--) { + hash += sfh_get16(data); + tmp = (sfh_get16(data+2) << 11) ^ hash; + hash = (hash << 16) ^ tmp; + data += 2*sizeof(uint16_t); + hash += hash >> 11; + } + + /* Handle end cases */ + switch (rem) { + case 3: hash += sfh_get16(data); + hash ^= hash << 16; + hash ^= data[sizeof(uint16_t)] << 18; + hash += hash >> 11; + break; + case 2: hash += sfh_get16(data); + hash ^= hash << 11; + hash += hash >> 17; + break; + case 1: hash += *data; + hash ^= hash << 10; + hash += hash >> 1; + } + + /* Force "avalanching" of final 127 bits */ + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + + return hash; + } + + +# Reference Implementation + +A reference implementation can be found here: +http://luci.subsignal.org/trac/browser/luci/trunk/libs/lmo/src + +The lmo_po2lmo.c executable implements a *.po to *.lmo conversation utility and lmo_lookup.c is a simple *.lmo test utility. +Lua bindings for lmo are defined in lmo_lualib.c and associated headers. diff --git a/docs/LuCI-0.10.md b/docs/LuCI-0.10.md new file mode 100644 index 000000000..5db9895e5 --- /dev/null +++ b/docs/LuCI-0.10.md @@ -0,0 +1,202 @@ +[[PageOutline(2-5, Table of Contents, floated)]] + + +This document describes new features and incompatibilities to LuCI 0.9.x. +It is targeted at module authors developing external addons to LuCI. + +# I18N Changes + +## API + +The call conventions for the i18n api changed, there is no dedicated translation +key anymore and the english text is used for lookup instead. This was done to +ease the maintenance of language files. + +Code that uses _translate()'' or ''i18n()_ must be changed as follows: + + + -- old style: + translate("some_text", "Some Text") + translatef("some_format_text", "Some formatted Text: %d", 123) + + -- new style: + translate("Some Text") + translatef("Some formatted Text: %d", 123) + + +Likewise for templates: + + + + <%:some_text Some Text%> + + + <%:Some Text%> + + +If code must support both LuCI 0.9.x and 0.10.x versions, it is suggested to write the calls as follows: + + translate("Some Text", "Some Text") + + +An alternative is wrapping translate() calls into a helper function: + + function tr(key, alt) + return translate(key) or translate(alt) or alt + end + + +... which is used as follows: + + tr("some_key", "Some Text") + + +## Translation File Format + +Translation catalogs are now maintained in *.po format files. During build those get translated +into [*.lmo archives](http://luci.subsignal.org/trac/wiki/Documentation/LMO). + +LuCI ships a [utility script](http://luci.subsignal.org/trac/browser/luci/branches/luci-0.10/build/i18n-lua2po.pl) +in the build/ directory to convert old Lua translation files to the *.po format. The generated *.po files should +be placed in the appropriate subdirectories within the top po/ file in the LuCI source tree. + +### Components built within the LuCI tree + +If components using translations are built along with the LuCI tree, the newly added *.po file are automatically +compiled into *.lmo archives during the build process. In order to bundle the appropriate *.lmo files into the +corresponding *.ipk packages, component Makefiles must include a "PO" variable specifying the files to include. + +Given a module _applications/example/'' which uses ''po/en/example.po'' and ''po/en/example-extra.po_, +the _applications/example/Makefile_ must be changed as follows: + + + PO = example example-extra + + include ../../build/config.mk + include ../../build/module.mk + + +### Standalone components + +Authors who externally package LuCI components must prepare required *.lmo archives themselves. +To convert existing Lua based message catalogs to the *.po format, the build/i18n-lua2po.pl helper script can be used. +In order to convert *.po files into *.lmo files, the standalone "po2lmo" utility must be compiled as follows: + + + $ svn co http://svn.luci.subsignal.org/luci/branches/luci-0.10/libs/lmo + $ cd lmo/ + $ make + $ ./src/po2lmo translations.po translations.lmo + + +Note that at the time of writing, the utility program needs Lua headers installed on the system in order to compile properly. + +# CBI + +## Datatypes + +The server side UVL validation has been dropped to reduce space requirements on the target. +Instead it is possible to define datatypes for CBI widgets now: + + + opt = section:option(Value, "optname", "Title Text") + opt.datatype = "ip4addr" + + +User provided data is validated once on the frontend via JavaScript and on the server side prior to saving it. +A list of possible datatypes can be found in the [luci.cbi.datatypes](http://luci.subsignal.org/trac/browser/luci/branches/luci-0.10/libs/web/luasrc/cbi/datatypes.lua#L26) class. + +## Validation + +Server-sided validator function can now return custom error messages to provide better feedback on invalid input. + + + opt = section:option(Value, "optname", "Title Text") + + function opt.validate(self, value, section) + if input_is_valid(value) then + return value + else + return nil, "The value is invalid because ..." + end + end + + +## Tabs + +It is now possible to break up CBI sections into multiple tabs to better organize longer forms. +The TypedSection and NamedSection classes gained two new functions to define tabs, _tab()'' and ''taboption()_. + + + sct = map:section(TypedSection, "name", "type", "Title Text") + + sct:tab("general", "General Tab Title", "General Tab Description") + sct:tab("advanced", "Advanced Tab Title", "Advanced Tab Description") + + opt = sct:taboption("general", Value, "optname", "Title Text") + ... + + +The _tab()_ function is declares a new tab and takes up to three arguments: + * Internal name of the tab, must be unique within the section + * Title text of the tab + * Optional description text for the tab + +The _taboption()'' function wraps ''option()_ and assigns the option object to the given tab. +It takes up to five arguments: + + * Name of the tab to assign the option to + * Option type, e.g. Value or DynamicList + * Option name + * Title text of the option + * Optional description text of the option + +If tabs are used within a particular section, the _option()_ function must not be used, +doing so results in undefined behaviour. + +## Hooks + +The CBI gained support for _hooks_ which can be used to trigger additional actions during the +life-cycle of a map: + + + map = Map("config", "Title Text") + + function map.on_commit(self) + -- do something if the UCI configuration got committed + end + + +The following hooks are defined: + +|| on_cancel || The user pressed cancel within a multi-step Delegator or a SimpleForm instance || +|| on_init || The CBI is about to render the Map object || +|| on_parse || The CBI is about to read received HTTP form values || +|| on_save, on_before_save || The CBI is about to save modified UCI configuration files || +|| on_after_save || Modified UCI configuration files just got saved +|| on_before_commit || The CBI is about to commit the changes || +|| on_commit, on_after_commit, on_before_apply || Modified configurations got committed and the CBI is about to restart associated services || +|| on_apply, on_after_apply || All changes where completely applied (only works on Map instances with the apply_on_parse attribute set) || + +## Sortable Tables + +TypedSection instances which use the "cbi/tblsection" template may now use a new attribute _sortable_ to allow the user to reorder table rows. + + + sct = map:section(TypedSection, "name", "type", "Title Text") + sct.template = "cbi/tblsection" + sct.sortable = true + + ... + + +# JavaScript + +The LuCI 0.10 branch introduced a new JavaScript file _xhr.js_ which provides support routines for XMLHttpRequest operations. +Each theme must include this file in the area of the document for forms to work correctly. + +It should be included like this: + + + + \ No newline at end of file diff --git a/docs/Modules.md b/docs/Modules.md new file mode 100644 index 000000000..2897df948 --- /dev/null +++ b/docs/Modules.md @@ -0,0 +1,94 @@ +# Categories + +The LuCI modules are divided into several category directories, namely: +* applications (Single applications or plugins for other modules or applications) +* i18n (Translation files) +* libs (Independent libraries) +* modules (Collections of applications) +* themes (Frontend themes) + +Each module goes into a subdirectory of any of this category-directories. + +# Module directory +The contents of a module directory are as follows: + +## Makefile +This is the module's makefile. If the module just contains Lua sourcecode or resources then the following Makefile should suffice. + + include ../../build/config.mk + include ../../build/module.mk + + +If you have C(++) code in your module your Makefile should at least contain the following things. + + include ../../build/config.mk + include ../../build/gccconfig.mk + include ../../build/module.mk + + compile: + # Commands to compile and link your C-code + # and to install them under the dist/ hierarchy + + clean: luaclean + # Commands to clean your compiled objects + + + +## src +The *src* directory is reserved for C sourcecode. + +## luasrc +*luasrc* contains all Lua sourcecode files. These will automatically be stripped or compiled depending on the Make target and are installed in the LuCI installation directory. + +## lua +*lua* is equivalent to _luasrc_ but containing Lua files will be installed in the Lua document root. + +## htdocs +All files under *htdocs* will be copied to the document root of the target webserver. + +## root +All directories and files under *root* will be copied to the installation target as they are. + +## dist +*dist* is reserved for the builder to create a working installation tree that will represent the filesystem on the target machine. +*DO NOT* put any files there as they will get deleted. + +## ipkg +*ipkg* contains IPKG package control files, like _preinst'', ''posinst'', ''prerm'', ''postrm''. ''conffiles_. +See IPKG documentation for details. + + +# OpenWRT feed integration +If you want to add your module to the LuCI OpenWRT feed you have to add several sections to the contrib/package/luci/Makefile. + +For a Web UI applications this is: + +A package description: + + define Package/luci-app-YOURMODULE + $(call Package/luci/webtemplate) + DEPENDS+=+some-package +some-other-package + TITLE:=SHORT DESCRIPTION OF YOURMODULE + endef + + + +A package installation target: + + define Package/luci-app-YOURMODULE/install + $(call Package/luci/install/template,$(1),applications/YOURMODULE) + endef + + +A module build instruction: + + ifneq ($(CONFIG_PACKAGE_luci-app-YOURMODULE),) + PKG_SELECTED_MODULES+=applications/YOURMODULE + endif + + + +A build package call: + + $(eval $(call BuildPackage,luci-app-YOURMODULE)) + diff --git a/docs/ModulesHowTo.md b/docs/ModulesHowTo.md new file mode 100644 index 000000000..7efed83d6 --- /dev/null +++ b/docs/ModulesHowTo.md @@ -0,0 +1,153 @@ +*Note:* If you plan to integrate your module into LuCI, you should read the [wiki:Documentation/Modules Module Reference] before. + +This tutorial describes how to write your own modules for the LuCI WebUI. +For this tutorial we refer to your LuCI installation directory as *lucidir_' (/usr/lib/lua/luci if you are working with an installed version) and assume your LuCI installation is reachable through your webserver via '_/cgi-bin/luci*. + +If you are working with the development environment replace *lucidir_' with '''''/path/to/your/luci/checkout''/applications/myapplication/luasrc''' (this is a default empty module you can use for your experiments) and your LuCI installation can probably be reached via http://localhost:8080/luci/ after you ran '_make runhttpd*. + + + +# Show me the way (The dispatching process) +To write a module you need to understand the basics of the dispatching process in LuCI. +LuCI uses a dispatching tree that will be built by executing the index-Function of every available controller. +The CGI-environment variable *PATH_INFO* will be used as the path in this dispatching tree, e.g.: /cgi-bin/luci/foo/bar/baz +will be resolved to foo.bar.baz + +To register a function in the dispatching tree, you can use the *entry*-function of _luci.dispatcher_. entry takes 4 arguments (2 are optional): + + entry(path, target, title=nil, order=nil) + + +* *path* is a table that describes the position in the dispatching tree: For example a path of {"foo", "bar", "baz"} would insert your node in foo.bar.baz. +* *target* describes the action that will be taken when a user requests the node. There are several predefined ones of which the 3 most important (call, template, cbi) are described later on on this page +* *title* defines the title that will be visible to the user in the menu (optional) +* *order* is a number with which nodes on the same level will be sorted in the menu (optional) + +You can assign more attributes by manipulating the node table returned by the entry-function. A few example attributes: + +* *i18n* defines which translation file should be automatically loaded when the page gets requested +* *dependent* protects plugins to be called out of their context if a parent node is missing +* *leaf* stops parsing the request at this node and goes no further in the dispatching tree +* *sysauth* requires the user to authenticate with a given system user account + + +# It's all about names (Naming and the module file) +Now that you know the basics about dispatching, we can start writing modules. But before you have to choose the category and name of your new digital child. + +We assume you want to create a new application "myapp" with a module "mymodule". + +So you have to create a new subdirectory *_lucidir''/controller/myapp''' with a file '_mymodule.lua* with the following content: + + module("luci.controller.myapp.mymodule", package.seeall) + + function index() + + end + + +The first line is required for Lua to correctly identify the module and create its scope. +The index-Function will be used to register actions in the dispatching tree. + + + +# Teaching your new child (Actions) +So it is there and has a name but it has no actions. + +We assume you want to reuse your module myapp.mymodule that you begun in the last step. + + +## Actions +Reopen *_lucidir_/controller/myapp/mymodule.lua* and just add a function to it so that its content looks like this example: + + + module("luci.controller.myapp.mymodule", package.seeall) + + function index() + entry({"click", "here", "now"}, call("action_tryme"), "Click here", 10).dependent=false + end + + function action_tryme() + luci.http.prepare_content("text/plain") + luci.http.write("Haha, rebooting now...") + luci.sys.reboot() + end + + +And now type */cgi-bin/luci/click/here/now_' ('_[http://localhost:8080/luci/click/here/now]* if you are using the development environment) in your browser. + +You see these action functions simple have to be added to a dispatching entry. + +As you might or might not know: CGI specification requires you to send a Content-Type header before you can send your content. You will find several shortcuts (like the one used above) as well as redirecting functions in the module *luci.http* + +## Views +If you only want to show the user a text or some interesting familiy photos it may be enough to use a HTML-template. These templates can also include some Lua code but be aware that writing whole office suites by only using these templates might be called "dirty" by other developers. + +Now let's create a little template *_lucidir_/view/myapp-mymodule/helloworld.htm* with the content: + + + <%+header%> +

<%:Hello World%>

+ <%+footer%> + + + +and add the following line to the index-Function of your module file. + + entry({"my", "new", "template"}, template("myapp-mymodule/helloworld"), "Hello world", 20).dependent=false + + +Now type */cgi-bin/luci/my/new/template_' ('_[http://localhost:8080/luci/my/new/template]* if you are using the development environment) in your browser. + +You may notice those fancy <% %>-Tags, these are [wiki:Documentation/Templates|template markups] used by the LuCI template processor. +It is always good to include header and footer at the beginning and end of a template as those create the default design and menu. + +## CBI models +The CBI is one of the uber coolest features of LuCI. It creates a formular based user interface and saves its contents to a specific UCI config file. You only have to describe the structure of the configuration file in a CBI model file and Luci does the rest of the work. This includes generating, parsing and validating a XHTML form and reading and writing the UCI file. + +So let's be serious at least for this paragraph and create a real pratical example *_lucidir_/model/cbi/myapp-mymodule/netifaces.lua* with the following contents: + + + m = Map("network", "Network") -- We want to edit the uci config file /etc/config/network + + s = m:section(TypedSection, "interface", "Interfaces") -- Especially the "interface"-sections + s.addremove = true -- Allow the user to create and remove the interfaces + function s:filter(value) + return value ~= "loopback" and value -- Don't touch loopback + end + s:depends("proto", "static") -- Only show those with "static" + s:depends("proto", "dhcp") -- or "dhcp" as protocol and leave PPPoE and PPTP alone + + p = s:option(ListValue, "proto", "Protocol") -- Creates an element list (select box) + p:value("static", "static") -- Key and value pairs + p:value("dhcp", "DHCP") + p.default = "static" + + s:option(Value, "ifname", "interface", "the physical interface to be used") -- This will give a simple textbox + + s:option(Value, "ipaddr", translate("ip", "IP Address")) -- Ja, das ist eine i18n-Funktion ;-) + + s:option(Value, "netmask", "Netmask"):depends("proto", "static") -- You may remember this "depends" function from above + + mtu = s:option(Value, "mtu", "MTU") + mtu.optional = true -- This one is very optional + + dns = s:option(Value, "dns", "DNS-Server") + dns:depends("proto", "static") + dns.optional = true + function dns:validate(value) -- Now, that's nifty, eh? + return value:match("[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") -- Returns nil if it doesn't match otherwise returns match + end + + gw = s:option(Value, "gateway", "Gateway") + gw:depends("proto", "static") + gw.rmempty = true -- Remove entry if it is empty + + return m -- Returns the map + + +and of course don't forget to add something like this to your module's index-Function. + + entry({"admin", "network", "interfaces"}, cbi("myapp-mymodule/netifaces"), "Network interfaces", 30).dependent=false + + +There are many more features, see [wiki:Documentation/CBI the CBI reference] and the modules shipped with LuCI. diff --git a/docs/Templates.md b/docs/Templates.md new file mode 100644 index 000000000..adf019c01 --- /dev/null +++ b/docs/Templates.md @@ -0,0 +1,65 @@ +LuCI has a simple regex based template processor which parses HTML-files to Lua functions and allows to store precompiled template files. +The simplest form of a template is just an ordinary HTML-file. It will be printed out to the user as is. + +In LuCI every template is an object with an own scope. It can therefore be instantiated and each instance can has a different scope. As every template processor. LuCI supports several special markups. Those are enclosed in `<% %>`-Tags. + +By adding `-` (dash) right after the opening `<%` every whitespace before the markup will be stripped. Adding a `-` right before the closing `%>` will equivalently strip every whitespace behind the markup. + + +# Builtin functions and markups +## Including Lua code +*Markup:* + + <% code %> + + + +## Writing variables and function values +*Syntax:* + + <% write (value) %> + + +*Short-Markup:* + + <%=value%> + + +## Including templates +*Syntax:* + + <% include (templatename) %> + + +*Short-Markup:* + + <%+templatename%> + + + +## Translating +*Syntax:* + + <%= translate("Text to translate") %> + + + +*Short-Markup:* + + <%:Text to translate%> + + + +## Commenting +*Markup:* + + <%# comment %> + + +# Builtin constants +| Name | Value | +---------|--------- +|`REQUEST_URI`|The current URL (without server part)| +|`controller`|Path to the Luci main dispatcher| +|`resource`|Path to the resource directory| +|`media`|Path to the active theme directory| diff --git a/docs/ThemesHowTo.md b/docs/ThemesHowTo.md new file mode 100644 index 000000000..ae6f8e09c --- /dev/null +++ b/docs/ThemesHowTo.md @@ -0,0 +1,76 @@ +# HowTo: Create Themes +*Note:* You should read the [Module Reference](Modules.md) and the [Template Reference](Templates.md) before. + +We assume you want to call your new theme _mytheme_. Make sure you replace this by your module name every time this is mentionend in this Howto. + + + +# Creating the structure +At first create a new theme directory *themes/_mytheme_*. + +Create a _Makefile_ inside your theme directory with the following content: + + include ../../build/config.mk + include ../../build/module.mk + + +Create the following directory structure inside your theme directory. +* ipkg +* htdocs + * luci-static + * _mytheme_ +* luasrc + * view + * themes + * _mytheme_ +* root + * etc + * uci-defaults + + + +# Designing +Create two LuCI HTML-Templates named _header.htm'' and ''footer.htm'' under *luasrc/view/themes/''mytheme_*. +The _header.htm'' will be included at the beginning of each rendered page and the ''footer.htm_ at the end. +So your _header.htm'' will probably contain a DOCTYPE description, headers, the menu and layout of the page and the ''footer.htm_ will close all remaining open tags and may add a footer bar but hey that's your choice you are the designer ;-). + +Just make sure your _header.htm_ *begins* with the following lines: + + <% + require("luci.http").prepare_content("text/html") + -%> + + +This makes sure your content will be sent to the client with the right content type. Of course you can adapt _text/html_ to your needs. + + +Put any stylesheets, Javascripts, images, ... into *htdocs/luci-static/_mytheme_*. +You should refer to this directory in your header and footer templates as: _<%=media%>''. That means for a stylesheet *htdocs/luci-static/''mytheme_/cascade.css* you would write: + + + + + + +# Making the theme selectable +If you are done with your work there are two last steps to do. +To make your theme OpenWRT-capable and selectable on the settings page you should now create a file *root/etc/uci-defaults/luci-theme-_mytheme_* with the following contents: + + #!/bin/sh + uci batch <<-EOF + set luci.themes.MyTheme=/luci-static/mytheme + commit luci + EOF + + +and another file *ipkg/postinst* with the following content: + + #!/bin/sh + [ -n "${IPKG_INSTROOT}" ] || { + ( . /etc/uci-defaults/luci-theme-mytheme ) && rm -f /etc/uci-defaults/luci-theme-mytheme + } + + +This is some OpenWRT magic to correctly register the template with LuCI when it gets installed. + +That's all. Now send your theme to the LuCI developers to get it into the development repository - if you like. diff --git a/docs/api/index.html b/docs/api/index.html new file mode 100644 index 000000000..5e3f3c211 --- /dev/null +++ b/docs/api/index.html @@ -0,0 +1,426 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ + + +

Modules

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
luci.dispatcher
luci.http
luci.http.conditionals
luci.http.date
luci.http.mime
luci.i18n
luci.ip + LuCI IP calculation and netlink access library.
luci.ip.cidr + IP CIDR Object.
luci.json
luci.jsonc + LuCI JSON parsing and serialization library.
luci.jsonc.parser + LuCI JSON parser instance.
luci.model.ipkg
luci.model.uci
luci.rpcc
luci.rpcc.ruci
luci.sys
luci.sys.init + +LuCI system utilities / init related functions.
luci.sys.iptparser
luci.sys.net + +LuCI system utilities / network related functions.
luci.sys.process + +LuCI system utilities / process related functions.
luci.sys.user + +LuCI system utilities / user related functions.
luci.sys.wifi + +LuCI system utilities / wifi related functions.
luci.util
nixio + General POSIX IO library.
nixio.CHANGELOG + Changes and improvements.
nixio.CryptoHash + Cryptographical Hash and HMAC object.
nixio.File + Large File Object.
nixio.README + General Information.
nixio.Socket + Socket Object.
nixio.TLSContext + Transport Layer Security Context Object.
nixio.TLSSocket + TLS Socket Object.
nixio.UnifiedIO + Unified high-level I/O utility API for Files, Sockets and TLS-Sockets.
nixio.bin + Binary operations and conversion.
nixio.bit + Bitfield operators and mainpulation functions.
nixio.crypto + Cryptographical library.
nixio.fs + Low-level and high-level filesystem manipulation library.
+ + + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/luadoc.css b/docs/api/luadoc.css new file mode 100644 index 000000000..f9f974951 --- /dev/null +++ b/docs/api/luadoc.css @@ -0,0 +1,285 @@ +body { + margin-left: 1em; + margin-right: 1em; + font-family: arial, helvetica, geneva, sans-serif; + background-color:#ffffff; margin:0px; +} + +code { + font-family: "Andale Mono", monospace; +} + +tt { + font-family: "Andale Mono", monospace; +} + +body, td, th { font-size: 11pt; } + +h1, h2, h3, h4 { margin-left: 0em; } + +textarea, pre, tt { font-size:10pt; } +body, td, th { color:#000000; } +small { font-size:0.85em; } +h1 { font-size:1.5em; } +h2 { font-size:1.25em; } +h3 { font-size:1.15em; } +h4 { font-size:1.06em; } + +a:link { font-weight:bold; color: #004080; text-decoration: none; } +a:visited { font-weight:bold; color: #006699; text-decoration: none; } +a:link:hover { text-decoration:underline; } +hr { color:#cccccc } +img { border-width: 0px; } + + +h3 { padding: 1em 0 0.5em; } + +p { margin-left: 1em; } + +p.name { + font-family: "Andale Mono", monospace; + padding-top: 1em; + margin-left: 0em; +} + +blockquote { margin-left: 3em; } + +pre.example { + background-color: rgb(245, 245, 245); + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-style: solid; + border-right-style: solid; + border-bottom-style: solid; + border-left-style: solid; + border-top-color: silver; + border-right-color: silver; + border-bottom-color: silver; + border-left-color: silver; + padding: 1em; + margin-left: 1em; + margin-right: 1em; + font-family: "Andale Mono", monospace; + font-size: smaller; +} + + +hr { + margin-left: 0em; + background: #00007f; + border: 0px; + height: 1px; +} + +ul { list-style-type: disc; } + +table.index { border: 1px #00007f; } +table.index td { text-align: left; vertical-align: top; } +table.index ul { padding-top: 0em; margin-top: 0em; } + +table { + border: 1px solid black; + border-collapse: collapse; + margin: 1em auto; +} +th { + border: 1px solid black; + padding: 0.5em; +} +td { + border: 1px solid black; + padding: 0.5em; +} +div.header, div.footer { margin-left: 0em; } + +#container +{ + margin-left: 1em; + margin-right: 1em; + background-color: #f0f0f0; +} + +#product +{ + text-align: center; + border-bottom: 1px solid #cccccc; + background-color: #ffffff; +} + +#product big { + font-size: 2em; +} + +#product_logo +{ +} + +#product_name +{ +} + +#product_description +{ +} + +#main +{ + background-color: #f0f0f0; + border-left: 2px solid #cccccc; +} + +#navigation +{ + float: left; + width: 18em; + margin: 0; + vertical-align: top; + background-color: #f0f0f0; + overflow:visible; +} + +#navigation h1 { + background-color:#e7e7e7; + font-size:1.1em; + color:#000000; + text-align:left; + margin:0px; + padding:0.2em; + border-top:1px solid #dddddd; + border-bottom:1px solid #dddddd; +} + +#navigation ul +{ + font-size:1em; + list-style-type: none; + padding: 0; + margin: 1px; +} + +#navigation li +{ + text-indent: -1em; + margin: 0em 0em 0em 0.5em; + display: block; + padding: 3px 0px 0px 12px; +} + +#navigation li li a +{ + padding: 0px 3px 0px -1em; +} + +#content +{ + margin-left: 18em; + padding: 1em; + border-left: 2px solid #cccccc; + border-right: 2px solid #cccccc; + background-color: #ffffff; +} + +#about +{ + clear: both; + margin: 0; + padding: 5px; + border-top: 2px solid #cccccc; + background-color: #ffffff; +} + +@media print { + body { + font: 12pt "Times New Roman", "TimeNR", Times, serif; + } + a { font-weight:bold; color: #004080; text-decoration: underline; } + + #main { background-color: #ffffff; border-left: 0px; } + #container { margin-left: 2%; margin-right: 2%; background-color: #ffffff; } + + #content { margin-left: 0px; padding: 1em; border-left: 0px; border-right: 0px; background-color: #ffffff; } + + #navigation { display: none; + } + pre.example { + font-family: "Andale Mono", monospace; + font-size: 10pt; + page-break-inside: avoid; + } +} + +table.module_list td +{ + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.module_list td.name { background-color: #f0f0f0; } +table.module_list td.summary { width: 100%; } + +table.file_list +{ + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.file_list td +{ + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.file_list td.name { background-color: #f0f0f0; } +table.file_list td.summary { width: 100%; } + + +table.function_list +{ + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.function_list td +{ + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.function_list td.name { background-color: #f0f0f0; } +table.function_list td.summary { width: 100%; } + + +table.table_list +{ + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.table_list td +{ + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.table_list td.name { background-color: #f0f0f0; } +table.table_list td.summary { width: 100%; } + +dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.function dd {padding: 0.5em 0;} +dl.function h3 {margin: 0; font-size: medium;} + +dl.table dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.table dd {padding-bottom: 1em;} +dl.table h3 {padding: 0; margin: 0; font-size: medium;} + +#TODO: make module_list, file_list, function_list, table_list inherit from a list + diff --git a/docs/api/modules/luci.dispatcher.html b/docs/api/modules/luci.dispatcher.html new file mode 100644 index 000000000..ea33a5c70 --- /dev/null +++ b/docs/api/modules/luci.dispatcher.html @@ -0,0 +1,1145 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.dispatcher

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
_ () + +No-op function used to mark translation entries for menu labels.
alias (...) + +Create a redirect to another dispatching node.
arcombine (trg1, trg2) + +Create a combined dispatching target for non argv and argv requests.
assign (path, clone, title, order) + +Clone a node of the dispatching tree to another position.
build_url (...) + +Build the URL relative to the server webroot from given virtual path.
call (name, ...) + +Create a function-call dispatching target.
cbi (model) + +Create a CBI model dispatching target.
createindex () + +Generate the dispatching index using the native file-cache based strategy.
createtree () + +Create the dispatching tree from the index.
dispatch (request) + +Dispatches a LuCI virtual path.
entry (path, target, title, order) + +Create a new dispatching node and define common parameters.
error404 (message) + +Send a 404 error code and render the "error404" template if available.
error500 (message) + +Send a 500 error code and render the "error500" template if available.
firstchild () + +Alias the first (lowest order) page automatically + +
form (model) + +Create a CBI form model dispatching target.
get (...) + +Fetch or create a dispatching node without setting the target module or +enabling the node.
httpdispatch (request) + +Dispatch an HTTP request.
lookup (...) + +Lookup node in dispatching tree.
node (...) + +Fetch or create a new dispatching node.
node_childs (node) + +Return a sorted table of visible children within a given node +
node_visible (node) + +Check whether a dispatch node shall be visible +
rewrite (n, ...) + +Rewrite the first x path values of the request.
template (name) + +Create a template render dispatching target.
translate (text) + +Access the luci.i18n translate() api.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
_ ()
+
+ + +No-op function used to mark translation entries for menu labels. + +This function does not actually translate the given argument but +is used by build/i18n-scan.pl to find translatable entries. + + + + + + + + + + +
+ + + + +
alias (...)
+
+ + +Create a redirect to another dispatching node. + + + +

Parameters

+
    + +
  • + ...: Virtual path destination +
  • + +
+ + + + + + + + +
+ + + + +
arcombine (trg1, trg2)
+
+ + +Create a combined dispatching target for non argv and argv requests. + + + +

Parameters

+
    + +
  • + trg1: Overview Target +
  • + +
  • + trg2: Detail Target +
  • + +
+ + + + + + + + +
+ + + + +
assign (path, clone, title, order)
+
+ + +Clone a node of the dispatching tree to another position. + + + +

Parameters

+
    + +
  • + path: Virtual path destination +
  • + +
  • + clone: Virtual path source +
  • + +
  • + title: Destination node title (optional) +
  • + +
  • + order: Destination node order value (optional) +
  • + +
+ + + + + + +

Return value:

+Dispatching tree node + + + +
+ + + + +
build_url (...)
+
+ + +Build the URL relative to the server webroot from given virtual path. + + + +

Parameters

+
    + +
  • + ...: Virtual path +
  • + +
+ + + + + + +

Return value:

+Relative URL + + + +
+ + + + +
call (name, ...)
+
+ + +Create a function-call dispatching target. + + + +

Parameters

+
    + +
  • + name: Target function of local controller +
  • + +
  • + ...: Additional parameters passed to the function +
  • + +
+ + + + + + + + +
+ + + + +
cbi (model)
+
+ + +Create a CBI model dispatching target. + + + +

Parameters

+
    + +
  • + model: CBI model to be rendered +
  • + +
+ + + + + + + + +
+ + + + +
createindex ()
+
+ + +Generate the dispatching index using the native file-cache based strategy. + + + + + + + + + + + +
+ + + + +
createtree ()
+
+ + +Create the dispatching tree from the index. + +Build the index before if it does not exist yet. + + + + + + + + + + +
+ + + + +
dispatch (request)
+
+ + +Dispatches a LuCI virtual path. + + + +

Parameters

+
    + +
  • + request: Virtual path +
  • + +
+ + + + + + + + +
+ + + + +
entry (path, target, title, order)
+
+ + +Create a new dispatching node and define common parameters. + + + +

Parameters

+
    + +
  • + path: Virtual path +
  • + +
  • + target: Target function to call when dispatched. +
  • + +
  • + title: Destination node title +
  • + +
  • + order: Destination node order value (optional) +
  • + +
+ + + + + + +

Return value:

+Dispatching tree node + + + +
+ + + + +
error404 (message)
+
+ + +Send a 404 error code and render the "error404" template if available. + + + +

Parameters

+
    + +
  • + message: Custom error message (optional) +
  • + +
+ + + + + + +

Return value:

+false + + + +
+ + + + +
error500 (message)
+
+ + +Send a 500 error code and render the "error500" template if available. + + + +

Parameters

+
    + +
  • + message: Custom error message (optional)# +
  • + +
+ + + + + + +

Return value:

+false + + + +
+ + + + +
firstchild ()
+
+ + +Alias the first (lowest order) page automatically + + + + + + + + + + + +
+ + + + +
form (model)
+
+ + +Create a CBI form model dispatching target. + + + +

Parameters

+
    + +
  • + model: CBI form model tpo be rendered +
  • + +
+ + + + + + + + +
+ + + + +
get (...)
+
+ + +Fetch or create a dispatching node without setting the target module or +enabling the node. + + + +

Parameters

+
    + +
  • + ...: Virtual path +
  • + +
+ + + + + + +

Return value:

+Dispatching tree node + + + +
+ + + + +
httpdispatch (request)
+
+ + +Dispatch an HTTP request. + + + +

Parameters

+
    + +
  • + request: LuCI HTTP Request object +
  • + +
+ + + + + + + + +
+ + + + +
lookup (...)
+
+ + +Lookup node in dispatching tree. + + + +

Parameters

+
    + +
  • + ...: Virtual path +
  • + +
+ + + + + + +

Return value:

+Node object, canonical url or nil if the path was not found. + + + +
+ + + + +
node (...)
+
+ + +Fetch or create a new dispatching node. + + + +

Parameters

+
    + +
  • + ...: Virtual path +
  • + +
+ + + + + + +

Return value:

+Dispatching tree node + + + +
+ + + + +
node_childs (node)
+
+ + +Return a sorted table of visible children within a given node + + + +

Parameters

+
    + +
  • + node: Dispatch node +
  • + +
+ + + + + + +

Return value:

+Ordered table of child node names + + + +
+ + + + +
node_visible (node)
+
+ + +Check whether a dispatch node shall be visible + + + +

Parameters

+
    + +
  • + node: Dispatch node +
  • + +
+ + + + + + +

Return value:

+Boolean indicating whether the node should be visible + + + +
+ + + + +
rewrite (n, ...)
+
+ + +Rewrite the first x path values of the request. + + + +

Parameters

+
    + +
  • + n: Number of path values to replace +
  • + +
  • + ...: Virtual path to replace removed path values with +
  • + +
+ + + + + + + + +
+ + + + +
template (name)
+
+ + +Create a template render dispatching target. + + + +

Parameters

+
    + +
  • + name: Template to be rendered +
  • + +
+ + + + + + + + +
+ + + + +
translate (text)
+
+ + +Access the luci.i18n translate() api. + + + +

Parameters

+
    + +
  • + text: Text to translate +
  • + +
+ + + + + + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.http.conditionals.html b/docs/api/modules/luci.http.conditionals.html new file mode 100644 index 000000000..8c940bd3f --- /dev/null +++ b/docs/api/modules/luci.http.conditionals.html @@ -0,0 +1,552 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.http.conditionals

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
if_match (req, stat) + +14.24 / If-Match + +Test whether the given message object contains an "If-Match" header and +compare it against the given stat object.
if_modified_since (req, stat) + +14.25 / If-Modified-Since + +Test whether the given message object contains an "If-Modified-Since" header +and compare it against the given stat object.
if_none_match (req, stat) + +14.26 / If-None-Match + +Test whether the given message object contains an "If-None-Match" header and +compare it against the given stat object.
if_range (req, stat) + +14.27 / If-Range + +The If-Range header is currently not implemented due to the lack of general +byte range stuff in luci.http.protocol .
if_unmodified_since (req, stat) + +14.28 / If-Unmodified-Since + +Test whether the given message object contains an "If-Unmodified-Since" +header and compare it against the given stat object.
mk_etag (stat) + +Implement 14.19 / ETag.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
if_match (req, stat)
+
+ + +14.24 / If-Match + +Test whether the given message object contains an "If-Match" header and +compare it against the given stat object. + + +

Parameters

+
    + +
  • + req: HTTP request message object +
  • + +
  • + stat: A file.stat object +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating whether the precondition is ok + +
  2. Alternative status code if the precondition failed + +
+ + + +
+ + + + +
if_modified_since (req, stat)
+
+ + +14.25 / If-Modified-Since + +Test whether the given message object contains an "If-Modified-Since" header +and compare it against the given stat object. + + +

Parameters

+
    + +
  • + req: HTTP request message object +
  • + +
  • + stat: A file.stat object +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating whether the precondition is ok + +
  2. Alternative status code if the precondition failed + +
  3. Table containing extra HTTP headers if the precondition failed + +
+ + + +
+ + + + +
if_none_match (req, stat)
+
+ + +14.26 / If-None-Match + +Test whether the given message object contains an "If-None-Match" header and +compare it against the given stat object. + + +

Parameters

+
    + +
  • + req: HTTP request message object +
  • + +
  • + stat: A file.stat object +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating whether the precondition is ok + +
  2. Alternative status code if the precondition failed + +
  3. Table containing extra HTTP headers if the precondition failed + +
+ + + +
+ + + + +
if_range (req, stat)
+
+ + +14.27 / If-Range + +The If-Range header is currently not implemented due to the lack of general +byte range stuff in luci.http.protocol . This function will always return +false, 412 to indicate a failed precondition. + + +

Parameters

+
    + +
  • + req: HTTP request message object +
  • + +
  • + stat: A file.stat object +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating whether the precondition is ok + +
  2. Alternative status code if the precondition failed + +
+ + + +
+ + + + +
if_unmodified_since (req, stat)
+
+ + +14.28 / If-Unmodified-Since + +Test whether the given message object contains an "If-Unmodified-Since" +header and compare it against the given stat object. + + +

Parameters

+
    + +
  • + req: HTTP request message object +
  • + +
  • + stat: A file.stat object +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating whether the precondition is ok + +
  2. Alternative status code if the precondition failed + +
+ + + +
+ + + + +
mk_etag (stat)
+
+ + +Implement 14.19 / ETag. + + + +

Parameters

+
    + +
  • + stat: A file.stat structure +
  • + +
+ + + + + + +

Return value:

+String containing the generated tag suitable for ETag headers + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.http.date.html b/docs/api/modules/luci.http.date.html new file mode 100644 index 000000000..1ec5beb8b --- /dev/null +++ b/docs/api/modules/luci.http.date.html @@ -0,0 +1,406 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.http.date

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + +
compare (d1, d2) + +Compare two dates which can either be unix epoch times or HTTP date strings.
to_http (time) + +Convert the given unix epoch time to valid HTTP date string.
to_unix (data) + +Parse given HTTP date string and convert it to unix epoch time.
tz_offset (tz) + +Return the time offset in seconds between the UTC and given time zone.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
compare (d1, d2)
+
+ + +Compare two dates which can either be unix epoch times or HTTP date strings. + + + +

Parameters

+
    + +
  • + d1: The first date or epoch time to compare +
  • + +
  • + d2: The first date or epoch time to compare +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. -1 - if d1 is lower then d2 + +
  2. 0 - if both dates are equal + +
  3. 1 - if d1 is higher then d2 + +
+ + + +
+ + + + +
to_http (time)
+
+ + +Convert the given unix epoch time to valid HTTP date string. + + + +

Parameters

+
    + +
  • + time: Unix epoch time +
  • + +
+ + + + + + +

Return value:

+String containing the formatted date + + + +
+ + + + +
to_unix (data)
+
+ + +Parse given HTTP date string and convert it to unix epoch time. + + + +

Parameters

+
    + +
  • + data: String containing the date +
  • + +
+ + + + + + +

Return value:

+Unix epoch time + + + +
+ + + + +
tz_offset (tz)
+
+ + +Return the time offset in seconds between the UTC and given time zone. + + + +

Parameters

+
    + +
  • + tz: Symbolic or numeric timezone specifier +
  • + +
+ + + + + + +

Return value:

+Time offset to UTC in seconds + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.http.html b/docs/api/modules/luci.http.html new file mode 100644 index 000000000..473172784 --- /dev/null +++ b/docs/api/modules/luci.http.html @@ -0,0 +1,1267 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.http

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
build_querystring (table) + +Create a querystring out of a table of key - value pairs.
close () + +Close the HTTP-Connection.
content () + +Return the request content if the request was of unknown type.
formvalue (name, noparse) + +Get a certain HTTP input value or a table of all input values.
formvaluetable (prefix) + +Get a table of all HTTP input values with a certain prefix.
getcookie (name) + +Get the value of a certain HTTP-Cookie.
getenv (name) + +Get the value of a certain HTTP environment variable +or the environment table itself.
header (key, value) + +Send a HTTP-Header.
mimedecode_message_body (src, msg, filecb) + +Decode a mime encoded http message body with multipart/form-data Content-Type.
parse_message_body (src, msg, filecb) + +Try to extract and decode a http message body from the given ltn12 source.
prepare_content (mime) + +Set the mime type of following content data.
redirect (url) + +Redirects the client to a new URL and closes the connection.
setfilehandler (callback) + +Set a handler function for incoming user file uploads.
source () + +Get the RAW HTTP input source +
splice (fp, size) + +Splice data from a filedescriptor to the client.
status (code, message) + +Set the HTTP status code and status message.
urldecode (str, no_plus) + +Return the URL-decoded equivalent of a string.
urldecode_message_body (src, msg) + +Decode an urlencoded http message body with application/x-www-urlencoded +Content-Type.
urldecode_params (url, tbl) + +Extract and split urlencoded data pairs, separated bei either "&" or ";" +from given url or string.
urlencode (str) + +Return the URL-encoded equivalent of a string.
urlencode_params (tbl) + +Encode each key-value-pair in given table to x-www-urlencoded format, +separated by "&".
write (content, src_err) + +Send a chunk of content data to the client.
write_json (data) + +Send the given data as JSON encoded string.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
build_querystring (table)
+
+ + +Create a querystring out of a table of key - value pairs. + + + +

Parameters

+
    + +
  • + table: Query string source table +
  • + +
+ + + + + + +

Return value:

+Encoded HTTP query string + + + +
+ + + + +
close ()
+
+ + +Close the HTTP-Connection. + + + + + + + + + + +
+ + + + +
content ()
+
+ + +Return the request content if the request was of unknown type. + + + + + + + + +

Return values:

+
    + +
  1. HTTP request body + +
  2. 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 +
  • + +
+ + + + + + + + +
+ + + + +
mimedecode_message_body (src, msg, filecb)
+
+ + +Decode a mime encoded http message body with multipart/form-data Content-Type. + +Stores all extracted data associated with its parameter name +in the params table within the given message object. Multiple parameter +values are stored as tables, ordinary ones as strings. + +If an optional file callback function is given then it is fed with the +file contents chunk by chunk and only the extracted file name is stored +within the params table. The callback function will be called subsequently +with three arguments: + o Table containing decoded (name, file) and raw (headers) mime header data + o String value containing a chunk of the file data + o Boolean which indicates whether the current chunk is the last one (eof) + + + +

Parameters

+
    + +
  • + src: Ltn12 source function +
  • + +
  • + msg: HTTP message object +
  • + +
  • + filecb: File callback function (optional) +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Value indicating successful operation (not nil means "ok") + +
  2. String containing the error if unsuccessful + +
+ + + +

See also:

+ + +
+ + + + +
parse_message_body (src, msg, filecb)
+
+ + +Try to extract and decode a http message body from the given ltn12 source. +This function will examine the Content-Type within the given message object +to select the appropriate content decoder. + +Currently the application/x-www-urlencoded and application/form-data +mime types are supported. If the encountered content encoding can't be +handled then the whole message body will be stored unaltered as "content" +property within the given message object. + + + +

Parameters

+
    + +
  • + src: Ltn12 source function +
  • + +
  • + msg: HTTP message object +
  • + +
  • + filecb: File data callback (optional, see mimedecode_message_body()) +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Value indicating successful operation (not nil means "ok") + +
  2. String containing the error if unsuccessful + +
+ + + +

See also:

+ + +
+ + + + +
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 +
  • + +
+ + + + + + + + +
+ + + + +
urldecode (str, no_plus)
+
+ + +Return the URL-decoded equivalent of a string. + + + +

Parameters

+
    + +
  • + str: URL-encoded string +
  • + +
  • + no_plus: Don't decode + to " " +
  • + +
+ + + + + + +

Return value:

+URL-decoded string + + + +

See also:

+ + +
+ + + + +
urldecode_message_body (src, msg)
+
+ + +Decode an urlencoded http message body with application/x-www-urlencoded +Content-Type. + +Stores all extracted data associated with its parameter name in the params +table within the given message object. Multiple parameter values are stored +as tables, ordinary ones as strings. + + + +

Parameters

+
    + +
  • + src: Ltn12 source function +
  • + +
  • + msg: HTTP message object +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Value indicating successful operation (not nil means "ok") + +
  2. String containing the error if unsuccessful + +
+ + + +

See also:

+ + +
+ + + + +
urldecode_params (url, tbl)
+
+ + +Extract and split urlencoded data pairs, separated bei either "&" or ";" +from given url or string. Returns a table with urldecoded values. + +Simple parameters are stored as string values associated with the parameter +name within the table. Parameters with multiple values are stored as array +containing the corresponding values. + + + +

Parameters

+
    + +
  • + url: The url or string which contains x-www-urlencoded form data +
  • + +
  • + tbl: Use the given table for storing values (optional) +
  • + +
+ + + + + + +

Return value:

+Table containing the urldecoded parameters + + + +

See also:

+ + +
+ + + + +
urlencode (str)
+
+ + +Return the URL-encoded equivalent of a string. + + + +

Parameters

+
    + +
  • + str: Source string +
  • + +
+ + + + + + +

Return value:

+URL-encoded string + + + +

See also:

+ + +
+ + + + +
urlencode_params (tbl)
+
+ + +Encode each key-value-pair in given table to x-www-urlencoded format, +separated by "&". + +Tables are encoded as parameters with multiple values by repeating the +parameter name with each value. + + + +

Parameters

+
    + +
  • + tbl: Table with the values +
  • + +
+ + + + + + +

Return value:

+String containing encoded values + + + +

See also:

+ + +
+ + + + +
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. + + + +

Parameters

+
    + +
  • + content: Content chunk +
  • + +
  • + src_err: Error object from source (optional) +
  • + +
+ + + + + + + + +

See also:

+ + +
+ + + + +
write_json (data)
+
+ + +Send the given data as JSON encoded string. + + + +

Parameters

+
    + +
  • + data: Data to send +
  • + +
+ + + + + + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.http.mime.html b/docs/api/modules/luci.http.mime.html new file mode 100644 index 000000000..85eaf53ab --- /dev/null +++ b/docs/api/modules/luci.http.mime.html @@ -0,0 +1,322 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.http.mime

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + +
to_ext (mimetype) + +Return corresponding extension for a given mime type or nil if the + +given mime-type is unknown.
to_mime (filename) + +Extract extension from a filename and return corresponding mime-type or + +"application/octet-stream" if the extension is unknown.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
to_ext (mimetype)
+
+ + +Return corresponding extension for a given mime type or nil if the + +given mime-type is unknown. + + +

Parameters

+
    + +
  • + mimetype: The mimetype to retrieve the extension from +
  • + +
+ + + + + + +

Return value:

+String with the extension or nil for unknown type + + + +
+ + + + +
to_mime (filename)
+
+ + +Extract extension from a filename and return corresponding mime-type or + +"application/octet-stream" if the extension is unknown. + + +

Parameters

+
    + +
  • + filename: The filename for which the mime type is guessed +
  • + +
+ + + + + + +

Return value:

+String containign the determined mime type + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.i18n.html b/docs/api/modules/luci.i18n.html new file mode 100644 index 000000000..0f315bebd --- /dev/null +++ b/docs/api/modules/luci.i18n.html @@ -0,0 +1,391 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.i18n

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + +
dump () + +Return all currently loaded translation strings as a key-value table.
setlanguage (lang) + +Set the context default translation language.
translate (key) + +Return the translated value for a specific translation key.
translatef (key, ...) + +Return the translated value for a specific translation key and use it as sprintf pattern.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
dump ()
+
+ + +Return all currently loaded translation strings as a key-value table. The key is the +hexadecimal representation of the translation key while the value is the translated +text content. + + + + + + + + +

Return value:

+Key-value translation string table. + + + +
+ + + + +
setlanguage (lang)
+
+ + +Set the context default translation language. + + + +

Parameters

+
    + +
  • + lang: An IETF/BCP 47 language tag or ISO3166 country code, e.g. "en-US" or "de" +
  • + +
+ + + + + + +

Return value:

+The effective loaded language, e.g. "en" for "en-US" - or nil on failure + + + +
+ + + + +
translate (key)
+
+ + +Return the translated value for a specific translation key. + + + +

Parameters

+
    + +
  • + key: Default translation text +
  • + +
+ + + + + + +

Return value:

+Translated string + + + +
+ + + + +
translatef (key, ...)
+
+ + +Return the translated value for a specific translation key and use it as sprintf pattern. + + + +

Parameters

+
    + +
  • + key: Default translation text +
  • + +
  • + ...: Format parameters +
  • + +
+ + + + + + +

Return value:

+Translated and formatted string + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.ip.cidr.html b/docs/api/modules/luci.ip.cidr.html new file mode 100644 index 000000000..ae6c61dc5 --- /dev/null +++ b/docs/api/modules/luci.ip.cidr.html @@ -0,0 +1,1511 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance luci.ip.cidr

+ +

+ IP CIDR Object. + Represents an IPv4 or IPv6 address range.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
cidr:is4 () + +Checks whether the CIDR instance is an IPv4 address range +
cidr:is4rfc1918 () + +Checks whether the CIDR instance is within the private RFC1918 address space +
cidr:is4linklocal () + +Checks whether the CIDR instance is an IPv4 link local (Zeroconf) address +
cidr:is6 () + +Checks whether the CIDR instance is an IPv6 address range +
cidr:is6linklocal () + +Checks whether the CIDR instance is an IPv6 link local address +
cidr:is6mapped4 () + +Checks whether the CIDR instance is an IPv6 mapped IPv4 address +
cidr:ismac () + +Checks whether the CIDR instance is an ethernet MAC address range +
cidr:ismaclocal () + +Checks whether the CIDR instance is a locally administered (LAA) MAC address +
cidr:ismacmcast () + +Checks whether the CIDR instance is a multicast MAC address +
cidr:lower (addr) + +Checks whether this CIDR instance is lower than the given argument.
cidr:higher (addr) + +Checks whether this CIDR instance is higher than the given argument.
cidr:equal (addr) + +Checks whether this CIDR instance is equal to the given argument.
cidr:prefix (mask) + +Get or set prefix size of CIDR instance.
cidr:network (mask) + +Derive network address of CIDR instance.
cidr:host () + +Derive host address of CIDR instance.
cidr:mask (mask) + +Derive netmask of CIDR instance.
cidr:broadcast (mask) + +Derive broadcast address of CIDR instance.
cidr:mapped4 () + +Derive mapped IPv4 address of CIDR instance.
cidr:tomac () + +Derive MAC address of IPv6 link local CIDR instance.
cidr:tolinklocal () + +Derive IPv6 link local address from MAC address CIDR instance.
cidr:contains (addr) + +Test whether CIDR contains given range.
cidr:add (amount, inplace) + +Add given amount to CIDR instance.
cidr:sub (amount, inplace) + +Subtract given amount from CIDR instance.
cidr:minhost () + +Calculate the lowest possible host address within this CIDR instance.
cidr:maxhost () + +Calculate the highest possible host address within this CIDR instance.
cidr:string () + +Convert CIDR instance into string representation.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
cidr:is4 ()
+
+ + +Checks whether the CIDR instance is an IPv4 address range + + + + + + + + +

Return value:

+true if the CIDR is an IPv4 range, else false + + + +

See also:

+ + +
+ + + + +
cidr:is4rfc1918 ()
+
+ + +Checks whether the CIDR instance is within the private RFC1918 address space + + + + + + +

Usage:

+
local addr = luci.ip.new("192.168.45.2/24") 
+if addr:is4rfc1918() then 
+	print("Is a private address") 
+end
+ + + +

Return value:

+true if the entire range of this CIDR lies within one of + the ranges 10.0.0.0-10.255.255.255, + 172.16.0.0-172.31.0.0 or + 192.168.0.0-192.168.255.255, else false. + + + +
+ + + + +
cidr:is4linklocal ()
+
+ + +Checks whether the CIDR instance is an IPv4 link local (Zeroconf) address + + + + + + +

Usage:

+
local addr = luci.ip.new("169.254.34.125") 
+if addr:is4linklocal() then 
+	print("Is a zeroconf address") 
+end
+ + + +

Return value:

+true if the entire range of this CIDR lies within the range + the range 169.254.0.0-169.254.255.255, else false. + + + +
+ + + + +
cidr:is6 ()
+
+ + +Checks whether the CIDR instance is an IPv6 address range + + + + + + + + +

Return value:

+true if the CIDR is an IPv6 range, else false + + + +

See also:

+ + +
+ + + + +
cidr:is6linklocal ()
+
+ + +Checks whether the CIDR instance is an IPv6 link local address + + + + + + +

Usage:

+
local addr = luci.ip.new("fe92:53a:3216:af01:221:63ff:fe75:aa17/64") 
+if addr:is6linklocal() then 
+	print("Is a linklocal address") 
+end
+ + + +

Return value:

+true if the entire range of this CIDR lies within the range + the fe80::/10 range, else false. + + + +
+ + + + +
cidr:is6mapped4 ()
+
+ + +Checks whether the CIDR instance is an IPv6 mapped IPv4 address + + + + + + +

Usage:

+
local addr = luci.ip.new("::ffff:192.168.1.1") 
+if addr:is6mapped4() then 
+	print("Is a mapped IPv4 address") 
+end
+ + + +

Return value:

+true if the address is an IPv6 mapped IPv4 address in the + form ::ffff:1.2.3.4. + + + +
+ + + + +
cidr:ismac ()
+
+ + +Checks whether the CIDR instance is an ethernet MAC address range + + + + + + + + +

Return value:

+true if the CIDR is a MAC address range, else false + + + +

See also:

+ + +
+ + + + +
cidr:ismaclocal ()
+
+ + +Checks whether the CIDR instance is a locally administered (LAA) MAC address + + + + + + +

Usage:

+
local mac = luci.ip.new("02:C0:FF:EE:00:01") 
+if mac:ismaclocal() then 
+  print("Is an LAA MAC address") 
+end
+ + + +

Return value:

+true if the MAC address sets the locally administered bit. + + + +
+ + + + +
cidr:ismacmcast ()
+
+ + +Checks whether the CIDR instance is a multicast MAC address + + + + + + +

Usage:

+
local mac = luci.ip.new("01:00:5E:7F:00:10") 
+if addr:ismacmcast() then 
+  print("Is a multicast MAC address") 
+end
+ + + +

Return value:

+true if the MAC address sets the multicast bit. + + + +
+ + + + +
cidr:lower (addr)
+
+ + +Checks whether this CIDR instance is lower than the given argument. +The comparisation follows these rules: +
  • An IPv4 address is always lower than an IPv6 address and IPv6 addresses +are considered lower than MAC addresses
  • +
  • Prefix sizes are ignored
+ + + +

Parameters

+
    + +
  • + addr: A luci.ip.cidr instance or a string convertible by + luci.ip.new() to compare against. +
  • + +
+ + + + +

Usage:

+
local addr = luci.ip.new("192.168.1.1") 
+print(addr:lower(addr)) -- false 
+print(addr:lower("10.10.10.10/24")) -- false 
+print(addr:lower(luci.ip.new("::1"))) -- true 
+print(addr:lower(luci.ip.new("192.168.200.1"))) -- true 
+print(addr:lower(luci.ip.new("00:14:22:01:23:45"))) -- true
+ + + +

Return value:

+true if this CIDR is lower than the given address, + else false. + + + +

See also:

+ + +
+ + + + +
cidr:higher (addr)
+
+ + +Checks whether this CIDR instance is higher than the given argument. +The comparisation follows these rules: +
  • An IPv4 address is always lower than an IPv6 address and IPv6 addresses +are considered lower than MAC addresses
  • +
  • Prefix sizes are ignored
+ + + +

Parameters

+
    + +
  • + addr: A luci.ip.cidr instance or a string convertible by + luci.ip.new() to compare against. +
  • + +
+ + + + +

Usage:

+
local addr = luci.ip.new("192.168.1.1") 
+print(addr:higher(addr)) -- false 
+print(addr:higher("10.10.10.10/24")) -- true 
+print(addr:higher(luci.ip.new("::1"))) -- false 
+print(addr:higher(luci.ip.new("192.168.200.1"))) -- false 
+print(addr:higher(luci.ip.new("00:14:22:01:23:45"))) -- false
+ + + +

Return value:

+true if this CIDR is higher than the given address, + else false. + + + +

See also:

+ + +
+ + + + +
cidr:equal (addr)
+
+ + +Checks whether this CIDR instance is equal to the given argument. + + + +

Parameters

+
    + +
  • + addr: A luci.ip.cidr instance or a string convertible by + luci.ip.new() to compare against. +
  • + +
+ + + + +

Usage:

+
local addr = luci.ip.new("192.168.1.1") 
+print(addr:equal(addr)) -- true 
+print(addr:equal("192.168.1.1")) -- true 
+print(addr:equal(luci.ip.new("::1"))) -- false 
+ 
+local addr6 = luci.ip.new("::1") 
+print(addr6:equal("0:0:0:0:0:0:0:1/64")) -- true 
+print(addr6:equal(luci.ip.new("fe80::221:63ff:fe75:aa17"))) -- false 
+ 
+local mac = luci.ip.new("00:14:22:01:23:45") 
+print(mac:equal("0:14:22:1:23:45")) -- true 
+print(mac:equal(luci.ip.new("01:23:45:67:89:AB")) -- false
+ + + +

Return value:

+true if this CIDR is equal to the given address, + else false. + + + +

See also:

+ + +
+ + + + +
cidr:prefix (mask)
+
+ + +Get or set prefix size of CIDR instance. +If the optional mask parameter is given, the prefix size of this CIDR is altered +else the current prefix size is returned. + + + +

Parameters

+
    + +
  • + mask: Either a number containing the number of bits (0..32 + for IPv4, 0..128 for IPv6 or 0..48 for MAC addresses) or a string + containing a valid netmask (optional) +
  • + +
+ + + + +

Usage:

+
local range = luci.ip.new("192.168.1.1/255.255.255.0") 
+print(range:prefix()) -- 24 
+ 
+range:prefix(16) 
+print(range:prefix()) -- 16 
+ 
+range:prefix("255.255.255.255") 
+print(range:prefix()) -- 32
+ + + +

Return value:

+Bit count of the current prefix size + + + +
+ + + + +
cidr:network (mask)
+
+ + +Derive network address of CIDR instance. + +Returns a new CIDR instance representing the network address of this instance +with all host parts masked out. The used prefix size can be overridden by the +optional mask parameter. + + + +

Parameters

+
    + +
  • + mask: Either a number containing the number of bits (0..32 + for IPv4, 0..128 for IPv6 or 0..48 for MAC addresses) or a string + containing a valid netmask (optional) +
  • + +
+ + + + +

Usage:

+
local range = luci.ip.new("192.168.62.243/255.255.0.0") 
+print(range:network())                -- "192.168.0.0" 
+print(range:network(24))              -- "192.168.62.0" 
+print(range:network("255.255.255.0")) -- "192.168.62.0" 
+ 
+local range6 = luci.ip.new("fd9b:62b3:9cc5:0:221:63ff:fe75:aa17/64") 
+print(range6:network())               -- "fd9b:62b3:9cc5::"
+ + + +

Return value:

+CIDR instance representing the network address + + + +
+ + + + +
cidr:host ()
+
+ + +Derive host address of CIDR instance. + +This function essentially constructs a copy of this CIDR with the prefix size +set to 32 for IPv4, 128 for IPv6 or 48 for MAC addresses. + + + + + + +

Usage:

+
local range = luci.ip.new("172.19.37.45/16") 
+print(range)        -- "172.19.37.45/16" 
+print(range:host()) -- "172.19.37.45"
+ + + +

Return value:

+CIDR instance representing the host address + + + +
+ + + + +
cidr:mask (mask)
+
+ + +Derive netmask of CIDR instance. + +Constructs a CIDR instance representing the netmask of this instance. The used +prefix size can be overridden by the optional mask parameter. + + + +

Parameters

+
    + +
  • + mask: Either a number containing the number of bits (0..32 + for IPv4, 0..128 for IPv6 or 0..48 for MAC addresses) or a string + containing a valid netmask (optional) +
  • + +
+ + + + +

Usage:

+
local range = luci.ip.new("172.19.37.45/16") 
+print(range:mask())            -- "255.255.0.0" 
+print(range:mask(24))          -- "255.255.255.0" 
+print(range:mask("255.0.0.0")) -- "255.0.0.0"
+ + + +

Return value:

+CIDR instance representing the netmask + + + +
+ + + + +
cidr:broadcast (mask)
+
+ + +Derive broadcast address of CIDR instance. + +Constructs a CIDR instance representing the broadcast address of this instance. +The used prefix size can be overridden by the optional mask parameter. + +This function has no effect on IPv6 or MAC address instances, it will return +nothing in this case. + + + +

Parameters

+
    + +
  • + mask: Either a number containing the number of bits (0..32 for IPv4) or + a string containing a valid netmask (optional) +
  • + +
+ + + + +

Usage:

+
local range = luci.ip.new("172.19.37.45/16") 
+print(range:broadcast())            -- "172.19.255.255" 
+print(range:broadcast(24))          -- "172.19.37.255" 
+print(range:broadcast("255.0.0.0")) -- "172.255.255.255"
+ + + +

Return value:

+Return a new CIDR instance representing the broadcast address if this + instance is an IPv4 range, else return nothing. + + + +
+ + + + +
cidr:mapped4 ()
+
+ + +Derive mapped IPv4 address of CIDR instance. + +Constructs a CIDR instance representing the IPv4 address of the IPv6 mapped +IPv4 address in this instance. + +This function has no effect on IPv4 instances, MAC address instances or IPv6 +instances which are not a mapped address, it will return nothing in this case. + + + + + + +

Usage:

+
local addr = luci.ip.new("::ffff:172.16.19.1") 
+print(addr:mapped4()) -- "172.16.19.1"
+ + + +

Return value:

+Return a new CIDR instance representing the IPv4 address if this + instance is an IPv6 mapped IPv4 address, else return nothing. + + + +
+ + + + +
cidr:tomac ()
+
+ + +Derive MAC address of IPv6 link local CIDR instance. + +Constructs a CIDR instance representing the MAC address contained in the IPv6 +link local address of this instance. + +This function has no effect on IPv4 instances, MAC address instances or IPv6 +instances which are not a link local address, it will return nothing in this +case. + + + + + + +

Usage:

+
local addr = luci.ip.new("fe80::6666:b3ff:fe47:e1b9") 
+print(addr:tomac()) -- "64:66:B3:47:E1:B9"
+ + + +

Return value:

+Return a new CIDR instance representing the MAC address if this + instance is an IPv6 link local address, else return nothing. + + + +
+ + + + +
cidr:tolinklocal ()
+
+ + +Derive IPv6 link local address from MAC address CIDR instance. + +Constructs a CIDR instance representing the IPv6 link local address of the +MAC address represented by this instance. + +This function has no effect on IPv4 instances or IPv6 instances, it will return +nothing in this case. + + + + + + +

Usage:

+
local mac = luci.ip.new("64:66:B3:47:E1:B9") 
+print(mac:tolinklocal()) -- "fe80::6666:b3ff:fe47:e1b9"
+ + + +

Return value:

+Return a new CIDR instance representing the IPv6 link local address. + + + +
+ + + + +
cidr:contains (addr)
+
+ + +Test whether CIDR contains given range. + + + +

Parameters

+
    + +
  • + addr: A luci.ip.cidr instance or a string convertible by + luci.ip.new() to test. +
  • + +
+ + + + +

Usage:

+
local range = luci.ip.new("10.24.0.0/255.255.0.0") 
+print(range:contains("10.24.5.1"))  -- true 
+print(range:contains("::1"))        -- false 
+print(range:contains("10.0.0.0/8")) -- false 
+ 
+local range6 = luci.ip.new("fe80::/10") 
+print(range6:contains("fe80::221:63f:fe75:aa17/64"))         -- true 
+print(range6:contains("fd9b:6b3:c5:0:221:63f:fe75:aa17/64")) -- false 
+ 
+local intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00/24") 
+print(intel_macs:contains("C0:B6:F9:A3:C:11"))  -- true 
+print(intel_macs:contains("64:66:B3:47:E1:B9")) -- false
+ + + +

Return value:

+true if this instance fully contains the given address else + false. + + + +
+ + + + +
cidr:add (amount, inplace)
+
+ + +Add given amount to CIDR instance. If the result would overflow the maximum +address space, the result is set to the highest possible address. + + + +

Parameters

+
    + +
  • + amount: A numeric value between 0 and 0xFFFFFFFF, a + luci.ip.cidr instance or a string convertible by + luci.ip.new(). +
  • + +
  • + inplace: If true, modify this instance instead of returning + a new derived CIDR instance. +
  • + +
+ + + + +

Usage:

+
local addr = luci.ip.new("192.168.1.1/24") 
+print(addr:add(250))           -- "192.168.1.251/24" 
+print(addr:add("0.0.99.0"))    -- "192.168.100.1/24" 
+ 
+addr:add(256, true)            -- true 
+print(addr)                    -- "192.168.2.1/24 
+ 
+addr:add("255.0.0.0", true)    -- false (overflow) 
+print(addr)                    -- "255.255.255.255/24 
+ 
+local addr6 = luci.ip.new("fe80::221:63f:fe75:aa17/64") 
+print(addr6:add(256))          -- "fe80::221:63f:fe75:ab17/64" 
+print(addr6:add("::ffff:0"))   -- "fe80::221:640:fe74:aa17/64" 
+ 
+addr6:add(256, true)           -- true 
+print(addr6)                   -- "fe80::221:63f:fe75:ab17/64 
+ 
+addr6:add("ffff::", true)      -- false (overflow) 
+print(addr6)                   -- "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/64" 
+ 
+local mac = luci.ip.new("00:14:22:01:23:45") 
+print(mac:add(256))            -- "00:14:22:01:24:45" 
+print(mac:add("0:0:0:0:FF:0")  -- "00:14:22:02:22:45" 
+ 
+mac:add(256, true)             -- true 
+print(mac)                     -- "00:14:22:01:24:45" 
+ 
+mac:add("FF:FF:0:0:0:0", true) -- false (overflow) 
+print(mac)                     -- "FF:FF:FF:FF:FF:FF"
+ + + +

Return value:

+
    +
  • When adding inplace: Return true if the addition succeeded + or false when the addition overflowed.
  • +
  • When deriving new CIDR: Return new instance representing the value of + this instance plus the added amount or the highest possible address if + the addition overflowed the available address space.
+ + + +
+ + + + +
cidr:sub (amount, inplace)
+
+ + +Subtract given amount from CIDR instance. If the result would under, the lowest +possible address is returned. + + + +

Parameters

+
    + +
  • + amount: A numeric value between 0 and 0xFFFFFFFF, a + luci.ip.cidr instance or a string convertible by + luci.ip.new(). +
  • + +
  • + inplace: If true, modify this instance instead of returning + a new derived CIDR instance. +
  • + +
+ + + + +

Usage:

+
local addr = luci.ip.new("192.168.1.1/24") 
+print(addr:sub(256))         -- "192.168.0.1/24" 
+print(addr:sub("0.168.0.0")) -- "192.0.1.1/24" 
+ 
+addr:sub(256, true)          -- true 
+print(addr)                  -- "192.168.0.1/24 
+ 
+addr:sub("255.0.0.0", true)  -- false (underflow) 
+print(addr)                  -- "0.0.0.0/24 
+ 
+local addr6 = luci.ip.new("fe80::221:63f:fe75:aa17/64") 
+print(addr6:sub(256))        -- "fe80::221:63f:fe75:a917/64" 
+print(addr6:sub("::ffff:0")) -- "fe80::221:63e:fe76:aa17/64" 
+ 
+addr:sub(256, true)          -- true 
+print(addr)                  -- "fe80::221:63f:fe75:a917/64" 
+ 
+addr:sub("ffff::", true)     -- false (underflow) 
+print(addr)                  -- "::/64" 
+ 
+local mac = luci.ip.new("00:14:22:01:23:45") 
+print(mac:sub(256))            -- "00:14:22:01:22:45" 
+print(mac:sub("0:0:0:0:FF:0")  -- "00:14:22:00:24:45" 
+ 
+mac:sub(256, true)             -- true 
+print(mac)                     -- "00:14:22:01:22:45" 
+ 
+mac:sub("FF:FF:0:0:0:0", true) -- false (overflow) 
+print(mac)                     -- "00:00:00:00:00:00"
+ + + +

Return value:

+
    +
  • When subtracting inplace: Return true if the subtraction + succeeded or false when the subtraction underflowed.
  • +
  • When deriving new CIDR: Return new instance representing the value of + this instance minus the subtracted amount or the lowest address if + the subtraction underflowed.
+ + + +
+ + + + +
cidr:minhost ()
+
+ + +Calculate the lowest possible host address within this CIDR instance. + + + + + + +

Usage:

+
local addr = luci.ip.new("192.168.123.56/24") 
+print(addr:minhost())  -- "192.168.123.1" 
+ 
+local addr6 = luci.ip.new("fd9b:62b3:9cc5:0:221:63ff:fe75:aa17/64") 
+print(addr6:minhost()) -- "fd9b:62b3:9cc5::1" 
+ 
+local mac = luci.ip.new("00:14:22:01:22:45/32") 
+print(mac:minhost())   -- "00:14:22:01:00:01"
+ + + +

Return value:

+Returns a new CIDR instance representing the lowest host address + within this range. + + + +
+ + + + +
cidr:maxhost ()
+
+ + +Calculate the highest possible host address within this CIDR instance. + + + + + + +

Usage:

+
local addr = luci.ip.new("192.168.123.56/24") 
+print(addr:maxhost())  -- "192.168.123.254" (.255 is broadcast) 
+ 
+local addr6 = luci.ip.new("fd9b:62b3:9cc5:0:221:63ff:fe75:aa17/64") 
+print(addr6:maxhost()) -- "fd9b:62b3:9cc5:0:ffff:ffff:ffff:ffff" 
+ 
+local mac = luci.ip.new("00:14:22:01:22:45/32") 
+print(mac:maxhost())   -- "00:14:22:01:FF:FF"
+ + + +

Return value:

+Returns a new CIDR instance representing the highest host address + within this range. + + + +
+ + + + +
cidr:string ()
+
+ + +Convert CIDR instance into string representation. + +If the prefix size of instance is less than 32 for IPv4, 128 for IPv6 or 48 for +MACs, the address is returned in the form "address/prefix" otherwise just +"address". + +It is usually not required to call this function directly as CIDR objects +define it as __tostring function in the associated metatable. + + + + + + + + +

Return value:

+Returns a string representing the range or address of this CIDR instance + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.ip.html b/docs/api/modules/luci.ip.html new file mode 100644 index 000000000..0599396b6 --- /dev/null +++ b/docs/api/modules/luci.ip.html @@ -0,0 +1,1217 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.ip

+ +

+ LuCI IP calculation and netlink access library.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
new (address, netmask) + +Construct a new luci.ip.cidr instance and autodetect the address family.
IPv4 (address, netmask) + +Construct a new IPv4 luci.ip.cidr instance.
IPv6 (address, netmask) + +Construct a new IPv6 luci.ip.cidr instance.
MAC (address, netmask) + +Construct a new MAC luci.ip.cidr instance.
checkip4 (address) + +Verify an IPv4 address.
checkip6 (address) + +Verify an IPv6 address.
checkmac (address) + +Verify an ethernet MAC address.
route (address, source) + +Determine the route leading to the given destination.
routes (filter, callback) + +Fetch all routes, optionally matching the given criteria.
neighbors (filter, callback) + +Fetches entries from the IPv4 ARP and IPv6 neighbour kernel table
link (device) + +Fetch basic device information
+ + + + + + +
+
+ + +

Functions

+
+ + + +
new (address, netmask)
+
+ + +Construct a new luci.ip.cidr instance and autodetect the address family. +Throws an error if the given strings do not represent a valid address or +if the given optional netmask is of a different family. + + +

Parameters

+
    + +
  • + address: String containing a valid IPv4 or IPv6 address, optionally +with prefix size (CIDR notation) or netmask separated by slash. +
  • + +
  • + netmask: String containing a valid IPv4 or IPv6 netmask or number +containing a prefix size in bits (0..32 for IPv4, +0..128 for IPv6). Overrides mask embedded in the first argument +if specified. (optional) +
  • + +
+ + + + +

Usage:

+
addr = luci.ip.new("10.24.0.1/24") 
+addr = luci.ip.new("10.24.0.1/255.255.255.0") 
+addr = luci.ip.new("10.24.0.1", "255.255.255.0")        -- separate netmask 
+addr = luci.ip.new("10.24.0.1/24", 16)                  -- override netmask 
+ 
+addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/64") 
+addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/ffff:ffff:ffff:ffff::") 
+addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17", "ffff:ffff:ffff:ffff::") 
+addr6 = luci.ip.new("fe80::221:63ff:fe75:aa17/64", 128) -- override netmask
+ + + +

Return value:

+A luci.ip.cidr object representing the given +address/mask range. + + + +

See also:

+ + +
+ + + + +
IPv4 (address, netmask)
+
+ + +Construct a new IPv4 luci.ip.cidr instance. +Throws an error if the given string does not represent a valid IPv4 address or +if the given optional netmask is of a different family. + + +

Parameters

+
    + +
  • + address: String containing a valid IPv4, optionally with prefix size +(CIDR notation) or netmask separated by slash. +
  • + +
  • + netmask: String containing a valid IPv4 netmask or number +containing a prefix size between 0 and 32 bit. +Overrides mask embedded in the first argument if specified. (optional) +
  • + +
+ + + + +

Usage:

+
addr = luci.ip.IPv4("10.24.0.1/24") 
+addr = luci.ip.IPv4("10.24.0.1/255.255.255.0") 
+addr = luci.ip.IPv4("10.24.0.1", "255.255.255.0")        -- separate netmask 
+addr = luci.ip.IPv4("10.24.0.1/24", 16)                  -- override netmask
+ + + +

Return value:

+A luci.ip.cidr object representing the given IPv4 range. + + + +

See also:

+ + +
+ + + + +
IPv6 (address, netmask)
+
+ + +Construct a new IPv6 luci.ip.cidr instance. +Throws an error if the given string does not represent a valid IPv6 address or +if the given optional netmask is of a different family. + + +

Parameters

+
    + +
  • + address: String containing a valid IPv6, optionally with prefix size +(CIDR notation) or netmask separated by slash. +
  • + +
  • + netmask: String containing a valid IPv4 netmask or number +containing a prefix size between 0 and 128 bit. +Overrides mask embedded in the first argument if specified. (optional) +
  • + +
+ + + + +

Usage:

+
addr6 = luci.ip.IPv6("fe80::221:63ff:fe75:aa17/64") 
+addr6 = luci.ip.IPv6("fe80::221:63ff:fe75:aa17/ffff:ffff:ffff:ffff::") 
+addr6 = luci.ip.IPv6("fe80::221:63ff:fe75:aa17", "ffff:ffff:ffff:ffff::") 
+addr6 = luci.ip.IPv6("fe80::221:63ff:fe75:aa17/64", 128) -- override netmask
+ + + +

Return value:

+A luci.ip.cidr object representing the given IPv6 range. + + + +

See also:

+ + +
+ + + + +
MAC (address, netmask)
+
+ + +Construct a new MAC luci.ip.cidr instance. +Throws an error if the given string does not represent a valid ethernet MAC +address or if the given optional mask is of a different family. + + +

Parameters

+
    + +
  • + address: String containing a valid ethernet MAC address, optionally with +prefix size (CIDR notation) or mask separated by slash. +
  • + +
  • + netmask: String containing a valid MAC address mask or number +containing a prefix size between 0 and 48 bit. +Overrides mask embedded in the first argument if specified. (optional) +
  • + +
+ + + + +

Usage:

+
intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00/24") 
+intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00/FF:FF:FF:0:0:0") 
+intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00", "FF:FF:FF:0:0:0") 
+intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00/24", 48) -- override mask
+ + + +

Return value:

+A luci.ip.cidr object representing the given MAC address range. + + + +

See also:

+ + +
+ + + + +
checkip4 (address)
+
+ + +Verify an IPv4 address. + +Checks whether given argument is a preexisting luci.ip.cidr IPv4 address +instance or a string literal convertible to an IPv4 address and returns a +plain Lua string containing the canonical representation of the address. + +If the argument is not a valid address, returns nothing. This function is +intended to aid in safely verifying address literals without having to deal +with exceptions. + + +

Parameters

+
    + +
  • + address: String containing a valid IPv4 address or existing +luci.ip.cidr IPv4 instance. +
  • + +
+ + + + +

Usage:

+
ipv4 = luci.ip.checkip4(luci.ip.new("127.0.0.1"))  -- "127.0.0.1" 
+ipv4 = luci.ip.checkip4("127.0.0.1")               -- "127.0.0.1" 
+ipv4 = luci.ip.checkip4("nonesense")               -- nothing 
+ipv4 = luci.ip.checkip4(123)                       -- nothing 
+ipv4 = luci.ip.checkip4(nil)                       -- nothing 
+ipv4 = luci.ip.checkip4()                          -- nothing
+ + + +

Return value:

+A string representing the given IPv4 address. + + + +

See also:

+ + +
+ + + + +
checkip6 (address)
+
+ + +Verify an IPv6 address. + +Checks whether given argument is a preexisting luci.ip.cidr IPv6 address +instance or a string literal convertible to an IPv6 address and returns a +plain Lua string containing the canonical representation of the address. + +If the argument is not a valid address, returns nothing. This function is +intended to aid in safely verifying address literals without having to deal +with exceptions. + + +

Parameters

+
    + +
  • + address: String containing a valid IPv6 address or existing +luci.ip.cidr IPv6 instance. +
  • + +
+ + + + +

Usage:

+
ipv6 = luci.ip.checkip6(luci.ip.new("0:0:0:0:0:0:0:1"))  -- "::1" 
+ipv6 = luci.ip.checkip6("0:0:0:0:0:0:0:1")               -- "::1" 
+ipv6 = luci.ip.checkip6("nonesense")                     -- nothing 
+ipv6 = luci.ip.checkip6(123)                             -- nothing 
+ipv6 = luci.ip.checkip6(nil)                             -- nothing 
+ipv6 = luci.ip.checkip6()                                -- nothing
+ + + +

Return value:

+A string representing the given IPv6 address. + + + +

See also:

+ + +
+ + + + +
checkmac (address)
+
+ + +Verify an ethernet MAC address. + +Checks whether given argument is a preexisting luci.ip.cidr MAC address +instance or a string literal convertible to an ethernet MAC and returns a +plain Lua string containing the canonical representation of the address. + +If the argument is not a valid address, returns nothing. This function is +intended to aid in safely verifying address literals without having to deal +with exceptions. + + +

Parameters

+
    + +
  • + address: String containing a valid MAC address or existing luci.ip.cidr +MAC address instance. +
  • + +
+ + + + +

Usage:

+
mac = luci.ip.checkmac(luci.ip.new("00-11-22-cc-dd-ee"))  -- "00:11:22:CC:DD:EE" 
+mac = luci.ip.checkmac("00:11:22:cc:dd:ee")               -- "00:11:22:CC:DD:EE" 
+mac = luci.ip.checkmac("nonesense")                       -- nothing 
+mac = luci.ip.checkmac(123)                               -- nothing 
+mac = luci.ip.checkmac(nil)                               -- nothing 
+mac = luci.ip.checkmac()                                  -- nothing
+ + + +

Return value:

+A string representing the given MAC address. + + + +

See also:

+ + +
+ + + + +
route (address, source)
+
+ + +Determine the route leading to the given destination. + + +

Parameters

+
    + +
  • + address: A luci.ip.cidr instance or a string containing +a valid IPv4 or IPv6 range as specified by luci.ip.new(). +
  • + +
  • + source: A luci.ip.cidr instance or a string containing +the preferred source address for route selection (optional). +
  • + +
+ + + + +

Usage:

+
    +
  • Find default gateway by getting route to Google's public NS server +
    rt = luci.ip.route("8.8.8.8") 
    +if rt ~= nil then 
    +	print("gateway is", rt.gw) 
    +end
  • +
  • Determine IPv6 upstream interface
    rt = luci.ip.route("2001::/7") 
    +if rt ~= nil then 
    +	print("ipv6 upstream device is", rt.dev) 
    +end
  • +
+ + + +

Return value:

+

Table containing the fields described below.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
type +

Route type with one of the following numeric values:

+ + + + + + + + + + + + + + + + + + + + + +
1RTN_UNICAST - Gateway or direct route
2RTN_LOCAL - Accept locally
3RTN_BROADCAST - + Accept locally as broadcast send as broadcast
4RTN_ANYCAST - + Accept locally as broadcast but send as unicast
5RTN_MULTICAST - Multicast route
+
familyNumber containing the route family, 4 for IPv4 or + 6 for IPv6
destDestination luci.ip.cidr instance
gwGateway luci.ip.cidr instance (optional)
fromSource address luci.ip.cidr instance (optional)
srcPreferred source luci.ip.cidr instance (optional)
devString containing the name of the outgoing interface
iifString containing the name of the incoming interface (optional)
tableNumber of the associated routing table (0..65535)
protoNumber of the associated routing protocol
scopeNumber describing the scope of the route, most commonly + 0 for global or 253 for on-link
metricNumber describing the route metric (optional)
expiresNumber of seconds the prefix is valid (IPv6 only, optional)
errorRoute destination error code (optional)
+ + + +

See also:

+ + +
+ + + + +
routes (filter, callback)
+
+ + +Fetch all routes, optionally matching the given criteria. + + +

Parameters

+
    + +
  • + filter:

    Table containing one or more of the possible filter +criteria described below (optional)

    + + + + + + + + + + + + + + +
    FieldDescription
    family + Number describing the address family to return - 4 selects + IPv4 routes, 6 IPv6 ones. Any other value selects both. +
    iif + String containing the incoming route interface to match. +
    oif + String containing the outgoing route interface to match. +
    type + Numeric type to match, e.g. 1 for unicast. +
    scope + Numeric scope to match, e.g. 253 for onlink. +
    proto + Numeric protocol to match, e.g. 2 for boot. +
    table + Numeric routing table to match (0..65535). +
    gw + String containing the gateway address to match. Can be in any notation + specified by luci.ip.new(). Prefix matching is performed when + comparing the routes, e.g. "192.168.1.0/24" would select routes with gateway + addresses 192.168.1.1 .. 192.168.1.255. +
    dest + String containing the destination to match. Prefix matching is performed. +
    from + String containing the source address to match. Prefix matching is performed. +
    src + String containing the preferred source address to match. + Prefix matching is performed. +
    dest_exact + String containing the destination to match. Exact matching is performed, + e.g. dest = "0.0.0.0/0" would match any IPv4 route + while dest_exact = "0.0.0.0/0" will only match the + default route. +
    from_exact + String containing the source address to match. Exact matching is performed. +
    +
  • + +
  • + callback:

    Callback function to invoke for each found route +instead of returning one table of route objects (optional)

    +
  • + +
+ + + + +

Usage:

+
    +
  • Find all IPv4 default routes: +
    luci.ip.routes({ dest_exact = "0.0.0.0/0" }, function(rt) 
    +	print(rt.type, rt.gw, rt.dev) 
    +end)
  • +
  • Find all global IPv6 prefixes on the current system: +
    luci.ip.routes({ from = "2001::/7" }, function(rt) 
    +	print(rt.from) 
    +end)
  • +
  • Fetch all IPv4 routes: +
    routes = luci.ip.routes({ family = 4 }) 
    +for _, rt in ipairs(routes) do 
    +	print(rt.dest, rt.gw, rt.dev) 
    +end
  • +
+ + + +

Return value:

+If no callback function is provided, a table of routes +as specified by luci.ip.route() +is returned. If a callback function is given, it is invoked for each route +and nothing is returned. + + + +

See also:

+ + +
+ + + + +
neighbors (filter, callback)
+
+ + +Fetches entries from the IPv4 ARP and IPv6 neighbour kernel table + + +

Parameters

+
    + +
  • + filter:

    Table containing one or more of the possible filter +criteria described below (optional)

    + + + + + +
    FieldDescription
    family + Number describing the address family to return - 4 selects + IPv4 ARP, 6 select IPv6 neighbour entries. Any other value + selects both. +
    dev + String containing the associated interface to match. +
    dest + String containing the associated address to match. Can be in any notation + specified by luci.ip.new(). Prefix matching is performed when + comparing the addresses, e.g. "192.168.1.0/24" would select ARP entries + for 192.168.1.1 .. 192.168.1.255. +
    mac + String containing MAC address to match. +
    +
  • + +
  • + callback:

    Callback function to invoke for each found neighbour +entry instead of returning one table of neighbour entries (optional)

    +
  • + +
+ + + + +

Usage:

+
    +
  • Find all ARP neighbours in the LAN: +
    luci.ip.neighbors({ dest = "192.168.0.0/16" }, function(n) 
    +	print(n.dest, n.mac) 
    +end)
  • +
  • Find all active IPv6 addresses of host with given MAC: +
    luci.ip.neighbors({ family = 6, mac = "00:21:63:75:aa:17" }, 
    +	function(n) 
    +		print(n.dest) 
    +	end)
  • +
+ + + +

Return value:

+If no callback function is provided, a table of neighbour entries +is returned. If a callback function is given, it is invoked for each entry +and nothing is returned. + +A neighbour entry is a table containing the following fields: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
familyNumber containing the neighbour entry family, 4 for IPv4 + ARP or 6 for IPv6 NDP
devString containing the associated device of the neighbour entry
destIP address luci.ip.cidr instance
macMAC address luci.ip.cidr instance
routerBoolean "true" if the neighbour entry is a router (IPv6, optional)
proxyBoolean "true" if this is a proxy entry (optional)
incompleteBoolean "true" if the entry is in incomplete state (optional)
reachableBoolean "true" if the entry is in reachable state (optional)
staleBoolean "true" if the entry is stale (optional)
delayBoolean "true" if the entry is delayed (optional)
probeBoolean "true" if the entry is in probe state (optional)
failedBoolean "true" if the entry is in failed state (optional)
noarpBoolean "true" if the entry is not caused by NDP or + ARP (optional)
permanentBoolean "true" if the entry was statically configured from + userspace (optional)
+ + + +
+ + + + +
link (device)
+
+ + +Fetch basic device information + + +

Parameters

+
    + +
  • + device: String containing the network device to query +
  • + +
+ + + + +

Usage:

+
    +
  • Test whether device br-lan exists: +
    print(luci.ip.link("br-lan").name ~= nil) 
    +
  • +
  • Query MAC address of eth0: +
    print(luci.ip.link("eth0").mac) 
    +
  • +
+ + + +

Return value:

+If the given interface is found, a table containing the fields +described below is returned, else an empty table. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
upBoolean indicating whether the device is in IFF_RUNNING state
typeNumeric value indicating the type of the device, e.g. 1 + for ethernet.
nameString containing the name of the device
masterIf queried device is a bridge port, string containing the name of + parent bridge device (optional)
mtuNumber containing the current MTU of the device
qlenNumber containing the TX queue length of the device
macMAC address luci.ip.cidr instance representing the device ethernet + address
+ + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.json.html b/docs/api/modules/luci.json.html new file mode 100644 index 000000000..db2d1da3f --- /dev/null +++ b/docs/api/modules/luci.json.html @@ -0,0 +1,594 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance luci.json

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ActiveDecoder (customnull) + +Create a new Active JSON-Decoder.
ActiveDecoder:get () + +Fetches one JSON-object from given source +
Decoder (customnull) + +Create a new JSON-Decoder.
Decoder:get () + +Get the decoded data packets after the rawdata has been sent to the sink.
Decoder:sink () + +Create an LTN12 sink from the decoder object which accepts the JSON-Data.
Encoder (data, buffersize, fastescape) + +Create a new JSON-Encoder.
Encoder:source () + +Create an LTN12 source providing the encoded JSON-Data.
decode (json) + +Directly decode a JSON string +
encode (obj) + +Direcly encode a Lua object into a JSON string.
null () + +Null replacement function +
+ + + + + + +
+
+ + +

Functions

+
+ + + +
ActiveDecoder (customnull)
+
+ + +Create a new Active JSON-Decoder. + + + +

Parameters

+
    + +
  • + customnull: Use luci.json.null instead of nil for decoding null +
  • + +
+ + + + + + +

Return value:

+Active JSON-Decoder + + + +
+ + + + +
ActiveDecoder:get ()
+
+ + +Fetches one JSON-object from given source + + + + + + + + +

Return value:

+Decoded object + + + +
+ + + + +
Decoder (customnull)
+
+ + +Create a new JSON-Decoder. + + + +

Parameters

+
    + +
  • + customnull: Use luci.json.null instead of nil for decoding null +
  • + +
+ + + + + + +

Return value:

+JSON-Decoder + + + +
+ + + + +
Decoder:get ()
+
+ + +Get the decoded data packets after the rawdata has been sent to the sink. + + + + + + + + +

Return value:

+Decoded data + + + +
+ + + + +
Decoder:sink ()
+
+ + +Create an LTN12 sink from the decoder object which accepts the JSON-Data. + + + + + + + + +

Return value:

+LTN12 sink + + + +
+ + + + +
Encoder (data, buffersize, fastescape)
+
+ + +Create a new JSON-Encoder. + + + +

Parameters

+
    + +
  • + data: Lua-Object to be encoded. +
  • + +
  • + buffersize: Blocksize of returned data source. +
  • + +
  • + fastescape: Use non-standard escaping (don't escape control chars) +
  • + +
+ + + + + + +

Return value:

+JSON-Encoder + + + +
+ + + + +
Encoder:source ()
+
+ + +Create an LTN12 source providing the encoded JSON-Data. + + + + + + + + +

Return value:

+LTN12 source + + + +
+ + + + +
decode (json)
+
+ + +Directly decode a JSON string + + + +

Parameters

+
    + +
  • + json: JSON-String +
  • + +
+ + + + + + +

Return value:

+Lua object + + + +
+ + + + +
encode (obj)
+
+ + +Direcly encode a Lua object into a JSON string. + + + +

Parameters

+
    + +
  • + obj: Lua Object +
  • + +
+ + + + + + +

Return value:

+JSON string + + + +
+ + + + +
null ()
+
+ + +Null replacement function + + + + + + + + +

Return value:

+null + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.jsonc.html b/docs/api/modules/luci.jsonc.html new file mode 100644 index 000000000..79deb933d --- /dev/null +++ b/docs/api/modules/luci.jsonc.html @@ -0,0 +1,393 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.jsonc

+ +

+ LuCI JSON parsing and serialization library. + The luci.jsonc class is a high level Lua binding to the JSON-C library to + allow reading and writing JSON data with minimal overhead.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + +
new () + +Construct a new luci.jsonc.parser instance.
parse (json) + +Parse a complete JSON string and convert it into a Lua data structure.
stringify (data, pretty) + +Convert given Lua data into a JSON string.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
new ()
+
+ + +Construct a new luci.jsonc.parser instance. + + + + + +

Usage:

+parser = luci.jsonc.new() + + + +

Return value:

+A luci.jsonc.parser object representing a JSON-C tokener. + + + +
+ + + + +
parse (json)
+
+ + +Parse a complete JSON string and convert it into a Lua data structure. + + +

Parameters

+
    + +
  • + json: A string containing the JSON data to parse, must be either a + JSON array or a JSON object. +
  • + +
+ + + + +

Usage:

+
data = luci.jsonc.parse('{ "name": "John", "age": 34 }') 
+print(data.name)  -- "John"
+ + + +

Return value:

+On success, a table containing the parsed JSON data is returned, on + failure the function returns nil and a string containing the reason of + the parse error. + + + +

See also:

+ + +
+ + + + +
stringify (data, pretty)
+
+ + +Convert given Lua data into a JSON string. + +This function recursively converts the given Lua data into a JSON string, +ignoring any unsupported data. Lua tables are converted into JSON arrays if they +only contain integer keys, mixed tables are turned into JSON objects with any +existing numeric keys converted into strings. + +Lua functions, coroutines and userdata objects are ignored and Lua numbers are +converted to integers if they do not contain fractional values. + + + +

Parameters

+
    + +
  • + data: The Lua data to convert, can be a table, string, boolean or number. +
  • + +
  • + pretty: A boolean value indicating whether the resulting JSON should be + pretty printed. +
  • + +
+ + + + +

Usage:

+
json = luci.jsonc.stringify({ item = true, values = { 1, 2, 3 } }) 
+print(json)  -- '{"item":true,"values":[1,2,3]}'
+ + + +

Return value:

+Returns a string containing the JSON representation of the given Lua + data. + + + +

See also:

+ + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.jsonc.parser.html b/docs/api/modules/luci.jsonc.parser.html new file mode 100644 index 000000000..709cb9afc --- /dev/null +++ b/docs/api/modules/luci.jsonc.parser.html @@ -0,0 +1,491 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance luci.jsonc.parser

+ +

+ LuCI JSON parser instance. + A JSON parser instance is useful to parse JSON data chunk by chunk, without + the need to assemble all data in advance.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
parser:parse (json) + +Parses one chunk of JSON data.
parser:get () + +Convert parsed JSON data into Lua table.
parser:set (data) + +Put Lua data into the parser.
parser:sink () + +Generate an ltn12-compatible sink.
parser:stringify (pretty) + +Serialize current parser state as JSON.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
parser:parse (json)
+
+ + +Parses one chunk of JSON data. + + + +

Parameters

+
    + +
  • + json: String containing the JSON fragment to parse +
  • + +
+ + + + +

Usage:

+
parser = luci.jsonc.new() 
+ 
+while true do 
+	chunk = ...  -- fetch a cunk of data, e.g. from a socket 
+	finish, errmsg = parser.parse(chunk) 
+ 
+	if finish == nil then 
+		error("Cannot parse JSON: " .. errmsg) 
+	end 
+ 
+	if finish == true then 
+		break 
+	end 
+end
+ + + +

Return value:

+
    +
  • true if a complete JSON object has been parsed and no further input is + expected.
  • +
  • false if further input is required
  • +
  • nil if an error was encountered while parsing the current chunk. + In this case a string describing the parse error is returned as second + value.
+ + + +

See also:

+ + +
+ + + + +
parser:get ()
+
+ + +Convert parsed JSON data into Lua table. + + + + + + +

Usage:

+
parser = luci.jsonc.new() 
+parser:parse('{ "example": "test" }') 
+ 
+data = parser:get() 
+print(data.example)  -- "test"
+ + + +

Return value:

+Parsed JSON object converted into a Lua table or nil if the parser + didn't finish or encountered an error. + + + +

See also:

+ + +
+ + + + +
parser:set (data)
+
+ + +Put Lua data into the parser. + + + +

Parameters

+
    + +
  • + data: Lua data to put into the parser object. The data is converted to an + internal JSON representation that can be dumped with stringify(). + The conversion follows the rules described in luci.jsonc.stringify. +
  • + +
+ + + + +

Usage:

+
parser = luci.jsonc.new() 
+parser:set({ "some", "data" })
+ + + +

Return value:

+Nothing is returned. + + + +

See also:

+ + +
+ + + + +
parser:sink ()
+
+ + +Generate an ltn12-compatible sink. + + + + + + +

Usage:

+
parser = luci.jsonc.new() 
+ltn12.pump.all(ltn12.source.file(io.input()), parser:sink()) 
+print(parser:get())
+ + + +

Return value:

+Returns a function that can be used as an ltn12 sink. + + + +
+ + + + +
parser:stringify (pretty)
+
+ + +Serialize current parser state as JSON. + + + +

Parameters

+
    + +
  • + pretty: A boolean value indicating whether the resulting JSON should be pretty printed. +
  • + +
+ + + + +

Usage:

+
parser = luci.jsonc.new() 
+parser:parse('{ "example": "test" }') 
+print(parser:serialize())  -- '{"example":"test"}'
+ + + +

Return value:

+Returns the serialized JSON data of this parser instance. + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.model.ipkg.html b/docs/api/modules/luci.model.ipkg.html new file mode 100644 index 000000000..a0af3187b --- /dev/null +++ b/docs/api/modules/luci.model.ipkg.html @@ -0,0 +1,730 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.model.ipkg

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
compare_versions (ver1, ver2, comp) + +lua version of opkg compare-versions +
find (pat, cb) + +Find packages that match the given pattern.
info (pkg) + +Return information about installed and available packages.
install (...) + +Install one or more packages.
installed (pkg) + +Determine whether a given package is installed.
list_all (pat, cb) + +List all packages known to opkg.
list_installed (pat, cb) + +List installed packages.
overlay_root () + +Determines the overlay root used by opkg.
remove (...) + +Remove one or more packages.
status (pkg) + +Return the package status of one or more packages.
update () + +Update package lists.
upgrade () + +Upgrades all installed packages.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
compare_versions (ver1, ver2, comp)
+
+ + +lua version of opkg compare-versions + + + +

Parameters

+
    + +
  • + ver1: string version 1 +
  • + +
  • + ver2: string version 2 +
  • + +
  • + comp: string compare versions using + "<=" or "<" lower-equal + ">" or ">=" greater-equal + "=" equal + "<<" lower + ">>" greater + "~=" not equal +
  • + +
+ + + + + + +

Return value:

+Boolean indicating the status of the compare + + + +
+ + + + +
find (pat, cb)
+
+ + +Find packages that match the given pattern. + + + +

Parameters

+
    + +
  • + pat: Find packages whose names or descriptions match this pattern, nil results in zero results +
  • + +
  • + cb: Callback function invoked for each patckage, receives name, version and description as arguments +
  • + +
+ + + + + + +

Return value:

+nothing + + + +
+ + + + +
info (pkg)
+
+ + +Return information about installed and available packages. + + + +

Parameters

+
    + +
  • + pkg: Limit output to a (set of) packages +
  • + +
+ + + + + + +

Return value:

+Table containing package information + + + +
+ + + + +
install (...)
+
+ + +Install one or more packages. + + + +

Parameters

+
    + +
  • + ...: List of packages to install +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating the status of the action + +
  2. OPKG return code, STDOUT and STDERR + +
+ + + +
+ + + + +
installed (pkg)
+
+ + +Determine whether a given package is installed. + + + +

Parameters

+
    + +
  • + pkg: Package +
  • + +
+ + + + + + +

Return value:

+Boolean + + + +
+ + + + +
list_all (pat, cb)
+
+ + +List all packages known to opkg. + + + +

Parameters

+
    + +
  • + pat: Only find packages matching this pattern, nil lists all packages +
  • + +
  • + cb: Callback function invoked for each package, receives name, version and description as arguments +
  • + +
+ + + + + + +

Return value:

+nothing + + + +
+ + + + +
list_installed (pat, cb)
+
+ + +List installed packages. + + + +

Parameters

+
    + +
  • + pat: Only find packages matching this pattern, nil lists all packages +
  • + +
  • + cb: Callback function invoked for each package, receives name, version and description as arguments +
  • + +
+ + + + + + +

Return value:

+nothing + + + +
+ + + + +
overlay_root ()
+
+ + +Determines the overlay root used by opkg. + + + + + + + + +

Return value:

+String containing the directory path of the overlay root. + + + +
+ + + + +
remove (...)
+
+ + +Remove one or more packages. + + + +

Parameters

+
    + +
  • + ...: List of packages to install +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating the status of the action + +
  2. OPKG return code, STDOUT and STDERR + +
+ + + +
+ + + + +
status (pkg)
+
+ + +Return the package status of one or more packages. + + + +

Parameters

+
    + +
  • + pkg: Limit output to a (set of) packages +
  • + +
+ + + + + + +

Return value:

+Table containing package status information + + + +
+ + + + +
update ()
+
+ + +Update package lists. + + + + + + + + +

Return values:

+
    + +
  1. Boolean indicating the status of the action + +
  2. OPKG return code, STDOUT and STDERR + +
+ + + +
+ + + + +
upgrade ()
+
+ + +Upgrades all installed packages. + + + + + + + + +

Return values:

+
    + +
  1. Boolean indicating the status of the action + +
  2. OPKG return code, STDOUT and STDERR + +
+ + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.model.uci.html b/docs/api/modules/luci.model.uci.html new file mode 100644 index 000000000..c1eaf5f81 --- /dev/null +++ b/docs/api/modules/luci.model.uci.html @@ -0,0 +1,1631 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance luci.model.uci

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Cursor:add (config, type) + +Add an anonymous section.
Cursor:apply (rollback) + +Applies UCI configuration changes.
Cursor:changes (config) + +Get a table of saved but uncommitted changes.
Cursor:commit (config) + +Commit saved changes.
Cursor:confirm () + +Confirms UCI apply process.
Cursor:delete (config, section, option) + +Deletes a section or an option.
Cursor:delete_all (config, type, comparator) + +Delete all sections of a given type that match certain criteria.
Cursor:foreach (config, type, callback) + +Call a function for every section of a certain type.
Cursor:get (config, section, option) + +Get a section type or an option +
Cursor:get_all (config, section) + +Get all sections of a config or all values of a section.
Cursor:get_bool (config, section, option) + +Get a boolean option and return it's value as true or false.
Cursor:get_confdir () + +Get the configuration directory.
Cursor:get_first (config, type, option, default) + +Get the given option from the first section with the given type.
Cursor:get_list (config, section, option) + +Get an option or list and return values as table.
Cursor:get_savedir () + +Get the directory for uncomitted changes.
Cursor:get_session_id () + +Get the effective session ID.
Cursor:load (config) + +Manually load a config.
Cursor:revert (config) + +Revert saved but uncommitted changes.
Cursor:rollback () + +Cancels UCI apply process.
Cursor:rollback_pending () + +Checks whether a pending rollback is scheduled.
Cursor:save (config) + +Saves changes made to a config to make them committable.
Cursor:section (config, type, name, values) + +Create a new section and initialize it with data.
Cursor:set (config, section, option, value) + +Set a value or create a named section.
Cursor:set_confdir (directory) + +Set the configuration directory.
Cursor:set_list (config, section, option, value) + +Set given values as list.
Cursor:set_savedir (directory) + +Set the directory for uncommitted changes.
Cursor:set_session_id (id) + +Set the effective session ID.
Cursor:substate () + +Create a sub-state of this cursor.
Cursor:tset (config, section, values) + +Updated the data of a section using data from a table.
Cursor:unload (config) + +Discard changes made to a config.
cursor () + +Create a new UCI-Cursor.
cursor_state () + +Create a new Cursor initialized to the state directory.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
Cursor:add (config, type)
+
+ + +Add an anonymous section. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + type: UCI section type +
  • + +
+ + + + + + +

Return value:

+Name of created section + + + +
+ + + + +
Cursor:apply (rollback)
+
+ + +Applies UCI configuration changes. + +If the rollback parameter is set to true, the apply function will invoke the +rollback mechanism which causes the configuration to be automatically reverted +if no confirm() call occurs within a certain timeout. + +The current default timeout is 30s and can be increased using the +"luci.apply.timeout" uci configuration key. + + + +

Parameters

+
    + +
  • + rollback: Enable rollback mechanism +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +
+ + + + +
Cursor:changes (config)
+
+ + +Get a table of saved but uncommitted changes. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
+ + + + + + +

Return value:

+Table of changes + + + +

See also:

+ + +
+ + + + +
Cursor:commit (config)
+
+ + +Commit saved changes. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +

See also:

+ + +
+ + + + +
Cursor:confirm ()
+
+ + +Confirms UCI apply process. + +If a previous UCI apply with rollback has been invoked using apply(true), +this function confirms the process and cancels the pending rollback timer. + +If no apply with rollback session is active, the function has no effect and +returns with a "No data" error. + + + + + + + + +

Return value:

+Boolean whether operation succeeded + + + +
+ + + + +
Cursor:delete (config, section, option)
+
+ + +Deletes a section or an option. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + section: UCI section name +
  • + +
  • + option: UCI option (optional) +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +
+ + + + +
Cursor:delete_all (config, type, comparator)
+
+ + +Delete all sections of a given type that match certain criteria. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + type: UCI section type +
  • + +
  • + comparator: Function that will be called for each section and returns + a boolean whether to delete the current section (optional) +
  • + +
+ + + + + + + + +
+ + + + +
Cursor:foreach (config, type, callback)
+
+ + +Call a function for every section of a certain type. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + type: UCI section type +
  • + +
  • + callback: Function to be called +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +
+ + + + +
Cursor:get (config, section, option)
+
+ + +Get a section type or an option + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + section: UCI section name +
  • + +
  • + option: UCI option (optional) +
  • + +
+ + + + + + +

Return value:

+UCI value + + + +
+ + + + +
Cursor:get_all (config, section)
+
+ + +Get all sections of a config or all values of a section. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + section: UCI section name (optional) +
  • + +
+ + + + + + +

Return value:

+Table of UCI sections or table of UCI values + + + +
+ + + + +
Cursor:get_bool (config, section, option)
+
+ + +Get a boolean option and return it's value as true or false. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + section: UCI section name +
  • + +
  • + option: UCI option +
  • + +
+ + + + + + +

Return value:

+Boolean + + + +
+ + + + +
Cursor:get_confdir ()
+
+ + +Get the configuration directory. + + + + + + + + +

Return value:

+Configuration directory + + + +
+ + + + +
Cursor:get_first (config, type, option, default)
+
+ + +Get the given option from the first section with the given type. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + type: UCI section type +
  • + +
  • + option: UCI option (optional) +
  • + +
  • + default: Default value (optional) +
  • + +
+ + + + + + +

Return value:

+UCI value + + + +
+ + + + +
Cursor:get_list (config, section, option)
+
+ + +Get an option or list and return values as table. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + section: UCI section name +
  • + +
  • + option: UCI option +
  • + +
+ + + + + + +

Return value:

+table. If the option was not found, you will simply get an empty + table. + + + +
+ + + + +
Cursor:get_savedir ()
+
+ + +Get the directory for uncomitted changes. + + + + + + + + +

Return value:

+Save directory + + + +
+ + + + +
Cursor:get_session_id ()
+
+ + +Get the effective session ID. + + + + + + + + +

Return value:

+String containing the session ID + + + +
+ + + + +
Cursor:load (config)
+
+ + +Manually load a config. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +

See also:

+ + +
+ + + + +
Cursor:revert (config)
+
+ + +Revert saved but uncommitted changes. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +

See also:

+ + +
+ + + + +
Cursor:rollback ()
+
+ + +Cancels UCI apply process. + +If a previous UCI apply with rollback has been invoked using apply(true), +this function cancels the process and rolls back the configuration to the +pre-apply state. + +If no apply with rollback session is active, the function has no effect and +returns with a "No data" error. + + + + + + + + +

Return value:

+Boolean whether operation succeeded + + + +
+ + + + +
Cursor:rollback_pending ()
+
+ + +Checks whether a pending rollback is scheduled. + +If a previous UCI apply with rollback has been invoked using apply(true), +and has not been confirmed or rolled back yet, this function returns true +and the remaining time until rollback in seconds. If no rollback is pending, +the function returns false. On error, the function returns false and an +additional string describing the error. + + + + + + + + +

Return values:

+
    + +
  1. Boolean whether rollback is pending + +
  2. Remaining time in seconds + +
+ + + +
+ + + + +
Cursor:save (config)
+
+ + +Saves changes made to a config to make them committable. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +

See also:

+ + +
+ + + + +
Cursor:section (config, type, name, values)
+
+ + +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. + +When invoked with three arguments config, sectionname, sectiontype, +then a named section of the given type is created. + +When invoked with four arguments config, sectionname, optionname and +optionvalue then the value of the specified option is set to the given value. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + section: UCI section name +
  • + +
  • + option: UCI option or UCI section type +
  • + +
  • + value: UCI value or nothing 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. Setting a list option to an empty list +has the same effect as deleting the option. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
  • + section: UCI section name +
  • + +
  • + option: UCI option +
  • + +
  • + value: Value or table. Non-table values will be set as single + item UCI list. +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +
+ + + + +
Cursor:set_savedir (directory)
+
+ + +Set the directory for uncommitted changes. + + + +

Parameters

+
    + +
  • + directory: UCI changes directory +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +
+ + + + +
Cursor:set_session_id (id)
+
+ + +Set the effective session ID. + + + +

Parameters

+
    + +
  • + id: String containing the session ID to set +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +
+ + + + +
Cursor:substate ()
+
+ + +Create a sub-state of this cursor. + +The sub-state is tied to the parent cursor, 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 +
  • + +
+ + + + + + + + +
+ + + + +
Cursor:unload (config)
+
+ + +Discard changes made to a config. + + + +

Parameters

+
    + +
  • + config: UCI config +
  • + +
+ + + + + + +

Return value:

+Boolean whether operation succeeded + + + +

See also:

+ + +
+ + + + +
cursor ()
+
+ + +Create a new UCI-Cursor. + + + + + + + + +

Return value:

+UCI-Cursor + + + +
+ + + + +
cursor_state ()
+
+ + +Create a new Cursor initialized to the state directory. + + + + + + + + +

Return value:

+UCI cursor + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.rpcc.html b/docs/api/modules/luci.rpcc.html new file mode 100644 index 000000000..18065788b --- /dev/null +++ b/docs/api/modules/luci.rpcc.html @@ -0,0 +1,324 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance luci.rpcc

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + +
Client:proxy (prefix) + +Create a transparent RPC proxy.
Client:request (method, params, notification) + +Request an RP call and get the response.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
Client:proxy (prefix)
+
+ + +Create a transparent RPC proxy. + + + +

Parameters

+
    + +
  • + prefix: Method prefix +
  • + +
+ + + + + + +

Return value:

+RPC Proxy object + + + +
+ + + + +
Client:request (method, params, notification)
+
+ + +Request an RP call and get the response. + + + +

Parameters

+
    + +
  • + method: Remote method +
  • + +
  • + params: Parameters +
  • + +
  • + notification: Notification only? +
  • + +
+ + + + + + +

Return value:

+response + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.rpcc.ruci.html b/docs/api/modules/luci.rpcc.ruci.html new file mode 100644 index 000000000..7348f1932 --- /dev/null +++ b/docs/api/modules/luci.rpcc.ruci.html @@ -0,0 +1,277 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance luci.rpcc.ruci

+ +

+ + + + + + + +

Functions

+ + + + + + + +
factory (rpccl) + +Create a new UCI over RPC proxy.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
factory (rpccl)
+
+ + +Create a new UCI over RPC proxy. + + + +

Parameters

+
    + +
  • + rpccl: RPC client +
  • + +
+ + + + + + +

Return value:

+Network transparent UCI module + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.sys.html b/docs/api/modules/luci.sys.html new file mode 100644 index 000000000..b86d280fb --- /dev/null +++ b/docs/api/modules/luci.sys.html @@ -0,0 +1,641 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.sys

+ +

+ + + + + + + +

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.
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 containing 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 containing 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 + + + +
+ + + + +
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!

+
+ +
+ + diff --git a/docs/api/modules/luci.sys.init.html b/docs/api/modules/luci.sys.init.html new file mode 100644 index 000000000..e2c51f953 --- /dev/null +++ b/docs/api/modules/luci.sys.init.html @@ -0,0 +1,512 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.sys.init

+ +

+ +LuCI system utilities / init related functions. +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
disable (name) + +Disable the given init script +
enable (name) + +Enable the given init script +
enabled (name) + +Test whether the given init script is enabled +
index (name) + +Get the index of he given init script +
names () + +Get the names of all installed init scripts +
start (name) + +Start the given init script +
stop (name) + +Stop the given init script +
+ + + + + + +
+
+ + +

Functions

+
+ + + +
disable (name)
+
+ + +Disable the given init script + + + +

Parameters

+
    + +
  • + name: Name of the init script +
  • + +
+ + + + + + +

Return value:

+Boolean indicating success + + + +
+ + + + +
enable (name)
+
+ + +Enable the given init script + + + +

Parameters

+
    + +
  • + name: Name of the init script +
  • + +
+ + + + + + +

Return value:

+Boolean indicating success + + + +
+ + + + +
enabled (name)
+
+ + +Test whether the given init script is enabled + + + +

Parameters

+
    + +
  • + name: Name of the init script +
  • + +
+ + + + + + +

Return value:

+Boolean indicating whether init is enabled + + + +
+ + + + +
index (name)
+
+ + +Get the index of he given init script + + + +

Parameters

+
    + +
  • + name: Name of the init script +
  • + +
+ + + + + + +

Return value:

+Numeric index value + + + +
+ + + + +
names ()
+
+ + +Get the names of all installed init scripts + + + + + + + + +

Return value:

+Table containing the names of all inistalled init scripts + + + +
+ + + + +
start (name)
+
+ + +Start the given init script + + + +

Parameters

+
    + +
  • + name: Name of the init script +
  • + +
+ + + + + + +

Return value:

+Boolean indicating success + + + +
+ + + + +
stop (name)
+
+ + +Stop the given init script + + + +

Parameters

+
    + +
  • + name: Name of the init script +
  • + +
+ + + + + + +

Return value:

+Boolean indicating success + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.sys.iptparser.html b/docs/api/modules/luci.sys.iptparser.html new file mode 100644 index 000000000..5928281cf --- /dev/null +++ b/docs/api/modules/luci.sys.iptparser.html @@ -0,0 +1,462 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance luci.sys.iptparser

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IptParser (family) + +Create a new iptables parser object.
IptParser:chain (table, chain) + +Return the given firewall chain within the given table name.
IptParser:chains (table) + +Find the names of all chains within the given table name.
IptParser:is_custom_target (target) + +Test whether the given target points to a custom chain.
IptParser:resync () + +Rebuild the internal lookup table, for example when rules have changed + +through external commands.
IptParser:tables () + +Find the names of all tables.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
IptParser (family)
+
+ + +Create a new iptables parser object. + + + +

Parameters

+
    + +
  • + family: Number specifying the address family. 4 for IPv4, 6 for IPv6 +
  • + +
+ + + + + + +

Return value:

+IptParser instance + + + +
+ + + + +
IptParser:chain (table, chain)
+
+ + +Return the given firewall chain within the given table name. + + + +

Parameters

+
    + +
  • + table: String containing the table name +
  • + +
  • + chain: String containing the chain name +
  • + +
+ + + + + + +

Return value:

+Table containing the fields "policy", "packets", "bytes" + and "rules". The "rules" field is a table of rule tables. + + + +
+ + + + +
IptParser:chains (table)
+
+ + +Find the names of all chains within the given table name. + + + +

Parameters

+
    + +
  • + table: String containing the table name +
  • + +
+ + + + + + +

Return value:

+Table of chain names in the order they occur. + + + +
+ + + + +
IptParser:is_custom_target (target)
+
+ + +Test whether the given target points to a custom chain. + + + +

Parameters

+
    + +
  • + target: String containing the target action +
  • + +
+ + + + + + +

Return value:

+Boolean indicating whether target is a custom chain. + + + +
+ + + + +
IptParser:resync ()
+
+ + +Rebuild the internal lookup table, for example when rules have changed + +through external commands. + + + + + + + +

Return value:

+nothing + + + +
+ + + + +
IptParser:tables ()
+
+ + +Find the names of all tables. + + + + + + + + +

Return value:

+Table of table names. + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.sys.net.html b/docs/api/modules/luci.sys.net.html new file mode 100644 index 000000000..e7802bb24 --- /dev/null +++ b/docs/api/modules/luci.sys.net.html @@ -0,0 +1,597 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.sys.net

+ +

+ +LuCI system utilities / network related functions. +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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.
host_hints () + +Returns a two-dimensional table of host hints.
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.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
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 + + + +
+ + + + +
host_hints ()
+
+ + +Returns a two-dimensional table of host hints. + + + + + + + + +

Return value:

+Table of table containing known hosts from various sources, + indexed by mac address. Each subtable contains at least one + of the fields "name", "ipv4" or "ipv6". + + + +
+ + + + +
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" } + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.sys.process.html b/docs/api/modules/luci.sys.process.html new file mode 100644 index 000000000..d3664817c --- /dev/null +++ b/docs/api/modules/luci.sys.process.html @@ -0,0 +1,519 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.sys.process

+ +

+ +LuCI system utilities / process related functions. +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
exec (commend, stdout, stderr, nowait) + +Execute a process, optionally capturing stdio.
info () + +Get the current process id.
list () + +Retrieve information about currently running processes.
setgroup (gid) + +Set the gid of a process identified by given pid.
setuser (uid) + +Set the uid of a process identified by given pid.
signal (pid, sig) + +Send a signal to a process identified by given pid.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
exec (commend, stdout, stderr, nowait)
+
+ + +Execute a process, optionally capturing stdio. + +Executes the process specified by the given argv vector, e.g. +{ "/bin/sh", "-c", "echo 1" } and waits for it to terminate unless a true +value has been passed for the "nowait" parameter. + +When a function value is passed for the stdout or stderr arguments, the passed +function is repeatedly called for each chunk read from the corresponding stdio +stream. The read data is passed as string containing at most 4096 bytes at a +time. + +When a true, non-function value is passed for the stdout or stderr arguments, +the data of the corresponding stdio stream is read into an internal string +buffer and returned as "stdout" or "stderr" field respectively in the result +table. + +When a true value is passed to the nowait parameter, the function does not +await process termination but returns as soon as all captured stdio streams +have been closed or - if no streams are captured - immediately after launching +the process. + + + +

Parameters

+
    + +
  • + commend: Table containing the argv vector to execute +
  • + +
  • + stdout: Callback function or boolean to indicate capturing (optional) +
  • + +
  • + stderr: Callback function or boolean to indicate capturing (optional) +
  • + +
  • + nowait: Don't wait for process termination when true (optional) +
  • + +
+ + + + + + +

Return value:

+Table containing at least the fields "code" which holds the exit + status of the invoked process or "-1" on error and "pid", which + contains the process id assigned to the spawned process. When + stdout and/or stderr capturing has been requested, it additionally + contains "stdout" and "stderr" fields respectively, holding the + captured stdio data as string. + + + +
+ + + + +
info ()
+
+ + +Get the current process id. + + + + + + + + +

Return value:

+Number containing the current pid + + + +
+ + + + +
list ()
+
+ + +Retrieve information about currently running processes. + + + + + + + + +

Return value:

+Table containing process information + + + +
+ + + + +
setgroup (gid)
+
+ + +Set the gid of a process identified by given pid. + + + +

Parameters

+
    + +
  • + gid: Number containing the Unix group id +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating successful operation + +
  2. String containing the error message if failed + +
  3. Number containing the error code if failed + +
+ + + +
+ + + + +
setuser (uid)
+
+ + +Set the uid of a process identified by given pid. + + + +

Parameters

+
    + +
  • + uid: Number containing the Unix user id +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating successful operation + +
  2. String containing the error message if failed + +
  3. Number containing the error code if failed + +
+ + + +
+ + + + +
signal (pid, sig)
+
+ + +Send a signal to a process identified by given pid. + + + +

Parameters

+
    + +
  • + pid: Number containing the process id +
  • + +
  • + sig: Signal to send (default: 15 [SIGTERM]) +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. Boolean indicating successful operation + +
  2. Number containing the error code if failed + +
+ + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.sys.user.html b/docs/api/modules/luci.sys.user.html new file mode 100644 index 000000000..b2307ad38 --- /dev/null +++ b/docs/api/modules/luci.sys.user.html @@ -0,0 +1,412 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.sys.user

+ +

+ +LuCI system utilities / user related functions. +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + +
getuser (uid) + +Retrieve user information for given uid.
checkpasswd (username, pass) + +Test whether given string matches the password of a given system user.
getpasswd (username) + +Retrieve the current user password hash.
setpasswd (username, password) + +Change the password of given user.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
getuser (uid)
+
+ + +Retrieve user information for given uid. + + + +

Parameters

+
    + +
  • + uid: Number containing the Unix user id +
  • + +
+ + + + + + +

Return value:

+Table containing the following fields: + { "uid", "gid", "name", "passwd", "dir", "shell", "gecos" } + + + +
+ + + + +
checkpasswd (username, pass)
+
+ + +Test whether given string matches the password of a given system user. + + + +

Parameters

+
    + +
  • + username: String containing the Unix user name +
  • + +
  • + pass: String containing the password to compare +
  • + +
+ + + + + + +

Return value:

+Boolean indicating whether the passwords are equal + + + +
+ + + + +
getpasswd (username)
+
+ + +Retrieve the current user password hash. + + + +

Parameters

+
    + +
  • + username: String containing the username to retrieve the password for +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. String containing the hash or nil if no password is set. + +
  2. Password database entry + +
+ + + +
+ + + + +
setpasswd (username, password)
+
+ + +Change the password of given user. + + + +

Parameters

+
    + +
  • + username: String containing the Unix user name +
  • + +
  • + password: String containing the password to compare +
  • + +
+ + + + + + +

Return value:

+Number containing 0 on success and >= 1 on error + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.sys.wifi.html b/docs/api/modules/luci.sys.wifi.html new file mode 100644 index 000000000..6c893244c --- /dev/null +++ b/docs/api/modules/luci.sys.wifi.html @@ -0,0 +1,280 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.sys.wifi

+ +

+ +LuCI system utilities / wifi related functions. +

+ + + + + + + +

Functions

+ + + + + + + +
getiwinfo (ifname) + +Get wireless information for given interface.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
getiwinfo (ifname)
+
+ + +Get wireless information for given interface. + + + +

Parameters

+
    + +
  • + ifname: String containing the interface name +
  • + +
+ + + + + + +

Return value:

+A wrapped iwinfo object instance + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/luci.util.html b/docs/api/modules/luci.util.html new file mode 100644 index 000000000..f8baddf41 --- /dev/null +++ b/docs/api/modules/luci.util.html @@ -0,0 +1,1830 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class luci.util

+ +

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
append (src, ...) + +Appends numerically indexed tables or single objects to a given table.
bigendian () + +Test whether the current system is operating in big endian mode.
class (base) + +Create a Class object (Python-style object model).
clone (object, deep) + +Clones the given object and return it's copy.
cmatch (str, pattern) + +Count the occurrences of given substring in given string.
combine (tbl1, tbl2, ...) + +Combines two or more numerically indexed tables and single objects into one table.
contains (table, value) + +Checks whether the given table contains the given value.
copcall (f, ...) + +This is a coroutine-safe drop-in replacement for Lua's "pcall"-function +
coxpcall (f, err, ...) + +This is a coroutine-safe drop-in replacement for Lua's "xpcall"-function +
dumptable (t, maxdepth) + +Recursively dumps a table to stdout, useful for testing and debugging.
exec (command) + +Execute given commandline and gather stdout.
execi (command) + +Return a line-buffered iterator over the output of given command.
get_bytecode (val) + +Return the current runtime bytecode of the given data.
imatch (val) + +Return a matching iterator for the given value.
instanceof (object, class) + +Test whether the given object is an instance of the given class.
keys (t) + +Retrieve all keys of given associative table.
kspairs (t) + +Return a key, value iterator for the given table.
libpath () + +Returns the absolute path to LuCI base directory.
parse_units (ustr) + +Parse certain units from the given string and return the canonical integer +value or 0 if the unit is unknown.
pcdata (value) + +Create valid XML PCDATA from given string.
perror (obj) + +Write given object to stderr.
restore_data (str) + +Restore data previously serialized with serialize_data().
serialize_data (val) + +Recursively serialize given data to lua code, suitable for restoring +with loadstring().
serialize_json (data, writer) + +Convert data structure to JSON +
shellquote (value) + +Safely quote value for use in shell commands.
spairs (t, f) + +Return a key, value iterator which returns the values sorted according to +the provided callback function.
split (str, pat, max, regex) + +Splits given string on a defined separator sequence and return a table +containing the resulting substrings.
strip_bytecode (code) + +Strips unnecessary lua bytecode from given string.
striptags (value) + +Strip HTML tags from given string.
threadlocal () + +Create a new or get an already existing thread local store associated with +the current active coroutine.
trim (str) + +Remove leading and trailing whitespace from given string value.
ubus (object, method, values) + +Issue an ubus call.
update (t, updates) + +Update values in given table with the values from the second given table.
urldecode (str, decode_plus) + +Decode an URL-encoded string - optionally decoding the "+" sign to space.
urlencode (str) + +URL-encode given string.
vspairs (t) + +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) +
  • + +
+ + + + + + +

Return value:

+A class object + + + +

See also:

+ + +
+ + + + +
clone (object, deep)
+
+ + +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 occurrences of given substring in given string. + + + +

Parameters

+
    + +
  • + str: String to search in +
  • + +
  • + pattern: String containing pattern to find +
  • + +
+ + + + + + +

Return value:

+Number of found occurrences + + + +
+ + + + +
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 + + + +
+ + + + +
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 iterator 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 + + + +

See also:

+ + +
+ + + + +
keys (t)
+
+ + +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 + + + +

See also:

+ + +
+ + + + +
serialize_data (val)
+
+ + +Recursively serialize given data to lua code, suitable for restoring +with loadstring(). + + + +

Parameters

+
    + +
  • + val: Value containing the data to serialize +
  • + +
+ + + + + + +

Return value:

+String value containing the serialized code + + + +

See also:

+ + +
+ + + + +
serialize_json (data, writer)
+
+ + +Convert data structure to JSON + + + +

Parameters

+
    + +
  • + data: The data to serialize +
  • + +
  • + writer: A function to write a chunk of JSON data (optional) +
  • + +
+ + + + + + +

Return value:

+String containing the JSON if called without write callback + + + +
+ + + + +
shellquote (value)
+
+ + +Safely quote value for use in shell commands. + + + +

Parameters

+
    + +
  • + value: String containing the value to quote +
  • + +
+ + + + + + +

Return value:

+Single-quote enclosed string with embedded quotes escaped + + + +
+ + + + +
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 +nterpreted 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 unnecessary 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 + + + +
+ + + + +
urldecode (str, decode_plus)
+
+ + +Decode an URL-encoded string - optionally decoding the "+" sign to space. + + + +

Parameters

+
    + +
  • + str: Input string in x-www-urlencoded format +
  • + +
  • + decode_plus: Decode "+" signs to spaces if true (optional) +
  • + +
+ + + + + + +

Return value:

+The decoded string + + + +

See also:

+ + +
+ + + + +
urlencode (str)
+
+ + +URL-encode given string. + + + +

Parameters

+
    + +
  • + str: String to encode +
  • + +
+ + + + + + +

Return value:

+String containing the encoded data + + + +

See also:

+ + +
+ + + + +
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 + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.CHANGELOG.html b/docs/api/modules/nixio.CHANGELOG.html new file mode 100644 index 000000000..94b44a5ca --- /dev/null +++ b/docs/api/modules/nixio.CHANGELOG.html @@ -0,0 +1,286 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class nixio.CHANGELOG

+ +

+ Changes and improvements.

+ + + + + + + + + + +

Tables

+ + + + + + + + + + + + +
0.2 + Initial Release.
0.3 + Service Release.
+ + + +
+
+ + + + +

Tables

+
+ +
0.2
+
+ Initial Release. +
    +
  • Initial Release
  • +
+ + + +
+ + +
0.3
+
+ Service Release. +
    +
  • Added getifaddrs() function.
  • +
  • Added getsockopt(), setsockopt(), getsockname() and getpeername() + directly to TLS-socket objects unifying the socket interface.
  • +
  • Added support for CyaSSL as cryptographical backend.
  • +
  • Added support for x509 certificates in DER format.
  • +
  • Added support for splice() in UnifiedIO.copyz().
  • +
  • Added interface to inject chunks into UnifiedIO.linesource() buffer.
  • +
  • Changed TLS behaviour to explicitly separate servers and clients.
  • +
  • Fixed usage of signed datatype breaking Base64 decoding.
  • +
  • Fixed namespace clashes for nixio.fs.
  • +
  • Fixed splice() support for some exotic C libraries.
  • +
  • Reconfigure axTLS cryptographical provider and mark it as obsolete.
  • +
+ + + +
+ + +
+ + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.CryptoHash.html b/docs/api/modules/nixio.CryptoHash.html new file mode 100644 index 000000000..7d2f48b1e --- /dev/null +++ b/docs/api/modules/nixio.CryptoHash.html @@ -0,0 +1,312 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance nixio.CryptoHash

+ +

+ Cryptographical Hash and HMAC object.

+ + + + + + + +

Functions

+ + + + + + + + + + + + +
CryptoHash:final () + Finalize the hash and return the digest.
CryptoHash:update (chunk) + Add another chunk of data to be hashed.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
CryptoHash:final ()
+
+ + Finalize the hash and return the digest. + + + + + +

Usage:

+You cannot call update on a hash object that was already finalized + you can however call final multiple times to get the digest. + + + +

Return values:

+
    + +
  1. hexdigest + +
  2. buffer containing binary digest + +
+ + + +
+ + + + +
CryptoHash:update (chunk)
+
+ + Add another chunk of data to be hashed. + + +

Parameters

+
    + +
  • + chunk: Chunk of data +
  • + +
+ + + + + + +

Return value:

+CryptoHash object (self) + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.File.html b/docs/api/modules/nixio.File.html new file mode 100644 index 000000000..7a7500a77 --- /dev/null +++ b/docs/api/modules/nixio.File.html @@ -0,0 +1,669 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance nixio.File

+ +

+ Large File Object. + Large file operations are supported up to 52 bits if the Lua number type is + double (default).

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File:close () + Close the file descriptor.
File:fileno () + Get the number of the filedescriptor.
File:lock (command, length) + Apply or test a lock on the file.
File:read (length) + Read from a file descriptor.
File:seek (offset, whence) + Reposition read / write offset of the file descriptor.
File:setblocking (blocking) + (POSIX) Set the blocking mode of the file descriptor.
File:stat (field) + Get file status and attributes.
File:sync (data_only) + Synchronizes the file with the storage device.
File:tell () + Return the current read / write offset of the file descriptor.
File:write (buffer, offset, length) + Write to the file descriptor.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
File:close ()
+
+ + Close the file descriptor. + + + + + + + +

Return value:

+true + + + +
+ + + + +
File:fileno ()
+
+ + Get the number of the filedescriptor. + + + + + + + +

Return value:

+file descriptor number + + + +
+ + + + +
File:lock (command, length)
+
+ + Apply or test a lock on the file. + + +

Parameters

+
    + +
  • + command: Locking Command ["lock", "tlock", "ulock", "test"] +
  • + +
  • + length: Amount of Bytes to lock from current offset (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • This function calls lockf() on POSIX and _locking() on Windows. + +
  • The "lock" command is blocking, "tlock" is non-blocking, + "ulock" unlocks and "test" only tests for the lock. + +
  • The "test" command is not available on Windows. + +
  • Locks are by default advisory on POSIX, but mandatory on Windows. + +
+ + + +

Return value:

+true + + + +
+ + + + +
File:read (length)
+
+ + Read from a file descriptor. + + +

Parameters

+
    + +
  • + length: Amount of data to read (in Bytes). +
  • + +
+ + + + +

Usage

+
    + +
  • Warning: It is not guaranteed that all requested data + is read at once especially when dealing with pipes. + You have to check the return value - the length of the buffer actually read - + or use the safe IO functions in the high-level IO utility module. + +
  • The length of the return buffer is limited by the (compile time) + nixio buffersize which is nixio.const.buffersize (8192 by default). + Any read request greater than that will be safely truncated to this value. + +
+ + + +

Return value:

+buffer containing data successfully read + + + +
+ + + + +
File:seek (offset, whence)
+
+ + Reposition read / write offset of the file descriptor. + The seek will be done either from the beginning of the file or relative + to the current position or relative to the end. + + +

Parameters

+
    + +
  • + offset: File Offset +
  • + +
  • + whence: Starting point ["set", "cur", "end"] +
  • + +
+ + + + +

Usage:

+This function calls lseek(). + + + +

Return value:

+new (absolute) offset position + + + +
+ + + + +
File:setblocking (blocking)
+
+ + (POSIX) Set the blocking mode of the file descriptor. + + +

Parameters

+
    + +
  • + blocking: (boolean) +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
File:stat (field)
+
+ + Get file status and attributes. + + +

Parameters

+
    + +
  • + field: Only return a specific field, not the whole table (optional) +
  • + +
+ + + + +

Usage:

+This function calls fstat(). + + + +

Return value:

+Table containing:
    +
  • atime = Last access timestamp
  • +
  • blksize = Blocksize (POSIX only)
  • +
  • blocks = Blocks used (POSIX only)
  • +
  • ctime = Creation timestamp
  • +
  • dev = Device ID
  • +
  • gid = Group ID
  • +
  • ino = Inode
  • +
  • modedec = Mode converted into a decimal number
  • +
  • modestr = Mode as string as returned by ls -l
  • +
  • mtime = Last modification timestamp
  • +
  • nlink = Number of links
  • +
  • rdev = Device ID (if special file)
  • +
  • size = Size in bytes
  • +
  • type = ["reg", "dir", "chr", "blk", "fifo", "lnk", "sock"]
  • +
  • uid = User ID
  • +
+ + + +
+ + + + +
File:sync (data_only)
+
+ + Synchronizes the file with the storage device. + Returns when the file is successfully written to the disk. + + +

Parameters

+
    + +
  • + data_only: Do not synchronize the metadata. (optional, boolean) +
  • + +
+ + + + +

Usage

+
    + +
  • This function calls fsync() when data_only equals false + otherwise fdatasync(), on Windows _commit() is used instead. + +
  • fdatasync() is only supported by Linux and Solaris. For other systems + the data_only parameter is ignored and fsync() is always called. + +
+ + + +

Return value:

+true + + + +
+ + + + +
File:tell ()
+
+ + Return the current read / write offset of the file descriptor. + + + + + +

Usage:

+This function calls lseek() with offset 0 from the current position. + + + +

Return value:

+offset position + + + +
+ + + + +
File:write (buffer, offset, length)
+
+ + Write to the file descriptor. + + +

Parameters

+
    + +
  • + buffer: Buffer holding the data to be written. +
  • + +
  • + offset: Offset to start reading the buffer from. (optional) +
  • + +
  • + length: Length of chunk to read from the buffer. (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • Warning: It is not guaranteed that all data + in the buffer is written at once especially when dealing with pipes. + You have to check the return value - the number of bytes actually written - + or use the safe IO functions in the high-level IO utility module. + +
  • Unlike standard Lua indexing the lowest offset and default is 0. + +
+ + + +

Return value:

+number of bytes written + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.README.html b/docs/api/modules/nixio.README.html new file mode 100644 index 000000000..e140659cc --- /dev/null +++ b/docs/api/modules/nixio.README.html @@ -0,0 +1,370 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class nixio.README

+ +

+ General Information.

+ + + + + + + + + + +

Tables

+ + + + + + + + + + + + + + + + + + + + + + +
Errorhandling + General error handling information.
Functions + Function conventions.
Platforms + Platform information.
TLS-Crypto + Cryptography and TLS libraries.
+ + + +
+
+ + + + +

Tables

+
+ +
Errorhandling
+
+ General error handling information. +
    +
  • Most of the functions available in this library may fail. If any error + occurs the function returns nil or false, an error code + (usually errno) and an additional error message text (if avaialable).
  • +
  • At the moment false is only returned when a non-blocking I/O function + fails with EAGAIN, EWOULDBLOCK or WSAEWOULDBLOCK for any others nil is + returned as first parameter. Therefore you can use false to write portable + non-blocking I/O applications.
  • +
  • Note that the function documentation does only mention the return values + in case of a successful operation.
  • +
  • You can find a table of common error numbers and other useful constants + like signal numbers in nixio.const e.g. nixio.const.EINVAL, + nixio.const.SIGTERM, etc. For portability there is a second error constant + table nixio.const_sock for socket error codes. This might + be important if you are dealing with Windows applications, on POSIX however + const_sock is just an alias for const.
  • +
  • With some exceptions - which are explicitly stated in the function + documentation - all blocking functions are signal-protected and will not fail + with EINTR.
  • +
  • On POSIX the SIGPIPE signal will be set to ignore upon initialization. + You should restore the default behaviour or set a custom signal handler + in your program after loading nixio if you need this behaviour.
  • +
+ + + +
+ + +
Functions
+
+ Function conventions. +
In general all functions are namend and behave like their POSIX API + counterparts - where applicable - applying the following rules: +
    +
  • Functions should be named like the underlying POSIX API function omitting + prefixes or suffixes - especially when placed in an object-context ( + lockf -> File:lock, fsync -> File:sync, dup2 -> dup, ...)
  • +
  • If you are unclear about the behaviour of a function you should consult + your OS API documentation (e.g. the manpages).
  • +
  • If the name is significantly different from the POSIX-function, the + underlying function(s) are stated in the documentation.
  • +
  • Parameters should reflect those of the C-API, buffer length arguments and + by-reference parameters should be omitted for practical purposes.
  • +
  • If a C function accepts a bitfield as parameter, it should be translated + into lower case string flags representing the flags if the bitfield is the + last parameter and also omitting prefixes or suffixes. (e.g. waitpid + (pid, &s, WNOHANG | WUNTRACED) -> waitpid(pid, "nohang", "untraced"), + getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) -> + Socket:getopt("socket", "reuseaddr"), etc.)
  • +
  • If it is not applicable to provide a string representation of the + bitfield a bitfield generator helper is provided. It is named FUNCTION_flags. + (open("/tmp/test", O_RDONLY | O_NONBLOCK) -> open("/tmp/test", open_flags( + "rdonly", "nonblock")))
  • +
+ + + +
+ + +
Platforms
+
+ Platform information. +
    +
  • The minimum platform requirements are a decent POSIX 2001 support. + Builds are more or less tested on Linux, Solaris and FreeBSD. Builds for + Windows XP SP1 and later can be compiled with MinGW either from Windows + itself or using the MinGW cross-compiler. Earlier versions of Windows are not + supported.
  • +
  • In general all functions which don't have any remarks + in their documentation are available on all platforms.
  • +
  • Functions with a (POSIX), (Linux) or similar prefix are only available + on these specific platforms. Same appplies to parameters of functions + with a similar suffix.
  • +
  • Some functions might have limitations on some platforms. This should + be stated in the documentation. Please also consult your OS API + documentation.
  • +
+ + + +
+ + +
TLS-Crypto
+
+ Cryptography and TLS libraries. +
    +
  • Currently 3 underlying cryptography libraries are supported: openssl, + cyassl and axTLS. The name of the library in use is written to + nixio.tls_provider
  • +
  • You should whenever possible use openssl or cyassl as axTLS has only + limited support. It does not provide support for non-blocking sockets and + is probably less audited than the other ones.
  • +
  • As the supported Windows versions are not suitable for embedded devices + axTLS is at the moment not supported on Windows.
  • +
+ + + +
+ + +
+ + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.Socket.html b/docs/api/modules/nixio.Socket.html new file mode 100644 index 000000000..185099125 --- /dev/null +++ b/docs/api/modules/nixio.Socket.html @@ -0,0 +1,1029 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance nixio.Socket

+ +

+ Socket Object. + Supports IPv4, IPv6 and UNIX (POSIX only) families.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Socket:accept () + Accept a connection on the socket.
Socket:bind (host, port) + Bind the socket to a network address.
Socket:close () + Close the socket.
Socket:connect (host, port) + Connect the socket to a network address.
Socket:fileno () + Get the number of the filedescriptor.
Socket:getopt (level, option) + Get a socket option.
Socket:getpeername () + Get the peer address of a socket.
Socket:getsockname () + Get the local address of a socket.
Socket:listen (backlog) + Listen for connections on the socket.
Socket:read  (length) + Receive a message on the socket (This is an alias for recv).
Socket:recv  (length) + Receive a message on the socket.
Socket:recvfrom (length) + Receive a message on the socket including the senders source address.
Socket:send (buffer, offset, length) + Send a message on the socket.
Socket:sendto (buffer, host, port, offset, length) + Send a message on the socket specifying the destination.
Socket:setblocking (blocking) + Set the blocking mode of the socket.
Socket:setopt (level, option, value) + Set a socket option.
Socket:shutdown (how) + Shut down part of a full-duplex connection.
Socket:write (buffer, offset, length) + Send a message on the socket (This is an alias for send).
+ + + + + + +
+
+ + +

Functions

+
+ + + +
Socket:accept ()
+
+ + Accept a connection on the socket. + + + + + + + +

Return values:

+
    + +
  1. Socket Object + +
  2. Peer IP-Address + +
  3. Peer Port + +
+ + + +
+ + + + +
Socket:bind (host, port)
+
+ + Bind the socket to a network address. + + +

Parameters

+
    + +
  • + host: Host (optional, default: all addresses) +
  • + +
  • + port: Port or service description +
  • + +
+ + + + +

Usage

+
    + +
  • This function calls getaddrinfo() and bind() but NOT listen(). + +
  • If host is a domain name it will be looked up and bind() + tries the IP-Addresses in the order returned by the DNS resolver + until the bind succeeds. + +
  • UNIX sockets ignore the port, + and interpret host as a socket path. + +
+ + + +

Return value:

+true + + + +
+ + + + +
Socket:close ()
+
+ + Close the socket. + + + + + + + +

Return value:

+true + + + +
+ + + + +
Socket:connect (host, port)
+
+ + Connect the socket to a network address. + + +

Parameters

+
    + +
  • + host: Hostname or IP-Address (optional, default: localhost) +
  • + +
  • + port: Port or service description +
  • + +
+ + + + +

Usage

+
    + +
  • This function calls getaddrinfo() and connect(). + +
  • If host is a domain name it will be looked up and connect() + tries the IP-Addresses in the order returned by the DNS resolver + until the connect succeeds. + +
  • UNIX sockets ignore the port, + and interpret host as a socket path. + +
+ + + +

Return value:

+true + + + +
+ + + + +
Socket:fileno ()
+
+ + Get the number of the filedescriptor. + + + + + + + +

Return value:

+file descriptor number + + + +
+ + + + +
Socket:getopt (level, option)
+
+ + Get a socket option. + + +

Parameters

+
    + +
  • + level: Level ["socket", "tcp", "ip", "ipv6"] +
  • + +
  • + option: Option ["keepalive", "reuseaddr", "sndbuf", "rcvbuf", + "priority", "broadcast", "linger", "sndtimeo", "rcvtimeo", "dontroute", + "bindtodevice", "error", "oobinline", "cork" (TCP), "nodelay" (TCP), + "mtu" (IP, IPv6), "hdrincl" (IP), "multicast_ttl" (IP), "multicast_loop" + (IP, IPv6), "multicast_if" (IP, IPv6), "v6only" (IPv6), "multicast_hops" + (IPv6), "add_membership" (IP, IPv6), "drop_membership" (IP, IPv6)] +
  • + +
+ + + + + + +

Return value:

+Value + + + +
+ + + + +
Socket:getpeername ()
+
+ + Get the peer address of a socket. + + + + + + + +

Return values:

+
    + +
  1. IP-Address + +
  2. Port + +
+ + + +
+ + + + +
Socket:getsockname ()
+
+ + Get the local address of a socket. + + + + + + + +

Return values:

+
    + +
  1. IP-Address + +
  2. Port + +
+ + + +
+ + + + +
Socket:listen (backlog)
+
+ + Listen for connections on the socket. + + +

Parameters

+
    + +
  • + backlog: Length of queue for pending connections +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
Socket:read  (length)
+
+ + Receive a message on the socket (This is an alias for recv). + See the recvfrom description for more details. + + +

Parameters

+
    + +
  • + length: Amount of data to read (in Bytes). +
  • + +
+ + + + + + +

Return value:

+buffer containing data successfully read + + + +

See also:

+ + +
+ + + + +
Socket:recv  (length)
+
+ + Receive a message on the socket. + This function is identical to recvfrom except that it does not return + the sender's source address. See the recvfrom description for more details. + + +

Parameters

+
    + +
  • + length: Amount of data to read (in Bytes). +
  • + +
+ + + + + + +

Return value:

+buffer containing data successfully read + + + +

See also:

+ + +
+ + + + +
Socket:recvfrom (length)
+
+ + Receive a message on the socket including the senders source address. + + +

Parameters

+
    + +
  • + length: Amount of data to read (in Bytes). +
  • + +
+ + + + +

Usage

+
    + +
  • Warning: It is not guaranteed that all requested data + is read at once. + You have to check the return value - the length of the buffer actually read - + or use the safe IO functions in the high-level IO utility module. + +
  • The length of the return buffer is limited by the (compile time) + nixio buffersize which is nixio.const.buffersize (8192 by default). + Any read request greater than that will be safely truncated to this value. + +
+ + + +

Return values:

+
    + +
  1. buffer containing data successfully read + +
  2. host IP-Address of the sender + +
  3. port Port of the sender + +
+ + + +
+ + + + +
Socket:send (buffer, offset, length)
+
+ + Send a message on the socket. + This function is identical to sendto except for the missing destination + parameters. See the sendto description for a detailed description. + + +

Parameters

+
    + +
  • + buffer: Buffer holding the data to be written. +
  • + +
  • + offset: Offset to start reading the buffer from. (optional) +
  • + +
  • + length: Length of chunk to read from the buffer. (optional) +
  • + +
+ + + + + + +

Return value:

+number of bytes written + + + +

See also:

+ + +
+ + + + +
Socket:sendto (buffer, host, port, offset, length)
+
+ + Send a message on the socket specifying the destination. + + +

Parameters

+
    + +
  • + buffer: Buffer holding the data to be written. +
  • + +
  • + host: Target IP-Address +
  • + +
  • + port: Target Port +
  • + +
  • + offset: Offset to start reading the buffer from. (optional) +
  • + +
  • + length: Length of chunk to read from the buffer. (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • Warning: It is not guaranteed that all data + in the buffer is written at once. + You have to check the return value - the number of bytes actually written - + or use the safe IO functions in the high-level IO utility module. + +
  • Unlike standard Lua indexing the lowest offset and default is 0. + +
+ + + +

Return value:

+number of bytes written + + + +
+ + + + +
Socket:setblocking (blocking)
+
+ + Set the blocking mode of the socket. + + +

Parameters

+
    + +
  • + blocking: (boolean) +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
Socket:setopt (level, option, value)
+
+ + Set a socket option. + + +

Parameters

+
    + +
  • + level: Level ["socket", "tcp", "ip", "ipv6"] +
  • + +
  • + option: Option ["keepalive", "reuseaddr", "sndbuf", "rcvbuf", + "priority", "broadcast", "linger", "sndtimeo", "rcvtimeo", "dontroute", + "bindtodevice", "error", "oobinline", "cork" (TCP), "nodelay" (TCP), + "mtu" (IP, IPv6), "hdrincl" (IP), "multicast_ttl" (IP), "multicast_loop" + (IP, IPv6), "multicast_if" (IP, IPv6), "v6only" (IPv6), "multicast_hops" + (IPv6), "add_membership" (IP, IPv6), "drop_membership" (IP, IPv6)] +
  • + +
  • + value: Value +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
Socket:shutdown (how)
+
+ + Shut down part of a full-duplex connection. + + +

Parameters

+
    + +
  • + how: (optional, default: rdwr) ["rdwr", "rd", "wr"] +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
Socket:write (buffer, offset, length)
+
+ + Send a message on the socket (This is an alias for send). + See the sendto description for a detailed description. + + +

Parameters

+
    + +
  • + buffer: Buffer holding the data to be written. +
  • + +
  • + offset: Offset to start reading the buffer from. (optional) +
  • + +
  • + length: Length of chunk to read from the buffer. (optional) +
  • + +
+ + + + + + +

Return value:

+number of bytes written + + + +

See also:

+ + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.TLSContext.html b/docs/api/modules/nixio.TLSContext.html new file mode 100644 index 000000000..c84d31895 --- /dev/null +++ b/docs/api/modules/nixio.TLSContext.html @@ -0,0 +1,475 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance nixio.TLSContext

+ +

+ Transport Layer Security Context Object.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TLSContext:create (socket) + Create a TLS Socket from a socket descriptor.
TLSContext:set_cert (path) + Assign a PEM certificate to this context.
TLSContext:set_ciphers (cipherlist) + Set the available ciphers for this context.
TLSContext:set_key (path) + Assign a PEM private key to this context.
TLSContext:set_verify (flag1, ...) + Set the verification flags of this context.
TLSContext:set_verify_depth (depth) + Set the verification depth of this context.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
TLSContext:create (socket)
+
+ + Create a TLS Socket from a socket descriptor. + + +

Parameters

+
    + +
  • + socket: Socket Object +
  • + +
+ + + + + + +

Return value:

+TLSSocket Object + + + +
+ + + + +
TLSContext:set_cert (path)
+
+ + Assign a PEM certificate to this context. + + +

Parameters

+
    + +
  • + path: Certificate File path +
  • + +
+ + + + +

Usage:

+This function calls SSL_CTX_use_certificate_chain_file(). + + + +

Return value:

+true + + + +
+ + + + +
TLSContext:set_ciphers (cipherlist)
+
+ + Set the available ciphers for this context. + + +

Parameters

+
    + +
  • + cipherlist: String containing a list of ciphers +
  • + +
+ + + + +

Usage:

+This function calls SSL_CTX_set_cipher_list(). + + + +

Return value:

+true + + + +
+ + + + +
TLSContext:set_key (path)
+
+ + Assign a PEM private key to this context. + + +

Parameters

+
    + +
  • + path: Private Key File path +
  • + +
+ + + + +

Usage:

+This function calls SSL_CTX_use_PrivateKey_file(). + + + +

Return value:

+true + + + +
+ + + + +
TLSContext:set_verify (flag1, ...)
+
+ + Set the verification flags of this context. + + +

Parameters

+
    + +
  • + flag1: First Flag ["none", "peer", "verify_fail_if_no_peer_cert", + "client_once"] +
  • + +
  • + ...: More Flags [-"-] +
  • + +
+ + + + +

Usage:

+This function calls SSL_CTX_set_verify(). + + + +

Return value:

+true + + + +
+ + + + +
TLSContext:set_verify_depth (depth)
+
+ + Set the verification depth of this context. + + +

Parameters

+
    + +
  • + depth: Depth +
  • + +
+ + + + +

Usage:

+This function calls SSL_CTX_set_verify_depth(). + + + +

Return value:

+true + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.TLSSocket.html b/docs/api/modules/nixio.TLSSocket.html new file mode 100644 index 000000000..5d6098a9f --- /dev/null +++ b/docs/api/modules/nixio.TLSSocket.html @@ -0,0 +1,571 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance nixio.TLSSocket

+ +

+ TLS Socket Object. + TLS Sockets contain the underlying socket and context in the fields + "socket" and "context".

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TLSSocket:accept () + Wait for a TLS handshake from a client.
TLSSocket:connect () + Initiate the TLS handshake as client with the server.
TLSSocket:read  (length) + Receive a message on the socket (This is an alias for recv).
TLSSocket:recv (length) + Receive a message on the socket.
TLSSocket:send (buffer, offset, length) + Send a message to the socket.
TLSSocket:shutdown () + Shut down the TLS connection.
TLSSocket:write (buffer, offset, length) + Send a message on the socket (This is an alias for send).
+ + + + + + +
+
+ + +

Functions

+
+ + + +
TLSSocket:accept ()
+
+ + Wait for a TLS handshake from a client. + + + + + +

Usage

+
    + +
  • This function calls SSL_accept(). + +
  • You have to call either connect or accept before transmitting data. + +
+ + + +

Return value:

+true + + + +

See also:

+ + +
+ + + + +
TLSSocket:connect ()
+
+ + Initiate the TLS handshake as client with the server. + + + + + +

Usage

+
    + +
  • This function calls SSL_connect(). + +
  • You have to call either connect or accept before transmitting data. + +
+ + + +

Return value:

+true + + + +

See also:

+ + +
+ + + + +
TLSSocket:read  (length)
+
+ + Receive a message on the socket (This is an alias for recv). + See the recv description for more details. + + +

Parameters

+
    + +
  • + length: Amount of data to read (in Bytes). +
  • + +
+ + + + + + +

Return value:

+buffer containing data successfully read + + + +

See also:

+ + +
+ + + + +
TLSSocket:recv (length)
+
+ + Receive a message on the socket. + + +

Parameters

+
    + +
  • + length: Amount of data to read (in Bytes). +
  • + +
+ + + + +

Usage

+
    + +
  • This function calls SSL_read(). + +
  • Warning: It is not guaranteed that all requested data + is read at once. + You have to check the return value - the length of the buffer actually read - + or use the safe IO functions in the high-level IO utility module. + +
  • The length of the return buffer is limited by the (compile time) + nixio buffersize which is nixio.const.buffersize (8192 by default). + Any read request greater than that will be safely truncated to this value. + +
+ + + +

Return value:

+buffer containing data successfully read + + + +
+ + + + +
TLSSocket:send (buffer, offset, length)
+
+ + Send a message to the socket. + + +

Parameters

+
    + +
  • + buffer: Buffer holding the data to be written. +
  • + +
  • + offset: Offset to start reading the buffer from. (optional) +
  • + +
  • + length: Length of chunk to read from the buffer. (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • This function calls SSL_write(). + +
  • Warning: It is not guaranteed that all data + in the buffer is written at once. + You have to check the return value - the number of bytes actually written - + or use the safe IO functions in the high-level IO utility module. + +
  • Unlike standard Lua indexing the lowest offset and default is 0. + +
+ + + +

Return value:

+number of bytes written + + + +
+ + + + +
TLSSocket:shutdown ()
+
+ + Shut down the TLS connection. + + + + + +

Usage:

+This function calls SSL_shutdown(). + + + +

Return value:

+true + + + +
+ + + + +
TLSSocket:write (buffer, offset, length)
+
+ + Send a message on the socket (This is an alias for send). + See the send description for a detailed description. + + +

Parameters

+
    + +
  • + buffer: Buffer holding the data to be written. +
  • + +
  • + offset: Offset to start reading the buffer from. (optional) +
  • + +
  • + length: Length of chunk to read from the buffer. (optional) +
  • + +
+ + + + + + +

Return value:

+number of bytes written + + + +

See also:

+ + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.UnifiedIO.html b/docs/api/modules/nixio.UnifiedIO.html new file mode 100644 index 000000000..6410ffb42 --- /dev/null +++ b/docs/api/modules/nixio.UnifiedIO.html @@ -0,0 +1,763 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Object Instance nixio.UnifiedIO

+ +

+ Unified high-level I/O utility API for Files, Sockets and TLS-Sockets. + These functions are added to the object function tables by doing + require "nixio.util", can be used on all nixio IO Descriptors and + are based on the shared low-level read() and write() functions.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
UnifiedIO:blocksource (blocksize, limit) + Create a block-based iterator.
UnifiedIO:close () + Close the descriptor.
UnifiedIO:copy (fdout, size) + Copy data from the current descriptor to another one.
UnifiedIO:copyz (fdout, size) + Copy data from the current descriptor to another one using kernel-space + copying if possible.
UnifiedIO:is_file () + Test whether the I/O-Descriptor is a file.
UnifiedIO:is_socket () + Test whether the I/O-Descriptor is a socket.
UnifiedIO:is_tls_socket () + Test whether the I/O-Descriptor is a TLS socket.
UnifiedIO:linesource (limit) + Create a line-based iterator.
UnifiedIO:readall (length) + Read a block of data and wait until all data is available.
UnifiedIO:sink (close_when_done) + Create a sink.
UnifiedIO:writeall (block) + Write a block of data and wait until all data is written.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
UnifiedIO:blocksource (blocksize, limit)
+
+ + Create a block-based iterator. + + +

Parameters

+
    + +
  • + blocksize: Advisory blocksize (optional) +
  • + +
  • + limit: Amount of data to consume (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • This function uses the low-level read function of the descriptor. + +
  • The blocksize given is only advisory and to be seen as an upper limit, + if an underlying read returns less bytes the chunk is nevertheless returned. + +
  • If the limit parameter is omitted, the iterator returns data + until an end-of-file, end-of-stream, connection shutdown or similar happens. + +
  • The iterator will not buffer so it is safe to mix with calls to read. + +
  • If the descriptor is non-blocking the iterator may fail with EAGAIN. + +
  • The iterator can be used as an LTN12 source. + +
+ + + +

Return value:

+Block-based Iterator + + + +
+ + + + +
UnifiedIO:close ()
+
+ + Close the descriptor. + + + + + +

Usage:

+If the descriptor is a TLS-socket the underlying descriptor is + closed without touching the TLS connection. + + + +

Return value:

+true + + + +
+ + + + +
UnifiedIO:copy (fdout, size)
+
+ + Copy data from the current descriptor to another one. + + +

Parameters

+
    + +
  • + fdout: Target Descriptor +
  • + +
  • + size: Bytes to copy (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • This function uses the blocksource function of the source descriptor + and the sink function of the target descriptor. + +
  • If the limit parameter is omitted, data is copied + until an end-of-file, end-of-stream, connection shutdown or similar happens. + +
  • If the descriptor is non-blocking the function may fail with EAGAIN. + +
+ + + +

Return values:

+
    + +
  1. bytes that were successfully written if no error occurred + +
  2. - reserved for error code - + +
  3. - reserved for error message - + +
  4. bytes that were successfully written even if an error occurred + +
+ + + +
+ + + + +
UnifiedIO:copyz (fdout, size)
+
+ + Copy data from the current descriptor to another one using kernel-space + copying if possible. + + +

Parameters

+
    + +
  • + fdout: Target Descriptor +
  • + +
  • + size: Bytes to copy (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • This function uses the sendfile() syscall to copy the data or the + blocksource function of the source descriptor and the sink function + of the target descriptor as a fallback mechanism. + +
  • If the limit parameter is omitted, data is copied + until an end-of-file, end-of-stream, connection shutdown or similar happens. + +
  • If the descriptor is non-blocking the function may fail with EAGAIN. + +
+ + + +

Return values:

+
    + +
  1. bytes that were successfully written if no error occurred + +
  2. - reserved for error code - + +
  3. - reserved for error message - + +
  4. bytes that were successfully written even if an error occurred + +
+ + + +
+ + + + +
UnifiedIO:is_file ()
+
+ + Test whether the I/O-Descriptor is a file. + + + + + + + +

Return value:

+boolean + + + +
+ + + + +
UnifiedIO:is_socket ()
+
+ + Test whether the I/O-Descriptor is a socket. + + + + + + + +

Return value:

+boolean + + + +
+ + + + +
UnifiedIO:is_tls_socket ()
+
+ + Test whether the I/O-Descriptor is a TLS socket. + + + + + + + +

Return value:

+boolean + + + +
+ + + + +
UnifiedIO:linesource (limit)
+
+ + Create a line-based iterator. + Lines may end with either \n or \r\n, these control chars are not included + in the return value. + + +

Parameters

+
    + +
  • + limit: Line limit +
  • + +
+ + + + +

Usage

+
    + +
  • This function uses the low-level read function of the descriptor. + +
  • Note: This function uses an internal buffer to read + ahead. Do NOT mix calls to read(all) and the returned iterator. If you want + to stop reading line-based and want to use the read(all) functions instead + you can pass "true" to the iterator which will flush the buffer + and return the bufferd data. + +
  • If the limit parameter is omitted, this function uses the nixio + buffersize (8192B by default). + +
  • If the descriptor is non-blocking the iterator may fail with EAGAIN. + +
  • The iterator can be used as an LTN12 source. + +
+ + + +

Return value:

+Line-based Iterator + + + +
+ + + + +
UnifiedIO:readall (length)
+
+ + Read a block of data and wait until all data is available. + + +

Parameters

+
    + +
  • + length: Bytes to read (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • This function uses the low-level read function of the descriptor. + +
  • If the length parameter is omitted, this function returns all data + that can be read before an end-of-file, end-of-stream, connection shutdown + or similar happens. + +
  • If the descriptor is non-blocking this function may fail with EAGAIN. + +
+ + + +

Return values:

+
    + +
  1. data that was successfully read if no error occurred + +
  2. - reserved for error code - + +
  3. - reserved for error message - + +
  4. data that was successfully read even if an error occurred + +
+ + + +
+ + + + +
UnifiedIO:sink (close_when_done)
+
+ + Create a sink. + This sink will simply write all data that it receives and optionally + close the descriptor afterwards. + + +

Parameters

+
    + +
  • + close_when_done: (optional, boolean) +
  • + +
+ + + + +

Usage

+
    + +
  • This function uses the writeall function of the descriptor. + +
  • If the descriptor is non-blocking the sink may fail with EAGAIN. + +
  • The iterator can be used as an LTN12 sink. + +
+ + + +

Return value:

+Sink + + + +
+ + + + +
UnifiedIO:writeall (block)
+
+ + Write a block of data and wait until all data is written. + + +

Parameters

+
    + +
  • + block: Bytes to write +
  • + +
+ + + + +

Usage

+
    + +
  • This function uses the low-level write function of the descriptor. + +
  • If the descriptor is non-blocking this function may fail with EAGAIN. + +
+ + + +

Return values:

+
    + +
  1. bytes that were successfully written if no error occurred + +
  2. - reserved for error code - + +
  3. - reserved for error message - + +
  4. bytes that were successfully written even if an error occurred + +
+ + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.bin.html b/docs/api/modules/nixio.bin.html new file mode 100644 index 000000000..48e6fcd8b --- /dev/null +++ b/docs/api/modules/nixio.bin.html @@ -0,0 +1,423 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class nixio.bin

+ +

+ Binary operations and conversion.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
b64decode (buffer) + Base64 decode a given buffer.
b64encode (buffer) + Base64 encode a given buffer.
crc32 (buffer, initial) + Calculate the CRC32 value of a buffer.
hexlify (buffer) + Return a hexadecimal ASCII represantation of the content of a buffer.
unhexlify (hexvalue) + Return a binary buffer from a hexadecimal ASCII representation.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
b64decode (buffer)
+
+ + Base64 decode a given buffer. + + +

Parameters

+
    + +
  • + buffer: Base 64 Encoded data +
  • + +
+ + + + + + +

Return value:

+binary data + + + +
+ + + + +
b64encode (buffer)
+
+ + Base64 encode a given buffer. + + +

Parameters

+
    + +
  • + buffer: Buffer +
  • + +
+ + + + + + +

Return value:

+base64 encoded buffer + + + +
+ + + + +
crc32 (buffer, initial)
+
+ + Calculate the CRC32 value of a buffer. + + +

Parameters

+
    + +
  • + buffer: Buffer +
  • + +
  • + initial: Initial CRC32 value (optional) +
  • + +
+ + + + + + +

Return value:

+crc32 value + + + +
+ + + + +
hexlify (buffer)
+
+ + Return a hexadecimal ASCII represantation of the content of a buffer. + + +

Parameters

+
    + +
  • + buffer: Buffer +
  • + +
+ + + + + + +

Return value:

+representation using characters [0-9a-f] + + + +
+ + + + +
unhexlify (hexvalue)
+
+ + Return a binary buffer from a hexadecimal ASCII representation. + + +

Parameters

+
    + +
  • + hexvalue: representation using characters [0-9a-f] +
  • + +
+ + + + + + +

Return value:

+binary data + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.bit.html b/docs/api/modules/nixio.bit.html new file mode 100644 index 000000000..419736363 --- /dev/null +++ b/docs/api/modules/nixio.bit.html @@ -0,0 +1,740 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class nixio.bit

+ +

+ Bitfield operators and mainpulation functions. + Can be used as a drop-in replacement for bitlib.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
arshift (oper, shift) + Arithmetically right shift a number.
band (oper1, oper2, ...) + Bitwise AND several numbers.
bnot (oper) + Invert given number.
bor (oper1, oper2, ...) + Bitwise OR several numbers.
bxor (oper1, oper2, ...) + Bitwise XOR several numbers.
cast (oper) + Cast a number to the bit-operating range.
check (bitfield, flag1, ...) + Checks whether given flags are set in a bitfield.
div (oper1, oper2, ...) + Integer division of 2 or more numbers.
lshift (oper, shift) + Left shift a number.
rshift (oper, shift) + Right shift a number.
set (bitfield, flag1, ...) + Sets one or more flags of a bitfield.
unset (bitfield, flag1, ...) + Unsets one or more flags of a bitfield.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
arshift (oper, shift)
+
+ + Arithmetically right shift a number. + + +

Parameters

+
    + +
  • + oper: number +
  • + +
  • + shift: bits to shift +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
band (oper1, oper2, ...)
+
+ + Bitwise AND several numbers. + + +

Parameters

+
    + +
  • + oper1: First Operand +
  • + +
  • + oper2: Second Operand +
  • + +
  • + ...: More Operands +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
bnot (oper)
+
+ + Invert given number. + + +

Parameters

+
    + +
  • + oper: Operand +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
bor (oper1, oper2, ...)
+
+ + Bitwise OR several numbers. + + +

Parameters

+
    + +
  • + oper1: First Operand +
  • + +
  • + oper2: Second Operand +
  • + +
  • + ...: More Operands +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
bxor (oper1, oper2, ...)
+
+ + Bitwise XOR several numbers. + + +

Parameters

+
    + +
  • + oper1: First Operand +
  • + +
  • + oper2: Second Operand +
  • + +
  • + ...: More Operands +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
cast (oper)
+
+ + Cast a number to the bit-operating range. + + +

Parameters

+
    + +
  • + oper: number +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
check (bitfield, flag1, ...)
+
+ + Checks whether given flags are set in a bitfield. + + +

Parameters

+
    + +
  • + bitfield: Bitfield +
  • + +
  • + flag1: First Flag +
  • + +
  • + ...: More Flags +
  • + +
+ + + + + + +

Return value:

+true when all flags are set, otherwise false + + + +
+ + + + +
div (oper1, oper2, ...)
+
+ + Integer division of 2 or more numbers. + + +

Parameters

+
    + +
  • + oper1: Operand 1 +
  • + +
  • + oper2: Operand 2 +
  • + +
  • + ...: More Operands +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
lshift (oper, shift)
+
+ + Left shift a number. + + +

Parameters

+
    + +
  • + oper: number +
  • + +
  • + shift: bits to shift +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
rshift (oper, shift)
+
+ + Right shift a number. + + +

Parameters

+
    + +
  • + oper: number +
  • + +
  • + shift: bits to shift +
  • + +
+ + + + + + +

Return value:

+number + + + +
+ + + + +
set (bitfield, flag1, ...)
+
+ + Sets one or more flags of a bitfield. + + +

Parameters

+
    + +
  • + bitfield: Bitfield +
  • + +
  • + flag1: First Flag +
  • + +
  • + ...: More Flags +
  • + +
+ + + + + + +

Return value:

+altered bitfield + + + +
+ + + + +
unset (bitfield, flag1, ...)
+
+ + Unsets one or more flags of a bitfield. + + +

Parameters

+
    + +
  • + bitfield: Bitfield +
  • + +
  • + flag1: First Flag +
  • + +
  • + ...: More Flags +
  • + +
+ + + + + + +

Return value:

+altered bitfield + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.crypto.html b/docs/api/modules/nixio.crypto.html new file mode 100644 index 000000000..b91fe28c1 --- /dev/null +++ b/docs/api/modules/nixio.crypto.html @@ -0,0 +1,315 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class nixio.crypto

+ +

+ Cryptographical library.

+ + + + + + + +

Functions

+ + + + + + + + + + + + +
hash (algo) + Create a hash object.
hmac (algo, key) + Create a HMAC object.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
hash (algo)
+
+ + Create a hash object. + + +

Parameters

+
    + +
  • + algo: Algorithm ["sha1", "md5"] +
  • + +
+ + + + + + +

Return value:

+CryptoHash Object + + + +
+ + + + +
hmac (algo, key)
+
+ + Create a HMAC object. + + +

Parameters

+
    + +
  • + algo: Algorithm ["sha1", "md5"] +
  • + +
  • + key: HMAC-Key +
  • + +
+ + + + + + +

Return value:

+CryptoHash Object + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.fs.html b/docs/api/modules/nixio.fs.html new file mode 100644 index 000000000..c9d34591c --- /dev/null +++ b/docs/api/modules/nixio.fs.html @@ -0,0 +1,1558 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class nixio.fs

+ +

+ Low-level and high-level filesystem manipulation library.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
access (path, mode1, ...) + Check user's permission on a file.
basename (path) + Strip the directory part from a path.
chmod (path, mode) + Change the file mode.
chown (path, user, group) + (POSIX) Change owner and group of a file.
copy (src, dest) + Copy a file, directory or symlink non-recursively preserving file mode, + timestamps, owner and group.
copyr (src, dest) + Copy a file, directory or symlink recursively preserving file mode, + timestamps, owner and group.
datacopy (src, dest, limit) + Copy data between files.
dir (path) + Iterate over the entries of a directory.
dirname (path) + Strip the base from a path.
glob (pattern) + (POSIX) Find pathnames matching a pattern.
lchown (path, user, group) + (POSIX) Change owner and group of a file and do not resolve + if target is a symlink.
link (oldpath, newpath) + Create a hard link.
lstat (path, field) + Get file status and attributes and do not resolve if target is a symlink.
mkdir (path, mode) + Create a new directory.
mkdirr (dest, mode) + Create a directory and all needed parent directories recursively.
mkfifo (path, mode) + (POSIX) Create a FIFO (named pipe).
move (src, dest) + Rename a file, directory or symlink non-recursively across filesystems.
mover (src, dest) + Rename a file, directory or symlink recursively across filesystems.
readfile (path, limit) + Read the contents of a file into a buffer.
readlink (path) + (POSIX) Read the target of a symbolic link.
realpath (path) + Return the cannonicalized absolute pathname.
remove (path) + Remove a file or directory.
rename (src, dest) + Renames a file or directory.
rmdir (path) + Remove an empty directory.
stat (path, field) + Get file status and attributes.
statvfs (path) + (POSIX) Get filesystem statistics.
symlink (oldpath, newpath) + (POSIX) Create a symbolic link.
unlink (path) + Delete a name and - if no links are left - the associated file.
utimes (path, actime, mtime) + Change file last access and last modification time.
writefile (path, data) + Write a buffer into a file truncating the file first.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
access (path, mode1, ...)
+
+ + Check user's permission on a file. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + mode1: First Mode to check ["f", "r", "w", "x"] +
  • + +
  • + ...: More Modes to check [-"-] +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
basename (path)
+
+ + Strip the directory part from a path. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
+ + + + +

Usage:

+This function cannot fail and will never return nil. + + + +

Return value:

+basename + + + +
+ + + + +
chmod (path, mode)
+
+ + Change the file mode. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + mode: File mode + [decimal mode number, "[-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT]"] +
  • + +
+ + + + +

Usage

+
    + +
  • Windows only supports setting the write-protection through the + "Writable to others" bit. + +
  • Notice: The mode-flag for the functions + open, mkdir, mkfifo are affected by the umask. + +
+ + + +

Return value:

+true + + + +

See also:

+ + +
+ + + + +
chown (path, user, group)
+
+ + (POSIX) Change owner and group of a file. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + user: User ID or Username (optional) +
  • + +
  • + group: Group ID or Groupname (optional) +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
copy (src, dest)
+
+ + Copy a file, directory or symlink non-recursively preserving file mode, + timestamps, owner and group. + + +

Parameters

+
    + +
  • + src: Source path +
  • + +
  • + dest: Destination path +
  • + +
+ + + + +

Usage:

+The destination must always be a full destination path e.g. do not + omit the basename even if source and destination basename are equal. + + + +

Return value:

+true + + + +
+ + + + +
copyr (src, dest)
+
+ + Copy a file, directory or symlink recursively preserving file mode, + timestamps, owner and group. + + +

Parameters

+
    + +
  • + src: Source path +
  • + +
  • + dest: Destination path +
  • + +
+ + + + +

Usage:

+The destination must always be a full destination path e.g. do not + omit the basename even if source and destination basename are equal. + + + +

Return value:

+true + + + +
+ + + + +
datacopy (src, dest, limit)
+
+ + Copy data between files. + + +

Parameters

+
    + +
  • + src: Source file path +
  • + +
  • + dest: Destination file path +
  • + +
  • + limit: Maximum bytes to copy (optional) +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
dir (path)
+
+ + Iterate over the entries of a directory. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
+ + + + +

Usage:

+The special entries "." and ".." are omitted. + + + +

Return value:

+directory iterator returning one entry per call + + + +
+ + + + +
dirname (path)
+
+ + Strip the base from a path. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
+ + + + +

Usage:

+This function cannot fail and will never return nil. + + + +

Return value:

+dirname + + + +
+ + + + +
glob (pattern)
+
+ + (POSIX) Find pathnames matching a pattern. + + +

Parameters

+
    + +
  • + pattern: Pattern +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. path iterator + +
  2. number of matches + +
+ + + +
+ + + + +
lchown (path, user, group)
+
+ + (POSIX) Change owner and group of a file and do not resolve + if target is a symlink. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + user: User ID or Username (optional) +
  • + +
  • + group: Group ID or Groupname (optional) +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
link (oldpath, newpath)
+
+ + Create a hard link. + + +

Parameters

+
    + +
  • + oldpath: Path +
  • + +
  • + newpath: Path +
  • + +
+ + + + +

Usage:

+This function calls link() on POSIX and CreateHardLink() on Windows. + + + +

Return value:

+true + + + +
+ + + + +
lstat (path, field)
+
+ + Get file status and attributes and do not resolve if target is a symlink. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + field: Only return a specific field, not the whole table (optional) +
  • + +
+ + + + + + +

Return value:

+Table containing attributes (see stat for a detailed description) + + + +

See also:

+ + +
+ + + + +
mkdir (path, mode)
+
+ + Create a new directory. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + mode: File mode (optional, see chmod and umask) +
  • + +
+ + + + + + +

Return value:

+true + + + +

See also:

+ + +
+ + + + +
mkdirr (dest, mode)
+
+ + Create a directory and all needed parent directories recursively. + + +

Parameters

+
    + +
  • + dest: Destination path +
  • + +
  • + mode: File mode (optional, see chmod and umask) +
  • + +
+ + + + + + +

Return value:

+true + + + +

See also:

+ + +
+ + + + +
mkfifo (path, mode)
+
+ + (POSIX) Create a FIFO (named pipe). + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + mode: File mode (optional, see chmod and umask) +
  • + +
+ + + + + + +

Return value:

+true + + + +

See also:

+ + +
+ + + + +
move (src, dest)
+
+ + Rename a file, directory or symlink non-recursively across filesystems. + + +

Parameters

+
    + +
  • + src: Source path +
  • + +
  • + dest: Destination path +
  • + +
+ + + + +

Usage:

+The destination must always be a full destination path e.g. do not + omit the basename even if source and destination basename are equal. + + + +

Return value:

+true + + + +
+ + + + +
mover (src, dest)
+
+ + Rename a file, directory or symlink recursively across filesystems. + + +

Parameters

+
    + +
  • + src: Source path +
  • + +
  • + dest: Destination path +
  • + +
+ + + + +

Usage:

+The destination must always be a full destination path e.g. do not + omit the basename even if source and destination basename are equal. + + + +

Return value:

+true + + + +
+ + + + +
readfile (path, limit)
+
+ + Read the contents of a file into a buffer. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + limit: Maximum bytes to read (optional) +
  • + +
+ + + + + + +

Return value:

+file contents + + + +
+ + + + +
readlink (path)
+
+ + (POSIX) Read the target of a symbolic link. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
+ + + + + + +

Return value:

+target path + + + +
+ + + + +
realpath (path)
+
+ + Return the cannonicalized absolute pathname. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
+ + + + + + +

Return value:

+absolute path + + + +
+ + + + +
remove (path)
+
+ + Remove a file or directory. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
rename (src, dest)
+
+ + Renames a file or directory. + + +

Parameters

+
    + +
  • + src: Source path +
  • + +
  • + dest: Destination path +
  • + +
+ + + + +

Usage:

+It is normally not possible to rename files across filesystems. + + + +

Return value:

+true + + + +
+ + + + +
rmdir (path)
+
+ + Remove an empty directory. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
stat (path, field)
+
+ + Get file status and attributes. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + field: Only return a specific field, not the whole table (optional) +
  • + +
+ + + + + + +

Return value:

+Table containing:
    +
  • atime = Last access timestamp
  • +
  • blksize = Blocksize (POSIX only)
  • +
  • blocks = Blocks used (POSIX only)
  • +
  • ctime = Creation timestamp
  • +
  • dev = Device ID
  • +
  • gid = Group ID
  • +
  • ino = Inode
  • +
  • modedec = Mode converted into a decimal number
  • +
  • modestr = Mode as string as returned by ls -l
  • +
  • mtime = Last modification timestamp
  • +
  • nlink = Number of links
  • +
  • rdev = Device ID (if special file)
  • +
  • size = Size in bytes
  • +
  • type = ["reg", "dir", "chr", "blk", "fifo", "lnk", "sock"]
  • +
  • uid = User ID
  • +
+ + + +
+ + + + +
statvfs (path)
+
+ + (POSIX) Get filesystem statistics. + + +

Parameters

+
    + +
  • + path: Path to any file within the filesystem. +
  • + +
+ + + + + + +

Return value:

+Table containing:
    +
  • bavail = available blocks
  • +
  • bfree = free blocks
  • +
  • blocks = number of fragments
  • +
  • frsize = fragment size
  • +
  • favail = available inodes
  • +
  • ffree = free inodes
  • +
  • files = inodes
  • +
  • flag = flags
  • +
  • fsid = filesystem ID
  • +
  • namemax = maximum filename length
  • +
+ + + +
+ + + + +
symlink (oldpath, newpath)
+
+ + (POSIX) Create a symbolic link. + + +

Parameters

+
    + +
  • + oldpath: Path +
  • + +
  • + newpath: Path +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
unlink (path)
+
+ + Delete a name and - if no links are left - the associated file. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
utimes (path, actime, mtime)
+
+ + Change file last access and last modification time. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + actime: Last access timestamp (optional, default: current time) +
  • + +
  • + mtime: Last modification timestamp (optional, default: actime) +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
writefile (path, data)
+
+ + Write a buffer into a file truncating the file first. + + +

Parameters

+
    + +
  • + path: Path +
  • + +
  • + data: Data to write +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/api/modules/nixio.html b/docs/api/modules/nixio.html new file mode 100644 index 000000000..bf93619c9 --- /dev/null +++ b/docs/api/modules/nixio.html @@ -0,0 +1,2401 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Class nixio

+ +

+ General POSIX IO library.

+ + + + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bind (host, port, family, socktype) + Create a new socket and bind it to a network address.
chdir (path) + Change the working directory.
closelog () + (POSIX) Close the connection to the system logger.
connect (host, port, family, socktype) + Create a new socket and connect to a network address.
crypt (key, salt) + (POSIX) Encrypt a user password.
dup (oldfd, newfd) + Duplicate a file descriptor.
errno () + Get the last system error code.
exec (executable, ...) + Execute a file to replace the current process.
exece (executable, arguments, environment) + Execute a file with a custom environment to replace the current process.
execp (executable, ...) + Invoke the shell and execute a file to replace the current process.
fork () + (POSIX) Clone the current process.
getaddrinfo (host, family, service) + Look up a hostname and service via DNS.
getcwd () + Get the current working directory.
getenv (variable) + Get the current environment table or a specific environment variable.
getgid () + (POSIX) Get the group id of the current process.
getgr (group) + (POSIX) Get all or a specific user group.
getifaddrs () + (Linux, BSD) Get a list of available network interfaces and their addresses.
getnameinfo (ipaddr) + Reverse look up an IP-Address via DNS.
getpid () + Get the ID of the current process.
getppid () + (POSIX) Get the parent process id of the current process.
getproto (proto) + Get all or a specific proto entry.
getprotobyname (name) + Get protocol entry by name.
getprotobynumber (proto) + Get protocol entry by number.
getpw (user) + (POSIX) Get all or a specific user account.
getsp (user) + (Linux, Solaris) Get all or a specific shadow password entry.
getuid () + (POSIX) Get the user id of the current process.
kill (target, signal) + (POSIX) Send a signal to one or more processes.
nanosleep (seconds, nanoseconds) + Sleep for a specified amount of time.
nice (nice) + (POSIX) Change priority of current process.
open (path, flags, mode) + Open a file.
open_flags (flag1, ...) + Generate flags for a call to open().
openlog (ident, flag1, ...) + (POSIX) Open a connection to the system logger.
pipe () + Create a pipe.
poll (fds, timeout) + Wait for some event on a file descriptor.
poll_flags (mode1, ...) + Generate events-bitfield or parse revents-bitfield for poll.
sendfile (socket, file, length) + (POSIX) Send data from a file to a socket in kernel-space.
setenv (variable, value) + Set or unset a environment variable.
setgid (gid) + (POSIX) Set the group id of the current process.
setlogmask (priority) + (POSIX) Set the logmask of the system logger for current process.
setsid () + (POSIX) Create a new session and set the process group ID.
setuid (gid) + (POSIX) Set the user id of the current process.
signal (signal, handler) + Ignore or use set the default handler for a signal.
socket (domain, type) + Create a new socket.
splice (fdin, fdout, length, flags) + (Linux) Send data from / to a pipe in kernel-space.
splice_flags (flag1, ...) + (Linux) Generate a flag bitfield for a call to splice.
strerror (errno) + Get the error message for the corresponding error code.
sysinfo () + (Linux) Get overall system statistics.
syslog (priority) + (POSIX) Write a message to the system logger.
times () + (POSIX) Get process times.
tls (mode) + Create a new TLS context.
umask (mask) + Sets the file mode creation mask.
uname () + (POSIX) Get information about current system and kernel.
waitpid (pid, flag1, ...) + (POSIX) Wait for a process to change state.
+ + + + + + +
+
+ + +

Functions

+
+ + + +
bind (host, port, family, socktype)
+
+ + Create a new socket and bind it to a network address. + This function is a shortcut for calling nixio.socket and then bind() + on the socket object. + + +

Parameters

+
    + +
  • + host: Hostname or IP-Address (optional, default: all addresses) +
  • + +
  • + port: Port or service description +
  • + +
  • + family: Address family ["any", "inet", "inet6"] +
  • + +
  • + socktype: Socket Type ["stream", "dgram"] +
  • + +
+ + + + +

Usage

+
    + +
  • This functions calls getaddrinfo(), socket(), + setsockopt() and bind() but NOT listen(). + +
  • The reuseaddr-option is automatically set before binding. + +
+ + + +

Return value:

+Socket Object + + + +
+ + + + +
chdir (path)
+
+ + Change the working directory. + + +

Parameters

+
    + +
  • + path: New working directory +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
closelog ()
+
+ + (POSIX) Close the connection to the system logger. + + + + + + + + + +
+ + + + +
connect (host, port, family, socktype)
+
+ + Create a new socket and connect to a network address. + This function is a shortcut for calling nixio.socket and then connect() + on the socket object. + + +

Parameters

+
    + +
  • + host: Hostname or IP-Address (optional, default: localhost) +
  • + +
  • + port: Port or service description +
  • + +
  • + family: Address family ["any", "inet", "inet6"] +
  • + +
  • + socktype: Socket Type ["stream", "dgram"] +
  • + +
+ + + + +

Usage:

+This functions calls getaddrinfo(), socket() and connect(). + + + +

Return value:

+Socket Object + + + +
+ + + + +
crypt (key, salt)
+
+ + (POSIX) Encrypt a user password. + + +

Parameters

+
    + +
  • + key: Key +
  • + +
  • + salt: Salt +
  • + +
+ + + + + + +

Return value:

+password hash + + + +
+ + + + +
dup (oldfd, newfd)
+
+ + Duplicate a file descriptor. + + +

Parameters

+
    + +
  • + oldfd: Old descriptor [File Object, Socket Object (POSIX only)] +
  • + +
  • + newfd: New descriptor to serve as copy (optional) +
  • + +
+ + + + +

Usage:

+This funcation calls dup2() if newfd is set, otherwise dup(). + + + +

Return value:

+File Object of new descriptor + + + +
+ + + + +
errno ()
+
+ + Get the last system error code. + + + + + + + +

Return value:

+Error code + + + +
+ + + + +
exec (executable, ...)
+
+ + Execute a file to replace the current process. + + +

Parameters

+
    + +
  • + executable: Executable +
  • + +
  • + ...: Parameters +
  • + +
+ + + + +

Usage

+
    + +
  • The name of the executable is automatically passed as argv[0] + +
  • This function does not return on success. + +
+ + + + + +
+ + + + +
exece (executable, arguments, environment)
+
+ + Execute a file with a custom environment to replace the current process. + + +

Parameters

+
    + +
  • + executable: Executable +
  • + +
  • + arguments: Argument Table +
  • + +
  • + environment: Environment Table (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • The name of the executable is automatically passed as argv[0] + +
  • This function does not return on success. + +
+ + + + + +
+ + + + +
execp (executable, ...)
+
+ + Invoke the shell and execute a file to replace the current process. + + +

Parameters

+
    + +
  • + executable: Executable +
  • + +
  • + ...: Parameters +
  • + +
+ + + + +

Usage

+
    + +
  • The name of the executable is automatically passed as argv[0] + +
  • This function does not return on success. + +
+ + + + + +
+ + + + +
fork ()
+
+ + (POSIX) Clone the current process. + + + + + + + +

Return value:

+the child process id for the parent process, 0 for the child process + + + +
+ + + + +
getaddrinfo (host, family, service)
+
+ + Look up a hostname and service via DNS. + + +

Parameters

+
    + +
  • + host: hostname to lookup (optional) +
  • + +
  • + family: address family ["any", "inet", "inet6"] +
  • + +
  • + service: service name or port (optional) +
  • + +
+ + + + + + +

Return value:

+Table containing one or more tables containing:
    +
  • family = ["inet", "inet6"]
  • +
  • socktype = ["stream", "dgram", "raw"]
  • +
  • address = Resolved IP-Address
  • +
  • port = Resolved Port (if service was given)
  • +
+ + + +
+ + + + +
getcwd ()
+
+ + Get the current working directory. + + + + + + + +

Return value:

+workign directory + + + +
+ + + + +
getenv (variable)
+
+ + Get the current environment table or a specific environment variable. + + +

Parameters

+
    + +
  • + variable: Variable (optional) +
  • + +
+ + + + + + +

Return value:

+environment table or single environment variable + + + +
+ + + + +
getgid ()
+
+ + (POSIX) Get the group id of the current process. + + + + + + + +

Return value:

+process group id + + + +
+ + + + +
getgr (group)
+
+ + (POSIX) Get all or a specific user group. + + +

Parameters

+
    + +
  • + group: Group ID or groupname (optional) +
  • + +
+ + + + + + +

Return value:

+Table containing:
    +
  • name = Group Name
  • +
  • gid = Group ID
  • +
  • passwd = Password
  • +
  • mem = {Member #1, Member #2, ...}
  • +
+ + + +
+ + + + +
getifaddrs ()
+
+ + (Linux, BSD) Get a list of available network interfaces and their addresses. + + + + + + + +

Return value:

+Table containing one or more tables containing:
    +
  • name = Interface Name
  • +
  • family = ["inet", "inet6", "packet"]
  • +
  • addr = Interface Address (IPv4, IPv6, MAC, ...)
  • +
  • broadaddr = Broadcast Address
  • +
  • dstaddr = Destination Address (Point-to-Point)
  • +
  • netmask = Netmask (if available)
  • +
  • prefix = Prefix (if available)
  • +
  • flags = Table of interface flags (up, multicast, loopback, ...)
  • +
  • data = Statistics (Linux, "packet"-family)
  • +
  • hatype = Hardware Type Identifier (Linix, "packet"-family)
  • +
  • ifindex = Interface Index (Linux, "packet"-family)
  • +
+ + + +
+ + + + +
getnameinfo (ipaddr)
+
+ + Reverse look up an IP-Address via DNS. + + +

Parameters

+
    + +
  • + ipaddr: IPv4 or IPv6-Address +
  • + +
+ + + + + + +

Return value:

+FQDN + + + +
+ + + + +
getpid ()
+
+ + Get the ID of the current process. + + + + + + + +

Return value:

+process id + + + +
+ + + + +
getppid ()
+
+ + (POSIX) Get the parent process id of the current process. + + + + + + + +

Return value:

+parent process id + + + +
+ + + + +
getproto (proto)
+
+ + Get all or a specific proto entry. + + +

Parameters

+
    + +
  • + proto: protocol number or name to lookup (optional) +
  • + +
+ + + + + + +

Return value:

+Table (or if no parameter is given, a table of tables) + containing the following fields:
    +
  • name = Protocol Name
  • +
  • proto = Protocol Number
  • +
  • aliases = Table of alias names
  • +
+ + + +
+ + + + +
getprotobyname (name)
+
+ + Get protocol entry by name. + + +

Parameters

+
    + +
  • + name: protocol name to lookup +
  • + +
+ + + + +

Usage:

+This function returns nil if the given protocol is unknown. + + + +

Return value:

+Table containing the following fields:
    +
  • name = Protocol Name
  • +
  • proto = Protocol Number
  • +
  • aliases = Table of alias names
  • +
+ + + +
+ + + + +
getprotobynumber (proto)
+
+ + Get protocol entry by number. + + +

Parameters

+
    + +
  • + proto: protocol number to lookup +
  • + +
+ + + + +

Usage:

+This function returns nil if the given protocol is unknown. + + + +

Return value:

+Table containing the following fields:
    +
  • name = Protocol Name
  • +
  • proto = Protocol Number
  • +
  • aliases = Table of alias names
  • +
+ + + +
+ + + + +
getpw (user)
+
+ + (POSIX) Get all or a specific user account. + + +

Parameters

+
    + +
  • + user: User ID or username (optional) +
  • + +
+ + + + + + +

Return value:

+Table containing:
    +
  • name = Name
  • +
  • uid = ID
  • +
  • gid = Group ID
  • +
  • passwd = Password
  • +
  • dir = Home directory
  • +
  • gecos = Information
  • +
  • shell = Shell
  • +
+ + + +
+ + + + +
getsp (user)
+
+ + (Linux, Solaris) Get all or a specific shadow password entry. + + +

Parameters

+
    + +
  • + user: username (optional) +
  • + +
+ + + + + + +

Return value:

+Table containing:
    +
  • namp = Name
  • +
  • expire = Expiration Date
  • +
  • flag = Flags
  • +
  • inact = Inactivity Date
  • +
  • lstchg = Last change
  • +
  • max = Maximum
  • +
  • min = Minimum
  • +
  • warn = Warning
  • +
  • pwdp = Password Hash
  • +
+ + + +
+ + + + +
getuid ()
+
+ + (POSIX) Get the user id of the current process. + + + + + + + +

Return value:

+process user id + + + +
+ + + + +
kill (target, signal)
+
+ + (POSIX) Send a signal to one or more processes. + + +

Parameters

+
    + +
  • + target: Target process of process group. +
  • + +
  • + signal: Signal to send +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
nanosleep (seconds, nanoseconds)
+
+ + Sleep for a specified amount of time. + + +

Parameters

+
    + +
  • + seconds: Seconds to wait (optional) +
  • + +
  • + nanoseconds: Nanoseconds to wait (optional) +
  • + +
+ + + + +

Usage

+
    + +
  • Not all systems support nanosecond precision but you can expect + to have at least maillisecond precision. + +
  • This function is not signal-protected and may fail with EINTR. + +
+ + + +

Return value:

+true + + + +
+ + + + +
nice (nice)
+
+ + (POSIX) Change priority of current process. + + +

Parameters

+
    + +
  • + nice: Nice Value +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
open (path, flags, mode)
+
+ + Open a file. + + +

Parameters

+
    + +
  • + path: Filesystem path to open +
  • + +
  • + flags: Flag string or number (see open_flags). + ["r", "r+", "w", "w+", "a", "a+"] +
  • + +
  • + mode: File mode for newly created files (see chmod, umask). +
  • + +
+ + + + +

Usage:

+Although this function also supports the traditional fopen() + file flags it does not create a file stream but uses the open() syscall. + + + +

Return value:

+File Object + + + +

See also:

+ + +
+ + + + +
open_flags (flag1, ...)
+
+ + Generate flags for a call to open(). + + +

Parameters

+
    + +
  • + flag1: First Flag ["append", "creat", "excl", "nonblock", "ndelay", + "sync", "trunc", "rdonly", "wronly", "rdwr"] +
  • + +
  • + ...: More Flags [-"-] +
  • + +
+ + + + +

Usage

+
    + +
  • This function cannot fail and will never return nil. + +
  • The "nonblock" and "ndelay" flags are aliases. + +
  • The "nonblock", "ndelay" and "sync" flags are no-ops on Windows. + +
+ + + +

Return value:

+flag to be used as second parameter to open + + + +
+ + + + +
openlog (ident, flag1, ...)
+
+ + (POSIX) Open a connection to the system logger. + + +

Parameters

+
    + +
  • + ident: Identifier +
  • + +
  • + flag1: Flag 1 ["cons", "nowait", "pid", "perror", "ndelay", "odelay"] +
  • + +
  • + ...: More flags [-"-] +
  • + +
+ + + + + + + + +
+ + + + +
pipe ()
+
+ + Create a pipe. + + + + + + + +

Return values:

+
    + +
  1. File Object of the read end + +
  2. File Object of the write end + +
+ + + +
+ + + + +
poll (fds, timeout)
+
+ + Wait for some event on a file descriptor. + poll() sets the revents-field of the tables provided by fds to a bitfield + indicating the events that occurred. + + +

Parameters

+
    + +
  • + fds: Table containing one or more tables containing
      +
    • fd = I/O Descriptor [Socket Object, File Object (POSIX)]
    • +
    • events = events to wait for (bitfield generated with poll_flags)
    • +
    +
  • + +
  • + timeout: Timeout in milliseconds +
  • + +
+ + + + +

Usage

+
    + +
  • This function works in-place on the provided table and only + writes the revents field, you can use other fields on your demand. + +
  • All metamethods on the tables provided as fds are ignored. + +
  • The revents-fields are not reset when the call times out. + You have to check the first return value to be 0 to handle this case. + +
  • If you want to wait on a TLS-Socket you have to use the underlying + socket instead. + +
  • On Windows poll is emulated through select(), can only be used + on socket descriptors and cannot take more than 64 descriptors per call. + +
  • This function is not signal-protected and may fail with EINTR. + +
+ + + +

Return values:

+
    + +
  1. number of ready IO descriptors + +
  2. the fds-table with revents-fields set + +
+ + + +

See also:

+ + +
+ + + + +
poll_flags (mode1, ...)
+
+ + Generate events-bitfield or parse revents-bitfield for poll. + + +

Parameters

+
    + +
  • + mode1: revents-Flag bitfield returned from poll to parse OR + ["in", "out", "err", "pri" (POSIX), "hup" (POSIX), "nval" (POSIX)] +
  • + +
  • + ...: More mode strings for generating the flag [-"-] +
  • + +
+ + + + + + +

Return value:

+table with boolean fields reflecting the mode parameter + OR bitfield to use for the events-Flag field + + + +

See also:

+ + +
+ + + + +
sendfile (socket, file, length)
+
+ + (POSIX) Send data from a file to a socket in kernel-space. + + +

Parameters

+
    + +
  • + socket: Socket Object +
  • + +
  • + file: File Object +
  • + +
  • + length: Amount of data to send (in Bytes). +
  • + +
+ + + + + + +

Return value:

+bytes sent + + + +
+ + + + +
setenv (variable, value)
+
+ + Set or unset a environment variable. + + +

Parameters

+
    + +
  • + variable: Variable +
  • + +
  • + value: Value (optional) +
  • + +
+ + + + +

Usage:

+The environment variable will be unset if value is omitted. + + + +

Return value:

+true + + + +
+ + + + +
setgid (gid)
+
+ + (POSIX) Set the group id of the current process. + + +

Parameters

+
    + +
  • + gid: New Group ID +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
setlogmask (priority)
+
+ + (POSIX) Set the logmask of the system logger for current process. + + +

Parameters

+
    + +
  • + priority: Priority ["emerg", "alert", "crit", "err", "warning", + "notice", "info", "debug"] +
  • + +
+ + + + + + + + +
+ + + + +
setsid ()
+
+ + (POSIX) Create a new session and set the process group ID. + + + + + + + +

Return value:

+session id + + + +
+ + + + +
setuid (gid)
+
+ + (POSIX) Set the user id of the current process. + + +

Parameters

+
    + +
  • + gid: New User ID +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
signal (signal, handler)
+
+ + Ignore or use set the default handler for a signal. + + +

Parameters

+
    + +
  • + signal: Signal +
  • + +
  • + handler: ["ign", "dfl"] +
  • + +
+ + + + + + +

Return value:

+true + + + +
+ + + + +
socket (domain, type)
+
+ + Create a new socket. + + +

Parameters

+
    + +
  • + domain: Domain ["inet", "inet6", "unix"] +
  • + +
  • + type: Type ["stream", "dgram", "raw"] +
  • + +
+ + + + + + +

Return value:

+Socket Object + + + +
+ + + + +
splice (fdin, fdout, length, flags)
+
+ + (Linux) Send data from / to a pipe in kernel-space. + + +

Parameters

+
    + +
  • + fdin: Input I/O descriptor +
  • + +
  • + fdout: Output I/O descriptor +
  • + +
  • + length: Amount of data to send (in Bytes). +
  • + +
  • + flags: (optional, bitfield generated by splice_flags) +
  • + +
+ + + + + + +

Return value:

+bytes sent + + + +

See also:

+ + +
+ + + + +
splice_flags (flag1, ...)
+
+ + (Linux) Generate a flag bitfield for a call to splice. + + +

Parameters

+
    + +
  • + flag1: First Flag ["move", "nonblock", "more"] +
  • + +
  • + ...: More flags [-"-] +
  • + +
+ + + + + + +

Return value:

+Flag bitfield + + + +

See also:

+ + +
+ + + + +
strerror (errno)
+
+ + Get the error message for the corresponding error code. + + +

Parameters

+
    + +
  • + errno: System error code +
  • + +
+ + + + + + +

Return value:

+Error message + + + +
+ + + + +
sysinfo ()
+
+ + (Linux) Get overall system statistics. + + + + + + + +

Return value:

+Table containing:
    +
  • uptime = system uptime in seconds
  • +
  • loads = {loadavg1, loadavg5, loadavg15}
  • +
  • totalram = total RAM
  • +
  • freeram = free RAM
  • +
  • sharedram = shared RAM
  • +
  • bufferram = buffered RAM
  • +
  • totalswap = total SWAP
  • +
  • freeswap = free SWAP
  • +
  • procs = number of running processes
  • +
+ + + +
+ + + + +
syslog (priority)
+
+ + (POSIX) Write a message to the system logger. + + +

Parameters

+
    + +
  • + priority: Priority ["emerg", "alert", "crit", "err", "warning", + "notice", "info", "debug"] +
  • + +
+ + + + + + + + +
+ + + + +
times ()
+
+ + (POSIX) Get process times. + + + + + + + +

Return value:

+Table containing:
    +
  • utime = user time
  • +
  • utime = system time
  • +
  • cutime = children user time
  • +
  • cstime = children system time
  • +
+ + + +
+ + + + +
tls (mode)
+
+ + Create a new TLS context. + + +

Parameters

+
    + +
  • + mode: TLS-Mode ["client", "server"] +
  • + +
+ + + + + + +

Return value:

+TLSContext Object + + + +
+ + + + +
umask (mask)
+
+ + Sets the file mode creation mask. + + +

Parameters

+
    + +
  • + mask: New creation mask (see chmod for format specifications) +
  • + +
+ + + + + + +

Return values:

+
    + +
  1. the old umask as decimal mode number + +
  2. the old umask as mode string + +
+ + + +
+ + + + +
uname ()
+
+ + (POSIX) Get information about current system and kernel. + + + + + + + +

Return value:

+Table containing:
    +
  • sysname = operating system
  • +
  • nodename = network name (usually hostname)
  • +
  • release = OS release
  • +
  • version = OS version
  • +
  • machine = hardware identifier
  • +
+ + + +
+ + + + +
waitpid (pid, flag1, ...)
+
+ + (POSIX) Wait for a process to change state. + + +

Parameters

+
    + +
  • + pid: Process ID (optional, default: any childprocess) +
  • + +
  • + flag1: Flag (optional) ["nohang", "untraced", "continued"] +
  • + +
  • + ...: More Flags [-"-] +
  • + +
+ + + + +

Usage:

+If the "nohang" is given this function becomes non-blocking. + + + +

Return values:

+
    + +
  1. process id of child or 0 if no child has changed state + +
  2. ["exited", "signaled", "stopped"] + +
  3. [exit code, terminate signal, stop signal] + +
+ + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/docs/i18n.md b/docs/i18n.md new file mode 100644 index 000000000..226a406c2 --- /dev/null +++ b/docs/i18n.md @@ -0,0 +1,19 @@ +# General +Translations are saved in the folder po/ for each module and application. You find the reference in po/templates/.pot. The actual translation files can be found at po/[lang]/[package].po . + +In order to use the commands below you need to have the _gettext'' utilities (''msgcat'', ''msgfmt'', ''msgmerge_) installed on your system. + +# Rebuild po files +If you want to rebuild the translations after you made changes to a package this is an easy way: + + ./build/i18n-scan.pl applications/[application] > applications/[application]/po/templates/[application_basename].pot + ./build/i18n-update.pl applications/[application]/po + + Example: + ./build/i18n-scan.pl applications/luci-app-firewall > applications/luci-app-firewall/po/templates/firewall.pot + ./build/i18n-update.pl applications/luci-app-firewall/po + (note that the directory argument can be omitted for i18n-update.pl to update all apps) + +*Note:* Some packages share translation files, in this case you need to scan through all their folders. The first command from above should then be: + + ./build/i18n-scan.pl applications/[package-1] applications/[package-2] applications/[package-n] > [location of shared template]/[application].pot diff --git a/docs/jsapi/LuCI.Class.html b/docs/jsapi/LuCI.Class.html new file mode 100644 index 000000000..28916f113 --- /dev/null +++ b/docs/jsapi/LuCI.Class.html @@ -0,0 +1,2322 @@ + + + + + Class: Class + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Class

+ + + + +
+ +
+

+ LuCI. + + Class +

+ +

LuCI.Class is the abstract base class all LuCI classes inherit from.

+

It provides simple means to create subclasses of given classes and +implements prototypal inheritance.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Class() +

+ + +
+ luci.js, line 59 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + staticLuCI.Class.extend(properties){LuCI.Class} +

+ + +
+ luci.js, line 87 +
+ +
+ + +
+
+ + +
+

Extends this base class with the properties described in +properties and returns a new subclassed Class instance

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
properties + + +Object.<string, *> + + + + + +

An object describing the properties to add to the new +subclass.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Class + + + Returns a new LuCI.Class sublassed from this class, extended +by the given properties and with its prototype set to this base +class to enable inheritance. The resulting value represents a +class constructor and can be instantiated with new.
+ + + + +
+ + + +
+
+

+ + staticLuCI.Class.instantiate(params, new_args){LuCI.Class} +

+ + +
+ luci.js, line 169 +
+ +
+ + +
+
+ + +
+

Calls the class constructor using new with the given argument +array being passed as variadic parameters to the constructor.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
params + + +Array.<*> + + + + + + + + + + +

An array of arbitrary values which will be passed as arguments +to the constructor function.

new_args + + +* + + + + + + + optional + + + + + repeatable + + +

Specifies arguments to be passed to the subclass constructor +as-is in order to instantiate the new subclass.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Class + + + Returns a new LuCI.Class instance extended by the given +properties with its prototype set to this base class to +enable inheritance.
+ + + + +
+ + + +
+
+

+ + staticLuCI.Class.isSubclass(classValue){boolean} +

+ + +
+ luci.js, line 195 +
+ +
+ + +
+
+ + +
+

Checks whether the given class value is a subclass of this class.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
classValue + + +LuCI.Class + + + + + +

The class object to test.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the given classValue is a subclass of this +class or false if the given value is not a valid class or not +a subclass of this class'.
+ + + + +
+ + + +
+
+

+ + staticLuCI.Class.singleton(properties, new_args){LuCI.Class} +

+ + +
+ luci.js, line 145 +
+ +
+ + +
+
+ + +
+

Extends this base class with the properties described in +properties, instantiates the resulting subclass using +the additional optional arguments passed to this function +and returns the resulting subclassed Class instance.

+

This function serves as a convenience shortcut for +Class.extend() and subsequent +new.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
properties + + +Object.<string, *> + + + + + + + + + + +

An object describing the properties to add to the new +subclass.

new_args + + +* + + + + + + + optional + + + + + repeatable + + +

Specifies arguments to be passed to the subclass constructor +as-is in order to instantiate the new subclass.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Class + + + Returns a new LuCI.Class instance extended by the given +properties with its prototype set to this base class to +enable inheritance.
+ + + + +
+ + + +
+
+

+ + super(key, callArgs){*|null} +

+ + +
+ luci.js, line 267 +
+ +
+ + +
+
+ + +
+

Walks up the parent class chain and looks for a class member +called key in any of the parent classes this class inherits +from. Returns the member value of the superclass or calls the +member as function and returns its return value when the +optional callArgs array is given.

+

This function has two signatures and is sensitive to the +amount of arguments passed to it:

+
    +
  • super('key') - +Returns the value of key when found within one of the +parent classes.
  • +
  • super('key', ['arg1', 'arg2']) - +Calls the key() method with parameters arg1 and arg2 +when found within one of the parent classes.
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +string + + + + + + + + + + +

The name of the superclass member to retrieve.

callArgs + + +Array.<*> + + + + + + + optional + + + + + +

An optional array of function call parameters to use. When +this parameter is specified, the found member value is called +as function using the values of this array as arguments.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws a ReferenceError when callArgs are specified and +the found member named by key is not a function value.

+
+
+
+
+
+ Type +
+
+ +ReferenceError + + +
+
+
+
+ + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + | + + null + + + Returns the value of the found member or the return value of +the call to the found method. Returns null when no member +was found in the parent class chain or when the call to the +superclass method returned null.
+ + + + +
+ + + +
+
+

+ + varargs(args, offset, extra_args){Array.<*>} +

+ + +
+ luci.js, line 225 +
+ +
+ + +
+
+ + +
+

Extract all values from the given argument array beginning from +offset and prepend any further given optional parameters to +the beginning of the resulting array copy.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
args + + +Array.<*> + + + + + + + + + + +

The array to extract the values from.

offset + + +number + + + + + + + + + + +

The offset from which to extract the values. An offset of 0 +would copy all values till the end.

extra_args + + +* + + + + + + + optional + + + + + repeatable + + +

Extra arguments to add to prepend to the resultung array.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<*> + + + Returns a new array consisting of the optional extra arguments +and the values extracted from the args array beginning with +offset.
+ + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Headers.html b/docs/jsapi/LuCI.Headers.html new file mode 100644 index 000000000..efb898bbf --- /dev/null +++ b/docs/jsapi/LuCI.Headers.html @@ -0,0 +1,1495 @@ + + + + + Class: Headers + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Headers

+ + + + +
+ +
+

+ LuCI. + + Headers +

+ +

The Headers class is an internal utility class exposed in HTTP +response objects using the response.headers property.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Headers() +

+ + +
+ luci.js, line 324 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + get(name){string|null} +

+ + +
+ luci.js, line 363 +
+ +
+ + +
+
+ + +
+

Returns the value of the given header name. +Note: Header-Names are case-insensitive.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + + +

The header name to read

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + | + + null + + + The value of the given header name or null if the header isn't present.
+ + + + +
+ + + +
+
+

+ + has(name){boolean} +

+ + +
+ luci.js, line 347 +
+ +
+ + +
+
+ + +
+

Checks whether the given header name is present. +Note: Header-Names are case-insensitive.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + + +

The header name to check

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the header name is present, false otherwise
+ + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.Device.html b/docs/jsapi/LuCI.Network.Device.html new file mode 100644 index 000000000..71d88df22 --- /dev/null +++ b/docs/jsapi/LuCI.Network.Device.html @@ -0,0 +1,3440 @@ + + + + + Class: Device + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Device

+ + + + +
+ +
+

+ LuCI.Network. + + Device +

+ +

A Network.Device class instance represents an underlying Linux network +device and allows querying device details such as packet statistics or MTU.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Network.Device() +

+ + +
+ network.js, line 2593 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + getBridgeID(){null|string} +

+ + +
+ network.js, line 2800 +
+ +
+ + +
+
+ + +
+

Get the bridge ID

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the ID of this network bridge or null if this network +device is not a Linux bridge.
+ + + + +
+ + + +
+
+

+ + getBridgeSTP(){boolean} +

+ + +
+ network.js, line 2812 +
+ +
+ + +
+
+ + +
+

Get the bridge STP setting

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when this device is a Linux bridge and has stp +enabled, else false.
+ + + + +
+ + + +
+
+

+ + getI18n(){string} +

+ + +
+ network.js, line 2727 +
+ +
+ + +
+
+ + +
+

Get a long description string for the device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns a string containing the type description and device name +for non-wifi devices or operation mode and ssid for wifi ones.
+ + + + +
+ + + +
+
+

+ + getIP6Addrs(){Array.<string>} +

+ + +
+ network.js, line 2671 +
+ +
+ + +
+
+ + +
+

Get the IPv6 addresses configured on the device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of IPv6 address strings.
+ + + + +
+ + + +
+
+

+ + getIPAddrs(){Array.<string>} +

+ + +
+ network.js, line 2660 +
+ +
+ + +
+
+ + +
+

Get the IPv4 addresses configured on the device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of IPv4 address strings.
+ + + + +
+ + + +
+
+

+ + getMAC(){null|string} +

+ + +
+ network.js, line 2639 +
+ +
+ + +
+
+ + +
+

Get the MAC address of the device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the MAC address of the device or null if not applicable, +e.g. for non-ethernet tunnel devices.
+ + + + +
+ + + +
+
+

+ + getMTU(){number} +

+ + +
+ network.js, line 2650 +
+ +
+ + +
+
+ + +
+

Get the MTU of the device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the MTU of the device.
+ + + + +
+ + + +
+
+

+ + getName(){string} +

+ + +
+ network.js, line 2628 +
+ +
+ + +
+
+ + +
+

Get the name of the network device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the name of the device, e.g. eth0 or wlan0.
+ + + + +
+ + + +
+
+

+ + getNetwork(){null|LuCI.Network.Protocol} +

+ + +
+ network.js, line 2907 +
+ +
+ + +
+
+ + +
+

Get the primary logical interface this device is assigned to.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + LuCI.Network.Protocol + + + Returns a Network.Protocol instance representing the logical +interface this device is attached to or null if it is not +assigned to any logical interface.
+ + + + +
+ + + +
+
+

+ + getNetworks(){Array.<LuCI.Network.Protocol>} +

+ + +
+ network.js, line 2918 +
+ +
+ + +
+
+ + +
+

Get the logical interfaces this device is assigned to.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<LuCI.Network.Protocol> + + + Returns an array of Network.Protocol instances representing the +logical interfaces this device is assigned to.
+ + + + +
+ + + +
+
+

+ + getPorts(){null|Array.<LuCI.Network.Device>} +

+ + +
+ network.js, line 2778 +
+ +
+ + +
+
+ + +
+

Get the associated bridge ports of the device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + Array.<LuCI.Network.Device> + + + Returns an array of Network.Device instances representing the ports +(slave interfaces) of the bridge or null when this device isn't +a Linux bridge.
+ + + + +
+ + + +
+
+

+ + getRXBytes(){number} +

+ + +
+ network.js, line 2872 +
+ +
+ + +
+
+ + +
+

Get the amount of received bytes.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the amount of bytes received by the network device.
+ + + + +
+ + + +
+
+

+ + getRXPackets(){number} +

+ + +
+ network.js, line 2894 +
+ +
+ + +
+
+ + +
+

Get the amount of received packets.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the amount of packets received by the network device.
+ + + + +
+ + + +
+
+

+ + getShortName(){string} +

+ + +
+ network.js, line 2713 +
+ +
+ + +
+
+ + +
+

Get a short description string for the device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the device name for non-wifi devices or a string containing +the operation mode and SSID for wifi devices.
+ + + + +
+ + + +
+
+

+ + getTXBytes(){number} +

+ + +
+ network.js, line 2861 +
+ +
+ + +
+
+ + +
+

Get the amount of transmitted bytes.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the amount of bytes transmitted by the network device.
+ + + + +
+ + + +
+
+

+ + getTXPackets(){number} +

+ + +
+ network.js, line 2883 +
+ +
+ + +
+
+ + +
+

Get the amount of transmitted packets.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the amount of packets transmitted by the network device.
+ + + + +
+ + + +
+
+

+ + getType(){string} +

+ + +
+ network.js, line 2689 +
+ +
+ + +
+
+ + +
+

Get the type of the device..

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns a string describing the type of the network device: +
    +
  • alias if it is an abstract alias device (@ notation)
  • +
  • wifi if it is a wireless interface (e.g. wlan0)
  • +
  • bridge if it is a bridge device (e.g. br-lan)
  • +
  • tunnel if it is a tun or tap device (e.g. tun0)
  • +
  • vlan if it is a vlan device (e.g. eth0.1)
  • +
  • switch if it is a switch device (e.g.eth1 connected to switch0)
  • +
  • ethernet for all other device types
  • +
+ + + + +
+ + + +
+
+

+ + getTypeI18n(){string} +

+ + +
+ network.js, line 2745 +
+ +
+ + +
+
+ + +
+

Get a string describing the device type.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns a string describing the type, e.g. "Wireless Adapter" or +"Bridge".
+ + + + +
+ + + +
+
+

+ + getWifiNetwork(){null|LuCI.Network.WifiNetwork} +

+ + +
+ network.js, line 2942 +
+ +
+ + +
+
+ + +
+

Get the related wireless network this device is related to.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + LuCI.Network.WifiNetwork + + + Returns a Network.WifiNetwork instance representing the wireless +network corresponding to this network device or null if this device +is not a wireless device.
+ + + + +
+ + + +
+
+

+ + isBridge(){boolean} +

+ + +
+ network.js, line 2840 +
+ +
+ + +
+
+ + +
+

Checks whether this device is a Linux bridge.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the network device is present and a Linux bridge, +else false.
+ + + + +
+ + + +
+
+

+ + isBridgePort(){boolean} +

+ + +
+ network.js, line 2851 +
+ +
+ + +
+
+ + +
+

Checks whether this device is part of a Linux bridge.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when this network device is part of a bridge, +else false.
+ + + + +
+ + + +
+
+

+ + isUp(){boolean} +

+ + +
+ network.js, line 2824 +
+ +
+ + +
+
+ + +
+

Checks whether this device is up.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the associated device is running pr false +when it is down or absent.
+ + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.Hosts.html b/docs/jsapi/LuCI.Network.Hosts.html new file mode 100644 index 000000000..fc392d880 --- /dev/null +++ b/docs/jsapi/LuCI.Network.Hosts.html @@ -0,0 +1,2421 @@ + + + + + Class: Hosts + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Hosts

+ + + + +
+ +
+

+ LuCI.Network. + + Hosts +

+ +

The LuCI.Network.Hosts class encapsulates host information aggregated +from multiple sources and provides convenience functions to access the +host information by different criteria.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Network.Hosts() +

+ + +
+ network.js, line 1628 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + getHostnameByIP6Addr(ipaddr){null|string} +

+ + +
+ network.js, line 1725 +
+ +
+ + +
+
+ + +
+

Lookup the hostname associated with the given IPv6 address.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ipaddr + + +string + + + + + +

The IPv6 address to lookup.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the hostname associated with the given IPv6 or null if +no matching host could be found or if no hostname is known for +the corresponding host.
+ + + + +
+ + + +
+
+

+ + getHostnameByIPAddr(ipaddr){null|string} +

+ + +
+ network.js, line 1689 +
+ +
+ + +
+
+ + +
+

Lookup the hostname associated with the given IPv4 address.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ipaddr + + +string + + + + + +

The IPv4 address to lookup.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the hostname associated with the given IPv4 or null if +no matching host could be found or if no hostname is known for +the corresponding host.
+ + + + +
+ + + +
+
+

+ + getHostnameByMACAddr(mac){null|string} +

+ + +
+ network.js, line 1644 +
+ +
+ + +
+
+ + +
+

Lookup the hostname associated with the given MAC address.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mac + + +string + + + + + +

The MAC address to lookup.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the hostname associated with the given MAC or null if +no matching host could be found or if no hostname is known for +the corresponding host.
+ + + + +
+ + + +
+
+

+ + getIP6AddrByMACAddr(mac){null|string} +

+ + +
+ network.js, line 1674 +
+ +
+ + +
+
+ + +
+

Lookup the IPv6 address associated with the given MAC address.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mac + + +string + + + + + +

The MAC address to lookup.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the IPv6 address associated with the given MAC or null if +no matching host could be found or if no IPv6 address is known for +the corresponding host.
+ + + + +
+ + + +
+
+

+ + getIPAddrByMACAddr(mac){null|string} +

+ + +
+ network.js, line 1659 +
+ +
+ + +
+
+ + +
+

Lookup the IPv4 address associated with the given MAC address.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mac + + +string + + + + + +

The MAC address to lookup.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the IPv4 address associated with the given MAC or null if +no matching host could be found or if no IPv4 address is known for +the corresponding host.
+ + + + +
+ + + +
+
+

+ + getMACAddrByIP6Addr(ipaddr){null|string} +

+ + +
+ network.js, line 1743 +
+ +
+ + +
+
+ + +
+

Lookup the MAC address associated with the given IPv6 address.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ipaddr + + +string + + + + + +

The IPv6 address to lookup.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the MAC address associated with the given IPv6 or null if +no matching host could be found or if no MAC address is known for +the corresponding host.
+ + + + +
+ + + +
+
+

+ + getMACAddrByIPAddr(ipaddr){null|string} +

+ + +
+ network.js, line 1707 +
+ +
+ + +
+
+ + +
+

Lookup the MAC address associated with the given IPv4 address.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ipaddr + + +string + + + + + +

The IPv4 address to lookup.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the MAC address associated with the given IPv4 or null if +no matching host could be found or if no MAC address is known for +the corresponding host.
+ + + + +
+ + + +
+
+

+ + getMACHints(preferIp6){Array.<Array.<string>>} +

+ + +
+ network.js, line 1771 +
+ +
+ + +
+
+ + +
+

Return an array of (MAC address, name hint) tuples sorted by +MAC address.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
preferIp6 + + +boolean + + + + + + false + + + + + optional + + + + + +

Whether to prefer IPv6 addresses (true) or IPv4 addresses (false) +as name hint when no hostname is known for a specific MAC address.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<Array.<string>> + + + Returns an array of arrays containing a name hint for each found +MAC address on the system. The array is sorted ascending by MAC. +Each item of the resulting array is a two element array with the +MAC being the first element and the name hint being the second +element. The name hint is either the hostname, an IPv4 or an IPv6 +address related to the MAC address. +If no hostname but both IPv4 and IPv6 addresses are known, the +preferIP6 flag specifies whether the IPv6 or the IPv4 address +is used as hint.
+ + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.Protocol.html b/docs/jsapi/LuCI.Network.Protocol.html new file mode 100644 index 000000000..20239bce8 --- /dev/null +++ b/docs/jsapi/LuCI.Network.Protocol.html @@ -0,0 +1,5394 @@ + + + + + Class: Protocol + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Protocol

+ + + + +
+ +
+

+ LuCI.Network. + + Protocol +

+ +

The Network.Protocol class serves as base for protocol specific +subclasses which describe logical UCI networks defined by config interface sections in /etc/config/network.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Network.Protocol() +

+ + +
+ network.js, line 1794 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + addDevice(device){boolean} +

+ + +
+ network.js, line 2383 +
+ +
+ + +
+
+ + +
+

Add the given network device to the logical interface.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
device + + +LuCI.Network.Protocol +| + +LuCI.Network.Device +| + +LuCI.Network.WifiDevice +| + +LuCI.Network.WifiNetwork +| + +string + + + + + +

The object or device name to add to the logical interface. In case the +given argument is not a string, it is resolved though the +Network.getIfnameOf() function.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the device name has been added or false if any +argument was invalid, if the device was already part of the logical +interface or if the logical interface is virtual.
+ + + + +
+ + + +
+
+

+ + containsDevice(device){boolean} +

+ + +
+ network.js, line 2552 +
+ +
+ + +
+
+ + +
+

Checks whether this logical interface contains the given device +object.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
device + + +LuCI.Network.Protocol +| + +LuCI.Network.Device +| + +LuCI.Network.WifiDevice +| + +LuCI.Network.WifiNetwork +| + +string + + + + + +

The object or device name to check. In case the given argument is not +a string, it is resolved though the +Network.getIfnameOf() function.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when this logical interface contains the given network +device or false if not.
+ + + + +
+ + + +
+
+

+ + deleteDevice(device){boolean} +

+ + +
+ network.js, line 2410 +
+ +
+ + +
+
+ + +
+

Remove the given network device from the logical interface.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
device + + +LuCI.Network.Protocol +| + +LuCI.Network.Device +| + +LuCI.Network.WifiDevice +| + +LuCI.Network.WifiNetwork +| + +string + + + + + +

The object or device name to remove from the logical interface. In case +the given argument is not a string, it is resolved though the +Network.getIfnameOf() function.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the device name has been added or false if any +argument was invalid, if the device was already part of the logical +interface or if the logical interface is virtual.
+ + + + +
+ + + +
+
+

+ + get(opt){null|string|Array.<string>} +

+ + +
+ network.js, line 1827 +
+ +
+ + +
+
+ + +
+

Read the given UCI option value of this network.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
opt + + +string + + + + + +

The UCI option name to read.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + | + + Array.<string> + + + Returns the UCI option value or null if the requested option is +not found.
+ + + + +
+ + + +
+
+

+ + getDevice(){LuCI.Network.Device} +

+ + +
+ network.js, line 2437 +
+ +
+ + +
+
+ + +
+

Returns the Linux network device associated with this logical +interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Network.Device + + + Returns a Network.Device class instance representing the +expected Linux network device according to the configuration.
+ + + + +
+ + + +
+
+

+ + getDevices(){null|Array.<LuCI.Network.Device>} +

+ + +
+ network.js, line 2498 +
+ +
+ + +
+
+ + +
+

Returns a list of network sub-devices associated with this logical +interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + Array.<LuCI.Network.Device> + + + Returns an array of of Network.Device class instances representing +the sub-devices attached to this logical interface or null if the +logical interface does not support sub-devices, e.g. because it is +virtual and not a bridge.
+ + + + +
+ + + +
+
+

+ + getDNS6Addrs(){Array.<string>} +

+ + +
+ network.js, line 2152 +
+ +
+ + +
+
+ + +
+

Query the IPv6 DNS servers associated with the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of IPv6 DNS servers registered by the remote +protocol backend.
+ + + + +
+ + + +
+
+

+ + getDNSAddrs(){Array.<string>} +

+ + +
+ network.js, line 2064 +
+ +
+ + +
+
+ + +
+

Query the IPv4 DNS servers associated with the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of IPv4 DNS servers registered by the remote +protocol backend.
+ + + + +
+ + + +
+
+

+ + getErrors(){Array.<string>} +

+ + +
+ network.js, line 2196 +
+ +
+ + +
+
+ + +
+

Query interface error messages published in ubus runtime state.

+

Interface errors are emitted by remote protocol handlers if the setup +of the underlying logical interface failed, e.g. due to bad +configuration or network connectivity issues.

+

This function will translate the found error codes to human readable +messages using the descriptions registered by +Network.registerErrorCode() +and fall back to "Unknown error (%s)" where %s is replaced by the +error code in case no translation can be found.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of translated interface error messages.
+ + + + +
+ + + +
+
+

+ + getExpiry(){number} +

+ + +
+ network.js, line 1947 +
+ +
+ + +
+
+ + +
+

Get the logical interface expiry time in seconds.

+

For protocols that have a concept of a lease, such as DHCP or +DHCPv6, this function returns the remaining time in seconds +until the lease expires.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the amount of seconds until the lease expires or -1 +if it isn't applicable to the associated protocol.
+ + + + +
+ + + +
+
+

+ + getGateway6Addr(){string} +

+ + +
+ network.js, line 2132 +
+ +
+ + +
+
+ + +
+

Query the gateway (nexthop) of the IPv6 default route associated with +this logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns a string containing the IPv6 nexthop address of the associated +default route or null if no default route was found.
+ + + + +
+ + + +
+
+

+ + getGatewayAddr(){string} +

+ + +
+ network.js, line 2044 +
+ +
+ + +
+
+ + +
+

Query the gateway (nexthop) of the default route associated with +this logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns a string containing the IPv4 nexthop address of the associated +default route or null if no default route was found.
+ + + + +
+ + + +
+
+

+ + abstractgetI18n(){string} +

+ + +
+ network.js, line 1892 +
+ +
+ + +
+
+ + +
+

Return a human readable description for the protcol, such as +Static address or DHCP client.

+

This function should be overwritten by subclasses.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the description string.
+ + + + +
+ + + +
+
+

+ + getIfname(){null|string} +

+ + +
+ network.js, line 1852 +
+ +
+ + +
+
+ + +
+

Get the associared Linux network device of this network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the name of the associated network device or null if +it could not be determined.
+ + + + +
+ + + +
+
+

+ + getIP6Addr(){null|string} +

+ + +
+ network.js, line 2083 +
+ +
+ + +
+
+ + +
+

Query the first (primary) IPv6 address of the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the primary IPv6 address registered by the protocol handler +in CIDR notation or null if no IPv6 addresses were set.
+ + + + +
+ + + +
+
+

+ + getIP6Addrs(){Array.<string>} +

+ + +
+ network.js, line 2105 +
+ +
+ + +
+
+ + +
+

Query all IPv6 addresses of the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of IPv6 addresses in CIDR notation which have been +registered by the protocol handler. The order of the resulting array +follows the order of the addresses in ubus runtime information.
+ + + + +
+ + + +
+
+

+ + getIP6Prefix(){null|string} +

+ + +
+ network.js, line 2171 +
+ +
+ + +
+
+ + +
+

Query the routed IPv6 prefix associated with the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the routed IPv6 prefix registered by the remote protocol +handler or null if no prefix is present.
+ + + + +
+ + + +
+
+

+ + getIPAddr(){null|string} +

+ + +
+ network.js, line 1999 +
+ +
+ + +
+
+ + +
+

Query the first (primary) IPv4 address of the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the primary IPv4 address registered by the protocol handler +or null if no IPv4 addresses were set.
+ + + + +
+ + + +
+
+

+ + getIPAddrs(){Array.<string>} +

+ + +
+ network.js, line 2012 +
+ +
+ + +
+
+ + +
+

Query all IPv4 addresses of the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of IPv4 addresses in CIDR notation which have been +registered by the protocol handler. The order of the resulting array +follows the order of the addresses in ubus runtime information.
+ + + + +
+ + + +
+
+

+ + getL2Device(){LuCI.Network.Device} +

+ + +
+ network.js, line 2470 +
+ +
+ + +
+
+ + +
+

Returns the layer 2 linux network device currently associated +with this logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Network.Device + + + Returns a Network.Device class instance representing the Linux +network device currently associated with the logical interface.
+ + + + +
+ + + +
+
+

+ + getL3Device(){LuCI.Network.Device} +

+ + +
+ network.js, line 2483 +
+ +
+ + +
+
+ + +
+

Returns the layer 3 linux network device currently associated +with this logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Network.Device + + + Returns a Network.Device class instance representing the Linux +network device currently associated with the logical interface.
+ + + + +
+ + + +
+
+

+ + getMetric(){number} +

+ + +
+ network.js, line 1967 +
+ +
+ + +
+
+ + +
+

Get the metric value of the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the current metric value used for device and network +routes spawned by the associated logical interface.
+ + + + +
+ + + +
+
+

+ + getName(){string} +

+ + +
+ network.js, line 1922 +
+ +
+ + +
+
+ + +
+

Get the name of the associated logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the logical interface name, such as lan or wan.
+ + + + +
+ + + +
+
+

+ + getNetmask(){null|string} +

+ + +
+ network.js, line 2030 +
+ +
+ + +
+
+ + +
+

Query the first (primary) IPv4 netmask of the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the netmask of the primary IPv4 address registered by the +protocol handler or null if no IPv4 addresses were set.
+ + + + +
+ + + +
+
+

+ + abstractgetOpkgPackage(){string} +

+ + +
+ network.js, line 2236 +
+ +
+ + +
+
+ + +
+

Get the name of the opkg package providing the protocol functionality.

+

This function should be overwritten by protocol specific subclasses.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the name of the opkg package required for the protocol to +function, e.g. odhcp6c for the dhcpv6 prototocol.
+ + + + +
+ + + +
+
+

+ + abstractgetProtocol(){string} +

+ + +
+ network.js, line 1878 +
+ +
+ + +
+
+ + +
+

Get the name of this network protocol class.

+

This function will be overwritten by subclasses created by +Network.registerProtocol().

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the name of the network protocol implementation, e.g. +static or dhcp.
+ + + + +
+ + + +
+
+

+ + getType(){null|string} +

+ + +
+ network.js, line 1912 +
+ +
+ + +
+
+ + +
+

Get the type of the underlying interface.

+

This function actually is a convenience wrapper around +proto.get("type") and is mainly used by other LuCI.Network code +to check whether the interface is declared as bridge in UCI.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the value of the type option of the associated logical +interface or null if no type option is set.
+ + + + +
+ + + +
+
+

+ + getUptime(){number} +

+ + +
+ network.js, line 1932 +
+ +
+ + +
+
+ + +
+

Get the uptime of the logical interface.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the uptime of the associated interface in seconds.
+ + + + +
+ + + +
+
+

+ + getZoneName(){null|string} +

+ + +
+ network.js, line 1983 +
+ +
+ + +
+
+ + +
+

Get the requested firewall zone name of the logical interface.

+

Some protocol implementations request a specific firewall zone +to trigger inclusion of their resulting network devices into the +firewall rule set.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the requested firewall zone name as published in the +ubus runtime information or null if the remote protocol +handler didn't request a zone.
+ + + + +
+ + + +
+
+

+ + isAlias(){null|string} +

+ + +
+ network.js, line 2324 +
+ +
+ + +
+
+ + +
+

Checks whether this interface is an alias interface.

+

Alias interfaces are interfaces layering on top of another interface +and are denoted by a special @interfacename notation in the +underlying ifname option.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the name of the parent interface if this logical interface +is an alias or null if it is not an alias interface.
+ + + + +
+ + + +
+
+

+ + isBridge(){boolean} +

+ + +
+ network.js, line 2221 +
+ +
+ + +
+
+ + +
+

Checks whether the underlying logical interface is declared as bridge.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the interface is declared with option type bridge +and when the associated protocol implementation is not marked virtual +or false when the logical interface is no bridge.
+ + + + +
+ + + +
+
+

+ + isDynamic(){boolean} +

+ + +
+ network.js, line 2309 +
+ +
+ + +
+
+ + +
+

Checks whether this logical interface is dynamic.

+

A dynamic interface is an interface which has been created at runtime, +e.g. as sub-interface of another interface, but which is not backed by +any user configuration. Such dynamic interfaces cannot be edited but +only brought down or restarted.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns a boolean indicating whether this interface is dynamic (true) +or not (false).
+ + + + +
+ + + +
+
+

+ + isEmpty(){boolean} +

+ + +
+ network.js, line 2344 +
+ +
+ + +
+
+ + +
+

Checks whether this logical interface is "empty", meaning that ut +has no network devices attached.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if this logical interface is empty, else false.
+ + + + +
+ + + +
+
+

+ + isFloating(){boolean} +

+ + +
+ network.js, line 2293 +
+ +
+ + +
+
+ + +
+

Checks whether this protocol is "floating".

+

A "floating" protocol is a protocol which spawns its own interfaces +on demand, like a virtual one but which relies on an existinf lower +level interface to initiate the connection.

+

An example for such a protocol is "pppoe".

+

This function exists for backwards compatibility with older code +but should not be used anymore.

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns a boolean indicating whether this protocol is floating (true) +or not (false).
+ + + + +
+ + + +
+
+

+ + abstractisInstalled(){boolean} +

+ + +
+ network.js, line 2252 +
+ +
+ + +
+
+ + +
+

Checks whether the protocol functionality is installed.

+

This function exists for compatibility with old code, it always +returns true.

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the protocol support is installed, else false.
+ + + + +
+ + + +
+
+

+ + isUp(){boolean} +

+ + +
+ network.js, line 2366 +
+ +
+ + +
+
+ + +
+

Checks whether this logical interface is configured and running.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the interface is active or false when it is not.
+ + + + +
+ + + +
+
+

+ + isVirtual(){boolean} +

+ + +
+ network.js, line 2272 +
+ +
+ + +
+
+ + +
+

Checks whether this protocol is "virtual".

+

A "virtual" protocol is a protocol which spawns its own interfaces +on demand instead of using existing physical interfaces.

+

Examples for virtual protocols are 6in4 which gre spawn tunnel +network device on startup, examples for non-virtual protcols are +dhcp or static which apply IP configuration to existing interfaces.

+

This function should be overwritten by subclasses.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns a boolean indicating whether the underlying protocol spawns +dynamic interfaces (true) or not (false).
+ + + + +
+ + + +
+
+

+ + set(opt, val) +

+ + +
+ network.js, line 1841 +
+ +
+ + +
+
+ + +
+

Set the given UCI option of this network to the given value.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
opt + + +string + + + + + +

The name of the UCI option to set.

val + + +null +| + +string +| + +Array.<string> + + + + + +

The value to set or null to remove the given option from the +configuration.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.WifiDevice.html b/docs/jsapi/LuCI.Network.WifiDevice.html new file mode 100644 index 000000000..89d050e87 --- /dev/null +++ b/docs/jsapi/LuCI.Network.WifiDevice.html @@ -0,0 +1,2787 @@ + + + + + Class: WifiDevice + + + + + + + + + + + + + + + + + +
+ + +
+

Class: WifiDevice

+ + + + +
+ +
+

+ LuCI.Network. + + WifiDevice +

+ +

A Network.WifiDevice class instance represents a wireless radio device +present on the system and provides wireless capability information as +well as methods for enumerating related wireless networks.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Network.WifiDevice() +

+ + +
+ network.js, line 2957 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + addWifiNetwork(options){Promise.<(null|LuCI.Network.WifiNetwork)>} +

+ + +
+ network.js, line 3222 +
+ +
+ + +
+
+ + +
+

Adds a new wireless network associated with this radio device to the +configuration and sets its options to the provided values.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +Object.<string, (string|Array.<string>)> + + + + + + + optional + + + + + +

The options to set for the newly added wireless network.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(null|LuCI.Network.WifiNetwork)> + + + Returns a promise resolving to a WifiNetwork instance describing +the newly added wireless network or null if the given options +were invalid.
+ + + + +
+ + + +
+
+

+ + deleteWifiNetwork(network){Promise.<boolean>} +

+ + +
+ network.js, line 3247 +
+ +
+ + +
+
+ + +
+

Deletes the wireless network with the given name associated with this +radio device.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
network + + +string + + + + + +

The name of the wireless network to lookup. This may be either an uci +configuration section ID, a network ID in the form radio#.network# +or a Linux network device name like wlan0 which is resolved to the +corresponding configuration section through ubus runtime information.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<boolean> + + + Returns a promise resolving to true when the wireless network was +successfully deleted from the configuration or false when the given +network could not be found or if the found network was not associated +with this wireless radio device.
+ + + + +
+ + + +
+
+

+ + get(opt){null|string|Array.<string>} +

+ + +
+ network.js, line 2997 +
+ +
+ + +
+
+ + +
+

Read the given UCI option value of this wireless device.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
opt + + +string + + + + + +

The UCI option name to read.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + | + + Array.<string> + + + Returns the UCI option value or null if the requested option is +not found.
+ + + + +
+ + + +
+
+

+ + getHTModes(){Array.<string>} +

+ + +
+ network.js, line 3075 +
+ +
+ + +
+
+ + +
+

Gets a list of supported htmodes.

+

The htmode values describe the wide-frequency options supported by +the wireless phy.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of valid htmode values for this radio. Currently +known mode values are: +
    +
  • HT20 - applicable to IEEE 802.11n, 20 MHz wide channels
  • +
  • HT40 - applicable to IEEE 802.11n, 40 MHz wide channels
  • +
  • VHT20 - applicable to IEEE 802.11ac, 20 MHz wide channels
  • +
  • VHT40 - applicable to IEEE 802.11ac, 40 MHz wide channels
  • +
  • VHT80 - applicable to IEEE 802.11ac, 80 MHz wide channels
  • +
  • VHT160 - applicable to IEEE 802.11ac, 160 MHz wide channels
  • +
+ + + + +
+ + + +
+
+

+ + getHWModes(){Array.<string>} +

+ + +
+ network.js, line 3054 +
+ +
+ + +
+
+ + +
+

Gets a list of supported hwmodes.

+

The hwmode values describe the frequency band and wireless standard +versions supported by the wireless phy.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of valid hwmode values for this radio. Currently +known mode values are: +
    +
  • a - Legacy 802.11a mode, 5 GHz, up to 54 Mbit/s
  • +
  • b - Legacy 802.11b mode, 2.4 GHz, up to 11 Mbit/s
  • +
  • g - Legacy 802.11g mode, 2.4 GHz, up to 54 Mbit/s
  • +
  • n - IEEE 802.11n mode, 2.4 or 5 GHz, up to 600 Mbit/s
  • +
  • ac - IEEE 802.11ac mode, 5 GHz, up to 6770 Mbit/s
  • +
+ + + + +
+ + + +
+
+

+ + getI18n(){string} +

+ + +
+ network.js, line 3086 +
+ +
+ + +
+
+ + +
+

Get a string describing the wireless radio hardware.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the description string.
+ + + + +
+ + + +
+
+

+ + getName(){string} +

+ + +
+ network.js, line 3035 +
+ +
+ + +
+
+ + +
+

Get the configuration name of this wireless radio.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the UCI section name (e.g. radio0) of the corresponding +radio configuration which also serves as unique logical identifier +for the wireless phy.
+ + + + +
+ + + +
+
+

+ + getScanList(){Promise.<Array.<LuCI.Network.WifiScanResult>>} +

+ + +
+ network.js, line 3147 +
+ +
+ + +
+
+ + +
+

Trigger a wireless scan on this radio device and obtain a list of +nearby networks.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.Network.WifiScanResult>> + + + Returns a promise resolving to an array of scan result objects +describing the networks found in the vincinity.
+ + + + +
+ + + +
+
+

+ + getWifiNetwork(network){Promise.<LuCI.Network.WifiNetwork>} +

+ + +
+ network.js, line 3180 +
+ +
+ + +
+
+ + +
+

Get the wifi network of the given name belonging to this radio device

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
network + + +string + + + + + +

The name of the wireless network to lookup. This may be either an uci +configuration section ID, a network ID in the form radio#.network# +or a Linux network device name like wlan0 which is resolved to the +corresponding configuration section through ubus runtime information.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<LuCI.Network.WifiNetwork> + + + Returns a promise resolving to a Network.WifiNetwork instance +representing the wireless network and rejecting with null if +the given network could not be found or is not associated with +this radio device.
+ + + + +
+ + + +
+
+

+ + getWifiNetworks(){Promise.<Array.<LuCI.Network.WifiNetwork>>} +

+ + +
+ network.js, line 3199 +
+ +
+ + +
+
+ + +
+

Get all wireless networks associated with this wireless radio device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.Network.WifiNetwork>> + + + Returns a promise resolving to an array of Network.WifiNetwork +instances respresenting the wireless networks associated with this +radio device.
+ + + + +
+ + + +
+
+

+ + isDisabled(){boolean} +

+ + +
+ network.js, line 3023 +
+ +
+ + +
+
+ + +
+

Checks whether this wireless radio is disabled.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the wireless radio is marked as disabled in ubus +runtime state or when the disabled option is set in the corresponding +UCI configuration.
+ + + + +
+ + + +
+
+

+ + isUp(){boolean} +

+ + +
+ network.js, line 3158 +
+ +
+ + +
+
+ + +
+

Check whether the wireless radio is marked as up in the ubus +runtime state.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the radio device is up, else false.
+ + + + +
+ + + +
+
+

+ + set(opt, val) +

+ + +
+ network.js, line 3011 +
+ +
+ + +
+
+ + +
+

Set the given UCI option of this network to the given value.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
opt + + +string + + + + + +

The name of the UCI option to set.

val + + +null +| + +string +| + +Array.<string> + + + + + +

The value to set or null to remove the given option from the +configuration.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.WifiNetwork.html b/docs/jsapi/LuCI.Network.WifiNetwork.html new file mode 100644 index 000000000..20ba7447a --- /dev/null +++ b/docs/jsapi/LuCI.Network.WifiNetwork.html @@ -0,0 +1,4908 @@ + + + + + Class: WifiNetwork + + + + + + + + + + + + + + + + + +
+ + +
+

Class: WifiNetwork

+ + + + +
+ +
+

+ LuCI.Network. + + WifiNetwork +

+ +

A Network.WifiNetwork instance represents a wireless network (vif) +configured on top of a radio device and provides functions for querying +the runtime state of the network. Most radio devices support multiple +such networks in parallel.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Network.WifiNetwork() +

+ + +
+ network.js, line 3280 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + get(opt){null|string|Array.<string>} +

+ + +
+ network.js, line 3313 +
+ +
+ + +
+
+ + +
+

Read the given UCI option value of this wireless network.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
opt + + +string + + + + + +

The UCI option name to read.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + | + + Array.<string> + + + Returns the UCI option value or null if the requested option is +not found.
+ + + + +
+ + + +
+
+

+ + getActiveBSSID(){string} +

+ + +
+ network.js, line 3566 +
+ +
+ + +
+
+ + +
+

Query the current BSSID from runtime information.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the current BSSID or Mesh ID as reported by ubus runtime +information.
+ + + + +
+ + + +
+
+

+ + getActiveEncryption(){string} +

+ + +
+ network.js, line 3577 +
+ +
+ + +
+
+ + +
+

Query the current encryption settings from runtime information.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns a string describing the current encryption or - if the the +encryption state could not be found in ubus runtime information.
+ + + + +
+ + + +
+
+

+ + getActiveMode(){string} +

+ + +
+ network.js, line 3514 +
+ +
+ + +
+
+ + +
+

Query the current operation mode from runtime information.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the human readable mode name as reported by ubus runtime +state. Possible returned values are: +
    +
  • Master
  • +
  • Ad-Hoc
  • +
  • Client
  • +
  • Monitor
  • +
  • Master (VLAN)
  • +
  • WDS
  • +
  • Mesh Point
  • +
  • P2P Client
  • +
  • P2P Go
  • +
  • Unknown
  • +
+ + + + +
+ + + +
+
+

+ + getActiveModeI18n(){string} +

+ + +
+ network.js, line 3535 +
+ +
+ + +
+
+ + +
+

Query the current operation mode from runtime information as +translated string.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the translated, human readable mode name as reported by +ubus runtime state.
+ + + + +
+ + + +
+
+

+ + getActiveSSID(){string} +

+ + +
+ network.js, line 3555 +
+ +
+ + +
+
+ + +
+

Query the current SSID from runtime information.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the current SSID or Mesh ID as reported by ubus runtime +information.
+ + + + +
+ + + +
+
+

+ + getAssocList(){Promise.<Array.<LuCI.Network.WifiPeerEntry>>} +

+ + +
+ network.js, line 3757 +
+ +
+ + +
+
+ + +
+

Fetch the list of associated peers.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.Network.WifiPeerEntry>> + + + Returns a promise resolving to an array of wireless peers associated +with this network.
+ + + + +
+ + + +
+
+

+ + getBitRate(){null|number} +

+ + +
+ network.js, line 3787 +
+ +
+ + +
+
+ + +
+

Query the current average bitrate of all peers associated to this +wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + number + + + Returns the average bit rate among all peers associated to the network +as reported by ubus runtime information or null if the information +is not available.
+ + + + +
+ + + +
+
+

+ + getBSSID(){null|string} +

+ + +
+ network.js, line 3392 +
+ +
+ + +
+
+ + +
+

Get the configured BSSID of the wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the BSSID value or null if none has been specified.
+ + + + +
+ + + +
+
+

+ + getChannel(){null|number} +

+ + +
+ network.js, line 3803 +
+ +
+ + +
+
+ + +
+

Query the current wireless channel.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + number + + + Returns the wireless channel as reported by ubus runtime information +or null if it cannot be determined.
+ + + + +
+ + + +
+
+

+ + getCountryCode(){string} +

+ + +
+ network.js, line 3836 +
+ +
+ + +
+
+ + +
+

Query the current country code.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the wireless country code as reported by ubus runtime +information or 00 if it cannot be determined.
+ + + + +
+ + + +
+
+

+ + getDevice(){LuCI.Network.Device} +

+ + +
+ network.js, line 3982 +
+ +
+ + +
+
+ + +
+

Get the associated Linux network device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Network.Device + + + Returns a Network.Device instance representing the Linux network +device associted with this wireless network.
+ + + + +
+ + + +
+
+

+ + getFrequency(){null|string} +

+ + +
+ network.js, line 3769 +
+ +
+ + +
+
+ + +
+

Query the current operating frequency of the wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the current operating frequency of the network from ubus +runtime information in GHz or null if the information is not +available.
+ + + + +
+ + + +
+
+

+ + getI18n(){string} +

+ + +
+ network.js, line 3930 +
+ +
+ + +
+
+ + +
+

Get a description string for this wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns a string describing this network, consisting of the +term Wireless Network, followed by the active operation mode, +the SSID, BSSID or internal network ID and the Linux network device +name, depending on which information is available.
+ + + + +
+ + + +
+
+

+ + getID(){string} +

+ + +
+ network.js, line 3417 +
+ +
+ + +
+
+ + +
+

Get the internal network ID of this wireless network.

+

The network ID is a LuCI specific identifer in the form +radio#.network# to identify wireless networks by their corresponding +radio and network index numbers.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the LuCI specific network ID.
+ + + + +
+ + + +
+
+

+ + getIfname(){null|string} +

+ + +
+ network.js, line 3439 +
+ +
+ + +
+
+ + +
+

Get the Linux network device name.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the current Linux network device name as resolved from +ubus runtime information or null if this network has no +associated network device, e.g. when not configured or up.
+ + + + +
+ + + +
+
+

+ + getMeshID(){null|string} +

+ + +
+ network.js, line 3379 +
+ +
+ + +
+
+ + +
+

Get the configured Mesh ID of the wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the configured mesh ID value or null when this network +is not in mesh mode.
+ + + + +
+ + + +
+
+

+ + getMode(){string} +

+ + +
+ network.js, line 3354 +
+ +
+ + +
+
+ + +
+

Get the configured operation mode of the wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the configured operation mode. Possible values are: +
    +
  • ap - Master (Access Point) mode
  • +
  • sta - Station (client) mode
  • +
  • adhoc - Ad-Hoc (IBSS) mode
  • +
  • mesh - Mesh (IEEE 802.11s) mode
  • +
  • monitor - Monitor mode
  • +
+ + + + +
+ + + +
+
+

+ + getName(){string} +

+ + +
+ network.js, line 3427 +
+ +
+ + +
+
+ + +
+

Get the configuration ID of this wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the corresponding UCI section ID of the network.
+ + + + +
+ + + +
+
+

+ + getNetwork(){null|LuCI.Network.Protocol} +

+ + +
+ network.js, line 3946 +
+ +
+ + +
+
+ + +
+

Get the primary logical interface this wireless network is attached to.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + LuCI.Network.Protocol + + + Returns a Network.Protocol instance representing the logical +interface or null if this network is not attached to any logical +interface.
+ + + + +
+ + + +
+
+

+ + getNetworkNames(){Array.<string>} +

+ + +
+ network.js, line 3403 +
+ +
+ + +
+
+ + +
+

Get the names of the logical interfaces this wireless network is +attached to.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array of logical interface names.
+ + + + +
+ + + +
+
+

+ + getNetworks(){Array.<LuCI.Network.Protocol>} +

+ + +
+ network.js, line 3957 +
+ +
+ + +
+
+ + +
+

Get the logical interfaces this wireless network is attached to.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<LuCI.Network.Protocol> + + + Returns an array of Network.Protocol instances representing the +logical interfaces this wireless network is attached to.
+ + + + +
+ + + +
+
+

+ + getNoise(){number} +

+ + +
+ network.js, line 3825 +
+ +
+ + +
+
+ + +
+

Query the current radio noise floor.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the radio noise floor in dBm as reported by ubus runtime +information or 0 if it cannot be determined.
+ + + + +
+ + + +
+
+

+ + getShortName(){string} +

+ + +
+ network.js, line 3915 +
+ +
+ + +
+
+ + +
+

Get a short description string for this wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns a string describing this network, consisting of the +active operation mode, followed by either the SSID, BSSID or +internal network ID, depending on which information is available.
+ + + + +
+ + + +
+
+

+ + getSignal(){null|number} +

+ + +
+ network.js, line 3814 +
+ +
+ + +
+
+ + +
+

Query the current wireless signal.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + number + + + Returns the wireless signal in dBm as reported by ubus runtime +information or null if it cannot be determined.
+ + + + +
+ + + +
+
+

+ + getSignalLevel(){number} +

+ + +
+ network.js, line 3874 +
+ +
+ + +
+
+ + +
+

Calculate the current signal.

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the calculated signal level, which is the difference between +noise and signal (SNR), divided by 5.
+ + + + +
+ + + +
+
+

+ + getSignalPercent(){number} +

+ + +
+ network.js, line 3897 +
+ +
+ + +
+
+ + +
+

Calculate the current signal quality percentage.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the calculated signal quality in percent. The value is +calculated from the quality and quality_max indicators reported +by ubus runtime state.
+ + + + +
+ + + +
+
+

+ + getSSID(){null|string} +

+ + +
+ network.js, line 3365 +
+ +
+ + +
+
+ + +
+

Get the configured SSID of the wireless network.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the configured SSID value or null when this network is +in mesh mode.
+ + + + +
+ + + +
+
+

+ + getTXPower(){null|number} +

+ + +
+ network.js, line 3847 +
+ +
+ + +
+
+ + +
+

Query the current radio TX power.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + number + + + Returns the wireless network transmit power in dBm as reported by +ubus runtime information or null if it cannot be determined.
+ + + + +
+ + + +
+
+

+ + getTXPowerOffset(){number} +

+ + +
+ network.js, line 3862 +
+ +
+ + +
+
+ + +
+

Query the radio TX power offset.

+

Some wireless radios have a fixed power offset, e.g. due to the +use of external amplifiers.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + number + + + Returns the wireless network transmit power offset in dBm as reported +by ubus runtime information or 0 if there is no offset, or if it +cannot be determined.
+ + + + +
+ + + +
+
+

+ + getWifiDevice(){null|LuCI.Network.WifiDevice} +

+ + +
+ network.js, line 3467 +
+ +
+ + +
+
+ + +
+

Get the corresponding wifi radio device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + LuCI.Network.WifiDevice + + + Returns a Network.WifiDevice instance representing the corresponding +wifi radio device or null if the related radio device could not be +found.
+ + + + +
+ + + +
+
+

+ + getWifiDeviceName(){null|string} +

+ + +
+ network.js, line 3455 +
+ +
+ + +
+
+ + +
+

Get the name of the corresponding wifi radio device.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the name of the radio device this network is configured on +or null if it cannot be determined.
+ + + + +
+ + + +
+
+

+ + isDisabled(){boolean} +

+ + +
+ network.js, line 3339 +
+ +
+ + +
+
+ + +
+

Checks whether this wireless network is disabled.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the wireless radio is marked as disabled in ubus +runtime state or when the disabled option is set in the corresponding +UCI configuration.
+ + + + +
+ + + +
+
+

+ + isUp(){boolean} +

+ + +
+ network.js, line 3488 +
+ +
+ + +
+
+ + +
+

Check whether the radio network is up.

+

This function actually queries the up state of the related radio +device and assumes this network to be up as well when the parent +radio is up. This is due to the fact that OpenWrt does not control +virtual interfaces individually but within one common hostapd +instance.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the network is up, else false.
+ + + + +
+ + + +
+
+

+ + set(opt, val) +

+ + +
+ network.js, line 3327 +
+ +
+ + +
+
+ + +
+

Set the given UCI option of this network to the given value.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
opt + + +string + + + + + +

The name of the UCI option to set.

val + + +null +| + +string +| + +Array.<string> + + + + + +

The value to set or null to remove the given option from the +configuration.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.html b/docs/jsapi/LuCI.Network.html new file mode 100644 index 000000000..5b4d1e81b --- /dev/null +++ b/docs/jsapi/LuCI.Network.html @@ -0,0 +1,7032 @@ + + + + + Class: Network + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Network

+ + + + +
+ +
+

+ LuCI. + + Network +

+ +

The LuCI.Network class combines data from multiple ubus apis to +provide an abstraction of the current network configuration state.

+

It provides methods to enumerate interfaces and devices, to query +current configuration details and to manipulate settings.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Network() +

+ + +
+ network.js, line 628 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + +

Classes

+ +
+
Device
+
+ +
Hosts
+
+ +
Protocol
+
+ +
WifiDevice
+
+ +
WifiNetwork
+
+
+ + + + + + + +

Methods

+ +
+ +
+
+

+ + addNetwork(name, options){Promise.<(null|LuCI.Network.Protocol)>} +

+ + +
+ network.js, line 884 +
+ +
+ + +
+
+ + +
+

Adds a new network of the given name and update it with the given +uci option values.

+

If a network with the given name already exist but is empty, then +this function will update its option, otherwise it will do nothing.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + + + + + + + +

The name of the network to add. Must be in the format [a-zA-Z0-9_]+.

options + + +Object.<string, (string|Array.<string>)> + + + + + + + optional + + + + + +

An object of uci option values to set on the new network or to +update in an existing, empty network.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(null|LuCI.Network.Protocol)> + + + Returns a promise resolving to the Protocol subclass instance +describing the added network or resolving to null if the name +was invalid or if a non-empty network of the given name already +existed.
+ + + + +
+ + + +
+
+

+ + addWifiNetwork(options){Promise.<(null|LuCI.Network.WifiNetwork)>} +

+ + +
+ network.js, line 1352 +
+ +
+ + +
+
+ + +
+

Adds a new wireless network to the configuration and sets its options +to the provided values.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +Object.<string, (string|Array.<string>)> + + + + + +

The options to set for the newly added wireless network. This object +must at least contain a device property which is set to the radio +name the new network belongs to.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(null|LuCI.Network.WifiNetwork)> + + + Returns a promise resolving to a WifiNetwork instance describing +the newly added wireless network or null if the given options +were invalid or if the associated radio device could not be found.
+ + + + +
+ + + +
+
+

+ + deleteNetwork(name){Promise.<boolean>} +

+ + +
+ network.js, line 962 +
+ +
+ + +
+
+ + +
+

Deletes the given network and its references from the network and +firewall configuration.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + + +

The name of the network to delete.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<boolean> + + + Returns a promise resolving to either true if the network and +references to it were successfully deleted from the configuration or +false if the given network could not be found.
+ + + + +
+ + + +
+
+

+ + deleteWifiNetwork(netname){Promise.<boolean>} +

+ + +
+ network.js, line 1390 +
+ +
+ + +
+
+ + +
+

Deletes the given wireless network from the configuration.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
netname + + +string + + + + + +

The name of the network to remove. This may be either a +network ID in the form radio#.network# or a Linux network device +name like wlan0 which is resolved to the corresponding configuration +section through ubus runtime information.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<boolean> + + + Returns a promise resolving to true if the wireless network has been +successfully deleted from the configuration or false if it could not +be found.
+ + + + +
+ + + +
+
+

+ + flushCache(){Promise.<Object>} +

+ + +
+ network.js, line 728 +
+ +
+ + +
+
+ + +
+

Flushes the local network state cache and fetches updated information +from the remote ubus apis.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Object> + + + Returns a promise resolving to the internal network state object.
+ + + + +
+ + + +
+
+

+ + formatWifiEncryption(encryption){null|string} +

+ + +
+ network.js, line 719 +
+ +
+ + +
+
+ + +
+

Converts a given encryption entry +into a human readable string such as mixed WPA/WPA2 PSK (TKIP, CCMP) +or WPA3 SAE (CCMP).

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
encryption + + +LuCI.Network.WifiEncryption + + + + + +

The wireless encryption entry to convert.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns the description string for the given encryption entry or +null if the given entry was invalid.
+ + + + +
+ + + +
+
+

+ + getDevice(name){Promise.<(null|LuCI.Network.Device)>} +

+ + +
+ network.js, line 1087 +
+ +
+ + +
+
+ + +
+

Get a Device instance describing the +given network device.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + + +

The name of the network device to get, e.g. eth0 or br-lan.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(null|LuCI.Network.Device)> + + + Returns a promise resolving to the Device instance describing +the network device or null if the given device name could not +be found.
+ + + + +
+ + + +
+
+

+ + getDevices(){Promise.<Array.<LuCI.Network.Device>>} +

+ + +
+ network.js, line 1110 +
+ +
+ + +
+
+ + +
+

Get a sorted list of all found network devices.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.Network.Device>> + + + Returns a promise resolving to a sorted array of Device class +instances describing the network devices found on the system.
+ + + + +
+ + + +
+
+

+ + getDSLModemType(){Promise.<(null|string)>} +

+ + +
+ network.js, line 1594 +
+ +
+ + +
+
+ + +
+

Queries the internal DSL modem type from board information.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(null|string)> + + + Returns a promise resolving to the type of the internal modem +(e.g. vdsl) or to null if no internal modem is present.
+ + + + +
+ + + +
+
+

+ + getHostHints(){Promise.<LuCI.Network.Hosts>} +

+ + +
+ network.js, line 1611 +
+ +
+ + +
+
+ + +
+

Queries aggregated information about known hosts.

+

This function aggregates information from various sources such as +DHCP lease databases, ARP and IPv6 neighbour entries, wireless +association list etc. and returns a Hosts +class instance describing the found hosts.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<LuCI.Network.Hosts> + + + Returns a Hosts instance describing host known on the system.
+ + + + +
+ + + +
+
+

+ + getIfnameOf(obj){null|string} +

+ + +
+ network.js, line 1583 +
+ +
+ + +
+
+ + +
+

Obtains the the network device name of the given object.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +LuCI.Network.Protocol +| + +LuCI.Network.Device +| + +LuCI.Network.WifiDevice +| + +LuCI.Network.WifiNetwork +| + +string + + + + + +

The object to get the device name from.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns a string containing the device name or null if the given +object could not be converted to a name.
+ + + + +
+ + + +
+
+

+ + getNetwork(name){Promise.<(null|LuCI.Network.Protocol)>} +

+ + +
+ network.js, line 921 +
+ +
+ + +
+
+ + +
+

Get a Protocol instance describing +the network with the given name.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + + +

The logical interface name of the network get, e.g. lan or wan.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(null|LuCI.Network.Protocol)> + + + Returns a promise resolving to a +Protocol subclass instance describing +the network or null if the network did not exist.
+ + + + +
+ + + +
+
+

+ + getNetworks(){Promise.<Array.<LuCI.Network.Protocol>>} +

+ + +
+ network.js, line 946 +
+ +
+ + +
+
+ + +
+

Gets an array containing all known networks.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.Network.Protocol>> + + + Returns a promise resolving to a name-sorted array of +Protocol subclass instances +describing all known networks.
+ + + + +
+ + + +
+
+

+ + getProtocol(protoname, netname){null|LuCI.Network.Protocol} +

+ + +
+ network.js, line 750 +
+ +
+ + +
+
+ + +
+

Instantiates the given Protocol backend, +optionally using the given network name.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
protoname + + +string + + + + + + + + + + + + +

The protocol backend to use, e.g. static or dhcp.

netname + + +string + + + + + + __dummy__ + + + + + optional + + + + + +

The network name to use for the instantiated protocol. This should be +usually set to one of the interfaces described in /etc/config/network +but it is allowed to omit it, e.g. to query protocol capabilities +without the need for an existing interface.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + LuCI.Network.Protocol + + + Returns the instantiated protocol backend class or null if the given +protocol isn't known.
+ + + + +
+ + + +
+
+

+ + getProtocols(){Array.<LuCI.Network.Protocol>} +

+ + +
+ network.js, line 765 +
+ +
+ + +
+
+ + +
+

Obtains instances of all known Protocol +backend classes.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<LuCI.Network.Protocol> + + + Returns an array of protocol class instances.
+ + + + +
+ + + +
+
+

+ + getSwitchTopologies(){Promise.<Object.<string, LuCI.Network.SwitchTopology>>} +

+ + +
+ network.js, line 1538 +
+ +
+ + +
+
+ + +
+

Returns the topologies of all swconfig switches found on the system.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Object.<string, LuCI.Network.SwitchTopology>> + + + Returns a promise resolving to an object containing the topologies +of each switch. The object keys correspond to the name of the switches +such as switch0, the values are +SwitchTopology objects describing +the layout.
+ + + + +
+ + + +
+
+

+ + getWAN6Networks(){Promise.<Array.<LuCI.Network.Protocol>>} +

+ + +
+ network.js, line 1493 +
+ +
+ + +
+
+ + +
+

Get IPv6 wan networks.

+

This function looks up all networks having a default ::/0 route +and returns them as array.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.Network.Protocol>> + + + Returns a promise resolving to an array of Protocol subclass +instances describing the found IPv6 default route interfaces.
+ + + + +
+ + + +
+
+

+ + getWANNetworks(){Promise.<Array.<LuCI.Network.Protocol>>} +

+ + +
+ network.js, line 1472 +
+ +
+ + +
+
+ + +
+

Get IPv4 wan networks.

+

This function looks up all networks having a default 0.0.0.0/0 route +and returns them as array.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.Network.Protocol>> + + + Returns a promise resolving to an array of Protocol subclass +instances describing the found default route interfaces.
+ + + + +
+ + + +
+
+

+ + getWifiDevice(devname){Promise.<(null|LuCI.Network.WifiDevice)>} +

+ + +
+ network.js, line 1240 +
+ +
+ + +
+
+ + +
+

Get a WifiDevice instance describing +the given wireless radio.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
devname + + +string + + + + + +

The configuration name of the wireless radio to lookup, e.g. radio0 +for the first mac80211 phy on the system.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(null|LuCI.Network.WifiDevice)> + + + Returns a promise resolving to the WifiDevice instance describing +the underlying radio device or null if the wireless radio could not +be found.
+ + + + +
+ + + +
+
+

+ + getWifiDevices(){Promise.<Array.<LuCI.Network.WifiDevice>>} +

+ + +
+ network.js, line 1260 +
+ +
+ + +
+
+ + +
+

Obtain a list of all configured radio devices.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.Network.WifiDevice>> + + + Returns a promise resolving to an array of WifiDevice instances +describing the wireless radios configured in the system. +The order of the array corresponds to the order of the radios in +the configuration.
+ + + + +
+ + + +
+
+

+ + getWifiNetwork(netname){Promise.<(null|LuCI.Network.WifiNetwork)>} +

+ + +
+ network.js, line 1289 +
+ +
+ + +
+
+ + +
+

Get a WifiNetwork instance describing +the given wireless network.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
netname + + +string + + + + + +

The name of the wireless network to lookup. This may be either an uci +configuration section ID, a network ID in the form radio#.network# +or a Linux network device name like wlan0 which is resolved to the +corresponding configuration section through ubus runtime information.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(null|LuCI.Network.WifiNetwork)> + + + Returns a promise resolving to the WifiNetwork instance describing +the wireless network or null if the corresponding network could not +be found.
+ + + + +
+ + + +
+
+

+ + isIgnoredDevice(name){boolean} +

+ + +
+ network.js, line 1223 +
+ +
+ + +
+
+ + +
+

Test if a given network device name is in the list of patterns for +device names to ignore.

+

Ignored device names are usually Linux network devices which are +spawned implicitly by kernel modules such as tunl0 or hwsim0 +and which are unsuitable for use in network configuration.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + + +

The device name to test.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the given name is in the ignore pattern list, +else returns false.
+ + + + +
+ + + +
+
+

+ + maskToPrefix(netmask, v6){null|number} +

+ + +
+ network.js, line 664 +
+ +
+ + +
+
+ + +
+

Converts the given netmask to a prefix size in bits.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
netmask + + +string + + + + + + + + + + + + +

The netmask to convert into a bit count.

v6 + + +boolean + + + + + + false + + + + + optional + + + + + +

Whether to parse the given netmask as IPv4 (false) or IPv6 (true) +address.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + number + + + Returns the number of prefix bits contained in the netmask or null +if the given netmask value was invalid.
+ + + + +
+ + + +
+
+

+ + prefixToMask(bits, v6){null|string} +

+ + +
+ network.js, line 646 +
+ +
+ + +
+
+ + +
+

Converts the given prefix size in bits to a netmask.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
bits + + +number + + + + + + + + + + + + +

The prefix size in bits.

v6 + + +boolean + + + + + + false + + + + + optional + + + + + +

Whether to convert the bits value into an IPv4 netmask (false) or +an IPv6 netmask (true).

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + + + Returns a string containing the netmask corresponding to the bit count +or null when the given amount of bits exceeds the maximum possible +value of 32 for IPv4 or 128 for IPv6.
+ + + + +
+ + + +
+
+

+ + registerErrorCode(code, message){boolean} +

+ + +
+ network.js, line 853 +
+ +
+ + +
+
+ + +
+

Registers a new human readable translation string for a Protocol +error code.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
code + + +string + + + + + +

The ubus protocol error code to register a translation for, e.g. +NO_DEVICE.

message + + +string + + + + + +

The message to use as translation for the given protocol error code.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the error code description has been added or false +if either the arguments were invalid or if there already was a +description for the given code.
+ + + + +
+ + + +
+
+

+ + registerPatternVirtual(pat) +

+ + +
+ network.js, line 833 +
+ +
+ + +
+
+ + +
+

Registers a new regular expression pattern to recognize +virtual interfaces.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
pat + + +RegExp + + + + + +

A RegExp instance to match a virtual interface name +such as 6in4-wan or tun0.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + registerProtocol(protoname, methods){LuCI.Network.Protocol} +

+ + +
+ network.js, line 792 +
+ +
+ + +
+
+ + +
+

Registers a new Protocol subclass +with the given methods and returns the resulting subclass value.

+

This functions internally calls +Class.extend() on the Network.Protocol +base class.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
protoname + + +string + + + + + +

The name of the new protocol to register.

methods + + +Object.<string, *> + + + + + +

The member methods and values of the new Protocol subclass to +be passed to Class.extend().

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Network.Protocol + + + Returns the new Protocol subclass.
+ + + + +
+ + + +
+
+

+ + renameNetwork(oldName, newName){Promise.<boolean>} +

+ + +
+ network.js, line 1026 +
+ +
+ + +
+
+ + +
+

Rename the given network and its references to a new name.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
oldName + + +string + + + + + +

The current name of the network.

newName + + +string + + + + + +

The name to rename the network to, must be in the format +[a-z-A-Z0-9_]+.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<boolean> + + + Returns a promise resolving to either true if the network was +successfully renamed or false if the new name was invalid, if +a network with the new name already exists or if the network to +rename could not be found.
+ + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

LuCI.Network.SwitchTopologyObject.<string, (Object|Array)>

+
+ + +
+
+ +
+

Describes an swconfig switch topology by specifying the CPU +connections and external port labels of a switch.

+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
netdevs + + +Object.<number, string> + + + +

The netdevs property points to an object describing the CPU port +connections of the switch. The numeric key of the enclosed object is +the port number, the value contains the Linux network device name the +port is hardwired to.

ports + + +Array.<Object.<string, (boolean|number|string)>> + + + +

The ports property points to an array describing the populated +ports of the switch in the external label order. Each array item is +an object containg the following keys:

+
    +
  • num - the internal switch port number
  • +
  • label - the label of the port, e.g. LAN 1 or CPU (eth0)
  • +
  • device - the connected Linux network device name (CPU ports only)
  • +
  • tagged - a boolean indicating whether the port must be tagged to +function (CPU ports only)
  • +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

LuCI.Network.WifiEncryptionObject.<string, (boolean|Array.<(number|string)>)>

+
+ + +
+
+ +
+

An encryption entry describes active wireless encryption settings +such as the used key management protocols, active ciphers and +protocol versions.

+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDescription
enabled + + +boolean + + + + + + + +

Specifies whether any kind of encryption, such as WEP or WPA is +enabled. If set to false, then no encryption is active and the +corresponding network is open.

wep + + +Array.<string> + + + + + + <optional>
+ + + +

When the wep property exists, the network uses WEP encryption. +In this case, the property is set to an array of active WEP modes +which might be either open, shared or both.

wpa + + +Array.<number> + + + + + + <optional>
+ + + +

When the wpa property exists, the network uses WPA security. +In this case, the property is set to an array containing the WPA +protocol versions used, e.g. [ 1, 2 ] for WPA/WPA2 mixed mode or +[ 3 ] for WPA3-SAE.

authentication + + +Array.<string> + + + + + + <optional>
+ + + +

The authentication property only applies to WPA encryption and +is defined when the wpa property is set as well. It points to +an array of active authentication suites used by the network, e.g. +[ "psk" ] for a WPA(2)-PSK network or [ "psk", "sae" ] for +mixed WPA2-PSK/WPA3-SAE encryption.

ciphers + + +Array.<string> + + + + + + <optional>
+ + + +

If either WEP or WPA encryption is active, then the ciphers +property will be set to an array describing the active encryption +ciphers used by the network, e.g. [ "tkip", "ccmp" ] for a +WPA/WPA2-PSK mixed network or [ "wep-40", "wep-104" ] for an +WEP network.

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

LuCI.Network.WifiPeerEntryObject.<string, (boolean|number|string|LuCI.Network.WifiRateEntry)>

+
+ + +
+
+ +
+

A wireless peer entry describes the properties of a remote wireless +peer associated with a local network.

+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDescription
mac + + +string + + + + + + + +

The MAC address (BSSID).

signal + + +number + + + + + + + +

The received signal strength.

signal_avg + + +number + + + + + + <optional>
+ + + +

The average signal strength if supported by the driver.

noise + + +number + + + + + + <optional>
+ + + +

The current noise floor of the radio. May be 0 or absent if not +supported by the driver.

inactive + + +number + + + + + + + +

The amount of milliseconds the peer has been inactive, e.g. due +to powersave.

connected_time + + +number + + + + + + + +

The amount of milliseconds the peer is associated to this network.

thr + + +number + + + + + + <optional>
+ + + +

The estimated throughput of the peer, May be 0 or absent if not +supported by the driver.

authorized + + +boolean + + + + + + + +

Specifies whether the peer is authorized to associate to this network.

authenticated + + +boolean + + + + + + + +

Specifies whether the peer completed authentication to this network.

preamble + + +string + + + + + + + +

The preamble mode used by the peer. May be long or short.

wme + + +boolean + + + + + + + +

Specifies whether the peer supports WME/WMM capabilities.

mfp + + +boolean + + + + + + + +

Specifies whether management frame protection is active.

tdls + + +boolean + + + + + + + +

Specifies whether TDLS is active.

mesh llid + + +number + + + + + + <optional>
+ + + +

The mesh LLID, may be 0 or absent if not applicable or supported +by the driver.

mesh plid + + +number + + + + + + <optional>
+ + + +

The mesh PLID, may be 0 or absent if not applicable or supported +by the driver.

mesh plink + + +string + + + + + + <optional>
+ + + +

The mesh peer link state description, may be an empty string ('') +or absent if not applicable or supported by the driver.

+

The following states are known:

+
    +
  • LISTEN
  • +
  • OPN_SNT
  • +
  • OPN_RCVD
  • +
  • CNF_RCVD
  • +
  • ESTAB
  • +
  • HOLDING
  • +
  • BLOCKED
  • +
  • UNKNOWN
  • +
mesh local PS + + +number + + + + + + <optional>
+ + + +

The local powersafe mode for the peer link, may be an empty +string ('') or absent if not applicable or supported by +the driver.

+

The following modes are known:

+
    +
  • ACTIVE (no power save)
  • +
  • LIGHT SLEEP
  • +
  • DEEP SLEEP
  • +
  • UNKNOWN
  • +
mesh peer PS + + +number + + + + + + <optional>
+ + + +

The remote powersafe mode for the peer link, may be an empty +string ('') or absent if not applicable or supported by +the driver.

+

The following modes are known:

+
    +
  • ACTIVE (no power save)
  • +
  • LIGHT SLEEP
  • +
  • DEEP SLEEP
  • +
  • UNKNOWN
  • +
mesh non-peer PS + + +number + + + + + + <optional>
+ + + +

The powersafe mode for all non-peer neigbours, may be an empty +string ('') or absent if not applicable or supported by the driver.

+

The following modes are known:

+
    +
  • ACTIVE (no power save)
  • +
  • LIGHT SLEEP
  • +
  • DEEP SLEEP
  • +
  • UNKNOWN
  • +
rx + + +LuCI.Network.WifiRateEntry + + + + + + + +

Describes the receiving wireless rate from the peer.

tx + + +LuCI.Network.WifiRateEntry + + + + + + + +

Describes the transmitting wireless rate to the peer.

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

LuCI.Network.WifiRateEntryObject.<string, (boolean|number)>

+
+ + +
+
+ +
+

A wireless rate entry describes the properties of a wireless +transmission rate to or from a peer.

+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDescription
drop_misc + + +number + + + + + + <optional>
+ + + +

The amount of received misc. packages that have been dropped, e.g. +due to corruption or missing authentication. Only applicable to +receiving rates.

packets + + +number + + + + + + + +

The amount of packets that have been received or sent.

bytes + + +number + + + + + + + +

The amount of bytes that have been received or sent.

failed + + +number + + + + + + <optional>
+ + + +

The amount of failed tranmission attempts. Only applicable to +transmit rates.

retries + + +number + + + + + + <optional>
+ + + +

The amount of retried transmissions. Only applicable to transmit +rates.

is_ht + + +boolean + + + + + + + +

Specifies whether this rate is an HT (IEEE 802.11n) rate.

is_vht + + +boolean + + + + + + + +

Specifies whether this rate is an VHT (IEEE 802.11ac) rate.

mhz + + +number + + + + + + + +

The channel width in MHz used for the transmission.

rate + + +number + + + + + + + +

The bitrate in bit/s of the transmission.

mcs + + +number + + + + + + <optional>
+ + + +

The MCS index of the used transmission rate. Only applicable to +HT or VHT rates.

40mhz + + +number + + + + + + <optional>
+ + + +

Specifies whether the tranmission rate used 40MHz wide channel. +Only applicable to HT or VHT rates.

+

Note: this option exists for backwards compatibility only and its +use is discouraged. The mhz field should be used instead to +determine the channel width.

short_gi + + +boolean + + + + + + <optional>
+ + + +

Specifies whether a short guard interval is used for the transmission. +Only applicable to HT or VHT rates.

nss + + +number + + + + + + <optional>
+ + + +

Specifies the number of spatial streams used by the transmission. +Only applicable to VHT rates.

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

LuCI.Network.WifiScanResultObject.<string, (number|string|LuCI.Network.WifiEncryption)>

+
+ + +
+
+ +
+

A wireless scan result object describes a neighbouring wireless +network found in the vincinity.

+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ssid + + +string + + + +

The SSID / Mesh ID of the network.

bssid + + +string + + + +

The BSSID if the network.

mode + + +string + + + +

The operation mode of the network (Master, Ad-Hoc, Mesh Point).

channel + + +number + + + +

The wireless channel of the network.

signal + + +number + + + +

The received signal strength of the network in dBm.

quality + + +number + + + +

The numeric quality level of the signal, can be used in conjunction +with quality_max to calculate a quality percentage.

quality_max + + +number + + + +

The maximum possible quality level of the signal, can be used in +conjunction with quality to calculate a quality percentage.

encryption + + +LuCI.Network.WifiEncryption + + + +

The encryption used by the wireless network.

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Poll.html b/docs/jsapi/LuCI.Poll.html new file mode 100644 index 000000000..a00c9a3ac --- /dev/null +++ b/docs/jsapi/LuCI.Poll.html @@ -0,0 +1,1878 @@ + + + + + Class: Poll + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Poll

+ + + + +
+ +
+

+ LuCI. + + Poll +

+ +

The Poll class allows registering and unregistering poll actions, +as well as starting, stopping and querying the state of the polling +loop.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Poll() +

+ + +
+ luci.js, line 999 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + active(){boolean} +

+ + +
+ luci.js, line 1150 +
+ +
+ + +
+
+ + +
+

Test whether the polling loop is running.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + +
    +
  • Returns true if polling is active, else false.
  • +
+ + + + +
+ + + +
+
+

+ + add(fn, interval){boolean} +

+ + +
+ luci.js, line 1023 +
+ +
+ + +
+
+ + +
+

Add a new operation to the polling loop. If the polling loop is not +already started at this point, it will be implicitely started.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +function + + + + + +

The function to invoke on each poll interval.

interval + + +number + + + + + +

The poll interval in seconds.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws TypeError when an invalid interval was passed.

+
+
+
+
+
+ Type +
+
+ +TypeError + + +
+
+
+
+ + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the function has been added or false if it +already is registered.
+ + + + +
+ + + +
+
+

+ + remove(fn){boolean} +

+ + +
+ luci.js, line 1064 +
+ +
+ + +
+
+ + +
+

Remove an operation from the polling loop. If no further operatons +are registered, the polling loop is implicitely stopped.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +function + + + + + +

The function to remove.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws TypeError when the given argument isn't a function.

+
+
+
+
+
+ Type +
+
+ +TypeError + + +
+
+
+
+ + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the function has been removed or false if it +wasn't found.
+ + + + +
+ + + +
+
+

+ + start(){boolean} +

+ + +
+ luci.js, line 1090 +
+ +
+ + +
+
+ + +
+

(Re)start the polling loop. Dispatches a custom poll-start event +to the document object upon successful start.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if polling has been started (or if no functions +where registered) or false when the polling loop already runs.
+ + + + +
+ + + +
+
+

+ + stop(){boolean} +

+ + +
+ luci.js, line 1115 +
+ +
+ + +
+
+ + +
+

Stop the polling loop. Dispatches a custom poll-stop event +to the document object upon successful stop.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if polling has been stopped or false if it din't +run to begin with.
+ + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Request.html b/docs/jsapi/LuCI.Request.html new file mode 100644 index 000000000..530bf9a03 --- /dev/null +++ b/docs/jsapi/LuCI.Request.html @@ -0,0 +1,2774 @@ + + + + + Class: Request + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Request

+ + + + +
+ +
+

+ LuCI. + + Request +

+ +

The Request class allows initiating HTTP requests and provides utilities +for dealing with responses.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Request() +

+ + +
+ luci.js, line 569 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + +

Classes

+ +
+
poll
+
+
+ + + + + + + +

Methods

+ +
+ +
+
+

+ + addInterceptor(interceptorFn){LuCI.Request.interceptorFn} +

+ + +
+ luci.js, line 844 +
+ +
+ + +
+
+ + +
+

Register an HTTP response interceptor function. Interceptor +functions are useful to perform default actions on incoming HTTP +responses, such as checking for expired authentication or for +implementing request retries before returning a failure.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
interceptorFn + + +LuCI.Request.interceptorFn + + + + + +

The interceptor function to register.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Request.interceptorFn + + + The registered function.
+ + + + +
+ + + +
+
+

+ + expandURL(url){string} +

+ + +
+ luci.js, line 586 +
+ +
+ + +
+
+ + +
+

Turn the given relative URL into an absolute URL if necessary.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +string + + + + + +

The URL to convert.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + The absolute URL derived from the given one, or the original URL +if it already was absolute.
+ + + + +
+ + + +
+
+

+ + get(target, options){Promise.<LuCI.Response>} +

+ + +
+ luci.js, line 797 +
+ +
+ + +
+
+ + +
+

Initiate an HTTP GET request to the given target.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
target + + +string + + + + + + + + + + +

The URL to request.

options + + +LuCI.Request.RequestOptions + + + + + + + optional + + + + + +

Additional options to configure the request.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<LuCI.Response> + + + The resulting HTTP response.
+ + + + +
+ + + +
+
+

+ + post(target, data, options){Promise.<LuCI.Response>} +

+ + +
+ luci.js, line 818 +
+ +
+ + +
+
+ + +
+

Initiate an HTTP POST request to the given target.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
target + + +string + + + + + + + + + + +

The URL to request.

data + + +* + + + + + + + optional + + + + + +

The request data to send, see LuCI.Request.RequestOptions for details.

options + + +LuCI.Request.RequestOptions + + + + + + + optional + + + + + +

Additional options to configure the request.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<LuCI.Response> + + + The resulting HTTP response.
+ + + + +
+ + + +
+
+

+ + removeInterceptor(interceptorFn){boolean} +

+ + +
+ luci.js, line 863 +
+ +
+ + +
+
+ + +
+

Remove an HTTP response interceptor function. The passed function +value must be the very same value that was used to register the +function.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
interceptorFn + + +LuCI.Request.interceptorFn + + + + + +

The interceptor function to remove.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if any function has been removed, else false.
+ + + + +
+ + + +
+
+

+ + request(target, options){Promise.<LuCI.Response>} +

+ + +
+ luci.js, line 648 +
+ +
+ + +
+
+ + +
+

Initiate an HTTP request to the given target.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
target + + +string + + + + + + + + + + +

The URL to request.

options + + +LuCI.Request.RequestOptions + + + + + + + optional + + + + + +

Additional options to configure the request.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<LuCI.Response> + + + The resulting HTTP response.
+ + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

+ + LuCI.Request.interceptorFn(res) +

+ + +
+ luci.js, line 822 +
+ +
+ + +
+
+ + +
+

Interceptor functions are invoked whenever an HTTP reply is received, in the order +these functions have been registered.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
res + + +LuCI.Response + + + + + +

The HTTP response object

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

LuCI.Request.RequestOptionsObject

+
+ + +
+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
method + + +string + + + + + + <optional>
+ + + +
+ + GET + +

The HTTP method to use, e.g. GET or POST.

query + + +Object.<string, (Object|string)> + + + + + + <optional>
+ + + +
+ +

Query string data to append to the URL. Non-string values of the +given object will be converted to JSON.

cache + + +boolean + + + + + + <optional>
+ + + +
+ + false + +

Specifies whether the HTTP response may be retrieved from cache.

username + + +string + + + + + + <optional>
+ + + +
+ +

Provides a username for HTTP basic authentication.

password + + +string + + + + + + <optional>
+ + + +
+ +

Provides a password for HTTP basic authentication.

timeout + + +number + + + + + + <optional>
+ + + +
+ +

Specifies the request timeout in seconds.

credentials + + +boolean + + + + + + <optional>
+ + + +
+ + false + +

Whether to include credentials such as cookies in the request.

content + + +* + + + + + + <optional>
+ + + +
+ +

Specifies the HTTP message body to send along with the request. +If the value is a function, it is invoked and the return value +used as content, if it is a FormData instance, it is used as-is, +if it is an object, it will be converted to JSON, in all other +cases it is converted to a string.

header + + +Object.<string, string> + + + + + + <optional>
+ + + +
+ +

Specifies HTTP headers to set for the request.

progress + + +function + + + + + + <optional>
+ + + +
+ +

An optional request callback function which receives ProgressEvent +instances as sole argument during the HTTP request transfer.

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Request.poll.html b/docs/jsapi/LuCI.Request.poll.html new file mode 100644 index 000000000..656f91152 --- /dev/null +++ b/docs/jsapi/LuCI.Request.poll.html @@ -0,0 +1,1997 @@ + + + + + Class: poll + + + + + + + + + + + + + + + + + +
+ + +
+

Class: poll

+ + + + +
+ +
+

+ LuCI.Request. + + poll +

+ +

The Request.poll class provides some convience wrappers around +LuCI.Poll mainly to simplify registering repeating HTTP +request calls as polling functions.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Request.poll() +

+ + +
+ luci.js, line 881 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + active() +

+ + +
+ luci.js, line 985 +
+ +
+ + +
+
+ + +
+

Alias for LuCI.Poll.active().

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + add(interval, url, options, callback){function} +

+ + +
+ luci.js, line 924 +
+ +
+ + +
+
+ + +
+

Register a repeating HTTP request with an optional callback +to invoke whenever a response for the request is received.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
interval + + +number + + + + + + + + + + +

The poll interval in seconds.

url + + +string + + + + + + + + + + +

The URL to request on each poll.

options + + +LuCI.Request.RequestOptions + + + + + + + optional + + + + + +

Additional options to configure the request.

callback + + +LuCI.Request.poll~callbackFn + + + + + + + optional + + + + + +

Callback function to +invoke for each HTTP reply.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws TypeError when an invalid interval was passed.

+
+
+
+
+
+ Type +
+
+ +TypeError + + +
+
+
+
+ + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + function + + + Returns the internally created poll function.
+ + + + +
+ + + +
+
+

+ + remove(entry){boolean} +

+ + +
+ luci.js, line 961 +
+ +
+ + +
+
+ + +
+

Remove a polling request that has been previously added using add(). +This function is essentially a wrapper around +LuCI.Poll.remove().

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
entry + + +function + + + + + +

The poll function returned by add().

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if any function has been removed, else false.
+ + + + +
+ + + +
+
+

+ + start() +

+ + +
+ luci.js, line 969 +
+ +
+ + +
+
+ + +
+

Alias for LuCI.Poll.start().

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + stop() +

+ + +
+ luci.js, line 977 +
+ +
+ + +
+
+ + +
+

Alias for LuCI.Poll.stop().

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

+ + callbackFn(res, data, duration) +

+ + +
+ luci.js, line 882 +
+ +
+ + +
+
+ + +
+

The callback function is invoked whenever an HTTP reply to a +polled request is received or when the polled request timed +out.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
res + + +LuCI.Response + + + + + +

The HTTP response object.

data + + +* + + + + + +

The response JSON if the response could be parsed as such, +else null.

duration + + +number + + + + + +

The total duration of the request in milliseconds.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.Response.html b/docs/jsapi/LuCI.Response.html new file mode 100644 index 000000000..a7398ef50 --- /dev/null +++ b/docs/jsapi/LuCI.Response.html @@ -0,0 +1,1855 @@ + + + + + Class: Response + + + + + + + + + + + + + + + + + +
+ + +
+

Class: Response

+ + + + +
+ +
+

+ LuCI. + + Response +

+ +

The Response class is an internal utility class representing HTTP responses.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.Response() +

+ + +
+ luci.js, line 377 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+
+

durationnumber

+
+ + +
+
+ +
+

The total duration of the HTTP request in milliseconds

+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

headersLuCI.Headers

+
+ + +
+
+ +
+

The HTTP headers of the response

+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

okboolean

+
+ + +
+
+ +
+

Describes whether the response is successful (status codes 200..299) or not

+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

statusnumber

+
+ + +
+
+ +
+

The numeric HTTP status code of the response

+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

statusTextstring

+
+ + +
+
+ +
+

The HTTP status description message of the response

+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

urlstring

+
+ + +
+
+ +
+

The final URL of the request, i.e. after following redirects.

+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

+ + clone(content){LuCI.Response} +

+ + +
+ luci.js, line 465 +
+ +
+ + +
+
+ + +
+

Clones the given response object, optionally overriding the content +of the cloned instance.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
content + + +* + + + + + + + optional + + + + + +

Override the content of the cloned response. Object values will be +treated as JSON response data, all other types will be converted +using String() and treated as response text.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.Response + + + The cloned Response instance.
+ + + + +
+ + + +
+
+

+ + json(){*} +

+ + +
+ luci.js, line 486 +
+ +
+ + +
+
+ + +
+

Access the response content as JSON data.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws SyntaxError if the content isn't valid JSON.

+
+
+
+
+
+ Type +
+
+ +SyntaxError + + +
+
+
+
+ + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + + + The parsed JSON data.
+ + + + +
+ + + +
+
+

+ + text(){string} +

+ + +
+ luci.js, line 501 +
+ +
+ + +
+
+ + +
+

Access the response content as string.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + The response content.
+ + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.XHR.html b/docs/jsapi/LuCI.XHR.html new file mode 100644 index 000000000..5a17dfa85 --- /dev/null +++ b/docs/jsapi/LuCI.XHR.html @@ -0,0 +1,2047 @@ + + + + + Class: XHR + + + + + + + + + + + + + + + + + +
+ + +
+

Class: XHR

+ + + + +
+ +
+

+ LuCI. + + XHR +

+ +

The LuCI.XHR class is a legacy compatibility shim for the +functionality formerly provided by xhr.js. It is registered as global +window.XHR symbol for compatibility with legacy code.

+

New code should use LuCI.Request instead to implement HTTP +request handling.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.XHR() +

+ + +
+ luci.js, line 2943 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + abort() +

+ + +
+ luci.js, line 3046 +
+ +
+ + +
+
+ + +
+

Ignored for backwards compatibility.

+

This function does nothing.

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + busy(){boolean} +

+ + +
+ luci.js, line 3035 +
+ +
+ + +
+
+ + +
+

Checks the running state of the request.

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the request is still running or false if it +already completed.
+ + + + +
+ + + +
+
+

+ + cancel() +

+ + +
+ luci.js, line 3022 +
+ +
+ + +
+
+ + +
+

Cancels a running request.

+

This function does not actually cancel the underlying +XMLHTTPRequest request but it sets a flag which prevents the +invocation of the callback function when the request eventually +finishes or timed out.

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + get(url, data, callback, timeout){Promise.<null>} +

+ + +
+ luci.js, line 2978 +
+ +
+ + +
+
+ + +
+

This function is a legacy wrapper around +LuCI.get().

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +string + + + + + + + + + + +

The URL to request

data + + +Object + + + + + + + optional + + + + + +

Additional query string data

callback + + +LuCI.requestCallbackFn + + + + + + + optional + + + + + +

Callback function to invoke on completion

timeout + + +number + + + + + + + optional + + + + + +

Request timeout to use

+ + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<null> + + +
+ + + + +
+ + + +
+
+

+ + post(url, data, callback, timeout){Promise.<null>} +

+ + +
+ luci.js, line 3005 +
+ +
+ + +
+
+ + +
+

This function is a legacy wrapper around +LuCI.post().

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +string + + + + + + + + + + +

The URL to request

data + + +Object + + + + + + + optional + + + + + +

Additional data to append to the request body.

callback + + +LuCI.requestCallbackFn + + + + + + + optional + + + + + +

Callback function to invoke on completion

timeout + + +number + + + + + + + optional + + + + + +

Request timeout to use

+ + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<null> + + +
+ + + + +
+ + + +
+
+

+ + send_form() +

+ + +
+ luci.js, line 3061 +
+ +
+ + +
+
+ + +
+

Existing for backwards compatibility.

+

This function simply throws an InternalError when invoked.

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws an InternalError with the message Not implemented +when invoked.

+
+
+
+
+
+ Type +
+
+ +InternalError + + +
+
+
+
+ + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.dom.html b/docs/jsapi/LuCI.dom.html new file mode 100644 index 000000000..8412eb302 --- /dev/null +++ b/docs/jsapi/LuCI.dom.html @@ -0,0 +1,3878 @@ + + + + + Class: dom + + + + + + + + + + + + + + + + + +
+ + +
+

Class: dom

+ + + + +
+ +
+

+ LuCI. + + dom +

+ +

The dom class provides convenience method for creating and +manipulating DOM elements.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.dom() +

+ + +
+ luci.js, line 2065 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + append(node, children){Node|null} +

+ + +
+ luci.js, line 2216 +
+ +
+ + +
+
+ + +
+

Appends the given children data to the given node.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +* + + + + + + + + + + +

The Node argument to append the children to.

children + + +* + + + + + + + optional + + + + + +

The childrens to append to the given node.

+

When children is an array, then each item of the array +will be either appended as child element or text node, +depending on whether the item is a DOM Node instance or +some other non-null value. Non-Node, non-null values +will be converted to strings first before being passed as +argument to createTextNode().

+

When children is a function, it will be invoked with +the passed node argument as sole parameter and the append +function will be invoked again, with the given node argument +as first and the return value of the children function as +second parameter.

+

When children is is a DOM Node instance, it will be +appended to the given node.

+

When children is any other non-null value, it will be +converted to a string and appened to the innerHTML property +of the given node.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Node + | + + null + + + Returns the last children Node appended to the node or null +if either the node argument was no valid DOM node or if the +children was null or didn't result in further DOM nodes.
+ + + + +
+ + + +
+
+

+ + attr(node, key, val) +

+ + +
+ luci.js, line 2331 +
+ +
+ + +
+
+ + +
+

Sets attributes or registers event listeners on element nodes.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +* + + + + + + + + + + +

The Node argument to set the attributes or add the event +listeners for. When the given node value is not a valid +DOM Node, the function returns and does nothing.

key + + +string +| + +Object.<string, *> + + + + + + + + + + +

Specifies either the attribute or event handler name to use, +or an object containing multiple key, value pairs which are +each added to the node as either attribute or event handler, +depending on the respective value.

val + + +* + + + + + + + optional + + + + + +

Specifies the attribute value or event handler function to add. +If the key parameter is an Object, this parameter will be +ignored.

+

When val is of type function, it will be registered as event +handler on the given node with the key parameter being the +event name.

+

When val is of type object, it will be serialized as JSON and +added as attribute to the given node, using the given key +as attribute name.

+

When val is of any other type, it will be added as attribute +to the given node as-is, with the underlying setAttribute() +call implicitely turning it into a string.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + bindClassInstance(node, inst){Class} +

+ + +
+ luci.js, line 2565 +
+ +
+ + +
+
+ + +
+

Binds the given class instance ot the specified DOM Node.

+

This function uses the dom.data() facility to attach the +passed instance of a Class to a node. This is needed for +complex widget elements or similar where the corresponding +class instance responsible for the element must be retrieved +from DOM nodes obtained by querySelector() or similar means.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +Node + + + + + +

The DOM Node instance to bind the class to.

inst + + +Class + + + + + +

The Class instance to bind to the node.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws a TypeError when the given instance argument isn't +a valid Class instance.

+
+
+
+
+
+ Type +
+
+ +TypeError + + +
+
+
+
+ + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Class + + + Returns the bound class instance.
+ + + + +
+ + + +
+
+

+ + callClassMethod(node, method, params){*|null} +

+ + +
+ luci.js, line 2619 +
+ +
+ + +
+
+ + +
+

Finds a bound class instance on the given node itself or the +first bound instance on its closest parent node and invokes +the specified method name on the found class instance.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +Node + + + + + + + + + + +

The DOM Node instance to start from.

method + + +string + + + + + + + + + + +

The name of the method to invoke on the found class instance.

params + + +* + + + + + + + + + + repeatable + + +

Additional arguments to pass to the invoked method as-is.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + | + + null + + + Returns the return value of the invoked method if a class +instance and method has been found. Returns null if either +no bound class instance could be found, or if the found +instance didn't have the requested method.
+ + + + +
+ + + +
+
+

+ + content(node, children){Node|null} +

+ + +
+ luci.js, line 2283 +
+ +
+ + +
+
+ + +
+

Replaces the content of the given node with the given children.

+

This function first removes any children of the given DOM +Node and then adds the given given children following the +rules outlined below.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +* + + + + + + + + + + +

The Node argument to replace the children of.

children + + +* + + + + + + + optional + + + + + +

The childrens to replace into the given node.

+

When children is an array, then each item of the array +will be either appended as child element or text node, +depending on whether the item is a DOM Node instance or +some other non-null value. Non-Node, non-null values +will be converted to strings first before being passed as +argument to createTextNode().

+

When children is a function, it will be invoked with +the passed node argument as sole parameter and the append +function will be invoked again, with the given node argument +as first and the return value of the children function as +second parameter.

+

When children is is a DOM Node instance, it will be +appended to the given node.

+

When children is any other non-null value, it will be +converted to a string and appened to the innerHTML property +of the given node.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Node + | + + null + + + Returns the last children Node appended to the node or null +if either the node argument was no valid DOM node or if the +children was null or didn't result in further DOM nodes.
+ + + + +
+ + + +
+
+

+ + create(html, attr, data){Node} +

+ + +
+ luci.js, line 2409 +
+ +
+ + +
+
+ + +
+

Creates a new DOM Node from the given html, attr and +data parameters.

+

This function has multiple signatures, it can be either invoked +in the form create(html[, attr[, data]]) or in the form +create(html[, data]). The used variant is determined from the +type of the second argument.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
html + + +* + + + + + + + + + + +

Describes the node to create.

+

When the value of html is of type array, a DocumentFragment +node is created and each item of the array is first converted +to a DOM Node by passing it through create() and then added +as child to the fragment.

+

When the value of html is a DOM Node instance, no new +element will be created but the node will be used as-is.

+

When the value of html is a string starting with <, it will +be passed to dom.parse() and the resulting value is used.

+

When the value of html is any other string, it will be passed +to document.createElement() for creating a new DOM Node of +the given name.

attr + + +Object.<string, *> + + + + + + + optional + + + + + +

Specifies an Object of key, value pairs to set as attributes +or event handlers on the created node. Refer to +dom.attr() for details.

data + + +* + + + + + + + optional + + + + + +

Specifies children to append to the newly created element. +Refer to dom.append() for details.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws an InvalidCharacterError when the given html +argument contained malformed markup (such as not escaped +& characters in XHTML mode) or when the given node name +in html contains characters which are not legal in DOM +element names, such as spaces.

+
+
+
+
+
+ Type +
+
+ +InvalidCharacterError + + +
+
+
+
+ + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Node + + + Returns the newly created Node.
+ + + + +
+ + + +
+
+

+ + data(node, key, val){*} +

+ + +
+ luci.js, line 2485 +
+ +
+ + +
+
+ + +
+

Attaches or detaches arbitrary data to and from a DOM Node.

+

This function is useful to attach non-string values or runtime +data that is not serializable to DOM nodes. To decouple data +from the DOM, values are not added directly to nodes, but +inserted into a registry instead which is then referenced by a +string key stored as data-idref attribute in the node.

+

This function has multiple signatures and is sensitive to the +number of arguments passed to it.

+
    +
  • dom.data(node) - +Fetches all data associated with the given node.
  • +
  • dom.data(node, key) - +Fetches a specific key associated with the given node.
  • +
  • dom.data(node, key, val) - +Sets a specific key to the given value associated with the +given node.
  • +
  • dom.data(node, null) - +Clears any data associated with the node.
  • +
  • dom.data(node, key, null) - +Clears the given key associated with the node.
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +Node + + + + + + + + + + +

The DOM Node instance to set or retrieve the data for.

key + + +string +| + +null + + + + + + + optional + + + + + +

This is either a string specifying the key to retrieve, or +null to unset the entire node data.

val + + +* +| + +null + + + + + + + optional + + + + + +

This is either a non-null value to set for a given key or +null to remove the given key from the specified node.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + + + Returns the get or set value, or null when no value could +be found.
+ + + + +
+ + + +
+
+

+ + elem(e){boolean} +

+ + +
+ luci.js, line 2079 +
+ +
+ + +
+
+ + +
+

Tests whether the given argument is a valid DOM Node.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
e + + +* + + + + + +

The value to test.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the value is a DOM Node, else false.
+ + + + +
+ + + +
+
+

+ + findClassInstance(node){Class|null} +

+ + +
+ luci.js, line 2585 +
+ +
+ + +
+
+ + +
+

Finds a bound class instance on the given node itself or the +first bound instance on its closest parent node.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +Node + + + + + +

The DOM Node instance to start from.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Class + | + + null + + + Returns the founds class instance if any or null if no bound +class could be found on the node itself or any of its parents.
+ + + + +
+ + + +
+
+

+ + isEmpty(node, ignoreFn){boolean} +

+ + +
+ luci.js, line 2665 +
+ +
+ + +
+
+ + +
+

Tests whether a given DOM Node instance is empty or appears +empty.

+

Any element child nodes which have the CSS class hidden set +or for which the optionally passed ignoreFn callback function +returns false are ignored.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +Node + + + + + + + + + + +

The DOM Node instance to test.

ignoreFn + + +LuCI.dom~ignoreCallbackFn + + + + + + + optional + + + + + +

Specifies an optional function which is invoked for each child +node to decide whether the child node should be ignored or not.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the node does not have any children or if +any children node either has a hidden CSS class or a false +result when testing it using the given ignoreFn.
+ + + + +
+ + + +
+
+

+ + matches(node, selector){boolean} +

+ + +
+ luci.js, line 2140 +
+ +
+ + +
+
+ + +
+

Tests whether a given Node matches the given query selector.

+

This function is a convenience wrapper around the standard +Node.matches("selector") function with the added benefit that +the node argument may be a non-Node value, in which case +this function simply returns false.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +* + + + + + + + + + + +

The Node argument to test the selector against.

selector + + +string + + + + + + + optional + + + + + +

The query selector expression to test against the given node.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the given node matches the specified selector +or false when the node argument is no valid DOM Node or the +selector didn't match.
+ + + + +
+ + + +
+
+

+ + parent(node, selector){Node|null} +

+ + +
+ luci.js, line 2167 +
+ +
+ + +
+
+ + +
+

Returns the closest parent node that matches the given query +selector expression.

+

This function is a convenience wrapper around the standard +Node.closest("selector") function with the added benefit that +the node argument may be a non-Node value, in which case +this function simply returns null.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +* + + + + + + + + + + +

The Node argument to find the closest parent for.

selector + + +string + + + + + + + optional + + + + + +

The query selector expression to test against each parent.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Node + | + + null + + + Returns the closest parent node matching the selector or +null when the node argument is no valid DOM Node or the +selector didn't match any parent.
+ + + + +
+ + + +
+
+

+ + parse(s){Node} +

+ + +
+ luci.js, line 2098 +
+ +
+ + +
+
+ + +
+

Parses a given string as HTML and returns the first child node.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
s + + +string + + + + + +

A string containing an HTML fragment to parse. Note that only +the first result of the resulting structure is returned, so an +input value of <div>foo</div> <div>bar</div> will only return +the first div element node.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Node + + + Returns the first DOM Node extracted from the HTML fragment or +null on parsing failures or if no element could be found.
+ + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

+ + ignoreCallbackFn(node){boolean} +

+ + +
+ luci.js, line 2628 +
+ +
+ + +
+
+ + +
+

The ignore callback function is invoked by isEmpty() for each +child node to decide whether to ignore a child node or not.

+

When this function returns false, the node passed to it is +ignored, else not.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
node + + +Node + + + + + +

The child node to test.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Boolean indicating whether to ignore the node or not.
+ + + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.fs.html b/docs/jsapi/LuCI.fs.html new file mode 100644 index 000000000..cfc0dc9ce --- /dev/null +++ b/docs/jsapi/LuCI.fs.html @@ -0,0 +1,2987 @@ + + + + + Class: fs + + + + + + + + + + + + + + + + + +
+ + +
+

Class: fs

+ + + + +
+ +
+

+ LuCI. + + fs +

+ +

Provides high level utilities to wrap file system related RPC calls. +To import the class in views, use 'require fs', to import it in +external JavaScript, use L.require("fs").then(...).

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.fs() +

+ + +
+ fs.js, line 111 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + exec(command, params, env){Promise.<LuCI.fs.FileExecResult>} +

+ + +
+ fs.js, line 232 +
+ +
+ + +
+
+ + +
+

Execute the specified command, optionally passing params and +environment variables.

+

Note: The command must be either the path to an executable, +or a basename without arguments in which case it will be searched +in $PATH. If specified, the values given in params will be passed +as arguments to the command.

+

The key/value pairs in the optional env table are translated to +setenv() calls prior to running the command.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
command + + +string + + + + + + + + + + +

The command to invoke.

params + + +Array.<string> + + + + + + + optional + + + + + +

The arguments to pass to the command.

env + + +Object.<string, string> + + + + + + + optional + + + + + +

Environment variables to set.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<LuCI.fs.FileExecResult> + + + Returns a promise resolving to an object describing the execution +results or rejecting with an error stating the failure reason.
+ + + + +
+ + + +
+
+

+ + lines(path){Promise.<Array.<string>>} +

+ + +
+ fs.js, line 281 +
+ +
+ + +
+
+ + +
+

Read the contents of the given file, split it into lines, trim +leading and trailing white space of each line and return the +resulting array.

+

This function is guaranteed to not reject its promises, on failure, +an empty array will be returned.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
path + + +string + + + + + +

The file path to read.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<string>> + + + Returns a promise resolving to an array containing the stripped lines +of the given file or [] on failure.
+ + + + +
+ + + +
+
+

+ + list(path){Promise.<Array.<LuCI.fs.FileStatEntry>>} +

+ + +
+ fs.js, line 132 +
+ +
+ + +
+
+ + +
+

Obtains a listing of the specified directory.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
path + + +string + + + + + +

The directory path to list.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<LuCI.fs.FileStatEntry>> + + + Returns a promise resolving to an array of stat detail objects or +rejecting with an error stating the failure reason.
+ + + + +
+ + + +
+
+

+ + read(path){Promise.<string>} +

+ + +
+ fs.js, line 161 +
+ +
+ + +
+
+ + +
+

Read the contents of the given file and return them. +Note: this function is unsuitable for obtaining binary data.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
path + + +string + + + + + +

The file path to read.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<string> + + + Returns a promise resolving to a string containing the file contents or +rejecting with an error stating the failure reason.
+ + + + +
+ + + +
+
+

+ + remove(The){Promise.<number>} +

+ + +
+ fs.js, line 203 +
+ +
+ + +
+
+ + +
+

Unlink the given file.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
The + + +string + + + + + +

file path to remove.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<number> + + + Returns a promise resolving to 0 or rejecting with an error stating +the failure reason.
+ + + + +
+ + + +
+
+

+ + stat(path){Promise.<LuCI.fs.FileStatEntry>} +

+ + +
+ fs.js, line 146 +
+ +
+ + +
+
+ + +
+

Return file stat information on the specified path.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
path + + +string + + + + + +

The filesystem path to stat.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<LuCI.fs.FileStatEntry> + + + Returns a promise resolving to a stat detail object or +rejecting with an error stating the failure reason.
+ + + + +
+ + + +
+
+

+ + trimmed(path){Promise.<string>} +

+ + +
+ fs.js, line 260 +
+ +
+ + +
+
+ + +
+

Read the contents of the given file, trim leading and trailing white +space and return the trimmed result. In case of errors, return an empty +string instead.

+

Note: this function is useful to read single-value files in /sys +or /proc.

+

This function is guaranteed to not reject its promises, on failure, +an empty string will be returned.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
path + + +string + + + + + +

The file path to read.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<string> + + + Returns a promise resolving to the file contents or the empty string +on failure.
+ + + + +
+ + + +
+
+

+ + write(path, data, mode){Promise.<number>} +

+ + +
+ fs.js, line 187 +
+ +
+ + +
+
+ + +
+

Write the given data to the specified file path. +If the specified file path does not exist, it will be created, given +sufficient permissions.

+

Note: data will be converted to a string using String(data) or to +'' when it is null.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
path + + +string + + + + + + + + + + +

The file path to write to.

data + + +* + + + + + + + optional + + + + + +

The file data to write. If it is null, it will be set to an empty +string.

mode + + +number + + + + + + + optional + + + + + +

The permissions to use on file creation. Default is 420 (0644).

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<number> + + + Returns a promise resolving to 0 or rejecting with an error stating +the failure reason.
+ + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

LuCI.fs.FileExecResultObject

+
+ + +
+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDescription
code + + +number + + + + + + + +

The exit code of the invoked command

stdout + + +string + + + + + + <optional>
+ + + +

The stdout produced by the command, if any

stderr + + +string + + + + + + <optional>
+ + + +

The stderr produced by the command, if any

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

LuCI.fs.FileStatEntryObject

+
+ + +
+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + +

Name of the directory entry

type + + +string + + + +

Type of the entry, one of block, char, directory, fifo, symlink, file, socket or unknown

size + + +number + + + +

Size in bytes

mode + + +number + + + +

Access permissions

atime + + +number + + + +

Last access time in seconds since epoch

mtime + + +number + + + +

Last modification time in seconds since epoch

ctime + + +number + + + +

Last change time in seconds since epoch

inode + + +number + + + +

Inode number

uid + + +number + + + +

Numeric owner id

gid + + +number + + + +

Numeric group id

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.html b/docs/jsapi/LuCI.html new file mode 100644 index 000000000..68e2042c5 --- /dev/null +++ b/docs/jsapi/LuCI.html @@ -0,0 +1,5023 @@ + + + + + Class: LuCI + + + + + + + + + + + + + + + + + +
+ + +
+

Class: LuCI

+ + + + +
+ +
+

+ LuCI +

+ +

This is the LuCI base class. It is automatically instantiated and +accessible using the global L variable.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI(env) +

+ + +
+ luci.js, line 1 +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
env + + +Object + + + + + +

The environment settings to use for the LuCI runtime.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + +

Classes

+ +
+
Class
+
+ +
dom
+
+ +
fs
+
+ +
Headers
+
+ +
Network
+
+ +
Poll
+
+ +
Request
+
+ +
Response
+
+ +
rpc
+
+ +
uci
+
+ +
view
+
+ +
XHR
+
+
+ + + + + +

Members

+ +
+ +
+
+

env

+
+ + +
+
+ +
+

The env object holds environment settings used by LuCI, such +as request timeouts, base URLs etc.

+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

+ + bind(fn, self, args){function} +

+ + +
+ luci.js, line 1340 +
+ +
+ + +
+
+ + +
+

Return a bound function using the given self as this context +and any further arguments as parameters to the bound function.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +function + + + + + + + + + + +

The function to bind.

self + + +* + + + + + + + + + + +

The value to bind as this context to the specified function.

args + + +* + + + + + + + optional + + + + + repeatable + + +

Zero or more variable arguments which are bound to the function +as parameters.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + function + + + Returns the bound function.
+ + + + +
+ + + +
+
+

+ + error(type, fmt, args) +

+ + +
+ luci.js, line 1300 +
+ +
+ + +
+
+ + +
+

A wrapper around raise() which also renders +the error either as modal overlay when ui.js is already loaed +or directly into the view body.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
type + + +Error +| + +string + + + + + + Error + + + + + optional + + + + + +

Either a string specifying the type of the error to throw or an +existing Error instance to copy.

fmt + + +string + + + + + + Unspecified error + + + + + optional + + + + + +

A format string which is used to form the error message, together +with all subsequent optional arguments.

args + + +* + + + + + + + + + optional + + + + + repeatable + + +

Zero or more variable arguments to the supplied format string.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws the created error object with the captured stack trace +appended to the message and the type set to the given type +argument or copied from the given error instance.

+
+
+
+
+
+ Type +
+
+ +Error + + +
+
+
+
+ + + + + + + +
+ + + +
+
+

+ + get(url, args, cb){Promise.<null>} +

+ + +
+ luci.js, line 1918 +
+ +
+ + +
+
+ + +
+

Issues a GET request to the given url and invokes the specified +callback function. The function is a wrapper around +Request.request().

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +string + + + + + + + + + + +

The URL to request.

args + + +Object.<string, string> + + + + + + + optional + + + + + +

Additional query string arguments to append to the URL.

cb + + +LuCI.requestCallbackFn + + + + + + + + + + +

The callback function to invoke when the request finishes.

+ + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<null> + + + Returns a promise resolving to null when concluded.
+ + + + +
+ + + +
+
+

+ + halt(){boolean} +

+ + +
+ luci.js, line 2040 +
+ +
+ + +
+
+ + +
+

Deprecated wrapper around Poll.stop().

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the polling loop has been stopped or false +when it didn't run to begin with.
+ + + + +
+ + + +
+
+

+ + hasSystemFeature(feature, subfeature){boolean|null} +

+ + +
+ luci.js, line 1574 +
+ +
+ + +
+
+ + +
+

Test whether a particular system feature is available, such as +hostapd SAE support or an installed firewall. The features are +queried once at the beginning of the LuCI session and cached in +SessionStorage throughout the lifetime of the associated tab or +browser window.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
feature + + +string + + + + + + + + + + +

The feature to test. For detailed list of known feature flags, +see /modules/luci-base/root/usr/libexec/rpcd/luci.

subfeature + + +string + + + + + + + optional + + + + + +

Some feature classes like hostapd provide sub-feature flags, +such as sae or 11w support. The subfeature argument can +be used to query these.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + | + + null + + + Return true if the queried feature (and sub-feature) is available +or false if the requested feature isn't present or known. +Return null when a sub-feature was queried for a feature which +has no sub-features.
+ + + + +
+ + + +
+
+

+ + isObject(val){boolean} +

+ + +
+ luci.js, line 1765 +
+ +
+ + +
+
+ + +
+

Tests whether the passed argument is a JavaScript object. +This function is meant to be an object counterpart to the +standard Array.isArray() function.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
val + + +* + + + + + + + optional + + + + + +

The value to test

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the given value is of type object and +not null, else returns false.
+ + + + +
+ + + +
+
+

+ + location(){string} +

+ + +
+ luci.js, line 1745 +
+ +
+ + +
+
+ + +
+

Return the complete URL path to the current view.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the URL path to the current view.
+ + + + +
+ + + +
+
+

+ + path(prefix, parts){string} +

+ + +
+ luci.js, line 1679 +
+ +
+ + +
+
+ + +
+

Construct a relative URL path from the given prefix and parts. +The resulting URL is guaranteed to only contain the characters +a-z, A-Z, 0-9, _, ., %, ,, ;, and - as well +as / for the path separator.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
prefix + + +string + + + + + + + optional + + + + + +

The prefix to join the given parts with. If the prefix is +omitted, it defaults to an empty string.

parts + + +Array.<string> + + + + + + + optional + + + + + +

An array of parts to join into an URL path. Parts may contain +slashes and any of the other characters mentioned above.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Return the joined URL path.
+ + + + +
+ + + +
+
+

+ + poll(interval, url, args, cb, post){function} +

+ + +
+ luci.js, line 1988 +
+ +
+ + +
+
+ + +
+

Register a polling HTTP request that invokes the specified +callback function. The function is a wrapper around +Request.poll.add().

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
interval + + +number + + + + + + + + + + + + +

The poll interval to use. If set to a value less than or equal +to 0, it will default to the global poll interval configured +in LuCI.env.pollinterval.

url + + +string + + + + + + + + + + + + +

The URL to request.

args + + +Object.<string, string> + + + + + + + + + optional + + + + + +

Specifies additional arguments for the request. For GET requests, +the arguments are appended to the URL as query string, for POST +requests, they'll be added to the request body.

cb + + +LuCI.requestCallbackFn + + + + + + + + + + + + +

The callback function to invoke whenever a request finishes.

post + + +boolean + + + + + + false + + + + + optional + + + + + +

When set to false or not specified, poll requests will be made +using the GET method. When set to true, POST requests will be +issued. In case of POST requests, the request body will contain +an argument token with the current value of LuCI.env.token by +default, regardless of the parameters specified with args.

+ + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + function + + + Returns the internally created function that has been passed to +Request.poll.add(). This value can +be passed to Poll.remove() to remove the +polling request.
+ + + + +
+ + + +
+
+

+ + post(url, args, cb){Promise.<null>} +

+ + +
+ luci.js, line 1946 +
+ +
+ + +
+
+ + +
+

Issues a POST request to the given url and invokes the specified +callback function. The function is a wrapper around +Request.request(). The request is +sent using application/x-www-form-urlencoded encoding and will +contain a field token with the current value of LuCI.env.token +by default.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +string + + + + + + + + + + +

The URL to request.

args + + +Object.<string, string> + + + + + + + optional + + + + + +

Additional post arguments to append to the request body.

cb + + +LuCI.requestCallbackFn + + + + + + + + + + +

The callback function to invoke when the request finishes.

+ + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<null> + + + Returns a promise resolving to null when concluded.
+ + + + +
+ + + +
+
+

+ + raise(type, fmt, args) +

+ + +
+ luci.js, line 1234 +
+ +
+ + +
+
+ + +
+

Captures the current stack trace and throws an error of the +specified type as a new exception. Also logs the exception as +error to the debug console if it is available.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
type + + +Error +| + +string + + + + + + Error + + + + + optional + + + + + +

Either a string specifying the type of the error to throw or an +existing Error instance to copy.

fmt + + +string + + + + + + Unspecified error + + + + + optional + + + + + +

A format string which is used to form the error message, together +with all subsequent optional arguments.

args + + +* + + + + + + + + + optional + + + + + repeatable + + +

Zero or more variable arguments to the supplied format string.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws the created error object with the captured stack trace +appended to the message and the type set to the given type +argument or copied from the given error instance.

+
+
+
+
+
+ Type +
+
+ +Error + + +
+
+
+
+ + + + + + + +
+ + + +
+
+

+ + require(name){Promise.<LuCI#Class>} +

+ + +
+ luci.js, line 1379 +
+ +
+ + +
+
+ + +
+

Load an additional LuCI JavaScript class and its dependencies, +instantiate it and return the resulting class instance. Each +class is only loaded once. Subsequent attempts to load the same +class will return the already instantiated class.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + + +

The name of the class to load in dotted notation. Dots will +be replaced by spaces and joined with the runtime-determined +base URL of LuCI.js to form an absolute URL to load the class +file from.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+
    +
  • + +
    +
    +
    +

    Throws a DependencyError when the class to load includes +circular dependencies.

    +
    +
    +
    +
    +
    + Type +
    +
    + +DependencyError + + +
    +
    +
    +
    + +
  • + +
  • + +
    +
    +
    +

    Throws NetworkError when the underlying LuCI.Request +call failed.

    +
    +
    +
    +
    +
    + Type +
    +
    + +NetworkError + + +
    +
    +
    +
    + +
  • + +
  • + +
    +
    +
    +

    Throws SyntaxError when the loaded class file code cannot +be interpreted by eval.

    +
    +
    +
    +
    +
    + Type +
    +
    + +SyntaxError + + +
    +
    +
    +
    + +
  • + +
  • + +
    +
    +
    +

    Throws TypeError when the class file could be loaded and +interpreted, but when invoking its code did not yield a valid +class instance.

    +
    +
    +
    +
    +
    + Type +
    +
    + +TypeError + + +
    +
    +
    +
    + +
  • +
+ + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<LuCI#Class> + + + Returns the instantiated class.
+ + + + +
+ + + +
+
+

+ + resolveDefault(value, defvalue){Promise.<*>} +

+ + +
+ luci.js, line 1873 +
+ +
+ + +
+
+ + +
+

Returns a promise resolving with either the given value or or with +the given default in case the input value is a rejecting promise.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +* + + + + + +

The value to resolve the promise with.

defvalue + + +* + + + + + +

The default value to resolve the promise with in case the given +input value is a rejecting promise.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<*> + + + Returns a new promise resolving either to the given input value or +to the given default value on error.
+ + + + +
+ + + +
+
+

+ + resource(parts){string} +

+ + +
+ luci.js, line 1732 +
+ +
+ + +
+
+ + +
+

Construct an URL path relative to the global static resource path +of the LuCI ui (usually /luci-static/resources).

+

The resulting URL is guaranteed to only contain the characters +a-z, A-Z, 0-9, _, ., %, ,, ;, and - as well +as / for the path separator.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
parts + + +Array.<string> + + + + + + + optional + + + + + +

An array of parts to join into an URL path. Parts may contain +slashes and any of the other characters mentioned above.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the resulting URL path.
+ + + + +
+ + + +
+
+

+ + run(){boolean} +

+ + +
+ luci.js, line 2053 +
+ +
+ + +
+
+ + +
+

Deprecated wrapper around Poll.start().

+
+ + + + + + + + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the polling loop has been started or false +when it was already running.
+ + + + +
+ + + +
+
+

+ + sortedKeys(obj, key, sortmode){Array.<string>} +

+ + +
+ luci.js, line 1794 +
+ +
+ + +
+
+ + +
+

Return an array of sorted object keys, optionally sorted by +a different key or a different sorting mode.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +object + + + + + + + + + + +

The object to extract the keys from. If the given value is +not an object, the function will return an empty array.

key + + +string + + + + + + + optional + + + + + +

Specifies the key to order by. This is mainly useful for +nested objects of objects or objects of arrays when sorting +shall not be performed by the primary object keys but by +some other key pointing to a value within the nested values.

sortmode + + +string + + + + + + + optional + + + + + +

May be either addr or num to override the natural +lexicographic sorting with a sorting suitable for IP/MAC style +addresses or numeric values respectively.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns an array containing the sorted keys of the given object.
+ + + + +
+ + + +
+
+

+ + stop(entry){boolean} +

+ + +
+ luci.js, line 2027 +
+ +
+ + +
+
+ + +
+

Deprecated wrapper around Poll.remove().

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
entry + + +function + + + + + +

The polling function to remove.

+ + + +
+ + + + + + + +
Deprecated
  • Yes
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the function has been removed or false if +it could not be found.
+ + + + +
+ + + +
+
+

+ + toArray(val){Array.<*>} +

+ + +
+ luci.js, line 1839 +
+ +
+ + +
+
+ + +
+

Converts the given value to an array. If the given value is of +type array, it is returned as-is, values of type object are +returned as one-element array containing the object, empty +strings and null values are returned as empty array, all other +values are converted using String(), trimmed, split on white +space and returned as array.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
val + + +* + + + + + +

The value to convert into an array.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<*> + + + Returns the resulting array.
+ + + + +
+ + + +
+
+

+ + url(parts){string} +

+ + +
+ luci.js, line 1710 +
+ +
+ + +
+
+ + +
+

Construct an URL pathrelative to the script path of the server +side LuCI application (usually /cgi-bin/luci).

+

The resulting URL is guaranteed to only contain the characters +a-z, A-Z, 0-9, _, ., %, ,, ;, and - as well +as / for the path separator.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
parts + + +Array.<string> + + + + + + + optional + + + + + +

An array of parts to join into an URL path. Parts may contain +slashes and any of the other characters mentioned above.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the resulting URL path.
+ + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

+ + LuCI.requestCallbackFn(xhr, data, duration) +

+ + +
+ luci.js, line 1877 +
+ +
+ + +
+
+ + +
+

The request callback function is invoked whenever an HTTP +reply to a request made using the L.get(), L.post() or +L.poll() function is timed out or received successfully.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
xhr + + +XMLHTTPRequest + + + + + +

The XMLHTTPRequest instance used to make the request.

data + + +* + + + + + +

The response JSON if the response could be parsed as such, +else null.

duration + + +number + + + + + +

The total duration of the request in milliseconds.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.rpc.html b/docs/jsapi/LuCI.rpc.html new file mode 100644 index 000000000..557b97237 --- /dev/null +++ b/docs/jsapi/LuCI.rpc.html @@ -0,0 +1,3225 @@ + + + + + Class: rpc + + + + + + + + + + + + + + + + + +
+ + +
+

Class: rpc

+ + + + +
+ +
+

+ LuCI. + + rpc +

+ +

The LuCI.rpc class provides high level ubus JSON-RPC abstractions +and means for listing and invoking remove RPC methods.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.rpc() +

+ + +
+ rpc.js, line 8 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + addInterceptor(interceptorFn){LuCI.rpc~interceptorFn} +

+ + +
+ rpc.js, line 454 +
+ +
+ + +
+
+ + +
+

Registers a new interceptor function.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
interceptorFn + + +LuCI.rpc~interceptorFn + + + + + +

The inteceptor function to register.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.rpc~interceptorFn + + + Returns the given function value.
+ + + + +
+ + + +
+
+

+ + declare(options){LuCI.rpc~invokeFn} +

+ + +
+ rpc.js, line 292 +
+ +
+ + +
+
+ + +
+

Describes a remote RPC call procedure and returns a function +implementing it.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +LuCI.rpc.DeclareOptions + + + + + +

If any object names are given, this function will return the method +signatures of each given object.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.rpc~invokeFn + + + Returns a new function implementing the method call described in +options.
+ + + + +
+ + + +
+
+

+ + getBaseURL(){string} +

+ + +
+ rpc.js, line 367 +
+ +
+ + +
+
+ + +
+

Returns the current RPC base URL.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the RPC URL endpoint to issue requests against.
+ + + + +
+ + + +
+
+

+ + getSessionID(){string} +

+ + +
+ rpc.js, line 346 +
+ +
+ + +
+
+ + +
+

Returns the current RPC session id.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the 32 byte session ID string used for authenticating remote +requests.
+ + + + +
+ + + +
+
+

+ + getStatusText(statusCode){string} +

+ + +
+ rpc.js, line 391 +
+ +
+ + +
+
+ + +
+

Translates a numeric ubus error code into a human readable +description.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
statusCode + + +number + + + + + +

The numeric status code.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the textual description of the code.
+ + + + +
+ + + +
+
+

+ + list(objectNames){Promise.<(Array.<string>|Object.<string, Object.<string, Object.<string, string>>>)>} +

+ + +
+ rpc.js, line 140 +
+ +
+ + +
+
+ + +
+

Lists available remote ubus objects or the method signatures of +specific objects.

+

This function has two signatures and is sensitive to the number of +arguments passed to it:

+
    +
  • list() - +Returns an array containing the names of all remote ubus objects
  • +
  • list("objname", ...) +Returns method signatures for each given ubus object name.
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
objectNames + + +string + + + + + + + optional + + + + + repeatable + + +

If any object names are given, this function will return the method +signatures of each given object.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<(Array.<string>|Object.<string, Object.<string, Object.<string, string>>>)> + + + When invoked without arguments, this function will return a promise +resolving to an array of ubus object names. When invoked with one or +more arguments, a promise resolving to an object describing the method +signatures of each requested ubus object name will be returned.
+ + + + +
+ + + +
+
+

+ + removeInterceptor(interceptorFn){boolean} +

+ + +
+ rpc.js, line 470 +
+ +
+ + +
+
+ + +
+

Removes a registered interceptor function.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
interceptorFn + + +LuCI.rpc~interceptorFn + + + + + +

The inteceptor function to remove.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true if the given function has been removed or false +if it has not been found.
+ + + + +
+ + + +
+
+

+ + setBaseURL(sid) +

+ + +
+ rpc.js, line 377 +
+ +
+ + +
+
+ + +
+

Set the RPC base URL to use.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sid + + +string + + + + + +

Sets the RPC URL endpoint to issue requests against.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + setSessionID(sid) +

+ + +
+ rpc.js, line 357 +
+ +
+ + +
+
+ + +
+

Set the RPC session id to use.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sid + + +string + + + + + +

Sets the 32 byte session ID string used for authenticating remote +requests.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

LuCI.rpc.DeclareOptionsObject

+
+ + +
+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDescription
object + + +string + + + + + + + +

The name of the remote ubus object to invoke.

method + + +string + + + + + + + +

The name of the remote ubus method to invoke.

params + + +Array.<string> + + + + + + <optional>
+ + + +

Lists the named parameters expected by the remote ubus RPC method. +The arguments passed to the resulting generated method call function +will be mapped to named parameters in the order they appear in this +array.

+

Extraneous parameters passed to the generated function will not be +sent to the remote procedure but are passed to the +filter function if one is specified.

+

Examples:

+
    +
  • params: [ "foo", "bar" ] - +When the resulting call function is invoked with fn(true, false), +the corresponding args object sent to the remote procedure will be +{ foo: true, bar: false }.
  • +
  • params: [ "test" ], filter: function(reply, args, extra) { ... } - +When the resultung generated function is invoked with +fn("foo", "bar", "baz") then { "test": "foo" } will be sent as +argument to the remote procedure and the filter function will be +invoked with filterFn(reply, [ "foo" ], "bar", "baz")
  • +
expect + + +Object.<string, *> + + + + + + <optional>
+ + + +

Describes the expected return data structure. The given object is +supposed to contain a single key selecting the value to use from +the returned ubus reply object. The value of the sole key within +the expect object is used to infer the expected type of the received +ubus reply data.

+

If the received data does not contain expect's key, or if the +type of the data differs from the type of the value in the expect +object, the expect object's value is returned as default instead.

+

The key in the expect object may be an empty string ('') in which +case the entire reply object is selected instead of one of its subkeys.

+

If the expect option is omitted, the received reply will be returned +as-is, regardless of its format or type.

+

Examples:

+
    +
  • expect: { '': { error: 'Invalid response' } } - +This requires the entire ubus reply to be a plain JavaScript +object. If the reply isn't an object but e.g. an array or a numeric +error code instead, it will get replaced with +{ error: 'Invalid response' } instead.
  • +
  • expect: { results: [] } - +This requires the received ubus reply to be an object containing +a key results with an array as value. If the received reply does +not contain such a key, or if reply.results points to a non-array +value, the empty array ([]) will be used instead.
  • +
  • expect: { success: false } - +This requires the received ubus reply to be an object containing +a key success with a boolean value. If the reply does not contain +success or if reply.success is not a boolean value, false will +be returned as default instead.
  • +
filter + + +LuCI.rpc~filterFn + + + + + + <optional>
+ + + +

Specfies an optional filter function which is invoked to transform the +received reply data before it is returned to the caller.

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

+ + filterFn(data, args, extraArgs){*} +

+ + +
+ rpc.js, line 231 +
+ +
+ + +
+
+ + +
+

The filter function is invoked to transform a received ubus RPC call +reply before returning it to the caller.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
data + + +* + + + + + + + + + + +

The received ubus reply data or a subset of it as described in the +expect option of the RPC call declaration. In case of remote call +errors, data is numeric ubus error code instead.

args + + +Array.<*> + + + + + + + + + + +

The arguments the RPC method has been invoked with.

extraArgs + + +* + + + + + + + + + + repeatable + + +

All extraneous arguments passed to the RPC method exceeding the number +of arguments describes in the RPC call declaration.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + + + The return value of the filter function will be returned to the caller +of the RPC method as-is.
+ + + + +
+ + + +
+
+

+ + interceptorFn(msg, req){Promise.<*>|*} +

+ + +
+ rpc.js, line 408 +
+ +
+ + +
+
+ + +
+

Registered interceptor functions are invoked before the standard reply +parsing and handling logic.

+

By returning rejected promises, interceptor functions can cause the +invocation function to fail, regardless of the received reply.

+

Interceptors may also modify their message argument in-place to +rewrite received replies before they're processed by the standard +response handling code.

+

A common use case for such functions is to detect failing RPC replies +due to expired authentication in order to trigger a new login.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
msg + + +* + + + + + +

The unprocessed, JSON decoded remote RPC method call reply.

+

Since interceptors run before the standard parsing logic, the reply +data is not verified for correctness or filtered according to +expect and filter specifications in the declarations.

req + + +Object + + + + + +

The related request object which is an extended variant of the +declaration object, allowing access to internals of the invocation +function such as filter, expect or params values.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<*> + | + + * + + + Interceptor functions may return a promise to defer response +processing until some delayed work completed. Any values the returned +promise resolves to are ignored. +When the returned promise rejects with an error, the invocation +function will fail too, forwarding the error to the caller.
+ + + + +
+ + + +
+
+

+ + invokeFn(params){Promise.<*>} +

+ + +
+ rpc.js, line 254 +
+ +
+ + +
+
+ + +
+

The generated invocation function is returned by +rpc.declare() and encapsulates a single +RPC method call.

+

Calling this function will execute a remote ubus HTTP call request +using the arguments passed to it as arguments and return a promise +resolving to the received reply values.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
params + + +* + + + + + + + + + + repeatable + + +

The parameters to pass to the remote procedure call. The given +positional arguments will be named to named RPC parameters according +to the names specified in the params array of the method declaration.

+

Any additional parameters exceeding the amount of arguments in the +params declaration are passed as private extra arguments to the +declared filter function.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<*> + + + Returns a promise resolving to the result data of the remote ubus +RPC method invocation, optionally substituted and filtered according +to the expect and filter declarations.
+ + + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.uci.html b/docs/jsapi/LuCI.uci.html new file mode 100644 index 000000000..32e34eacb --- /dev/null +++ b/docs/jsapi/LuCI.uci.html @@ -0,0 +1,4773 @@ + + + + + Class: uci + + + + + + + + + + + + + + + + + +
+ + +
+

Class: uci

+ + + + +
+ +
+

+ LuCI. + + uci +

+ +

The LuCI.uci class utilizes LuCI.rpc to declare low level +remote UCI ubus procedures and implements a local caching and data +manipulation layer on top to allow for synchroneous operations on +UCI configuration data.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.uci() +

+ + +
+ uci.js, line 4 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + add(config, type, name){string} +

+ + +
+ uci.js, line 269 +
+ +
+ + +
+
+ + +
+

Adds a new section of the given type to the given configuration, +optionally named according to the given name.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + + + + + + +

The name of the configuration to add the section to.

type + + +string + + + + + + + + + + +

The type of the section to add.

name + + +string + + + + + + + optional + + + + + +

The name of the section to add. If the name is omitted, an anonymous +section will be added instead.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + Returns the section ID of the newly added section which is equivalent +to the given name for non-anonymous sections.
+ + + + +
+ + + +
+
+

+ + apply(timeout){Promise.<number>} +

+ + +
+ uci.js, line 858 +
+ +
+ + +
+
+ + +
+

Instructs the remote ubus UCI api to commit all saved changes with +rollback protection and attempts to confirm the pending commit +operation to cancel the rollback timer.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
timeout + + +number + + + + + + 10 + + + + + optional + + + + + +

Override the confirmation timeout after which a rollback is triggered.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<number> + + + Returns a promise resolving/rejecting with the ubus RPC status code.
+ + + + +
+ + + +
+
+

+ + changes(){Promise.<Object.<string, Array.<LuCI.uci.ChangeRecord>>>} +

+ + +
+ uci.js, line 938 +
+ +
+ + +
+
+ + +
+

Fetches uncommitted UCI changes from the remote ubus RPC api.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Object.<string, Array.<LuCI.uci.ChangeRecord>>> + + + Returns a promise resolving to an object containing the configuration +names as keys and arrays of related change records as values.
+ + + + +
+ + + +
+
+

+ + createSID(config){string} +

+ + +
+ uci.js, line 88 +
+ +
+ + +
+
+ + +
+

Generates a new, unique section ID for the given configuration.

+

Note that the generated ID is temporary, it will get replaced by an +identifier in the form cfgXXXXXX once the configuration is saved +by the remote ubus UCI api.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + +

The configuration to generate the new section ID for.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + + + A newly generated, unique section ID in the form newXXXXXX +where X denotes a hexadecimal digit.
+ + + + +
+ + + +
+
+

+ + get(config, sid, option){null|string|Array.<string>|LuCI.uci.SectionObject} +

+ + +
+ uci.js, line 443 +
+ +
+ + +
+
+ + +
+

Gets the value of the given option within the specified section +of the given configuration or the entire section object if the +option name is omitted.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + + + + + + +

The name of the configuration to read the value from.

sid + + +string + + + + + + + + + + +

The name or ID of the section to read.

option + + +string + + + + + + + optional + + + + + +

The option name to read the value from. If the option name is +omitted or null, the entire section is returned instead.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + | + + Array.<string> + | + + LuCI.uci.SectionObject + + +
    +
  • Returns a string containing the option value in case of a +plain UCI option.
  • +
  • Returns an array of strings containing the option values in +case of option pointing to an UCI list.
  • +
  • Returns a section object if +the option argument has been omitted or is null.
  • +
  • Returns null if the config, section or option has not been +found or if the corresponding configuration is not loaded.
  • +
+ + + + +
+ + + +
+
+

+ + get_first(config, type, option){null|string|Array.<string>|LuCI.uci.SectionObject} +

+ + +
+ uci.js, line 618 +
+ +
+ + +
+
+ + +
+

Gets the value of the given option or the entire section object of +the first found section of the specified type or the first found +section of the entire configuration if no type is specfied.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + + + + + + +

The name of the configuration to read the value from.

type + + +string + + + + + + + optional + + + + + +

The type of the first section to find. If it is null, the first +section of the entire config is read, otherwise the first section +matching the given type.

option + + +string + + + + + + + optional + + + + + +

The option name to read the value from. If the option name is +omitted or null, the entire section is returned instead.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + null + | + + string + | + + Array.<string> + | + + LuCI.uci.SectionObject + + +
    +
  • Returns a string containing the option value in case of a +plain UCI option.
  • +
  • Returns an array of strings containing the option values in +case of option pointing to an UCI list.
  • +
  • Returns a section object if +the option argument has been omitted or is null.
  • +
  • Returns null if the config, section or option has not been +found or if the corresponding configuration is not loaded.
  • +
+ + + + +
+ + + +
+
+

+ + load(config){Promise.<Array.<string>>} +

+ + +
+ uci.js, line 205 +
+ +
+ + +
+
+ + +
+

Loads the given UCI configurations from the remote ubus api.

+

Loaded configurations are cached and only loaded once. Subsequent +load operations of the same configurations will return the cached +data.

+

To force reloading a configuration, it has to be unloaded with +uci.unload() first.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string +| + +Array.<string> + + + + + +

The name of the configuration or an array of configuration +names to load.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Promise.<Array.<string>> + + + Returns a promise resolving to the names of the configurations +that have been successfully loaded.
+ + + + +
+ + + +
+
+

+ + move(config, sid1, sid2, after){boolean} +

+ + +
+ uci.js, line 718 +
+ +
+ + +
+
+ + +
+

Move the first specified section within the given configuration +before or after the second specified section.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
config + + +string + + + + + + + + + + + + +

The configuration to move the section within.

sid1 + + +string + + + + + + + + + + + + +

The ID of the section to move within the configuration.

sid2 + + +string + + + + + + + + + optional + + + + + +

The ID of the target section for the move operation. If the +after argument is false or not specified, the section named by +sid1 will be moved before this target section, if the after +argument is true, the sid1 section will be moved after this +section.

+

When the sid2 argument is null, the section specified by sid1 +is moved to the end of the configuration.

after + + +boolean + + + + + + false + + + + + optional + + + + + +

When true, the section sid1 is moved after the section sid2, +when false, the section sid1 is moved before sid2.

+

If sid2 is null, then this parameter has no effect and the section +sid1 is moved to the end of the configuration instead.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the section was successfully moved, or false +when either the section specified by sid1 or by sid2 is not found.
+ + + + +
+ + + +
+
+

+ + remove(config, sid) +

+ + +
+ uci.js, line 296 +
+ +
+ + +
+
+ + +
+

Removes the section with the given ID from the given configuration.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + +

The name of the configuration to remove the section from.

sid + + +string + + + + + +

The ID of the section to remove.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + resolveSID(config, sid){string|null} +

+ + +
+ uci.js, line 119 +
+ +
+ + +
+
+ + +
+

Resolves a given section ID in extended notation to the internal +section ID value.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + +

The configuration to resolve the section ID for.

sid + + +string + + + + + +

The section ID to resolve. If the ID is in the form @typename[#], +it will get resolved to an internal anonymous ID in the forms +cfgXXXXXX/newXXXXXX or to the name of a section in case it points +to a named section. When the given ID is not in extended notation, +it will be returned as-is.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + string + | + + null + + + Returns the resolved section ID or the original given ID if it was +not in extended notation. Returns null when an extended ID could +not be resolved to existing section ID.
+ + + + +
+ + + +
+
+

+ + save(){Array.<string>} +

+ + +
+ uci.js, line 772 +
+ +
+ + +
+
+ + +
+

Submits all local configuration changes to the remove ubus api, +adds, removes and reorders remote sections as needed and reloads +all loaded configurations to resynchronize the local state with +the remote configuration values.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<string> + + + Returns a promise resolving to an array of configuration names which +have been reloaded by the save operation.
+ + + + +
+ + + +
+
+

+ + sections(config, type, cb){Array.<LuCI.uci.SectionObject>} +

+ + +
+ uci.js, line 384 +
+ +
+ + +
+
+ + +
+

Enumerates the sections of the given configuration, optionally +filtered by type.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + + + + + + +

The name of the configuration to enumerate the sections for.

type + + +string + + + + + + + optional + + + + + +

Enumerate only sections of the given type. If omitted, enumerate +all sections.

cb + + +LuCI.uci~sectionsFn + + + + + + + optional + + + + + +

An optional callback to invoke for each enumerated section.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<LuCI.uci.SectionObject> + + + Returns a sorted array of the section objects within the given +configuration, filtered by type of a type has been specified.
+ + + + +
+ + + +
+
+

+ + set(config, sid, option, value) +

+ + +
+ uci.js, line 516 +
+ +
+ + +
+
+ + +
+

Sets the value of the given option within the specified section +of the given configuration.

+

If either config, section or option is null, or if option begins +with a dot, the function will do nothing.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + +

The name of the configuration to set the option value in.

sid + + +string + + + + + +

The name or ID of the section to set the option value in.

option + + +string + + + + + +

The option name to set the value for.

value + + +null +| + +string +| + +Array.<string> + + + + + +

The option value to set. If the value is null or an empty string, +the option will be removed, otherwise it will be set or overwritten +with the given value.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + set_first(config, type, option, value) +

+ + +
+ uci.js, line 653 +
+ +
+ + +
+
+ + +
+

Sets the value of the given option within the first found section +of the given configuration matching the specified type or within +the first section of the entire config when no type has is specified.

+

If either config, type or option is null, or if option begins +with a dot, the function will do nothing.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + + + + + + +

The name of the configuration to set the option value in.

type + + +string + + + + + + + optional + + + + + +

The type of the first section to find. If it is null, the first +section of the entire config is written to, otherwise the first +section matching the given type is used.

option + + +string + + + + + + + + + + +

The option name to set the value for.

value + + +null +| + +string +| + +Array.<string> + + + + + + + + + + +

The option value to set. If the value is null or an empty string, +the option will be removed, otherwise it will be set or overwritten +with the given value.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + unload(config) +

+ + +
+ uci.js, line 237 +
+ +
+ + +
+
+ + +
+

Unloads the given UCI configurations from the local cache.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string +| + +Array.<string> + + + + + +

The name of the configuration or an array of configuration +names to unload.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + unset(config, sid, option) +

+ + +
+ uci.js, line 587 +
+ +
+ + +
+
+ + +
+

Remove the given option within the specified section of the given +configuration.

+

This function is a convenience wrapper around +uci.set(config, section, option, null).

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + +

The name of the configuration to remove the option from.

sid + + +string + + + + + +

The name or ID of the section to remove the option from.

option + + +string + + + + + +

The name of the option to remove.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+
+

+ + unset_first(config, type, option) +

+ + +
+ uci.js, line 683 +
+ +
+ + +
+
+ + +
+

Removes the given option within the first found section of the given +configuration matching the specified type or within the first section +of the entire config when no type has is specified.

+

This function is a convenience wrapper around +uci.set_first(config, type, option, null).

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
config + + +string + + + + + + + + + + +

The name of the configuration to set the option value in.

type + + +string + + + + + + + optional + + + + + +

The type of the first section to find. If it is null, the first +section of the entire config is written to, otherwise the first +section matching the given type is used.

option + + +string + + + + + + + + + + +

The option name to set the value for.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

LuCI.uci.ChangeRecordArray.<string>

+
+ + +
+
+ +
+

An UCI change record is a plain array containing the change operation +name as first element, the affected section ID as second argument +and an optional third and fourth argument whose meanings depend on +the operation.

+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
0 + + +string + + + +

The operation name - may be one of add, set, remove, order, +list-add, list-del or rename.

1 + + +string + + + +

The section ID targeted by the operation.

2 + + +string + + + +

The meaning of the third element depends on the operation.

+
    +
  • For add it is type of the section that has been added
  • +
  • For set it either is the option name if a fourth element exists, +or the type of a named section which has been added when the change +entry only contains three elements.
  • +
  • For remove it contains the name of the option that has been +removed.
  • +
  • For order it specifies the new sort index of the section.
  • +
  • For list-add it contains the name of the list option a new value +has been added to.
  • +
  • For list-del it contains the name of the list option a value has +been removed from.
  • +
  • For rename it contains the name of the option that has been +renamed if a fourth element exists, else it contains the new name +a section has been renamed to if the change entry only contains +three elements.
  • +
4 + + +string + + + +

The meaning of the fourth element depends on the operation.

+
    +
  • For set it is the value an option has been set to.
  • +
  • For list-add it is the new value that has been added to a +list option.
  • +
  • For rename it is the new name of an option that has been +renamed.
  • +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

LuCI.uci.SectionObjectObject.<string, (boolean|number|string|Array.<string>)>

+
+ + +
+
+ +
+

A section object represents the options and their corresponding values +enclosed within a configuration section, as well as some additional +meta data such as sort indexes and internal ID.

+

Any internal metadata fields are prefixed with a dot which is isn't +an allowed character for normal option names.

+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
.anonymous + + +boolean + + + +

The .anonymous property specifies whether the configuration is +anonymous (true) or named (false).

.index + + +number + + + +

The .index property specifes the sort order of the section.

.name + + +string + + + +

The .name property holds the name of the section object. It may be +either an anonymous ID in the form cfgXXXXXX or newXXXXXX with X +being a hexadecimal digit or a string holding the name of the section.

.type + + +string + + + +

The .type property contains the type of the corresponding uci +section.

* + + +string +| + +Array.<string> + + + +

A section object may contain an arbitrary number of further properties +representing the uci option enclosed in the section.

+

All option property names will be in the form [A-Za-z0-9_]+ and +either contain a string value or an array of strings, in case the +underlying option is an UCI list.

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+

+ + sectionsFn(section, sid) +

+ + +
+ uci.js, line 352 +
+ +
+ + +
+
+ + +
+

The sections callback is invoked for each section found within +the given configuration and receives the section object and its +associated name as arguments.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
section + + +LuCI.uci.SectionObject + + + + + +

The section object.

sid + + +string + + + + + +

The name or ID of the section.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.view.html b/docs/jsapi/LuCI.view.html new file mode 100644 index 000000000..59b34cfd8 --- /dev/null +++ b/docs/jsapi/LuCI.view.html @@ -0,0 +1,2083 @@ + + + + + Class: view + + + + + + + + + + + + + + + + + +
+ + +
+

Class: view

+ + + + +
+ +
+

+ LuCI. + + view +

+ +

The view class forms the basis of views and provides a standard +set of methods to inherit from.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.view() +

+ + +
+ luci.js, line 2687 +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + addFooter(){DocumentFragment} +

+ + +
+ luci.js, line 2905 +
+ +
+ + +
+
+ + +
+

Renders a standard page action footer if any of the +handleSave(), handleSaveApply() or handleReset() +functions are defined.

+

The default implementation should be sufficient for most +views - it will render a standard page footer with action +buttons labeled Save, Save & Apply and Reset +triggering the handleSave(), handleSaveApply() and +handleReset() functions respectively.

+

When any of these handle*() functions is overwritten +with null by a view extending this class, the +corresponding button will not be rendered.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + DocumentFragment + + + Returns a DocumentFragment containing the footer bar +with buttons for each corresponding handle*() action +or an empty DocumentFragment if all three handle*() +methods are overwritten with null.
+ + + + +
+ + + +
+
+

+ + handleReset(ev){*|Promise.<*>} +

+ + +
+ luci.js, line 2871 +
+ +
+ + +
+
+ + +
+

The handleReset function is invoked when the user clicks +the Reset button in the page action footer.

+

The default implementation should be sufficient for most +views using form.Map() based forms - it +will iterate all forms present in the view and invoke +the Map.reset() method on each form.

+

Views not using Map instances or requiring other special +logic should overwrite handleReset() with a custom +implementation.

+

To disable the Reset page footer button, views extending +this base class should overwrite the handleReset function +with null.

+

The invocation of this function is wrapped by +Promise.resolve() so it may return Promises if needed.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ev + + +Event + + + + + +

The DOM event that triggered the function.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + | + + Promise.<*> + + + Any return values of this function are discarded, but +passed through Promise.resolve() to ensure that any +returned promise runs to completion before the button +is reenabled.
+ + + + +
+ + + +
+
+

+ + handleSave(ev){*|Promise.<*>} +

+ + +
+ luci.js, line 2790 +
+ +
+ + +
+
+ + +
+

The handleSave function is invoked when the user clicks +the Save button in the page action footer.

+

The default implementation should be sufficient for most +views using form.Map() based forms - it +will iterate all forms present in the view and invoke +the Map.save() method on each form.

+

Views not using Map instances or requiring other special +logic should overwrite handleSave() with a custom +implementation.

+

To disable the Save page footer button, views extending +this base class should overwrite the handleSave function +with null.

+

The invocation of this function is wrapped by +Promise.resolve() so it may return Promises if needed.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ev + + +Event + + + + + +

The DOM event that triggered the function.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + | + + Promise.<*> + + + Any return values of this function are discarded, but +passed through Promise.resolve() to ensure that any +returned promise runs to completion before the button +is reenabled.
+ + + + +
+ + + +
+
+

+ + handleSaveApply(ev){*|Promise.<*>} +

+ + +
+ luci.js, line 2834 +
+ +
+ + +
+
+ + +
+

The handleSaveApply function is invoked when the user clicks +the Save & Apply button in the page action footer.

+

The default implementation should be sufficient for most +views using form.Map() based forms - it +will first invoke +view.handleSave() and then +call ui.changes.apply() to start the +modal config apply and page reload flow.

+

Views not using Map instances or requiring other special +logic should overwrite handleSaveApply() with a custom +implementation.

+

To disable the Save & Apply page footer button, views +extending this base class should overwrite the +handleSaveApply function with null.

+

The invocation of this function is wrapped by +Promise.resolve() so it may return Promises if needed.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ev + + +Event + + + + + +

The DOM event that triggered the function.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + | + + Promise.<*> + + + Any return values of this function are discarded, but +passed through Promise.resolve() to ensure that any +returned promise runs to completion before the button +is reenabled.
+ + + + +
+ + + +
+
+

+ + abstractload(){*|Promise.<*>} +

+ + +
+ luci.js, line 2725 +
+ +
+ + +
+
+ + +
+

The load function is invoked before the view is rendered.

+

The invocation of this function is wrapped by +Promise.resolve() so it may return Promises if needed.

+

The return value of the function (or the resolved values +of the promise returned by it) will be passed as first +argument to render().

+

This function is supposed to be overwritten by subclasses, +the default implementation does nothing.

+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + | + + Promise.<*> + + + May return any value or a Promise resolving to any value.
+ + + + +
+ + + +
+
+

+ + abstractrender(load_results){Node|Promise.<Node>} +

+ + +
+ luci.js, line 2757 +
+ +
+ + +
+
+ + +
+

The render function is invoked after the +load() function and responsible +for setting up the view contents. It must return a DOM +Node or DocumentFragment holding the contents to +insert into the view area.

+

The invocation of this function is wrapped by +Promise.resolve() so it may return Promises if needed.

+

The return value of the function (or the resolved values +of the promise returned by it) will be inserted into the +main content area using +dom.append().

+

This function is supposed to be overwritten by subclasses, +the default implementation does nothing.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
load_results + + +* +| + +null + + + + + +

This function will receive the return value of the +view.load() function as first +argument.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Node + | + + Promise.<Node> + + + Should return a DOM Node value or a Promise resolving +to a Node value.
+ + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/fonts/OpenSans-Bold-webfont.eot b/docs/jsapi/fonts/OpenSans-Bold-webfont.eot new file mode 100644 index 000000000..5d20d9163 Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-Bold-webfont.eot differ diff --git a/docs/jsapi/fonts/OpenSans-Bold-webfont.svg b/docs/jsapi/fonts/OpenSans-Bold-webfont.svg new file mode 100644 index 000000000..3ed7be4bc --- /dev/null +++ b/docs/jsapi/fonts/OpenSans-Bold-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/jsapi/fonts/OpenSans-Bold-webfont.woff b/docs/jsapi/fonts/OpenSans-Bold-webfont.woff new file mode 100644 index 000000000..1205787b0 Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-Bold-webfont.woff differ diff --git a/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.eot b/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.eot new file mode 100644 index 000000000..1f639a15f Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.eot differ diff --git a/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.svg b/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.svg new file mode 100644 index 000000000..6a2607b9d --- /dev/null +++ b/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.woff b/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.woff new file mode 100644 index 000000000..ed760c062 Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-BoldItalic-webfont.woff differ diff --git a/docs/jsapi/fonts/OpenSans-Italic-webfont.eot b/docs/jsapi/fonts/OpenSans-Italic-webfont.eot new file mode 100644 index 000000000..0c8a0ae06 Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-Italic-webfont.eot differ diff --git a/docs/jsapi/fonts/OpenSans-Italic-webfont.svg b/docs/jsapi/fonts/OpenSans-Italic-webfont.svg new file mode 100644 index 000000000..e1075dcc2 --- /dev/null +++ b/docs/jsapi/fonts/OpenSans-Italic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/jsapi/fonts/OpenSans-Italic-webfont.woff b/docs/jsapi/fonts/OpenSans-Italic-webfont.woff new file mode 100644 index 000000000..ff652e643 Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-Italic-webfont.woff differ diff --git a/docs/jsapi/fonts/OpenSans-Light-webfont.eot b/docs/jsapi/fonts/OpenSans-Light-webfont.eot new file mode 100644 index 000000000..14868406a Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-Light-webfont.eot differ diff --git a/docs/jsapi/fonts/OpenSans-Light-webfont.svg b/docs/jsapi/fonts/OpenSans-Light-webfont.svg new file mode 100644 index 000000000..11a472ca8 --- /dev/null +++ b/docs/jsapi/fonts/OpenSans-Light-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/jsapi/fonts/OpenSans-Light-webfont.woff b/docs/jsapi/fonts/OpenSans-Light-webfont.woff new file mode 100644 index 000000000..e78607481 Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-Light-webfont.woff differ diff --git a/docs/jsapi/fonts/OpenSans-LightItalic-webfont.eot b/docs/jsapi/fonts/OpenSans-LightItalic-webfont.eot new file mode 100644 index 000000000..8f445929f Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-LightItalic-webfont.eot differ diff --git a/docs/jsapi/fonts/OpenSans-LightItalic-webfont.svg b/docs/jsapi/fonts/OpenSans-LightItalic-webfont.svg new file mode 100644 index 000000000..431d7e354 --- /dev/null +++ b/docs/jsapi/fonts/OpenSans-LightItalic-webfont.svg @@ -0,0 +1,1835 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/jsapi/fonts/OpenSans-LightItalic-webfont.woff b/docs/jsapi/fonts/OpenSans-LightItalic-webfont.woff new file mode 100644 index 000000000..43e8b9e6c Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-LightItalic-webfont.woff differ diff --git a/docs/jsapi/fonts/OpenSans-Regular-webfont.eot b/docs/jsapi/fonts/OpenSans-Regular-webfont.eot new file mode 100644 index 000000000..6bbc3cf58 Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-Regular-webfont.eot differ diff --git a/docs/jsapi/fonts/OpenSans-Regular-webfont.svg b/docs/jsapi/fonts/OpenSans-Regular-webfont.svg new file mode 100644 index 000000000..25a395234 --- /dev/null +++ b/docs/jsapi/fonts/OpenSans-Regular-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/jsapi/fonts/OpenSans-Regular-webfont.woff b/docs/jsapi/fonts/OpenSans-Regular-webfont.woff new file mode 100644 index 000000000..e231183dc Binary files /dev/null and b/docs/jsapi/fonts/OpenSans-Regular-webfont.woff differ diff --git a/docs/jsapi/fs.js.html b/docs/jsapi/fs.js.html new file mode 100644 index 000000000..3ee1af8e6 --- /dev/null +++ b/docs/jsapi/fs.js.html @@ -0,0 +1,350 @@ + + + + + JSDoc: Source: fs.js + + + + + + + + + + +
+ +

Source: fs.js

+ + + + + + +
+
+
'use strict';
+'require rpc';
+
+/**
+ * @typedef {Object} FileStatEntry
+ * @memberof LuCI.fs
+
+ * @property {string} name - Name of the directory entry
+ * @property {string} type - Type of the entry, one of `block`, `char`, `directory`, `fifo`, `symlink`, `file`, `socket` or `unknown`
+ * @property {number} size - Size in bytes
+ * @property {number} mode - Access permissions
+ * @property {number} atime - Last access time in seconds since epoch
+ * @property {number} mtime - Last modification time in seconds since epoch
+ * @property {number} ctime - Last change time in seconds since epoch
+ * @property {number} inode - Inode number
+ * @property {number} uid - Numeric owner id
+ * @property {number} gid - Numeric group id
+ */
+
+/**
+ * @typedef {Object} FileExecResult
+ * @memberof LuCI.fs
+ *
+ * @property {number} code - The exit code of the invoked command
+ * @property {string} [stdout] - The stdout produced by the command, if any
+ * @property {string} [stderr] - The stderr produced by the command, if any
+ */
+
+var callFileList, callFileStat, callFileRead, callFileWrite, callFileRemove,
+    callFileExec, callFileMD5;
+
+callFileList = rpc.declare({
+	object: 'file',
+	method: 'list',
+	params: [ 'path' ]
+});
+
+callFileStat = rpc.declare({
+	object: 'file',
+	method: 'stat',
+	params: [ 'path' ]
+});
+
+callFileRead = rpc.declare({
+	object: 'file',
+	method: 'read',
+	params: [ 'path' ]
+});
+
+callFileWrite = rpc.declare({
+	object: 'file',
+	method: 'write',
+	params: [ 'path', 'data', 'mode' ]
+});
+
+callFileRemove = rpc.declare({
+	object: 'file',
+	method: 'remove',
+	params: [ 'path' ]
+});
+
+callFileExec = rpc.declare({
+	object: 'file',
+	method: 'exec',
+	params: [ 'command', 'params', 'env' ]
+});
+
+callFileMD5 = rpc.declare({
+	object: 'file',
+	method: 'md5',
+	params: [ 'path' ]
+});
+
+var rpcErrors = [
+	null,
+	'InvalidCommandError',
+	'InvalidArgumentError',
+	'MethodNotFoundError',
+	'NotFoundError',
+	'NoDataError',
+	'PermissionError',
+	'TimeoutError',
+	'UnsupportedError'
+];
+
+function handleRpcReply(expect, rc) {
+	if (typeof(rc) == 'number' && rc != 0) {
+		var e = new Error(rpc.getStatusText(rc)); e.name = rpcErrors[rc] || 'Error';
+		throw e;
+	}
+
+	if (expect) {
+		var type = Object.prototype.toString;
+
+		for (var key in expect) {
+			if (rc != null && key != '')
+				rc = rc[key];
+
+			if (rc == null || type.call(rc) != type.call(expect[key])) {
+				var e = new Error(_('Unexpected reply data format')); e.name = 'TypeError';
+				throw e;
+			}
+
+			break;
+		}
+	}
+
+	return rc;
+}
+
+/**
+ * @class fs
+ * @memberof LuCI
+ * @hideconstructor
+ * @classdesc
+ *
+ * Provides high level utilities to wrap file system related RPC calls.
+ * To import the class in views, use `'require fs'`, to import it in
+ * external JavaScript, use `L.require("fs").then(...)`.
+ */
+var FileSystem = L.Class.extend(/** @lends LuCI.fs.prototype */ {
+	/**
+	 * Obtains a listing of the specified directory.
+	 *
+	 * @param {string} path
+	 * The directory path to list.
+	 *
+	 * @returns {Promise<LuCI.fs.FileStatEntry[]>}
+	 * Returns a promise resolving to an array of stat detail objects or
+	 * rejecting with an error stating the failure reason.
+	 */
+	list: function(path) {
+		return callFileList(path).then(handleRpcReply.bind(this, { entries: [] }));
+	},
+
+	/**
+	 * Return file stat information on the specified path.
+	 *
+	 * @param {string} path
+	 * The filesystem path to stat.
+	 *
+	 * @returns {Promise<LuCI.fs.FileStatEntry>}
+	 * Returns a promise resolving to a stat detail object or
+	 * rejecting with an error stating the failure reason.
+	 */
+	stat: function(path) {
+		return callFileStat(path).then(handleRpcReply.bind(this, { '': {} }));
+	},
+
+	/**
+	 * Read the contents of the given file and return them.
+	 * Note: this function is unsuitable for obtaining binary data.
+	 *
+	 * @param {string} path
+	 * The file path to read.
+	 *
+	 * @returns {Promise<string>}
+	 * Returns a promise resolving to a string containing the file contents or
+	 * rejecting with an error stating the failure reason.
+	 */
+	read: function(path) {
+		return callFileRead(path).then(handleRpcReply.bind(this, { data: '' }));
+	},
+
+	/**
+	 * Write the given data to the specified file path.
+	 * If the specified file path does not exist, it will be created, given
+	 * sufficient permissions.
+	 *
+	 * Note: `data` will be converted to a string using `String(data)` or to
+	 * `''` when it is `null`.
+	 *
+	 * @param {string} path
+	 * The file path to write to.
+	 *
+	 * @param {*} [data]
+	 * The file data to write. If it is null, it will be set to an empty
+	 * string.
+	 *
+	 * @param {number} [mode]
+	 * The permissions to use on file creation. Default is 420 (0644).
+	 *
+	 * @returns {Promise<number>}
+	 * Returns a promise resolving to `0` or rejecting with an error stating
+	 * the failure reason.
+	 */
+	write: function(path, data, mode) {
+		data = (data != null) ? String(data) : '';
+		mode = (mode != null) ? mode : 420; // 0644
+		return callFileWrite(path, data, mode).then(handleRpcReply.bind(this, { '': 0 }));
+	},
+
+	/**
+	 * Unlink the given file.
+	 *
+	 * @param {string}
+	 * The file path to remove.
+	 *
+	 * @returns {Promise<number>}
+	 * Returns a promise resolving to `0` or rejecting with an error stating
+	 * the failure reason.
+	 */
+	remove: function(path) {
+		return callFileRemove(path).then(handleRpcReply.bind(this, { '': 0 }));
+	},
+
+	/**
+	 * Execute the specified command, optionally passing params and
+	 * environment variables.
+	 *
+	 * Note: The `command` must be either the path to an executable,
+	 * or a basename without arguments in which case it will be searched
+	 * in $PATH. If specified, the values given in `params` will be passed
+	 * as arguments to the command.
+	 *
+	 * The key/value pairs in the optional `env` table are translated to
+	 * `setenv()` calls prior to running the command.
+	 *
+	 * @param {string} command
+	 * The command to invoke.
+	 *
+	 * @param {string[]} [params]
+	 * The arguments to pass to the command.
+	 *
+	 * @param {Object.<string, string>} [env]
+	 * Environment variables to set.
+	 *
+	 * @returns {Promise<LuCI.fs.FileExecResult>}
+	 * Returns a promise resolving to an object describing the execution
+	 * results or rejecting with an error stating the failure reason.
+	 */
+	exec: function(command, params, env) {
+		if (!Array.isArray(params))
+			params = null;
+
+		if (!L.isObject(env))
+			env = null;
+
+		return callFileExec(command, params, env).then(handleRpcReply.bind(this, { '': {} }));
+	},
+
+	/**
+	 * Read the contents of the given file, trim leading and trailing white
+	 * space and return the trimmed result. In case of errors, return an empty
+	 * string instead.
+	 *
+	 * Note: this function is useful to read single-value files in `/sys`
+	 * or `/proc`.
+	 *
+	 * This function is guaranteed to not reject its promises, on failure,
+	 * an empty string will be returned.
+	 *
+	 * @param {string} path
+	 * The file path to read.
+	 *
+	 * @returns {Promise<string>}
+	 * Returns a promise resolving to the file contents or the empty string
+	 * on failure.
+	 */
+	trimmed: function(path) {
+		return L.resolveDefault(this.read(path), '').then(function(s) {
+			return s.trim();
+		});
+	},
+
+	/**
+	 * Read the contents of the given file, split it into lines, trim
+	 * leading and trailing white space of each line and return the
+	 * resulting array.
+	 *
+	 * This function is guaranteed to not reject its promises, on failure,
+	 * an empty array will be returned.
+	 *
+	 * @param {string} path
+	 * The file path to read.
+	 *
+	 * @returns {Promise<string[]>}
+	 * Returns a promise resolving to an array containing the stripped lines
+	 * of the given file or `[]` on failure.
+	 */
+	lines: function(path) {
+		return L.resolveDefault(this.read(path), '').then(function(s) {
+			var lines = [];
+
+			s = s.trim();
+
+			if (s != '') {
+				var l = s.split(/\n/);
+
+				for (var i = 0; i < l.length; i++)
+					lines.push(l[i].trim());
+			}
+
+			return lines;
+		});
+	}
+});
+
+return FileSystem;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 09:33:05 GMT+0100 (Central European Standard Time) +
+ + + + + diff --git a/docs/jsapi/index.html b/docs/jsapi/index.html new file mode 100644 index 000000000..550ed9bc8 --- /dev/null +++ b/docs/jsapi/index.html @@ -0,0 +1,1131 @@ + + + + + Index + + + + + + + + + + + + + + + + + +
+ + +
+

Index

+ + + + + + +

+ + + + + + + + + + + + + +
+

OpenWrt luci feed

+

Translation status

+

Description

+

This is the OpenWrt "luci"-feed containing LuCI - OpenWrt Configuration Interface.

+

Usage

+

This feed is enabled by default. Your feeds.conf.default (or feeds.conf) should contain a line like:

+
src-git luci https://github.com/openwrt/luci.git
+
+

To install all its package definitions, run:

+
./scripts/feeds update luci
+./scripts/feeds install -a -p luci
+
+

API Reference

+

You can browse the generated API documentation directly on Github.

+ +

Development

+

Documentation for developing and extending LuCI can be found in the Wiki

+

License

+

See LICENSE file.

+

Package Guidelines

+

See CONTRIBUTING.md file.

+

Translation status

+

Translation status

+
+ + + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 10:17:12 GMT+0100 (Central European Standard Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/luci.js.html b/docs/jsapi/luci.js.html new file mode 100644 index 000000000..7cad32ce5 --- /dev/null +++ b/docs/jsapi/luci.js.html @@ -0,0 +1,3125 @@ + + + + + JSDoc: Source: luci.js + + + + + + + + + + +
+ +

Source: luci.js

+ + + + + + +
+
+
/**
+ * @class LuCI
+ * @classdesc
+ *
+ * This is the LuCI base class. It is automatically instantiated and
+ * accessible using the global `L` variable.
+ *
+ * @param {Object} env
+ * The environment settings to use for the LuCI runtime.
+ */
+
+(function(window, document, undefined) {
+	'use strict';
+
+	/* Object.assign polyfill for IE */
+	if (typeof Object.assign !== 'function') {
+		Object.defineProperty(Object, 'assign', {
+			value: function assign(target, varArgs) {
+				if (target == null)
+					throw new TypeError('Cannot convert undefined or null to object');
+
+				var to = Object(target);
+
+				for (var index = 1; index < arguments.length; index++)
+					if (arguments[index] != null)
+						for (var nextKey in arguments[index])
+							if (Object.prototype.hasOwnProperty.call(arguments[index], nextKey))
+								to[nextKey] = arguments[index][nextKey];
+
+				return to;
+			},
+			writable: true,
+			configurable: true
+		});
+	}
+
+	/* Promise.finally polyfill */
+	if (typeof Promise.prototype.finally !== 'function') {
+		Promise.prototype.finally = function(fn) {
+			var onFinally = function(cb) {
+				return Promise.resolve(fn.call(this)).then(cb);
+			};
+
+			return this.then(
+				function(result) { return onFinally.call(this, function() { return result }) },
+				function(reason) { return onFinally.call(this, function() { return Promise.reject(reason) }) }
+			);
+		};
+	}
+
+	/*
+	 * Class declaration and inheritance helper
+	 */
+
+	var toCamelCase = function(s) {
+		return s.replace(/(?:^|[\. -])(.)/g, function(m0, m1) { return m1.toUpperCase() });
+	};
+
+	/**
+	 * @class Class
+	 * @hideconstructor
+	 * @memberof LuCI
+	 * @classdesc
+	 *
+	 * `LuCI.Class` is the abstract base class all LuCI classes inherit from.
+	 *
+	 * It provides simple means to create subclasses of given classes and
+	 * implements prototypal inheritance.
+	 */
+	var superContext = null, Class = Object.assign(function() {}, {
+		/**
+		 * Extends this base class with the properties described in
+		 * `properties` and returns a new subclassed Class instance
+		 *
+		 * @memberof LuCI.Class
+		 *
+		 * @param {Object<string, *>} properties
+		 * An object describing the properties to add to the new
+		 * subclass.
+		 *
+		 * @returns {LuCI.Class}
+		 * Returns a new LuCI.Class sublassed from this class, extended
+		 * by the given properties and with its prototype set to this base
+		 * class to enable inheritance. The resulting value represents a
+		 * class constructor and can be instantiated with `new`.
+		 */
+		extend: function(properties) {
+			var props = {
+				__base__: { value: this.prototype },
+				__name__: { value: properties.__name__ || 'anonymous' }
+			};
+
+			var ClassConstructor = function() {
+				if (!(this instanceof ClassConstructor))
+					throw new TypeError('Constructor must not be called without "new"');
+
+				if (Object.getPrototypeOf(this).hasOwnProperty('__init__')) {
+					if (typeof(this.__init__) != 'function')
+						throw new TypeError('Class __init__ member is not a function');
+
+					this.__init__.apply(this, arguments)
+				}
+				else {
+					this.super('__init__', arguments);
+				}
+			};
+
+			for (var key in properties)
+				if (!props[key] && properties.hasOwnProperty(key))
+					props[key] = { value: properties[key], writable: true };
+
+			ClassConstructor.prototype = Object.create(this.prototype, props);
+			ClassConstructor.prototype.constructor = ClassConstructor;
+			Object.assign(ClassConstructor, this);
+			ClassConstructor.displayName = toCamelCase(props.__name__.value + 'Class');
+
+			return ClassConstructor;
+		},
+
+		/**
+		 * Extends this base class with the properties described in
+		 * `properties`, instantiates the resulting subclass using
+		 * the additional optional arguments passed to this function
+		 * and returns the resulting subclassed Class instance.
+		 *
+		 * This function serves as a convenience shortcut for
+		 * {@link LuCI.Class.extend Class.extend()} and subsequent
+		 * `new`.
+		 *
+		 * @memberof LuCI.Class
+		 *
+		 * @param {Object<string, *>} properties
+		 * An object describing the properties to add to the new
+		 * subclass.
+		 *
+		 * @param {...*} [new_args]
+		 * Specifies arguments to be passed to the subclass constructor
+		 * as-is in order to instantiate the new subclass.
+		 *
+		 * @returns {LuCI.Class}
+		 * Returns a new LuCI.Class instance extended by the given
+		 * properties with its prototype set to this base class to
+		 * enable inheritance.
+		 */
+		singleton: function(properties /*, ... */) {
+			return Class.extend(properties)
+				.instantiate(Class.prototype.varargs(arguments, 1));
+		},
+
+		/**
+		 * Calls the class constructor using `new` with the given argument
+		 * array being passed as variadic parameters to the constructor.
+		 *
+		 * @memberof LuCI.Class
+		 *
+		 * @param {Array<*>} params
+		 * An array of arbitrary values which will be passed as arguments
+		 * to the constructor function.
+		 *
+		 * @param {...*} [new_args]
+		 * Specifies arguments to be passed to the subclass constructor
+		 * as-is in order to instantiate the new subclass.
+		 *
+		 * @returns {LuCI.Class}
+		 * Returns a new LuCI.Class instance extended by the given
+		 * properties with its prototype set to this base class to
+		 * enable inheritance.
+		 */
+		instantiate: function(args) {
+			return new (Function.prototype.bind.apply(this,
+				Class.prototype.varargs(args, 0, null)))();
+		},
+
+		/* unused */
+		call: function(self, method) {
+			if (typeof(this.prototype[method]) != 'function')
+				throw new ReferenceError(method + ' is not defined in class');
+
+			return this.prototype[method].apply(self, self.varargs(arguments, 1));
+		},
+
+		/**
+		 * Checks whether the given class value is a subclass of this class.
+		 *
+		 * @memberof LuCI.Class
+		 *
+		 * @param {LuCI.Class} classValue
+		 * The class object to test.
+		 *
+		 * @returns {boolean}
+		 * Returns `true` when the given `classValue` is a subclass of this
+		 * class or `false` if the given value is not a valid class or not
+		 * a subclass of this class'.
+		 */
+		isSubclass: function(classValue) {
+			return (classValue != null &&
+			        typeof(classValue) == 'function' &&
+			        classValue.prototype instanceof this);
+		},
+
+		prototype: {
+			/**
+			 * Extract all values from the given argument array beginning from
+			 * `offset` and prepend any further given optional parameters to
+			 * the beginning of the resulting array copy.
+			 *
+			 * @memberof LuCI.Class
+			 * @instance
+			 *
+			 * @param {Array<*>} args
+			 * The array to extract the values from.
+			 *
+			 * @param {number} offset
+			 * The offset from which to extract the values. An offset of `0`
+			 * would copy all values till the end.
+			 *
+			 * @param {...*} [extra_args]
+			 * Extra arguments to add to prepend to the resultung array.
+			 *
+			 * @returns {Array<*>}
+			 * Returns a new array consisting of the optional extra arguments
+			 * and the values extracted from the `args` array beginning with
+			 * `offset`.
+			 */
+			varargs: function(args, offset /*, ... */) {
+				return Array.prototype.slice.call(arguments, 2)
+					.concat(Array.prototype.slice.call(args, offset));
+			},
+
+			/**
+			 * Walks up the parent class chain and looks for a class member
+			 * called `key` in any of the parent classes this class inherits
+			 * from. Returns the member value of the superclass or calls the
+			 * member as function and returns its return value when the
+			 * optional `callArgs` array is given.
+			 *
+			 * This function has two signatures and is sensitive to the
+			 * amount of arguments passed to it:
+			 *  - `super('key')` -
+			 *    Returns the value of `key` when found within one of the
+			 *    parent classes.
+			 *  - `super('key', ['arg1', 'arg2'])` -
+			 *    Calls the `key()` method with parameters `arg1` and `arg2`
+			 *    when found within one of the parent classes.
+			 *
+			 * @memberof LuCI.Class
+			 * @instance
+			 *
+			 * @param {string} key
+			 * The name of the superclass member to retrieve.
+			 *
+			 * @param {Array<*>} [callArgs]
+			 * An optional array of function call parameters to use. When
+			 * this parameter is specified, the found member value is called
+			 * as function using the values of this array as arguments.
+			 *
+			 * @throws {ReferenceError}
+			 * Throws a `ReferenceError` when `callArgs` are specified and
+			 * the found member named by `key` is not a function value.
+			 *
+			 * @returns {*|null}
+			 * Returns the value of the found member or the return value of
+			 * the call to the found method. Returns `null` when no member
+			 * was found in the parent class chain or when the call to the
+			 * superclass method returned `null`.
+			 */
+			super: function(key, callArgs) {
+				for (superContext = Object.getPrototypeOf(superContext ||
+				                                          Object.getPrototypeOf(this));
+				     superContext && !superContext.hasOwnProperty(key);
+				     superContext = Object.getPrototypeOf(superContext)) { }
+
+				if (!superContext)
+					return null;
+
+				var res = superContext[key];
+
+				if (arguments.length > 1) {
+					if (typeof(res) != 'function')
+						throw new ReferenceError(key + ' is not a function in base class');
+
+					if (typeof(callArgs) != 'object')
+						callArgs = this.varargs(arguments, 1);
+
+					res = res.apply(this, callArgs);
+				}
+
+				superContext = null;
+
+				return res;
+			},
+
+			/**
+			 * Returns a string representation of this class.
+			 *
+			 * @returns {string}
+			 * Returns a string representation of this class containing the
+			 * constructor functions `displayName` and describing the class
+			 * members and their respective types.
+			 */
+			toString: function() {
+				var s = '[' + this.constructor.displayName + ']', f = true;
+				for (var k in this) {
+					if (this.hasOwnProperty(k)) {
+						s += (f ? ' {\n' : '') + '  ' + k + ': ' + typeof(this[k]) + '\n';
+						f = false;
+					}
+				}
+				return s + (f ? '' : '}');
+			}
+		}
+	});
+
+
+	/**
+	 * @class
+	 * @memberof LuCI
+	 * @hideconstructor
+	 * @classdesc
+	 *
+	 * The `Headers` class is an internal utility class exposed in HTTP
+	 * response objects using the `response.headers` property.
+	 */
+	var Headers = Class.extend(/** @lends LuCI.Headers.prototype */ {
+		__name__: 'LuCI.XHR.Headers',
+		__init__: function(xhr) {
+			var hdrs = this.headers = {};
+			xhr.getAllResponseHeaders().split(/\r\n/).forEach(function(line) {
+				var m = /^([^:]+):(.*)$/.exec(line);
+				if (m != null)
+					hdrs[m[1].trim().toLowerCase()] = m[2].trim();
+			});
+		},
+
+		/**
+		 * Checks whether the given header name is present.
+		 * Note: Header-Names are case-insensitive.
+		 *
+		 * @instance
+		 * @memberof LuCI.Headers
+		 * @param {string} name
+		 * The header name to check
+		 *
+		 * @returns {boolean}
+		 * Returns `true` if the header name is present, `false` otherwise
+		 */
+		has: function(name) {
+			return this.headers.hasOwnProperty(String(name).toLowerCase());
+		},
+
+		/**
+		 * Returns the value of the given header name.
+		 * Note: Header-Names are case-insensitive.
+		 *
+		 * @instance
+		 * @memberof LuCI.Headers
+		 * @param {string} name
+		 * The header name to read
+		 *
+		 * @returns {string|null}
+		 * The value of the given header name or `null` if the header isn't present.
+		 */
+		get: function(name) {
+			var key = String(name).toLowerCase();
+			return this.headers.hasOwnProperty(key) ? this.headers[key] : null;
+		}
+	});
+
+	/**
+	 * @class
+	 * @memberof LuCI
+	 * @hideconstructor
+	 * @classdesc
+	 *
+	 * The `Response` class is an internal utility class representing HTTP responses.
+	 */
+	var Response = Class.extend({
+		__name__: 'LuCI.XHR.Response',
+		__init__: function(xhr, url, duration, headers, content) {
+			/**
+			 * Describes whether the response is successful (status codes `200..299`) or not
+			 * @instance
+			 * @memberof LuCI.Response
+			 * @name ok
+			 * @type {boolean}
+			 */
+			this.ok = (xhr.status >= 200 && xhr.status <= 299);
+
+			/**
+			 * The numeric HTTP status code of the response
+			 * @instance
+			 * @memberof LuCI.Response
+			 * @name status
+			 * @type {number}
+			 */
+			this.status = xhr.status;
+
+			/**
+			 * The HTTP status description message of the response
+			 * @instance
+			 * @memberof LuCI.Response
+			 * @name statusText
+			 * @type {string}
+			 */
+			this.statusText = xhr.statusText;
+
+			/**
+			 * The HTTP headers of the response
+			 * @instance
+			 * @memberof LuCI.Response
+			 * @name headers
+			 * @type {LuCI.Headers}
+			 */
+			this.headers = (headers != null) ? headers : new Headers(xhr);
+
+			/**
+			 * The total duration of the HTTP request in milliseconds
+			 * @instance
+			 * @memberof LuCI.Response
+			 * @name duration
+			 * @type {number}
+			 */
+			this.duration = duration;
+
+			/**
+			 * The final URL of the request, i.e. after following redirects.
+			 * @instance
+			 * @memberof LuCI.Response
+			 * @name url
+			 * @type {string}
+			 */
+			this.url = url;
+
+			/* privates */
+			this.xhr = xhr;
+
+			if (content != null && typeof(content) == 'object') {
+				this.responseJSON = content;
+				this.responseText = null;
+			}
+			else if (content != null) {
+				this.responseJSON = null;
+				this.responseText = String(content);
+			}
+			else {
+				this.responseJSON = null;
+				this.responseText = xhr.responseText;
+			}
+		},
+
+		/**
+		 * Clones the given response object, optionally overriding the content
+		 * of the cloned instance.
+		 *
+		 * @instance
+		 * @memberof LuCI.Response
+		 * @param {*} [content]
+		 * Override the content of the cloned response. Object values will be
+		 * treated as JSON response data, all other types will be converted
+		 * using `String()` and treated as response text.
+		 *
+		 * @returns {LuCI.Response}
+		 * The cloned `Response` instance.
+		 */
+		clone: function(content) {
+			var copy = new Response(this.xhr, this.url, this.duration, this.headers, content);
+
+			copy.ok = this.ok;
+			copy.status = this.status;
+			copy.statusText = this.statusText;
+
+			return copy;
+		},
+
+		/**
+		 * Access the response content as JSON data.
+		 *
+		 * @instance
+		 * @memberof LuCI.Response
+		 * @throws {SyntaxError}
+		 * Throws `SyntaxError` if the content isn't valid JSON.
+		 *
+		 * @returns {*}
+		 * The parsed JSON data.
+		 */
+		json: function() {
+			if (this.responseJSON == null)
+				this.responseJSON = JSON.parse(this.responseText);
+
+			return this.responseJSON;
+		},
+
+		/**
+		 * Access the response content as string.
+		 *
+		 * @instance
+		 * @memberof LuCI.Response
+		 * @returns {string}
+		 * The response content.
+		 */
+		text: function() {
+			if (this.responseText == null && this.responseJSON != null)
+				this.responseText = JSON.stringify(this.responseJSON);
+
+			return this.responseText;
+		}
+	});
+
+
+	var requestQueue = [];
+
+	function isQueueableRequest(opt) {
+		if (!classes.rpc)
+			return false;
+
+		if (opt.method != 'POST' || typeof(opt.content) != 'object')
+			return false;
+
+		if (opt.nobatch === true)
+			return false;
+
+		var rpcBaseURL = Request.expandURL(classes.rpc.getBaseURL());
+
+		return (rpcBaseURL != null && opt.url.indexOf(rpcBaseURL) == 0);
+	}
+
+	function flushRequestQueue() {
+		if (!requestQueue.length)
+			return;
+
+		var reqopt = Object.assign({}, requestQueue[0][0], { content: [], nobatch: true }),
+		    batch = [];
+
+		for (var i = 0; i < requestQueue.length; i++) {
+			batch[i] = requestQueue[i];
+			reqopt.content[i] = batch[i][0].content;
+		}
+
+		requestQueue.length = 0;
+
+		Request.request(rpcBaseURL, reqopt).then(function(reply) {
+			var json = null, req = null;
+
+			try { json = reply.json() }
+			catch(e) { }
+
+			while ((req = batch.shift()) != null)
+				if (Array.isArray(json) && json.length)
+					req[2].call(reqopt, reply.clone(json.shift()));
+				else
+					req[1].call(reqopt, new Error('No related RPC reply'));
+		}).catch(function(error) {
+			var req = null;
+
+			while ((req = batch.shift()) != null)
+				req[1].call(reqopt, error);
+		});
+	}
+
+	/**
+	 * @class
+	 * @memberof LuCI
+	 * @hideconstructor
+	 * @classdesc
+	 *
+	 * The `Request` class allows initiating HTTP requests and provides utilities
+	 * for dealing with responses.
+	 */
+	var Request = Class.singleton(/** @lends LuCI.Request.prototype */ {
+		__name__: 'LuCI.Request',
+
+		interceptors: [],
+
+		/**
+		 * Turn the given relative URL into an absolute URL if necessary.
+		 *
+		 * @instance
+		 * @memberof LuCI.Request
+		 * @param {string} url
+		 * The URL to convert.
+		 *
+		 * @returns {string}
+		 * The absolute URL derived from the given one, or the original URL
+		 * if it already was absolute.
+		 */
+		expandURL: function(url) {
+			if (!/^(?:[^/]+:)?\/\//.test(url))
+				url = location.protocol + '//' + location.host + url;
+
+			return url;
+		},
+
+		/**
+		 * @typedef {Object} RequestOptions
+		 * @memberof LuCI.Request
+		 *
+		 * @property {string} [method=GET]
+		 * The HTTP method to use, e.g. `GET` or `POST`.
+		 *
+		 * @property {Object<string, Object|string>} [query]
+		 * Query string data to append to the URL. Non-string values of the
+		 * given object will be converted to JSON.
+		 *
+		 * @property {boolean} [cache=false]
+		 * Specifies whether the HTTP response may be retrieved from cache.
+		 *
+		 * @property {string} [username]
+		 * Provides a username for HTTP basic authentication.
+		 *
+		 * @property {string} [password]
+		 * Provides a password for HTTP basic authentication.
+		 *
+		 * @property {number} [timeout]
+		 * Specifies the request timeout in seconds.
+		 *
+		 * @property {boolean} [credentials=false]
+		 * Whether to include credentials such as cookies in the request.
+		 *
+		 * @property {*} [content]
+		 * Specifies the HTTP message body to send along with the request.
+		 * If the value is a function, it is invoked and the return value
+		 * used as content, if it is a FormData instance, it is used as-is,
+		 * if it is an object, it will be converted to JSON, in all other
+		 * cases it is converted to a string.
+		 *
+	     * @property {Object<string, string>} [header]
+	     * Specifies HTTP headers to set for the request.
+	     *
+	     * @property {function} [progress]
+	     * An optional request callback function which receives ProgressEvent
+	     * instances as sole argument during the HTTP request transfer.
+		 */
+
+		/**
+		 * Initiate an HTTP request to the given target.
+		 *
+		 * @instance
+		 * @memberof LuCI.Request
+		 * @param {string} target
+		 * The URL to request.
+		 *
+		 * @param {LuCI.Request.RequestOptions} [options]
+		 * Additional options to configure the request.
+		 *
+		 * @returns {Promise<LuCI.Response>}
+		 * The resulting HTTP response.
+		 */
+		request: function(target, options) {
+			var state = { xhr: new XMLHttpRequest(), url: this.expandURL(target), start: Date.now() },
+			    opt = Object.assign({}, options, state),
+			    content = null,
+			    contenttype = null,
+			    callback = this.handleReadyStateChange;
+
+			return new Promise(function(resolveFn, rejectFn) {
+				opt.xhr.onreadystatechange = callback.bind(opt, resolveFn, rejectFn);
+				opt.method = String(opt.method || 'GET').toUpperCase();
+
+				if ('query' in opt) {
+					var q = (opt.query != null) ? Object.keys(opt.query).map(function(k) {
+						if (opt.query[k] != null) {
+							var v = (typeof(opt.query[k]) == 'object')
+								? JSON.stringify(opt.query[k])
+								: String(opt.query[k]);
+
+							return '%s=%s'.format(encodeURIComponent(k), encodeURIComponent(v));
+						}
+						else {
+							return encodeURIComponent(k);
+						}
+					}).join('&') : '';
+
+					if (q !== '') {
+						switch (opt.method) {
+						case 'GET':
+						case 'HEAD':
+						case 'OPTIONS':
+							opt.url += ((/\?/).test(opt.url) ? '&' : '?') + q;
+							break;
+
+						default:
+							if (content == null) {
+								content = q;
+								contenttype = 'application/x-www-form-urlencoded';
+							}
+						}
+					}
+				}
+
+				if (!opt.cache)
+					opt.url += ((/\?/).test(opt.url) ? '&' : '?') + (new Date()).getTime();
+
+				if (isQueueableRequest(opt)) {
+					requestQueue.push([opt, rejectFn, resolveFn]);
+					requestAnimationFrame(flushRequestQueue);
+					return;
+				}
+
+				if ('username' in opt && 'password' in opt)
+					opt.xhr.open(opt.method, opt.url, true, opt.username, opt.password);
+				else
+					opt.xhr.open(opt.method, opt.url, true);
+
+				opt.xhr.responseType = 'text';
+
+				if ('overrideMimeType' in opt.xhr)
+					opt.xhr.overrideMimeType('application/octet-stream');
+
+				if ('timeout' in opt)
+					opt.xhr.timeout = +opt.timeout;
+
+				if ('credentials' in opt)
+					opt.xhr.withCredentials = !!opt.credentials;
+
+				if (opt.content != null) {
+					switch (typeof(opt.content)) {
+					case 'function':
+						content = opt.content(xhr);
+						break;
+
+					case 'object':
+						if (!(opt.content instanceof FormData)) {
+							content = JSON.stringify(opt.content);
+							contenttype = 'application/json';
+						}
+						else {
+							content = opt.content;
+						}
+						break;
+
+					default:
+						content = String(opt.content);
+					}
+				}
+
+				if ('headers' in opt)
+					for (var header in opt.headers)
+						if (opt.headers.hasOwnProperty(header)) {
+							if (header.toLowerCase() != 'content-type')
+								opt.xhr.setRequestHeader(header, opt.headers[header]);
+							else
+								contenttype = opt.headers[header];
+						}
+
+				if ('progress' in opt && 'upload' in opt.xhr)
+					opt.xhr.upload.addEventListener('progress', opt.progress);
+
+				if (contenttype != null)
+					opt.xhr.setRequestHeader('Content-Type', contenttype);
+
+				try {
+					opt.xhr.send(content);
+				}
+				catch (e) {
+					rejectFn.call(opt, e);
+				}
+			});
+		},
+
+		handleReadyStateChange: function(resolveFn, rejectFn, ev) {
+			var xhr = this.xhr,
+			    duration = Date.now() - this.start;
+
+			if (xhr.readyState !== 4)
+				return;
+
+			if (xhr.status === 0 && xhr.statusText === '') {
+				if (duration >= this.timeout)
+					rejectFn.call(this, new Error('XHR request timed out'));
+				else
+					rejectFn.call(this, new Error('XHR request aborted by browser'));
+			}
+			else {
+				var response = new Response(
+					xhr, xhr.responseURL || this.url, duration);
+
+				Promise.all(Request.interceptors.map(function(fn) { return fn(response) }))
+					.then(resolveFn.bind(this, response))
+					.catch(rejectFn.bind(this));
+			}
+		},
+
+		/**
+		 * Initiate an HTTP GET request to the given target.
+		 *
+		 * @instance
+		 * @memberof LuCI.Request
+		 * @param {string} target
+		 * The URL to request.
+		 *
+		 * @param {LuCI.Request.RequestOptions} [options]
+		 * Additional options to configure the request.
+		 *
+		 * @returns {Promise<LuCI.Response>}
+		 * The resulting HTTP response.
+		 */
+		get: function(url, options) {
+			return this.request(url, Object.assign({ method: 'GET' }, options));
+		},
+
+		/**
+		 * Initiate an HTTP POST request to the given target.
+		 *
+		 * @instance
+		 * @memberof LuCI.Request
+		 * @param {string} target
+		 * The URL to request.
+		 *
+		 * @param {*} [data]
+		 * The request data to send, see {@link LuCI.Request.RequestOptions} for details.
+		 *
+		 * @param {LuCI.Request.RequestOptions} [options]
+		 * Additional options to configure the request.
+		 *
+		 * @returns {Promise<LuCI.Response>}
+		 * The resulting HTTP response.
+		 */
+		post: function(url, data, options) {
+			return this.request(url, Object.assign({ method: 'POST', content: data }, options));
+		},
+
+		/**
+		 * Interceptor functions are invoked whenever an HTTP reply is received, in the order
+		 * these functions have been registered.
+		 * @callback LuCI.Request.interceptorFn
+		 * @param {LuCI.Response} res
+		 * The HTTP response object
+		 */
+
+		/**
+		 * Register an HTTP response interceptor function. Interceptor
+		 * functions are useful to perform default actions on incoming HTTP
+		 * responses, such as checking for expired authentication or for
+		 * implementing request retries before returning a failure.
+		 *
+		 * @instance
+		 * @memberof LuCI.Request
+		 * @param {LuCI.Request.interceptorFn} interceptorFn
+		 * The interceptor function to register.
+		 *
+		 * @returns {LuCI.Request.interceptorFn}
+		 * The registered function.
+		 */
+		addInterceptor: function(interceptorFn) {
+			if (typeof(interceptorFn) == 'function')
+				this.interceptors.push(interceptorFn);
+			return interceptorFn;
+		},
+
+		/**
+		 * Remove an HTTP response interceptor function. The passed function
+		 * value must be the very same value that was used to register the
+		 * function.
+		 *
+		 * @instance
+		 * @memberof LuCI.Request
+		 * @param {LuCI.Request.interceptorFn} interceptorFn
+		 * The interceptor function to remove.
+		 *
+		 * @returns {boolean}
+		 * Returns `true` if any function has been removed, else `false`.
+		 */
+		removeInterceptor: function(interceptorFn) {
+			var oldlen = this.interceptors.length, i = oldlen;
+			while (i--)
+				if (this.interceptors[i] === interceptorFn)
+					this.interceptors.splice(i, 1);
+			return (this.interceptors.length < oldlen);
+		},
+
+		/**
+		 * @class
+		 * @memberof LuCI.Request
+		 * @hideconstructor
+		 * @classdesc
+		 *
+		 * The `Request.poll` class provides some convience wrappers around
+		 * {@link LuCI.Poll} mainly to simplify registering repeating HTTP
+		 * request calls as polling functions.
+		 */
+		poll: {
+			/**
+			 * The callback function is invoked whenever an HTTP reply to a
+			 * polled request is received or when the polled request timed
+			 * out.
+			 *
+			 * @callback LuCI.Request.poll~callbackFn
+			 * @param {LuCI.Response} res
+			 * The HTTP response object.
+			 *
+			 * @param {*} data
+			 * The response JSON if the response could be parsed as such,
+			 * else `null`.
+			 *
+			 * @param {number} duration
+			 * The total duration of the request in milliseconds.
+			 */
+
+			/**
+			 * Register a repeating HTTP request with an optional callback
+			 * to invoke whenever a response for the request is received.
+			 *
+			 * @instance
+			 * @memberof LuCI.Request.poll
+			 * @param {number} interval
+			 * The poll interval in seconds.
+			 *
+			 * @param {string} url
+			 * The URL to request on each poll.
+			 *
+			 * @param {LuCI.Request.RequestOptions} [options]
+			 * Additional options to configure the request.
+			 *
+			 * @param {LuCI.Request.poll~callbackFn} [callback]
+			 * {@link LuCI.Request.poll~callbackFn Callback} function to
+			 * invoke for each HTTP reply.
+			 *
+			 * @throws {TypeError}
+			 * Throws `TypeError` when an invalid interval was passed.
+			 *
+			 * @returns {function}
+			 * Returns the internally created poll function.
+			 */
+			add: function(interval, url, options, callback) {
+				if (isNaN(interval) || interval <= 0)
+					throw new TypeError('Invalid poll interval');
+
+				var ival = interval >>> 0,
+				    opts = Object.assign({}, options, { timeout: ival * 1000 - 5 });
+
+				var fn = function() {
+					return Request.request(url, options).then(function(res) {
+						if (!Poll.active())
+							return;
+
+						try {
+							callback(res, res.json(), res.duration);
+						}
+						catch (err) {
+							callback(res, null, res.duration);
+						}
+					});
+				};
+
+				return (Poll.add(fn, ival) ? fn : null);
+			},
+
+			/**
+			 * Remove a polling request that has been previously added using `add()`.
+			 * This function is essentially a wrapper around
+			 * {@link LuCI.Poll.remove LuCI.Poll.remove()}.
+			 *
+			 * @instance
+			 * @memberof LuCI.Request.poll
+			 * @param {function} entry
+			 * The poll function returned by {@link LuCI.Request.poll#add add()}.
+			 *
+			 * @returns {boolean}
+			 * Returns `true` if any function has been removed, else `false`.
+			 */
+			remove: function(entry) { return Poll.remove(entry) },
+
+			/**
+			  * Alias for {@link LuCI.Poll.start LuCI.Poll.start()}.
+			  *
+			  * @instance
+			  * @memberof LuCI.Request.poll
+			  */
+			start: function() { return Poll.start() },
+
+			/**
+			  * Alias for {@link LuCI.Poll.stop LuCI.Poll.stop()}.
+			  *
+			  * @instance
+			  * @memberof LuCI.Request.poll
+			  */
+			stop: function() { return Poll.stop() },
+
+			/**
+			  * Alias for {@link LuCI.Poll.active LuCI.Poll.active()}.
+			  *
+			  * @instance
+			  * @memberof LuCI.Request.poll
+			  */
+			active: function() { return Poll.active() }
+		}
+	});
+
+	/**
+	 * @class
+	 * @memberof LuCI
+	 * @hideconstructor
+	 * @classdesc
+	 *
+	 * The `Poll` class allows registering and unregistering poll actions,
+	 * as well as starting, stopping and querying the state of the polling
+	 * loop.
+	 */
+	var Poll = Class.singleton(/** @lends LuCI.Poll.prototype */ {
+		__name__: 'LuCI.Poll',
+
+		queue: [],
+
+		/**
+		 * Add a new operation to the polling loop. If the polling loop is not
+		 * already started at this point, it will be implicitely started.
+		 *
+		 * @instance
+		 * @memberof LuCI.Poll
+		 * @param {function} fn
+		 * The function to invoke on each poll interval.
+		 *
+		 * @param {number} interval
+		 * The poll interval in seconds.
+		 *
+		 * @throws {TypeError}
+		 * Throws `TypeError` when an invalid interval was passed.
+		 *
+		 * @returns {boolean}
+		 * Returns `true` if the function has been added or `false` if it
+		 * already is registered.
+		 */
+		add: function(fn, interval) {
+			if (interval == null || interval <= 0)
+				interval = window.L ? window.L.env.pollinterval : null;
+
+			if (isNaN(interval) || typeof(fn) != 'function')
+				throw new TypeError('Invalid argument to LuCI.Poll.add()');
+
+			for (var i = 0; i < this.queue.length; i++)
+				if (this.queue[i].fn === fn)
+					return false;
+
+			var e = {
+				r: true,
+				i: interval >>> 0,
+				fn: fn
+			};
+
+			this.queue.push(e);
+
+			if (this.tick != null && !this.active())
+				this.start();
+
+			return true;
+		},
+
+		/**
+		 * Remove an operation from the polling loop. If no further operatons
+		 * are registered, the polling loop is implicitely stopped.
+		 *
+		 * @instance
+		 * @memberof LuCI.Poll
+		 * @param {function} fn
+		 * The function to remove.
+		 *
+		 * @throws {TypeError}
+		 * Throws `TypeError` when the given argument isn't a function.
+		 *
+		 * @returns {boolean}
+		 * Returns `true` if the function has been removed or `false` if it
+		 * wasn't found.
+		 */
+		remove: function(fn) {
+			if (typeof(fn) != 'function')
+				throw new TypeError('Invalid argument to LuCI.Poll.remove()');
+
+			var len = this.queue.length;
+
+			for (var i = len; i > 0; i--)
+				if (this.queue[i-1].fn === fn)
+					this.queue.splice(i-1, 1);
+
+			if (!this.queue.length && this.stop())
+				this.tick = 0;
+
+			return (this.queue.length != len);
+		},
+
+		/**
+		 * (Re)start the polling loop. Dispatches a custom `poll-start` event
+		 * to the `document` object upon successful start.
+		 *
+		 * @instance
+		 * @memberof LuCI.Poll
+		 * @returns {boolean}
+		 * Returns `true` if polling has been started (or if no functions
+		 * where registered) or `false` when the polling loop already runs.
+		 */
+		start: function() {
+			if (this.active())
+				return false;
+
+			this.tick = 0;
+
+			if (this.queue.length) {
+				this.timer = window.setInterval(this.step, 1000);
+				this.step();
+				document.dispatchEvent(new CustomEvent('poll-start'));
+			}
+
+			return true;
+		},
+
+		/**
+		 * Stop the polling loop. Dispatches a custom `poll-stop` event
+		 * to the `document` object upon successful stop.
+		 *
+		 * @instance
+		 * @memberof LuCI.Poll
+		 * @returns {boolean}
+		 * Returns `true` if polling has been stopped or `false` if it din't
+		 * run to begin with.
+		 */
+		stop: function() {
+			if (!this.active())
+				return false;
+
+			document.dispatchEvent(new CustomEvent('poll-stop'));
+			window.clearInterval(this.timer);
+			delete this.timer;
+			delete this.tick;
+			return true;
+		},
+
+		/* private */
+		step: function() {
+			for (var i = 0, e = null; (e = Poll.queue[i]) != null; i++) {
+				if ((Poll.tick % e.i) != 0)
+					continue;
+
+				if (!e.r)
+					continue;
+
+				e.r = false;
+
+				Promise.resolve(e.fn()).finally((function() { this.r = true }).bind(e));
+			}
+
+			Poll.tick = (Poll.tick + 1) % Math.pow(2, 32);
+		},
+
+		/**
+		 * Test whether the polling loop is running.
+		 *
+		 * @instance
+		 * @memberof LuCI.Poll
+		 * @returns {boolean} - Returns `true` if polling is active, else `false`.
+		 */
+		active: function() {
+			return (this.timer != null);
+		}
+	});
+
+
+	var dummyElem = null,
+	    domParser = null,
+	    originalCBIInit = null,
+	    rpcBaseURL = null,
+	    sysFeatures = null,
+	    classes = {};
+
+	var LuCI = Class.extend(/** @lends LuCI.prototype */ {
+		__name__: 'LuCI',
+		__init__: function(env) {
+
+			document.querySelectorAll('script[src*="/luci.js"]').forEach(function(s) {
+				if (env.base_url == null || env.base_url == '') {
+					var m = (s.getAttribute('src') || '').match(/^(.*)\/luci\.js(?:\?v=([^?]+))?$/);
+					if (m) {
+						env.base_url = m[1];
+						env.resource_version = m[2];
+					}
+				}
+			});
+
+			if (env.base_url == null)
+				this.error('InternalError', 'Cannot find url of luci.js');
+
+			Object.assign(this.env, env);
+
+			document.addEventListener('poll-start', function(ev) {
+				document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) {
+					e.style.display = (e.id == 'xhr_poll_status_off') ? 'none' : '';
+				});
+			});
+
+			document.addEventListener('poll-stop', function(ev) {
+				document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) {
+					e.style.display = (e.id == 'xhr_poll_status_on') ? 'none' : '';
+				});
+			});
+
+			var domReady = new Promise(function(resolveFn, rejectFn) {
+				document.addEventListener('DOMContentLoaded', resolveFn);
+			});
+
+			Promise.all([
+				domReady,
+				this.require('ui'),
+				this.require('rpc'),
+				this.require('form'),
+				this.probeRPCBaseURL()
+			]).then(this.setupDOM.bind(this)).catch(this.error);
+
+			originalCBIInit = window.cbi_init;
+			window.cbi_init = function() {};
+		},
+
+		/**
+		 * Captures the current stack trace and throws an error of the
+		 * specified type as a new exception. Also logs the exception as
+		 * error to the debug console if it is available.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {Error|string} [type=Error]
+		 * Either a string specifying the type of the error to throw or an
+		 * existing `Error` instance to copy.
+		 *
+		 * @param {string} [fmt=Unspecified error]
+		 * A format string which is used to form the error message, together
+		 * with all subsequent optional arguments.
+		 *
+		 * @param {...*} [args]
+		 * Zero or more variable arguments to the supplied format string.
+		 *
+		 * @throws {Error}
+		 * Throws the created error object with the captured stack trace
+		 * appended to the message and the type set to the given type
+		 * argument or copied from the given error instance.
+		 */
+		raise: function(type, fmt /*, ...*/) {
+			var e = null,
+			    msg = fmt ? String.prototype.format.apply(fmt, this.varargs(arguments, 2)) : null,
+			    stack = null;
+
+			if (type instanceof Error) {
+				e = type;
+
+				if (msg)
+					e.message = msg + ': ' + e.message;
+			}
+			else {
+				try { throw new Error('stacktrace') }
+				catch (e2) { stack = (e2.stack || '').split(/\n/) }
+
+				e = new (window[type || 'Error'] || Error)(msg || 'Unspecified error');
+				e.name = type || 'Error';
+			}
+
+			stack = (stack || []).map(function(frame) {
+				frame = frame.replace(/(.*?)@(.+):(\d+):(\d+)/g, 'at $1 ($2:$3:$4)').trim();
+				return frame ? '  ' + frame : '';
+			});
+
+			if (!/^  at /.test(stack[0]))
+				stack.shift();
+
+			if (/\braise /.test(stack[0]))
+				stack.shift();
+
+			if (/\berror /.test(stack[0]))
+				stack.shift();
+
+			if (stack.length)
+				e.message += '\n' + stack.join('\n');
+
+			if (window.console && console.debug)
+				console.debug(e);
+
+			throw e;
+		},
+
+		/**
+		 * A wrapper around {@link LuCI#raise raise()} which also renders
+		 * the error either as modal overlay when `ui.js` is already loaed
+		 * or directly into the view body.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {Error|string} [type=Error]
+		 * Either a string specifying the type of the error to throw or an
+		 * existing `Error` instance to copy.
+		 *
+		 * @param {string} [fmt=Unspecified error]
+		 * A format string which is used to form the error message, together
+		 * with all subsequent optional arguments.
+		 *
+		 * @param {...*} [args]
+		 * Zero or more variable arguments to the supplied format string.
+		 *
+		 * @throws {Error}
+		 * Throws the created error object with the captured stack trace
+		 * appended to the message and the type set to the given type
+		 * argument or copied from the given error instance.
+		 */
+		error: function(type, fmt /*, ...*/) {
+			try {
+				L.raise.apply(L, Array.prototype.slice.call(arguments));
+			}
+			catch (e) {
+				if (!e.reported) {
+					if (L.ui)
+						L.ui.addNotification(e.name || _('Runtime error'),
+							E('pre', {}, e.message), 'danger');
+					else
+						L.dom.content(document.querySelector('#maincontent'),
+							E('pre', { 'class': 'alert-message error' }, e.message));
+
+					e.reported = true;
+				}
+
+				throw e;
+			}
+		},
+
+		/**
+		 * Return a bound function using the given `self` as `this` context
+		 * and any further arguments as parameters to the bound function.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {function} fn
+		 * The function to bind.
+		 *
+		 * @param {*} self
+		 * The value to bind as `this` context to the specified function.
+		 *
+		 * @param {...*} [args]
+		 * Zero or more variable arguments which are bound to the function
+		 * as parameters.
+		 *
+		 * @returns {function}
+		 * Returns the bound function.
+		 */
+		bind: function(fn, self /*, ... */) {
+			return Function.prototype.bind.apply(fn, this.varargs(arguments, 2, self));
+		},
+
+		/**
+		 * Load an additional LuCI JavaScript class and its dependencies,
+		 * instantiate it and return the resulting class instance. Each
+		 * class is only loaded once. Subsequent attempts to load the same
+		 * class will return the already instantiated class.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {string} name
+		 * The name of the class to load in dotted notation. Dots will
+		 * be replaced by spaces and joined with the runtime-determined
+		 * base URL of LuCI.js to form an absolute URL to load the class
+		 * file from.
+		 *
+		 * @throws {DependencyError}
+		 * Throws a `DependencyError` when the class to load includes
+		 * circular dependencies.
+		 *
+		 * @throws {NetworkError}
+		 * Throws `NetworkError` when the underlying {@link LuCI.Request}
+		 * call failed.
+		 *
+		 * @throws {SyntaxError}
+		 * Throws `SyntaxError` when the loaded class file code cannot
+		 * be interpreted by `eval`.
+		 *
+		 * @throws {TypeError}
+		 * Throws `TypeError` when the class file could be loaded and
+		 * interpreted, but when invoking its code did not yield a valid
+		 * class instance.
+		 *
+		 * @returns {Promise<LuCI#Class>}
+		 * Returns the instantiated class.
+		 */
+		require: function(name, from) {
+			var L = this, url = null, from = from || [];
+
+			/* Class already loaded */
+			if (classes[name] != null) {
+				/* Circular dependency */
+				if (from.indexOf(name) != -1)
+					L.raise('DependencyError',
+						'Circular dependency: class "%s" depends on "%s"',
+						name, from.join('" which depends on "'));
+
+				return Promise.resolve(classes[name]);
+			}
+
+			url = '%s/%s.js%s'.format(L.env.base_url, name.replace(/\./g, '/'), (L.env.resource_version ? '?v=' + L.env.resource_version : ''));
+			from = [ name ].concat(from);
+
+			var compileClass = function(res) {
+				if (!res.ok)
+					L.raise('NetworkError',
+						'HTTP error %d while loading class file "%s"', res.status, url);
+
+				var source = res.text(),
+				    requirematch = /^require[ \t]+(\S+)(?:[ \t]+as[ \t]+([a-zA-Z_]\S*))?$/,
+				    strictmatch = /^use[ \t]+strict$/,
+				    depends = [],
+				    args = '';
+
+				/* find require statements in source */
+				for (var i = 0, off = -1, quote = -1, esc = false; i < source.length; i++) {
+					var chr = source.charCodeAt(i);
+
+					if (esc) {
+						esc = false;
+					}
+					else if (chr == 92) {
+						esc = true;
+					}
+					else if (chr == quote) {
+						var s = source.substring(off, i),
+						    m = requirematch.exec(s);
+
+						if (m) {
+							var dep = m[1], as = m[2] || dep.replace(/[^a-zA-Z0-9_]/g, '_');
+							depends.push(L.require(dep, from));
+							args += ', ' + as;
+						}
+						else if (!strictmatch.exec(s)) {
+							break;
+						}
+
+						off = -1;
+						quote = -1;
+					}
+					else if (quote == -1 && (chr == 34 || chr == 39)) {
+						off = i + 1;
+						quote = chr;
+					}
+				}
+
+				/* load dependencies and instantiate class */
+				return Promise.all(depends).then(function(instances) {
+					var _factory, _class;
+
+					try {
+						_factory = eval(
+							'(function(window, document, L%s) { %s })\n\n//# sourceURL=%s\n'
+								.format(args, source, res.url));
+					}
+					catch (error) {
+						L.raise('SyntaxError', '%s\n  in %s:%s',
+							error.message, res.url, error.lineNumber || '?');
+					}
+
+					_factory.displayName = toCamelCase(name + 'ClassFactory');
+					_class = _factory.apply(_factory, [window, document, L].concat(instances));
+
+					if (!Class.isSubclass(_class))
+					    L.error('TypeError', '"%s" factory yields invalid constructor', name);
+
+					if (_class.displayName == 'AnonymousClass')
+						_class.displayName = toCamelCase(name + 'Class');
+
+					var ptr = Object.getPrototypeOf(L),
+					    parts = name.split(/\./),
+					    instance = new _class();
+
+					for (var i = 0; ptr && i < parts.length - 1; i++)
+						ptr = ptr[parts[i]];
+
+					if (ptr)
+						ptr[parts[i]] = instance;
+
+					classes[name] = instance;
+
+					return instance;
+				});
+			};
+
+			/* Request class file */
+			classes[name] = Request.get(url, { cache: true }).then(compileClass);
+
+			return classes[name];
+		},
+
+		/* DOM setup */
+		probeRPCBaseURL: function() {
+			if (rpcBaseURL == null) {
+				try {
+					rpcBaseURL = window.sessionStorage.getItem('rpcBaseURL');
+				}
+				catch (e) { }
+			}
+
+			if (rpcBaseURL == null) {
+				var rpcFallbackURL = this.url('admin/ubus');
+
+				rpcBaseURL = Request.get('/ubus/').then(function(res) {
+					return (rpcBaseURL = (res.status == 400) ? '/ubus/' : rpcFallbackURL);
+				}, function() {
+					return (rpcBaseURL = rpcFallbackURL);
+				}).then(function(url) {
+					try {
+						window.sessionStorage.setItem('rpcBaseURL', url);
+					}
+					catch (e) { }
+
+					return url;
+				});
+			}
+
+			return Promise.resolve(rpcBaseURL);
+		},
+
+		probeSystemFeatures: function() {
+			var sessionid = classes.rpc.getSessionID();
+
+			if (sysFeatures == null) {
+				try {
+					var data = JSON.parse(window.sessionStorage.getItem('sysFeatures'));
+
+					if (this.isObject(data) && this.isObject(data[sessionid]))
+						sysFeatures = data[sessionid];
+				}
+				catch (e) {}
+			}
+
+			if (!this.isObject(sysFeatures)) {
+				sysFeatures = classes.rpc.declare({
+					object: 'luci',
+					method: 'getFeatures',
+					expect: { '': {} }
+				})().then(function(features) {
+					try {
+						var data = {};
+						    data[sessionid] = features;
+
+						window.sessionStorage.setItem('sysFeatures', JSON.stringify(data));
+					}
+					catch (e) {}
+
+					sysFeatures = features;
+
+					return features;
+				});
+			}
+
+			return Promise.resolve(sysFeatures);
+		},
+
+		/**
+		 * Test whether a particular system feature is available, such as
+		 * hostapd SAE support or an installed firewall. The features are
+		 * queried once at the beginning of the LuCI session and cached in
+		 * `SessionStorage` throughout the lifetime of the associated tab or
+		 * browser window.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {string} feature
+		 * The feature to test. For detailed list of known feature flags,
+		 * see `/modules/luci-base/root/usr/libexec/rpcd/luci`.
+		 *
+		 * @param {string} [subfeature]
+		 * Some feature classes like `hostapd` provide sub-feature flags,
+		 * such as `sae` or `11w` support. The `subfeature` argument can
+		 * be used to query these.
+		 *
+		 * @return {boolean|null}
+		 * Return `true` if the queried feature (and sub-feature) is available
+		 * or `false` if the requested feature isn't present or known.
+		 * Return `null` when a sub-feature was queried for a feature which
+		 * has no sub-features.
+		 */
+		hasSystemFeature: function() {
+			var ft = sysFeatures[arguments[0]];
+
+			if (arguments.length == 2)
+				return this.isObject(ft) ? ft[arguments[1]] : null;
+
+			return (ft != null && ft != false);
+		},
+
+		/* private */
+		notifySessionExpiry: function() {
+			Poll.stop();
+
+			L.ui.showModal(_('Session expired'), [
+				E('div', { class: 'alert-message warning' },
+					_('A new login is required since the authentication session expired.')),
+				E('div', { class: 'right' },
+					E('div', {
+						class: 'btn primary',
+						click: function() {
+							var loc = window.location;
+							window.location = loc.protocol + '//' + loc.host + loc.pathname + loc.search;
+						}
+					}, _('To login…')))
+			]);
+
+			L.raise('SessionError', 'Login session is expired');
+		},
+
+		/* private */
+		setupDOM: function(res) {
+			var domEv = res[0],
+			    uiClass = res[1],
+			    rpcClass = res[2],
+			    formClass = res[3],
+			    rpcBaseURL = res[4];
+
+			rpcClass.setBaseURL(rpcBaseURL);
+
+			rpcClass.addInterceptor(function(msg, req) {
+				if (!L.isObject(msg) || !L.isObject(msg.error) || msg.error.code != -32002)
+					return;
+
+				if (!L.isObject(req) || (req.object == 'session' && req.method == 'access'))
+					return;
+
+				return rpcClass.declare({
+					'object': 'session',
+					'method': 'access',
+					'params': [ 'scope', 'object', 'function' ],
+					'expect': { access: true }
+				})('uci', 'luci', 'read').catch(L.notifySessionExpiry);
+			});
+
+			Request.addInterceptor(function(res) {
+				var isDenied = false;
+
+				if (res.status == 403 && res.headers.get('X-LuCI-Login-Required') == 'yes')
+					isDenied = true;
+
+				if (!isDenied)
+					return;
+
+				L.notifySessionExpiry();
+			});
+
+			return this.probeSystemFeatures().finally(this.initDOM);
+		},
+
+		/* private */
+		initDOM: function() {
+			originalCBIInit();
+			Poll.start();
+			document.dispatchEvent(new CustomEvent('luci-loaded'));
+		},
+
+		/**
+		 * The `env` object holds environment settings used by LuCI, such
+		 * as request timeouts, base URLs etc.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 */
+		env: {},
+
+		/**
+		 * Construct a relative URL path from the given prefix and parts.
+		 * The resulting URL is guaranteed to only contain the characters
+		 * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
+		 * as `/` for the path separator.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {string} [prefix]
+		 * The prefix to join the given parts with. If the `prefix` is
+		 * omitted, it defaults to an empty string.
+		 *
+		 * @param {string[]} [parts]
+		 * An array of parts to join into an URL path. Parts may contain
+		 * slashes and any of the other characters mentioned above.
+		 *
+		 * @return {string}
+		 * Return the joined URL path.
+		 */
+		path: function(prefix, parts) {
+			var url = [ prefix || '' ];
+
+			for (var i = 0; i < parts.length; i++)
+				if (/^(?:[a-zA-Z0-9_.%,;-]+\/)*[a-zA-Z0-9_.%,;-]+$/.test(parts[i]))
+					url.push('/', parts[i]);
+
+			if (url.length === 1)
+				url.push('/');
+
+			return url.join('');
+		},
+
+		/**
+		 * Construct an URL  pathrelative to the script path of the server
+		 * side LuCI application (usually `/cgi-bin/luci`).
+		 *
+		 * The resulting URL is guaranteed to only contain the characters
+		 * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
+		 * as `/` for the path separator.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {string[]} [parts]
+		 * An array of parts to join into an URL path. Parts may contain
+		 * slashes and any of the other characters mentioned above.
+		 *
+		 * @return {string}
+		 * Returns the resulting URL path.
+		 */
+		url: function() {
+			return this.path(this.env.scriptname, arguments);
+		},
+
+		/**
+		 * Construct an URL path relative to the global static resource path
+		 * of the LuCI ui (usually `/luci-static/resources`).
+		 *
+		 * The resulting URL is guaranteed to only contain the characters
+		 * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
+		 * as `/` for the path separator.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {string[]} [parts]
+		 * An array of parts to join into an URL path. Parts may contain
+		 * slashes and any of the other characters mentioned above.
+		 *
+		 * @return {string}
+		 * Returns the resulting URL path.
+		 */
+		resource: function() {
+			return this.path(this.env.resource, arguments);
+		},
+
+		/**
+		 * Return the complete URL path to the current view.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @return {string}
+		 * Returns the URL path to the current view.
+		 */
+		location: function() {
+			return this.path(this.env.scriptname, this.env.requestpath);
+		},
+
+
+		/**
+		 * Tests whether the passed argument is a JavaScript object.
+		 * This function is meant to be an object counterpart to the
+		 * standard `Array.isArray()` function.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {*} [val]
+		 * The value to test
+		 *
+		 * @return {boolean}
+		 * Returns `true` if the given value is of type object and
+		 * not `null`, else returns `false`.
+		 */
+		isObject: function(val) {
+			return (val != null && typeof(val) == 'object');
+		},
+
+		/**
+		 * Return an array of sorted object keys, optionally sorted by
+		 * a different key or a different sorting mode.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {object} obj
+		 * The object to extract the keys from. If the given value is
+		 * not an object, the function will return an empty array.
+		 *
+		 * @param {string} [key]
+		 * Specifies the key to order by. This is mainly useful for
+		 * nested objects of objects or objects of arrays when sorting
+		 * shall not be performed by the primary object keys but by
+		 * some other key pointing to a value within the nested values.
+		 *
+		 * @param {string} [sortmode]
+		 * May be either `addr` or `num` to override the natural
+		 * lexicographic sorting with a sorting suitable for IP/MAC style
+		 * addresses or numeric values respectively.
+		 *
+		 * @return {string[]}
+		 * Returns an array containing the sorted keys of the given object.
+		 */
+		sortedKeys: function(obj, key, sortmode) {
+			if (obj == null || typeof(obj) != 'object')
+				return [];
+
+			return Object.keys(obj).map(function(e) {
+				var v = (key != null) ? obj[e][key] : e;
+
+				switch (sortmode) {
+				case 'addr':
+					v = (v != null) ? v.replace(/(?:^|[.:])([0-9a-fA-F]{1,4})/g,
+						function(m0, m1) { return ('000' + m1.toLowerCase()).substr(-4) }) : null;
+					break;
+
+				case 'num':
+					v = (v != null) ? +v : null;
+					break;
+				}
+
+				return [ e, v ];
+			}).filter(function(e) {
+				return (e[1] != null);
+			}).sort(function(a, b) {
+				return (a[1] > b[1]);
+			}).map(function(e) {
+				return e[0];
+			});
+		},
+
+		/**
+		 * Converts the given value to an array. If the given value is of
+		 * type array, it is returned as-is, values of type object are
+		 * returned as one-element array containing the object, empty
+		 * strings and `null` values are returned as empty array, all other
+		 * values are converted using `String()`, trimmed, split on white
+		 * space and returned as array.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {*} val
+		 * The value to convert into an array.
+		 *
+		 * @return {Array<*>}
+		 * Returns the resulting array.
+		 */
+		toArray: function(val) {
+			if (val == null)
+				return [];
+			else if (Array.isArray(val))
+				return val;
+			else if (typeof(val) == 'object')
+				return [ val ];
+
+			var s = String(val).trim();
+
+			if (s == '')
+				return [];
+
+			return s.split(/\s+/);
+		},
+
+		/**
+		 * Returns a promise resolving with either the given value or or with
+		 * the given default in case the input value is a rejecting promise.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {*} value
+		 * The value to resolve the promise with.
+		 *
+		 * @param {*} defvalue
+		 * The default value to resolve the promise with in case the given
+		 * input value is a rejecting promise.
+		 *
+		 * @returns {Promise<*>}
+		 * Returns a new promise resolving either to the given input value or
+		 * to the given default value on error.
+		 */
+		resolveDefault: function(value, defvalue) {
+			return Promise.resolve(value).catch(function() { return defvalue });
+		},
+
+		/**
+		 * The request callback function is invoked whenever an HTTP
+		 * reply to a request made using the `L.get()`, `L.post()` or
+		 * `L.poll()` function is timed out or received successfully.
+		 *
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @callback LuCI.requestCallbackFn
+		 * @param {XMLHTTPRequest} xhr
+		 * The XMLHTTPRequest instance used to make the request.
+		 *
+		 * @param {*} data
+		 * The response JSON if the response could be parsed as such,
+		 * else `null`.
+		 *
+		 * @param {number} duration
+		 * The total duration of the request in milliseconds.
+		 */
+
+		/**
+		 * Issues a GET request to the given url and invokes the specified
+		 * callback function. The function is a wrapper around
+		 * {@link LuCI.Request#request Request.request()}.
+		 *
+		 * @deprecated
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {string} url
+		 * The URL to request.
+		 *
+		 * @param {Object<string, string>} [args]
+		 * Additional query string arguments to append to the URL.
+		 *
+		 * @param {LuCI.requestCallbackFn} cb
+		 * The callback function to invoke when the request finishes.
+		 *
+		 * @return {Promise<null>}
+		 * Returns a promise resolving to `null` when concluded.
+		 */
+		get: function(url, args, cb) {
+			return this.poll(null, url, args, cb, false);
+		},
+
+		/**
+		 * Issues a POST request to the given url and invokes the specified
+		 * callback function. The function is a wrapper around
+		 * {@link LuCI.Request#request Request.request()}. The request is
+		 * sent using `application/x-www-form-urlencoded` encoding and will
+		 * contain a field `token` with the current value of `LuCI.env.token`
+		 * by default.
+		 *
+		 * @deprecated
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {string} url
+		 * The URL to request.
+		 *
+		 * @param {Object<string, string>} [args]
+		 * Additional post arguments to append to the request body.
+		 *
+		 * @param {LuCI.requestCallbackFn} cb
+		 * The callback function to invoke when the request finishes.
+		 *
+		 * @return {Promise<null>}
+		 * Returns a promise resolving to `null` when concluded.
+		 */
+		post: function(url, args, cb) {
+			return this.poll(null, url, args, cb, true);
+		},
+
+		/**
+		 * Register a polling HTTP request that invokes the specified
+		 * callback function. The function is a wrapper around
+		 * {@link LuCI.Request.poll#add Request.poll.add()}.
+		 *
+		 * @deprecated
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {number} interval
+		 * The poll interval to use. If set to a value less than or equal
+		 * to `0`, it will default to the global poll interval configured
+		 * in `LuCI.env.pollinterval`.
+		 *
+		 * @param {string} url
+		 * The URL to request.
+		 *
+		 * @param {Object<string, string>} [args]
+		 * Specifies additional arguments for the request. For GET requests,
+		 * the arguments are appended to the URL as query string, for POST
+		 * requests, they'll be added to the request body.
+		 *
+		 * @param {LuCI.requestCallbackFn} cb
+		 * The callback function to invoke whenever a request finishes.
+		 *
+		 * @param {boolean} [post=false]
+		 * When set to `false` or not specified, poll requests will be made
+		 * using the GET method. When set to `true`, POST requests will be
+		 * issued. In case of POST requests, the request body will contain
+		 * an argument `token` with the current value of `LuCI.env.token` by
+		 * default, regardless of the parameters specified with `args`.
+		 *
+		 * @return {function}
+		 * Returns the internally created function that has been passed to
+		 * {@link LuCI.Request.poll#add Request.poll.add()}. This value can
+		 * be passed to {@link LuCI.Poll.remove Poll.remove()} to remove the
+		 * polling request.
+		 */
+		poll: function(interval, url, args, cb, post) {
+			if (interval !== null && interval <= 0)
+				interval = this.env.pollinterval;
+
+			var data = post ? { token: this.env.token } : null,
+			    method = post ? 'POST' : 'GET';
+
+			if (!/^(?:\/|\S+:\/\/)/.test(url))
+				url = this.url(url);
+
+			if (args != null)
+				data = Object.assign(data || {}, args);
+
+			if (interval !== null)
+				return Request.poll.add(interval, url, { method: method, query: data }, cb);
+			else
+				return Request.request(url, { method: method, query: data })
+					.then(function(res) {
+						var json = null;
+						if (/^application\/json\b/.test(res.headers.get('Content-Type')))
+							try { json = res.json() } catch(e) {}
+						cb(res.xhr, json, res.duration);
+					});
+		},
+
+		/**
+		 * Deprecated wrapper around {@link LuCI.Poll.remove Poll.remove()}.
+		 *
+		 * @deprecated
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @param {function} entry
+		 * The polling function to remove.
+		 *
+		 * @return {boolean}
+		 * Returns `true` when the function has been removed or `false` if
+		 * it could not be found.
+		 */
+		stop: function(entry) { return Poll.remove(entry) },
+
+		/**
+		 * Deprecated wrapper around {@link LuCI.Poll.stop Poll.stop()}.
+		 *
+		 * @deprecated
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @return {boolean}
+		 * Returns `true` when the polling loop has been stopped or `false`
+		 * when it didn't run to begin with.
+		 */
+		halt: function() { return Poll.stop() },
+
+		/**
+		 * Deprecated wrapper around {@link LuCI.Poll.start Poll.start()}.
+		 *
+		 * @deprecated
+		 * @instance
+		 * @memberof LuCI
+		 *
+		 * @return {boolean}
+		 * Returns `true` when the polling loop has been started or `false`
+		 * when it was already running.
+		 */
+		run: function() { return Poll.start() },
+
+
+		/**
+		 * @class
+		 * @memberof LuCI
+		 * @hideconstructor
+		 * @classdesc
+		 *
+		 * The `dom` class provides convenience method for creating and
+		 * manipulating DOM elements.
+		 */
+		dom: Class.singleton(/* @lends LuCI.dom.prototype */ {
+			__name__: 'LuCI.DOM',
+
+			/**
+			 * Tests whether the given argument is a valid DOM `Node`.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {*} e
+			 * The value to test.
+			 *
+			 * @returns {boolean}
+			 * Returns `true` if the value is a DOM `Node`, else `false`.
+			 */
+			elem: function(e) {
+				return (e != null && typeof(e) == 'object' && 'nodeType' in e);
+			},
+
+			/**
+			 * Parses a given string as HTML and returns the first child node.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {string} s
+			 * A string containing an HTML fragment to parse. Note that only
+			 * the first result of the resulting structure is returned, so an
+			 * input value of `<div>foo</div> <div>bar</div>` will only return
+			 * the first `div` element node.
+			 *
+			 * @returns {Node}
+			 * Returns the first DOM `Node` extracted from the HTML fragment or
+			 * `null` on parsing failures or if no element could be found.
+			 */
+			parse: function(s) {
+				var elem;
+
+				try {
+					domParser = domParser || new DOMParser();
+					elem = domParser.parseFromString(s, 'text/html').body.firstChild;
+				}
+				catch(e) {}
+
+				if (!elem) {
+					try {
+						dummyElem = dummyElem || document.createElement('div');
+						dummyElem.innerHTML = s;
+						elem = dummyElem.firstChild;
+					}
+					catch (e) {}
+				}
+
+				return elem || null;
+			},
+
+			/**
+			 * Tests whether a given `Node` matches the given query selector.
+			 *
+			 * This function is a convenience wrapper around the standard
+			 * `Node.matches("selector")` function with the added benefit that
+			 * the `node` argument may be a non-`Node` value, in which case
+			 * this function simply returns `false`.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {*} node
+			 * The `Node` argument to test the selector against.
+			 *
+			 * @param {string} [selector]
+			 * The query selector expression to test against the given node.
+			 *
+			 * @returns {boolean}
+			 * Returns `true` if the given node matches the specified selector
+			 * or `false` when the node argument is no valid DOM `Node` or the
+			 * selector didn't match.
+			 */
+			matches: function(node, selector) {
+				var m = this.elem(node) ? node.matches || node.msMatchesSelector : null;
+				return m ? m.call(node, selector) : false;
+			},
+
+			/**
+			 * Returns the closest parent node that matches the given query
+			 * selector expression.
+			 *
+			 * This function is a convenience wrapper around the standard
+			 * `Node.closest("selector")` function with the added benefit that
+			 * the `node` argument may be a non-`Node` value, in which case
+			 * this function simply returns `null`.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {*} node
+			 * The `Node` argument to find the closest parent for.
+			 *
+			 * @param {string} [selector]
+			 * The query selector expression to test against each parent.
+			 *
+			 * @returns {Node|null}
+			 * Returns the closest parent node matching the selector or
+			 * `null` when the node argument is no valid DOM `Node` or the
+			 * selector didn't match any parent.
+			 */
+			parent: function(node, selector) {
+				if (this.elem(node) && node.closest)
+					return node.closest(selector);
+
+				while (this.elem(node))
+					if (this.matches(node, selector))
+						return node;
+					else
+						node = node.parentNode;
+
+				return null;
+			},
+
+			/**
+			 * Appends the given children data to the given node.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {*} node
+			 * The `Node` argument to append the children to.
+			 *
+			 * @param {*} [children]
+			 * The childrens to append to the given node.
+			 *
+			 * When `children` is an array, then each item of the array
+			 * will be either appended as child element or text node,
+			 * depending on whether the item is a DOM `Node` instance or
+			 * some other non-`null` value. Non-`Node`, non-`null` values
+			 * will be converted to strings first before being passed as
+			 * argument to `createTextNode()`.
+			 *
+			 * When `children` is a function, it will be invoked with
+			 * the passed `node` argument as sole parameter and the `append`
+			 * function will be invoked again, with the given `node` argument
+			 * as first and the return value of the `children` function as
+			 * second parameter.
+			 *
+			 * When `children` is is a DOM `Node` instance, it will be
+			 * appended to the given `node`.
+			 *
+			 * When `children` is any other non-`null` value, it will be
+			 * converted to a string and appened to the `innerHTML` property
+			 * of the given `node`.
+			 *
+			 * @returns {Node|null}
+			 * Returns the last children `Node` appended to the node or `null`
+			 * if either the `node` argument was no valid DOM `node` or if the
+			 * `children` was `null` or didn't result in further DOM nodes.
+			 */
+			append: function(node, children) {
+				if (!this.elem(node))
+					return null;
+
+				if (Array.isArray(children)) {
+					for (var i = 0; i < children.length; i++)
+						if (this.elem(children[i]))
+							node.appendChild(children[i]);
+						else if (children !== null && children !== undefined)
+							node.appendChild(document.createTextNode('' + children[i]));
+
+					return node.lastChild;
+				}
+				else if (typeof(children) === 'function') {
+					return this.append(node, children(node));
+				}
+				else if (this.elem(children)) {
+					return node.appendChild(children);
+				}
+				else if (children !== null && children !== undefined) {
+					node.innerHTML = '' + children;
+					return node.lastChild;
+				}
+
+				return null;
+			},
+
+			/**
+			 * Replaces the content of the given node with the given children.
+			 *
+			 * This function first removes any children of the given DOM
+			 * `Node` and then adds the given given children following the
+			 * rules outlined below.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {*} node
+			 * The `Node` argument to replace the children of.
+			 *
+			 * @param {*} [children]
+			 * The childrens to replace into the given node.
+			 *
+			 * When `children` is an array, then each item of the array
+			 * will be either appended as child element or text node,
+			 * depending on whether the item is a DOM `Node` instance or
+			 * some other non-`null` value. Non-`Node`, non-`null` values
+			 * will be converted to strings first before being passed as
+			 * argument to `createTextNode()`.
+			 *
+			 * When `children` is a function, it will be invoked with
+			 * the passed `node` argument as sole parameter and the `append`
+			 * function will be invoked again, with the given `node` argument
+			 * as first and the return value of the `children` function as
+			 * second parameter.
+			 *
+			 * When `children` is is a DOM `Node` instance, it will be
+			 * appended to the given `node`.
+			 *
+			 * When `children` is any other non-`null` value, it will be
+			 * converted to a string and appened to the `innerHTML` property
+			 * of the given `node`.
+			 *
+			 * @returns {Node|null}
+			 * Returns the last children `Node` appended to the node or `null`
+			 * if either the `node` argument was no valid DOM `node` or if the
+			 * `children` was `null` or didn't result in further DOM nodes.
+			 */
+			content: function(node, children) {
+				if (!this.elem(node))
+					return null;
+
+				var dataNodes = node.querySelectorAll('[data-idref]');
+
+				for (var i = 0; i < dataNodes.length; i++)
+					delete this.registry[dataNodes[i].getAttribute('data-idref')];
+
+				while (node.firstChild)
+					node.removeChild(node.firstChild);
+
+				return this.append(node, children);
+			},
+
+			/**
+			 * Sets attributes or registers event listeners on element nodes.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {*} node
+			 * The `Node` argument to set the attributes or add the event
+			 * listeners for. When the given `node` value is not a valid
+			 * DOM `Node`, the function returns and does nothing.
+			 *
+			 * @param {string|Object<string, *>} key
+			 * Specifies either the attribute or event handler name to use,
+			 * or an object containing multiple key, value pairs which are
+			 * each added to the node as either attribute or event handler,
+			 * depending on the respective value.
+			 *
+			 * @param {*} [val]
+			 * Specifies the attribute value or event handler function to add.
+			 * If the `key` parameter is an `Object`, this parameter will be
+			 * ignored.
+			 *
+			 * When `val` is of type function, it will be registered as event
+			 * handler on the given `node` with the `key` parameter being the
+			 * event name.
+			 *
+			 * When `val` is of type object, it will be serialized as JSON and
+			 * added as attribute to the given `node`, using the given `key`
+			 * as attribute name.
+			 *
+			 * When `val` is of any other type, it will be added as attribute
+			 * to the given `node` as-is, with the underlying `setAttribute()`
+			 * call implicitely turning it into a string.
+			 */
+			attr: function(node, key, val) {
+				if (!this.elem(node))
+					return null;
+
+				var attr = null;
+
+				if (typeof(key) === 'object' && key !== null)
+					attr = key;
+				else if (typeof(key) === 'string')
+					attr = {}, attr[key] = val;
+
+				for (key in attr) {
+					if (!attr.hasOwnProperty(key) || attr[key] == null)
+						continue;
+
+					switch (typeof(attr[key])) {
+					case 'function':
+						node.addEventListener(key, attr[key]);
+						break;
+
+					case 'object':
+						node.setAttribute(key, JSON.stringify(attr[key]));
+						break;
+
+					default:
+						node.setAttribute(key, attr[key]);
+					}
+				}
+			},
+
+			/**
+			 * Creates a new DOM `Node` from the given `html`, `attr` and
+			 * `data` parameters.
+			 *
+			 * This function has multiple signatures, it can be either invoked
+			 * in the form `create(html[, attr[, data]])` or in the form
+			 * `create(html[, data])`. The used variant is determined from the
+			 * type of the second argument.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {*} html
+			 * Describes the node to create.
+			 *
+			 * When the value of `html` is of type array, a `DocumentFragment`
+			 * node is created and each item of the array is first converted
+			 * to a DOM `Node` by passing it through `create()` and then added
+			 * as child to the fragment.
+			 *
+			 * When the value of `html` is a DOM `Node` instance, no new
+			 * element will be created but the node will be used as-is.
+			 *
+			 * When the value of `html` is a string starting with `<`, it will
+			 * be passed to `dom.parse()` and the resulting value is used.
+			 *
+			 * When the value of `html` is any other string, it will be passed
+			 * to `document.createElement()` for creating a new DOM `Node` of
+			 * the given name.
+			 *
+			 * @param {Object<string, *>} [attr]
+			 * Specifies an Object of key, value pairs to set as attributes
+			 * or event handlers on the created node. Refer to
+			 * {@link LuCI.dom#attr dom.attr()} for details.
+			 *
+			 * @param {*} [data]
+			 * Specifies children to append to the newly created element.
+			 * Refer to {@link LuCI.dom#append dom.append()} for details.
+			 *
+			 * @throws {InvalidCharacterError}
+			 * Throws an `InvalidCharacterError` when the given `html`
+			 * argument contained malformed markup (such as not escaped
+			 * `&` characters in XHTML mode) or when the given node name
+			 * in `html` contains characters which are not legal in DOM
+			 * element names, such as spaces.
+			 *
+			 * @returns {Node}
+			 * Returns the newly created `Node`.
+			 */
+			create: function() {
+				var html = arguments[0],
+				    attr = arguments[1],
+				    data = arguments[2],
+				    elem;
+
+				if (!(attr instanceof Object) || Array.isArray(attr))
+					data = attr, attr = null;
+
+				if (Array.isArray(html)) {
+					elem = document.createDocumentFragment();
+					for (var i = 0; i < html.length; i++)
+						elem.appendChild(this.create(html[i]));
+				}
+				else if (this.elem(html)) {
+					elem = html;
+				}
+				else if (html.charCodeAt(0) === 60) {
+					elem = this.parse(html);
+				}
+				else {
+					elem = document.createElement(html);
+				}
+
+				if (!elem)
+					return null;
+
+				this.attr(elem, attr);
+				this.append(elem, data);
+
+				return elem;
+			},
+
+			registry: {},
+
+			/**
+			 * Attaches or detaches arbitrary data to and from a DOM `Node`.
+			 *
+			 * This function is useful to attach non-string values or runtime
+			 * data that is not serializable to DOM nodes. To decouple data
+			 * from the DOM, values are not added directly to nodes, but
+			 * inserted into a registry instead which is then referenced by a
+			 * string key stored as `data-idref` attribute in the node.
+			 *
+			 * This function has multiple signatures and is sensitive to the
+			 * number of arguments passed to it.
+			 *
+			 *  - `dom.data(node)` -
+			 *     Fetches all data associated with the given node.
+			 *  - `dom.data(node, key)` -
+			 *     Fetches a specific key associated with the given node.
+			 *  - `dom.data(node, key, val)` -
+			 *     Sets a specific key to the given value associated with the
+			 *     given node.
+			 *  - `dom.data(node, null)` -
+			 *     Clears any data associated with the node.
+			 *  - `dom.data(node, key, null)` -
+			 *     Clears the given key associated with the node.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {Node} node
+			 * The DOM `Node` instance to set or retrieve the data for.
+			 *
+			 * @param {string|null} [key]
+			 * This is either a string specifying the key to retrieve, or
+			 * `null` to unset the entire node data.
+			 *
+			 * @param {*|null} [val]
+			 * This is either a non-`null` value to set for a given key or
+			 * `null` to remove the given `key` from the specified node.
+			 *
+			 * @returns {*}
+			 * Returns the get or set value, or `null` when no value could
+			 * be found.
+			 */
+			data: function(node, key, val) {
+				var id = node.getAttribute('data-idref');
+
+				/* clear all data */
+				if (arguments.length > 1 && key == null) {
+					if (id != null) {
+						node.removeAttribute('data-idref');
+						val = this.registry[id]
+						delete this.registry[id];
+						return val;
+					}
+
+					return null;
+				}
+
+				/* clear a key */
+				else if (arguments.length > 2 && key != null && val == null) {
+					if (id != null) {
+						val = this.registry[id][key];
+						delete this.registry[id][key];
+						return val;
+					}
+
+					return null;
+				}
+
+				/* set a key */
+				else if (arguments.length > 2 && key != null && val != null) {
+					if (id == null) {
+						do { id = Math.floor(Math.random() * 0xffffffff).toString(16) }
+						while (this.registry.hasOwnProperty(id));
+
+						node.setAttribute('data-idref', id);
+						this.registry[id] = {};
+					}
+
+					return (this.registry[id][key] = val);
+				}
+
+				/* get all data */
+				else if (arguments.length == 1) {
+					if (id != null)
+						return this.registry[id];
+
+					return null;
+				}
+
+				/* get a key */
+				else if (arguments.length == 2) {
+					if (id != null)
+						return this.registry[id][key];
+				}
+
+				return null;
+			},
+
+			/**
+			 * Binds the given class instance ot the specified DOM `Node`.
+			 *
+			 * This function uses the `dom.data()` facility to attach the
+			 * passed instance of a Class to a node. This is needed for
+			 * complex widget elements or similar where the corresponding
+			 * class instance responsible for the element must be retrieved
+			 * from DOM nodes obtained by `querySelector()` or similar means.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {Node} node
+			 * The DOM `Node` instance to bind the class to.
+			 *
+			 * @param {Class} inst
+			 * The Class instance to bind to the node.
+			 *
+			 * @throws {TypeError}
+			 * Throws a `TypeError` when the given instance argument isn't
+			 * a valid Class instance.
+			 *
+			 * @returns {Class}
+			 * Returns the bound class instance.
+			 */
+			bindClassInstance: function(node, inst) {
+				if (!(inst instanceof Class))
+					L.error('TypeError', 'Argument must be a class instance');
+
+				return this.data(node, '_class', inst);
+			},
+
+			/**
+			 * Finds a bound class instance on the given node itself or the
+			 * first bound instance on its closest parent node.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {Node} node
+			 * The DOM `Node` instance to start from.
+			 *
+			 * @returns {Class|null}
+			 * Returns the founds class instance if any or `null` if no bound
+			 * class could be found on the node itself or any of its parents.
+			 */
+			findClassInstance: function(node) {
+				var inst = null;
+
+				do {
+					inst = this.data(node, '_class');
+					node = node.parentNode;
+				}
+				while (!(inst instanceof Class) && node != null);
+
+				return inst;
+			},
+
+			/**
+			 * Finds a bound class instance on the given node itself or the
+			 * first bound instance on its closest parent node and invokes
+			 * the specified method name on the found class instance.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {Node} node
+			 * The DOM `Node` instance to start from.
+			 *
+			 * @param {string} method
+			 * The name of the method to invoke on the found class instance.
+			 *
+			 * @param {...*} params
+			 * Additional arguments to pass to the invoked method as-is.
+			 *
+			 * @returns {*|null}
+			 * Returns the return value of the invoked method if a class
+			 * instance and method has been found. Returns `null` if either
+			 * no bound class instance could be found, or if the found
+			 * instance didn't have the requested `method`.
+			 */
+			callClassMethod: function(node, method /*, ... */) {
+				var inst = this.findClassInstance(node);
+
+				if (inst == null || typeof(inst[method]) != 'function')
+					return null;
+
+				return inst[method].apply(inst, inst.varargs(arguments, 2));
+			},
+
+			/**
+			 * The ignore callback function is invoked by `isEmpty()` for each
+			 * child node to decide whether to ignore a child node or not.
+			 *
+			 * When this function returns `false`, the node passed to it is
+			 * ignored, else not.
+			 *
+			 * @callback LuCI.dom~ignoreCallbackFn
+			 * @param {Node} node
+			 * The child node to test.
+			 *
+			 * @returns {boolean}
+			 * Boolean indicating whether to ignore the node or not.
+			 */
+
+			/**
+			 * Tests whether a given DOM `Node` instance is empty or appears
+			 * empty.
+			 *
+			 * Any element child nodes which have the CSS class `hidden` set
+			 * or for which the optionally passed `ignoreFn` callback function
+			 * returns `false` are ignored.
+			 *
+			 * @instance
+			 * @memberof LuCI.dom
+			 * @param {Node} node
+			 * The DOM `Node` instance to test.
+			 *
+			 * @param {LuCI.dom~ignoreCallbackFn} [ignoreFn]
+			 * Specifies an optional function which is invoked for each child
+			 * node to decide whether the child node should be ignored or not.
+			 *
+			 * @returns {boolean}
+			 * Returns `true` if the node does not have any children or if
+			 * any children node either has a `hidden` CSS class or a `false`
+			 * result when testing it using the given `ignoreFn`.
+			 */
+			isEmpty: function(node, ignoreFn) {
+				for (var child = node.firstElementChild; child != null; child = child.nextElementSibling)
+					if (!child.classList.contains('hidden') && (!ignoreFn || !ignoreFn(child)))
+						return false;
+
+				return true;
+			}
+		}),
+
+		Poll: Poll,
+		Class: Class,
+		Request: Request,
+
+		/**
+		 * @class
+		 * @memberof LuCI
+		 * @hideconstructor
+		 * @classdesc
+		 *
+		 * The `view` class forms the basis of views and provides a standard
+		 * set of methods to inherit from.
+		 */
+		view: Class.extend(/* @lends LuCI.view.prototype */ {
+			__name__: 'LuCI.View',
+
+			__init__: function() {
+				var vp = document.getElementById('view');
+
+				L.dom.content(vp, E('div', { 'class': 'spinning' }, _('Loading view…')));
+
+				return Promise.resolve(this.load())
+					.then(L.bind(this.render, this))
+					.then(L.bind(function(nodes) {
+						var vp = document.getElementById('view');
+
+						L.dom.content(vp, nodes);
+						L.dom.append(vp, this.addFooter());
+					}, this)).catch(L.error);
+			},
+
+			/**
+			 * The load function is invoked before the view is rendered.
+			 *
+			 * The invocation of this function is wrapped by
+			 * `Promise.resolve()` so it may return Promises if needed.
+			 *
+			 * The return value of the function (or the resolved values
+			 * of the promise returned by it) will be passed as first
+			 * argument to `render()`.
+			 *
+			 * This function is supposed to be overwritten by subclasses,
+			 * the default implementation does nothing.
+			 *
+			 * @instance
+			 * @abstract
+			 * @memberof LuCI.view
+			 *
+			 * @returns {*|Promise<*>}
+			 * May return any value or a Promise resolving to any value.
+			 */
+			load: function() {},
+
+			/**
+			 * The render function is invoked after the
+			 * {@link LuCI.view#load load()} function and responsible
+			 * for setting up the view contents. It must return a DOM
+			 * `Node` or `DocumentFragment` holding the contents to
+			 * insert into the view area.
+			 *
+			 * The invocation of this function is wrapped by
+			 * `Promise.resolve()` so it may return Promises if needed.
+			 *
+			 * The return value of the function (or the resolved values
+			 * of the promise returned by it) will be inserted into the
+			 * main content area using
+			 * {@link LuCI.dom#append dom.append()}.
+			 *
+			 * This function is supposed to be overwritten by subclasses,
+			 * the default implementation does nothing.
+			 *
+			 * @instance
+			 * @abstract
+			 * @memberof LuCI.view
+			 * @param {*|null} load_results
+			 * This function will receive the return value of the
+			 * {@link LuCI.view#load view.load()} function as first
+			 * argument.
+			 *
+			 * @returns {Node|Promise<Node>}
+			 * Should return a DOM `Node` value or a `Promise` resolving
+			 * to a `Node` value.
+			 */
+			render: function() {},
+
+			/**
+			 * The handleSave function is invoked when the user clicks
+			 * the `Save` button in the page action footer.
+			 *
+			 * The default implementation should be sufficient for most
+			 * views using {@link form#Map form.Map()} based forms - it
+			 * will iterate all forms present in the view and invoke
+			 * the {@link form#Map#save Map.save()} method on each form.
+			 *
+			 * Views not using `Map` instances or requiring other special
+			 * logic should overwrite `handleSave()` with a custom
+			 * implementation.
+			 *
+			 * To disable the `Save` page footer button, views extending
+			 * this base class should overwrite the `handleSave` function
+			 * with `null`.
+			 *
+			 * The invocation of this function is wrapped by
+			 * `Promise.resolve()` so it may return Promises if needed.
+			 *
+			 * @instance
+			 * @memberof LuCI.view
+			 * @param {Event} ev
+			 * The DOM event that triggered the function.
+			 *
+			 * @returns {*|Promise<*>}
+			 * Any return values of this function are discarded, but
+			 * passed through `Promise.resolve()` to ensure that any
+			 * returned promise runs to completion before the button
+			 * is reenabled.
+			 */
+			handleSave: function(ev) {
+				var tasks = [];
+
+				document.getElementById('maincontent')
+					.querySelectorAll('.cbi-map').forEach(function(map) {
+						tasks.push(L.dom.callClassMethod(map, 'save'));
+					});
+
+				return Promise.all(tasks);
+			},
+
+			/**
+			 * The handleSaveApply function is invoked when the user clicks
+			 * the `Save & Apply` button in the page action footer.
+			 *
+			 * The default implementation should be sufficient for most
+			 * views using {@link form#Map form.Map()} based forms - it
+			 * will first invoke
+			 * {@link LuCI.view.handleSave view.handleSave()} and then
+			 * call {@link ui#changes#apply ui.changes.apply()} to start the
+			 * modal config apply and page reload flow.
+			 *
+			 * Views not using `Map` instances or requiring other special
+			 * logic should overwrite `handleSaveApply()` with a custom
+			 * implementation.
+			 *
+			 * To disable the `Save & Apply` page footer button, views
+			 * extending this base class should overwrite the
+			 * `handleSaveApply` function with `null`.
+			 *
+			 * The invocation of this function is wrapped by
+			 * `Promise.resolve()` so it may return Promises if needed.
+			 *
+			 * @instance
+			 * @memberof LuCI.view
+			 * @param {Event} ev
+			 * The DOM event that triggered the function.
+			 *
+			 * @returns {*|Promise<*>}
+			 * Any return values of this function are discarded, but
+			 * passed through `Promise.resolve()` to ensure that any
+			 * returned promise runs to completion before the button
+			 * is reenabled.
+			 */
+			handleSaveApply: function(ev) {
+				return this.handleSave(ev).then(function() {
+					L.ui.changes.apply(true);
+				});
+			},
+
+			/**
+			 * The handleReset function is invoked when the user clicks
+			 * the `Reset` button in the page action footer.
+			 *
+			 * The default implementation should be sufficient for most
+			 * views using {@link form#Map form.Map()} based forms - it
+			 * will iterate all forms present in the view and invoke
+			 * the {@link form#Map#save Map.reset()} method on each form.
+			 *
+			 * Views not using `Map` instances or requiring other special
+			 * logic should overwrite `handleReset()` with a custom
+			 * implementation.
+			 *
+			 * To disable the `Reset` page footer button, views extending
+			 * this base class should overwrite the `handleReset` function
+			 * with `null`.
+			 *
+			 * The invocation of this function is wrapped by
+			 * `Promise.resolve()` so it may return Promises if needed.
+			 *
+			 * @instance
+			 * @memberof LuCI.view
+			 * @param {Event} ev
+			 * The DOM event that triggered the function.
+			 *
+			 * @returns {*|Promise<*>}
+			 * Any return values of this function are discarded, but
+			 * passed through `Promise.resolve()` to ensure that any
+			 * returned promise runs to completion before the button
+			 * is reenabled.
+			 */
+			handleReset: function(ev) {
+				var tasks = [];
+
+				document.getElementById('maincontent')
+					.querySelectorAll('.cbi-map').forEach(function(map) {
+						tasks.push(L.dom.callClassMethod(map, 'reset'));
+					});
+
+				return Promise.all(tasks);
+			},
+
+			/**
+			 * Renders a standard page action footer if any of the
+			 * `handleSave()`, `handleSaveApply()` or `handleReset()`
+			 * functions are defined.
+			 *
+			 * The default implementation should be sufficient for most
+			 * views - it will render a standard page footer with action
+			 * buttons labeled `Save`, `Save & Apply` and `Reset`
+			 * triggering the `handleSave()`, `handleSaveApply()` and
+			 * `handleReset()` functions respectively.
+			 *
+			 * When any of these `handle*()` functions is overwritten
+			 * with `null` by a view extending this class, the
+			 * corresponding button will not be rendered.
+			 *
+			 * @instance
+			 * @memberof LuCI.view
+			 * @returns {DocumentFragment}
+			 * Returns a `DocumentFragment` containing the footer bar
+			 * with buttons for each corresponding `handle*()` action
+			 * or an empty `DocumentFragment` if all three `handle*()`
+			 * methods are overwritten with `null`.
+			 */
+			addFooter: function() {
+				var footer = E([]);
+
+				if (this.handleSaveApply || this.handleSave || this.handleReset) {
+					footer.appendChild(E('div', { 'class': 'cbi-page-actions' }, [
+						this.handleSaveApply ? E('button', {
+							'class': 'cbi-button cbi-button-apply',
+							'click': L.ui.createHandlerFn(this, 'handleSaveApply')
+						}, [ _('Save & Apply') ]) : '', ' ',
+						this.handleSave ? E('button', {
+							'class': 'cbi-button cbi-button-save',
+							'click': L.ui.createHandlerFn(this, 'handleSave')
+						}, [ _('Save') ]) : '', ' ',
+						this.handleReset ? E('button', {
+							'class': 'cbi-button cbi-button-reset',
+							'click': L.ui.createHandlerFn(this, 'handleReset')
+						}, [ _('Reset') ]) : ''
+					]));
+				}
+
+				return footer;
+			}
+		})
+	});
+
+	/**
+	 * @class
+	 * @memberof LuCI
+	 * @deprecated
+	 * @classdesc
+	 *
+	 * The `LuCI.XHR` class is a legacy compatibility shim for the
+	 * functionality formerly provided by `xhr.js`. It is registered as global
+	 * `window.XHR` symbol for compatibility with legacy code.
+	 *
+	 * New code should use {@link LuCI.Request} instead to implement HTTP
+	 * request handling.
+	 */
+	var XHR = Class.extend(/** @lends LuCI.XHR.prototype */ {
+		__name__: 'LuCI.XHR',
+		__init__: function() {
+			if (window.console && console.debug)
+				console.debug('Direct use XHR() is deprecated, please use L.Request instead');
+		},
+
+		_response: function(cb, res, json, duration) {
+			if (this.active)
+				cb(res, json, duration);
+			delete this.active;
+		},
+
+		/**
+		 * This function is a legacy wrapper around
+		 * {@link LuCI#get LuCI.get()}.
+		 *
+		 * @instance
+		 * @deprecated
+		 * @memberof LuCI.XHR
+		 *
+		 * @param {string} url
+		 * The URL to request
+		 *
+		 * @param {Object} [data]
+		 * Additional query string data
+		 *
+		 * @param {LuCI.requestCallbackFn} [callback]
+		 * Callback function to invoke on completion
+		 *
+		 * @param {number} [timeout]
+		 * Request timeout to use
+		 *
+		 * @return {Promise<null>}
+		 */
+		get: function(url, data, callback, timeout) {
+			this.active = true;
+			L.get(url, data, this._response.bind(this, callback), timeout);
+		},
+
+		/**
+		 * This function is a legacy wrapper around
+		 * {@link LuCI#post LuCI.post()}.
+		 *
+		 * @instance
+		 * @deprecated
+		 * @memberof LuCI.XHR
+		 *
+		 * @param {string} url
+		 * The URL to request
+		 *
+		 * @param {Object} [data]
+		 * Additional data to append to the request body.
+		 *
+		 * @param {LuCI.requestCallbackFn} [callback]
+		 * Callback function to invoke on completion
+		 *
+		 * @param {number} [timeout]
+		 * Request timeout to use
+		 *
+		 * @return {Promise<null>}
+		 */
+		post: function(url, data, callback, timeout) {
+			this.active = true;
+			L.post(url, data, this._response.bind(this, callback), timeout);
+		},
+
+		/**
+		 * Cancels a running request.
+		 *
+		 * This function does not actually cancel the underlying
+		 * `XMLHTTPRequest` request but it sets a flag which prevents the
+		 * invocation of the callback function when the request eventually
+		 * finishes or timed out.
+		 *
+		 * @instance
+		 * @deprecated
+		 * @memberof LuCI.XHR
+		 */
+		cancel: function() { delete this.active },
+
+		/**
+		 * Checks the running state of the request.
+		 *
+		 * @instance
+		 * @deprecated
+		 * @memberof LuCI.XHR
+		 *
+		 * @returns {boolean}
+		 * Returns `true` if the request is still running or `false` if it
+		 * already completed.
+		 */
+		busy: function() { return (this.active === true) },
+
+		/**
+		 * Ignored for backwards compatibility.
+		 *
+		 * This function does nothing.
+		 *
+		 * @instance
+		 * @deprecated
+		 * @memberof LuCI.XHR
+		 */
+		abort: function() {},
+
+		/**
+		 * Existing for backwards compatibility.
+		 *
+		 * This function simply throws an `InternalError` when invoked.
+		 *
+		 * @instance
+		 * @deprecated
+		 * @memberof LuCI.XHR
+		 *
+		 * @throws {InternalError}
+		 * Throws an `InternalError` with the message `Not implemented`
+		 * when invoked.
+		 */
+		send_form: function() { L.error('InternalError', 'Not implemented') },
+	});
+
+	XHR.get = function() { return window.L.get.apply(window.L, arguments) };
+	XHR.post = function() { return window.L.post.apply(window.L, arguments) };
+	XHR.poll = function() { return window.L.poll.apply(window.L, arguments) };
+	XHR.stop = Request.poll.remove.bind(Request.poll);
+	XHR.halt = Request.poll.stop.bind(Request.poll);
+	XHR.run = Request.poll.start.bind(Request.poll);
+	XHR.running = Request.poll.active.bind(Request.poll);
+
+	window.XHR = XHR;
+	window.LuCI = LuCI;
+})(window, document);
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 09:33:05 GMT+0100 (Central European Standard Time) +
+ + + + + diff --git a/docs/jsapi/network.js.html b/docs/jsapi/network.js.html new file mode 100644 index 000000000..e06633357 --- /dev/null +++ b/docs/jsapi/network.js.html @@ -0,0 +1,4038 @@ + + + + + JSDoc: Source: network.js + + + + + + + + + + +
+ +

Source: network.js

+ + + + + + +
+
+
'use strict';
+'require uci';
+'require rpc';
+'require validation';
+
+var proto_errors = {
+	CONNECT_FAILED:			_('Connection attempt failed'),
+	INVALID_ADDRESS:		_('IP address in invalid'),
+	INVALID_GATEWAY:		_('Gateway address is invalid'),
+	INVALID_LOCAL_ADDRESS:	_('Local IP address is invalid'),
+	MISSING_ADDRESS:		_('IP address is missing'),
+	MISSING_PEER_ADDRESS:	_('Peer address is missing'),
+	NO_DEVICE:				_('Network device is not present'),
+	NO_IFACE:				_('Unable to determine device name'),
+	NO_IFNAME:				_('Unable to determine device name'),
+	NO_WAN_ADDRESS:			_('Unable to determine external IP address'),
+	NO_WAN_LINK:			_('Unable to determine upstream interface'),
+	PEER_RESOLVE_FAIL:		_('Unable to resolve peer host name'),
+	PIN_FAILED:				_('PIN code rejected')
+};
+
+var iface_patterns_ignore = [
+	/^wmaster\d+/,
+	/^wifi\d+/,
+	/^hwsim\d+/,
+	/^imq\d+/,
+	/^ifb\d+/,
+	/^mon\.wlan\d+/,
+	/^sit\d+/,
+	/^gre\d+/,
+	/^gretap\d+/,
+	/^ip6gre\d+/,
+	/^ip6tnl\d+/,
+	/^tunl\d+/,
+	/^lo$/
+];
+
+var iface_patterns_wireless = [
+	/^wlan\d+/,
+	/^wl\d+/,
+	/^ath\d+/,
+	/^\w+\.network\d+/
+];
+
+var iface_patterns_virtual = [ ];
+
+var callLuciNetworkDevices = rpc.declare({
+	object: 'luci-rpc',
+	method: 'getNetworkDevices',
+	expect: { '': {} }
+});
+
+var callLuciWirelessDevices = rpc.declare({
+	object: 'luci-rpc',
+	method: 'getWirelessDevices',
+	expect: { '': {} }
+});
+
+var callLuciBoardJSON = rpc.declare({
+	object: 'luci-rpc',
+	method: 'getBoardJSON'
+});
+
+var callLuciHostHints = rpc.declare({
+	object: 'luci-rpc',
+	method: 'getHostHints',
+	expect: { '': {} }
+});
+
+var callIwinfoAssoclist = rpc.declare({
+	object: 'iwinfo',
+	method: 'assoclist',
+	params: [ 'device', 'mac' ],
+	expect: { results: [] }
+});
+
+var callIwinfoScan = rpc.declare({
+	object: 'iwinfo',
+	method: 'scan',
+	params: [ 'device' ],
+	nobatch: true,
+	expect: { results: [] }
+});
+
+var callNetworkInterfaceDump = rpc.declare({
+	object: 'network.interface',
+	method: 'dump',
+	expect: { 'interface': [] }
+});
+
+var callNetworkProtoHandlers = rpc.declare({
+	object: 'network',
+	method: 'get_proto_handlers',
+	expect: { '': {} }
+});
+
+var _init = null,
+    _state = null,
+    _protocols = {},
+    _protospecs = {};
+
+function getProtocolHandlers(cache) {
+	return callNetworkProtoHandlers().then(function(protos) {
+		/* Register "none" protocol */
+		if (!protos.hasOwnProperty('none'))
+			Object.assign(protos, { none: { no_device: false } });
+
+		/* Hack: emulate relayd protocol */
+		if (!protos.hasOwnProperty('relay'))
+			Object.assign(protos, { relay: { no_device: true } });
+
+		Object.assign(_protospecs, protos);
+
+		return Promise.all(Object.keys(protos).map(function(p) {
+			return Promise.resolve(L.require('protocol.%s'.format(p))).catch(function(err) {
+				if (L.isObject(err) && err.name != 'NetworkError')
+					L.error(err);
+			});
+		})).then(function() {
+			return protos;
+		});
+	}).catch(function() {
+		return {};
+	});
+}
+
+function getWifiStateBySid(sid) {
+	var s = uci.get('wireless', sid);
+
+	if (s != null && s['.type'] == 'wifi-iface') {
+		for (var radioname in _state.radios) {
+			for (var i = 0; i < _state.radios[radioname].interfaces.length; i++) {
+				var netstate = _state.radios[radioname].interfaces[i];
+
+				if (typeof(netstate.section) != 'string')
+					continue;
+
+				var s2 = uci.get('wireless', netstate.section);
+
+				if (s2 != null && s['.type'] == s2['.type'] && s['.name'] == s2['.name']) {
+					if (s2['.anonymous'] == false && netstate.section.charAt(0) == '@')
+						return null;
+
+					return [ radioname, _state.radios[radioname], netstate ];
+				}
+			}
+		}
+	}
+
+	return null;
+}
+
+function getWifiStateByIfname(ifname) {
+	for (var radioname in _state.radios) {
+		for (var i = 0; i < _state.radios[radioname].interfaces.length; i++) {
+			var netstate = _state.radios[radioname].interfaces[i];
+
+			if (typeof(netstate.ifname) != 'string')
+				continue;
+
+			if (netstate.ifname == ifname)
+				return [ radioname, _state.radios[radioname], netstate ];
+		}
+	}
+
+	return null;
+}
+
+function isWifiIfname(ifname) {
+	for (var i = 0; i < iface_patterns_wireless.length; i++)
+		if (iface_patterns_wireless[i].test(ifname))
+			return true;
+
+	return false;
+}
+
+function getWifiSidByNetid(netid) {
+	var m = /^(\w+)\.network(\d+)$/.exec(netid);
+	if (m) {
+		var sections = uci.sections('wireless', 'wifi-iface');
+		for (var i = 0, n = 0; i < sections.length; i++) {
+			if (sections[i].device != m[1])
+				continue;
+
+			if (++n == +m[2])
+				return sections[i]['.name'];
+		}
+	}
+
+	return null;
+}
+
+function getWifiSidByIfname(ifname) {
+	var sid = getWifiSidByNetid(ifname);
+
+	if (sid != null)
+		return sid;
+
+	var res = getWifiStateByIfname(ifname);
+
+	if (res != null && L.isObject(res[2]) && typeof(res[2].section) == 'string')
+		return res[2].section;
+
+	return null;
+}
+
+function getWifiNetidBySid(sid) {
+	var s = uci.get('wireless', sid);
+	if (s != null && s['.type'] == 'wifi-iface') {
+		var radioname = s.device;
+		if (typeof(s.device) == 'string') {
+			var i = 0, netid = null, sections = uci.sections('wireless', 'wifi-iface');
+			for (var i = 0, n = 0; i < sections.length; i++) {
+				if (sections[i].device != s.device)
+					continue;
+
+				n++;
+
+				if (sections[i]['.name'] != s['.name'])
+					continue;
+
+				return [ '%s.network%d'.format(s.device, n), s.device ];
+			}
+
+		}
+	}
+
+	return null;
+}
+
+function getWifiNetidByNetname(name) {
+	var sections = uci.sections('wireless', 'wifi-iface');
+	for (var i = 0; i < sections.length; i++) {
+		if (typeof(sections[i].network) != 'string')
+			continue;
+
+		var nets = sections[i].network.split(/\s+/);
+		for (var j = 0; j < nets.length; j++) {
+			if (nets[j] != name)
+				continue;
+
+			return getWifiNetidBySid(sections[i]['.name']);
+		}
+	}
+
+	return null;
+}
+
+function isVirtualIfname(ifname) {
+	for (var i = 0; i < iface_patterns_virtual.length; i++)
+		if (iface_patterns_virtual[i].test(ifname))
+			return true;
+
+	return false;
+}
+
+function isIgnoredIfname(ifname) {
+	for (var i = 0; i < iface_patterns_ignore.length; i++)
+		if (iface_patterns_ignore[i].test(ifname))
+			return true;
+
+	return false;
+}
+
+function appendValue(config, section, option, value) {
+	var values = uci.get(config, section, option),
+	    isArray = Array.isArray(values),
+	    rv = false;
+
+	if (isArray == false)
+		values = L.toArray(values);
+
+	if (values.indexOf(value) == -1) {
+		values.push(value);
+		rv = true;
+	}
+
+	uci.set(config, section, option, isArray ? values : values.join(' '));
+
+	return rv;
+}
+
+function removeValue(config, section, option, value) {
+	var values = uci.get(config, section, option),
+	    isArray = Array.isArray(values),
+	    rv = false;
+
+	if (isArray == false)
+		values = L.toArray(values);
+
+	for (var i = values.length - 1; i >= 0; i--) {
+		if (values[i] == value) {
+			values.splice(i, 1);
+			rv = true;
+		}
+	}
+
+	if (values.length > 0)
+		uci.set(config, section, option, isArray ? values : values.join(' '));
+	else
+		uci.unset(config, section, option);
+
+	return rv;
+}
+
+function prefixToMask(bits, v6) {
+	var w = v6 ? 128 : 32,
+	    m = [];
+
+	if (bits > w)
+		return null;
+
+	for (var i = 0; i < w / 16; i++) {
+		var b = Math.min(16, bits);
+		m.push((0xffff << (16 - b)) & 0xffff);
+		bits -= b;
+	}
+
+	if (v6)
+		return String.prototype.format.apply('%x:%x:%x:%x:%x:%x:%x:%x', m).replace(/:0(?::0)+$/, '::');
+	else
+		return '%d.%d.%d.%d'.format(m[0] >>> 8, m[0] & 0xff, m[1] >>> 8, m[1] & 0xff);
+}
+
+function maskToPrefix(mask, v6) {
+	var m = v6 ? validation.parseIPv6(mask) : validation.parseIPv4(mask);
+
+	if (!m)
+		return null;
+
+	var bits = 0;
+
+	for (var i = 0, z = false; i < m.length; i++) {
+		z = z || !m[i];
+
+		while (!z && (m[i] & (v6 ? 0x8000 : 0x80))) {
+			m[i] = (m[i] << 1) & (v6 ? 0xffff : 0xff);
+			bits++;
+		}
+
+		if (m[i])
+			return null;
+	}
+
+	return bits;
+}
+
+function initNetworkState(refresh) {
+	if (_state == null || refresh) {
+		_init = _init || Promise.all([
+			L.resolveDefault(callNetworkInterfaceDump(), []),
+			L.resolveDefault(callLuciBoardJSON(), {}),
+			L.resolveDefault(callLuciNetworkDevices(), {}),
+			L.resolveDefault(callLuciWirelessDevices(), {}),
+			L.resolveDefault(callLuciHostHints(), {}),
+			getProtocolHandlers(),
+			uci.load(['network', 'wireless', 'luci'])
+		]).then(function(data) {
+			var netifd_ifaces = data[0],
+			    board_json    = data[1],
+			    luci_devs     = data[2];
+
+			var s = {
+				isTunnel: {}, isBridge: {}, isSwitch: {}, isWifi: {},
+				ifaces: netifd_ifaces, radios: data[3], hosts: data[4],
+				netdevs: {}, bridges: {}, switches: {}
+			};
+
+			for (var name in luci_devs) {
+				var dev = luci_devs[name];
+
+				if (isVirtualIfname(name))
+					s.isTunnel[name] = true;
+
+				if (!s.isTunnel[name] && isIgnoredIfname(name))
+					continue;
+
+				s.netdevs[name] = s.netdevs[name] || {
+					idx:      dev.ifindex,
+					name:     name,
+					rawname:  name,
+					flags:    dev.flags,
+					stats:    dev.stats,
+					macaddr:  dev.mac,
+					type:     dev.type,
+					mtu:      dev.mtu,
+					qlen:     dev.qlen,
+					ipaddrs:  [],
+					ip6addrs: []
+				};
+
+				if (Array.isArray(dev.ipaddrs))
+					for (var i = 0; i < dev.ipaddrs.length; i++)
+						s.netdevs[name].ipaddrs.push(dev.ipaddrs[i].address + '/' + dev.ipaddrs[i].netmask);
+
+				if (Array.isArray(dev.ip6addrs))
+					for (var i = 0; i < dev.ip6addrs.length; i++)
+						s.netdevs[name].ip6addrs.push(dev.ip6addrs[i].address + '/' + dev.ip6addrs[i].netmask);
+			}
+
+			for (var name in luci_devs) {
+				var dev = luci_devs[name];
+
+				if (!dev.bridge)
+					continue;
+
+				var b = {
+					name:    name,
+					id:      dev.id,
+					stp:     dev.stp,
+					ifnames: []
+				};
+
+				for (var i = 0; dev.ports && i < dev.ports.length; i++) {
+					var subdev = s.netdevs[dev.ports[i]];
+
+					if (subdev == null)
+						continue;
+
+					b.ifnames.push(subdev);
+					subdev.bridge = b;
+				}
+
+				s.bridges[name] = b;
+				s.isBridge[name] = true;
+			}
+
+			if (L.isObject(board_json.switch)) {
+				for (var switchname in board_json.switch) {
+					var layout = board_json.switch[switchname],
+					    netdevs = {},
+					    nports = {},
+					    ports = [],
+					    pnum = null,
+					    role = null;
+
+					if (L.isObject(layout) && Array.isArray(layout.ports)) {
+						for (var i = 0, port; (port = layout.ports[i]) != null; i++) {
+							if (typeof(port) == 'object' && typeof(port.num) == 'number' &&
+								(typeof(port.role) == 'string' || typeof(port.device) == 'string')) {
+								var spec = {
+									num:   port.num,
+									role:  port.role || 'cpu',
+									index: (port.index != null) ? port.index : port.num
+								};
+
+								if (port.device != null) {
+									spec.device = port.device;
+									spec.tagged = spec.need_tag;
+									netdevs[port.num] = port.device;
+								}
+
+								ports.push(spec);
+
+								if (port.role != null)
+									nports[port.role] = (nports[port.role] || 0) + 1;
+							}
+						}
+
+						ports.sort(function(a, b) {
+							if (a.role != b.role)
+								return (a.role < b.role) ? -1 : 1;
+
+							return (a.index - b.index);
+						});
+
+						for (var i = 0, port; (port = ports[i]) != null; i++) {
+							if (port.role != role) {
+								role = port.role;
+								pnum = 1;
+							}
+
+							if (role == 'cpu')
+								port.label = 'CPU (%s)'.format(port.device);
+							else if (nports[role] > 1)
+								port.label = '%s %d'.format(role.toUpperCase(), pnum++);
+							else
+								port.label = role.toUpperCase();
+
+							delete port.role;
+							delete port.index;
+						}
+
+						s.switches[switchname] = {
+							ports: ports,
+							netdevs: netdevs
+						};
+					}
+				}
+			}
+
+			if (L.isObject(board_json.dsl) && L.isObject(board_json.dsl.modem)) {
+				s.hasDSLModem = board_json.dsl.modem;
+			}
+
+			_init = null;
+
+			return (_state = s);
+		});
+	}
+
+	return (_state != null ? Promise.resolve(_state) : _init);
+}
+
+function ifnameOf(obj) {
+	if (obj instanceof Protocol)
+		return obj.getIfname();
+	else if (obj instanceof Device)
+		return obj.getName();
+	else if (obj instanceof WifiDevice)
+		return obj.getName();
+	else if (obj instanceof WifiNetwork)
+		return obj.getIfname();
+	else if (typeof(obj) == 'string')
+		return obj.replace(/:.+$/, '');
+
+	return null;
+}
+
+function networkSort(a, b) {
+	return a.getName() > b.getName();
+}
+
+function deviceSort(a, b) {
+	var typeWeigth = { wifi: 2, alias: 3 },
+        weightA = typeWeigth[a.getType()] || 1,
+        weightB = typeWeigth[b.getType()] || 1;
+
+    if (weightA != weightB)
+    	return weightA - weightB;
+
+	return a.getName() > b.getName();
+}
+
+function formatWifiEncryption(enc) {
+	if (!L.isObject(enc))
+		return null;
+
+	if (!enc.enabled)
+		return 'None';
+
+	var ciphers = Array.isArray(enc.ciphers)
+		? enc.ciphers.map(function(c) { return c.toUpperCase() }) : [ 'NONE' ];
+
+	if (Array.isArray(enc.wep)) {
+		var has_open = false,
+		    has_shared = false;
+
+		for (var i = 0; i < enc.wep.length; i++)
+			if (enc.wep[i] == 'open')
+				has_open = true;
+			else if (enc.wep[i] == 'shared')
+				has_shared = true;
+
+		if (has_open && has_shared)
+			return 'WEP Open/Shared (%s)'.format(ciphers.join(', '));
+		else if (has_open)
+			return 'WEP Open System (%s)'.format(ciphers.join(', '));
+		else if (has_shared)
+			return 'WEP Shared Auth (%s)'.format(ciphers.join(', '));
+
+		return 'WEP';
+	}
+
+	if (Array.isArray(enc.wpa)) {
+		var versions = [],
+		    suites = Array.isArray(enc.authentication)
+			? enc.authentication.map(function(a) { return a.toUpperCase() }) : [ 'NONE' ];
+
+		for (var i = 0; i < enc.wpa.length; i++)
+			switch (enc.wpa[i]) {
+			case 1:
+				versions.push('WPA');
+				break;
+
+			default:
+				versions.push('WPA%d'.format(enc.wpa[i]));
+				break;
+			}
+
+		if (versions.length > 1)
+			return 'mixed %s %s (%s)'.format(versions.join('/'), suites.join(', '), ciphers.join(', '));
+
+		return '%s %s (%s)'.format(versions[0], suites.join(', '), ciphers.join(', '));
+	}
+
+	return 'Unknown';
+}
+
+function enumerateNetworks() {
+	var uciInterfaces = uci.sections('network', 'interface'),
+	    networks = {};
+
+	for (var i = 0; i < uciInterfaces.length; i++)
+		networks[uciInterfaces[i]['.name']] = this.instantiateNetwork(uciInterfaces[i]['.name']);
+
+	for (var i = 0; i < _state.ifaces.length; i++)
+		if (networks[_state.ifaces[i].interface] == null)
+			networks[_state.ifaces[i].interface] =
+				this.instantiateNetwork(_state.ifaces[i].interface, _state.ifaces[i].proto);
+
+	var rv = [];
+
+	for (var network in networks)
+		if (networks.hasOwnProperty(network))
+			rv.push(networks[network]);
+
+	rv.sort(networkSort);
+
+	return rv;
+}
+
+
+var Hosts, Network, Protocol, Device, WifiDevice, WifiNetwork;
+
+/**
+ * @class
+ * @memberof LuCI
+ * @hideconstructor
+ * @classdesc
+ *
+ * The `LuCI.Network` class combines data from multiple `ubus` apis to
+ * provide an abstraction of the current network configuration state.
+ *
+ * It provides methods to enumerate interfaces and devices, to query
+ * current configuration details and to manipulate settings.
+ */
+Network = L.Class.extend(/** @lends LuCI.Network.prototype */ {
+	/**
+	 * Converts the given prefix size in bits to a netmask.
+	 *
+	 * @method
+	 *
+	 * @param {number} bits
+	 * The prefix size in bits.
+	 *
+	 * @param {boolean} [v6=false]
+	 * Whether to convert the bits value into an IPv4 netmask (`false`) or
+	 * an IPv6 netmask (`true`).
+	 *
+	 * @returns {null|string}
+	 * Returns a string containing the netmask corresponding to the bit count
+	 * or `null` when the given amount of bits exceeds the maximum possible
+	 * value of `32` for IPv4 or `128` for IPv6.
+	 */
+	prefixToMask: prefixToMask,
+
+	/**
+	 * Converts the given netmask to a prefix size in bits.
+	 *
+	 * @method
+	 *
+	 * @param {string} netmask
+	 * The netmask to convert into a bit count.
+	 *
+	 * @param {boolean} [v6=false]
+	 * Whether to parse the given netmask as IPv4 (`false`) or IPv6 (`true`)
+	 * address.
+	 *
+	 * @returns {null|number}
+	 * Returns the number of prefix bits contained in the netmask or `null`
+	 * if the given netmask value was invalid.
+	 */
+	maskToPrefix: maskToPrefix,
+
+	/**
+	 * An encryption entry describes active wireless encryption settings
+	 * such as the used key management protocols, active ciphers and
+	 * protocol versions.
+	 *
+	 * @typedef {Object<string, boolean|Array<number|string>>} LuCI.Network.WifiEncryption
+	 * @memberof LuCI.Network
+	 *
+	 * @property {boolean} enabled
+	 * Specifies whether any kind of encryption, such as `WEP` or `WPA` is
+	 * enabled. If set to `false`, then no encryption is active and the
+	 * corresponding network is open.
+	 *
+	 * @property {string[]} [wep]
+	 * When the `wep` property exists, the network uses WEP encryption.
+	 * In this case, the property is set to an array of active WEP modes
+	 * which might be either `open`, `shared` or both.
+	 *
+	 * @property {number[]} [wpa]
+	 * When the `wpa` property exists, the network uses WPA security.
+	 * In this case, the property is set to an array containing the WPA
+	 * protocol versions used, e.g. `[ 1, 2 ]` for WPA/WPA2 mixed mode or
+	 * `[ 3 ]` for WPA3-SAE.
+	 *
+	 * @property {string[]} [authentication]
+	 * The `authentication` property only applies to WPA encryption and
+	 * is defined when the `wpa` property is set as well. It points to
+	 * an array of active authentication suites used by the network, e.g.
+	 * `[ "psk" ]` for a WPA(2)-PSK network or `[ "psk", "sae" ]` for
+	 * mixed WPA2-PSK/WPA3-SAE encryption.
+	 *
+	 * @property {string[]} [ciphers]
+	 * If either WEP or WPA encryption is active, then the `ciphers`
+	 * property will be set to an array describing the active encryption
+	 * ciphers used by the network, e.g. `[ "tkip", "ccmp" ]` for a
+	 * WPA/WPA2-PSK mixed network or `[ "wep-40", "wep-104" ]` for an
+	 * WEP network.
+	 */
+
+	/**
+	 * Converts a given {@link LuCI.Network.WifiEncryption encryption entry}
+	 * into a human readable string such as `mixed WPA/WPA2 PSK (TKIP, CCMP)`
+	 * or `WPA3 SAE (CCMP)`.
+	 *
+	 * @method
+	 *
+	 * @param {LuCI.Network.WifiEncryption} encryption
+	 * The wireless encryption entry to convert.
+	 *
+	 * @returns {null|string}
+	 * Returns the description string for the given encryption entry or
+	 * `null` if the given entry was invalid.
+	 */
+	formatWifiEncryption: formatWifiEncryption,
+
+	/**
+	 * Flushes the local network state cache and fetches updated information
+	 * from the remote `ubus` apis.
+	 *
+	 * @returns {Promise<Object>}
+	 * Returns a promise resolving to the internal network state object.
+	 */
+	flushCache: function() {
+		initNetworkState(true);
+		return _init;
+	},
+
+	/**
+	 * Instantiates the given {@link LuCI.Network.Protocol Protocol} backend,
+	 * optionally using the given network name.
+	 *
+	 * @param {string} protoname
+	 * The protocol backend to use, e.g. `static` or `dhcp`.
+	 *
+	 * @param {string} [netname=__dummy__]
+	 * The network name to use for the instantiated protocol. This should be
+	 * usually set to one of the interfaces described in /etc/config/network
+	 * but it is allowed to omit it, e.g. to query protocol capabilities
+	 * without the need for an existing interface.
+	 *
+	 * @returns {null|LuCI.Network.Protocol}
+	 * Returns the instantiated protocol backend class or `null` if the given
+	 * protocol isn't known.
+	 */
+	getProtocol: function(protoname, netname) {
+		var v = _protocols[protoname];
+		if (v != null)
+			return new v(netname || '__dummy__');
+
+		return null;
+	},
+
+	/**
+	 * Obtains instances of all known {@link LuCI.Network.Protocol Protocol}
+	 * backend classes.
+	 *
+	 * @returns {Array<LuCI.Network.Protocol>}
+	 * Returns an array of protocol class instances.
+	 */
+	getProtocols: function() {
+		var rv = [];
+
+		for (var protoname in _protocols)
+			rv.push(new _protocols[protoname]('__dummy__'));
+
+		return rv;
+	},
+
+	/**
+	 * Registers a new {@link LuCI.Network.Protocol Protocol} subclass
+	 * with the given methods and returns the resulting subclass value.
+	 *
+	 * This functions internally calls
+	 * {@link LuCI.Class.extend Class.extend()} on the `Network.Protocol`
+	 * base class.
+	 *
+	 * @param {string} protoname
+	 * The name of the new protocol to register.
+	 *
+	 * @param {Object<string, *>} methods
+	 * The member methods and values of the new `Protocol` subclass to
+	 * be passed to {@link LuCI.Class.extend Class.extend()}.
+	 *
+	 * @returns {LuCI.Network.Protocol}
+	 * Returns the new `Protocol` subclass.
+	 */
+	registerProtocol: function(protoname, methods) {
+		var spec = L.isObject(_protospecs) ? _protospecs[protoname] : null;
+		var proto = Protocol.extend(Object.assign({
+			getI18n: function() {
+				return protoname;
+			},
+
+			isFloating: function() {
+				return false;
+			},
+
+			isVirtual: function() {
+				return (L.isObject(spec) && spec.no_device == true);
+			},
+
+			renderFormOptions: function(section) {
+
+			}
+		}, methods, {
+			__init__: function(name) {
+				this.sid = name;
+			},
+
+			getProtocol: function() {
+				return protoname;
+			}
+		}));
+
+		_protocols[protoname] = proto;
+
+		return proto;
+	},
+
+	/**
+	 * Registers a new regular expression pattern to recognize
+	 * virtual interfaces.
+	 *
+	 * @param {RegExp} pat
+	 * A `RegExp` instance to match a virtual interface name
+	 * such as `6in4-wan` or `tun0`.
+	 */
+	registerPatternVirtual: function(pat) {
+		iface_patterns_virtual.push(pat);
+	},
+
+	/**
+	 * Registers a new human readable translation string for a `Protocol`
+	 * error code.
+	 *
+	 * @param {string} code
+	 * The `ubus` protocol error code to register a translation for, e.g.
+	 * `NO_DEVICE`.
+	 *
+	 * @param {string} message
+	 * The message to use as translation for the given protocol error code.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` if the error code description has been added or `false`
+	 * if either the arguments were invalid or if there already was a
+	 * description for the given code.
+	 */
+	registerErrorCode: function(code, message) {
+		if (typeof(code) == 'string' &&
+		    typeof(message) == 'string' &&
+		    !proto_errors.hasOwnProperty(code)) {
+			proto_errors[code] = message;
+			return true;
+		}
+
+		return false;
+	},
+
+	/**
+	 * Adds a new network of the given name and update it with the given
+	 * uci option values.
+	 *
+	 * If a network with the given name already exist but is empty, then
+	 * this function will update its option, otherwise it will do nothing.
+	 *
+	 * @param {string} name
+	 * The name of the network to add. Must be in the format `[a-zA-Z0-9_]+`.
+	 *
+	 * @param {Object<string, string|string[]>} [options]
+	 * An object of uci option values to set on the new network or to
+	 * update in an existing, empty network.
+	 *
+	 * @returns {Promise<null|LuCI.Network.Protocol>}
+	 * Returns a promise resolving to the `Protocol` subclass instance
+	 * describing the added network or resolving to `null` if the name
+	 * was invalid or if a non-empty network of the given name already
+	 * existed.
+	 */
+	addNetwork: function(name, options) {
+		return this.getNetwork(name).then(L.bind(function(existingNetwork) {
+			if (name != null && /^[a-zA-Z0-9_]+$/.test(name) && existingNetwork == null) {
+				var sid = uci.add('network', 'interface', name);
+
+				if (sid != null) {
+					if (L.isObject(options))
+						for (var key in options)
+							if (options.hasOwnProperty(key))
+								uci.set('network', sid, key, options[key]);
+
+					return this.instantiateNetwork(sid);
+				}
+			}
+			else if (existingNetwork != null && existingNetwork.isEmpty()) {
+				if (L.isObject(options))
+					for (var key in options)
+						if (options.hasOwnProperty(key))
+							existingNetwork.set(key, options[key]);
+
+				return existingNetwork;
+			}
+		}, this));
+	},
+
+	/**
+	 * Get a {@link LuCI.Network.Protocol Protocol} instance describing
+	 * the network with the given name.
+	 *
+	 * @param {string} name
+	 * The logical interface name of the network get, e.g. `lan` or `wan`.
+	 *
+	 * @returns {Promise<null|LuCI.Network.Protocol>}
+	 * Returns a promise resolving to a
+	 * {@link LuCI.Network.Protocol Protocol} subclass instance describing
+	 * the network or `null` if the network did not exist.
+	 */
+	getNetwork: function(name) {
+		return initNetworkState().then(L.bind(function() {
+			var section = (name != null) ? uci.get('network', name) : null;
+
+			if (section != null && section['.type'] == 'interface') {
+				return this.instantiateNetwork(name);
+			}
+			else if (name != null) {
+				for (var i = 0; i < _state.ifaces.length; i++)
+					if (_state.ifaces[i].interface == name)
+						return this.instantiateNetwork(name, _state.ifaces[i].proto);
+			}
+
+			return null;
+		}, this));
+	},
+
+	/**
+	 * Gets an array containing all known networks.
+	 *
+	 * @returns {Promise<Array<LuCI.Network.Protocol>>}
+	 * Returns a promise resolving to a name-sorted array of
+	 * {@link LuCI.Network.Protocol Protocol} subclass instances
+	 * describing all known networks.
+	 */
+	getNetworks: function() {
+		return initNetworkState().then(L.bind(enumerateNetworks, this));
+	},
+
+	/**
+	 * Deletes the given network and its references from the network and
+	 * firewall configuration.
+	 *
+	 * @param {string} name
+	 * The name of the network to delete.
+	 *
+	 * @returns {Promise<boolean>}
+	 * Returns a promise resolving to either `true` if the network and
+	 * references to it were successfully deleted from the configuration or
+	 * `false` if the given network could not be found.
+	 */
+	deleteNetwork: function(name) {
+		var requireFirewall = Promise.resolve(L.require('firewall')).catch(function() {});
+
+		return Promise.all([ requireFirewall, initNetworkState() ]).then(function() {
+			var uciInterface = uci.get('network', name);
+
+			if (uciInterface != null && uciInterface['.type'] == 'interface') {
+				uci.remove('network', name);
+
+				uci.sections('luci', 'ifstate', function(s) {
+					if (s.interface == name)
+						uci.remove('luci', s['.name']);
+				});
+
+				uci.sections('network', 'alias', function(s) {
+					if (s.interface == name)
+						uci.remove('network', s['.name']);
+				});
+
+				uci.sections('network', 'route', function(s) {
+					if (s.interface == name)
+						uci.remove('network', s['.name']);
+				});
+
+				uci.sections('network', 'route6', function(s) {
+					if (s.interface == name)
+						uci.remove('network', s['.name']);
+				});
+
+				uci.sections('wireless', 'wifi-iface', function(s) {
+					var networks = L.toArray(s.network).filter(function(network) { return network != name });
+
+					if (networks.length > 0)
+						uci.set('wireless', s['.name'], 'network', networks.join(' '));
+					else
+						uci.unset('wireless', s['.name'], 'network');
+				});
+
+				if (L.firewall)
+					return L.firewall.deleteNetwork(name).then(function() { return true });
+
+				return true;
+			}
+
+			return false;
+		});
+	},
+
+	/**
+	 * Rename the given network and its references to a new name.
+	 *
+	 * @param {string} oldName
+	 * The current name of the network.
+	 *
+	 * @param {string} newName
+	 * The name to rename the network to, must be in the format
+	 * `[a-z-A-Z0-9_]+`.
+	 *
+	 * @returns {Promise<boolean>}
+	 * Returns a promise resolving to either `true` if the network was
+	 * successfully renamed or `false` if the new name was invalid, if
+	 * a network with the new name already exists or if the network to
+	 * rename could not be found.
+	 */
+	renameNetwork: function(oldName, newName) {
+		return initNetworkState().then(function() {
+			if (newName == null || !/^[a-zA-Z0-9_]+$/.test(newName) || uci.get('network', newName) != null)
+				return false;
+
+			var oldNetwork = uci.get('network', oldName);
+
+			if (oldNetwork == null || oldNetwork['.type'] != 'interface')
+				return false;
+
+			var sid = uci.add('network', 'interface', newName);
+
+			for (var key in oldNetwork)
+				if (oldNetwork.hasOwnProperty(key) && key.charAt(0) != '.')
+					uci.set('network', sid, key, oldNetwork[key]);
+
+			uci.sections('luci', 'ifstate', function(s) {
+				if (s.interface == oldName)
+					uci.set('luci', s['.name'], 'interface', newName);
+			});
+
+			uci.sections('network', 'alias', function(s) {
+				if (s.interface == oldName)
+					uci.set('network', s['.name'], 'interface', newName);
+			});
+
+			uci.sections('network', 'route', function(s) {
+				if (s.interface == oldName)
+					uci.set('network', s['.name'], 'interface', newName);
+			});
+
+			uci.sections('network', 'route6', function(s) {
+				if (s.interface == oldName)
+					uci.set('network', s['.name'], 'interface', newName);
+			});
+
+			uci.sections('wireless', 'wifi-iface', function(s) {
+				var networks = L.toArray(s.network).map(function(network) { return (network == oldName ? newName : network) });
+
+				if (networks.length > 0)
+					uci.set('wireless', s['.name'], 'network', networks.join(' '));
+			});
+
+			uci.remove('network', oldName);
+
+			return true;
+		});
+	},
+
+	/**
+	 * Get a {@link LuCI.Network.Device Device} instance describing the
+	 * given network device.
+	 *
+	 * @param {string} name
+	 * The name of the network device to get, e.g. `eth0` or `br-lan`.
+	 *
+	 * @returns {Promise<null|LuCI.Network.Device>}
+	 * Returns a promise resolving to the `Device` instance describing
+	 * the network device or `null` if the given device name could not
+	 * be found.
+	 */
+	getDevice: function(name) {
+		return initNetworkState().then(L.bind(function() {
+			if (name == null)
+				return null;
+
+			if (_state.netdevs.hasOwnProperty(name) || isWifiIfname(name))
+				return this.instantiateDevice(name);
+
+			var netid = getWifiNetidBySid(name);
+			if (netid != null)
+				return this.instantiateDevice(netid[0]);
+
+			return null;
+		}, this));
+	},
+
+	/**
+	 * Get a sorted list of all found network devices.
+	 *
+	 * @returns {Promise<Array<LuCI.Network.Device>>}
+	 * Returns a promise resolving to a sorted array of `Device` class
+	 * instances describing the network devices found on the system.
+	 */
+	getDevices: function() {
+		return initNetworkState().then(L.bind(function() {
+			var devices = {};
+
+			/* find simple devices */
+			var uciInterfaces = uci.sections('network', 'interface');
+			for (var i = 0; i < uciInterfaces.length; i++) {
+				var ifnames = L.toArray(uciInterfaces[i].ifname);
+
+				for (var j = 0; j < ifnames.length; j++) {
+					if (ifnames[j].charAt(0) == '@')
+						continue;
+
+					if (isIgnoredIfname(ifnames[j]) || isVirtualIfname(ifnames[j]) || isWifiIfname(ifnames[j]))
+						continue;
+
+					devices[ifnames[j]] = this.instantiateDevice(ifnames[j]);
+				}
+			}
+
+			for (var ifname in _state.netdevs) {
+				if (devices.hasOwnProperty(ifname))
+					continue;
+
+				if (isIgnoredIfname(ifname) || isVirtualIfname(ifname) || isWifiIfname(ifname))
+					continue;
+
+				devices[ifname] = this.instantiateDevice(ifname);
+			}
+
+			/* find VLAN devices */
+			var uciSwitchVLANs = uci.sections('network', 'switch_vlan');
+			for (var i = 0; i < uciSwitchVLANs.length; i++) {
+				if (typeof(uciSwitchVLANs[i].ports) != 'string' ||
+				    typeof(uciSwitchVLANs[i].device) != 'string' ||
+				    !_state.switches.hasOwnProperty(uciSwitchVLANs[i].device))
+					continue;
+
+				var ports = uciSwitchVLANs[i].ports.split(/\s+/);
+				for (var j = 0; j < ports.length; j++) {
+					var m = ports[j].match(/^(\d+)([tu]?)$/);
+					if (m == null)
+						continue;
+
+					var netdev = _state.switches[uciSwitchVLANs[i].device].netdevs[m[1]];
+					if (netdev == null)
+						continue;
+
+					if (!devices.hasOwnProperty(netdev))
+						devices[netdev] = this.instantiateDevice(netdev);
+
+					_state.isSwitch[netdev] = true;
+
+					if (m[2] != 't')
+						continue;
+
+					var vid = uciSwitchVLANs[i].vid || uciSwitchVLANs[i].vlan;
+					    vid = (vid != null ? +vid : null);
+
+					if (vid == null || vid < 0 || vid > 4095)
+						continue;
+
+					var vlandev = '%s.%d'.format(netdev, vid);
+
+					if (!devices.hasOwnProperty(vlandev))
+						devices[vlandev] = this.instantiateDevice(vlandev);
+
+					_state.isSwitch[vlandev] = true;
+				}
+			}
+
+			/* find wireless interfaces */
+			var uciWifiIfaces = uci.sections('wireless', 'wifi-iface'),
+			    networkCount = {};
+
+			for (var i = 0; i < uciWifiIfaces.length; i++) {
+				if (typeof(uciWifiIfaces[i].device) != 'string')
+					continue;
+
+				networkCount[uciWifiIfaces[i].device] = (networkCount[uciWifiIfaces[i].device] || 0) + 1;
+
+				var netid = '%s.network%d'.format(uciWifiIfaces[i].device, networkCount[uciWifiIfaces[i].device]);
+
+				devices[netid] = this.instantiateDevice(netid);
+			}
+
+			var rv = [];
+
+			for (var netdev in devices)
+				if (devices.hasOwnProperty(netdev))
+					rv.push(devices[netdev]);
+
+			rv.sort(deviceSort);
+
+			return rv;
+		}, this));
+	},
+
+	/**
+	 * Test if a given network device name is in the list of patterns for
+	 * device names to ignore.
+	 *
+	 * Ignored device names are usually Linux network devices which are
+	 * spawned implicitly by kernel modules such as `tunl0` or `hwsim0`
+	 * and which are unsuitable for use in network configuration.
+	 *
+	 * @param {string} name
+	 * The device name to test.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` if the given name is in the ignore pattern list,
+	 * else returns `false`.
+	 */
+	isIgnoredDevice: function(name) {
+		return isIgnoredIfname(name);
+	},
+
+	/**
+	 * Get a {@link LuCI.Network.WifiDevice WifiDevice} instance describing
+	 * the given wireless radio.
+	 *
+	 * @param {string} devname
+	 * The configuration name of the wireless radio to lookup, e.g. `radio0`
+	 * for the first mac80211 phy on the system.
+	 *
+	 * @returns {Promise<null|LuCI.Network.WifiDevice>}
+	 * Returns a promise resolving to the `WifiDevice` instance describing
+	 * the underlying radio device or `null` if the wireless radio could not
+	 * be found.
+	 */
+	getWifiDevice: function(devname) {
+		return initNetworkState().then(L.bind(function() {
+			var existingDevice = uci.get('wireless', devname);
+
+			if (existingDevice == null || existingDevice['.type'] != 'wifi-device')
+				return null;
+
+			return this.instantiateWifiDevice(devname, _state.radios[devname] || {});
+		}, this));
+	},
+
+	/**
+	 * Obtain a list of all configured radio devices.
+	 *
+	 * @returns {Promise<Array<LuCI.Network.WifiDevice>>}
+	 * Returns a promise resolving to an array of `WifiDevice` instances
+	 * describing the wireless radios configured in the system.
+	 * The order of the array corresponds to the order of the radios in
+	 * the configuration.
+	 */
+	getWifiDevices: function() {
+		return initNetworkState().then(L.bind(function() {
+			var uciWifiDevices = uci.sections('wireless', 'wifi-device'),
+			    rv = [];
+
+			for (var i = 0; i < uciWifiDevices.length; i++) {
+				var devname = uciWifiDevices[i]['.name'];
+				rv.push(this.instantiateWifiDevice(devname, _state.radios[devname] || {}));
+			}
+
+			return rv;
+		}, this));
+	},
+
+	/**
+	 * Get a {@link LuCI.Network.WifiNetwork WifiNetwork} instance describing
+	 * the given wireless network.
+	 *
+	 * @param {string} netname
+	 * The name of the wireless network to lookup. This may be either an uci
+	 * configuration section ID, a network ID in the form `radio#.network#`
+	 * or a Linux network device name like `wlan0` which is resolved to the
+	 * corresponding configuration section through `ubus` runtime information.
+	 *
+	 * @returns {Promise<null|LuCI.Network.WifiNetwork>}
+	 * Returns a promise resolving to the `WifiNetwork` instance describing
+	 * the wireless network or `null` if the corresponding network could not
+	 * be found.
+	 */
+	getWifiNetwork: function(netname) {
+		var sid, res, netid, radioname, radiostate, netstate;
+
+		return initNetworkState().then(L.bind(function() {
+			sid = getWifiSidByNetid(netname);
+
+			if (sid != null) {
+				res        = getWifiStateBySid(sid);
+				netid      = netname;
+				radioname  = res ? res[0] : null;
+				radiostate = res ? res[1] : null;
+				netstate   = res ? res[2] : null;
+			}
+			else {
+				res = getWifiStateByIfname(netname);
+
+				if (res != null) {
+					radioname  = res[0];
+					radiostate = res[1];
+					netstate   = res[2];
+					sid        = netstate.section;
+					netid      = L.toArray(getWifiNetidBySid(sid))[0];
+				}
+				else {
+					res = getWifiStateBySid(netname);
+
+					if (res != null) {
+						radioname  = res[0];
+						radiostate = res[1];
+						netstate   = res[2];
+						sid        = netname;
+						netid      = L.toArray(getWifiNetidBySid(sid))[0];
+					}
+					else {
+						res = getWifiNetidBySid(netname);
+
+						if (res != null) {
+							netid     = res[0];
+							radioname = res[1];
+							sid       = netname;
+						}
+					}
+				}
+			}
+
+			return this.instantiateWifiNetwork(sid || netname, radioname, radiostate, netid, netstate);
+		}, this));
+	},
+
+	/**
+	 * Adds a new wireless network to the configuration and sets its options
+	 * to the provided values.
+	 *
+	 * @param {Object<string, string|string[]>} options
+	 * The options to set for the newly added wireless network. This object
+	 * must at least contain a `device` property which is set to the radio
+	 * name the new network belongs to.
+	 *
+	 * @returns {Promise<null|LuCI.Network.WifiNetwork>}
+	 * Returns a promise resolving to a `WifiNetwork` instance describing
+	 * the newly added wireless network or `null` if the given options
+	 * were invalid or if the associated radio device could not be found.
+	 */
+	addWifiNetwork: function(options) {
+		return initNetworkState().then(L.bind(function() {
+			if (options == null ||
+			    typeof(options) != 'object' ||
+			    typeof(options.device) != 'string')
+			    return null;
+
+			var existingDevice = uci.get('wireless', options.device);
+			if (existingDevice == null || existingDevice['.type'] != 'wifi-device')
+				return null;
+
+			/* XXX: need to add a named section (wifinet#) here */
+			var sid = uci.add('wireless', 'wifi-iface');
+			for (var key in options)
+				if (options.hasOwnProperty(key))
+					uci.set('wireless', sid, key, options[key]);
+
+			var radioname = existingDevice['.name'],
+			    netid = getWifiNetidBySid(sid) || [];
+
+			return this.instantiateWifiNetwork(sid, radioname, _state.radios[radioname], netid[0], null);
+		}, this));
+	},
+
+	/**
+	 * Deletes the given wireless network from the configuration.
+	 *
+	 * @param {string} netname
+	 * The name of the network to remove. This may be either a
+	 * network ID in the form `radio#.network#` or a Linux network device
+	 * name like `wlan0` which is resolved to the corresponding configuration
+	 * section through `ubus` runtime information.
+	 *
+	 * @returns {Promise<boolean>}
+	 * Returns a promise resolving to `true` if the wireless network has been
+	 * successfully deleted from the configuration or `false` if it could not
+	 * be found.
+	 */
+	deleteWifiNetwork: function(netname) {
+		return initNetworkState().then(L.bind(function() {
+			var sid = getWifiSidByIfname(netname);
+
+			if (sid == null)
+				return false;
+
+			uci.remove('wireless', sid);
+			return true;
+		}, this));
+	},
+
+	/* private */
+	getStatusByRoute: function(addr, mask) {
+		return initNetworkState().then(L.bind(function() {
+			var rv = [];
+
+			for (var i = 0; i < _state.ifaces.length; i++) {
+				if (!Array.isArray(_state.ifaces[i].route))
+					continue;
+
+				for (var j = 0; j < _state.ifaces[i].route.length; j++) {
+					if (typeof(_state.ifaces[i].route[j]) != 'object' ||
+					    typeof(_state.ifaces[i].route[j].target) != 'string' ||
+					    typeof(_state.ifaces[i].route[j].mask) != 'number')
+					    continue;
+
+					if (_state.ifaces[i].route[j].table)
+						continue;
+
+					if (_state.ifaces[i].route[j].target != addr ||
+					    _state.ifaces[i].route[j].mask != mask)
+					    continue;
+
+					rv.push(_state.ifaces[i]);
+				}
+			}
+
+			return rv;
+		}, this));
+	},
+
+	/* private */
+	getStatusByAddress: function(addr) {
+		return initNetworkState().then(L.bind(function() {
+			var rv = [];
+
+			for (var i = 0; i < _state.ifaces.length; i++) {
+				if (Array.isArray(_state.ifaces[i]['ipv4-address']))
+					for (var j = 0; j < _state.ifaces[i]['ipv4-address'].length; j++)
+						if (typeof(_state.ifaces[i]['ipv4-address'][j]) == 'object' &&
+						    _state.ifaces[i]['ipv4-address'][j].address == addr)
+							return _state.ifaces[i];
+
+				if (Array.isArray(_state.ifaces[i]['ipv6-address']))
+					for (var j = 0; j < _state.ifaces[i]['ipv6-address'].length; j++)
+						if (typeof(_state.ifaces[i]['ipv6-address'][j]) == 'object' &&
+						    _state.ifaces[i]['ipv6-address'][j].address == addr)
+							return _state.ifaces[i];
+
+				if (Array.isArray(_state.ifaces[i]['ipv6-prefix-assignment']))
+					for (var j = 0; j < _state.ifaces[i]['ipv6-prefix-assignment'].length; j++)
+						if (typeof(_state.ifaces[i]['ipv6-prefix-assignment'][j]) == 'object' &&
+							typeof(_state.ifaces[i]['ipv6-prefix-assignment'][j]['local-address']) == 'object' &&
+						    _state.ifaces[i]['ipv6-prefix-assignment'][j]['local-address'].address == addr)
+							return _state.ifaces[i];
+			}
+
+			return null;
+		}, this));
+	},
+
+	/**
+	 * Get IPv4 wan networks.
+	 *
+	 * This function looks up all networks having a default `0.0.0.0/0` route
+	 * and returns them as array.
+	 *
+	 * @returns {Promise<Array<LuCI.Network.Protocol>>}
+	 * Returns a promise resolving to an array of `Protocol` subclass
+	 * instances describing the found default route interfaces.
+	 */
+	getWANNetworks: function() {
+		return this.getStatusByRoute('0.0.0.0', 0).then(L.bind(function(statuses) {
+			var rv = [];
+
+			for (var i = 0; i < statuses.length; i++)
+				rv.push(this.instantiateNetwork(statuses[i].interface, statuses[i].proto));
+
+			return rv;
+		}, this));
+	},
+
+	/**
+	 * Get IPv6 wan networks.
+	 *
+	 * This function looks up all networks having a default `::/0` route
+	 * and returns them as array.
+	 *
+	 * @returns {Promise<Array<LuCI.Network.Protocol>>}
+	 * Returns a promise resolving to an array of `Protocol` subclass
+	 * instances describing the found IPv6 default route interfaces.
+	 */
+	getWAN6Networks: function() {
+		return this.getStatusByRoute('::', 0).then(L.bind(function(statuses) {
+			var rv = [];
+
+			for (var i = 0; i < statuses.length; i++)
+				rv.push(this.instantiateNetwork(statuses[i].interface, statuses[i].proto));
+
+			return rv;
+		}, this));
+	},
+
+	/**
+	 * Describes an swconfig switch topology by specifying the CPU
+	 * connections and external port labels of a switch.
+	 *
+	 * @typedef {Object<string, Object|Array>} SwitchTopology
+	 * @memberof LuCI.Network
+	 *
+	 * @property {Object<number, string>} netdevs
+	 * The `netdevs` property points to an object describing the CPU port
+	 * connections of the switch. The numeric key of the enclosed object is
+	 * the port number, the value contains the Linux network device name the
+	 * port is hardwired to.
+	 *
+	 * @property {Array<Object<string, boolean|number|string>>} ports
+	 * The `ports` property points to an array describing the populated
+	 * ports of the switch in the external label order. Each array item is
+	 * an object containg the following keys:
+	 *  - `num` - the internal switch port number
+	 *  - `label` - the label of the port, e.g. `LAN 1` or `CPU (eth0)`
+	 *  - `device` - the connected Linux network device name (CPU ports only)
+	 *  - `tagged` - a boolean indicating whether the port must be tagged to
+	 *     function (CPU ports only)
+	 */
+
+	/**
+	 * Returns the topologies of all swconfig switches found on the system.
+	 *
+	 * @returns {Promise<Object<string, LuCI.Network.SwitchTopology>>}
+	 * Returns a promise resolving to an object containing the topologies
+	 * of each switch. The object keys correspond to the name of the switches
+	 * such as `switch0`, the values are
+	 * {@link LuCI.Network.SwitchTopology SwitchTopology} objects describing
+	 * the layout.
+	 */
+	getSwitchTopologies: function() {
+		return initNetworkState().then(function() {
+			return _state.switches;
+		});
+	},
+
+	/* private */
+	instantiateNetwork: function(name, proto) {
+		if (name == null)
+			return null;
+
+		proto = (proto == null ? uci.get('network', name, 'proto') : proto);
+
+		var protoClass = _protocols[proto] || Protocol;
+		return new protoClass(name);
+	},
+
+	/* private */
+	instantiateDevice: function(name, network, extend) {
+		if (extend != null)
+			return new (Device.extend(extend))(name, network);
+
+		return new Device(name, network);
+	},
+
+	/* private */
+	instantiateWifiDevice: function(radioname, radiostate) {
+		return new WifiDevice(radioname, radiostate);
+	},
+
+	/* private */
+	instantiateWifiNetwork: function(sid, radioname, radiostate, netid, netstate) {
+		return new WifiNetwork(sid, radioname, radiostate, netid, netstate);
+	},
+
+	/**
+	 * Obtains the the network device name of the given object.
+	 *
+	 * @param {LuCI.Network.Protocol|LuCI.Network.Device|LuCI.Network.WifiDevice|LuCI.Network.WifiNetwork|string} obj
+	 * The object to get the device name from.
+	 *
+	 * @returns {null|string}
+	 * Returns a string containing the device name or `null` if the given
+	 * object could not be converted to a name.
+	 */
+	getIfnameOf: function(obj) {
+		return ifnameOf(obj);
+	},
+
+	/**
+	 * Queries the internal DSL modem type from board information.
+	 *
+	 * @returns {Promise<null|string>}
+	 * Returns a promise resolving to the type of the internal modem
+	 * (e.g. `vdsl`) or to `null` if no internal modem is present.
+	 */
+	getDSLModemType: function() {
+		return initNetworkState().then(function() {
+			return _state.hasDSLModem ? _state.hasDSLModem.type : null;
+		});
+	},
+
+	/**
+	 * Queries aggregated information about known hosts.
+	 *
+	 * This function aggregates information from various sources such as
+	 * DHCP lease databases, ARP and IPv6 neighbour entries, wireless
+	 * association list etc. and returns a {@link LuCI.Network.Hosts Hosts}
+	 * class instance describing the found hosts.
+	 *
+	 * @returns {Promise<LuCI.Network.Hosts>}
+	 * Returns a `Hosts` instance describing host known on the system.
+	 */
+	getHostHints: function() {
+		return initNetworkState().then(function() {
+			return new Hosts(_state.hosts);
+		});
+	}
+});
+
+/**
+ * @class
+ * @memberof LuCI.Network
+ * @hideconstructor
+ * @classdesc
+ *
+ * The `LuCI.Network.Hosts` class encapsulates host information aggregated
+ * from multiple sources and provides convenience functions to access the
+ * host information by different criteria.
+ */
+Hosts = L.Class.extend(/** @lends LuCI.Network.Hosts.prototype */ {
+	__init__: function(hosts) {
+		this.hosts = hosts;
+	},
+
+	/**
+	 * Lookup the hostname associated with the given MAC address.
+	 *
+	 * @param {string} mac
+	 * The MAC address to lookup.
+	 *
+	 * @returns {null|string}
+	 * Returns the hostname associated with the given MAC or `null` if
+	 * no matching host could be found or if no hostname is known for
+	 * the corresponding host.
+	 */
+	getHostnameByMACAddr: function(mac) {
+		return this.hosts[mac] ? this.hosts[mac].name : null;
+	},
+
+	/**
+	 * Lookup the IPv4 address associated with the given MAC address.
+	 *
+	 * @param {string} mac
+	 * The MAC address to lookup.
+	 *
+	 * @returns {null|string}
+	 * Returns the IPv4 address associated with the given MAC or `null` if
+	 * no matching host could be found or if no IPv4 address is known for
+	 * the corresponding host.
+	 */
+	getIPAddrByMACAddr: function(mac) {
+		return this.hosts[mac] ? this.hosts[mac].ipv4 : null;
+	},
+
+	/**
+	 * Lookup the IPv6 address associated with the given MAC address.
+	 *
+	 * @param {string} mac
+	 * The MAC address to lookup.
+	 *
+	 * @returns {null|string}
+	 * Returns the IPv6 address associated with the given MAC or `null` if
+	 * no matching host could be found or if no IPv6 address is known for
+	 * the corresponding host.
+	 */
+	getIP6AddrByMACAddr: function(mac) {
+		return this.hosts[mac] ? this.hosts[mac].ipv6 : null;
+	},
+
+	/**
+	 * Lookup the hostname associated with the given IPv4 address.
+	 *
+	 * @param {string} ipaddr
+	 * The IPv4 address to lookup.
+	 *
+	 * @returns {null|string}
+	 * Returns the hostname associated with the given IPv4 or `null` if
+	 * no matching host could be found or if no hostname is known for
+	 * the corresponding host.
+	 */
+	getHostnameByIPAddr: function(ipaddr) {
+		for (var mac in this.hosts)
+			if (this.hosts[mac].ipv4 == ipaddr && this.hosts[mac].name != null)
+				return this.hosts[mac].name;
+		return null;
+	},
+
+	/**
+	 * Lookup the MAC address associated with the given IPv4 address.
+	 *
+	 * @param {string} ipaddr
+	 * The IPv4 address to lookup.
+	 *
+	 * @returns {null|string}
+	 * Returns the MAC address associated with the given IPv4 or `null` if
+	 * no matching host could be found or if no MAC address is known for
+	 * the corresponding host.
+	 */
+	getMACAddrByIPAddr: function(ipaddr) {
+		for (var mac in this.hosts)
+			if (this.hosts[mac].ipv4 == ipaddr)
+				return mac;
+		return null;
+	},
+
+	/**
+	 * Lookup the hostname associated with the given IPv6 address.
+	 *
+	 * @param {string} ipaddr
+	 * The IPv6 address to lookup.
+	 *
+	 * @returns {null|string}
+	 * Returns the hostname associated with the given IPv6 or `null` if
+	 * no matching host could be found or if no hostname is known for
+	 * the corresponding host.
+	 */
+	getHostnameByIP6Addr: function(ip6addr) {
+		for (var mac in this.hosts)
+			if (this.hosts[mac].ipv6 == ip6addr && this.hosts[mac].name != null)
+				return this.hosts[mac].name;
+		return null;
+	},
+
+	/**
+	 * Lookup the MAC address associated with the given IPv6 address.
+	 *
+	 * @param {string} ipaddr
+	 * The IPv6 address to lookup.
+	 *
+	 * @returns {null|string}
+	 * Returns the MAC address associated with the given IPv6 or `null` if
+	 * no matching host could be found or if no MAC address is known for
+	 * the corresponding host.
+	 */
+	getMACAddrByIP6Addr: function(ip6addr) {
+		for (var mac in this.hosts)
+			if (this.hosts[mac].ipv6 == ip6addr)
+				return mac;
+		return null;
+	},
+
+	/**
+	 * Return an array of (MAC address, name hint) tuples sorted by
+	 * MAC address.
+	 *
+	 * @param {boolean} [preferIp6=false]
+	 * Whether to prefer IPv6 addresses (`true`) or IPv4 addresses (`false`)
+	 * as name hint when no hostname is known for a specific MAC address.
+	 *
+	 * @returns {Array<Array<string>>}
+	 * Returns an array of arrays containing a name hint for each found
+	 * MAC address on the system. The array is sorted ascending by MAC.
+	 *
+	 * Each item of the resulting array is a two element array with the
+	 * MAC being the first element and the name hint being the second
+	 * element. The name hint is either the hostname, an IPv4 or an IPv6
+	 * address related to the MAC address.
+	 *
+	 * If no hostname but both IPv4 and IPv6 addresses are known, the
+	 * `preferIP6` flag specifies whether the IPv6 or the IPv4 address
+	 * is used as hint.
+	 */
+	getMACHints: function(preferIp6) {
+		var rv = [];
+		for (var mac in this.hosts) {
+			var hint = this.hosts[mac].name ||
+				this.hosts[mac][preferIp6 ? 'ipv6' : 'ipv4'] ||
+				this.hosts[mac][preferIp6 ? 'ipv4' : 'ipv6'];
+
+			rv.push([mac, hint]);
+		}
+		return rv.sort(function(a, b) { return a[0] > b[0] });
+	}
+});
+
+/**
+ * @class
+ * @memberof LuCI.Network
+ * @hideconstructor
+ * @classdesc
+ *
+ * The `Network.Protocol` class serves as base for protocol specific
+ * subclasses which describe logical UCI networks defined by `config
+ * interface` sections in `/etc/config/network`.
+ */
+Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ {
+	__init__: function(name) {
+		this.sid = name;
+	},
+
+	_get: function(opt) {
+		var val = uci.get('network', this.sid, opt);
+
+		if (Array.isArray(val))
+			return val.join(' ');
+
+		return val || '';
+	},
+
+	_ubus: function(field) {
+		for (var i = 0; i < _state.ifaces.length; i++) {
+			if (_state.ifaces[i].interface != this.sid)
+				continue;
+
+			return (field != null ? _state.ifaces[i][field] : _state.ifaces[i]);
+		}
+	},
+
+	/**
+	 * Read the given UCI option value of this network.
+	 *
+	 * @param {string} opt
+	 * The UCI option name to read.
+	 *
+	 * @returns {null|string|string[]}
+	 * Returns the UCI option value or `null` if the requested option is
+	 * not found.
+	 */
+	get: function(opt) {
+		return uci.get('network', this.sid, opt);
+	},
+
+	/**
+	 * Set the given UCI option of this network to the given value.
+	 *
+	 * @param {string} opt
+	 * The name of the UCI option to set.
+	 *
+	 * @param {null|string|string[]} val
+	 * The value to set or `null` to remove the given option from the
+	 * configuration.
+	 */
+	set: function(opt, val) {
+		return uci.set('network', this.sid, opt, val);
+	},
+
+	/**
+	 * Get the associared Linux network device of this network.
+	 *
+	 * @returns {null|string}
+	 * Returns the name of the associated network device or `null` if
+	 * it could not be determined.
+	 */
+	getIfname: function() {
+		var ifname;
+
+		if (this.isFloating())
+			ifname = this._ubus('l3_device');
+		else
+			ifname = this._ubus('device') || this._ubus('l3_device');
+
+		if (ifname != null)
+			return ifname;
+
+		var res = getWifiNetidByNetname(this.sid);
+		return (res != null ? res[0] : null);
+	},
+
+	/**
+	 * Get the name of this network protocol class.
+	 *
+	 * This function will be overwritten by subclasses created by
+	 * {@link LuCI.Network#registerProtocol Network.registerProtocol()}.
+	 *
+	 * @abstract
+	 * @returns {string}
+	 * Returns the name of the network protocol implementation, e.g.
+	 * `static` or `dhcp`.
+	 */
+	getProtocol: function() {
+		return null;
+	},
+
+	/**
+	 * Return a human readable description for the protcol, such as
+	 * `Static address` or `DHCP client`.
+	 *
+	 * This function should be overwritten by subclasses.
+	 *
+	 * @abstract
+	 * @returns {string}
+	 * Returns the description string.
+	 */
+	getI18n: function() {
+		switch (this.getProtocol()) {
+		case 'none':   return _('Unmanaged');
+		case 'static': return _('Static address');
+		case 'dhcp':   return _('DHCP client');
+		default:       return _('Unknown');
+		}
+	},
+
+	/**
+	 * Get the type of the underlying interface.
+	 *
+	 * This function actually is a convenience wrapper around
+	 * `proto.get("type")` and is mainly used by other `LuCI.Network` code
+	 * to check whether the interface is declared as bridge in UCI.
+	 *
+	 * @returns {null|string}
+	 * Returns the value of the `type` option of the associated logical
+	 * interface or `null` if no `type` option is set.
+	 */
+	getType: function() {
+		return this._get('type');
+	},
+
+	/**
+	 * Get the name of the associated logical interface.
+	 *
+	 * @returns {string}
+	 * Returns the logical interface name, such as `lan` or `wan`.
+	 */
+	getName: function() {
+		return this.sid;
+	},
+
+	/**
+	 * Get the uptime of the logical interface.
+	 *
+	 * @returns {number}
+	 * Returns the uptime of the associated interface in seconds.
+	 */
+	getUptime: function() {
+		return this._ubus('uptime') || 0;
+	},
+
+	/**
+	 * Get the logical interface expiry time in seconds.
+	 *
+	 * For protocols that have a concept of a lease, such as DHCP or
+	 * DHCPv6, this function returns the remaining time in seconds
+	 * until the lease expires.
+	 *
+	 * @returns {number}
+	 * Returns the amount of seconds until the lease expires or `-1`
+	 * if it isn't applicable to the associated protocol.
+	 */
+	getExpiry: function() {
+		var u = this._ubus('uptime'),
+		    d = this._ubus('data');
+
+		if (typeof(u) == 'number' && d != null &&
+		    typeof(d) == 'object' && typeof(d.leasetime) == 'number') {
+			var r = d.leasetime - (u % d.leasetime);
+			return (r > 0 ? r : 0);
+		}
+
+		return -1;
+	},
+
+	/**
+	 * Get the metric value of the logical interface.
+	 *
+	 * @returns {number}
+	 * Returns the current metric value used for device and network
+	 * routes spawned by the associated logical interface.
+	 */
+	getMetric: function() {
+		return this._ubus('metric') || 0;
+	},
+
+	/**
+	 * Get the requested firewall zone name of the logical interface.
+	 *
+	 * Some protocol implementations request a specific firewall zone
+	 * to trigger inclusion of their resulting network devices into the
+	 * firewall rule set.
+	 *
+	 * @returns {null|string}
+	 * Returns the requested firewall zone name as published in the
+	 * `ubus` runtime information or `null` if the remote protocol
+	 * handler didn't request a zone.
+	 */
+	getZoneName: function() {
+		var d = this._ubus('data');
+
+		if (L.isObject(d) && typeof(d.zone) == 'string')
+			return d.zone;
+
+		return null;
+	},
+
+	/**
+	 * Query the first (primary) IPv4 address of the logical interface.
+	 *
+	 * @returns {null|string}
+	 * Returns the primary IPv4 address registered by the protocol handler
+	 * or `null` if no IPv4 addresses were set.
+	 */
+	getIPAddr: function() {
+		var addrs = this._ubus('ipv4-address');
+		return ((Array.isArray(addrs) && addrs.length) ? addrs[0].address : null);
+	},
+
+	/**
+	 * Query all IPv4 addresses of the logical interface.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of IPv4 addresses in CIDR notation which have been
+	 * registered by the protocol handler. The order of the resulting array
+	 * follows the order of the addresses in `ubus` runtime information.
+	 */
+	getIPAddrs: function() {
+		var addrs = this._ubus('ipv4-address'),
+		    rv = [];
+
+		if (Array.isArray(addrs))
+			for (var i = 0; i < addrs.length; i++)
+				rv.push('%s/%d'.format(addrs[i].address, addrs[i].mask));
+
+		return rv;
+	},
+
+	/**
+	 * Query the first (primary) IPv4 netmask of the logical interface.
+	 *
+	 * @returns {null|string}
+	 * Returns the netmask of the primary IPv4 address registered by the
+	 * protocol handler or `null` if no IPv4 addresses were set.
+	 */
+	getNetmask: function() {
+		var addrs = this._ubus('ipv4-address');
+		if (Array.isArray(addrs) && addrs.length)
+			return prefixToMask(addrs[0].mask, false);
+	},
+
+	/**
+	 * Query the gateway (nexthop) of the default route associated with
+	 * this logical interface.
+	 *
+	 * @returns {string}
+	 * Returns a string containing the IPv4 nexthop address of the associated
+	 * default route or `null` if no default route was found.
+	 */
+	getGatewayAddr: function() {
+		var routes = this._ubus('route');
+
+		if (Array.isArray(routes))
+			for (var i = 0; i < routes.length; i++)
+				if (typeof(routes[i]) == 'object' &&
+				    routes[i].target == '0.0.0.0' &&
+				    routes[i].mask == 0)
+				    return routes[i].nexthop;
+
+		return null;
+	},
+
+	/**
+	 * Query the IPv4 DNS servers associated with the logical interface.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of IPv4 DNS servers registered by the remote
+	 * protocol backend.
+	 */
+	getDNSAddrs: function() {
+		var addrs = this._ubus('dns-server'),
+		    rv = [];
+
+		if (Array.isArray(addrs))
+			for (var i = 0; i < addrs.length; i++)
+				if (!/:/.test(addrs[i]))
+					rv.push(addrs[i]);
+
+		return rv;
+	},
+
+	/**
+	 * Query the first (primary) IPv6 address of the logical interface.
+	 *
+	 * @returns {null|string}
+	 * Returns the primary IPv6 address registered by the protocol handler
+	 * in CIDR notation or `null` if no IPv6 addresses were set.
+	 */
+	getIP6Addr: function() {
+		var addrs = this._ubus('ipv6-address');
+
+		if (Array.isArray(addrs) && L.isObject(addrs[0]))
+			return '%s/%d'.format(addrs[0].address, addrs[0].mask);
+
+		addrs = this._ubus('ipv6-prefix-assignment');
+
+		if (Array.isArray(addrs) && L.isObject(addrs[0]) && L.isObject(addrs[0]['local-address']))
+			return '%s/%d'.format(addrs[0]['local-address'].address, addrs[0]['local-address'].mask);
+
+		return null;
+	},
+
+	/**
+	 * Query all IPv6 addresses of the logical interface.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of IPv6 addresses in CIDR notation which have been
+	 * registered by the protocol handler. The order of the resulting array
+	 * follows the order of the addresses in `ubus` runtime information.
+	 */
+	getIP6Addrs: function() {
+		var addrs = this._ubus('ipv6-address'),
+		    rv = [];
+
+		if (Array.isArray(addrs))
+			for (var i = 0; i < addrs.length; i++)
+				if (L.isObject(addrs[i]))
+					rv.push('%s/%d'.format(addrs[i].address, addrs[i].mask));
+
+		addrs = this._ubus('ipv6-prefix-assignment');
+
+		if (Array.isArray(addrs))
+			for (var i = 0; i < addrs.length; i++)
+				if (L.isObject(addrs[i]) && L.isObject(addrs[i]['local-address']))
+					rv.push('%s/%d'.format(addrs[i]['local-address'].address, addrs[i]['local-address'].mask));
+
+		return rv;
+	},
+
+	/**
+	 * Query the gateway (nexthop) of the IPv6 default route associated with
+	 * this logical interface.
+	 *
+	 * @returns {string}
+	 * Returns a string containing the IPv6 nexthop address of the associated
+	 * default route or `null` if no default route was found.
+	 */
+	getGateway6Addr: function() {
+		var routes = this._ubus('route');
+
+		if (Array.isArray(routes))
+			for (var i = 0; i < routes.length; i++)
+				if (typeof(routes[i]) == 'object' &&
+				    routes[i].target == '::' &&
+				    routes[i].mask == 0)
+				    return routes[i].nexthop;
+
+		return null;
+	},
+
+	/**
+	 * Query the IPv6 DNS servers associated with the logical interface.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of IPv6 DNS servers registered by the remote
+	 * protocol backend.
+	 */
+	getDNS6Addrs: function() {
+		var addrs = this._ubus('dns-server'),
+		    rv = [];
+
+		if (Array.isArray(addrs))
+			for (var i = 0; i < addrs.length; i++)
+				if (/:/.test(addrs[i]))
+					rv.push(addrs[i]);
+
+		return rv;
+	},
+
+	/**
+	 * Query the routed IPv6 prefix associated with the logical interface.
+	 *
+	 * @returns {null|string}
+	 * Returns the routed IPv6 prefix registered by the remote protocol
+	 * handler or `null` if no prefix is present.
+	 */
+	getIP6Prefix: function() {
+		var prefixes = this._ubus('ipv6-prefix');
+
+		if (Array.isArray(prefixes) && L.isObject(prefixes[0]))
+			return '%s/%d'.format(prefixes[0].address, prefixes[0].mask);
+
+		return null;
+	},
+
+	/**
+	 * Query interface error messages published in `ubus` runtime state.
+	 *
+	 * Interface errors are emitted by remote protocol handlers if the setup
+	 * of the underlying logical interface failed, e.g. due to bad
+	 * configuration or network connectivity issues.
+	 *
+	 * This function will translate the found error codes to human readable
+	 * messages using the descriptions registered by
+	 * {@link LuCI.Network#registerErrorCode Network.registerErrorCode()}
+	 * and fall back to `"Unknown error (%s)"` where `%s` is replaced by the
+	 * error code in case no translation can be found.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of translated interface error messages.
+	 */
+	getErrors: function() {
+		var errors = this._ubus('errors'),
+		    rv = null;
+
+		if (Array.isArray(errors)) {
+			for (var i = 0; i < errors.length; i++) {
+				if (!L.isObject(errors[i]) || typeof(errors[i].code) != 'string')
+					continue;
+
+				rv = rv || [];
+				rv.push(proto_errors[errors[i].code] || _('Unknown error (%s)').format(errors[i].code));
+			}
+		}
+
+		return rv;
+	},
+
+	/**
+	 * Checks whether the underlying logical interface is declared as bridge.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the interface is declared with `option type bridge`
+	 * and when the associated protocol implementation is not marked virtual
+	 * or `false` when the logical interface is no bridge.
+	 */
+	isBridge: function() {
+		return (!this.isVirtual() && this.getType() == 'bridge');
+	},
+
+	/**
+	 * Get the name of the opkg package providing the protocol functionality.
+	 *
+	 * This function should be overwritten by protocol specific subclasses.
+	 *
+	 * @abstract
+	 *
+	 * @returns {string}
+	 * Returns the name of the opkg package required for the protocol to
+	 * function, e.g. `odhcp6c` for the `dhcpv6` prototocol.
+	 */
+	getOpkgPackage: function() {
+		return null;
+	},
+
+	/**
+	 * Checks whether the protocol functionality is installed.
+	 *
+	 * This function exists for compatibility with old code, it always
+	 * returns `true`.
+	 *
+	 * @deprecated
+	 * @abstract
+	 *
+	 * @returns {boolean}
+	 * Returns `true` if the protocol support is installed, else `false`.
+	 */
+	isInstalled: function() {
+		return true;
+	},
+
+	/**
+	 * Checks whether this protocol is "virtual".
+	 *
+	 * A "virtual" protocol is a protocol which spawns its own interfaces
+	 * on demand instead of using existing physical interfaces.
+	 *
+	 * Examples for virtual protocols are `6in4` which `gre` spawn tunnel
+	 * network device on startup, examples for non-virtual protcols are
+	 * `dhcp` or `static` which apply IP configuration to existing interfaces.
+	 *
+	 * This function should be overwritten by subclasses.
+	 *
+	 * @returns {boolean}
+	 * Returns a boolean indicating whether the underlying protocol spawns
+	 * dynamic interfaces (`true`) or not (`false`).
+	 */
+	isVirtual: function() {
+		return false;
+	},
+
+	/**
+	 * Checks whether this protocol is "floating".
+	 *
+	 * A "floating" protocol is a protocol which spawns its own interfaces
+	 * on demand, like a virtual one but which relies on an existinf lower
+	 * level interface to initiate the connection.
+	 *
+	 * An example for such a protocol is "pppoe".
+	 *
+	 * This function exists for backwards compatibility with older code
+	 * but should not be used anymore.
+	 *
+	 * @deprecated
+	 * @returns {boolean}
+	 * Returns a boolean indicating whether this protocol is floating (`true`)
+	 * or not (`false`).
+	 */
+	isFloating: function() {
+		return false;
+	},
+
+	/**
+	 * Checks whether this logical interface is dynamic.
+	 *
+	 * A dynamic interface is an interface which has been created at runtime,
+	 * e.g. as sub-interface of another interface, but which is not backed by
+	 * any user configuration. Such dynamic interfaces cannot be edited but
+	 * only brought down or restarted.
+	 *
+	 * @returns {boolean}
+	 * Returns a boolean indicating whether this interface is dynamic (`true`)
+	 * or not (`false`).
+	 */
+	isDynamic: function() {
+		return (this._ubus('dynamic') == true);
+	},
+
+	/**
+	 * Checks whether this interface is an alias interface.
+	 *
+	 * Alias interfaces are interfaces layering on top of another interface
+	 * and are denoted by a special `@interfacename` notation in the
+	 * underlying `ifname` option.
+	 *
+	 * @returns {null|string}
+	 * Returns the name of the parent interface if this logical interface
+	 * is an alias or `null` if it is not an alias interface.
+	 */
+	isAlias: function() {
+		var ifnames = L.toArray(uci.get('network', this.sid, 'ifname')),
+		    parent = null;
+
+		for (var i = 0; i < ifnames.length; i++)
+			if (ifnames[i].charAt(0) == '@')
+				parent = ifnames[i].substr(1);
+			else if (parent != null)
+				parent = null;
+
+		return parent;
+	},
+
+	/**
+	 * Checks whether this logical interface is "empty", meaning that ut
+	 * has no network devices attached.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` if this logical interface is empty, else `false`.
+	 */
+	isEmpty: function() {
+		if (this.isFloating())
+			return false;
+
+		var empty = true,
+		    ifname = this._get('ifname');
+
+		if (ifname != null && ifname.match(/\S+/))
+			empty = false;
+
+		if (empty == true && getWifiNetidBySid(this.sid) != null)
+			empty = false;
+
+		return empty;
+	},
+
+	/**
+	 * Checks whether this logical interface is configured and running.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the interface is active or `false` when it is not.
+	 */
+	isUp: function() {
+		return (this._ubus('up') == true);
+	},
+
+	/**
+	 * Add the given network device to the logical interface.
+	 *
+	 * @param {LuCI.Network.Protocol|LuCI.Network.Device|LuCI.Network.WifiDevice|LuCI.Network.WifiNetwork|string} device
+	 * The object or device name to add to the logical interface. In case the
+	 * given argument is not a string, it is resolved though the
+	 * {@link LuCI.Network#getIfnameOf Network.getIfnameOf()} function.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` if the device name has been added or `false` if any
+	 * argument was invalid, if the device was already part of the logical
+	 * interface or if the logical interface is virtual.
+	 */
+	addDevice: function(ifname) {
+		ifname = ifnameOf(ifname);
+
+		if (ifname == null || this.isFloating())
+			return false;
+
+		var wif = getWifiSidByIfname(ifname);
+
+		if (wif != null)
+			return appendValue('wireless', wif, 'network', this.sid);
+
+		return appendValue('network', this.sid, 'ifname', ifname);
+	},
+
+	/**
+	 * Remove the given network device from the logical interface.
+	 *
+	 * @param {LuCI.Network.Protocol|LuCI.Network.Device|LuCI.Network.WifiDevice|LuCI.Network.WifiNetwork|string} device
+	 * The object or device name to remove from the logical interface. In case
+	 * the given argument is not a string, it is resolved though the
+	 * {@link LuCI.Network#getIfnameOf Network.getIfnameOf()} function.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` if the device name has been added or `false` if any
+	 * argument was invalid, if the device was already part of the logical
+	 * interface or if the logical interface is virtual.
+	 */
+	deleteDevice: function(ifname) {
+		var rv = false;
+
+		ifname = ifnameOf(ifname);
+
+		if (ifname == null || this.isFloating())
+			return false;
+
+		var wif = getWifiSidByIfname(ifname);
+
+		if (wif != null)
+			rv = removeValue('wireless', wif, 'network', this.sid);
+
+		if (removeValue('network', this.sid, 'ifname', ifname))
+			rv = true;
+
+		return rv;
+	},
+
+	/**
+	 * Returns the Linux network device associated with this logical
+	 * interface.
+	 *
+	 * @returns {LuCI.Network.Device}
+	 * Returns a `Network.Device` class instance representing the
+	 * expected Linux network device according to the configuration.
+	 */
+	getDevice: function() {
+		if (this.isVirtual()) {
+			var ifname = '%s-%s'.format(this.getProtocol(), this.sid);
+			_state.isTunnel[this.getProtocol() + '-' + this.sid] = true;
+			return L.network.instantiateDevice(ifname, this);
+		}
+		else if (this.isBridge()) {
+			var ifname = 'br-%s'.format(this.sid);
+			_state.isBridge[ifname] = true;
+			return new Device(ifname, this);
+		}
+		else {
+			var ifnames = L.toArray(uci.get('network', this.sid, 'ifname'));
+
+			for (var i = 0; i < ifnames.length; i++) {
+				var m = ifnames[i].match(/^([^:/]+)/);
+				return ((m && m[1]) ? L.network.instantiateDevice(m[1], this) : null);
+			}
+
+			ifname = getWifiNetidByNetname(this.sid);
+
+			return (ifname != null ? L.network.instantiateDevice(ifname[0], this) : null);
+		}
+	},
+
+	/**
+	 * Returns the layer 2 linux network device currently associated
+	 * with this logical interface.
+	 *
+	 * @returns {LuCI.Network.Device}
+	 * Returns a `Network.Device` class instance representing the Linux
+	 * network device currently associated with the logical interface.
+	 */
+	getL2Device: function() {
+		var ifname = this._ubus('device');
+		return (ifname != null ? L.network.instantiateDevice(ifname, this) : null);
+	},
+
+	/**
+	 * Returns the layer 3 linux network device currently associated
+	 * with this logical interface.
+	 *
+	 * @returns {LuCI.Network.Device}
+	 * Returns a `Network.Device` class instance representing the Linux
+	 * network device currently associated with the logical interface.
+	 */
+	getL3Device: function() {
+		var ifname = this._ubus('l3_device');
+		return (ifname != null ? L.network.instantiateDevice(ifname, this) : null);
+	},
+
+	/**
+	 * Returns a list of network sub-devices associated with this logical
+	 * interface.
+	 *
+	 * @returns {null|Array<LuCI.Network.Device>}
+	 * Returns an array of of `Network.Device` class instances representing
+	 * the sub-devices attached to this logical interface or `null` if the
+	 * logical interface does not support sub-devices, e.g. because it is
+	 * virtual and not a bridge.
+	 */
+	getDevices: function() {
+		var rv = [];
+
+		if (!this.isBridge() && !(this.isVirtual() && !this.isFloating()))
+			return null;
+
+		var ifnames = L.toArray(uci.get('network', this.sid, 'ifname'));
+
+		for (var i = 0; i < ifnames.length; i++) {
+			if (ifnames[i].charAt(0) == '@')
+				continue;
+
+			var m = ifnames[i].match(/^([^:/]+)/);
+			if (m != null)
+				rv.push(L.network.instantiateDevice(m[1], this));
+		}
+
+		var uciWifiIfaces = uci.sections('wireless', 'wifi-iface');
+
+		for (var i = 0; i < uciWifiIfaces.length; i++) {
+			if (typeof(uciWifiIfaces[i].device) != 'string')
+				continue;
+
+			var networks = L.toArray(uciWifiIfaces[i].network);
+
+			for (var j = 0; j < networks.length; j++) {
+				if (networks[j] != this.sid)
+					continue;
+
+				var netid = getWifiNetidBySid(uciWifiIfaces[i]['.name']);
+
+				if (netid != null)
+					rv.push(L.network.instantiateDevice(netid[0], this));
+			}
+		}
+
+		rv.sort(deviceSort);
+
+		return rv;
+	},
+
+	/**
+	 * Checks whether this logical interface contains the given device
+	 * object.
+	 *
+	 * @param {LuCI.Network.Protocol|LuCI.Network.Device|LuCI.Network.WifiDevice|LuCI.Network.WifiNetwork|string} device
+	 * The object or device name to check. In case the given argument is not
+	 * a string, it is resolved though the
+	 * {@link LuCI.Network#getIfnameOf Network.getIfnameOf()} function.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when this logical interface contains the given network
+	 * device or `false` if not.
+	 */
+	containsDevice: function(ifname) {
+		ifname = ifnameOf(ifname);
+
+		if (ifname == null)
+			return false;
+		else if (this.isVirtual() && '%s-%s'.format(this.getProtocol(), this.sid) == ifname)
+			return true;
+		else if (this.isBridge() && 'br-%s'.format(this.sid) == ifname)
+			return true;
+
+		var ifnames = L.toArray(uci.get('network', this.sid, 'ifname'));
+
+		for (var i = 0; i < ifnames.length; i++) {
+			var m = ifnames[i].match(/^([^:/]+)/);
+			if (m != null && m[1] == ifname)
+				return true;
+		}
+
+		var wif = getWifiSidByIfname(ifname);
+
+		if (wif != null) {
+			var networks = L.toArray(uci.get('wireless', wif, 'network'));
+
+			for (var i = 0; i < networks.length; i++)
+				if (networks[i] == this.sid)
+					return true;
+		}
+
+		return false;
+	}
+});
+
+/**
+ * @class
+ * @memberof LuCI.Network
+ * @hideconstructor
+ * @classdesc
+ *
+ * A `Network.Device` class instance represents an underlying Linux network
+ * device and allows querying device details such as packet statistics or MTU.
+ */
+Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ {
+	__init__: function(ifname, network) {
+		var wif = getWifiSidByIfname(ifname);
+
+		if (wif != null) {
+			var res = getWifiStateBySid(wif) || [],
+			    netid = getWifiNetidBySid(wif) || [];
+
+			this.wif    = new WifiNetwork(wif, res[0], res[1], netid[0], res[2], { ifname: ifname });
+			this.ifname = this.wif.getIfname();
+		}
+
+		this.ifname  = this.ifname || ifname;
+		this.dev     = _state.netdevs[this.ifname];
+		this.network = network;
+	},
+
+	_devstate: function(/* ... */) {
+		var rv = this.dev;
+
+		for (var i = 0; i < arguments.length; i++)
+			if (L.isObject(rv))
+				rv = rv[arguments[i]];
+			else
+				return null;
+
+		return rv;
+	},
+
+	/**
+	 * Get the name of the network device.
+	 *
+	 * @returns {string}
+	 * Returns the name of the device, e.g. `eth0` or `wlan0`.
+	 */
+	getName: function() {
+		return (this.wif != null ? this.wif.getIfname() : this.ifname);
+	},
+
+	/**
+	 * Get the MAC address of the device.
+	 *
+	 * @returns {null|string}
+	 * Returns the MAC address of the device or `null` if not applicable,
+	 * e.g. for non-ethernet tunnel devices.
+	 */
+	getMAC: function() {
+		var mac = this._devstate('macaddr');
+		return mac ? mac.toUpperCase() : null;
+	},
+
+	/**
+	 * Get the MTU of the device.
+	 *
+	 * @returns {number}
+	 * Returns the MTU of the device.
+	 */
+	getMTU: function() {
+		return this._devstate('mtu');
+	},
+
+	/**
+	 * Get the IPv4 addresses configured on the device.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of IPv4 address strings.
+	 */
+	getIPAddrs: function() {
+		var addrs = this._devstate('ipaddrs');
+		return (Array.isArray(addrs) ? addrs : []);
+	},
+
+	/**
+	 * Get the IPv6 addresses configured on the device.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of IPv6 address strings.
+	 */
+	getIP6Addrs: function() {
+		var addrs = this._devstate('ip6addrs');
+		return (Array.isArray(addrs) ? addrs : []);
+	},
+
+	/**
+	 * Get the type of the device..
+	 *
+	 * @returns {string}
+	 * Returns a string describing the type of the network device:
+	 *  - `alias` if it is an abstract alias device (`@` notation)
+	 *  - `wifi` if it is a wireless interface (e.g. `wlan0`)
+	 *  - `bridge` if it is a bridge device (e.g. `br-lan`)
+	 *  - `tunnel` if it is a tun or tap device (e.g. `tun0`)
+	 *  - `vlan` if it is a vlan device (e.g. `eth0.1`)
+	 *  - `switch` if it is a switch device (e.g.`eth1` connected to switch0)
+	 *  - `ethernet` for all other device types
+	 */
+	getType: function() {
+		if (this.ifname != null && this.ifname.charAt(0) == '@')
+			return 'alias';
+		else if (this.wif != null || isWifiIfname(this.ifname))
+			return 'wifi';
+		else if (_state.isBridge[this.ifname])
+			return 'bridge';
+		else if (_state.isTunnel[this.ifname])
+			return 'tunnel';
+		else if (this.ifname.indexOf('.') > -1)
+			return 'vlan';
+		else if (_state.isSwitch[this.ifname])
+			return 'switch';
+		else
+			return 'ethernet';
+	},
+
+	/**
+	 * Get a short description string for the device.
+	 *
+	 * @returns {string}
+	 * Returns the device name for non-wifi devices or a string containing
+	 * the operation mode and SSID for wifi devices.
+	 */
+	getShortName: function() {
+		if (this.wif != null)
+			return this.wif.getShortName();
+
+		return this.ifname;
+	},
+
+	/**
+	 * Get a long description string for the device.
+	 *
+	 * @returns {string}
+	 * Returns a string containing the type description and device name
+	 * for non-wifi devices or operation mode and ssid for wifi ones.
+	 */
+	getI18n: function() {
+		if (this.wif != null) {
+			return '%s: %s "%s"'.format(
+				_('Wireless Network'),
+				this.wif.getActiveMode(),
+				this.wif.getActiveSSID() || this.wif.getActiveBSSID() || this.wif.getID() || '?');
+		}
+
+		return '%s: "%s"'.format(this.getTypeI18n(), this.getName());
+	},
+
+	/**
+	 * Get a string describing the device type.
+	 *
+	 * @returns {string}
+	 * Returns a string describing the type, e.g. "Wireless Adapter" or
+	 * "Bridge".
+	 */
+	getTypeI18n: function() {
+		switch (this.getType()) {
+		case 'alias':
+			return _('Alias Interface');
+
+		case 'wifi':
+			return _('Wireless Adapter');
+
+		case 'bridge':
+			return _('Bridge');
+
+		case 'switch':
+			return _('Ethernet Switch');
+
+		case 'vlan':
+			return (_state.isSwitch[this.ifname] ? _('Switch VLAN') : _('Software VLAN'));
+
+		case 'tunnel':
+			return _('Tunnel Interface');
+
+		default:
+			return _('Ethernet Adapter');
+		}
+	},
+
+	/**
+	 * Get the associated bridge ports of the device.
+	 *
+	 * @returns {null|Array<LuCI.Network.Device>}
+	 * Returns an array of `Network.Device` instances representing the ports
+	 * (slave interfaces) of the bridge or `null` when this device isn't
+	 * a Linux bridge.
+	 */
+	getPorts: function() {
+		var br = _state.bridges[this.ifname],
+		    rv = [];
+
+		if (br == null || !Array.isArray(br.ifnames))
+			return null;
+
+		for (var i = 0; i < br.ifnames.length; i++)
+			rv.push(L.network.instantiateDevice(br.ifnames[i].name));
+
+		rv.sort(deviceSort);
+
+		return rv;
+	},
+
+	/**
+	 * Get the bridge ID
+	 *
+	 * @returns {null|string}
+	 * Returns the ID of this network bridge or `null` if this network
+	 * device is not a Linux bridge.
+	 */
+	getBridgeID: function() {
+		var br = _state.bridges[this.ifname];
+		return (br != null ? br.id : null);
+	},
+
+	/**
+	 * Get the bridge STP setting
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when this device is a Linux bridge and has `stp`
+	 * enabled, else `false`.
+	 */
+	getBridgeSTP: function() {
+		var br = _state.bridges[this.ifname];
+		return (br != null ? !!br.stp : false);
+	},
+
+	/**
+	 * Checks whether this device is up.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the associated device is running pr `false`
+	 * when it is down or absent.
+	 */
+	isUp: function() {
+		var up = this._devstate('flags', 'up');
+
+		if (up == null)
+			up = (this.getType() == 'alias');
+
+		return up;
+	},
+
+	/**
+	 * Checks whether this device is a Linux bridge.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the network device is present and a Linux bridge,
+	 * else `false`.
+	 */
+	isBridge: function() {
+		return (this.getType() == 'bridge');
+	},
+
+	/**
+	 * Checks whether this device is part of a Linux bridge.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when this network device is part of a bridge,
+	 * else `false`.
+	 */
+	isBridgePort: function() {
+		return (this._devstate('bridge') != null);
+	},
+
+	/**
+	 * Get the amount of transmitted bytes.
+	 *
+	 * @returns {number}
+	 * Returns the amount of bytes transmitted by the network device.
+	 */
+	getTXBytes: function() {
+		var stat = this._devstate('stats');
+		return (stat != null ? stat.tx_bytes || 0 : 0);
+	},
+
+	/**
+	 * Get the amount of received bytes.
+	 *
+	 * @returns {number}
+	 * Returns the amount of bytes received by the network device.
+	 */
+	getRXBytes: function() {
+		var stat = this._devstate('stats');
+		return (stat != null ? stat.rx_bytes || 0 : 0);
+	},
+
+	/**
+	 * Get the amount of transmitted packets.
+	 *
+	 * @returns {number}
+	 * Returns the amount of packets transmitted by the network device.
+	 */
+	getTXPackets: function() {
+		var stat = this._devstate('stats');
+		return (stat != null ? stat.tx_packets || 0 : 0);
+	},
+
+	/**
+	 * Get the amount of received packets.
+	 *
+	 * @returns {number}
+	 * Returns the amount of packets received by the network device.
+	 */
+	getRXPackets: function() {
+		var stat = this._devstate('stats');
+		return (stat != null ? stat.rx_packets || 0 : 0);
+	},
+
+	/**
+	 * Get the primary logical interface this device is assigned to.
+	 *
+	 * @returns {null|LuCI.Network.Protocol}
+	 * Returns a `Network.Protocol` instance representing the logical
+	 * interface this device is attached to or `null` if it is not
+	 * assigned to any logical interface.
+	 */
+	getNetwork: function() {
+		return this.getNetworks()[0];
+	},
+
+	/**
+	 * Get the logical interfaces this device is assigned to.
+	 *
+	 * @returns {Array<LuCI.Network.Protocol>}
+	 * Returns an array of `Network.Protocol` instances representing the
+	 * logical interfaces this device is assigned to.
+	 */
+	getNetworks: function() {
+		if (this.networks == null) {
+			this.networks = [];
+
+			var networks = enumerateNetworks.apply(L.network);
+
+			for (var i = 0; i < networks.length; i++)
+				if (networks[i].containsDevice(this.ifname) || networks[i].getIfname() == this.ifname)
+					this.networks.push(networks[i]);
+
+			this.networks.sort(networkSort);
+		}
+
+		return this.networks;
+	},
+
+	/**
+	 * Get the related wireless network this device is related to.
+	 *
+	 * @returns {null|LuCI.Network.WifiNetwork}
+	 * Returns a `Network.WifiNetwork` instance representing the wireless
+	 * network corresponding to this network device or `null` if this device
+	 * is not a wireless device.
+	 */
+	getWifiNetwork: function() {
+		return (this.wif != null ? this.wif : null);
+	}
+});
+
+/**
+ * @class
+ * @memberof LuCI.Network
+ * @hideconstructor
+ * @classdesc
+ *
+ * A `Network.WifiDevice` class instance represents a wireless radio device
+ * present on the system and provides wireless capability information as
+ * well as methods for enumerating related wireless networks.
+ */
+WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ {
+	__init__: function(name, radiostate) {
+		var uciWifiDevice = uci.get('wireless', name);
+
+		if (uciWifiDevice != null &&
+		    uciWifiDevice['.type'] == 'wifi-device' &&
+		    uciWifiDevice['.name'] != null) {
+			this.sid    = uciWifiDevice['.name'];
+		}
+
+		this.sid    = this.sid || name;
+		this._ubusdata = {
+			radio: name,
+			dev:   radiostate
+		};
+	},
+
+	/* private */
+	ubus: function(/* ... */) {
+		var v = this._ubusdata;
+
+		for (var i = 0; i < arguments.length; i++)
+			if (L.isObject(v))
+				v = v[arguments[i]];
+			else
+				return null;
+
+		return v;
+	},
+
+	/**
+	 * Read the given UCI option value of this wireless device.
+	 *
+	 * @param {string} opt
+	 * The UCI option name to read.
+	 *
+	 * @returns {null|string|string[]}
+	 * Returns the UCI option value or `null` if the requested option is
+	 * not found.
+	 */
+	get: function(opt) {
+		return uci.get('wireless', this.sid, opt);
+	},
+
+	/**
+	 * Set the given UCI option of this network to the given value.
+	 *
+	 * @param {string} opt
+	 * The name of the UCI option to set.
+	 *
+	 * @param {null|string|string[]} val
+	 * The value to set or `null` to remove the given option from the
+	 * configuration.
+	 */
+	set: function(opt, value) {
+		return uci.set('wireless', this.sid, opt, value);
+	},
+
+	/**
+	 * Checks whether this wireless radio is disabled.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the wireless radio is marked as disabled in `ubus`
+	 * runtime state or when the `disabled` option is set in the corresponding
+	 * UCI configuration.
+	 */
+	isDisabled: function() {
+		return this.ubus('dev', 'disabled') || this.get('disabled') == '1';
+	},
+
+	/**
+	 * Get the configuration name of this wireless radio.
+	 *
+	 * @returns {string}
+	 * Returns the UCI section name (e.g. `radio0`) of the corresponding
+	 * radio configuration which also serves as unique logical identifier
+	 * for the wireless phy.
+	 */
+	getName: function() {
+		return this.sid;
+	},
+
+	/**
+	 * Gets a list of supported hwmodes.
+	 *
+	 * The hwmode values describe the frequency band and wireless standard
+	 * versions supported by the wireless phy.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of valid hwmode values for this radio. Currently
+	 * known mode values are:
+	 *  - `a` - Legacy 802.11a mode, 5 GHz, up to 54 Mbit/s
+	 *  - `b` - Legacy 802.11b mode, 2.4 GHz, up to 11 Mbit/s
+	 *  - `g` - Legacy 802.11g mode, 2.4 GHz, up to 54 Mbit/s
+	 *  - `n` - IEEE 802.11n mode, 2.4 or 5 GHz, up to 600 Mbit/s
+	 *  - `ac` - IEEE 802.11ac mode, 5 GHz, up to 6770 Mbit/s
+	 */
+	getHWModes: function() {
+		var hwmodes = this.ubus('dev', 'iwinfo', 'hwmodes');
+		return Array.isArray(hwmodes) ? hwmodes : [ 'b', 'g' ];
+	},
+
+	/**
+	 * Gets a list of supported htmodes.
+	 *
+	 * The htmode values describe the wide-frequency options supported by
+	 * the wireless phy.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of valid htmode values for this radio. Currently
+	 * known mode values are:
+	 *  - `HT20` - applicable to IEEE 802.11n, 20 MHz wide channels
+	 *  - `HT40` - applicable to IEEE 802.11n, 40 MHz wide channels
+	 *  - `VHT20` - applicable to IEEE 802.11ac, 20 MHz wide channels
+	 *  - `VHT40` - applicable to IEEE 802.11ac, 40 MHz wide channels
+	 *  - `VHT80` - applicable to IEEE 802.11ac, 80 MHz wide channels
+	 *  - `VHT160` - applicable to IEEE 802.11ac, 160 MHz wide channels
+	 */
+	getHTModes: function() {
+		var htmodes = this.ubus('dev', 'iwinfo', 'htmodes');
+		return (Array.isArray(htmodes) && htmodes.length) ? htmodes : null;
+	},
+
+	/**
+	 * Get a string describing the wireless radio hardware.
+	 *
+	 * @returns {string}
+	 * Returns the description string.
+	 */
+	getI18n: function() {
+		var hw = this.ubus('dev', 'iwinfo', 'hardware'),
+		    type = L.isObject(hw) ? hw.name : null;
+
+		if (this.ubus('dev', 'iwinfo', 'type') == 'wl')
+			type = 'Broadcom';
+
+		var hwmodes = this.getHWModes(),
+		    modestr = '';
+
+		hwmodes.sort(function(a, b) {
+			return (a.length != b.length ? a.length > b.length : a > b);
+		});
+
+		modestr = hwmodes.join('');
+
+		return '%s 802.11%s Wireless Controller (%s)'.format(type || 'Generic', modestr, this.getName());
+	},
+
+	/**
+	 * A wireless scan result object describes a neighbouring wireless
+	 * network found in the vincinity.
+	 *
+	 * @typedef {Object<string, number|string|LuCI.Network.WifiEncryption>} WifiScanResult
+	 * @memberof LuCI.Network
+	 *
+	 * @property {string} ssid
+	 * The SSID / Mesh ID of the network.
+	 *
+	 * @property {string} bssid
+	 * The BSSID if the network.
+	 *
+	 * @property {string} mode
+	 * The operation mode of the network (`Master`, `Ad-Hoc`, `Mesh Point`).
+	 *
+	 * @property {number} channel
+	 * The wireless channel of the network.
+	 *
+	 * @property {number} signal
+	 * The received signal strength of the network in dBm.
+	 *
+	 * @property {number} quality
+	 * The numeric quality level of the signal, can be used in conjunction
+	 * with `quality_max` to calculate a quality percentage.
+	 *
+	 * @property {number} quality_max
+	 * The maximum possible quality level of the signal, can be used in
+	 * conjunction with `quality` to calculate a quality percentage.
+	 *
+	 * @property {LuCI.Network.WifiEncryption} encryption
+	 * The encryption used by the wireless network.
+	 */
+
+	/**
+	 * Trigger a wireless scan on this radio device and obtain a list of
+	 * nearby networks.
+	 *
+	 * @returns {Promise<Array<LuCI.Network.WifiScanResult>>}
+	 * Returns a promise resolving to an array of scan result objects
+	 * describing the networks found in the vincinity.
+	 */
+	getScanList: function() {
+		return callIwinfoScan(this.sid);
+	},
+
+	/**
+	 * Check whether the wireless radio is marked as up in the `ubus`
+	 * runtime state.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the radio device is up, else `false`.
+	 */
+	isUp: function() {
+		if (L.isObject(_state.radios[this.sid]))
+			return (_state.radios[this.sid].up == true);
+
+		return false;
+	},
+
+	/**
+	 * Get the wifi network of the given name belonging to this radio device
+	 *
+	 * @param {string} network
+	 * The name of the wireless network to lookup. This may be either an uci
+	 * configuration section ID, a network ID in the form `radio#.network#`
+	 * or a Linux network device name like `wlan0` which is resolved to the
+	 * corresponding configuration section through `ubus` runtime information.
+	 *
+	 * @returns {Promise<LuCI.Network.WifiNetwork>}
+	 * Returns a promise resolving to a `Network.WifiNetwork` instance
+	 * representing the wireless network and rejecting with `null` if
+	 * the given network could not be found or is not associated with
+	 * this radio device.
+	 */
+	getWifiNetwork: function(network) {
+		return L.network.getWifiNetwork(network).then(L.bind(function(networkInstance) {
+			var uciWifiIface = (networkInstance.sid ? uci.get('wireless', networkInstance.sid) : null);
+
+			if (uciWifiIface == null || uciWifiIface['.type'] != 'wifi-iface' || uciWifiIface.device != this.sid)
+				return Promise.reject();
+
+			return networkInstance;
+		}, this));
+	},
+
+	/**
+	 * Get all wireless networks associated with this wireless radio device.
+	 *
+	 * @returns {Promise<Array<LuCI.Network.WifiNetwork>>}
+	 * Returns a promise resolving to an array of `Network.WifiNetwork`
+	 * instances respresenting the wireless networks associated with this
+	 * radio device.
+	 */
+	getWifiNetworks: function() {
+		var uciWifiIfaces = uci.sections('wireless', 'wifi-iface'),
+		    tasks = [];
+
+		for (var i = 0; i < uciWifiIfaces.length; i++)
+			if (uciWifiIfaces[i].device == this.sid)
+				tasks.push(L.network.getWifiNetwork(uciWifiIfaces[i]['.name']));
+
+		return Promise.all(tasks);
+	},
+
+	/**
+	 * Adds a new wireless network associated with this radio device to the
+	 * configuration and sets its options to the provided values.
+	 *
+	 * @param {Object<string, string|string[]>} [options]
+	 * The options to set for the newly added wireless network.
+	 *
+	 * @returns {Promise<null|LuCI.Network.WifiNetwork>}
+	 * Returns a promise resolving to a `WifiNetwork` instance describing
+	 * the newly added wireless network or `null` if the given options
+	 * were invalid.
+	 */
+	addWifiNetwork: function(options) {
+		if (!L.isObject(options))
+			options = {};
+
+		options.device = this.sid;
+
+		return L.network.addWifiNetwork(options);
+	},
+
+	/**
+	 * Deletes the wireless network with the given name associated with this
+	 * radio device.
+	 *
+	 * @param {string} network
+	 * The name of the wireless network to lookup. This may be either an uci
+	 * configuration section ID, a network ID in the form `radio#.network#`
+	 * or a Linux network device name like `wlan0` which is resolved to the
+	 * corresponding configuration section through `ubus` runtime information.
+	 *
+	 * @returns {Promise<boolean>}
+	 * Returns a promise resolving to `true` when the wireless network was
+	 * successfully deleted from the configuration or `false` when the given
+	 * network could not be found or if the found network was not associated
+	 * with this wireless radio device.
+	 */
+	deleteWifiNetwork: function(network) {
+		var sid = null;
+
+		if (network instanceof WifiNetwork) {
+			sid = network.sid;
+		}
+		else {
+			var uciWifiIface = uci.get('wireless', network);
+
+			if (uciWifiIface == null || uciWifiIface['.type'] != 'wifi-iface')
+				sid = getWifiSidByIfname(network);
+		}
+
+		if (sid == null || uci.get('wireless', sid, 'device') != this.sid)
+			return Promise.resolve(false);
+
+		uci.delete('wireless', network);
+
+		return Promise.resolve(true);
+	}
+});
+
+/**
+ * @class
+ * @memberof LuCI.Network
+ * @hideconstructor
+ * @classdesc
+ *
+ * A `Network.WifiNetwork` instance represents a wireless network (vif)
+ * configured on top of a radio device and provides functions for querying
+ * the runtime state of the network. Most radio devices support multiple
+ * such networks in parallel.
+ */
+WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ {
+	__init__: function(sid, radioname, radiostate, netid, netstate) {
+		this.sid    = sid;
+		this.netid  = netid;
+		this._ubusdata = {
+			radio: radioname,
+			dev:   radiostate,
+			net:   netstate
+		};
+	},
+
+	ubus: function(/* ... */) {
+		var v = this._ubusdata;
+
+		for (var i = 0; i < arguments.length; i++)
+			if (L.isObject(v))
+				v = v[arguments[i]];
+			else
+				return null;
+
+		return v;
+	},
+
+	/**
+	 * Read the given UCI option value of this wireless network.
+	 *
+	 * @param {string} opt
+	 * The UCI option name to read.
+	 *
+	 * @returns {null|string|string[]}
+	 * Returns the UCI option value or `null` if the requested option is
+	 * not found.
+	 */
+	get: function(opt) {
+		return uci.get('wireless', this.sid, opt);
+	},
+
+	/**
+	 * Set the given UCI option of this network to the given value.
+	 *
+	 * @param {string} opt
+	 * The name of the UCI option to set.
+	 *
+	 * @param {null|string|string[]} val
+	 * The value to set or `null` to remove the given option from the
+	 * configuration.
+	 */
+	set: function(opt, value) {
+		return uci.set('wireless', this.sid, opt, value);
+	},
+
+	/**
+	 * Checks whether this wireless network is disabled.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the wireless radio is marked as disabled in `ubus`
+	 * runtime state or when the `disabled` option is set in the corresponding
+	 * UCI configuration.
+	 */
+	isDisabled: function() {
+		return this.ubus('dev', 'disabled') || this.get('disabled') == '1';
+	},
+
+	/**
+	 * Get the configured operation mode of the wireless network.
+	 *
+	 * @returns {string}
+	 * Returns the configured operation mode. Possible values are:
+	 *  - `ap` - Master (Access Point) mode
+	 *  - `sta` - Station (client) mode
+	 *  - `adhoc` - Ad-Hoc (IBSS) mode
+	 *  - `mesh` - Mesh (IEEE 802.11s) mode
+	 *  - `monitor` - Monitor mode
+	 */
+	getMode: function() {
+		return this.ubus('net', 'config', 'mode') || this.get('mode') || 'ap';
+	},
+
+	/**
+	 * Get the configured SSID of the wireless network.
+	 *
+	 * @returns {null|string}
+	 * Returns the configured SSID value or `null` when this network is
+	 * in mesh mode.
+	 */
+	getSSID: function() {
+		if (this.getMode() == 'mesh')
+			return null;
+
+		return this.ubus('net', 'config', 'ssid') || this.get('ssid');
+	},
+
+	/**
+	 * Get the configured Mesh ID of the wireless network.
+	 *
+	 * @returns {null|string}
+	 * Returns the configured mesh ID value or `null` when this network
+	 * is not in mesh mode.
+	 */
+	getMeshID: function() {
+		if (this.getMode() != 'mesh')
+			return null;
+
+		return this.ubus('net', 'config', 'mesh_id') || this.get('mesh_id');
+	},
+
+	/**
+	 * Get the configured BSSID of the wireless network.
+	 *
+	 * @returns {null|string}
+	 * Returns the BSSID value or `null` if none has been specified.
+	 */
+	getBSSID: function() {
+		return this.ubus('net', 'config', 'bssid') || this.get('bssid');
+	},
+
+	/**
+	 * Get the names of the logical interfaces this wireless network is
+	 * attached to.
+	 *
+	 * @returns {string[]}
+	 * Returns an array of logical interface names.
+	 */
+	getNetworkNames: function() {
+		return L.toArray(this.ubus('net', 'config', 'network') || this.get('network'));
+	},
+
+	/**
+	 * Get the internal network ID of this wireless network.
+	 *
+	 * The network ID is a LuCI specific identifer in the form
+	 * `radio#.network#` to identify wireless networks by their corresponding
+	 * radio and network index numbers.
+	 *
+	 * @returns {string}
+	 * Returns the LuCI specific network ID.
+	 */
+	getID: function() {
+		return this.netid;
+	},
+
+	/**
+	 * Get the configuration ID of this wireless network.
+	 *
+	 * @returns {string}
+	 * Returns the corresponding UCI section ID of the network.
+	 */
+	getName: function() {
+		return this.sid;
+	},
+
+	/**
+	 * Get the Linux network device name.
+	 *
+	 * @returns {null|string}
+	 * Returns the current Linux network device name as resolved from
+	 * `ubus` runtime information or `null` if this network has no
+	 * associated network device, e.g. when not configured or up.
+	 */
+	getIfname: function() {
+		var ifname = this.ubus('net', 'ifname') || this.ubus('net', 'iwinfo', 'ifname');
+
+		if (ifname == null || ifname.match(/^(wifi|radio)\d/))
+			ifname = this.netid;
+
+		return ifname;
+	},
+
+	/**
+	 * Get the name of the corresponding wifi radio device.
+	 *
+	 * @returns {null|string}
+	 * Returns the name of the radio device this network is configured on
+	 * or `null` if it cannot be determined.
+	 */
+	getWifiDeviceName: function() {
+		return this.ubus('radio') || this.get('device');
+	},
+
+	/**
+	 * Get the corresponding wifi radio device.
+	 *
+	 * @returns {null|LuCI.Network.WifiDevice}
+	 * Returns a `Network.WifiDevice` instance representing the corresponding
+	 * wifi radio device or `null` if the related radio device could not be
+	 * found.
+	 */
+	getWifiDevice: function() {
+		var radioname = this.getWifiDeviceName();
+
+		if (radioname == null)
+			return Promise.reject();
+
+		return L.network.getWifiDevice(radioname);
+	},
+
+	/**
+	 * Check whether the radio network is up.
+	 *
+	 * This function actually queries the up state of the related radio
+	 * device and assumes this network to be up as well when the parent
+	 * radio is up. This is due to the fact that OpenWrt does not control
+	 * virtual interfaces individually but within one common hostapd
+	 * instance.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the network is up, else `false`.
+	 */
+	isUp: function() {
+		var device = this.getDevice();
+
+		if (device == null)
+			return false;
+
+		return device.isUp();
+	},
+
+	/**
+	 * Query the current operation mode from runtime information.
+	 *
+	 * @returns {string}
+	 * Returns the human readable mode name as reported by `ubus` runtime
+	 * state. Possible returned values are:
+	 *  - `Master`
+	 *  - `Ad-Hoc`
+	 *  - `Client`
+	 *  - `Monitor`
+	 *  - `Master (VLAN)`
+	 *  - `WDS`
+	 *  - `Mesh Point`
+	 *  - `P2P Client`
+	 *  - `P2P Go`
+	 *  - `Unknown`
+	 */
+	getActiveMode: function() {
+		var mode = this.ubus('net', 'iwinfo', 'mode') || this.ubus('net', 'config', 'mode') || this.get('mode') || 'ap';
+
+		switch (mode) {
+		case 'ap':      return 'Master';
+		case 'sta':     return 'Client';
+		case 'adhoc':   return 'Ad-Hoc';
+		case 'mesh':    return 'Mesh';
+		case 'monitor': return 'Monitor';
+		default:        return mode;
+		}
+	},
+
+	/**
+	 * Query the current operation mode from runtime information as
+	 * translated string.
+	 *
+	 * @returns {string}
+	 * Returns the translated, human readable mode name as reported by
+	 *`ubus` runtime state.
+	 */
+	getActiveModeI18n: function() {
+		var mode = this.getActiveMode();
+
+		switch (mode) {
+		case 'Master':  return _('Master');
+		case 'Client':  return _('Client');
+		case 'Ad-Hoc':  return _('Ad-Hoc');
+		case 'Mash':    return _('Mesh');
+		case 'Monitor': return _('Monitor');
+		default:        return mode;
+		}
+	},
+
+	/**
+	 * Query the current SSID from runtime information.
+	 *
+	 * @returns {string}
+	 * Returns the current SSID or Mesh ID as reported by `ubus` runtime
+	 * information.
+	 */
+	getActiveSSID: function() {
+		return this.ubus('net', 'iwinfo', 'ssid') || this.ubus('net', 'config', 'ssid') || this.get('ssid');
+	},
+
+	/**
+	 * Query the current BSSID from runtime information.
+	 *
+	 * @returns {string}
+	 * Returns the current BSSID or Mesh ID as reported by `ubus` runtime
+	 * information.
+	 */
+	getActiveBSSID: function() {
+		return this.ubus('net', 'iwinfo', 'bssid') || this.ubus('net', 'config', 'bssid') || this.get('bssid');
+	},
+
+	/**
+	 * Query the current encryption settings from runtime information.
+	 *
+	 * @returns {string}
+	 * Returns a string describing the current encryption or `-` if the the
+	 * encryption state could not be found in `ubus` runtime information.
+	 */
+	getActiveEncryption: function() {
+		return formatWifiEncryption(this.ubus('net', 'iwinfo', 'encryption')) || '-';
+	},
+
+	/**
+	 * A wireless peer entry describes the properties of a remote wireless
+	 * peer associated with a local network.
+	 *
+	 * @typedef {Object<string, boolean|number|string|LuCI.Network.WifiRateEntry>} WifiPeerEntry
+	 * @memberof LuCI.Network
+	 *
+	 * @property {string} mac
+	 * The MAC address (BSSID).
+	 *
+	 * @property {number} signal
+	 * The received signal strength.
+	 *
+	 * @property {number} [signal_avg]
+	 * The average signal strength if supported by the driver.
+	 *
+	 * @property {number} [noise]
+	 * The current noise floor of the radio. May be `0` or absent if not
+	 * supported by the driver.
+	 *
+	 * @property {number} inactive
+	 * The amount of milliseconds the peer has been inactive, e.g. due
+	 * to powersave.
+	 *
+	 * @property {number} connected_time
+	 * The amount of milliseconds the peer is associated to this network.
+	 *
+	 * @property {number} [thr]
+	 * The estimated throughput of the peer, May be `0` or absent if not
+	 * supported by the driver.
+	 *
+	 * @property {boolean} authorized
+	 * Specifies whether the peer is authorized to associate to this network.
+	 *
+	 * @property {boolean} authenticated
+	 * Specifies whether the peer completed authentication to this network.
+	 *
+	 * @property {string} preamble
+	 * The preamble mode used by the peer. May be `long` or `short`.
+	 *
+	 * @property {boolean} wme
+	 * Specifies whether the peer supports WME/WMM capabilities.
+	 *
+	 * @property {boolean} mfp
+	 * Specifies whether management frame protection is active.
+	 *
+	 * @property {boolean} tdls
+	 * Specifies whether TDLS is active.
+	 *
+	 * @property {number} [mesh llid]
+	 * The mesh LLID, may be `0` or absent if not applicable or supported
+	 * by the driver.
+	 *
+	 * @property {number} [mesh plid]
+	 * The mesh PLID, may be `0` or absent if not applicable or supported
+	 * by the driver.
+	 *
+	 * @property {string} [mesh plink]
+	 * The mesh peer link state description, may be an empty string (`''`)
+	 * or absent if not applicable or supported by the driver.
+	 *
+	 * The following states are known:
+	 *  - `LISTEN`
+	 *  - `OPN_SNT`
+	 *  - `OPN_RCVD`
+	 *  - `CNF_RCVD`
+	 *  - `ESTAB`
+	 *  - `HOLDING`
+	 *  - `BLOCKED`
+	 *  - `UNKNOWN`
+	 *
+	 * @property {number} [mesh local PS]
+	 * The local powersafe mode for the peer link, may be an empty
+	 * string (`''`) or absent if not applicable or supported by
+	 * the driver.
+	 *
+	 * The following modes are known:
+	 *  - `ACTIVE` (no power save)
+	 *  - `LIGHT SLEEP`
+	 *  - `DEEP SLEEP`
+	 *  - `UNKNOWN`
+	 *
+	 * @property {number} [mesh peer PS]
+	 * The remote powersafe mode for the peer link, may be an empty
+	 * string (`''`) or absent if not applicable or supported by
+	 * the driver.
+	 *
+	 * The following modes are known:
+	 *  - `ACTIVE` (no power save)
+	 *  - `LIGHT SLEEP`
+	 *  - `DEEP SLEEP`
+	 *  - `UNKNOWN`
+	 *
+	 * @property {number} [mesh non-peer PS]
+	 * The powersafe mode for all non-peer neigbours, may be an empty
+	 * string (`''`) or absent if not applicable or supported by the driver.
+	 *
+	 * The following modes are known:
+	 *  - `ACTIVE` (no power save)
+	 *  - `LIGHT SLEEP`
+	 *  - `DEEP SLEEP`
+	 *  - `UNKNOWN`
+	 *
+	 * @property {LuCI.Network.WifiRateEntry} rx
+	 * Describes the receiving wireless rate from the peer.
+	 *
+	 * @property {LuCI.Network.WifiRateEntry} tx
+	 * Describes the transmitting wireless rate to the peer.
+	 */
+
+	/**
+	 * A wireless rate entry describes the properties of a wireless
+	 * transmission rate to or from a peer.
+	 *
+	 * @typedef {Object<string, boolean|number>} WifiRateEntry
+	 * @memberof LuCI.Network
+	 *
+	 * @property {number} [drop_misc]
+	 * The amount of received misc. packages that have been dropped, e.g.
+	 * due to corruption or missing authentication. Only applicable to
+	 * receiving rates.
+	 *
+	 * @property {number} packets
+	 * The amount of packets that have been received or sent.
+	 *
+	 * @property {number} bytes
+	 * The amount of bytes that have been received or sent.
+	 *
+	 * @property {number} [failed]
+	 * The amount of failed tranmission attempts. Only applicable to
+	 * transmit rates.
+	 *
+	 * @property {number} [retries]
+	 * The amount of retried transmissions. Only applicable to transmit
+	 * rates.
+	 *
+	 * @property {boolean} is_ht
+	 * Specifies whether this rate is an HT (IEEE 802.11n) rate.
+	 *
+	 * @property {boolean} is_vht
+	 * Specifies whether this rate is an VHT (IEEE 802.11ac) rate.
+	 *
+	 * @property {number} mhz
+	 * The channel width in MHz used for the transmission.
+	 *
+	 * @property {number} rate
+	 * The bitrate in bit/s of the transmission.
+	 *
+	 * @property {number} [mcs]
+	 * The MCS index of the used transmission rate. Only applicable to
+	 * HT or VHT rates.
+	 *
+	 * @property {number} [40mhz]
+	 * Specifies whether the tranmission rate used 40MHz wide channel.
+	 * Only applicable to HT or VHT rates.
+	 *
+	 * Note: this option exists for backwards compatibility only and its
+	 * use is discouraged. The `mhz` field should be used instead to
+	 * determine the channel width.
+	 *
+	 * @property {boolean} [short_gi]
+	 * Specifies whether a short guard interval is used for the transmission.
+	 * Only applicable to HT or VHT rates.
+	 *
+	 * @property {number} [nss]
+	 * Specifies the number of spatial streams used by the transmission.
+	 * Only applicable to VHT rates.
+	 */
+
+	/**
+	 * Fetch the list of associated peers.
+	 *
+	 * @returns {Promise<Array<LuCI.Network.WifiPeerEntry>>}
+	 * Returns a promise resolving to an array of wireless peers associated
+	 * with this network.
+	 */
+	getAssocList: function() {
+		return callIwinfoAssoclist(this.getIfname());
+	},
+
+	/**
+	 * Query the current operating frequency of the wireless network.
+	 *
+	 * @returns {null|string}
+	 * Returns the current operating frequency of the network from `ubus`
+	 * runtime information in GHz or `null` if the information is not
+	 * available.
+	 */
+	getFrequency: function() {
+		var freq = this.ubus('net', 'iwinfo', 'frequency');
+
+		if (freq != null && freq > 0)
+			return '%.03f'.format(freq / 1000);
+
+		return null;
+	},
+
+	/**
+	 * Query the current average bitrate of all peers associated to this
+	 * wireless network.
+	 *
+	 * @returns {null|number}
+	 * Returns the average bit rate among all peers associated to the network
+	 * as reported by `ubus` runtime information or `null` if the information
+	 * is not available.
+	 */
+	getBitRate: function() {
+		var rate = this.ubus('net', 'iwinfo', 'bitrate');
+
+		if (rate != null && rate > 0)
+			return (rate / 1000);
+
+		return null;
+	},
+
+	/**
+	 * Query the current wireless channel.
+	 *
+	 * @returns {null|number}
+	 * Returns the wireless channel as reported by `ubus` runtime information
+	 * or `null` if it cannot be determined.
+	 */
+	getChannel: function() {
+		return this.ubus('net', 'iwinfo', 'channel') || this.ubus('dev', 'config', 'channel') || this.get('channel');
+	},
+
+	/**
+	 * Query the current wireless signal.
+	 *
+	 * @returns {null|number}
+	 * Returns the wireless signal in dBm as reported by `ubus` runtime
+	 * information or `null` if it cannot be determined.
+	 */
+	getSignal: function() {
+		return this.ubus('net', 'iwinfo', 'signal') || 0;
+	},
+
+	/**
+	 * Query the current radio noise floor.
+	 *
+	 * @returns {number}
+	 * Returns the radio noise floor in dBm as reported by `ubus` runtime
+	 * information or `0` if it cannot be determined.
+	 */
+	getNoise: function() {
+		return this.ubus('net', 'iwinfo', 'noise') || 0;
+	},
+
+	/**
+	 * Query the current country code.
+	 *
+	 * @returns {string}
+	 * Returns the wireless country code as reported by `ubus` runtime
+	 * information or `00` if it cannot be determined.
+	 */
+	getCountryCode: function() {
+		return this.ubus('net', 'iwinfo', 'country') || this.ubus('dev', 'config', 'country') || '00';
+	},
+
+	/**
+	 * Query the current radio TX power.
+	 *
+	 * @returns {null|number}
+	 * Returns the wireless network transmit power in dBm as reported by
+	 * `ubus` runtime information or `null` if it cannot be determined.
+	 */
+	getTXPower: function() {
+		return this.ubus('net', 'iwinfo', 'txpower');
+	},
+
+	/**
+	 * Query the radio TX power offset.
+	 *
+	 * Some wireless radios have a fixed power offset, e.g. due to the
+	 * use of external amplifiers.
+	 *
+	 * @returns {number}
+	 * Returns the wireless network transmit power offset in dBm as reported
+	 * by `ubus` runtime information or `0` if there is no offset, or if it
+	 * cannot be determined.
+	 */
+	getTXPowerOffset: function() {
+		return this.ubus('net', 'iwinfo', 'txpower_offset') || 0;
+	},
+
+	/**
+	 * Calculate the current signal.
+	 *
+	 * @deprecated
+	 * @returns {number}
+	 * Returns the calculated signal level, which is the difference between
+	 * noise and signal (SNR), divided by 5.
+	 */
+	getSignalLevel: function(signal, noise) {
+		if (this.getActiveBSSID() == '00:00:00:00:00:00')
+			return -1;
+
+		signal = signal || this.getSignal();
+		noise  = noise  || this.getNoise();
+
+		if (signal < 0 && noise < 0) {
+			var snr = -1 * (noise - signal);
+			return Math.floor(snr / 5);
+		}
+
+		return 0;
+	},
+
+	/**
+	 * Calculate the current signal quality percentage.
+	 *
+	 * @returns {number}
+	 * Returns the calculated signal quality in percent. The value is
+	 * calculated from the `quality` and `quality_max` indicators reported
+	 * by `ubus` runtime state.
+	 */
+	getSignalPercent: function() {
+		var qc = this.ubus('net', 'iwinfo', 'quality') || 0,
+		    qm = this.ubus('net', 'iwinfo', 'quality_max') || 0;
+
+		if (qc > 0 && qm > 0)
+			return Math.floor((100 / qm) * qc);
+
+		return 0;
+	},
+
+	/**
+	 * Get a short description string for this wireless network.
+	 *
+	 * @returns {string}
+	 * Returns a string describing this network, consisting of the
+	 * active operation mode, followed by either the SSID, BSSID or
+	 * internal network ID, depending on which information is available.
+	 */
+	getShortName: function() {
+		return '%s "%s"'.format(
+			this.getActiveModeI18n(),
+			this.getActiveSSID() || this.getActiveBSSID() || this.getID());
+	},
+
+	/**
+	 * Get a description string for this wireless network.
+	 *
+	 * @returns {string}
+	 * Returns a string describing this network, consisting of the
+	 * term `Wireless Network`, followed by the active operation mode,
+	 * the SSID, BSSID or internal network ID and the Linux network device
+	 * name, depending on which information is available.
+	 */
+	getI18n: function() {
+		return '%s: %s "%s" (%s)'.format(
+			_('Wireless Network'),
+			this.getActiveModeI18n(),
+			this.getActiveSSID() || this.getActiveBSSID() || this.getID(),
+			this.getIfname());
+	},
+
+	/**
+	 * Get the primary logical interface this wireless network is attached to.
+	 *
+	 * @returns {null|LuCI.Network.Protocol}
+	 * Returns a `Network.Protocol` instance representing the logical
+	 * interface or `null` if this network is not attached to any logical
+	 * interface.
+	 */
+	getNetwork: function() {
+		return this.getNetworks()[0];
+	},
+
+	/**
+	 * Get the logical interfaces this wireless network is attached to.
+	 *
+	 * @returns {Array<LuCI.Network.Protocol>}
+	 * Returns an array of `Network.Protocol` instances representing the
+	 * logical interfaces this wireless network is attached to.
+	 */
+	getNetworks: function() {
+		var networkNames = this.getNetworkNames(),
+		    networks = [];
+
+		for (var i = 0; i < networkNames.length; i++) {
+			var uciInterface = uci.get('network', networkNames[i]);
+
+			if (uciInterface == null || uciInterface['.type'] != 'interface')
+				continue;
+
+			networks.push(L.network.instantiateNetwork(networkNames[i]));
+		}
+
+		networks.sort(networkSort);
+
+		return networks;
+	},
+
+	/**
+	 * Get the associated Linux network device.
+	 *
+	 * @returns {LuCI.Network.Device}
+	 * Returns a `Network.Device` instance representing the Linux network
+	 * device associted with this wireless network.
+	 */
+	getDevice: function() {
+		return L.network.instantiateDevice(this.getIfname());
+	}
+});
+
+return Network;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 09:33:05 GMT+0100 (Central European Standard Time) +
+ + + + + diff --git a/docs/jsapi/rpc.js.html b/docs/jsapi/rpc.js.html new file mode 100644 index 000000000..ca068f31b --- /dev/null +++ b/docs/jsapi/rpc.js.html @@ -0,0 +1,528 @@ + + + + + JSDoc: Source: rpc.js + + + + + + + + + + +
+ +

Source: rpc.js

+ + + + + + +
+
+
'use strict';
+
+var rpcRequestID = 1,
+    rpcSessionID = L.env.sessionid || '00000000000000000000000000000000',
+    rpcBaseURL = L.url('admin/ubus'),
+    rpcInterceptorFns = [];
+
+/**
+ * @class rpc
+ * @memberof LuCI
+ * @hideconstructor
+ * @classdesc
+ *
+ * The `LuCI.rpc` class provides high level ubus JSON-RPC abstractions
+ * and means for listing and invoking remove RPC methods.
+ */
+return L.Class.extend(/** @lends LuCI.rpc.prototype */ {
+	/* privates */
+	call: function(req, cb, nobatch) {
+		var q = '';
+
+		if (Array.isArray(req)) {
+			if (req.length == 0)
+				return Promise.resolve([]);
+
+			for (var i = 0; i < req.length; i++)
+				if (req[i].params)
+					q += '%s%s.%s'.format(
+						q ? ';' : '/',
+						req[i].params[1],
+						req[i].params[2]
+					);
+		}
+		else if (req.params) {
+			q += '/%s.%s'.format(req.params[1], req.params[2]);
+		}
+
+		return L.Request.post(rpcBaseURL + q, req, {
+			timeout: (L.env.rpctimeout || 20) * 1000,
+			nobatch: nobatch,
+			credentials: true
+		}).then(cb, cb);
+	},
+
+	parseCallReply: function(req, res) {
+		var msg = null;
+
+		if (res instanceof Error)
+			return req.reject(res);
+
+		try {
+			if (!res.ok)
+				L.raise('RPCError', 'RPC call to %s/%s failed with HTTP error %d: %s',
+					req.object, req.method, res.status, res.statusText || '?');
+
+			msg = res.json();
+		}
+		catch (e) {
+			return req.reject(e);
+		}
+
+		/*
+		 * The interceptor args are intentionally swapped.
+		 * Response is passed as first arg to align with Request class interceptors
+		 */
+		Promise.all(rpcInterceptorFns.map(function(fn) { return fn(msg, req) }))
+			.then(this.handleCallReply.bind(this, req, msg))
+			.catch(req.reject);
+	},
+
+	handleCallReply: function(req, msg) {
+		var type = Object.prototype.toString,
+		    ret = null;
+
+		try {
+			/* verify message frame */
+			if (!L.isObject(msg) || msg.jsonrpc != '2.0')
+				L.raise('RPCError', 'RPC call to %s/%s returned invalid message frame',
+					req.object, req.method);
+
+			/* check error condition */
+			if (L.isObject(msg.error) && msg.error.code && msg.error.message)
+				L.raise('RPCError', 'RPC call to %s/%s failed with error %d: %s',
+					req.object, req.method, msg.error.code, msg.error.message || '?');
+		}
+		catch (e) {
+			return req.reject(e);
+		}
+
+		if (!req.object && !req.method) {
+			ret = msg.result;
+		}
+		else if (Array.isArray(msg.result)) {
+			ret = (msg.result.length > 1) ? msg.result[1] : msg.result[0];
+		}
+
+		if (req.expect) {
+			for (var key in req.expect) {
+				if (ret != null && key != '')
+					ret = ret[key];
+
+				if (ret == null || type.call(ret) != type.call(req.expect[key]))
+					ret = req.expect[key];
+
+				break;
+			}
+		}
+
+		/* apply filter */
+		if (typeof(req.filter) == 'function') {
+			req.priv[0] = ret;
+			req.priv[1] = req.params;
+			ret = req.filter.apply(this, req.priv);
+		}
+
+		req.resolve(ret);
+	},
+
+	/**
+	 * Lists available remote ubus objects or the method signatures of
+	 * specific objects.
+	 *
+	 * This function has two signatures and is sensitive to the number of
+	 * arguments passed to it:
+	 *  - `list()` -
+	 *    Returns an array containing the names of all remote `ubus` objects
+	 *  - `list("objname", ...)`
+	 *    Returns method signatures for each given `ubus` object name.
+	 *
+	 * @param {...string} [objectNames]
+	 * If any object names are given, this function will return the method
+	 * signatures of each given object.
+	 *
+	 * @returns {Promise<Array<string>|Object<string, Object<string, Object<string, string>>>>}
+	 * When invoked without arguments, this function will return a promise
+	 * resolving to an array of `ubus` object names. When invoked with one or
+	 * more arguments, a promise resolving to an object describing the method
+	 * signatures of each requested `ubus` object name will be returned.
+	 */
+	list: function() {
+		var msg = {
+			jsonrpc: '2.0',
+			id:      rpcRequestID++,
+			method:  'list',
+			params:  arguments.length ? this.varargs(arguments) : undefined
+		};
+
+		return new Promise(L.bind(function(resolveFn, rejectFn) {
+			/* store request info */
+			var req = {
+				resolve: resolveFn,
+				reject:  rejectFn
+			};
+
+			/* call rpc */
+			this.call(msg, this.parseCallReply.bind(this, req));
+		}, this));
+	},
+
+	/**
+	 * @typedef {Object} DeclareOptions
+	 * @memberof LuCI.rpc
+	 *
+	 * @property {string} object
+	 * The name of the remote `ubus` object to invoke.
+	 *
+	 * @property {string} method
+	 * The name of the remote `ubus` method to invoke.
+	 *
+	 * @property {string[]} [params]
+	 * Lists the named parameters expected by the remote `ubus` RPC method.
+	 * The arguments passed to the resulting generated method call function
+	 * will be mapped to named parameters in the order they appear in this
+	 * array.
+	 *
+	 * Extraneous parameters passed to the generated function will not be
+	 * sent to the remote procedure but are passed to the
+	 * {@link LuCI.rpc~filterFn filter function} if one is specified.
+	 *
+	 * Examples:
+	 *  - `params: [ "foo", "bar" ]` -
+	 *    When the resulting call function is invoked with `fn(true, false)`,
+	 *    the corresponding args object sent to the remote procedure will be
+	 *    `{ foo: true, bar: false }`.
+	 *  - `params: [ "test" ], filter: function(reply, args, extra) { ... }` -
+	 *    When the resultung generated function is invoked with
+	 *    `fn("foo", "bar", "baz")` then `{ "test": "foo" }` will be sent as
+	 *    argument to the remote procedure and the filter function will be
+	 *    invoked with `filterFn(reply, [ "foo" ], "bar", "baz")`
+	 *
+	 * @property {Object<string,*>} [expect]
+	 * Describes the expected return data structure. The given object is
+	 * supposed to contain a single key selecting the value to use from
+	 * the returned `ubus` reply object. The value of the sole key within
+	 * the `expect` object is used to infer the expected type of the received
+	 * `ubus` reply data.
+	 *
+	 * If the received data does not contain `expect`'s key, or if the
+	 * type of the data differs from the type of the value in the expect
+	 * object, the expect object's value is returned as default instead.
+	 *
+	 * The key in the `expect` object may be an empty string (`''`) in which
+	 * case the entire reply object is selected instead of one of its subkeys.
+	 *
+	 * If the `expect` option is omitted, the received reply will be returned
+	 * as-is, regardless of its format or type.
+	 *
+	 * Examples:
+	 *  - `expect: { '': { error: 'Invalid response' } }` -
+	 *    This requires the entire `ubus` reply to be a plain JavaScript
+	 *    object. If the reply isn't an object but e.g. an array or a numeric
+	 *    error code instead, it will get replaced with
+	 *    `{ error: 'Invalid response' }` instead.
+	 *  - `expect: { results: [] }` -
+	 *    This requires the received `ubus` reply to be an object containing
+	 *    a key `results` with an array as value. If the received reply does
+	 *    not contain such a key, or if `reply.results` points to a non-array
+	 *    value, the empty array (`[]`) will be used instead.
+	 *  - `expect: { success: false }` -
+	 *    This requires the received `ubus` reply to be an object containing
+	 *    a key `success` with a boolean value. If the reply does not contain
+	 *    `success` or if `reply.success` is not a boolean value, `false` will
+	 *    be returned as default instead.
+	 *
+	 * @property {LuCI.rpc~filterFn} [filter]
+	 * Specfies an optional filter function which is invoked to transform the
+	 * received reply data before it is returned to the caller.
+	 *
+	 */
+
+	/**
+	 * The filter function is invoked to transform a received `ubus` RPC call
+	 * reply before returning it to the caller.
+	 *
+	 * @callback LuCI.rpc~filterFn
+	 *
+	 * @param {*} data
+	 * The received `ubus` reply data or a subset of it as described in the
+	 * `expect` option of the RPC call declaration. In case of remote call
+	 * errors, `data` is numeric `ubus` error code instead.
+	 *
+	 * @param {Array<*>} args
+	 * The arguments the RPC method has been invoked with.
+	 *
+	 * @param {...*} extraArgs
+	 * All extraneous arguments passed to the RPC method exceeding the number
+	 * of arguments describes in the RPC call declaration.
+	 *
+	 * @return {*}
+	 * The return value of the filter function will be returned to the caller
+	 * of the RPC method as-is.
+	 */
+
+	/**
+	 * The generated invocation function is returned by
+	 * {@link LuCI.rpc#declare rpc.declare()} and encapsulates a single
+	 * RPC method call.
+	 *
+	 * Calling this function will execute a remote `ubus` HTTP call request
+	 * using the arguments passed to it as arguments and return a promise
+	 * resolving to the received reply values.
+	 *
+	 * @callback LuCI.rpc~invokeFn
+	 *
+	 * @param {...*} params
+	 * The parameters to pass to the remote procedure call. The given
+	 * positional arguments will be named to named RPC parameters according
+	 * to the names specified in the `params` array of the method declaration.
+	 *
+	 * Any additional parameters exceeding the amount of arguments in the
+	 * `params` declaration are passed as private extra arguments to the
+	 * declared filter function.
+	 *
+	 * @return {Promise<*>}
+	 * Returns a promise resolving to the result data of the remote `ubus`
+	 * RPC method invocation, optionally substituted and filtered according
+	 * to the `expect` and `filter` declarations.
+	 */
+
+	/**
+	 * Describes a remote RPC call procedure and returns a function
+	 * implementing it.
+	 *
+	 * @param {LuCI.rpc.DeclareOptions} options
+	 * If any object names are given, this function will return the method
+	 * signatures of each given object.
+	 *
+	 * @returns {LuCI.rpc~invokeFn}
+	 * Returns a new function implementing the method call described in
+	 * `options`.
+	 */
+	declare: function(options) {
+		return Function.prototype.bind.call(function(rpc, options) {
+			var args = this.varargs(arguments, 2);
+			return new Promise(function(resolveFn, rejectFn) {
+				/* build parameter object */
+				var p_off = 0;
+				var params = { };
+				if (Array.isArray(options.params))
+					for (p_off = 0; p_off < options.params.length; p_off++)
+						params[options.params[p_off]] = args[p_off];
+
+				/* all remaining arguments are private args */
+				var priv = [ undefined, undefined ];
+				for (; p_off < args.length; p_off++)
+					priv.push(args[p_off]);
+
+				/* store request info */
+				var req = {
+					expect:  options.expect,
+					filter:  options.filter,
+					resolve: resolveFn,
+					reject:  rejectFn,
+					params:  params,
+					priv:    priv,
+					object:  options.object,
+					method:  options.method
+				};
+
+				/* build message object */
+				var msg = {
+					jsonrpc: '2.0',
+					id:      rpcRequestID++,
+					method:  'call',
+					params:  [
+						rpcSessionID,
+						options.object,
+						options.method,
+						params
+					]
+				};
+
+				/* call rpc */
+				rpc.call(msg, rpc.parseCallReply.bind(rpc, req), options.nobatch);
+			});
+		}, this, this, options);
+	},
+
+	/**
+	 * Returns the current RPC session id.
+	 *
+	 * @returns {string}
+	 * Returns the 32 byte session ID string used for authenticating remote
+	 * requests.
+	 */
+	getSessionID: function() {
+		return rpcSessionID;
+	},
+
+	/**
+	 * Set the RPC session id to use.
+	 *
+	 * @param {string} sid
+	 * Sets the 32 byte session ID string used for authenticating remote
+	 * requests.
+	 */
+	setSessionID: function(sid) {
+		rpcSessionID = sid;
+	},
+
+	/**
+	 * Returns the current RPC base URL.
+	 *
+	 * @returns {string}
+	 * Returns the RPC URL endpoint to issue requests against.
+	 */
+	getBaseURL: function() {
+		return rpcBaseURL;
+	},
+
+	/**
+	 * Set the RPC base URL to use.
+	 *
+	 * @param {string} sid
+	 * Sets the RPC URL endpoint to issue requests against.
+	 */
+	setBaseURL: function(url) {
+		rpcBaseURL = url;
+	},
+
+	/**
+	 * Translates a numeric `ubus` error code into a human readable
+	 * description.
+	 *
+	 * @param {number} statusCode
+	 * The numeric status code.
+	 *
+	 * @returns {string}
+	 * Returns the textual description of the code.
+	 */
+	getStatusText: function(statusCode) {
+		switch (statusCode) {
+		case 0: return _('Command OK');
+		case 1: return _('Invalid command');
+		case 2: return _('Invalid argument');
+		case 3: return _('Method not found');
+		case 4: return _('Resource not found');
+		case 5: return _('No data received');
+		case 6: return _('Permission denied');
+		case 7: return _('Request timeout');
+		case 8: return _('Not supported');
+		case 9: return _('Unspecified error');
+		case 10: return _('Connection lost');
+		default: return _('Unknown error code');
+		}
+	},
+
+	/**
+	 * Registered interceptor functions are invoked before the standard reply
+	 * parsing and handling logic.
+	 *
+	 * By returning rejected promises, interceptor functions can cause the
+	 * invocation function to fail, regardless of the received reply.
+	 *
+	 * Interceptors may also modify their message argument in-place to
+	 * rewrite received replies before they're processed by the standard
+	 * response handling code.
+	 *
+	 * A common use case for such functions is to detect failing RPC replies
+	 * due to expired authentication in order to trigger a new login.
+	 *
+	 * @callback LuCI.rpc~interceptorFn
+	 *
+	 * @param {*} msg
+	 * The unprocessed, JSON decoded remote RPC method call reply.
+	 *
+	 * Since interceptors run before the standard parsing logic, the reply
+	 * data is not verified for correctness or filtered according to
+	 * `expect` and `filter` specifications in the declarations.
+	 *
+	 * @param {Object} req
+	 * The related request object which is an extended variant of the
+	 * declaration object, allowing access to internals of the invocation
+	 * function such as `filter`, `expect` or `params` values.
+	 *
+	 * @return {Promise<*>|*}
+	 * Interceptor functions may return a promise to defer response
+	 * processing until some delayed work completed. Any values the returned
+	 * promise resolves to are ignored.
+	 *
+	 * When the returned promise rejects with an error, the invocation
+	 * function will fail too, forwarding the error to the caller.
+	 */
+
+	/**
+	 * Registers a new interceptor function.
+	 *
+	 * @param {LuCI.rpc~interceptorFn} interceptorFn
+	 * The inteceptor function to register.
+	 *
+	 * @returns {LuCI.rpc~interceptorFn}
+	 * Returns the given function value.
+	 */
+	addInterceptor: function(interceptorFn) {
+		if (typeof(interceptorFn) == 'function')
+			rpcInterceptorFns.push(interceptorFn);
+		return interceptorFn;
+	},
+
+	/**
+	 * Removes a registered interceptor function.
+	 *
+	 * @param {LuCI.rpc~interceptorFn} interceptorFn
+	 * The inteceptor function to remove.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` if the given function has been removed or `false`
+	 * if it has not been found.
+	 */
+	removeInterceptor: function(interceptorFn) {
+		var oldlen = rpcInterceptorFns.length, i = oldlen;
+		while (i--)
+			if (rpcInterceptorFns[i] === interceptorFn)
+				rpcInterceptorFns.splice(i, 1);
+		return (rpcInterceptorFns.length < oldlen);
+	}
+});
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 09:33:05 GMT+0100 (Central European Standard Time) +
+ + + + + diff --git a/docs/jsapi/scripts/linenumber.js b/docs/jsapi/scripts/linenumber.js new file mode 100644 index 000000000..4354785ce --- /dev/null +++ b/docs/jsapi/scripts/linenumber.js @@ -0,0 +1,25 @@ +/*global document */ +(() => { + const source = document.getElementsByClassName('prettyprint source linenums'); + let i = 0; + let lineNumber = 0; + let lineId; + let lines; + let totalLines; + let anchorHash; + + if (source && source[0]) { + anchorHash = document.location.hash.substring(1); + lines = source[0].getElementsByTagName('li'); + totalLines = lines.length; + + for (; i < totalLines; i++) { + lineNumber++; + lineId = `line${lineNumber}`; + lines[i].id = lineId; + if (lineId === anchorHash) { + lines[i].className += ' selected'; + } + } + } +})(); diff --git a/docs/jsapi/scripts/prettify/Apache-License-2.0.txt b/docs/jsapi/scripts/prettify/Apache-License-2.0.txt new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/docs/jsapi/scripts/prettify/Apache-License-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/jsapi/scripts/prettify/lang-css.js b/docs/jsapi/scripts/prettify/lang-css.js new file mode 100644 index 000000000..041e1f590 --- /dev/null +++ b/docs/jsapi/scripts/prettify/lang-css.js @@ -0,0 +1,2 @@ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", +/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); diff --git a/docs/jsapi/scripts/prettify/prettify.js b/docs/jsapi/scripts/prettify/prettify.js new file mode 100644 index 000000000..eef5ad7e6 --- /dev/null +++ b/docs/jsapi/scripts/prettify/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p th:last-child { border-right: 1px solid #ddd; } + +.ancestors, .attribs { color: #999; } +.ancestors a, .attribs a +{ + color: #999 !important; + text-decoration: none; +} + +.clear +{ + clear: both; +} + +.important +{ + font-weight: bold; + color: #950B02; +} + +.yes-def { + text-indent: -1000px; +} + +.type-signature { + color: #aaa; +} + +.name, .signature { + font-family: Consolas, Monaco, 'Andale Mono', monospace; +} + +.details { margin-top: 14px; border-left: 2px solid #DDD; } +.details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; } +.details dd { margin-left: 70px; } +.details ul { margin: 0; } +.details ul { list-style-type: none; } +.details li { margin-left: 30px; padding-top: 6px; } +.details pre.prettyprint { margin: 0 } +.details .object-value { padding-top: 0; } + +.description { + margin-bottom: 1em; + margin-top: 1em; +} + +.code-caption +{ + font-style: italic; + font-size: 107%; + margin: 0; +} + +.source +{ + border: 1px solid #ddd; + width: 80%; + overflow: auto; +} + +.prettyprint.source { + width: inherit; +} + +.source code +{ + font-size: 100%; + line-height: 18px; + display: block; + padding: 4px 12px; + margin: 0; + background-color: #fff; + color: #4D4E53; +} + +.prettyprint code span.line +{ + display: inline-block; +} + +.prettyprint.linenums +{ + padding-left: 70px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.prettyprint.linenums ol +{ + padding-left: 0; +} + +.prettyprint.linenums li +{ + border-left: 3px #ddd solid; +} + +.prettyprint.linenums li.selected, +.prettyprint.linenums li.selected * +{ + background-color: lightyellow; +} + +.prettyprint.linenums li * +{ + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; +} + +.params .name, .props .name, .name code { + color: #4D4E53; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 100%; +} + +.params td.description > p:first-child, +.props td.description > p:first-child +{ + margin-top: 0; + padding-top: 0; +} + +.params td.description > p:last-child, +.props td.description > p:last-child +{ + margin-bottom: 0; + padding-bottom: 0; +} + +.disabled { + color: #454545; +} diff --git a/docs/jsapi/styles/prettify-jsdoc.css b/docs/jsapi/styles/prettify-jsdoc.css new file mode 100644 index 000000000..5a2526e37 --- /dev/null +++ b/docs/jsapi/styles/prettify-jsdoc.css @@ -0,0 +1,111 @@ +/* JSDoc prettify.js theme */ + +/* plain text */ +.pln { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* string content */ +.str { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a keyword */ +.kwd { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a comment */ +.com { + font-weight: normal; + font-style: italic; +} + +/* a type name */ +.typ { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a literal value */ +.lit { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* punctuation */ +.pun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp open bracket */ +.opn { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp close bracket */ +.clo { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a markup tag name */ +.tag { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute name */ +.atn { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute value */ +.atv { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a declaration */ +.dec { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a variable name */ +.var { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a function name */ +.fun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; +} diff --git a/docs/jsapi/styles/prettify-tomorrow.css b/docs/jsapi/styles/prettify-tomorrow.css new file mode 100644 index 000000000..aa2908c25 --- /dev/null +++ b/docs/jsapi/styles/prettify-tomorrow.css @@ -0,0 +1,132 @@ +/* Tomorrow Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* Pretty printing styles. Used with prettify.js. */ +/* SPAN elements with the classes below are added by prettyprint. */ +/* plain text */ +.pln { + color: #4d4d4c; } + +@media screen { + /* string content */ + .str { + color: #718c00; } + + /* a keyword */ + .kwd { + color: #8959a8; } + + /* a comment */ + .com { + color: #8e908c; } + + /* a type name */ + .typ { + color: #4271ae; } + + /* a literal value */ + .lit { + color: #f5871f; } + + /* punctuation */ + .pun { + color: #4d4d4c; } + + /* lisp open bracket */ + .opn { + color: #4d4d4c; } + + /* lisp close bracket */ + .clo { + color: #4d4d4c; } + + /* a markup tag name */ + .tag { + color: #c82829; } + + /* a markup attribute name */ + .atn { + color: #f5871f; } + + /* a markup attribute value */ + .atv { + color: #3e999f; } + + /* a declaration */ + .dec { + color: #f5871f; } + + /* a variable name */ + .var { + color: #c82829; } + + /* a function name */ + .fun { + color: #4271ae; } } +/* Use higher contrast and text-weight for printable form. */ +@media print, projection { + .str { + color: #060; } + + .kwd { + color: #006; + font-weight: bold; } + + .com { + color: #600; + font-style: italic; } + + .typ { + color: #404; + font-weight: bold; } + + .lit { + color: #044; } + + .pun, .opn, .clo { + color: #440; } + + .tag { + color: #006; + font-weight: bold; } + + .atn { + color: #404; } + + .atv { + color: #060; } } +/* Style */ +/* +pre.prettyprint { + background: white; + font-family: Menlo, Monaco, Consolas, monospace; + font-size: 12px; + line-height: 1.5; + border: 1px solid #ccc; + padding: 10px; } +*/ + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; } + +/* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L4, +li.L5, +li.L6, +li.L7, +li.L8, +li.L9 { + /* */ } + +/* Alternate shading for lines */ +li.L1, +li.L3, +li.L5, +li.L7, +li.L9 { + /* */ } diff --git a/docs/jsapi/uci.js.html b/docs/jsapi/uci.js.html new file mode 100644 index 000000000..d61010f0e --- /dev/null +++ b/docs/jsapi/uci.js.html @@ -0,0 +1,994 @@ + + + + + JSDoc: Source: uci.js + + + + + + + + + + +
+ +

Source: uci.js

+ + + + + + +
+
+
'use strict';
+'require rpc';
+
+/**
+ * @class uci
+ * @memberof LuCI
+ * @hideconstructor
+ * @classdesc
+ *
+ * The `LuCI.uci` class utilizes {@link LuCI.rpc} to declare low level
+ * remote UCI `ubus` procedures and implements a local caching and data
+ * manipulation layer on top to allow for synchroneous operations on
+ * UCI configuration data.
+ */
+return L.Class.extend(/** @lends LuCI.uci.prototype */ {
+	__init__: function() {
+		this.state = {
+			newidx:  0,
+			values:  { },
+			creates: { },
+			changes: { },
+			deletes: { },
+			reorder: { }
+		};
+
+		this.loaded = {};
+	},
+
+	callLoad: rpc.declare({
+		object: 'uci',
+		method: 'get',
+		params: [ 'config' ],
+		expect: { values: { } }
+	}),
+
+
+	callOrder: rpc.declare({
+		object: 'uci',
+		method: 'order',
+		params: [ 'config', 'sections' ]
+	}),
+
+	callAdd: rpc.declare({
+		object: 'uci',
+		method: 'add',
+		params: [ 'config', 'type', 'name', 'values' ],
+		expect: { section: '' }
+	}),
+
+	callSet: rpc.declare({
+		object: 'uci',
+		method: 'set',
+		params: [ 'config', 'section', 'values' ]
+	}),
+
+	callDelete: rpc.declare({
+		object: 'uci',
+		method: 'delete',
+		params: [ 'config', 'section', 'options' ]
+	}),
+
+	callApply: rpc.declare({
+		object: 'uci',
+		method: 'apply',
+		params: [ 'timeout', 'rollback' ]
+	}),
+
+	callConfirm: rpc.declare({
+		object: 'uci',
+		method: 'confirm'
+	}),
+
+
+	/**
+	 * Generates a new, unique section ID for the given configuration.
+	 *
+	 * Note that the generated ID is temporary, it will get replaced by an
+	 * identifier in the form `cfgXXXXXX` once the configuration is saved
+	 * by the remote `ubus` UCI api.
+	 *
+	 * @param {string} config
+	 * The configuration to generate the new section ID for.
+	 *
+	 * @returns {string}
+	 * A newly generated, unique section ID in the form `newXXXXXX`
+	 * where `X` denotes a hexadecimal digit.
+	 */
+	createSID: function(conf) {
+		var v = this.state.values,
+		    n = this.state.creates,
+		    sid;
+
+		do {
+			sid = "new%06x".format(Math.random() * 0xFFFFFF);
+		} while ((n[conf] && n[conf][sid]) || (v[conf] && v[conf][sid]));
+
+		return sid;
+	},
+
+	/**
+	 * Resolves a given section ID in extended notation to the internal
+	 * section ID value.
+	 *
+	 * @param {string} config
+	 * The configuration to resolve the section ID for.
+	 *
+	 * @param {string} sid
+	 * The section ID to resolve. If the ID is in the form `@typename[#]`,
+	 * it will get resolved to an internal anonymous ID in the forms
+	 * `cfgXXXXXX`/`newXXXXXX` or to the name of a section in case it points
+	 * to a named section. When the given ID is not in extended notation,
+	 * it will be returned as-is.
+	 *
+	 * @returns {string|null}
+	 * Returns the resolved section ID or the original given ID if it was
+	 * not in extended notation. Returns `null` when an extended ID could
+	 * not be resolved to existing section ID.
+	 */
+	resolveSID: function(conf, sid) {
+		if (typeof(sid) != 'string')
+			return sid;
+
+		var m = /^@([a-zA-Z0-9_-]+)\[(-?[0-9]+)\]$/.exec(sid);
+
+		if (m) {
+			var type = m[1],
+			    pos = +m[2],
+			    sections = this.sections(conf, type),
+			    section = sections[pos >= 0 ? pos : sections.length + pos];
+
+			return section ? section['.name'] : null;
+		}
+
+		return sid;
+	},
+
+	/* private */
+	reorderSections: function() {
+		var v = this.state.values,
+		    n = this.state.creates,
+		    r = this.state.reorder,
+		    tasks = [];
+
+		if (Object.keys(r).length === 0)
+			return Promise.resolve();
+
+		/*
+		 gather all created and existing sections, sort them according
+		 to their index value and issue an uci order call
+		*/
+		for (var c in r) {
+			var o = [ ];
+
+			if (n[c])
+				for (var s in n[c])
+					o.push(n[c][s]);
+
+			for (var s in v[c])
+				o.push(v[c][s]);
+
+			if (o.length > 0) {
+				o.sort(function(a, b) {
+					return (a['.index'] - b['.index']);
+				});
+
+				var sids = [ ];
+
+				for (var i = 0; i < o.length; i++)
+					sids.push(o[i]['.name']);
+
+				tasks.push(this.callOrder(c, sids));
+			}
+		}
+
+		this.state.reorder = { };
+		return Promise.all(tasks);
+	},
+
+	/* private */
+	loadPackage: function(packageName) {
+		if (this.loaded[packageName] == null)
+			return (this.loaded[packageName] = this.callLoad(packageName));
+
+		return Promise.resolve(this.loaded[packageName]);
+	},
+
+	/**
+	 * Loads the given UCI configurations from the remote `ubus` api.
+	 *
+	 * Loaded configurations are cached and only loaded once. Subsequent
+	 * load operations of the same configurations will return the cached
+	 * data.
+	 *
+	 * To force reloading a configuration, it has to be unloaded with
+	 * {@link LuCI.uci#unload uci.unload()} first.
+	 *
+	 * @param {string|string[]} config
+	 * The name of the configuration or an array of configuration
+	 * names to load.
+	 *
+	 * @returns {Promise<string[]>}
+	 * Returns a promise resolving to the names of the configurations
+	 * that have been successfully loaded.
+	 */
+	load: function(packages) {
+		var self = this,
+		    pkgs = [ ],
+		    tasks = [];
+
+		if (!Array.isArray(packages))
+			packages = [ packages ];
+
+		for (var i = 0; i < packages.length; i++)
+			if (!self.state.values[packages[i]]) {
+				pkgs.push(packages[i]);
+				tasks.push(self.loadPackage(packages[i]));
+			}
+
+		return Promise.all(tasks).then(function(responses) {
+			for (var i = 0; i < responses.length; i++)
+				self.state.values[pkgs[i]] = responses[i];
+
+			if (responses.length)
+				document.dispatchEvent(new CustomEvent('uci-loaded'));
+
+			return pkgs;
+		});
+	},
+
+	/**
+	 * Unloads the given UCI configurations from the local cache.
+	 *
+	 * @param {string|string[]} config
+	 * The name of the configuration or an array of configuration
+	 * names to unload.
+	 */
+	unload: function(packages) {
+		if (!Array.isArray(packages))
+			packages = [ packages ];
+
+		for (var i = 0; i < packages.length; i++) {
+			delete this.state.values[packages[i]];
+			delete this.state.creates[packages[i]];
+			delete this.state.changes[packages[i]];
+			delete this.state.deletes[packages[i]];
+
+			delete this.loaded[packages[i]];
+		}
+	},
+
+	/**
+	 * Adds a new section of the given type to the given configuration,
+	 * optionally named according to the given name.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to add the section to.
+	 *
+	 * @param {string} type
+	 * The type of the section to add.
+	 *
+	 * @param {string} [name]
+	 * The name of the section to add. If the name is omitted, an anonymous
+	 * section will be added instead.
+	 *
+	 * @returns {string}
+	 * Returns the section ID of the newly added section which is equivalent
+	 * to the given name for non-anonymous sections.
+	 */
+	add: function(conf, type, name) {
+		var n = this.state.creates,
+		    sid = name || this.createSID(conf);
+
+		if (!n[conf])
+			n[conf] = { };
+
+		n[conf][sid] = {
+			'.type':      type,
+			'.name':      sid,
+			'.create':    name,
+			'.anonymous': !name,
+			'.index':     1000 + this.state.newidx++
+		};
+
+		return sid;
+	},
+
+	/**
+	 * Removes the section with the given ID from the given configuration.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to remove the section from.
+	 *
+	 * @param {string} sid
+	 * The ID of the section to remove.
+	 */
+	remove: function(conf, sid) {
+		var n = this.state.creates,
+		    c = this.state.changes,
+		    d = this.state.deletes;
+
+		/* requested deletion of a just created section */
+		if (n[conf] && n[conf][sid]) {
+			delete n[conf][sid];
+		}
+		else {
+			if (c[conf])
+				delete c[conf][sid];
+
+			if (!d[conf])
+				d[conf] = { };
+
+			d[conf][sid] = true;
+		}
+	},
+
+	/**
+	 * A section object represents the options and their corresponding values
+	 * enclosed within a configuration section, as well as some additional
+	 * meta data such as sort indexes and internal ID.
+	 *
+	 * Any internal metadata fields are prefixed with a dot which is isn't
+	 * an allowed character for normal option names.
+	 *
+	 * @typedef {Object<string, boolean|number|string|string[]>} SectionObject
+	 * @memberof LuCI.uci
+	 *
+	 * @property {boolean} .anonymous
+	 * The `.anonymous` property specifies whether the configuration is
+	 * anonymous (`true`) or named (`false`).
+	 *
+	 * @property {number} .index
+	 * The `.index` property specifes the sort order of the section.
+	 *
+	 * @property {string} .name
+	 * The `.name` property holds the name of the section object. It may be
+	 * either an anonymous ID in the form `cfgXXXXXX` or `newXXXXXX` with `X`
+	 * being a hexadecimal digit or a string holding the name of the section.
+	 *
+	 * @property {string} .type
+	 * The `.type` property contains the type of the corresponding uci
+	 * section.
+	 *
+	 * @property {string|string[]} *
+	 * A section object may contain an arbitrary number of further properties
+	 * representing the uci option enclosed in the section.
+	 *
+	 * All option property names will be in the form `[A-Za-z0-9_]+` and
+	 * either contain a string value or an array of strings, in case the
+	 * underlying option is an UCI list.
+	 */
+
+	/**
+	 * The sections callback is invoked for each section found within
+	 * the given configuration and receives the section object and its
+	 * associated name as arguments.
+	 *
+	 * @callback LuCI.uci~sectionsFn
+	 *
+	 * @param {LuCI.uci.SectionObject} section
+	 * The section object.
+	 *
+	 * @param {string} sid
+	 * The name or ID of the section.
+	 */
+
+	/**
+	 * Enumerates the sections of the given configuration, optionally
+	 * filtered by type.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to enumerate the sections for.
+	 *
+	 * @param {string} [type]
+	 * Enumerate only sections of the given type. If omitted, enumerate
+	 * all sections.
+	 *
+	 * @param {LuCI.uci~sectionsFn} [cb]
+	 * An optional callback to invoke for each enumerated section.
+	 *
+	 * @returns {Array<LuCI.uci.SectionObject>}
+	 * Returns a sorted array of the section objects within the given
+	 * configuration, filtered by type of a type has been specified.
+	 */
+	sections: function(conf, type, cb) {
+		var sa = [ ],
+		    v = this.state.values[conf],
+		    n = this.state.creates[conf],
+		    c = this.state.changes[conf],
+		    d = this.state.deletes[conf];
+
+		if (!v)
+			return sa;
+
+		for (var s in v)
+			if (!d || d[s] !== true)
+				if (!type || v[s]['.type'] == type)
+					sa.push(Object.assign({ }, v[s], c ? c[s] : undefined));
+
+		if (n)
+			for (var s in n)
+				if (!type || n[s]['.type'] == type)
+					sa.push(Object.assign({ }, n[s]));
+
+		sa.sort(function(a, b) {
+			return a['.index'] - b['.index'];
+		});
+
+		for (var i = 0; i < sa.length; i++)
+			sa[i]['.index'] = i;
+
+		if (typeof(cb) == 'function')
+			for (var i = 0; i < sa.length; i++)
+				cb.call(this, sa[i], sa[i]['.name']);
+
+		return sa;
+	},
+
+	/**
+	 * Gets the value of the given option within the specified section
+	 * of the given configuration or the entire section object if the
+	 * option name is omitted.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to read the value from.
+	 *
+	 * @param {string} sid
+	 * The name or ID of the section to read.
+	 *
+	 * @param {string} [option]
+	 * The option name to read the value from. If the option name is
+	 * omitted or `null`, the entire section is returned instead.
+	 *
+	 * @returns {null|string|string[]|LuCI.uci.SectionObject}
+	 * - Returns a string containing the option value in case of a
+	 *   plain UCI option.
+	 * - Returns an array of strings containing the option values in
+	 *   case of `option` pointing to an UCI list.
+	 * - Returns a {@link LuCI.uci.SectionObject section object} if
+	 *   the `option` argument has been omitted or is `null`.
+	 * - Returns `null` if the config, section or option has not been
+	 *   found or if the corresponding configuration is not loaded.
+	 */
+	get: function(conf, sid, opt) {
+		var v = this.state.values,
+		    n = this.state.creates,
+		    c = this.state.changes,
+		    d = this.state.deletes;
+
+		sid = this.resolveSID(conf, sid);
+
+		if (sid == null)
+			return null;
+
+		/* requested option in a just created section */
+		if (n[conf] && n[conf][sid]) {
+			if (!n[conf])
+				return undefined;
+
+			if (opt == null)
+				return n[conf][sid];
+
+			return n[conf][sid][opt];
+		}
+
+		/* requested an option value */
+		if (opt != null) {
+			/* check whether option was deleted */
+			if (d[conf] && d[conf][sid]) {
+				if (d[conf][sid] === true)
+					return undefined;
+
+				for (var i = 0; i < d[conf][sid].length; i++)
+					if (d[conf][sid][i] == opt)
+						return undefined;
+			}
+
+			/* check whether option was changed */
+			if (c[conf] && c[conf][sid] && c[conf][sid][opt] != null)
+				return c[conf][sid][opt];
+
+			/* return base value */
+			if (v[conf] && v[conf][sid])
+				return v[conf][sid][opt];
+
+			return undefined;
+		}
+
+		/* requested an entire section */
+		if (v[conf])
+			return v[conf][sid];
+
+		return undefined;
+	},
+
+	/**
+	 * Sets the value of the given option within the specified section
+	 * of the given configuration.
+	 *
+	 * If either config, section or option is null, or if `option` begins
+	 * with a dot, the function will do nothing.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to set the option value in.
+	 *
+	 * @param {string} sid
+	 * The name or ID of the section to set the option value in.
+	 *
+	 * @param {string} option
+	 * The option name to set the value for.
+	 *
+	 * @param {null|string|string[]} value
+	 * The option value to set. If the value is `null` or an empty string,
+	 * the option will be removed, otherwise it will be set or overwritten
+	 * with the given value.
+	 */
+	set: function(conf, sid, opt, val) {
+		var v = this.state.values,
+		    n = this.state.creates,
+		    c = this.state.changes,
+		    d = this.state.deletes;
+
+		sid = this.resolveSID(conf, sid);
+
+		if (sid == null || opt == null || opt.charAt(0) == '.')
+			return;
+
+		if (n[conf] && n[conf][sid]) {
+			if (val != null)
+				n[conf][sid][opt] = val;
+			else
+				delete n[conf][sid][opt];
+		}
+		else if (val != null && val !== '') {
+			/* do not set within deleted section */
+			if (d[conf] && d[conf][sid] === true)
+				return;
+
+			/* only set in existing sections */
+			if (!v[conf] || !v[conf][sid])
+				return;
+
+			if (!c[conf])
+				c[conf] = {};
+
+			if (!c[conf][sid])
+				c[conf][sid] = {};
+
+			/* undelete option */
+			if (d[conf] && d[conf][sid])
+				d[conf][sid] = d[conf][sid].filter(function(o) { return o !== opt });
+
+			c[conf][sid][opt] = val;
+		}
+		else {
+			/* only delete in existing sections */
+			if (!(v[conf] && v[conf][sid] && v[conf][sid].hasOwnProperty(opt)) &&
+			    !(c[conf] && c[conf][sid] && c[conf][sid].hasOwnProperty(opt)))
+			    return;
+
+			if (!d[conf])
+				d[conf] = { };
+
+			if (!d[conf][sid])
+				d[conf][sid] = [ ];
+
+			if (d[conf][sid] !== true)
+				d[conf][sid].push(opt);
+		}
+	},
+
+	/**
+	 * Remove the given option within the specified section of the given
+	 * configuration.
+	 *
+	 * This function is a convenience wrapper around
+	 * `uci.set(config, section, option, null)`.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to remove the option from.
+	 *
+	 * @param {string} sid
+	 * The name or ID of the section to remove the option from.
+	 *
+	 * @param {string} option
+	 * The name of the option to remove.
+	 */
+	unset: function(conf, sid, opt) {
+		return this.set(conf, sid, opt, null);
+	},
+
+	/**
+	 * Gets the value of the given option or the entire section object of
+	 * the first found section of the specified type or the first found
+	 * section of the entire configuration if no type is specfied.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to read the value from.
+	 *
+	 * @param {string} [type]
+	 * The type of the first section to find. If it is `null`, the first
+	 * section of the entire config is read, otherwise the first section
+	 * matching the given type.
+	 *
+	 * @param {string} [option]
+	 * The option name to read the value from. If the option name is
+	 * omitted or `null`, the entire section is returned instead.
+	 *
+	 * @returns {null|string|string[]|LuCI.uci.SectionObject}
+	 * - Returns a string containing the option value in case of a
+	 *   plain UCI option.
+	 * - Returns an array of strings containing the option values in
+	 *   case of `option` pointing to an UCI list.
+	 * - Returns a {@link LuCI.uci.SectionObject section object} if
+	 *   the `option` argument has been omitted or is `null`.
+	 * - Returns `null` if the config, section or option has not been
+	 *   found or if the corresponding configuration is not loaded.
+	 */
+	get_first: function(conf, type, opt) {
+		var sid = null;
+
+		this.sections(conf, type, function(s) {
+			if (sid == null)
+				sid = s['.name'];
+		});
+
+		return this.get(conf, sid, opt);
+	},
+
+	/**
+	 * Sets the value of the given option within the first found section
+	 * of the given configuration matching the specified type or within
+	 * the first section of the entire config when no type has is specified.
+	 *
+	 * If either config, type or option is null, or if `option` begins
+	 * with a dot, the function will do nothing.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to set the option value in.
+	 *
+	 * @param {string} [type]
+	 * The type of the first section to find. If it is `null`, the first
+	 * section of the entire config is written to, otherwise the first
+	 * section matching the given type is used.
+	 *
+	 * @param {string} option
+	 * The option name to set the value for.
+	 *
+	 * @param {null|string|string[]} value
+	 * The option value to set. If the value is `null` or an empty string,
+	 * the option will be removed, otherwise it will be set or overwritten
+	 * with the given value.
+	 */
+	set_first: function(conf, type, opt, val) {
+		var sid = null;
+
+		this.sections(conf, type, function(s) {
+			if (sid == null)
+				sid = s['.name'];
+		});
+
+		return this.set(conf, sid, opt, val);
+	},
+
+	/**
+	 * Removes the given option within the first found section of the given
+	 * configuration matching the specified type or within the first section
+	 * of the entire config when no type has is specified.
+	 *
+	 * This function is a convenience wrapper around
+	 * `uci.set_first(config, type, option, null)`.
+	 *
+	 * @param {string} config
+	 * The name of the configuration to set the option value in.
+	 *
+	 * @param {string} [type]
+	 * The type of the first section to find. If it is `null`, the first
+	 * section of the entire config is written to, otherwise the first
+	 * section matching the given type is used.
+	 *
+	 * @param {string} option
+	 * The option name to set the value for.
+	 */
+	unset_first: function(conf, type, opt) {
+		return this.set_first(conf, type, opt, null);
+	},
+
+	/**
+	 * Move the first specified section within the given configuration
+	 * before or after the second specified section.
+	 *
+	 * @param {string} config
+	 * The configuration to move the section within.
+	 *
+	 * @param {string} sid1
+	 * The ID of the section to move within the configuration.
+	 *
+	 * @param {string} [sid2]
+	 * The ID of the target section for the move operation. If the
+	 * `after` argument is `false` or not specified, the section named by
+	 * `sid1` will be moved before this target section, if the `after`
+	 * argument is `true`, the `sid1` section will be moved after this
+	 * section.
+	 *
+	 * When the `sid2` argument is `null`, the section specified by `sid1`
+	 * is moved to the end of the configuration.
+	 *
+	 * @param {boolean} [after=false]
+	 * When `true`, the section `sid1` is moved after the section `sid2`,
+	 * when `false`, the section `sid1` is moved before `sid2`.
+	 *
+	 * If `sid2` is null, then this parameter has no effect and the section
+	 * `sid1` is moved to the end of the configuration instead.
+	 *
+	 * @returns {boolean}
+	 * Returns `true` when the section was successfully moved, or `false`
+	 * when either the section specified by `sid1` or by `sid2` is not found.
+	 */
+	move: function(conf, sid1, sid2, after) {
+		var sa = this.sections(conf),
+		    s1 = null, s2 = null;
+
+		sid1 = this.resolveSID(conf, sid1);
+		sid2 = this.resolveSID(conf, sid2);
+
+		for (var i = 0; i < sa.length; i++) {
+			if (sa[i]['.name'] != sid1)
+				continue;
+
+			s1 = sa[i];
+			sa.splice(i, 1);
+			break;
+		}
+
+		if (s1 == null)
+			return false;
+
+		if (sid2 == null) {
+			sa.push(s1);
+		}
+		else {
+			for (var i = 0; i < sa.length; i++) {
+				if (sa[i]['.name'] != sid2)
+					continue;
+
+				s2 = sa[i];
+				sa.splice(i + !!after, 0, s1);
+				break;
+			}
+
+			if (s2 == null)
+				return false;
+		}
+
+		for (var i = 0; i < sa.length; i++)
+			this.get(conf, sa[i]['.name'])['.index'] = i;
+
+		this.state.reorder[conf] = true;
+
+		return true;
+	},
+
+	/**
+	 * Submits all local configuration changes to the remove `ubus` api,
+	 * adds, removes and reorders remote sections as needed and reloads
+	 * all loaded configurations to resynchronize the local state with
+	 * the remote configuration values.
+	 *
+	 * @returns {string[]}
+	 * Returns a promise resolving to an array of configuration names which
+	 * have been reloaded by the save operation.
+	 */
+	save: function() {
+		var v = this.state.values,
+		    n = this.state.creates,
+		    c = this.state.changes,
+		    d = this.state.deletes,
+		    r = this.state.reorder,
+		    self = this,
+		    snew = [ ],
+		    pkgs = { },
+		    tasks = [];
+
+		if (n)
+			for (var conf in n) {
+				for (var sid in n[conf]) {
+					var r = {
+						config: conf,
+						values: { }
+					};
+
+					for (var k in n[conf][sid]) {
+						if (k == '.type')
+							r.type = n[conf][sid][k];
+						else if (k == '.create')
+							r.name = n[conf][sid][k];
+						else if (k.charAt(0) != '.')
+							r.values[k] = n[conf][sid][k];
+					}
+
+					snew.push(n[conf][sid]);
+					tasks.push(self.callAdd(r.config, r.type, r.name, r.values));
+				}
+
+				pkgs[conf] = true;
+			}
+
+		if (c)
+			for (var conf in c) {
+				for (var sid in c[conf])
+					tasks.push(self.callSet(conf, sid, c[conf][sid]));
+
+				pkgs[conf] = true;
+			}
+
+		if (d)
+			for (var conf in d) {
+				for (var sid in d[conf]) {
+					var o = d[conf][sid];
+					tasks.push(self.callDelete(conf, sid, (o === true) ? null : o));
+				}
+
+				pkgs[conf] = true;
+			}
+
+		if (r)
+			for (var conf in r)
+				pkgs[conf] = true;
+
+		return Promise.all(tasks).then(function(responses) {
+			/*
+			 array "snew" holds references to the created uci sections,
+			 use it to assign the returned names of the new sections
+			*/
+			for (var i = 0; i < snew.length; i++)
+				snew[i]['.name'] = responses[i];
+
+			return self.reorderSections();
+		}).then(function() {
+			pkgs = Object.keys(pkgs);
+
+			self.unload(pkgs);
+
+			return self.load(pkgs);
+		});
+	},
+
+	/**
+	 * Instructs the remote `ubus` UCI api to commit all saved changes with
+	 * rollback protection and attempts to confirm the pending commit
+	 * operation to cancel the rollback timer.
+	 *
+	 * @param {number} [timeout=10]
+	 * Override the confirmation timeout after which a rollback is triggered.
+	 *
+	 * @returns {Promise<number>}
+	 * Returns a promise resolving/rejecting with the `ubus` RPC status code.
+	 */
+	apply: function(timeout) {
+		var self = this,
+		    date = new Date();
+
+		if (typeof(timeout) != 'number' || timeout < 1)
+			timeout = 10;
+
+		return self.callApply(timeout, true).then(function(rv) {
+			if (rv != 0)
+				return Promise.reject(rv);
+
+			var try_deadline = date.getTime() + 1000 * timeout;
+			var try_confirm = function() {
+				return self.callConfirm().then(function(rv) {
+					if (rv != 0) {
+						if (date.getTime() < try_deadline)
+							window.setTimeout(try_confirm, 250);
+						else
+							return Promise.reject(rv);
+					}
+
+					return rv;
+				});
+			};
+
+			window.setTimeout(try_confirm, 1000);
+		});
+	},
+
+	/**
+	 * An UCI change record is a plain array containing the change operation
+	 * name as first element, the affected section ID as second argument
+	 * and an optional third and fourth argument whose meanings depend on
+	 * the operation.
+	 *
+	 * @typedef {string[]} ChangeRecord
+	 * @memberof LuCI.uci
+	 *
+	 * @property {string} 0
+	 * The operation name - may be one of `add`, `set`, `remove`, `order`,
+	 * `list-add`, `list-del` or `rename`.
+	 *
+	 * @property {string} 1
+	 * The section ID targeted by the operation.
+	 *
+	 * @property {string} 2
+	 * The meaning of the third element depends on the operation.
+	 * - For `add` it is type of the section that has been added
+	 * - For `set` it either is the option name if a fourth element exists,
+	 *   or the type of a named section which has been added when the change
+	 *   entry only contains three elements.
+	 * - For `remove` it contains the name of the option that has been
+	 *   removed.
+	 * - For `order` it specifies the new sort index of the section.
+	 * - For `list-add` it contains the name of the list option a new value
+	 *   has been added to.
+	 * - For `list-del` it contains the name of the list option a value has
+	 *   been removed from.
+	 * - For `rename` it contains the name of the option that has been
+	 *   renamed if a fourth element exists, else it contains the new name
+	 *   a section has been renamed to if the change entry only contains
+	 *   three elements.
+	 *
+	 * @property {string} 4
+	 * The meaning of the fourth element depends on the operation.
+	 * - For `set` it is the value an option has been set to.
+	 * - For `list-add` it is the new value that has been added to a
+	 *   list option.
+	 * - For `rename` it is the new name of an option that has been
+	 *   renamed.
+	 */
+
+	/**
+	 * Fetches uncommitted UCI changes from the remote `ubus` RPC api.
+	 *
+	 * @method
+	 * @returns {Promise<Object<string, Array<LuCI.uci.ChangeRecord>>>}
+	 * Returns a promise resolving to an object containing the configuration
+	 * names as keys and arrays of related change records as values.
+	 */
+	changes: rpc.declare({
+		object: 'uci',
+		method: 'changes',
+		expect: { changes: { } }
+	})
+});
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.3 on Tue Nov 05 2019 09:33:05 GMT+0100 (Central European Standard Time) +
+ + + + + -- cgit v1.2.3