From 2da8f3324e7268a7e49767e65c1b46cc3adf9134 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 12 Oct 2008 22:38:30 +0000 Subject: [PATCH] * luci-0.8: merge ppp config support (r3562-r3568) --- i18n/english/luasrc/i18n/admin-core.en.lua | 13 +++ i18n/english/luasrc/i18n/admin-core.en.xml | 13 +++ i18n/german/luasrc/i18n/admin-core.de.lua | 13 +++ i18n/german/luasrc/i18n/admin-core.de.xml | 13 +++ libs/uvl/luasrc/uvl/datatypes.lua | 16 +++ .../admin-core/root/lib/uci/schema/default/network | 111 ++++++++++++++++----- .../luasrc/model/cbi/admin_network/ifaces.lua | 62 ++++++++++-- 7 files changed, 207 insertions(+), 34 deletions(-) diff --git a/i18n/english/luasrc/i18n/admin-core.en.lua b/i18n/english/luasrc/i18n/admin-core.en.lua index 7eacad355..aaea8b4fa 100644 --- a/i18n/english/luasrc/i18n/admin-core.en.lua +++ b/i18n/english/luasrc/i18n/admin-core.en.lua @@ -197,6 +197,19 @@ network_interface_demand = 'Automatic Disconnect' network_interface_demand_desc = 'Time (in seconds) after which an unused connection will be closed' network_interface_keepalive = 'Keep-Alive' network_interface_keepalive_desc = 'Number of failed connection tests to initiate automatic reconnect' +network_interface_device = 'Modem device' +network_interface_device_desc = 'The device node of your modem, e.g. /dev/ttyUSB0' +network_interface_defaultroute = 'Replace default route' +network_interface_defaultroute_desc = 'Let pppd replace the current default route to use the PPP interface after successful connect' +network_interface_peerdns = 'Use peer DNS' +network_interface_peerdns_desc = 'Configure the local DNS server to use the name servers adverticed by the PPP peer' +network_interface_ipv6 = 'Enable IPv6 on PPP link' +network_interface_connect = 'Connect script' +network_interface_connect_desc = 'Let pppd run this script after establishing the PPP link' +network_interface_disconnect = 'Disconnect script' +network_interface_disconnect_desc = 'Let pppd run this script before tearing down the PPP link' +network_interface_pppd_options = 'Additional pppd options' +network_interface_pppd_options_desc = 'Specify additional command line arguments for pppd here' a_n_r_routes1 = 'Routes specify over which interface and gateway a certain host or network can be reached.' a_n_routes_static = 'Static Routes' a_n_routes_kernel4 = 'Active IPv4-Routes' diff --git a/i18n/english/luasrc/i18n/admin-core.en.xml b/i18n/english/luasrc/i18n/admin-core.en.xml index dff551614..ee6512b9e 100644 --- a/i18n/english/luasrc/i18n/admin-core.en.xml +++ b/i18n/english/luasrc/i18n/admin-core.en.xml @@ -201,6 +201,19 @@ Time (in seconds) after which an unused connection will be closed Keep-Alive Number of failed connection tests to initiate automatic reconnect +Modem device +The device node of your modem, e.g. /dev/ttyUSB0 +Replace default route +Let pppd replace the current default route to use the PPP interface after successful connect +Use peer DNS +Configure the local DNS server to use the name servers adverticed by the PPP peer +Enable IPv6 on PPP link +Connect script +Let pppd run this script after establishing the PPP link +Disconnect script +Let pppd run this script before tearing down the PPP link +Additional pppd options +Specify additional command line arguments for pppd here Routes specify over which interface and gateway a certain host or network can be reached. Static Routes Active IPv4-Routes diff --git a/i18n/german/luasrc/i18n/admin-core.de.lua b/i18n/german/luasrc/i18n/admin-core.de.lua index 0f1310ac5..c492acb5e 100644 --- a/i18n/german/luasrc/i18n/admin-core.de.lua +++ b/i18n/german/luasrc/i18n/admin-core.de.lua @@ -201,6 +201,19 @@ network_interface_demand_desc = 'Zeit (in s) nach der die Verbindung bei Inaktiv network_interface_keepalive = 'Keep-Alive' network_interface_keepalive_desc = 'Anzahl fehlgeschlagener Verbindungstests nach der automatisch neu verbunden wird' network_interface_server = 'PPTP-Server' +network_interface_device = 'Modemgerät' +network_interface_device_desc = 'Geräteknoten des Modems, z.B. /dev/ttyUSB0' +network_interface_defaultroute = 'Standardroute ersetzen' +network_interface_defaultroute_desc = 'Lässt pppd die aktuelle Standardroute ersetzen und über die PPP Schnittstelle leiten' +network_interface_peerdns = 'DNS der Gegenstelle nutzen' +network_interface_peerdns_desc = 'Konfiguriert den lokalen DNS-Server so, dass er die von der Gegenstelle angekündigten Nameserver-Adressen nutzt' +network_interface_ipv6 = 'IPv6 für die PPP-Verbindung aktivieren' +network_interface_connect = 'Verbindungs-Script' +network_interface_connect_desc = 'Lässt pppd das angegebene Script nach dem Aufbau der PPP Verbindung abarbeiten' +network_interface_disconnect = 'Trennuns-Script' +network_interface_disconnect_desc = 'Lässt pppd das angegebene Script vor dem Trennen der PPP Verbindung abarbeiten' +network_interface_pppd_options = 'Weitere pppd Optionen' +network_interface_pppd_options_desc = 'Hier können zusätzliche Kommandozeilenargumente für pppd angegeben werden' network_switch_desc = 'Die zu einem VLAN gehörenden Schnittstellen werden durch Leerzeichen getrennt. Die Schnittstelle mit der höchsten Nummer (meistens 5) bildet in der Regel die Verbindung zur internen Netzschnittstelle des Routers. Bei Geräten mit 5 Schnittstellen ist in der Regel die Schnittstelle mit der niedrigsten Nummer (0) die standardmäßige Uplinkschnittstelle des Routers.' noise = 'Rausch' power = 'Leistung' diff --git a/i18n/german/luasrc/i18n/admin-core.de.xml b/i18n/german/luasrc/i18n/admin-core.de.xml index 1451fc654..fc7da5186 100644 --- a/i18n/german/luasrc/i18n/admin-core.de.xml +++ b/i18n/german/luasrc/i18n/admin-core.de.xml @@ -208,6 +208,19 @@ Keep-Alive Anzahl fehlgeschlagener Verbindungstests nach der automatisch neu verbunden wird PPTP-Server +Modemgerät +Geräteknoten des Modems, z.B. /dev/ttyUSB0 +Standardroute ersetzen +Lässt pppd die aktuelle Standardroute ersetzen und über die PPP Schnittstelle leiten +DNS der Gegenstelle nutzen +Konfiguriert den lokalen DNS-Server so, dass er die von der Gegenstelle angekündigten Nameserver-Adressen nutzt +IPv6 für die PPP-Verbindung aktivieren +Verbindungs-Script +Lässt pppd das angegebene Script nach dem Aufbau der PPP Verbindung abarbeiten +Trennuns-Script +Lässt pppd das angegebene Script vor dem Trennen der PPP Verbindung abarbeiten +Weitere pppd Optionen +Hier können zusätzliche Kommandozeilenargumente für pppd angegeben werden Die zu einem VLAN gehörenden Schnittstellen werden durch Leerzeichen getrennt. Die Schnittstelle mit der höchsten Nummer (meistens 5) bildet in der Regel die Verbindung zur internen Netzschnittstelle des Routers. Bei Geräten mit 5 Schnittstellen ist in der Regel die Schnittstelle mit der niedrigsten Nummer (0) die standardmäßige Uplinkschnittstelle des Routers. Rausch diff --git a/libs/uvl/luasrc/uvl/datatypes.lua b/libs/uvl/luasrc/uvl/datatypes.lua index fc37fa3c6..615e2946d 100644 --- a/libs/uvl/luasrc/uvl/datatypes.lua +++ b/libs/uvl/luasrc/uvl/datatypes.lua @@ -169,3 +169,19 @@ function file( val, seen ) return false end + +function device( val, seen ) + local s = fs.stat( val ) + seen = seen or { } + + if s and not seen[s.ino] then + seen[s.ino] = true + if s.type == "character device" or s.type == "block device" then + return true + elseif s.type == "link" then + return device( fs.readlink(val), seen ) + end + end + + return false +end diff --git a/modules/admin-core/root/lib/uci/schema/default/network b/modules/admin-core/root/lib/uci/schema/default/network index 57d02a63e..c0f358742 100644 --- a/modules/admin-core/root/lib/uci/schema/default/network +++ b/modules/admin-core/root/lib/uci/schema/default/network @@ -10,11 +10,12 @@ config section list depends 'proto=static, ipaddr, netmask' list depends 'proto=static, ip6addr' list depends 'proto=pppoe, username, password' + list depends 'proto=ppp, device' list depends 'proto=pptp, username, password, server' list depends 'proto=dhcp' list depends 'proto=none' - option named true - option required true + option named 'true' + option required 'true' config variable option name 'ifname' @@ -74,16 +75,17 @@ config variable option title 'DNS server (IPv4 or IPv6)' option section 'network.interface' option datatype 'ipaddr' - option multival true + option multival 'true' config variable option name 'keepalive' option title 'keep-alive' - option descriptions 'Number of connection failures before reconnect' + option description 'Number of connection failures before reconnect' option section 'network.interface' option datatype 'uint' - list depends proto=pppoe - list depends proto=pptp + list depends 'proto=pppoe' + list depends 'proto=pptp' + list depends 'proto=ppp' config variable option name 'demand' @@ -91,38 +93,90 @@ config variable option description 'Number of seconds to wait before closing the connection due to inactivity' option section 'network.interface' option datatype 'uint' - list depends proto=pppoe - list depends proto=pptp + list depends 'proto=pppoe' + list depends 'proto=pptp' + list depends 'proto=ppp' config variable option name 'username' option title 'Username' option section 'network.interface' option datatype 'string' - list depends proto=pppoe - list depends proto=pptp + list depends 'proto=pppoe' + list depends 'proto=pptp' + list depends 'proto=ppp' config variable option name 'password' option title 'Password' option section 'network.interface' option datatype 'string' - list depends proto=pppoe - list depends proto=pptp + list depends 'proto=pppoe' + list depends 'proto=pptp' + list depends 'proto=ppp' config variable option name 'server' option title 'PPTP server' option section 'network.interface' - option datatype 'ipaddr' - list depends proto=pptp + option datatype 'host' + list depends 'proto=pptp' + +config variable + option name 'device' + option title 'Modem device' + option section 'network.interface' + option datatype 'device' + list depends 'proto=ppp' + +config variable + option name 'defaultroute' + option title 'Replace default route' + option section 'network.interface' + option datatype 'boolean' + list depends 'proto=ppp' + +config variable + option name 'peerdns' + option title 'Use peer DNS' + option section 'network.interface' + option datatype 'boolean' + list depends 'proto=ppp' + +config variable + option name 'ipv6' + option title 'Enable IPv6 on PPP link' + option section 'network.interface' + option datatype 'boolean' + list depends 'proto=ppp' + +config variable + option name 'connect' + option title 'PPP connect script' + option section 'network.interface' + option datatype 'file' + list depends 'proto=ppp' + +config variable + option name 'disconnect' + option title 'PPP disconnect script' + option section 'network.interface' + option datatype 'file' + list depends 'proto=ppp' + +config variable + option name 'pppd_options' + option title 'Additional PPP daemon options' + option section 'network.interface' + option datatype 'string' + list depends 'proto=ppp' config variable option name 'proto' option title 'Protocol' option section 'network.interface' option type 'enum' - option required true + option required 'true' config enum option variable 'network.interface.proto' @@ -133,7 +187,7 @@ config enum option variable 'network.interface.proto' option value 'dhcp' option title 'Retrieve IP address via DHCP' - option default true + option default 'true' config enum option variable 'network.interface.proto' @@ -148,7 +202,12 @@ config enum config enum option variable 'network.interface.proto' option value 'pppoe' - option title 'Retrieve IP address via PPPoE' + option title 'Interface is a PPPoE connection' + +config enum + option variable 'network.interface.proto' + option value 'ppp' + option title 'Interface is a PPP connection' config variable option name 'type' @@ -169,14 +228,14 @@ config section option package 'network' list depends 'proto=static, ipaddr, netmask' list depends 'proto=static, ip6addr' - option named true + option named 'true' config variable option name 'interface' option title 'Parent interface' option section 'network.alias' option valueof 'network.interface' - option required true + option required 'true' config variable option name 'ipaddr' @@ -225,7 +284,7 @@ config variable option title 'Protocol' option section 'network.alias' option type 'enum' - option required true + option required 'true' config enum option variable 'network.alias.proto' @@ -244,14 +303,14 @@ config variable option title 'Interface' option section 'network.route' option valueof 'network.interface' - option required true + option required 'true' config variable option name 'target' option title 'Target IPv4 host or network' option section 'network.route' option datatype 'ip4addr' - option required true + option required 'true' config variable option name 'netmask' @@ -264,7 +323,7 @@ config variable option title 'IPv4 gateway' option section 'network.route' option datatype 'ip4addr' - option required true + option required 'true' @@ -272,6 +331,6 @@ config section option name 'switch' option title 'Section switch' option package 'network' - option named true - option dynamic true - option required true + option named 'true' + option dynamic 'true' + option required 'true' diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua index d06ad90c9..a832f39f4 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua @@ -27,6 +27,7 @@ p = s:option(ListValue, "proto", translate("protocol")) p:value("static", translate("static")) p:value("dhcp", "DHCP") p:value("pppoe", "PPPoE") +p:value("ppp", "PPP") p:value("pptp", "PPTP") p.default = "static" @@ -43,11 +44,11 @@ for i,d in ipairs(luci.sys.net.devices()) do end local zones = luci.tools.webadmin.network_get_zones(arg[1]) -if zones then +if zones then if #zones == 0 then m:chain("firewall") - - fwzone = s:option(Value, "_fwzone", + + fwzone = s:option(Value, "_fwzone", translate("network_interface_fwzone"), translate("network_interface_fwzone_desc")) fwzone.rmempty = true @@ -59,11 +60,11 @@ if zones then fwzone:value(section.name) end ) - - function fwzone.write(self, section, value) + + function fwzone.write(self, section, value) local zone = luci.tools.webadmin.firewall_find_zone(value) local stat - + if not zone then stat = m.uci:section("firewall", "zone", nil, { name = value, @@ -74,7 +75,7 @@ if zones then net = (net or value) .. " " .. section stat = m.uci:set("firewall", zone, "network", net) end - + if stat then self.render = function() end end @@ -134,11 +135,13 @@ user = s:option(Value, "username", translate("username")) user.rmempty = true user:depends("proto", "pptp") user:depends("proto", "pppoe") +user:depends("proto", "ppp") pass = s:option(Value, "password", translate("password")) pass.rmempty = true pass:depends("proto", "pptp") pass:depends("proto", "pppoe") +pass:depends("proto", "ppp") ka = s:option(Value, "keepalive", translate("network_interface_keepalive"), @@ -147,16 +150,59 @@ ka = s:option(Value, "keepalive", ka.rmempty = true ka:depends("proto", "pptp") ka:depends("proto", "pppoe") +ka:depends("proto", "ppp") -demand = s:option(Value, "demand", +demand = s:option(Value, "demand", translate("network_interface_demand"), translate("network_interface_demand_desc") ) demand.rmempty = true demand:depends("proto", "pptp") demand:depends("proto", "pppoe") +demand:depends("proto", "ppp") +device = s:option(Value, "device", + translate("network_interface_device"), + translate("network_interface_device_desc") +) +device.rmempty = true +device:depends("proto", "ppp") + +defaultroute = s:option(Flag, "defaultroute", + translate("network_interface_defaultroute"), + translate("network_interface_defaultroute_desc") +) +defaultroute:depends("proto", "ppp") +peerdns = s:option(Flag, "peerdns", + translate("network_interface_peerdns"), + translate("network_interface_peerdns_desc") +) +peerdns:depends("proto", "ppp") + +ipv6 = s:option(Flag, "ipv6", translate("network_interface_ipv6") ) +ipv6:depends("proto", "ppp") + +connect = s:option(Value, "connect", + translate("network_interface_connect"), + translate("network_interface_connect_desc") +) +connect.optional = true +connect:depends("proto", "ppp") + +disconnect = s:option(Value, "disconnect", + translate("network_interface_disconnect"), + translate("network_interface_disconnect_desc") +) +disconnect.optional = true +disconnect:depends("proto", "ppp") + +pppd_options = s:option(Value, "pppd_options", + translate("network_interface_pppd_options"), + translate("network_interface_pppd_options_desc") +) +pppd_options.optional = true +pppd_options:depends("proto", "ppp") s2 = m:section(TypedSection, "alias", translate("aliases")) -- 2.11.0