From 7a76f6b68fc2808c7fabb43a7a6e23932cad8e5f Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 27 Oct 2009 16:48:03 +0000 Subject: [PATCH] Forgotten files --- .../niu/luasrc/model/cbi/niu/network/etherwan.lua | 164 +++++++++++++++++++++ modules/niu/luasrc/model/cbi/niu/network/wan.lua | 20 +++ .../niu/luasrc/model/cbi/niu/network/wandevice.lua | 30 ++++ 3 files changed, 214 insertions(+) create mode 100644 modules/niu/luasrc/model/cbi/niu/network/etherwan.lua create mode 100644 modules/niu/luasrc/model/cbi/niu/network/wan.lua create mode 100644 modules/niu/luasrc/model/cbi/niu/network/wandevice.lua diff --git a/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua b/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua new file mode 100644 index 000000000..53be7eb65 --- /dev/null +++ b/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua @@ -0,0 +1,164 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2009 Steven Barth +Copyright 2009 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 + +$Id$ +]]-- + +local fs = require "nixio.fs" +local nw = require "luci.model.network" + +local has_ipv6 = nw:has_ipv6() +local has_pptp = fs.access("/usr/sbin/pptp") +local has_pppd = fs.access("/usr/sbin/pppd") +local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")() +local has_pppoa = fs.glob("/usr/lib/pppd/*/pppoatm.so")() + + +m = Map("network", translate("m_n_internet")) +nw.init(m.uci) + +s = m:section(NamedSection, "wan", "interface") +s.addremove = false + +s:tab("general", translate("niu_general", "General Settings")) +s:tab("expert", translate("niu_expert", "Expert Settings")) + +p = s:taboption("general", ListValue, "proto", translate("protocol")) +p.override_scheme = true +p.default = "static" +p:value("static", translate("static")) +p:value("dhcp", "DHCP") +if has_pppoe then p:value("pppoe", "PPPoE") end +if has_pppoa then p:value("pppoa", "PPPoA") end +if has_pptp then p:value("pptp", "PPTP") end +p:value("none", translate("none")) + + + +ipaddr = s:taboption("general", Value, "ipaddr", translate("ipaddress")) +ipaddr.rmempty = true +ipaddr:depends("proto", "static") + +nm = s:taboption("general", Value, "netmask", translate("netmask")) +nm.rmempty = true +nm:depends("proto", "static") +nm:value("255.255.255.0") +nm:value("255.255.0.0") +nm:value("255.0.0.0") + +gw = s:taboption("general", Value, "gateway", translate("gateway")) +gw:depends("proto", "static") +gw.rmempty = true + +bcast = s:taboption("expert", Value, "bcast", translate("broadcast")) +bcast:depends("proto", "static") + +if has_ipv6 then + ip6addr = s:taboption("expert", Value, "ip6addr", translate("ip6address"), translate("cidr6")) + ip6addr:depends("proto", "static") + + ip6gw = s:taboption("expert", Value, "ip6gw", translate("gateway6")) + ip6gw:depends("proto", "static") +end + +dns = s:taboption("expert", Value, "dns", translate("dnsserver")) +dns:depends("peerdns", "") + +mtu = s:taboption("expert", Value, "mtu", "MTU") +mtu.isinteger = true + +mac = s:taboption("expert", Value, "macaddr", translate("macaddress")) + + +srv = s:taboption("general", Value, "server", translate("network_interface_server")) +srv:depends("proto", "pptp") +srv.rmempty = true + +if has_pppd or has_pppoe or has_pppoa or has_pptp then + user = s:taboption("general", Value, "username", translate("username")) + user.rmempty = true + user:depends("proto", "pptp") + user:depends("proto", "pppoe") + user:depends("proto", "pppoa") + + pass = s:taboption("general", Value, "password", translate("password")) + pass.rmempty = true + pass.password = true + pass:depends("proto", "pptp") + pass:depends("proto", "pppoe") + pass:depends("proto", "pppoa") + + ka = s:taboption("expert", Value, "keepalive", + translate("network_interface_keepalive"), + translate("network_interface_keepalive_desc") + ) + ka.default = "5" + ka:depends("proto", "pptp") + ka:depends("proto", "pppoe") + ka:depends("proto", "pppoa") + + demand = s:taboption("expert", Value, "demand", + translate("network_interface_demand"), + translate("network_interface_demand_desc") + ) + demand:depends("proto", "pptp") + demand:depends("proto", "pppoe") + demand:depends("proto", "pppoa") +end + +if has_pppoa then + encaps = s:taboption("expert", ListValue, "encaps", translate("network_interface_encaps")) + encaps:depends("proto", "pppoa") + encaps:value("", translate("cbi_select")) + encaps:value("vc", "VC") + encaps:value("llc", "LLC") + + vpi = s:taboption("expert", Value, "vpi", "VPI") + vpi:depends("proto", "pppoa") + + vci = s:taboption("expert", Value, "vci", "VCI") + vci:depends("proto", "pppoa") +end + +if has_pptp or has_pppd or has_pppoe or has_pppoa or has_3g then +--[[ + defaultroute = s:taboption("expert", Flag, "defaultroute", + translate("network_interface_defaultroute"), + translate("network_interface_defaultroute_desc") + ) + defaultroute:depends("proto", "pppoa") + defaultroute:depends("proto", "pppoe") + defaultroute:depends("proto", "pptp") + defaultroute.rmempty = false + function defaultroute.cfgvalue(...) + return ( AbstractValue.cfgvalue(...) or '1' ) + end +]] + peerdns = s:taboption("expert", Flag, "peerdns", + translate("network_interface_peerdns"), + translate("network_interface_peerdns_desc") + ) + peerdns:depends("proto", "pppoa") + peerdns:depends("proto", "pppoe") + peerdns:depends("proto", "pptp") + peerdns.rmempty = false + peerdns.default = "1" + + if has_ipv6 then + ipv6 = s:taboption("expert", Flag, "ipv6", translate("network_interface_ipv6") ) + ipv6:depends("proto", "pppoa") + ipv6:depends("proto", "pppoe") + ipv6:depends("proto", "pptp") + end +end + +return m diff --git a/modules/niu/luasrc/model/cbi/niu/network/wan.lua b/modules/niu/luasrc/model/cbi/niu/network/wan.lua new file mode 100644 index 000000000..6c23738eb --- /dev/null +++ b/modules/niu/luasrc/model/cbi/niu/network/wan.lua @@ -0,0 +1,20 @@ +local cursor = require "luci.model.uci".cursor() +local d = Delegator() +d.allow_finish = true +d.allow_back = true +d.allow_cancel = true + +d:add("device", load("niu/network/wandevice")) +d:add("etherwan", load("niu/network/etherwan")) + +function d.on_cancel() + cursor:revert("network") + cursor:revert("wireless") +end + +function d.on_done() + cursor:commit("network") + cursor:commit("wireless") +end + +return d \ No newline at end of file diff --git a/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua b/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua new file mode 100644 index 000000000..1f65196f1 --- /dev/null +++ b/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua @@ -0,0 +1,30 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2009 Steven Barth + +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 + +$Id$ +]]-- + +local cursor = require "luci.model.uci".cursor() +local nw = require "luci.model.network" +nw.init(cursor) + +f = Form("wandev", "Internet Device") +l = f:field(ListValue, "device", "Gerät") +l:value("ethernet:eth0", "Ethernet / Cable / DSL (eth0)") +l:value("none", "No Internet Connection") + +function f.handle(self, state, data) + if state == FORM_VALID then + + end +end + +return f -- 2.11.0