- Source:
Methods
addDevice(device) → {boolean}
Add the given network device to the logical interface.
Parameters:
Name | Type | Description |
---|---|---|
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
|
- Source:
Returns:
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.
- Type
- boolean
containsDevice(device) → {boolean}
Checks whether this logical interface contains the given device object.
Parameters:
Name | Type | Description |
---|---|---|
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
|
- Source:
Returns:
Returns true
when this logical interface contains the given network
device or false
if not.
- Type
- boolean
deleteDevice(device) → {boolean}
Remove the given network device from the logical interface.
Parameters:
Name | Type | Description |
---|---|---|
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
|
- Source:
Returns:
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.
- Type
- boolean
get(opt) → {null|string|Array.<string>}
Read the given UCI option value of this network.
Parameters:
Name | Type | Description |
---|---|---|
opt |
string | The UCI option name to read. |
- Source:
Returns:
Returns the UCI option value or null
if the requested option is
not found.
- Type
- null | string | Array.<string>
getDevice() → {LuCI.Network.Device}
Returns the Linux network device associated with this logical interface.
- Source:
Returns:
Returns a Network.Device
class instance representing the
expected Linux network device according to the configuration.
- Type
- LuCI.Network.Device
getDevices() → {null|Array.<LuCI.Network.Device>}
Returns a list of network sub-devices associated with this logical interface.
- Source:
Returns:
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.
- Type
- null | Array.<LuCI.Network.Device>
getDNS6Addrs() → {Array.<string>}
Query the IPv6 DNS servers associated with the logical interface.
- Source:
Returns:
Returns an array of IPv6 DNS servers registered by the remote protocol backend.
- Type
- Array.<string>
getDNSAddrs() → {Array.<string>}
Query the IPv4 DNS servers associated with the logical interface.
- Source:
Returns:
Returns an array of IPv4 DNS servers registered by the remote protocol backend.
- Type
- Array.<string>
getErrors() → {Array.<string>}
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.
- Source:
Returns:
Returns an array of translated interface error messages.
- Type
- Array.<string>
getExpiry() → {number}
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.
- Source:
Returns:
Returns the amount of seconds until the lease expires or -1
if it isn't applicable to the associated protocol.
- Type
- number
getGateway6Addr() → {string}
Query the gateway (nexthop) of the IPv6 default route associated with this logical interface.
- Source:
Returns:
Returns a string containing the IPv6 nexthop address of the associated
default route or null
if no default route was found.
- Type
- string
getGatewayAddr() → {string}
Query the gateway (nexthop) of the default route associated with this logical interface.
- Source:
Returns:
Returns a string containing the IPv4 nexthop address of the associated
default route or null
if no default route was found.
- Type
- string
(abstract) getI18n() → {string}
Return a human readable description for the protcol, such as
Static address
or DHCP client
.
This function should be overwritten by subclasses.
- Source:
Returns:
Returns the description string.
- Type
- string
getIfname() → {null|string}
Get the associared Linux network device of this network.
- Source:
Returns:
Returns the name of the associated network device or null
if
it could not be determined.
- Type
- null | string
getIP6Addr() → {null|string}
Query the first (primary) IPv6 address of the logical interface.
- Source:
Returns:
Returns the primary IPv6 address registered by the protocol handler
in CIDR notation or null
if no IPv6 addresses were set.
- Type
- null | string
getIP6Addrs() → {Array.<string>}
Query all IPv6 addresses of the logical interface.
- Source:
Returns:
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.
- Type
- Array.<string>
getIP6Prefix() → {null|string}
Query the routed IPv6 prefix associated with the logical interface.
- Source:
Returns:
Returns the routed IPv6 prefix registered by the remote protocol
handler or null
if no prefix is present.
- Type
- null | string
getIPAddr() → {null|string}
Query the first (primary) IPv4 address of the logical interface.
- Source:
Returns:
Returns the primary IPv4 address registered by the protocol handler
or null
if no IPv4 addresses were set.
- Type
- null | string
getIPAddrs() → {Array.<string>}
Query all IPv4 addresses of the logical interface.
- Source:
Returns:
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.
- Type
- Array.<string>
getL2Device() → {LuCI.Network.Device}
Returns the layer 2 linux network device currently associated with this logical interface.
- Source:
Returns:
Returns a Network.Device
class instance representing the Linux
network device currently associated with the logical interface.
- Type
- LuCI.Network.Device
getL3Device() → {LuCI.Network.Device}
Returns the layer 3 linux network device currently associated with this logical interface.
- Source:
Returns:
Returns a Network.Device
class instance representing the Linux
network device currently associated with the logical interface.
- Type
- LuCI.Network.Device
getMetric() → {number}
Get the metric value of the logical interface.
- Source:
Returns:
Returns the current metric value used for device and network routes spawned by the associated logical interface.
- Type
- number
getName() → {string}
Get the name of the associated logical interface.
- Source:
Returns:
Returns the logical interface name, such as lan
or wan
.
- Type
- string
getNetmask() → {null|string}
Query the first (primary) IPv4 netmask of the logical interface.
- Source:
Returns:
Returns the netmask of the primary IPv4 address registered by the
protocol handler or null
if no IPv4 addresses were set.
- Type
- null | string
(abstract) getOpkgPackage() → {string}
Get the name of the opkg package providing the protocol functionality.
This function should be overwritten by protocol specific subclasses.
- Source:
Returns:
Returns the name of the opkg package required for the protocol to
function, e.g. odhcp6c
for the dhcpv6
prototocol.
- Type
- string
(abstract) getProtocol() → {string}
Get the name of this network protocol class.
This function will be overwritten by subclasses created by
Network.registerProtocol()
.
- Source:
Returns:
Returns the name of the network protocol implementation, e.g.
static
or dhcp
.
- Type
- string
getType() → {null|string}
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.
- Source:
Returns:
Returns the value of the type
option of the associated logical
interface or null
if no type
option is set.
- Type
- null | string
getUptime() → {number}
Get the uptime of the logical interface.
- Source:
Returns:
Returns the uptime of the associated interface in seconds.
- Type
- number
getZoneName() → {null|string}
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.
- Source:
Returns:
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.
- Type
- null | string
isAlias() → {null|string}
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.
- Source:
Returns:
Returns the name of the parent interface if this logical interface
is an alias or null
if it is not an alias interface.
- Type
- null | string
isBridge() → {boolean}
Checks whether the underlying logical interface is declared as bridge.
- Source:
Returns:
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.
- Type
- boolean
isDynamic() → {boolean}
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.
- Source:
Returns:
Returns a boolean indicating whether this interface is dynamic (true
)
or not (false
).
- Type
- boolean
isEmpty() → {boolean}
Checks whether this logical interface is "empty", meaning that ut has no network devices attached.
- Source:
Returns:
Returns true
if this logical interface is empty, else false
.
- Type
- boolean
isFloating() → {boolean}
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
- Source:
Returns:
Returns a boolean indicating whether this protocol is floating (true
)
or not (false
).
- Type
- boolean
(abstract) isInstalled() → {boolean}
Checks whether the protocol functionality is installed.
This function exists for compatibility with old code, it always
returns true
.
- Deprecated:
- Yes
- Source:
Returns:
Returns true
if the protocol support is installed, else false
.
- Type
- boolean
isUp() → {boolean}
Checks whether this logical interface is configured and running.
- Source:
Returns:
Returns true
when the interface is active or false
when it is not.
- Type
- boolean
isVirtual() → {boolean}
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.
- Source:
Returns:
Returns a boolean indicating whether the underlying protocol spawns
dynamic interfaces (true
) or not (false
).
- Type
- boolean
set(opt, val)
Set the given UCI option of this network to the given value.
Parameters:
Name | Type | Description |
---|---|---|
opt |
string | The name of the UCI option to set. |
val |
null | string | Array.<string> | The value to set or |
- Source: