e0e65e5e4d61e28d6fa14d62b942af4e08c796ac
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / dhcpleases.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 local sys = require "luci.sys"
16
17 m2 = Map("dhcp", translate("DHCP Leases"),
18         translate("Static leases are used to assign fixed IP addresses and symbolic hostnames to " ..
19                 "DHCP clients. They are also required for non-dynamic interface configurations where " ..
20                 "only hosts with a corresponding lease are served."))
21
22 m2:section(SimpleSection).template = "admin_network/lease_status"
23
24 s = m2:section(TypedSection, "host", translate("Static Leases"),
25         translate("Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> " ..
26                 "indentifies the host, the <em>IPv4-Address</em> specifies to the fixed address to " ..
27                 "use and the <em>Hostname</em> is assigned as symbolic name to the requesting host."))
28
29 s.addremove = true
30 s.anonymous = true
31 s.template = "cbi/tblsection"
32
33 name = s:option(Value, "name", translate("Hostname"))
34 name.datatype = "hostname"
35 name.rmempty  = true
36
37 mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
38 mac.datatype = "macaddr"
39
40 ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
41 ip.datatype = "ip4addr"
42
43 sys.net.arptable(function(entry)
44         ip:value(entry["IP address"])
45         mac:value(
46                 entry["HW address"],
47                 entry["HW address"] .. " (" .. entry["IP address"] .. ")"
48         )
49 end)
50
51
52 return m2