566ea2331a11fe13a3fd03f7b0177b6c3aed0a94
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / proto_dhcp.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.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
13 local map, section, net = ...
14 local ifc = net:get_interface()
15
16 local hostname, accept_ra, send_rs
17 local bcast, no_gw, metric, clientid, vendorclass
18
19
20 hostname = section:taboption("general", Value, "hostname",
21         translate("Hostname to send when requesting DHCP"))
22
23 hostname.placeholder = luci.sys.hostname()
24 hostname.datatype    = "hostname"
25
26
27 if luci.model.network:has_ipv6() then
28
29         accept_ra = s:taboption("general", Flag, "accept_ra", translate("Accept router advertisements"))
30         accept_ra.default = accept_ra.enabled
31
32
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", "")
36
37 end
38
39 bcast = section:taboption("advanced", Flag, "broadcast",
40         translate("Use broadcast flag"),
41         translate("Required for certain ISPs, e.g. Charter with DOCSIS 3"))
42
43 bcast.default = bcast.disabled
44
45
46 no_gw = section:taboption("advanced", Flag, "gateway",
47         translate("Use default gateway"),
48         translate("If unchecked, no default route is configured"))
49
50 no_gw.default = no_gw.enabled
51
52 function no_gw.cfgvalue(...)
53         return Flag.cfgvalue(...) == "0.0.0.0" and "0" or "1"
54 end
55
56 function no_gw.write(self, section, value)
57         if value == "1" then
58                 m:set(section, "gateway", nil)
59         else
60                 m:set(section, "gateway", "0.0.0.0")
61         end
62 end
63
64
65 metric = section:taboption("advanced", Value, "metric",
66         translate("Use gateway metric"))
67
68 metric.placeholder = "0"
69 metric.datatype    = "uinteger"
70 metric:depends("gateway", "1")
71
72
73 clientid = section:taboption("advanced", Value, "clientid",
74         translate("Client ID to send when requesting DHCP"))
75
76
77 vendorclass = section:taboption("advanced", Value, "vendorclass",
78         translate("Vendor Class to send when requesting DHCP"))
79
80
81 macaddr = section:taboption("advanced", Value, "macaddr", translate("Override MAC address"))
82 macaddr.placeholder = ifc and ifc:mac() or "00:00:00:00:00:00"
83 macaddr.datatype    = "macaddr"
84
85
86 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
87 mtu.placeholder = "1500"
88 mtu.datatype    = "max(1500)"