diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2011-10-11 02:07:15 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2011-10-11 02:07:15 +0000 |
commit | 1ffe61277e656943128cafc70e35ee05669d1cce (patch) | |
tree | 746267318e619636e98b9016484b8ff039a876ab /protocols/6x4/luasrc | |
parent | 9ebf90071996df0916d9617e6a935f669812a8b9 (diff) |
move protocol support into a new protocols/ subdir
Diffstat (limited to 'protocols/6x4/luasrc')
3 files changed, 257 insertions, 0 deletions
diff --git a/protocols/6x4/luasrc/model/cbi/admin_network/proto_6in4.lua b/protocols/6x4/luasrc/model/cbi/admin_network/proto_6in4.lua new file mode 100644 index 0000000000..29b1039fb7 --- /dev/null +++ b/protocols/6x4/luasrc/model/cbi/admin_network/proto_6in4.lua @@ -0,0 +1,96 @@ +--[[ +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 ipaddr, peeraddr, ip6addr, tunnelid, username, password +local defaultroute, metric, ttl, mtu + + +ipaddr = s:taboption("general", Value, "ipaddr", + translate("Local IPv4 address"), + translate("Leave empty to use the current WAN address")) + +ipaddr.datatype = "ip4addr" + + +peeraddr = s:taboption("general", Value, "peeraddr", + translate("Remote IPv4 address"), + translate("This is usually the address of the nearest PoP operated by the tunnel broker")) + +peeraddr.rmempty = false +peeraddr.datatype = "ip4addr" + + +ip6addr = s:taboption("general", Value, "ip6addr", + translate("Local IPv6 address"), + translate("This is the local endpoint address assigned by the tunnel broker, it usually ends with <code>:2</code>")) + +ip6addr.rmempty = false +ip6addr.datatype = "ip6addr" + + +local update = section:taboption("general", Flag, "_update", + translate("Dynamic tunnel"), + translate("Enable HE.net dynamic endpoint update")) + +update.enabled = "1" +update.disabled = "0" + +function update.write() end +function update.remove() end +function update.cfgvalue(self, section) + return (tonumber(m:get(section, "tunnelid")) ~= nil) + and self.enabled or self.disabled +end + + +tunnelid = section:taboption("general", Value, "tunnelid", translate("Tunnel ID")) +tunnelid.datatype = "uinteger" +tunnelid:depends("_update", update.enabled) + + +username = section:taboption("general", Value, "username", + translate("HE.net user ID"), + translate("This is the 32 byte hex encoded user ID, not the login name")) + +username:depends("_update", update.enabled) + + +password = section:taboption("general", Value, "password", translate("HE.net password")) +password.password = true +password:depends("_update", update.enabled) + + +defaultroute = section:taboption("advanced", Flag, "defaultroute", + translate("Default gateway"), + translate("If unchecked, no default route is configured")) + +defaultroute.default = defaultroute.enabled + + +metric = section:taboption("advanced", Value, "metric", + translate("Use gateway metric")) + +metric.placeholder = "0" +metric.datatype = "uinteger" +metric:depends("defaultroute", defaultroute.enabled) + + +ttl = section:taboption("advanced", Value, "ttl", translate("Use TTL on tunnel interface")) +ttl.placeholder = "64" +ttl.datatype = "range(1,255)" + + +mtu = section:taboption("advanced", Value, "mtu", translate("Use MTU on tunnel interface")) +mtu.placeholder = "1280" +mtu.datatype = "max(1500)" diff --git a/protocols/6x4/luasrc/model/cbi/admin_network/proto_6to4.lua b/protocols/6x4/luasrc/model/cbi/admin_network/proto_6to4.lua new file mode 100644 index 0000000000..d10ab089cb --- /dev/null +++ b/protocols/6x4/luasrc/model/cbi/admin_network/proto_6to4.lua @@ -0,0 +1,97 @@ +--[[ +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 ipaddr, adv_interface, adv_subnet +local adv_valid_lifetime, adv_preferred_lifetime, defaultroute, metric, ttl, mtu + + +ipaddr = section:taboption("general", Value, "ipaddr", + translate("Local IPv4 address"), + translate("Leave empty to use the current WAN address")) + +ipaddr.datatype = "ip4addr" + + +adv_interface = section:taboption("general", Value, "adv_interface", translate("Advertise IPv6 on network")) +adv_interface.widget = "checkbox" +adv_interface.exclude = arg[1] +adv_interface.default = "lan" +adv_interface.template = "cbi/network_netlist" +adv_interface.nocreate = true +adv_interface.nobridges = true +adv_interface.novirtual = true + + +adv_subnet = section:taboption("general", Value, "adv_subnet", + translate("Advertised network ID"), + translate("Allowed range is 1 to 65535")) + +adv_subnet.placeholder = "1" +adv_subnet.datatype = "range(1,65535)" + +function adv_subnet.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + return v and tonumber(v, 16) +end + +function adv_subnet .write(self, section, value) + value = tonumber(value) or 1 + + if value > 65535 then value = 65535 + elseif value < 1 then value = 1 end + + Value.write(self, section, "%X" % value) +end + + +adv_valid_lifetime = section:taboption("advanced", Value, "adv_valid_lifetime", + translate("Use valid lifetime"), + translate("Specifies the advertised valid prefix lifetime in seconds")) + +adv_valid_lifetime.placeholder = "300" +adv_valid_lifetime.datatype = "uinteger" + + +adv_preferred_lifetime = section:taboption("advanced", Value, "adv_preferred_lifetime", + translate("Use preferred lifetime"), + translate("Specifies the advertised preferred prefix lifetime in seconds")) + +adv_preferred_lifetime.placeholder = "120" +adv_preferred_lifetime.datatype = "uinteger" + + + +defaultroute = section:taboption("advanced", Flag, "defaultroute", + translate("Use default gateway"), + translate("If unchecked, no default route is configured")) + +defaultroute.default = defaultroute.enabled + + +metric = section:taboption("advanced", Value, "metric", + translate("Use gateway metric")) + +metric.placeholder = "0" +metric.datatype = "uinteger" +metric:depends("defaultroute", defaultroute.enabled) + + +ttl = section:taboption("advanced", Value, "ttl", translate("Use TTL on tunnel interface")) +ttl.placeholder = "64" +ttl.datatype = "range(1,255)" + + +mtu = section:taboption("advanced", Value, "mtu", translate("Use MTU on tunnel interface")) +mtu.placeholder = "1280" +mtu.datatype = "max(1500)" diff --git a/protocols/6x4/luasrc/model/network/proto_6x4.lua b/protocols/6x4/luasrc/model/network/proto_6x4.lua new file mode 100644 index 0000000000..d4d72c8282 --- /dev/null +++ b/protocols/6x4/luasrc/model/network/proto_6x4.lua @@ -0,0 +1,64 @@ +--[[ +LuCI - Network model - 6to4 & 6in4 protocol extension + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +local netmod = luci.model.network + +local _, p +for _, p in ipairs({"6in4", "6to4"}) do + + local proto = netmod:register_protocol(p) + + function proto.get_i18n(self) + if p == "6in4" then + return luci.i18n.translate("IPv6-in-IPv4 (RFC4213)") + elseif p == "6to4" then + return luci.i18n.translate("IPv6-over-IPv4") + end + end + + function proto.ifname(self) + return p .. "-" .. self.sid + end + + function proto.opkg_package(self) + return p + end + + function proto.is_installed(self) + return nixio.fs.access("/lib/network/" .. p .. ".sh") + end + + function proto.is_floating(self) + return true + end + + function proto.is_virtual(self) + return true + end + + function proto.get_interfaces(self) + return nil + end + + function proto.contains_interface(self, ifname) + return (netmod:ifnameof(ifc) == self:ifname()) + end + + netmod:register_pattern_virtual("^%s-%%w" % p) +end |