Merge pull request #1309 from dibdot/dnscrypt-proxy
[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("", translate("auto"))
42         xfer_mode:value("atm", translate("ATM (Asynchronous Transfer Mode)"))
43         xfer_mode:value("ptm", translate("PTM/EFM (Packet Transfer Mode)"))
44
45         line_mode = dsl:option(ListValue, "line_mode", translate("DSL line mode"))
46         line_mode:value("", translate("auto"))
47         line_mode:value("adsl", translate("ADSL"))
48         line_mode:value("vdsl", translate("VDSL"))
49
50         firmware = dsl:option(Value, "firmware", translate("Firmware File"))
51
52         m.pageaction = true
53 end
54
55 -- Show ATM bridge section if we have the capabilities
56 if fs.access("/usr/sbin/br2684ctl") then
57         atm = m:section(TypedSection, "atm-bridge", translate("ATM Bridges"),
58                 translate("ATM bridges expose encapsulated ethernet in AAL5 " ..
59                         "connections as virtual Linux network interfaces which can " ..
60                         "be used in conjunction with DHCP or PPP to dial into the " ..
61                         "provider network."))
62
63         atm.addremove = true
64         atm.anonymous = true
65
66         atm.create = function(self, section)
67                 local sid = TypedSection.create(self, section)
68                 local max_unit = -1
69
70                 m.uci:foreach("network", "atm-bridge",
71                         function(s)
72                                 local u = tonumber(s.unit)
73                                 if u ~= nil and u > max_unit then
74                                         max_unit = u
75                                 end
76                         end)
77
78                 m.uci:set("network", sid, "unit", max_unit + 1)
79                 m.uci:set("network", sid, "atmdev", 0)
80                 m.uci:set("network", sid, "encaps", "llc")
81                 m.uci:set("network", sid, "payload", "bridged")
82                 m.uci:set("network", sid, "vci", 35)
83                 m.uci:set("network", sid, "vpi", 8)
84
85                 return sid
86         end
87
88         atm:tab("general", translate("General Setup"))
89         atm:tab("advanced", translate("Advanced Settings"))
90
91         vci    = atm:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)"))
92         vpi    = atm:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)"))
93         encaps = atm:taboption("general", ListValue, "encaps", translate("Encapsulation mode"))
94         encaps:value("llc", translate("LLC"))
95         encaps:value("vc", translate("VC-Mux"))
96
97         atmdev  = atm:taboption("advanced", Value, "atmdev", translate("ATM device number"))
98         unit    = atm:taboption("advanced", Value, "unit", translate("Bridge unit number"))
99         payload = atm:taboption("advanced", ListValue, "payload", translate("Forwarding mode"))
100         payload:value("bridged", translate("bridged"))
101         payload:value("routed", translate("routed"))
102         m.pageaction = true
103 end
104
105 local network = require "luci.model.network"
106 if network:has_ipv6() then
107         local s = m:section(NamedSection, "globals", "globals", translate("Global network options"))
108         local o = s:option(Value, "ula_prefix", translate("IPv6 ULA-Prefix"))
109         o.datatype = "ip6addr"
110         o.rmempty = true
111         m.pageaction = true
112 end
113
114
115 return m