modules/admin-full: readd atm bridge config
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / network.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
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
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15
16 local fs = require "nixio.fs"
17
18 m = Map("network", translate("Interfaces"))
19 m:section(SimpleSection).template = "admin_network/iface_overview"
20
21 -- Show ATM bridge section if we have the capabilities
22 if fs.access("/usr/sbin/br2684ctl") then
23         atm = m:section(TypedSection, "atm-bridge", translate("ATM Bridges"),
24                 translate("ATM bridges expose encapsulated ethernet in AAL5 " ..
25                         "connections as virtual Linux network interfaces which can " ..
26                         "be used in conjunction with DHCP or PPP to dial into the " ..
27                         "provider network."))
28
29         atm.addremove = true
30         atm.anonymous = true
31
32         atm.create = function(self, section)
33                 local sid = TypedSection.create(self, section)
34                 local max_unit = -1
35
36                 m.uci:foreach("network", "atm-bridge",
37                         function(s)
38                                 local u = tonumber(s.unit)
39                                 if u ~= nil and u > max_unit then
40                                         max_unit = u
41                                 end
42                         end)
43
44                 m.uci:set("network", sid, "unit", max_unit + 1)
45                 m.uci:set("network", sid, "atmdev", 0)
46                 m.uci:set("network", sid, "encaps", "llc")
47                 m.uci:set("network", sid, "payload", "bridged")
48                 m.uci:set("network", sid, "vci", 35)
49                 m.uci:set("network", sid, "vpi", 8)
50
51                 return sid
52         end
53
54         atm:tab("general", translate("General Setup"))
55         atm:tab("advanced", translate("Advanced Settings"))
56
57         vci    = atm:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)"))
58         vpi    = atm:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)"))
59         encaps = atm:taboption("general", ListValue, "encaps", translate("Encapsulation mode"))
60         encaps:value("llc", translate("LLC"))
61         encaps:value("vc", translate("VC-Mux"))
62
63         atmdev  = atm:taboption("advanced", Value, "atmdev", translate("ATM device number"))
64         unit    = atm:taboption("advanced", Value, "unit", translate("Bridge unit number"))
65         payload = atm:taboption("advanced", ListValue, "payload", translate("Forwarding mode"))
66         payload:value("bridged", translate("bridged"))
67         payload:value("routed", translate("routed"))
68 else
69         m.pageaction = false
70 end
71
72 return m