f2984b5810edf1dfe9c142a4a966c50b34f26a41
[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.pageaction = false
20 m:section(SimpleSection).template = "admin_network/iface_overview"
21
22 -- Show ATM bridge section if we have the capabilities
23 if fs.access("/usr/sbin/br2684ctl") then
24         atm = m:section(TypedSection, "atm-bridge", translate("ATM Bridges"),
25                 translate("ATM bridges expose encapsulated ethernet in AAL5 " ..
26                         "connections as virtual Linux network interfaces which can " ..
27                         "be used in conjunction with DHCP or PPP to dial into the " ..
28                         "provider network."))
29
30         atm.addremove = true
31         atm.anonymous = true
32
33         atm.create = function(self, section)
34                 local sid = TypedSection.create(self, section)
35                 local max_unit = -1
36
37                 m.uci:foreach("network", "atm-bridge",
38                         function(s)
39                                 local u = tonumber(s.unit)
40                                 if u ~= nil and u > max_unit then
41                                         max_unit = u
42                                 end
43                         end)
44
45                 m.uci:set("network", sid, "unit", max_unit + 1)
46                 m.uci:set("network", sid, "atmdev", 0)
47                 m.uci:set("network", sid, "encaps", "llc")
48                 m.uci:set("network", sid, "payload", "bridged")
49                 m.uci:set("network", sid, "vci", 35)
50                 m.uci:set("network", sid, "vpi", 8)
51
52                 return sid
53         end
54
55         atm:tab("general", translate("General Setup"))
56         atm:tab("advanced", translate("Advanced Settings"))
57
58         vci    = atm:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)"))
59         vpi    = atm:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)"))
60         encaps = atm:taboption("general", ListValue, "encaps", translate("Encapsulation mode"))
61         encaps:value("llc", translate("LLC"))
62         encaps:value("vc", translate("VC-Mux"))
63
64         atmdev  = atm:taboption("advanced", Value, "atmdev", translate("ATM device number"))
65         unit    = atm:taboption("advanced", Value, "unit", translate("Bridge unit number"))
66         payload = atm:taboption("advanced", ListValue, "payload", translate("Forwarding mode"))
67         payload:value("bridged", translate("bridged"))
68         payload:value("routed", translate("routed"))
69         m.pageaction = true
70 end
71
72 local network = require "luci.model.network"
73 if network:has_ipv6() then
74         local s = m:section(NamedSection, "globals", "globals", translate("Global network options"))
75         local o = s:option(Value, "ula_prefix", translate("IPv6 ULA-Prefix"))
76         o.datatype = "ip6addr"
77         o.rmempty = true
78         m.pageaction = true
79 end
80
81
82 return m