diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/model/network/proto_6x4.lua | 64 | ||||
-rw-r--r-- | libs/core/luasrc/model/network/proto_ppp.lua | 86 | ||||
-rw-r--r-- | libs/core/luasrc/model/network/proto_relay.lua | 165 |
3 files changed, 0 insertions, 315 deletions
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 <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 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 <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({"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 <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 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 |