2 LuCI - Lua Configuration Interface
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
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
10 http://www.apache.org/licenses/LICENSE-2.0
13 local map, section, net = ...
14 local ifc = net:get_interface()
16 local hostname, accept_ra, send_rs
17 local bcast, no_gw, no_dns, dns, metric, clientid, vendorclass
20 hostname = section:taboption("general", Value, "hostname",
21 translate("Hostname to send when requesting DHCP"))
23 hostname.placeholder = luci.sys.hostname()
24 hostname.datatype = "hostname"
27 if luci.model.network:has_ipv6() then
29 accept_ra = s:taboption("general", Flag, "accept_ra", translate("Accept router advertisements"))
30 accept_ra.default = accept_ra.enabled
33 send_rs = s:taboption("general", Flag, "send_rs", translate("Send router solicitations"))
34 send_rs.default = send_rs.disabled
35 send_rs:depends("accept_ra", "")
39 bcast = section:taboption("advanced", Flag, "broadcast",
40 translate("Use broadcast flag"),
41 translate("Required for certain ISPs, e.g. Charter with DOCSIS 3"))
43 bcast.default = bcast.disabled
46 no_gw = section:taboption("advanced", Flag, "gateway",
47 translate("Use default gateway"),
48 translate("If unchecked, no default route is configured"))
50 no_gw.default = no_gw.enabled
52 function no_gw.cfgvalue(...)
53 return Flag.cfgvalue(...) == "0.0.0.0" and "0" or "1"
56 function no_gw.write(self, section, value)
58 m:set(section, "gateway", nil)
60 m:set(section, "gateway", "0.0.0.0")
65 no_dns = section:taboption("advanced", Flag, "_no_dns",
66 translate("Use DNS servers advertised by peer"),
67 translate("If unchecked, the advertised DNS server addresses are ignored"))
69 no_dns.default = no_dns.enabled
71 function no_dns.cfgvalue(self, section)
73 for addr in luci.util.imatch(m:get(section, "dns")) do
79 function no_dns.remove(self, section)
80 return m:del(section, "dns")
83 function no_dns.write() end
86 dns = section:taboption("advanced", DynamicList, "dns",
87 translate("Use custom DNS servers"))
89 dns:depends("_no_dns", "")
90 dns.datatype = "ipaddr"
94 metric = section:taboption("advanced", Value, "metric",
95 translate("Use gateway metric"))
97 metric.placeholder = "0"
98 metric.datatype = "uinteger"
99 metric:depends("gateway", "1")
102 clientid = section:taboption("advanced", Value, "clientid",
103 translate("Client ID to send when requesting DHCP"))
106 vendorclass = section:taboption("advanced", Value, "vendorclass",
107 translate("Vendor Class to send when requesting DHCP"))
110 macaddr = section:taboption("advanced", Value, "macaddr", translate("Override MAC address"))
111 macaddr.placeholder = ifc and ifc:mac() or "00:00:00:00:00:00"
112 macaddr.datatype = "macaddr"
115 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
116 mtu.placeholder = "1500"
117 mtu.datatype = "max(1500)"