Merge pull request #302 from chris5560/master
[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-2015 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 local ipc = require "luci.ip"
6
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 ipc.neighbors({ }, function(n)
23         if n.mac and n.dest and not n.dest:is6linklocal() then
24                 ip:value(n.dest:string(), "%s (%s)" %{ n.dest:string(), n.mac })
25         end
26 end)
27
28 return m