summaryrefslogtreecommitdiffhomepage
path: root/docs/api/modules/luci.ip.cidr.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/api/modules/luci.ip.cidr.html')
-rw-r--r--docs/api/modules/luci.ip.cidr.html1511
1 files changed, 1511 insertions, 0 deletions
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 @@
+<!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>
+ <a href="../modules/luci.ip.html">luci.ip</a>
+ </li>
+
+ <li><strong>luci.ip.cidr</strong></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/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>Object Instance <code>luci.ip.cidr</code></h1>
+
+<p>
+ IP CIDR Object.
+ Represents an IPv4 or IPv6 address range.</p>
+
+
+
+
+
+
+
+<h2>Functions</h2>
+<table class="function_list">
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.is4">cidr:is4</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is an IPv4 address range
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.is4rfc1918">cidr:is4rfc1918</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is within the private RFC1918 address space
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.is4linklocal">cidr:is4linklocal</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is an IPv4 link local (Zeroconf) address
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.is6">cidr:is6</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is an IPv6 address range
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.is6linklocal">cidr:is6linklocal</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is an IPv6 link local address
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.is6mapped4">cidr:is6mapped4</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is an IPv6 mapped IPv4 address
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.ismac">cidr:ismac</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is an ethernet MAC address range
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.ismaclocal">cidr:ismaclocal</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is a locally administered (LAA) MAC address
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.ismacmcast">cidr:ismacmcast</a>&nbsp;()</td>
+ <td class="summary">
+
+Checks whether the CIDR instance is a multicast MAC address
+ </td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.lower">cidr:lower</a>&nbsp;(addr)</td>
+ <td class="summary">
+
+Checks whether this CIDR instance is lower than the given argument.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.higher">cidr:higher</a>&nbsp;(addr)</td>
+ <td class="summary">
+
+Checks whether this CIDR instance is higher than the given argument.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.equal">cidr:equal</a>&nbsp;(addr)</td>
+ <td class="summary">
+
+Checks whether this CIDR instance is equal to the given argument.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.prefix">cidr:prefix</a>&nbsp;(mask)</td>
+ <td class="summary">
+
+Get or set prefix size of CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.network">cidr:network</a>&nbsp;(mask)</td>
+ <td class="summary">
+
+Derive network address of CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.host">cidr:host</a>&nbsp;()</td>
+ <td class="summary">
+
+Derive host address of CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.mask">cidr:mask</a>&nbsp;(mask)</td>
+ <td class="summary">
+
+Derive netmask of CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.broadcast">cidr:broadcast</a>&nbsp;(mask)</td>
+ <td class="summary">
+
+Derive broadcast address of CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.mapped4">cidr:mapped4</a>&nbsp;()</td>
+ <td class="summary">
+
+Derive mapped IPv4 address of CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.tomac">cidr:tomac</a>&nbsp;()</td>
+ <td class="summary">
+
+Derive MAC address of IPv6 link local CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.tolinklocal">cidr:tolinklocal</a>&nbsp;()</td>
+ <td class="summary">
+
+Derive IPv6 link local address from MAC address CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.contains">cidr:contains</a>&nbsp;(addr)</td>
+ <td class="summary">
+
+Test whether CIDR contains given range.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.add">cidr:add</a>&nbsp;(amount, inplace)</td>
+ <td class="summary">
+
+Add given amount to CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.sub">cidr:sub</a>&nbsp;(amount, inplace)</td>
+ <td class="summary">
+
+Subtract given amount from CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.minhost">cidr:minhost</a>&nbsp;()</td>
+ <td class="summary">
+
+Calculate the lowest possible host address within this CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.maxhost">cidr:maxhost</a>&nbsp;()</td>
+ <td class="summary">
+
+Calculate the highest possible host address within this CIDR instance.</td>
+ </tr>
+
+ <tr>
+ <td class="name" nowrap><a href="#cidr.string">cidr:string</a>&nbsp;()</td>
+ <td class="summary">
+
+Convert CIDR instance into string representation.</td>
+ </tr>
+
+</table>
+
+
+
+
+
+
+<br/>
+<br/>
+
+
+<h2><a name="functions"></a>Functions</h2>
+<dl class="function">
+
+
+
+<dt><a name="cidr.is4"></a><strong>cidr:is4</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is an IPv4 address range
+
+
+
+
+
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the CIDR is an IPv4 range, else <code>false</code>
+
+
+
+<h3>See also:</h3>
+<ul>
+
+ <li><a href="#cidr.is6">
+ cidr:is6
+ </a>
+
+ <li><a href="#cidr.ismac">
+ cidr:ismac
+ </a>
+
+</ul>
+
+</dd>
+
+
+
+
+<dt><a name="cidr.is4rfc1918"></a><strong>cidr:is4rfc1918</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is within the private RFC1918 address space
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local addr = luci.ip.new("192.168.45.2/24")
+if addr:is4rfc1918() then
+ print("Is a private address")
+end</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the entire range of this CIDR lies within one of
+ the ranges <code>10.0.0.0-10.255.255.255</code>,
+ <code>172.16.0.0-172.31.0.0</code> or
+ <code>192.168.0.0-192.168.255.255</code>, else <code>false</code>.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.is4linklocal"></a><strong>cidr:is4linklocal</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is an IPv4 link local (Zeroconf) address
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local addr = luci.ip.new("169.254.34.125")
+if addr:is4linklocal() then
+ print("Is a zeroconf address")
+end</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the entire range of this CIDR lies within the range
+ the range <code>169.254.0.0-169.254.255.255</code>, else <code>false</code>.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.is6"></a><strong>cidr:is6</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is an IPv6 address range
+
+
+
+
+
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the CIDR is an IPv6 range, else <code>false</code>
+
+
+
+<h3>See also:</h3>
+<ul>
+
+ <li><a href="#cidr.is4">
+ cidr:is4
+ </a>
+
+ <li><a href="#cidr.ismac">
+ cidr:ismac
+ </a>
+
+</ul>
+
+</dd>
+
+
+
+
+<dt><a name="cidr.is6linklocal"></a><strong>cidr:is6linklocal</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is an IPv6 link local address
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local addr = luci.ip.new("fe92:53a:3216:af01:221:63ff:fe75:aa17/64")
+if addr:is6linklocal() then
+ print("Is a linklocal address")
+end</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the entire range of this CIDR lies within the range
+ the <code>fe80::/10</code> range, else <code>false</code>.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.is6mapped4"></a><strong>cidr:is6mapped4</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is an IPv6 mapped IPv4 address
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local addr = luci.ip.new("::ffff:192.168.1.1")
+if addr:is6mapped4() then
+ print("Is a mapped IPv4 address")
+end</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the address is an IPv6 mapped IPv4 address in the
+ form <code>::ffff:1.2.3.4</code>.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.ismac"></a><strong>cidr:ismac</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is an ethernet MAC address range
+
+
+
+
+
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the CIDR is a MAC address range, else <code>false</code>
+
+
+
+<h3>See also:</h3>
+<ul>
+
+ <li><a href="#cidr.is4">
+ cidr:is4
+ </a>
+
+ <li><a href="#cidr.is6">
+ cidr:is6
+ </a>
+
+</ul>
+
+</dd>
+
+
+
+
+<dt><a name="cidr.ismaclocal"></a><strong>cidr:ismaclocal</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is a locally administered (LAA) MAC address
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local mac = luci.ip.new("02:C0:FF:EE:00:01")
+if mac:ismaclocal() then
+ print("Is an LAA MAC address")
+end</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the MAC address sets the locally administered bit.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.ismacmcast"></a><strong>cidr:ismacmcast</strong>&nbsp;()</dt>
+<dd>
+
+
+Checks whether the CIDR instance is a multicast MAC address
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local mac = luci.ip.new("01:00:5E:7F:00:10")
+if addr:ismacmcast() then
+ print("Is a multicast MAC address")
+end</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if the MAC address sets the multicast bit.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.lower"></a><strong>cidr:lower</strong>&nbsp;(addr)</dt>
+<dd>
+
+
+Checks whether this CIDR instance is lower than the given argument.
+The comparisation follows these rules:
+<ul><li>An IPv4 address is always lower than an IPv6 address and IPv6 addresses
+are considered lower than MAC addresses</li>
+<li>Prefix sizes are ignored</li></ul>
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ addr: A <code>luci.ip.cidr</code> instance or a string convertible by
+ <code>luci.ip.new()</code> to compare against.
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if this CIDR is lower than the given address,
+ else <code>false</code>.
+
+
+
+<h3>See also:</h3>
+<ul>
+
+ <li><a href="#cidr.higher">
+ cidr:higher
+ </a>
+
+ <li><a href="#cidr.equal">
+ cidr:equal
+ </a>
+
+</ul>
+
+</dd>
+
+
+
+
+<dt><a name="cidr.higher"></a><strong>cidr:higher</strong>&nbsp;(addr)</dt>
+<dd>
+
+
+Checks whether this CIDR instance is higher than the given argument.
+The comparisation follows these rules:
+<ul><li>An IPv4 address is always lower than an IPv6 address and IPv6 addresses
+are considered lower than MAC addresses</li>
+<li>Prefix sizes are ignored</li></ul>
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ addr: A <code>luci.ip.cidr</code> instance or a string convertible by
+ <code>luci.ip.new()</code> to compare against.
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if this CIDR is higher than the given address,
+ else <code>false</code>.
+
+
+
+<h3>See also:</h3>
+<ul>
+
+ <li><a href="#cidr.lower">
+ cidr:lower
+ </a>
+
+ <li><a href="#cidr.equal">
+ cidr:equal
+ </a>
+
+</ul>
+
+</dd>
+
+
+
+
+<dt><a name="cidr.equal"></a><strong>cidr:equal</strong>&nbsp;(addr)</dt>
+<dd>
+
+
+Checks whether this CIDR instance is equal to the given argument.
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ addr: A <code>luci.ip.cidr</code> instance or a string convertible by
+ <code>luci.ip.new()</code> to compare against.
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if this CIDR is equal to the given address,
+ else <code>false</code>.
+
+
+
+<h3>See also:</h3>
+<ul>
+
+ <li><a href="#cidr.lower">
+ cidr:lower
+ </a>
+
+ <li><a href="#cidr.higher">
+ cidr:higher
+ </a>
+
+</ul>
+
+</dd>
+
+
+
+
+<dt><a name="cidr.prefix"></a><strong>cidr:prefix</strong>&nbsp;(mask)</dt>
+<dd>
+
+
+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.
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ mask: Either a number containing the number of bits (<code>0..32</code>
+ for IPv4, <code>0..128</code> for IPv6 or <code>0..48</code> for MAC addresses) or a string
+ containing a valid netmask (optional)
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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</pre>
+
+
+
+<h3>Return value:</h3>
+Bit count of the current prefix size
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.network"></a><strong>cidr:network</strong>&nbsp;(mask)</dt>
+<dd>
+
+
+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.
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ mask: Either a number containing the number of bits (<code>0..32</code>
+ for IPv4, <code>0..128</code> for IPv6 or <code>0..48</code> for MAC addresses) or a string
+ containing a valid netmask (optional)
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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::"</pre>
+
+
+
+<h3>Return value:</h3>
+CIDR instance representing the network address
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.host"></a><strong>cidr:host</strong>&nbsp;()</dt>
+<dd>
+
+
+Derive host address of CIDR instance.
+
+This function essentially constructs a copy of this CIDR with the prefix size
+set to <code>32</code> for IPv4, <code>128</code> for IPv6 or <code>48</code> for MAC addresses.
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local range = luci.ip.new("172.19.37.45/16")
+print(range) -- "172.19.37.45/16"
+print(range:host()) -- "172.19.37.45"</pre>
+
+
+
+<h3>Return value:</h3>
+CIDR instance representing the host address
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.mask"></a><strong>cidr:mask</strong>&nbsp;(mask)</dt>
+<dd>
+
+
+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.
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ mask: Either a number containing the number of bits (<code>0..32</code>
+ for IPv4, <code>0..128</code> for IPv6 or <code>0..48</code> for MAC addresses) or a string
+ containing a valid netmask (optional)
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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"</pre>
+
+
+
+<h3>Return value:</h3>
+CIDR instance representing the netmask
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.broadcast"></a><strong>cidr:broadcast</strong>&nbsp;(mask)</dt>
+<dd>
+
+
+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.
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ mask: Either a number containing the number of bits (<code>0..32</code> for IPv4) or
+ a string containing a valid netmask (optional)
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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"</pre>
+
+
+
+<h3>Return value:</h3>
+Return a new CIDR instance representing the broadcast address if this
+ instance is an IPv4 range, else return nothing.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.mapped4"></a><strong>cidr:mapped4</strong>&nbsp;()</dt>
+<dd>
+
+
+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.
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local addr = luci.ip.new("::ffff:172.16.19.1")
+print(addr:mapped4()) -- "172.16.19.1"</pre>
+
+
+
+<h3>Return value:</h3>
+Return a new CIDR instance representing the IPv4 address if this
+ instance is an IPv6 mapped IPv4 address, else return nothing.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.tomac"></a><strong>cidr:tomac</strong>&nbsp;()</dt>
+<dd>
+
+
+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.
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local addr = luci.ip.new("fe80::6666:b3ff:fe47:e1b9")
+print(addr:tomac()) -- "64:66:B3:47:E1:B9"</pre>
+
+
+
+<h3>Return value:</h3>
+Return a new CIDR instance representing the MAC address if this
+ instance is an IPv6 link local address, else return nothing.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.tolinklocal"></a><strong>cidr:tolinklocal</strong>&nbsp;()</dt>
+<dd>
+
+
+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.
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>local mac = luci.ip.new("64:66:B3:47:E1:B9")
+print(mac:tolinklocal()) -- "fe80::6666:b3ff:fe47:e1b9"</pre>
+
+
+
+<h3>Return value:</h3>
+Return a new CIDR instance representing the IPv6 link local address.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.contains"></a><strong>cidr:contains</strong>&nbsp;(addr)</dt>
+<dd>
+
+
+Test whether CIDR contains given range.
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ addr: A <code>luci.ip.cidr</code> instance or a string convertible by
+ <code>luci.ip.new()</code> to test.
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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</pre>
+
+
+
+<h3>Return value:</h3>
+<code>true</code> if this instance fully contains the given address else
+ <code>false</code>.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.add"></a><strong>cidr:add</strong>&nbsp;(amount, inplace)</dt>
+<dd>
+
+
+Add given amount to CIDR instance. If the result would overflow the maximum
+address space, the result is set to the highest possible address.
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ amount: A numeric value between 0 and 0xFFFFFFFF, a
+ <code>luci.ip.cidr</code> instance or a string convertible by
+ <code>luci.ip.new()</code>.
+ </li>
+
+ <li>
+ inplace: If <code>true</code>, modify this instance instead of returning
+ a new derived CIDR instance.
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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"</pre>
+
+
+
+<h3>Return value:</h3>
+<ul>
+ <li>When adding inplace: Return <code>true</code> if the addition succeeded
+ or <code>false</code> when the addition overflowed.</li>
+ <li>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.</li></ul>
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.sub"></a><strong>cidr:sub</strong>&nbsp;(amount, inplace)</dt>
+<dd>
+
+
+Subtract given amount from CIDR instance. If the result would under, the lowest
+possible address is returned.
+
+
+
+<h3>Parameters</h3>
+<ul>
+
+ <li>
+ amount: A numeric value between 0 and 0xFFFFFFFF, a
+ <code>luci.ip.cidr</code> instance or a string convertible by
+ <code>luci.ip.new()</code>.
+ </li>
+
+ <li>
+ inplace: If <code>true</code>, modify this instance instead of returning
+ a new derived CIDR instance.
+ </li>
+
+</ul>
+
+
+
+
+<h3>Usage:</h3>
+<pre>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"</pre>
+
+
+
+<h3>Return value:</h3>
+<ul>
+ <li>When subtracting inplace: Return <code>true</code> if the subtraction
+ succeeded or <code>false</code> when the subtraction underflowed.</li>
+ <li>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.</li></ul>
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.minhost"></a><strong>cidr:minhost</strong>&nbsp;()</dt>
+<dd>
+
+
+Calculate the lowest possible host address within this CIDR instance.
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>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"</pre>
+
+
+
+<h3>Return value:</h3>
+Returns a new CIDR instance representing the lowest host address
+ within this range.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.maxhost"></a><strong>cidr:maxhost</strong>&nbsp;()</dt>
+<dd>
+
+
+Calculate the highest possible host address within this CIDR instance.
+
+
+
+
+
+
+<h3>Usage:</h3>
+<pre>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"</pre>
+
+
+
+<h3>Return value:</h3>
+Returns a new CIDR instance representing the highest host address
+ within this range.
+
+
+
+</dd>
+
+
+
+
+<dt><a name="cidr.string"></a><strong>cidr:string</strong>&nbsp;()</dt>
+<dd>
+
+
+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.
+
+
+
+
+
+
+
+
+<h3>Return value:</h3>
+Returns a string representing the range or address of this CIDR instance
+
+
+
+</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>