123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html>
- <head>
- <title>Reference</title>
- <link rel="stylesheet" href="../luadoc.css" type="text/css" />
- <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
- </head>
- <body>
- <div id="container">
- <div id="product">
- <div id="product_logo"></div>
- <div id="product_name"><big><b></b></big></div>
- <div id="product_description"></div>
- </div> <!-- id="product" -->
- <div id="main">
- <div id="navigation">
- <h1>LuaDoc</h1>
- <ul>
-
- <li><a href="../index.html">Index</a></li>
-
- </ul>
- <!-- Module list -->
- <h1>Modules</h1>
- <ul>
- <li>
- <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
- </li>
- <li>
- <a href="../modules/luci.http.html">luci.http</a>
- </li>
- <li>
- <a href="../modules/luci.http.conditionals.html">luci.http.conditionals</a>
- </li>
- <li>
- <a href="../modules/luci.http.date.html">luci.http.date</a>
- </li>
- <li>
- <a href="../modules/luci.http.mime.html">luci.http.mime</a>
- </li>
- <li>
- <a href="../modules/luci.i18n.html">luci.i18n</a>
- </li>
- <li><strong>luci.ip</strong></li>
-
- <li>
- <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
- </li>
- <li>
- <a href="../modules/luci.json.html">luci.json</a>
- </li>
- <li>
- <a href="../modules/luci.jsonc.html">luci.jsonc</a>
- </li>
- <li>
- <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
- </li>
- <li>
- <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
- </li>
- <li>
- <a href="../modules/luci.model.uci.html">luci.model.uci</a>
- </li>
- <li>
- <a href="../modules/luci.rpcc.html">luci.rpcc</a>
- </li>
- <li>
- <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
- </li>
- <li>
- <a href="../modules/luci.sys.html">luci.sys</a>
- </li>
- <li>
- <a href="../modules/luci.sys.init.html">luci.sys.init</a>
- </li>
- <li>
- <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
- </li>
- <li>
- <a href="../modules/luci.sys.net.html">luci.sys.net</a>
- </li>
- <li>
- <a href="../modules/luci.sys.process.html">luci.sys.process</a>
- </li>
- <li>
- <a href="../modules/luci.sys.user.html">luci.sys.user</a>
- </li>
- <li>
- <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
- </li>
- <li>
- <a href="../modules/luci.util.html">luci.util</a>
- </li>
- <li>
- <a href="../modules/luci.xml.html">luci.xml</a>
- </li>
- <li>
- <a href="../modules/nixio.html">nixio</a>
- </li>
- <li>
- <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
- </li>
- <li>
- <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
- </li>
- <li>
- <a href="../modules/nixio.File.html">nixio.File</a>
- </li>
- <li>
- <a href="../modules/nixio.README.html">nixio.README</a>
- </li>
- <li>
- <a href="../modules/nixio.Socket.html">nixio.Socket</a>
- </li>
- <li>
- <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
- </li>
- <li>
- <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
- </li>
- <li>
- <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
- </li>
- <li>
- <a href="../modules/nixio.bin.html">nixio.bin</a>
- </li>
- <li>
- <a href="../modules/nixio.bit.html">nixio.bit</a>
- </li>
- <li>
- <a href="../modules/nixio.crypto.html">nixio.crypto</a>
- </li>
- <li>
- <a href="../modules/nixio.fs.html">nixio.fs</a>
- </li>
- </ul>
- <!-- File list -->
- </div><!-- id="navigation" -->
- <div id="content">
- <h1>Class <code>luci.ip</code></h1>
- <p>
- LuCI IP calculation and netlink access library.</p>
- <h2>Functions</h2>
- <table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#new">new</a> (address, netmask)</td>
- <td class="summary">
-
- Construct a new luci.ip.cidr instance and autodetect the address family.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#IPv4">IPv4</a> (address, netmask)</td>
- <td class="summary">
-
- Construct a new IPv4 luci.ip.cidr instance.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#IPv6">IPv6</a> (address, netmask)</td>
- <td class="summary">
-
- Construct a new IPv6 luci.ip.cidr instance.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#MAC">MAC</a> (address, netmask)</td>
- <td class="summary">
-
- Construct a new MAC luci.ip.cidr instance.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#checkip4">checkip4</a> (address)</td>
- <td class="summary">
-
- Verify an IPv4 address.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#checkip6">checkip6</a> (address)</td>
- <td class="summary">
-
- Verify an IPv6 address.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#checkmac">checkmac</a> (address)</td>
- <td class="summary">
-
- Verify an ethernet MAC address.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#route">route</a> (address, source)</td>
- <td class="summary">
-
- Determine the route leading to the given destination.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#routes">routes</a> (filter, callback)</td>
- <td class="summary">
-
- Fetch all routes, optionally matching the given criteria.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#neighbors">neighbors</a> (filter, callback)</td>
- <td class="summary">
-
- Fetches entries from the IPv4 ARP and IPv6 neighbour kernel table </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#link">link</a> (device)</td>
- <td class="summary">
-
- Fetch basic device information </td>
- </tr>
- </table>
- <br/>
- <br/>
- <h2><a name="functions"></a>Functions</h2>
- <dl class="function">
- <dt><a name="new"></a><strong>new</strong> (address, netmask)</dt>
- <dd>
-
- 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.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- address: String containing a valid IPv4 or IPv6 address, optionally
- with prefix size (CIDR notation) or netmask separated by slash.
- </li>
-
- <li>
- netmask: String containing a valid IPv4 or IPv6 netmask or number
- containing a prefix size in bits (<code>0..32</code> for IPv4,
- <code>0..128</code> for IPv6). Overrides mask embedded in the first argument
- if specified. (optional)
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <pre>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</pre>
- <h3>Return value:</h3>
- A <code>luci.ip.cidr</code> object representing the given
- address/mask range.
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#IPv4">
- IPv4
- </a>
-
- <li><a href="#IPv6">
- IPv6
- </a>
-
- <li><a href="#MAC">
- MAC
- </a>
-
- </ul>
- </dd>
- <dt><a name="IPv4"></a><strong>IPv4</strong> (address, netmask)</dt>
- <dd>
-
- 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.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- address: String containing a valid IPv4, optionally with prefix size
- (CIDR notation) or netmask separated by slash.
- </li>
-
- <li>
- netmask: String containing a valid IPv4 netmask or number
- containing a prefix size between <code>0</code> and <code>32</code> bit.
- Overrides mask embedded in the first argument if specified. (optional)
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <pre>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</pre>
- <h3>Return value:</h3>
- A <code>luci.ip.cidr</code> object representing the given IPv4 range.
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#IPv6">
- IPv6
- </a>
-
- <li><a href="#MAC">
- MAC
- </a>
-
- </ul>
- </dd>
- <dt><a name="IPv6"></a><strong>IPv6</strong> (address, netmask)</dt>
- <dd>
-
- 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.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- address: String containing a valid IPv6, optionally with prefix size
- (CIDR notation) or netmask separated by slash.
- </li>
-
- <li>
- netmask: String containing a valid IPv4 netmask or number
- containing a prefix size between <code>0</code> and <code>128</code> bit.
- Overrides mask embedded in the first argument if specified. (optional)
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <pre>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</pre>
- <h3>Return value:</h3>
- A <code>luci.ip.cidr</code> object representing the given IPv6 range.
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#IPv4">
- IPv4
- </a>
-
- <li><a href="#MAC">
- MAC
- </a>
-
- </ul>
- </dd>
- <dt><a name="MAC"></a><strong>MAC</strong> (address, netmask)</dt>
- <dd>
-
- 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.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- address: String containing a valid ethernet MAC address, optionally with
- prefix size (CIDR notation) or mask separated by slash.
- </li>
-
- <li>
- netmask: String containing a valid MAC address mask or number
- containing a prefix size between <code>0</code> and <code>48</code> bit.
- Overrides mask embedded in the first argument if specified. (optional)
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <pre>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</pre>
- <h3>Return value:</h3>
- A <code>luci.ip.cidr</code> object representing the given MAC address range.
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#IPv4">
- IPv4
- </a>
-
- <li><a href="#IPv6">
- IPv6
- </a>
-
- </ul>
- </dd>
- <dt><a name="checkip4"></a><strong>checkip4</strong> (address)</dt>
- <dd>
-
- 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.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- address: String containing a valid IPv4 address or existing
- luci.ip.cidr IPv4 instance.
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <pre>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</pre>
- <h3>Return value:</h3>
- A string representing the given IPv4 address.
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#checkip6">
- checkip6
- </a>
-
- <li><a href="#checkmac">
- checkmac
- </a>
-
- </ul>
- </dd>
- <dt><a name="checkip6"></a><strong>checkip6</strong> (address)</dt>
- <dd>
-
- 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.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- address: String containing a valid IPv6 address or existing
- luci.ip.cidr IPv6 instance.
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <pre>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</pre>
- <h3>Return value:</h3>
- A string representing the given IPv6 address.
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#checkip4">
- checkip4
- </a>
-
- <li><a href="#checkmac">
- checkmac
- </a>
-
- </ul>
- </dd>
- <dt><a name="checkmac"></a><strong>checkmac</strong> (address)</dt>
- <dd>
-
- 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.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- address: String containing a valid MAC address or existing luci.ip.cidr
- MAC address instance.
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <pre>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</pre>
- <h3>Return value:</h3>
- A string representing the given MAC address.
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#checkip4">
- checkip4
- </a>
-
- <li><a href="#checkip6">
- checkip6
- </a>
-
- </ul>
- </dd>
- <dt><a name="route"></a><strong>route</strong> (address, source)</dt>
- <dd>
-
- Determine the route leading to the given destination.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- address: A <code>luci.ip.cidr</code> instance or a string containing
- a valid IPv4 or IPv6 range as specified by <code>luci.ip.new()</code>.
- </li>
-
- <li>
- source: A <code>luci.ip.cidr</code> instance or a string containing
- the preferred source address for route selection (optional).
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <ul>
- <li>Find default gateway by getting route to Google's public NS server
- <pre>rt = luci.ip.route("8.8.8.8")
- if rt ~= nil then
- print("gateway is", rt.gw)
- end</pre></li>
- <li>Determine IPv6 upstream interface <pre>rt = luci.ip.route("2001::/7")
- if rt ~= nil then
- print("ipv6 upstream device is", rt.dev)
- end</pre></li>
- </ul>
- <h3>Return value:</h3>
- <p>Table containing the fields described below.</p>
- <table id="routetable">
- <tr><th>Field</th><th>Description</th></tr>
- <tr><td><code>type</code><td>
- <p>Route type with one of the following numeric values:</p>
- <table>
- <tr>
- <td><code>1</code></td>
- <td><code>RTN_UNICAST</code> - Gateway or direct route</td>
- </tr>
- <tr>
- <td><code>2</code></td>
- <td><code>RTN_LOCAL</code> - Accept locally</td>
- </tr>
- <tr>
- <td><code>3</code></td>
- <td><code>RTN_BROADCAST</code> -
- Accept locally as broadcast send as broadcast</td>
- </tr>
- <tr>
- <td><code>4</code></td>
- <td><code>RTN_ANYCAST</code> -
- Accept locally as broadcast but send as unicast</td>
- </tr>
- <tr>
- <td><code>5</code></td>
- <td><code>RTN_MULTICAST</code> - Multicast route</td>
- </tr>
- </table>
- </td></tr>
- <tr>
- <td><code>family</code></td>
- <td>Number containing the route family, <code>4</code> for IPv4 or
- <code>6</code> for IPv6</td>
- </tr>
- <tr>
- <td><code>dest</code></td>
- <td>Destination <code>luci.ip.cidr</code> instance</td>
- </tr>
- <tr>
- <td><code>gw</code></td>
- <td>Gateway <code>luci.ip.cidr</code> instance (optional)</td>
- </tr>
- <tr>
- <td><code>from</code></td>
- <td>Source address <code>luci.ip.cidr</code> instance (optional)</td>
- </tr>
- <tr>
- <td><code>src</code></td>
- <td>Preferred source <code>luci.ip.cidr</code> instance (optional)</td>
- </tr>
- <tr>
- <td><code>dev</code></td>
- <td>String containing the name of the outgoing interface</td>
- </tr>
- <tr>
- <td><code>iif</code></td>
- <td>String containing the name of the incoming interface (optional)</td>
- </tr>
- <tr>
- <td><code>table</code></td>
- <td>Number of the associated routing table (<code>0..65535</code>)</td>
- </tr>
- <tr>
- <td><code>proto</code></td>
- <td>Number of the associated routing protocol</td>
- </tr>
- <tr>
- <td><code>scope</code></td>
- <td>Number describing the scope of the route, most commonly
- <code>0</code> for global or <code>253</code> for on-link</td>
- </tr>
- <tr>
- <td><code>metric</code></td>
- <td>Number describing the route metric (optional)</td>
- </tr>
- <tr>
- <td><code>expires</code></td>
- <td>Number of seconds the prefix is valid (IPv6 only, optional)</td>
- </tr>
- <tr>
- <td><code>error</code></td>
- <td>Route destination error code (optional)</td>
- </tr>
- </table>
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#routes">
- routes
- </a>
-
- </ul>
- </dd>
- <dt><a name="routes"></a><strong>routes</strong> (filter, callback)</dt>
- <dd>
-
- Fetch all routes, optionally matching the given criteria.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- filter: <p>Table containing one or more of the possible filter
- criteria described below (optional)</p><table>
- <tr><th>Field</th><th>Description</th></tr>
- <tr><td><code>family</code></td><td>
- Number describing the address family to return - <code>4</code> selects
- IPv4 routes, <code>6</code> IPv6 ones. Any other value selects both.
- </td></tr>
- <tr><td><code>iif</code></td><td>
- String containing the incoming route interface to match.
- </td></tr>
- <tr><td><code>oif</code></td><td>
- String containing the outgoing route interface to match.
- </td></tr>
- <tr><td><code>type</code></td><td>
- Numeric type to match, e.g. <code>1</code> for unicast.
- </td></tr>
- <tr><td><code>scope</code></td><td>
- Numeric scope to match, e.g. <code>253</code> for onlink.
- </td></tr>
- <tr><td><code>proto</code></td><td>
- Numeric protocol to match, e.g. <code>2</code> for boot.
- </td></tr>
- <tr><td><code>table</code></td><td>
- Numeric routing table to match (<code>0..65535</code>).
- </td></tr>
- <tr><td><code>gw</code></td><td>
- String containing the gateway address to match. Can be in any notation
- specified by <code>luci.ip.new()</code>. Prefix matching is performed when
- comparing the routes, e.g. "192.168.1.0/24" would select routes with gateway
- addresses <code>192.168.1.1 .. 192.168.1.255</code>.
- </td></tr>
- <tr><td><code>dest</code></td><td>
- String containing the destination to match. Prefix matching is performed.
- </td></tr>
- <tr><td><code>from</code></td><td>
- String containing the source address to match. Prefix matching is performed.
- </td></tr>
- <tr><td><code>src</code></td><td>
- String containing the preferred source address to match.
- Prefix matching is performed.
- </td></tr>
- <tr><td><code>dest_exact</code></td><td>
- String containing the destination to match. Exact matching is performed,
- e.g. <code>dest = "0.0.0.0/0"</code> would match <em>any</em> IPv4 route
- while <code>dest_exact = "0.0.0.0/0"</code> will <em>only</em> match the
- default route.
- </td></tr>
- <tr><td><code>from_exact</code></td><td>
- String containing the source address to match. Exact matching is performed.
- </td></tr>
- </table>
- </li>
-
- <li>
- callback: <p>Callback function to invoke for each found route
- instead of returning one table of route objects (optional)</p>
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <ul>
- <li>Find all IPv4 default routes:
- <pre>luci.ip.routes({ dest_exact = "0.0.0.0/0" }, function(rt)
- print(rt.type, rt.gw, rt.dev)
- end)</pre></li>
- <li>Find all global IPv6 prefixes on the current system:
- <pre>luci.ip.routes({ from = "2001::/7" }, function(rt)
- print(rt.from)
- end)</pre></li>
- <li>Fetch all IPv4 routes:
- <pre>routes = luci.ip.routes({ family = 4 })
- for _, rt in ipairs(routes) do
- print(rt.dest, rt.gw, rt.dev)
- end</pre></li>
- </ul>
- <h3>Return value:</h3>
- If no callback function is provided, a table of routes
- <a href="#routetable">as specified by <code>luci.ip.route()</code></a>
- is returned. If a callback function is given, it is invoked for each route
- and nothing is returned.
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#route">
- route
- </a>
-
- </ul>
- </dd>
- <dt><a name="neighbors"></a><strong>neighbors</strong> (filter, callback)</dt>
- <dd>
-
- Fetches entries from the IPv4 ARP and IPv6 neighbour kernel table
- <h3>Parameters</h3>
- <ul>
-
- <li>
- filter: <p>Table containing one or more of the possible filter
- criteria described below (optional)</p><table>
- <tr><th>Field</th><th>Description</th></tr>
- <tr><td><code>family</code></td><td>
- Number describing the address family to return - <code>4</code> selects
- IPv4 ARP, <code>6</code> select IPv6 neighbour entries. Any other value
- selects both.
- </td></tr>
- <tr><td><code>dev</code></td><td>
- String containing the associated interface to match.
- </td></tr>
- <tr><td><code>dest</code></td><td>
- String containing the associated address to match. Can be in any notation
- specified by <code>luci.ip.new()</code>. Prefix matching is performed when
- comparing the addresses, e.g. "192.168.1.0/24" would select ARP entries
- for <code>192.168.1.1 .. 192.168.1.255</code>.
- </td></tr>
- <tr><td><code>mac</code></td><td>
- String containing MAC address to match.
- </td></tr>
- </table>
- </li>
-
- <li>
- callback: <p>Callback function to invoke for each found neighbour
- entry instead of returning one table of neighbour entries (optional)</p>
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <ul>
- <li>Find all ARP neighbours in the LAN:
- <pre>luci.ip.neighbors({ dest = "192.168.0.0/16" }, function(n)
- print(n.dest, n.mac)
- end)</pre></li>
- <li>Find all active IPv6 addresses of host with given MAC:
- <pre>luci.ip.neighbors({ family = 6, mac = "00:21:63:75:aa:17" },
- function(n)
- print(n.dest)
- end)</pre></li>
- </ul>
- <h3>Return value:</h3>
- 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:
-
- <table>
- <tr><th>Field</th><th>Description</th></tr>
- <tr>
- <td><code>family</code></td>
- <td>Number containing the neighbour entry family, <code>4</code> for IPv4
- ARP or <code>6</code> for IPv6 NDP</td>
- </tr>
- <tr>
- <td><code>dev</code></td>
- <td>String containing the associated device of the neighbour entry</td>
- </tr>
- <tr>
- <td><code>dest</code></td>
- <td>IP address <code>luci.ip.cidr</code> instance</td>
- </tr>
- <tr>
- <td><code>mac</code></td>
- <td>MAC address <code>luci.ip.cidr</code> instance</td>
- </tr>
- <tr>
- <td><code>router</code></td>
- <td>Boolean "true" if the neighbour entry is a router (IPv6, optional)</td>
- </tr>
- <tr>
- <td><code>proxy</code></td>
- <td>Boolean "true" if this is a proxy entry (optional)</td>
- </tr>
- <tr>
- <td><code>incomplete</code></td>
- <td>Boolean "true" if the entry is in incomplete state (optional)</td>
- </tr>
- <tr>
- <td><code>reachable</code></td>
- <td>Boolean "true" if the entry is in reachable state (optional)</td>
- </tr>
- <tr>
- <td><code>stale</code></td>
- <td>Boolean "true" if the entry is stale (optional)</td>
- </tr>
- <tr>
- <td><code>delay</code></td>
- <td>Boolean "true" if the entry is delayed (optional)</td>
- </tr>
- <tr>
- <td><code>probe</code></td>
- <td>Boolean "true" if the entry is in probe state (optional)</td>
- </tr>
- <tr>
- <td><code>failed</code></td>
- <td>Boolean "true" if the entry is in failed state (optional)</td>
- </tr>
- <tr>
- <td><code>noarp</code></td>
- <td>Boolean "true" if the entry is not caused by NDP or
- ARP (optional)</td>
- </tr>
- <tr>
- <td><code>permanent</code></td>
- <td>Boolean "true" if the entry was statically configured from
- userspace (optional)</td>
- </tr>
- </table>
- </dd>
- <dt><a name="link"></a><strong>link</strong> (device)</dt>
- <dd>
-
- Fetch basic device information
- <h3>Parameters</h3>
- <ul>
-
- <li>
- device: String containing the network device to query
- </li>
-
- </ul>
- <h3>Usage:</h3>
- <ul>
- <li>Test whether device br-lan exists:
- <pre>print(luci.ip.link("br-lan").name ~= nil)
- </pre></li>
- <li>Query MAC address of eth0:
- <pre>print(luci.ip.link("eth0").mac)
- </pre></li>
- </ul>
- <h3>Return value:</h3>
- If the given interface is found, a table containing the fields
- described below is returned, else an empty table.
-
- <table>
- <tr><th>Field</th><th>Description</th></tr>
- <tr>
- <td><code>up</code></td>
- <td>Boolean indicating whether the device is in IFF_RUNNING state</td>
- </tr>
- <tr>
- <td><code>type</code></td>
- <td>Numeric value indicating the type of the device, e.g. <code>1</code>
- for ethernet.</td>
- </tr>
- <tr>
- <td><code>name</code></td>
- <td>String containing the name of the device</td>
- </tr>
- <tr>
- <td><code>master</code></td>
- <td>If queried device is a bridge port, string containing the name of
- parent bridge device (optional)</td>
- </tr>
- <tr>
- <td><code>mtu</code></td>
- <td>Number containing the current MTU of the device</td>
- </tr>
- <tr>
- <td><code>qlen</code></td>
- <td>Number containing the TX queue length of the device</td>
- </tr>
- <tr>
- <td><code>mac</code></td>
- <td>MAC address <code>luci.ip.cidr</code> instance representing the device ethernet
- address</td>
- </tr>
- </table>
- </dd>
- </dl>
- </div> <!-- id="content" -->
- </div> <!-- id="main" -->
- <div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
- </div> <!-- id="about" -->
- </div> <!-- id="container" -->
- </body>
- </html>
|