Update my email addresses in the license headers
[project/luci.git] / applications / luci-app-ahcp / luasrc / model / cbi / ahcp.lua
1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 m = Map("ahcpd", translate("AHCP Server"), translate("AHCP is an autoconfiguration protocol " ..
5         "for IPv6 and dual-stack IPv6/IPv4 networks designed to be used in place of router " ..
6         "discovery or DHCP on networks where it is difficult or impossible to configure a " ..
7         "server within every link-layer broadcast domain, for example mobile ad-hoc networks."))
8
9
10 m:section(SimpleSection).template = "ahcp_status"
11
12 s = m:section(TypedSection, "ahcpd")
13 s:tab("general", translate("General Setup"))
14 s:tab("advanced", translate("Advanced Settings"))
15 s.addremove = false
16 s.anonymous = true
17
18
19 mode = s:taboption("general", ListValue, "mode", translate("Operation mode"))
20 mode:value("server", translate("Server"))
21 mode:value("forwarder", translate("Forwarder"))
22
23 net = s:taboption("general", Value, "interface", translate("Served interfaces"))
24 net.template = "cbi/network_netlist"
25 net.widget   = "checkbox"
26 net.nocreate = true
27
28 function net.cfgvalue(self, section)
29         return m.uci:get("ahcpd", section, "interface")
30 end
31
32 pfx = s:taboption("general", DynamicList, "prefix", translate("Announced prefixes"),
33         translate("Specifies the announced IPv4 and IPv6 network prefixes in CIDR notation"))
34 pfx.optional  = true
35 pfx.datatype  = "ipaddr"
36 pfx:depends("mode", "server")
37
38 nss = s:taboption("general", DynamicList, "name_server", translate("Announced DNS servers"),
39         translate("Specifies the announced IPv4 and IPv6 name servers"))
40 nss.optional = true
41 nss.datatype = "ipaddr"
42 nss:depends("mode", "server")
43
44 ntp = s:taboption("general", DynamicList, "ntp_server", translate("Announced NTP servers"),
45         translate("Specifies the announced IPv4 and IPv6 NTP servers"))
46 ntp.optional = true
47 ntp.datatype = "ipaddr"
48 ntp:depends("mode", "server")
49
50 mca = s:taboption("general", Value, "multicast_address", translate("Multicast address"))
51 mca.optional    = true
52 mca.placeholder = "ff02::cca6:c0f9:e182:5359"
53 mca.datatype    = "ip6addr"
54
55 port = s:taboption("general", Value, "port", translate("Port"))
56 port.optional    = true
57 port.placeholder = 5359
58 port.datatype    = "port"
59
60 fam = s:taboption("general", ListValue, "_family", translate("Protocol family"))
61 fam:value("", translate("IPv4 and IPv6"))
62 fam:value("ipv4", translate("IPv4 only"))
63 fam:value("ipv6", translate("IPv6 only"))
64
65 function fam.cfgvalue(self, section)
66         local v4 = m.uci:get_bool("ahcpd", section, "ipv4_only")
67         local v6 = m.uci:get_bool("ahcpd", section, "ipv6_only")
68         if v4 then
69                 return "ipv4"
70         elseif v6 then
71                 return "ipv6"
72         end
73         return ""
74 end
75
76 function fam.write(self, section, value)
77         if value == "ipv4" then
78                 m.uci:set("ahcpd", section, "ipv4_only", "true")
79                 m.uci:delete("ahcpd", section, "ipv6_only")
80         elseif value == "ipv6" then
81                 m.uci:set("ahcpd", section, "ipv6_only", "true")
82                 m.uci:delete("ahcpd", section, "ipv4_only")
83         end
84 end
85
86 function fam.remove(self, section)
87         m.uci:delete("ahcpd", section, "ipv4_only")
88         m.uci:delete("ahcpd", section, "ipv6_only")
89 end
90
91 ltime = s:taboption("general", Value, "lease_time", translate("Lease validity time"))
92 ltime.optional    = true
93 ltime.placeholder = 3666
94 ltime.datatype    = "uinteger"
95
96
97 ld = s:taboption("advanced", Value, "lease_dir", translate("Lease directory"))
98 ld.datatype    = "directory"
99 ld.placeholder = "/var/lib/leases"
100
101 id = s:taboption("advanced", Value, "id_file", translate("Unique ID file"))
102 --id.datatype    = "file"
103 id.placeholder = "/var/lib/ahcpd-unique-id"
104
105 log = s:taboption("advanced", Value, "log_file", translate("Log file"))
106 --log.datatype    = "file"
107 log.placeholder = "/var/log/ahcpd.log"
108
109
110 return m