luci-base: add luci.sys.net.host_hints() and regenerate documentation
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
parent
e0988b089b
commit
c23885f6a7
4 changed files with 69 additions and 3 deletions
|
@ -903,7 +903,8 @@ Get an option or list and return values as table.
|
||||||
|
|
||||||
|
|
||||||
<h3>Return value:</h3>
|
<h3>Return value:</h3>
|
||||||
UCI value
|
table. If the option was not found, you will simply get
|
||||||
|
an empty table.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1200,7 +1201,8 @@ Boolean whether operation succeeded
|
||||||
<dd>
|
<dd>
|
||||||
|
|
||||||
|
|
||||||
Set given values as list.
|
Set given values as list. Setting a list option to an empty list
|
||||||
|
has the same effect as deleting the option.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1220,7 +1222,7 @@ Set given values as list.
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
value: UCI value
|
value: value or table. Raw values will become a single item table.
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -241,6 +241,13 @@ Return information about available network interfaces.</td>
|
||||||
Determine the names of available network interfaces.</td>
|
Determine the names of available network interfaces.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#net.host_hints">host_hints</a> ()</td>
|
||||||
|
<td class="summary">
|
||||||
|
|
||||||
|
Returns a two-dimensional table of host hints.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="name" nowrap><a href="#net.ipv4_hints">ipv4_hints</a> ()</td>
|
<td class="name" nowrap><a href="#net.ipv4_hints">ipv4_hints</a> ()</td>
|
||||||
<td class="summary">
|
<td class="summary">
|
||||||
|
@ -393,6 +400,31 @@ Table containing all current interface names
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dt><a name="net.host_hints"></a><strong>host_hints</strong> ()</dt>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
|
||||||
|
Returns a two-dimensional table of host hints.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Return value:</h3>
|
||||||
|
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".
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dt><a name="net.ipv4_hints"></a><strong>ipv4_hints</strong> ()</dt>
|
<dt><a name="net.ipv4_hints"></a><strong>ipv4_hints</strong> ()</dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
|
||||||
|
|
|
@ -292,6 +292,28 @@ function net.ipv6_hints(callback)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function net.host_hints(callback)
|
||||||
|
if callback then
|
||||||
|
_nethints(1, function(mac, v4, v6, name)
|
||||||
|
if mac and mac ~= "00:00:00:00:00:00" and (v4 or v6 or name) then
|
||||||
|
callback(mac, v4, v6, name)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
local rv = { }
|
||||||
|
_nethints(1, function(mac, v4, v6, name)
|
||||||
|
if mac and mac ~= "00:00:00:00:00:00" and (v4 or v6 or name) then
|
||||||
|
local e = { }
|
||||||
|
if v4 then e.ipv4 = v4 end
|
||||||
|
if v6 then e.ipv6 = v6 end
|
||||||
|
if name then e.name = name end
|
||||||
|
rv[mac] = e
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return rv
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function net.conntrack(callback)
|
function net.conntrack(callback)
|
||||||
local ok, nfct = pcall(io.lines, "/proc/net/nf_conntrack")
|
local ok, nfct = pcall(io.lines, "/proc/net/nf_conntrack")
|
||||||
if not ok or not nfct then
|
if not ok or not nfct then
|
||||||
|
|
|
@ -150,6 +150,16 @@ Returns a two-dimensional table of IPv6 address hints.
|
||||||
[ "ip", "name" ]
|
[ "ip", "name" ]
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
---[[
|
||||||
|
Returns a two-dimensional table of host hints.
|
||||||
|
|
||||||
|
@class function
|
||||||
|
@name net.host_hints
|
||||||
|
@return 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".
|
||||||
|
]]
|
||||||
|
|
||||||
---[[
|
---[[
|
||||||
Returns conntrack information
|
Returns conntrack information
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue