Update my email addresses in the license headers
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_network / proto_ahcp.lua
1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local map, section, net = ...
5
6 local device, apn, service, pincode, username, password
7 local ipv6, maxwait, defaultroute, metric, peerdns, dns,
8 keepalive_failure, keepalive_interval, demand
9
10
11 mca = s:taboption("ahcp", Value, "multicast_address", translate("Multicast address"))
12 mca.optional = true
13 mca.placeholder = "ff02::cca6:c0f9:e182:5359"
14 mca.datatype = "ip6addr"
15 mca:depends("proto", "ahcp")
16
17 port = s:taboption("ahcp", Value, "port", translate("Port"))
18 port.optional = true
19 port.placeholder = 5359
20 port.datatype = "port"
21 port:depends("proto", "ahcp")
22
23 fam = s:taboption("ahcp", ListValue, "_family", translate("Protocol family"))
24 fam:value("", translate("IPv4 and IPv6"))
25 fam:value("ipv4", translate("IPv4 only"))
26 fam:value("ipv6", translate("IPv6 only"))
27 fam:depends("proto", "ahcp")
28
29 function fam.cfgvalue(self, section)
30 local v4 = m.uci:get_bool("network", section, "ipv4_only")
31 local v6 = m.uci:get_bool("network", section, "ipv6_only")
32 if v4 then
33 return "ipv4"
34 elseif v6 then
35 return "ipv6"
36 end
37 return ""
38 end
39
40 function fam.write(self, section, value)
41 if value == "ipv4" then
42 m.uci:set("network", section, "ipv4_only", "true")
43 m.uci:delete("network", section, "ipv6_only")
44 elseif value == "ipv6" then
45 m.uci:set("network", section, "ipv6_only", "true")
46 m.uci:delete("network", section, "ipv4_only")
47 end
48 end
49
50 function fam.remove(self, section)
51 m.uci:delete("network", section, "ipv4_only")
52 m.uci:delete("network", section, "ipv6_only")
53 end
54
55 nodns = s:taboption("ahcp", Flag, "no_dns", translate("Disable DNS setup"))
56 nodns.optional = true
57 nodns.enabled = "true"
58 nodns.disabled = "false"
59 nodns.default = nodns.disabled
60 nodns:depends("proto", "ahcp")
61
62 ltime = s:taboption("ahcp", Value, "lease_time", translate("Lease validity time"))
63 ltime.optional = true
64 ltime.placeholder = 3666
65 ltime.datatype = "uinteger"
66 ltime:depends("proto", "ahcp")
67