summaryrefslogtreecommitdiffhomepage
path: root/protocols/core
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-10-11 02:07:15 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-10-11 02:07:15 +0000
commit1ffe61277e656943128cafc70e35ee05669d1cce (patch)
tree746267318e619636e98b9016484b8ff039a876ab /protocols/core
parent9ebf90071996df0916d9617e6a935f669812a8b9 (diff)
move protocol support into a new protocols/ subdir
Diffstat (limited to 'protocols/core')
-rw-r--r--protocols/core/luasrc/model/cbi/admin_network/proto_dhcp.lua88
-rw-r--r--protocols/core/luasrc/model/cbi/admin_network/proto_none.lua13
-rw-r--r--protocols/core/luasrc/model/cbi/admin_network/proto_static.lua78
3 files changed, 179 insertions, 0 deletions
diff --git a/protocols/core/luasrc/model/cbi/admin_network/proto_dhcp.lua b/protocols/core/luasrc/model/cbi/admin_network/proto_dhcp.lua
new file mode 100644
index 000000000..566ea2331
--- /dev/null
+++ b/protocols/core/luasrc/model/cbi/admin_network/proto_dhcp.lua
@@ -0,0 +1,88 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+]]--
+
+local map, section, net = ...
+local ifc = net:get_interface()
+
+local hostname, accept_ra, send_rs
+local bcast, no_gw, metric, clientid, vendorclass
+
+
+hostname = section:taboption("general", Value, "hostname",
+ translate("Hostname to send when requesting DHCP"))
+
+hostname.placeholder = luci.sys.hostname()
+hostname.datatype = "hostname"
+
+
+if luci.model.network:has_ipv6() then
+
+ accept_ra = s:taboption("general", Flag, "accept_ra", translate("Accept router advertisements"))
+ accept_ra.default = accept_ra.enabled
+
+
+ send_rs = s:taboption("general", Flag, "send_rs", translate("Send router solicitations"))
+ send_rs.default = send_rs.disabled
+ send_rs:depends("accept_ra", "")
+
+end
+
+bcast = section:taboption("advanced", Flag, "broadcast",
+ translate("Use broadcast flag"),
+ translate("Required for certain ISPs, e.g. Charter with DOCSIS 3"))
+
+bcast.default = bcast.disabled
+
+
+no_gw = section:taboption("advanced", Flag, "gateway",
+ translate("Use default gateway"),
+ translate("If unchecked, no default route is configured"))
+
+no_gw.default = no_gw.enabled
+
+function no_gw.cfgvalue(...)
+ return Flag.cfgvalue(...) == "0.0.0.0" and "0" or "1"
+end
+
+function no_gw.write(self, section, value)
+ if value == "1" then
+ m:set(section, "gateway", nil)
+ else
+ m:set(section, "gateway", "0.0.0.0")
+ end
+end
+
+
+metric = section:taboption("advanced", Value, "metric",
+ translate("Use gateway metric"))
+
+metric.placeholder = "0"
+metric.datatype = "uinteger"
+metric:depends("gateway", "1")
+
+
+clientid = section:taboption("advanced", Value, "clientid",
+ translate("Client ID to send when requesting DHCP"))
+
+
+vendorclass = section:taboption("advanced", Value, "vendorclass",
+ translate("Vendor Class to send when requesting DHCP"))
+
+
+macaddr = section:taboption("advanced", Value, "macaddr", translate("Override MAC address"))
+macaddr.placeholder = ifc and ifc:mac() or "00:00:00:00:00:00"
+macaddr.datatype = "macaddr"
+
+
+mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
+mtu.placeholder = "1500"
+mtu.datatype = "max(1500)"
diff --git a/protocols/core/luasrc/model/cbi/admin_network/proto_none.lua b/protocols/core/luasrc/model/cbi/admin_network/proto_none.lua
new file mode 100644
index 000000000..0e34b67de
--- /dev/null
+++ b/protocols/core/luasrc/model/cbi/admin_network/proto_none.lua
@@ -0,0 +1,13 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+]]--
+
+local map, section, net = ...
diff --git a/protocols/core/luasrc/model/cbi/admin_network/proto_static.lua b/protocols/core/luasrc/model/cbi/admin_network/proto_static.lua
new file mode 100644
index 000000000..8ae9b7eab
--- /dev/null
+++ b/protocols/core/luasrc/model/cbi/admin_network/proto_static.lua
@@ -0,0 +1,78 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+]]--
+
+local map, section, net = ...
+local ifc = net:get_interface()
+
+local ipaddr, netmask, gateway, broadcast, accept_ra, send_rs, ip6addr, ip6gw
+local macaddr, mtu, metric
+
+
+ipaddr = section:taboption("general", Value, "ipaddr", translate("IPv4 address"))
+ipaddr.datatype = "ip4addr"
+
+
+netmask = section:taboption("general", Value, "netmask",
+ translate("IPv4 netmask"))
+
+netmask.datatype = "ip4addr"
+netmask:value("255.255.255.0")
+netmask:value("255.255.0.0")
+netmask:value("255.0.0.0")
+
+
+gateway = section:taboption("general", Value, "gateway", translate("IPv4 gateway"))
+gateway.datatype = "ip4addr"
+
+
+broadcast = section:taboption("general", Value, "broadcast", translate("IPv4 broadcast"))
+broadcast.datatype = "ip4addr"
+
+
+if luci.model.network:has_ipv6() then
+
+ accept_ra = s:taboption("general", Flag, "accept_ra", translate("Accept router advertisements"))
+ accept_ra.default = accept_ra.disabled
+
+
+ send_rs = s:taboption("general", Flag, "send_rs", translate("Send router solicitations"))
+ send_rs.default = send_rs.enabled
+ send_rs:depends("accept_ra", "")
+
+
+ ip6addr = section:taboption("general", Value, "ip6addr", translate("IPv6 address"))
+ ip6addr.datatype = "ip6addr"
+ ip6addr:depends("accept_ra", "")
+
+
+ ip6gw = section:taboption("general", Value, "ip6gw", translate("IPv6 gateway"))
+ ip6gw.datatype = "ip6addr"
+ ip6gw:depends("accept_ra", "")
+
+end
+
+
+macaddr = section:taboption("advanced", Value, "macaddr", translate("Override MAC address"))
+macaddr.placeholder = ifc and ifc:mac() or "00:00:00:00:00:00"
+macaddr.datatype = "macaddr"
+
+
+mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
+mtu.placeholder = "1500"
+mtu.datatype = "max(1500)"
+
+
+metric = section:taboption("advanced", Value, "metric",
+ translate("Use gateway metric"))
+
+metric.placeholder = "0"
+metric.datatype = "uinteger"