2 LuCI - Lua Configuration Interface
4 Copyright 2009 Steven Barth <steven@midlink.org>
5 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 local fs = require "nixio.fs"
17 local nw = require "luci.model.network"
19 local has_ipv6 = nw:has_ipv6()
20 local has_pptp = fs.access("/usr/sbin/pptp")
21 local has_pppd = fs.access("/usr/sbin/pppd")
22 local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")()
23 local has_pppoa = fs.glob("/usr/lib/pppd/*/pppoatm.so")()
26 m = Map("network", "Configure Ethernet Adapter")
29 s = m:section(NamedSection, "wan", "interface")
32 s:tab("general", translate("General Settings"))
33 s:tab("expert", translate("Expert Settings"))
35 p = s:taboption("general", ListValue, "proto", "Connection Type")
36 p.override_scheme = true
38 p:value("dhcp", "Cable / Ethernet / DHCP")
39 if has_pppoe then p:value("pppoe", "DSL / PPPoE") end
40 if has_pppoa then p:value("pppoa", "PPPoA") end
41 if has_pptp then p:value("pptp", "PPTP") end
42 p:value("static", "Static Ethernet")
46 ipaddr = s:taboption("general", Value, "ipaddr", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
48 ipaddr:depends("proto", "static")
50 nm = s:taboption("general", Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"))
52 nm:depends("proto", "static")
53 nm:value("255.255.255.0")
54 nm:value("255.255.0.0")
57 gw = s:taboption("general", Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
58 gw:depends("proto", "static")
61 bcast = s:taboption("expert", Value, "bcast", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Broadcast"))
62 bcast:depends("proto", "static")
65 ip6addr = s:taboption("expert", Value, "ip6addr", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address"), translate("<abbr title=\"Classless Inter-Domain Routing\">CIDR</abbr>-Notation: address/prefix"))
66 ip6addr:depends("proto", "static")
68 ip6gw = s:taboption("expert", Value, "ip6gw", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
69 ip6gw:depends("proto", "static")
72 dns = s:taboption("expert", Value, "dns", translate("<abbr title=\"Domain Name System\">DNS</abbr>-Server"))
73 dns:depends("peerdns", "")
75 mtu = s:taboption("expert", Value, "mtu", "MTU")
78 mac = s:taboption("expert", Value, "macaddr", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
81 srv = s:taboption("general", Value, "server", translate("<abbr title=\"Point-to-Point Tunneling Protocol\">PPTP</abbr>-Server"))
82 srv:depends("proto", "pptp")
85 if has_pppd or has_pppoe or has_pppoa or has_pptp then
86 user = s:taboption("general", Value, "username", translate("Username"))
88 user:depends("proto", "pptp")
89 user:depends("proto", "pppoe")
90 user:depends("proto", "pppoa")
92 pass = s:taboption("general", Value, "password", translate("Password"))
95 pass:depends("proto", "pptp")
96 pass:depends("proto", "pppoe")
97 pass:depends("proto", "pppoa")
99 ka = s:taboption("expert", Value, "keepalive",
100 translate("Keep-Alive"),
101 translate("Number of failed connection tests to initiate automatic reconnect")
104 ka:depends("proto", "pptp")
105 ka:depends("proto", "pppoe")
106 ka:depends("proto", "pppoa")
108 demand = s:taboption("expert", Value, "demand",
109 translate("Automatic Disconnect"),
110 translate("Time (in seconds) after which an unused connection will be closed")
112 demand:depends("proto", "pptp")
113 demand:depends("proto", "pppoe")
114 demand:depends("proto", "pppoa")
118 encaps = s:taboption("expert", ListValue, "encaps", translate("PPPoA Encapsulation"))
119 encaps:depends("proto", "pppoa")
120 encaps:value("", translate("-- Please choose --"))
121 encaps:value("vc", "VC")
122 encaps:value("llc", "LLC")
124 vpi = s:taboption("expert", Value, "vpi", "VPI")
125 vpi:depends("proto", "pppoa")
127 vci = s:taboption("expert", Value, "vci", "VCI")
128 vci:depends("proto", "pppoa")
131 if has_pptp or has_pppd or has_pppoe or has_pppoa or has_3g then
133 defaultroute = s:taboption("expert", Flag, "defaultroute",
134 translate("Replace default route"),
135 translate("Let pppd replace the current default route to use the PPP interface after successful connect")
137 defaultroute:depends("proto", "pppoa")
138 defaultroute:depends("proto", "pppoe")
139 defaultroute:depends("proto", "pptp")
140 defaultroute.rmempty = false
141 function defaultroute.cfgvalue(...)
142 return ( AbstractValue.cfgvalue(...) or '1' )
145 peerdns = s:taboption("expert", Flag, "peerdns",
146 translate("Use peer DNS"),
147 translate("Configure the local DNS server to use the name servers adverticed by the PPP peer")
149 peerdns:depends("proto", "pppoa")
150 peerdns:depends("proto", "pppoe")
151 peerdns:depends("proto", "pptp")
152 peerdns.rmempty = false
153 peerdns.default = "1"
156 ipv6 = s:taboption("expert", Flag, "ipv6", translate("Enable IPv6 on PPP link") )
157 ipv6:depends("proto", "pppoa")
158 ipv6:depends("proto", "pppoe")
159 ipv6:depends("proto", "pptp")