luci-0.11: merge outstanding trunk changes
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / hosts.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15
16 require("luci.sys")
17 require("luci.util")
18 m = Map("dhcp", translate("Hostnames"))
19
20 s = m:section(TypedSection, "domain", translate("Host entries"))
21 s.addremove = true
22 s.anonymous = true
23 s.template = "cbi/tblsection"
24
25 hn = s:option(Value, "name", translate("Hostname"))
26 hn.datatype = "hostname"
27 hn.rmempty = true
28
29 ip = s:option(Value, "ip", translate("IP address"))
30 ip.datatype = "ipaddr"
31 ip.rmempty = true
32
33 local arptable = luci.sys.net.arptable() or {}
34 for i, dataset in ipairs(arptable) do
35 ip:value(
36 dataset["IP address"],
37 "%s (%s)" %{ dataset["IP address"], dataset["HW address"] }
38 )
39 end
40
41 return m