From 2e6118888156b66d8a84e6487de12d5ba88a6a6e Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 1 Sep 2015 12:19:27 +0200 Subject: Add generated documentation to repository Signed-off-by: Jo-Philipp Wich --- doc/modules/luci.ip.html | 902 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 902 insertions(+) create mode 100644 doc/modules/luci.ip.html (limited to 'doc/modules/luci.ip.html') diff --git a/doc/modules/luci.ip.html b/doc/modules/luci.ip.html new file mode 100644 index 0000000000..8a78da204c --- /dev/null +++ b/doc/modules/luci.ip.html @@ -0,0 +1,902 @@ + + + + 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.
route (address) + +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.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
+ + + +

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

See also:

+ + +
+ + + + +
route (address)
+
+ + +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(). +
  • + +
+ + + + +

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 +critera 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 +critera 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
macString containing the associated MAC address
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
macString containing the link local address of the device in + dotted hex notation
+ + + +
+ + +
+ + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + -- cgit v1.2.3