18f717222475a06bcb6a9356761dab10d91b140c
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_network / hosts.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 require("luci.sys")
6 require("luci.util")
7 m = Map("dhcp", translate("Hostnames"))
8
9 s = m:section(TypedSection, "domain", translate("Host entries"))
10 s.addremove = true
11 s.anonymous = true
12 s.template = "cbi/tblsection"
13
14 hn = s:option(Value, "name", translate("Hostname"))
15 hn.datatype = "hostname"
16 hn.rmempty  = true
17
18 ip = s:option(Value, "ip", translate("IP address"))
19 ip.datatype = "ipaddr"
20 ip.rmempty  = true
21
22 local arptable = luci.sys.net.arptable() or {}
23 for i, dataset in ipairs(arptable) do
24         ip:value(
25                 dataset["IP address"],
26                 "%s (%s)" %{ dataset["IP address"], dataset["HW address"] }
27         )
28 end
29
30 return m