luci-mod-admin-full: add dsl configuration
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_network / network.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 local fs = require "nixio.fs"
6
7 m = Map("network", translate("Interfaces"))
8 m.pageaction = false
9 m:section(SimpleSection).template = "admin_network/iface_overview"
10
11 if fs.access("/etc/init.d/dsl_control") then
12         dsl = m:section(TypedSection, "dsl", translate("DSL"))
13
14         dsl.anonymous = true
15
16         annex = dsl:option(ListValue, "annex", translate("Annex"))
17         annex:value("a", translate("Annex A + L + M (all)"))
18         annex:value("b", translate("Annex B (all)"))
19         annex:value("j", translate("Annex J (all)"))
20         annex:value("m", translate("Annex M (all)"))
21         annex:value("bdmt", translate("Annex B G.992.1"))
22         annex:value("b2", translate("Annex B G.992.3"))
23         annex:value("b2p", translate("Annex B G.992.5"))
24         annex:value("at1", translate("ANSI T1.413"))
25         annex:value("admt", translate("Annex A G.992.1"))
26         annex:value("alite", translate("Annex A G.992.2"))
27         annex:value("a2", translate("Annex A G.992.3"))
28         annex:value("a2p", translate("Annex A G.992.5"))
29         annex:value("l", translate("Annex L G.992.3 POTS 1"))
30         annex:value("m2", translate("Annex M G.992.3"))
31         annex:value("m2p", translate("Annex M G.992.5"))
32
33         tone = dsl:option(ListValue, "tone", translate("Tone"))
34         tone:value("", translate("auto"))
35         tone:value("a", translate("A43C + J43 + A43"))
36         tone:value("av", translate("A43C + J43 + A43 + V43"))
37         tone:value("b", translate("B43 + B43C"))
38         tone:value("bv", translate("B43 + B43C + V43"))
39
40         xfer_mode = dsl:option(ListValue, "xfer_mode", translate("Encapsulation mode"))
41         xfer_mode:value("atm", translate("ATM (Asynchronous Transfer Mode)"))
42         xfer_mode:value("ptm", translate("PTM/EFM (Packet Transfer Mode)"))
43
44         line_mode = dsl:option(ListValue, "line_mode", translate("DSL line mode"))
45         line_mode:value("", translate("auto"))
46         line_mode:value("adsl", translate("ADSL"))
47         line_mode:value("vdsl", translate("VDSL"))
48
49         firmware = dsl:option(Value, "firmware", translate("Firmware File"))
50
51         m.pageaction = true
52 end
53
54 -- Show ATM bridge section if we have the capabilities
55 if fs.access("/usr/sbin/br2684ctl") then
56         atm = m:section(TypedSection, "atm-bridge", translate("ATM Bridges"),
57                 translate("ATM bridges expose encapsulated ethernet in AAL5 " ..
58                         "connections as virtual Linux network interfaces which can " ..
59                         "be used in conjunction with DHCP or PPP to dial into the " ..
60                         "provider network."))
61
62         atm.addremove = true
63         atm.anonymous = true
64
65         atm.create = function(self, section)
66                 local sid = TypedSection.create(self, section)
67                 local max_unit = -1
68
69                 m.uci:foreach("network", "atm-bridge",
70                         function(s)
71                                 local u = tonumber(s.unit)
72                                 if u ~= nil and u > max_unit then
73                                         max_unit = u
74                                 end
75                         end)
76
77                 m.uci:set("network", sid, "unit", max_unit + 1)
78                 m.uci:set("network", sid, "atmdev", 0)
79                 m.uci:set("network", sid, "encaps", "llc")
80                 m.uci:set("network", sid, "payload", "bridged")
81                 m.uci:set("network", sid, "vci", 35)
82                 m.uci:set("network", sid, "vpi", 8)
83
84                 return sid
85         end
86
87         atm:tab("general", translate("General Setup"))
88         atm:tab("advanced", translate("Advanced Settings"))
89
90         vci    = atm:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)"))
91         vpi    = atm:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)"))
92         encaps = atm:taboption("general", ListValue, "encaps", translate("Encapsulation mode"))
93         encaps:value("llc", translate("LLC"))
94         encaps:value("vc", translate("VC-Mux"))
95
96         atmdev  = atm:taboption("advanced", Value, "atmdev", translate("ATM device number"))
97         unit    = atm:taboption("advanced", Value, "unit", translate("Bridge unit number"))
98         payload = atm:taboption("advanced", ListValue, "payload", translate("Forwarding mode"))
99         payload:value("bridged", translate("bridged"))
100         payload:value("routed", translate("routed"))
101         m.pageaction = true
102 end
103
104 local network = require "luci.model.network"
105 if network:has_ipv6() then
106         local s = m:section(NamedSection, "globals", "globals", translate("Global network options"))
107         local o = s:option(Value, "ula_prefix", translate("IPv6 ULA-Prefix"))
108         o.datatype = "ip6addr"
109         o.rmempty = true
110         m.pageaction = true
111 end
112
113
114 return m