From: Jo-Philipp Wich Date: Tue, 11 Oct 2011 02:07:15 +0000 (+0000) Subject: move protocol support into a new protocols/ subdir X-Git-Tag: 0.11.0~1573 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=1ffe61277e656943128cafc70e35ee05669d1cce move protocol support into a new protocols/ subdir --- diff --git a/libs/core/luasrc/model/network/proto_6x4.lua b/libs/core/luasrc/model/network/proto_6x4.lua deleted file mode 100644 index d4d72c828..000000000 --- a/libs/core/luasrc/model/network/proto_6x4.lua +++ /dev/null @@ -1,64 +0,0 @@ ---[[ -LuCI - Network model - 6to4 & 6in4 protocol extension - -Copyright 2011 Jo-Philipp Wich - -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 diff --git a/libs/core/luasrc/model/network/proto_ppp.lua b/libs/core/luasrc/model/network/proto_ppp.lua deleted file mode 100644 index af6f39402..000000000 --- a/libs/core/luasrc/model/network/proto_ppp.lua +++ /dev/null @@ -1,86 +0,0 @@ ---[[ -LuCI - Network model - 3G, PPP, PPtP, PPPoE and PPPoA protocol extension - -Copyright 2011 Jo-Philipp Wich - -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({"ppp", "pptp", "pppoe", "pppoa", "3g"}) do - - local proto = netmod:register_protocol(p) - - function proto.get_i18n(self) - if p == "ppp" then - return luci.i18n.translate("PPP") - elseif p == "pptp" then - return luci.i18n.translate("PPtP") - elseif p == "3g" then - return luci.i18n.translate("UMTS/GPRS/EV-DO") - elseif p == "pppoe" then - return luci.i18n.translate("PPPoE") - elseif p == "pppoa" then - return luci.i18n.translate("PPPoATM") - end - end - - function proto.ifname(self) - return p .. "-" .. self.sid - end - - function proto.opkg_package(self) - if p == "ppp" or p == "pptp" then - return p - elseif p == "3g" then - return "comgt" - elseif p == "pppoe" then - return "ppp-mod-pppoe" - elseif p == "pppoa" then - return "ppp-mod-pppoa" - end - end - - function proto.is_installed(self) - return nixio.fs.access("/lib/network/" .. p .. ".sh") - end - - function proto.is_floating(self) - return (p ~= "pppoe") - end - - function proto.is_virtual(self) - return true - end - - function proto.get_interfaces(self) - if self:is_floating() then - return nil - else - return netmod.protocol.get_interfaces(self) - end - end - - function proto.contains_interface(self, ifc) - if self:is_floating() then - return (netmod:ifnameof(ifc) == self:ifname()) - else - return netmod.protocol.contains_interface(self, ifc) - end - end - - netmod:register_pattern_virtual("^%s-%%w" % p) -end diff --git a/libs/core/luasrc/model/network/proto_relay.lua b/libs/core/luasrc/model/network/proto_relay.lua deleted file mode 100644 index 03f6d6abf..000000000 --- a/libs/core/luasrc/model/network/proto_relay.lua +++ /dev/null @@ -1,165 +0,0 @@ ---[[ -LuCI - Network model - relay protocol extension - -Copyright 2011 Jo-Philipp Wich - -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 device = luci.util.class(netmod.interface) - -netmod:register_pattern_virtual("^relay-%w") - -local proto = netmod:register_protocol("relay") - -function proto.get_i18n(self) - return luci.i18n.translate("Relay bridge") -end - -function proto.ifname(self) - return "relay-" .. self.sid -end - -function proto.opkg_package(self) - return "relayd" -end - -function proto.is_installed(self) - return nixio.fs.access("/lib/network/relay.sh") -end - -function proto.is_floating(self) - return true -end - -function proto.is_virtual(self) - return true -end - -function proto.get_interface(self) - return device(self.sid, self) -end - -function proto.get_interfaces(self) - if not self.ifaces then - local ifs = { } - local _, net, dev - - for net in luci.util.imatch(self:_get("network")) do - net = netmod:get_network(net) - if net then - dev = net:get_interface() - if dev then - ifs[dev:name()] = dev - end - end - end - - for dev in luci.util.imatch(self:_get("ifname")) do - dev = netmod:get_interface(dev) - if dev then - ifs[dev:name()] = dev - end - end - - self.ifaces = { } - - for _, dev in luci.util.kspairs(ifs) do - self.ifaces[#self.ifaces+1] = dev - end - end - - return self.ifaces -end - -function proto.uptime(self) - local net - local upt = 0 - for net in luci.util.imatch(self:_get("network")) do - net = netmod:get_network(net) - if net then - upt = math.max(upt, net:uptime()) - end - end - return upt -end - - -function device.__init__(self, ifname, network) - self.ifname = ifname - self.network = network -end - -function device.type(self) - return "tunnel" -end - -function device.is_up(self) - if self.network then - local _, dev - for _, dev in ipairs(self.network:get_interfaces()) do - if not dev:is_up() then - return false - end - end - return true - end - return false -end - -function device._stat(self, what) - local v = 0 - if self.network then - local _, dev - for _, dev in ipairs(self.network:get_interfaces()) do - v = v + dev[what](dev) - end - end - return v -end - -function device.rx_bytes(self) return self:_stat("rx_bytes") end -function device.tx_bytes(self) return self:_stat("tx_bytes") end -function device.rx_packets(self) return self:_stat("rx_packets") end -function device.tx_packets(self) return self:_stat("tx_packets") end - -function device.mac(self) - if self.network then - local _, dev - for _, dev in ipairs(self.network:get_interfaces()) do - return dev:mac() - end - end -end - -function device.ipaddrs(self) - local addrs = { } - if self.network then - addrs[1] = luci.ip.IPv4(self.network:_get("ipaddr")) - end - return addrs -end - -function device.ip6addrs(self) - return { } -end - -function device.shortname(self) - return "%s %q" % { luci.i18n.translate("Relay"), self.ifname } -end - -function device.get_type_i18n(self) - return luci.i18n.translate("Relay Bridge") -end diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/proto_3g.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_3g.lua deleted file mode 100644 index f14434dd8..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_3g.lua +++ /dev/null @@ -1,152 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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 device, apn, service, pincode, username, password -local ipv6, maxwait, defaultroute, metric, peerdns, dns, - keepalive_failure, keepalive_interval, demand - - -device = section:taboption("general", Value, "device", translate("Modem device")) -device.rmempty = false - -local device_suggestions = nixio.fs.glob("/dev/tty[A-Z]*") - or nixio.fs.glob("/dev/tts/*") - -if device_suggestions then - local node - for node in device_suggestions do - device:value(node) - end -end - - -service = section:taboption("general", Value, "service", translate("Service Type")) -service:value("", translate("-- Please choose --")) -service:value("umts", "UMTS/GPRS") -service:value("cdma", "CDMA") -service:value("evdo", "EV-DO") - - -apn = section:taboption("general", Value, "apn", translate("APN")) - - -pincode = section:taboption("general", Value, "pincode", translate("PIN")) -pincode.datatype = "range(0,9999)" - - -username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) - - -password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) -password.password = true - - -if luci.model.network:has_ipv6() then - - ipv6 = section:taboption("advanced", Flag, "ipv6", - translate("Enable IPv6 negotiation on the PPP link")) - - ipv6.default = ipv6.disabled - -end - - -maxwait = section:taboption("advanced", Value, "maxwait", - translate("Modem init timeout"), - translate("Maximum amount of seconds to wait for the modem to become ready")) - -maxwait.placeholder = "20" -maxwait.datatype = "min(1)" - - -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) - - -peerdns = section:taboption("advanced", Flag, "peerdns", - translate("Use DNS servers advertised by peer"), - translate("If unchecked, the advertised DNS server addresses are ignored")) - -peerdns.default = peerdns.enabled - - -dns = section:taboption("advanced", DynamicList, "dns", - translate("Use custom DNS servers")) - -dns:depends("peerdns", "") -dns.datatype = "ipaddr" - - -keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", - translate("LCP echo failure threshold"), - translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) - -function keepalive_failure.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^(%d+)[ ,]+%d+") or v) - end -end - -function keepalive_failure.write() end -function keepalive_failure.remove() end - -keepalive_failure.placeholder = "0" -keepalive_failure.datatype = "uinteger" - - -keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", - translate("LCP echo interval"), - translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) - -function keepalive_interval.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^%d+[ ,]+(%d+)")) - end -end - -function keepalive_interval.write(self, section, value) - local f = tonumber(keepalive_failure:formvalue(section)) or 0 - local i = tonumber(value) or 5 - if i < 1 then i = 1 end - if f > 0 then - m:set(section, "keepalive", "%d %d" %{ f, i }) - else - m:del(section, "keepalive") - end -end - -keepalive_interval.remove = keepalive_interval.write -keepalive_interval.placeholder = "5" -keepalive_interval.datatype = "min(1)" - - -demand = section:taboption("advanced", Value, "demand", - translate("Inactivity timeout"), - translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) - -demand.placeholder = "0" -demand.datatype = "uinteger" diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/proto_6in4.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_6in4.lua deleted file mode 100644 index 29b1039fb..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_6in4.lua +++ /dev/null @@ -1,96 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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 :2")) - -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/modules/admin-full/luasrc/model/cbi/admin_network/proto_6to4.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_6to4.lua deleted file mode 100644 index d10ab089c..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_6to4.lua +++ /dev/null @@ -1,97 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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/modules/admin-full/luasrc/model/cbi/admin_network/proto_dhcp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_dhcp.lua deleted file mode 100644 index 566ea2331..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_dhcp.lua +++ /dev/null @@ -1,88 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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/modules/admin-full/luasrc/model/cbi/admin_network/proto_none.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_none.lua deleted file mode 100644 index 0e34b67de..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_none.lua +++ /dev/null @@ -1,13 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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/modules/admin-full/luasrc/model/cbi/admin_network/proto_ppp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_ppp.lua deleted file mode 100644 index 6cbdd9953..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_ppp.lua +++ /dev/null @@ -1,130 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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 device, username, password -local ipv6, defaultroute, metric, peerdns, dns, - keepalive_failure, keepalive_interval, demand - - -device = section:taboption("general", Value, "device", translate("Modem device")) -device.rmempty = false - -local device_suggestions = nixio.fs.glob("/dev/tty*S*") - or nixio.fs.glob("/dev/tts/*") - -if device_suggestions then - local node - for node in device_suggestions do - device:value(node) - end -end - - -username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) - - -password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) -password.password = true - - -if luci.model.network:has_ipv6() then - - ipv6 = section:taboption("advanced", Flag, "ipv6", - translate("Enable IPv6 negotiation on the PPP link")) - - ipv6.default = ipv6.disabled - -end - - -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) - - -peerdns = section:taboption("advanced", Flag, "peerdns", - translate("Use DNS servers advertised by peer"), - translate("If unchecked, the advertised DNS server addresses are ignored")) - -peerdns.default = peerdns.enabled - - -dns = section:taboption("advanced", DynamicList, "dns", - translate("Use custom DNS servers")) - -dns:depends("peerdns", "") -dns.datatype = "ipaddr" - - -keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", - translate("LCP echo failure threshold"), - translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) - -function keepalive_failure.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^(%d+)[ ,]+%d+") or v) - end -end - -function keepalive_failure.write() end -function keepalive_failure.remove() end - -keepalive_failure.placeholder = "0" -keepalive_failure.datatype = "uinteger" - - -keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", - translate("LCP echo interval"), - translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) - -function keepalive_interval.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^%d+[ ,]+(%d+)")) - end -end - -function keepalive_interval.write(self, section, value) - local f = tonumber(keepalive_failure:formvalue(section)) or 0 - local i = tonumber(value) or 5 - if i < 1 then i = 1 end - if f > 0 then - m:set(section, "keepalive", "%d %d" %{ f, i }) - else - m:del(section, "keepalive") - end -end - -keepalive_interval.remove = keepalive_interval.write -keepalive_interval.placeholder = "5" -keepalive_interval.datatype = "min(1)" - - -demand = section:taboption("advanced", Value, "demand", - translate("Inactivity timeout"), - translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) - -demand.placeholder = "0" -demand.datatype = "uinteger" diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/proto_pppoa.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_pppoa.lua deleted file mode 100644 index 9bc956a79..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_pppoa.lua +++ /dev/null @@ -1,136 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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 encaps, atmdev, vci, vpi, username, password -local ipv6, defaultroute, metric, peerdns, dns, - keepalive_failure, keepalive_interval, demand - - -encaps = section:taboption("general", ListValue, "encaps", translate("PPPoA Encapsulation")) -encaps:value("vc", "VC-Mux") -encaps:value("llc", "LLC") - - -atmdev = section:taboption("general", Value, "atmdev", translate("ATM device number")) -atmdev.default = "0" -atmdev.datatype = "uinteger" - - -vci = section:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)")) -vci.default = "35" -vci.datatype = "uinteger" - - -vpi = section:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)")) -vpi.default = "8" -vpi.datatype = "uinteger" - - -username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) - - -password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) -password.password = true - - -if luci.model.network:has_ipv6() then - - ipv6 = section:taboption("advanced", Flag, "ipv6", - translate("Enable IPv6 negotiation on the PPP link")) - - ipv6.default = ipv6.disabled - -end - - -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) - - -peerdns = section:taboption("advanced", Flag, "peerdns", - translate("Use DNS servers advertised by peer"), - translate("If unchecked, the advertised DNS server addresses are ignored")) - -peerdns.default = peerdns.enabled - - -dns = section:taboption("advanced", DynamicList, "dns", - translate("Use custom DNS servers")) - -dns:depends("peerdns", "") -dns.datatype = "ipaddr" - - -keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", - translate("LCP echo failure threshold"), - translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) - -function keepalive_failure.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^(%d+)[ ,]+%d+") or v) - end -end - -function keepalive_failure.write() end -function keepalive_failure.remove() end - -keepalive_failure.placeholder = "0" -keepalive_failure.datatype = "uinteger" - - -keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", - translate("LCP echo interval"), - translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) - -function keepalive_interval.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^%d+[ ,]+(%d+)")) - end -end - -function keepalive_interval.write(self, section, value) - local f = tonumber(keepalive_failure:formvalue(section)) or 0 - local i = tonumber(value) or 5 - if i < 1 then i = 1 end - if f > 0 then - m:set(section, "keepalive", "%d %d" %{ f, i }) - else - m:del(section, "keepalive") - end -end - -keepalive_interval.remove = keepalive_interval.write -keepalive_interval.placeholder = "5" -keepalive_interval.datatype = "min(1)" - - -demand = section:taboption("advanced", Value, "demand", - translate("Inactivity timeout"), - translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) - -demand.placeholder = "0" -demand.datatype = "uinteger" diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/proto_pppoe.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_pppoe.lua deleted file mode 100644 index 6a5d3c362..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_pppoe.lua +++ /dev/null @@ -1,130 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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 username, password, ac, service -local ipv6, defaultroute, metric, peerdns, dns, - keepalive_failure, keepalive_interval, demand - - -username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) - - -password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) -password.password = true - - -ac = section:taboption("general", Value, "ac", - translate("Access Concentrator"), - translate("Leave empty to autodetect")) - -ac.placeholder = translate("auto") - - -service = section:taboption("general", Value, "service", - translate("Service Name"), - translate("Leave empty to autodetect")) - -service.placeholder = translate("auto") - - -if luci.model.network:has_ipv6() then - - ipv6 = section:taboption("advanced", Flag, "ipv6", - translate("Enable IPv6 negotiation on the PPP link")) - - ipv6.default = ipv6.disabled - -end - - -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) - - -peerdns = section:taboption("advanced", Flag, "peerdns", - translate("Use DNS servers advertised by peer"), - translate("If unchecked, the advertised DNS server addresses are ignored")) - -peerdns.default = peerdns.enabled - - -dns = section:taboption("advanced", DynamicList, "dns", - translate("Use custom DNS servers")) - -dns:depends("peerdns", "") -dns.datatype = "ipaddr" - - -keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", - translate("LCP echo failure threshold"), - translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) - -function keepalive_failure.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^(%d+)[ ,]+%d+") or v) - end -end - -function keepalive_failure.write() end -function keepalive_failure.remove() end - -keepalive_failure.placeholder = "0" -keepalive_failure.datatype = "uinteger" - - -keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", - translate("LCP echo interval"), - translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) - -function keepalive_interval.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^%d+[ ,]+(%d+)")) - end -end - -function keepalive_interval.write(self, section, value) - local f = tonumber(keepalive_failure:formvalue(section)) or 0 - local i = tonumber(value) or 5 - if i < 1 then i = 1 end - if f > 0 then - m:set(section, "keepalive", "%d %d" %{ f, i }) - else - m:del(section, "keepalive") - end -end - -keepalive_interval.remove = keepalive_interval.write -keepalive_interval.placeholder = "5" -keepalive_interval.datatype = "min(1)" - - -demand = section:taboption("advanced", Value, "demand", - translate("Inactivity timeout"), - translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) - -demand.placeholder = "0" -demand.datatype = "uinteger" diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/proto_pptp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_pptp.lua deleted file mode 100644 index 4124b2efe..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_pptp.lua +++ /dev/null @@ -1,60 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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 server, username, password -local buffering, defaultroute, metric, peerdns, dns - - -server = section:taboption("general", Value, "server", translate("VPN Server")) -server.datatype = "host" - - -username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) - - -password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) -password.password = true - - -buffering = section:taboption("advanced", Flag, "buffering", translate("Enable buffering")) -buffering.default = buffering.enabled - - -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) - - -peerdns = section:taboption("advanced", Flag, "peerdns", - translate("Use DNS servers advertised by peer"), - translate("If unchecked, the advertised DNS server addresses are ignored")) - -peerdns.default = peerdns.enabled - - -dns = section:taboption("advanced", DynamicList, "dns", - translate("Use DNS servers")) - -dns:depends("peerdns", "") -dns.datatype = "ipaddr" diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/proto_relay.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_relay.lua deleted file mode 100644 index 017bb9bfa..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_relay.lua +++ /dev/null @@ -1,77 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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, network -local forward_bcast, forward_dhcp, gateway, expiry, retry, table - - -ipaddr = section:taboption("general", Value, "ipaddr", - translate("Local IPv4 address"), - translate("Address to access local relay bridge")) - -ipaddr.datatype = "ip4addr" - - -network = s:taboption("general", DynamicList, "network", translate("Relay between networks")) -network.widget = "checkbox" -network.exclude = arg[1] -network.template = "cbi/network_netlist" -network.nocreate = true -network.nobridges = true -network.novirtual = true -network:depends("proto", "relay") - - -forward_bcast = section:taboption("advanced", Flag, "forward_bcast", - translate("Forward broadcast traffic")) - -forward_bcast.default = forward_bcast.enabled - - -forward_dhcp = section:taboption("advanced", Flag, "forward_dhcp", - translate("Forward DHCP traffic")) - -forward_dhcp.default = forward_dhcp.enabled - - -gateway = section:taboption("advanced", Value, "gateway", - translate("Use DHCP gateway"), - translate("Override the gateway in DHCP responses")) - -gateway.datatype = "ip4addr" -gateway:depends("forward_dhcp", forward_dhcp.enabled) - - -expiry = section:taboption("advanced", Value, "expiry", - translate("Host expiry timeout"), - translate("Specifies the maximum amount of seconds after which hosts are presumed to be dead")) - -expiry.placeholder = "30" -expiry.datatype = "min(1)" - - -retry = section:taboption("advanced", Value, "retry", - translate("ARP retry threshold"), - translate("Specifies the maximum amount of failed ARP requests until hosts are presumed to be dead")) - -retry.placeholder = "5" -retry.datatype = "min(1)" - - -table = section:taboption("advanced", Value, "table", - translate("Use routing table"), - translate("Override the table used for internal routes")) - -table.placeholder = "16800" -table.datatype = "range(0,65535)" diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/proto_static.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_static.lua deleted file mode 100644 index 8ae9b7eab..000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_static.lua +++ /dev/null @@ -1,78 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich - -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" diff --git a/protocols/3g/luasrc/model/cbi/admin_network/proto_3g.lua b/protocols/3g/luasrc/model/cbi/admin_network/proto_3g.lua new file mode 100644 index 000000000..f14434dd8 --- /dev/null +++ b/protocols/3g/luasrc/model/cbi/admin_network/proto_3g.lua @@ -0,0 +1,152 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2011 Jo-Philipp Wich + +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 device, apn, service, pincode, username, password +local ipv6, maxwait, defaultroute, metric, peerdns, dns, + keepalive_failure, keepalive_interval, demand + + +device = section:taboption("general", Value, "device", translate("Modem device")) +device.rmempty = false + +local device_suggestions = nixio.fs.glob("/dev/tty[A-Z]*") + or nixio.fs.glob("/dev/tts/*") + +if device_suggestions then + local node + for node in device_suggestions do + device:value(node) + end +end + + +service = section:taboption("general", Value, "service", translate("Service Type")) +service:value("", translate("-- Please choose --")) +service:value("umts", "UMTS/GPRS") +service:value("cdma", "CDMA") +service:value("evdo", "EV-DO") + + +apn = section:taboption("general", Value, "apn", translate("APN")) + + +pincode = section:taboption("general", Value, "pincode", translate("PIN")) +pincode.datatype = "range(0,9999)" + + +username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) + + +password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) +password.password = true + + +if luci.model.network:has_ipv6() then + + ipv6 = section:taboption("advanced", Flag, "ipv6", + translate("Enable IPv6 negotiation on the PPP link")) + + ipv6.default = ipv6.disabled + +end + + +maxwait = section:taboption("advanced", Value, "maxwait", + translate("Modem init timeout"), + translate("Maximum amount of seconds to wait for the modem to become ready")) + +maxwait.placeholder = "20" +maxwait.datatype = "min(1)" + + +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) + + +peerdns = section:taboption("advanced", Flag, "peerdns", + translate("Use DNS servers advertised by peer"), + translate("If unchecked, the advertised DNS server addresses are ignored")) + +peerdns.default = peerdns.enabled + + +dns = section:taboption("advanced", DynamicList, "dns", + translate("Use custom DNS servers")) + +dns:depends("peerdns", "") +dns.datatype = "ipaddr" + + +keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", + translate("LCP echo failure threshold"), + translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) + +function keepalive_failure.cfgvalue(self, section) + local v = m:get(section, "keepalive") + if v and #v > 0 then + return tonumber(v:match("^(%d+)[ ,]+%d+") or v) + end +end + +function keepalive_failure.write() end +function keepalive_failure.remove() end + +keepalive_failure.placeholder = "0" +keepalive_failure.datatype = "uinteger" + + +keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", + translate("LCP echo interval"), + translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) + +function keepalive_interval.cfgvalue(self, section) + local v = m:get(section, "keepalive") + if v and #v > 0 then + return tonumber(v:match("^%d+[ ,]+(%d+)")) + end +end + +function keepalive_interval.write(self, section, value) + local f = tonumber(keepalive_failure:formvalue(section)) or 0 + local i = tonumber(value) or 5 + if i < 1 then i = 1 end + if f > 0 then + m:set(section, "keepalive", "%d %d" %{ f, i }) + else + m:del(section, "keepalive") + end +end + +keepalive_interval.remove = keepalive_interval.write +keepalive_interval.placeholder = "5" +keepalive_interval.datatype = "min(1)" + + +demand = section:taboption("advanced", Value, "demand", + translate("Inactivity timeout"), + translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) + +demand.placeholder = "0" +demand.datatype = "uinteger" 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 000000000..29b1039fb --- /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 + +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 :2")) + +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 000000000..d10ab089c --- /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 + +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 000000000..d4d72c828 --- /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 + +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 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 + +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 + +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 + +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" diff --git a/protocols/ppp/luasrc/model/cbi/admin_network/proto_ppp.lua b/protocols/ppp/luasrc/model/cbi/admin_network/proto_ppp.lua new file mode 100644 index 000000000..6cbdd9953 --- /dev/null +++ b/protocols/ppp/luasrc/model/cbi/admin_network/proto_ppp.lua @@ -0,0 +1,130 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2011 Jo-Philipp Wich + +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 device, username, password +local ipv6, defaultroute, metric, peerdns, dns, + keepalive_failure, keepalive_interval, demand + + +device = section:taboption("general", Value, "device", translate("Modem device")) +device.rmempty = false + +local device_suggestions = nixio.fs.glob("/dev/tty*S*") + or nixio.fs.glob("/dev/tts/*") + +if device_suggestions then + local node + for node in device_suggestions do + device:value(node) + end +end + + +username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) + + +password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) +password.password = true + + +if luci.model.network:has_ipv6() then + + ipv6 = section:taboption("advanced", Flag, "ipv6", + translate("Enable IPv6 negotiation on the PPP link")) + + ipv6.default = ipv6.disabled + +end + + +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) + + +peerdns = section:taboption("advanced", Flag, "peerdns", + translate("Use DNS servers advertised by peer"), + translate("If unchecked, the advertised DNS server addresses are ignored")) + +peerdns.default = peerdns.enabled + + +dns = section:taboption("advanced", DynamicList, "dns", + translate("Use custom DNS servers")) + +dns:depends("peerdns", "") +dns.datatype = "ipaddr" + + +keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", + translate("LCP echo failure threshold"), + translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) + +function keepalive_failure.cfgvalue(self, section) + local v = m:get(section, "keepalive") + if v and #v > 0 then + return tonumber(v:match("^(%d+)[ ,]+%d+") or v) + end +end + +function keepalive_failure.write() end +function keepalive_failure.remove() end + +keepalive_failure.placeholder = "0" +keepalive_failure.datatype = "uinteger" + + +keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", + translate("LCP echo interval"), + translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) + +function keepalive_interval.cfgvalue(self, section) + local v = m:get(section, "keepalive") + if v and #v > 0 then + return tonumber(v:match("^%d+[ ,]+(%d+)")) + end +end + +function keepalive_interval.write(self, section, value) + local f = tonumber(keepalive_failure:formvalue(section)) or 0 + local i = tonumber(value) or 5 + if i < 1 then i = 1 end + if f > 0 then + m:set(section, "keepalive", "%d %d" %{ f, i }) + else + m:del(section, "keepalive") + end +end + +keepalive_interval.remove = keepalive_interval.write +keepalive_interval.placeholder = "5" +keepalive_interval.datatype = "min(1)" + + +demand = section:taboption("advanced", Value, "demand", + translate("Inactivity timeout"), + translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) + +demand.placeholder = "0" +demand.datatype = "uinteger" diff --git a/protocols/ppp/luasrc/model/cbi/admin_network/proto_pppoa.lua b/protocols/ppp/luasrc/model/cbi/admin_network/proto_pppoa.lua new file mode 100644 index 000000000..9bc956a79 --- /dev/null +++ b/protocols/ppp/luasrc/model/cbi/admin_network/proto_pppoa.lua @@ -0,0 +1,136 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2011 Jo-Philipp Wich + +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 encaps, atmdev, vci, vpi, username, password +local ipv6, defaultroute, metric, peerdns, dns, + keepalive_failure, keepalive_interval, demand + + +encaps = section:taboption("general", ListValue, "encaps", translate("PPPoA Encapsulation")) +encaps:value("vc", "VC-Mux") +encaps:value("llc", "LLC") + + +atmdev = section:taboption("general", Value, "atmdev", translate("ATM device number")) +atmdev.default = "0" +atmdev.datatype = "uinteger" + + +vci = section:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)")) +vci.default = "35" +vci.datatype = "uinteger" + + +vpi = section:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)")) +vpi.default = "8" +vpi.datatype = "uinteger" + + +username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) + + +password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) +password.password = true + + +if luci.model.network:has_ipv6() then + + ipv6 = section:taboption("advanced", Flag, "ipv6", + translate("Enable IPv6 negotiation on the PPP link")) + + ipv6.default = ipv6.disabled + +end + + +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) + + +peerdns = section:taboption("advanced", Flag, "peerdns", + translate("Use DNS servers advertised by peer"), + translate("If unchecked, the advertised DNS server addresses are ignored")) + +peerdns.default = peerdns.enabled + + +dns = section:taboption("advanced", DynamicList, "dns", + translate("Use custom DNS servers")) + +dns:depends("peerdns", "") +dns.datatype = "ipaddr" + + +keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", + translate("LCP echo failure threshold"), + translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) + +function keepalive_failure.cfgvalue(self, section) + local v = m:get(section, "keepalive") + if v and #v > 0 then + return tonumber(v:match("^(%d+)[ ,]+%d+") or v) + end +end + +function keepalive_failure.write() end +function keepalive_failure.remove() end + +keepalive_failure.placeholder = "0" +keepalive_failure.datatype = "uinteger" + + +keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", + translate("LCP echo interval"), + translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) + +function keepalive_interval.cfgvalue(self, section) + local v = m:get(section, "keepalive") + if v and #v > 0 then + return tonumber(v:match("^%d+[ ,]+(%d+)")) + end +end + +function keepalive_interval.write(self, section, value) + local f = tonumber(keepalive_failure:formvalue(section)) or 0 + local i = tonumber(value) or 5 + if i < 1 then i = 1 end + if f > 0 then + m:set(section, "keepalive", "%d %d" %{ f, i }) + else + m:del(section, "keepalive") + end +end + +keepalive_interval.remove = keepalive_interval.write +keepalive_interval.placeholder = "5" +keepalive_interval.datatype = "min(1)" + + +demand = section:taboption("advanced", Value, "demand", + translate("Inactivity timeout"), + translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) + +demand.placeholder = "0" +demand.datatype = "uinteger" diff --git a/protocols/ppp/luasrc/model/cbi/admin_network/proto_pppoe.lua b/protocols/ppp/luasrc/model/cbi/admin_network/proto_pppoe.lua new file mode 100644 index 000000000..6a5d3c362 --- /dev/null +++ b/protocols/ppp/luasrc/model/cbi/admin_network/proto_pppoe.lua @@ -0,0 +1,130 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2011 Jo-Philipp Wich + +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 username, password, ac, service +local ipv6, defaultroute, metric, peerdns, dns, + keepalive_failure, keepalive_interval, demand + + +username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) + + +password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) +password.password = true + + +ac = section:taboption("general", Value, "ac", + translate("Access Concentrator"), + translate("Leave empty to autodetect")) + +ac.placeholder = translate("auto") + + +service = section:taboption("general", Value, "service", + translate("Service Name"), + translate("Leave empty to autodetect")) + +service.placeholder = translate("auto") + + +if luci.model.network:has_ipv6() then + + ipv6 = section:taboption("advanced", Flag, "ipv6", + translate("Enable IPv6 negotiation on the PPP link")) + + ipv6.default = ipv6.disabled + +end + + +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) + + +peerdns = section:taboption("advanced", Flag, "peerdns", + translate("Use DNS servers advertised by peer"), + translate("If unchecked, the advertised DNS server addresses are ignored")) + +peerdns.default = peerdns.enabled + + +dns = section:taboption("advanced", DynamicList, "dns", + translate("Use custom DNS servers")) + +dns:depends("peerdns", "") +dns.datatype = "ipaddr" + + +keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", + translate("LCP echo failure threshold"), + translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) + +function keepalive_failure.cfgvalue(self, section) + local v = m:get(section, "keepalive") + if v and #v > 0 then + return tonumber(v:match("^(%d+)[ ,]+%d+") or v) + end +end + +function keepalive_failure.write() end +function keepalive_failure.remove() end + +keepalive_failure.placeholder = "0" +keepalive_failure.datatype = "uinteger" + + +keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", + translate("LCP echo interval"), + translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) + +function keepalive_interval.cfgvalue(self, section) + local v = m:get(section, "keepalive") + if v and #v > 0 then + return tonumber(v:match("^%d+[ ,]+(%d+)")) + end +end + +function keepalive_interval.write(self, section, value) + local f = tonumber(keepalive_failure:formvalue(section)) or 0 + local i = tonumber(value) or 5 + if i < 1 then i = 1 end + if f > 0 then + m:set(section, "keepalive", "%d %d" %{ f, i }) + else + m:del(section, "keepalive") + end +end + +keepalive_interval.remove = keepalive_interval.write +keepalive_interval.placeholder = "5" +keepalive_interval.datatype = "min(1)" + + +demand = section:taboption("advanced", Value, "demand", + translate("Inactivity timeout"), + translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) + +demand.placeholder = "0" +demand.datatype = "uinteger" diff --git a/protocols/ppp/luasrc/model/network/proto_ppp.lua b/protocols/ppp/luasrc/model/network/proto_ppp.lua new file mode 100644 index 000000000..af6f39402 --- /dev/null +++ b/protocols/ppp/luasrc/model/network/proto_ppp.lua @@ -0,0 +1,86 @@ +--[[ +LuCI - Network model - 3G, PPP, PPtP, PPPoE and PPPoA protocol extension + +Copyright 2011 Jo-Philipp Wich + +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({"ppp", "pptp", "pppoe", "pppoa", "3g"}) do + + local proto = netmod:register_protocol(p) + + function proto.get_i18n(self) + if p == "ppp" then + return luci.i18n.translate("PPP") + elseif p == "pptp" then + return luci.i18n.translate("PPtP") + elseif p == "3g" then + return luci.i18n.translate("UMTS/GPRS/EV-DO") + elseif p == "pppoe" then + return luci.i18n.translate("PPPoE") + elseif p == "pppoa" then + return luci.i18n.translate("PPPoATM") + end + end + + function proto.ifname(self) + return p .. "-" .. self.sid + end + + function proto.opkg_package(self) + if p == "ppp" or p == "pptp" then + return p + elseif p == "3g" then + return "comgt" + elseif p == "pppoe" then + return "ppp-mod-pppoe" + elseif p == "pppoa" then + return "ppp-mod-pppoa" + end + end + + function proto.is_installed(self) + return nixio.fs.access("/lib/network/" .. p .. ".sh") + end + + function proto.is_floating(self) + return (p ~= "pppoe") + end + + function proto.is_virtual(self) + return true + end + + function proto.get_interfaces(self) + if self:is_floating() then + return nil + else + return netmod.protocol.get_interfaces(self) + end + end + + function proto.contains_interface(self, ifc) + if self:is_floating() then + return (netmod:ifnameof(ifc) == self:ifname()) + else + return netmod.protocol.contains_interface(self, ifc) + end + end + + netmod:register_pattern_virtual("^%s-%%w" % p) +end diff --git a/protocols/pptp/luasrc/model/cbi/admin_network/proto_pptp.lua b/protocols/pptp/luasrc/model/cbi/admin_network/proto_pptp.lua new file mode 100644 index 000000000..4124b2efe --- /dev/null +++ b/protocols/pptp/luasrc/model/cbi/admin_network/proto_pptp.lua @@ -0,0 +1,60 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2011 Jo-Philipp Wich + +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 server, username, password +local buffering, defaultroute, metric, peerdns, dns + + +server = section:taboption("general", Value, "server", translate("VPN Server")) +server.datatype = "host" + + +username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) + + +password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) +password.password = true + + +buffering = section:taboption("advanced", Flag, "buffering", translate("Enable buffering")) +buffering.default = buffering.enabled + + +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) + + +peerdns = section:taboption("advanced", Flag, "peerdns", + translate("Use DNS servers advertised by peer"), + translate("If unchecked, the advertised DNS server addresses are ignored")) + +peerdns.default = peerdns.enabled + + +dns = section:taboption("advanced", DynamicList, "dns", + translate("Use DNS servers")) + +dns:depends("peerdns", "") +dns.datatype = "ipaddr" diff --git a/protocols/relay/luasrc/model/cbi/admin_network/proto_relay.lua b/protocols/relay/luasrc/model/cbi/admin_network/proto_relay.lua new file mode 100644 index 000000000..017bb9bfa --- /dev/null +++ b/protocols/relay/luasrc/model/cbi/admin_network/proto_relay.lua @@ -0,0 +1,77 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2011 Jo-Philipp Wich + +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, network +local forward_bcast, forward_dhcp, gateway, expiry, retry, table + + +ipaddr = section:taboption("general", Value, "ipaddr", + translate("Local IPv4 address"), + translate("Address to access local relay bridge")) + +ipaddr.datatype = "ip4addr" + + +network = s:taboption("general", DynamicList, "network", translate("Relay between networks")) +network.widget = "checkbox" +network.exclude = arg[1] +network.template = "cbi/network_netlist" +network.nocreate = true +network.nobridges = true +network.novirtual = true +network:depends("proto", "relay") + + +forward_bcast = section:taboption("advanced", Flag, "forward_bcast", + translate("Forward broadcast traffic")) + +forward_bcast.default = forward_bcast.enabled + + +forward_dhcp = section:taboption("advanced", Flag, "forward_dhcp", + translate("Forward DHCP traffic")) + +forward_dhcp.default = forward_dhcp.enabled + + +gateway = section:taboption("advanced", Value, "gateway", + translate("Use DHCP gateway"), + translate("Override the gateway in DHCP responses")) + +gateway.datatype = "ip4addr" +gateway:depends("forward_dhcp", forward_dhcp.enabled) + + +expiry = section:taboption("advanced", Value, "expiry", + translate("Host expiry timeout"), + translate("Specifies the maximum amount of seconds after which hosts are presumed to be dead")) + +expiry.placeholder = "30" +expiry.datatype = "min(1)" + + +retry = section:taboption("advanced", Value, "retry", + translate("ARP retry threshold"), + translate("Specifies the maximum amount of failed ARP requests until hosts are presumed to be dead")) + +retry.placeholder = "5" +retry.datatype = "min(1)" + + +table = section:taboption("advanced", Value, "table", + translate("Use routing table"), + translate("Override the table used for internal routes")) + +table.placeholder = "16800" +table.datatype = "range(0,65535)" diff --git a/protocols/relay/luasrc/model/network/proto_relay.lua b/protocols/relay/luasrc/model/network/proto_relay.lua new file mode 100644 index 000000000..03f6d6abf --- /dev/null +++ b/protocols/relay/luasrc/model/network/proto_relay.lua @@ -0,0 +1,165 @@ +--[[ +LuCI - Network model - relay protocol extension + +Copyright 2011 Jo-Philipp Wich + +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 device = luci.util.class(netmod.interface) + +netmod:register_pattern_virtual("^relay-%w") + +local proto = netmod:register_protocol("relay") + +function proto.get_i18n(self) + return luci.i18n.translate("Relay bridge") +end + +function proto.ifname(self) + return "relay-" .. self.sid +end + +function proto.opkg_package(self) + return "relayd" +end + +function proto.is_installed(self) + return nixio.fs.access("/lib/network/relay.sh") +end + +function proto.is_floating(self) + return true +end + +function proto.is_virtual(self) + return true +end + +function proto.get_interface(self) + return device(self.sid, self) +end + +function proto.get_interfaces(self) + if not self.ifaces then + local ifs = { } + local _, net, dev + + for net in luci.util.imatch(self:_get("network")) do + net = netmod:get_network(net) + if net then + dev = net:get_interface() + if dev then + ifs[dev:name()] = dev + end + end + end + + for dev in luci.util.imatch(self:_get("ifname")) do + dev = netmod:get_interface(dev) + if dev then + ifs[dev:name()] = dev + end + end + + self.ifaces = { } + + for _, dev in luci.util.kspairs(ifs) do + self.ifaces[#self.ifaces+1] = dev + end + end + + return self.ifaces +end + +function proto.uptime(self) + local net + local upt = 0 + for net in luci.util.imatch(self:_get("network")) do + net = netmod:get_network(net) + if net then + upt = math.max(upt, net:uptime()) + end + end + return upt +end + + +function device.__init__(self, ifname, network) + self.ifname = ifname + self.network = network +end + +function device.type(self) + return "tunnel" +end + +function device.is_up(self) + if self.network then + local _, dev + for _, dev in ipairs(self.network:get_interfaces()) do + if not dev:is_up() then + return false + end + end + return true + end + return false +end + +function device._stat(self, what) + local v = 0 + if self.network then + local _, dev + for _, dev in ipairs(self.network:get_interfaces()) do + v = v + dev[what](dev) + end + end + return v +end + +function device.rx_bytes(self) return self:_stat("rx_bytes") end +function device.tx_bytes(self) return self:_stat("tx_bytes") end +function device.rx_packets(self) return self:_stat("rx_packets") end +function device.tx_packets(self) return self:_stat("tx_packets") end + +function device.mac(self) + if self.network then + local _, dev + for _, dev in ipairs(self.network:get_interfaces()) do + return dev:mac() + end + end +end + +function device.ipaddrs(self) + local addrs = { } + if self.network then + addrs[1] = luci.ip.IPv4(self.network:_get("ipaddr")) + end + return addrs +end + +function device.ip6addrs(self) + return { } +end + +function device.shortname(self) + return "%s %q" % { luci.i18n.translate("Relay"), self.ifname } +end + +function device.get_type_i18n(self) + return luci.i18n.translate("Relay Bridge") +end