727526b784a6b37eb5608370da0eaa38551ad33c
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / network / lan1.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2009 Steven Barth <steven@midlink.org>
5 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
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 nw = require "luci.model.network"
17 local fw = require "luci.model.firewall"
18
19 local has_ipv6 = nw:has_ipv6()
20
21 m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
22 m:chain("firewall")
23
24 nw.init(m.uci)
25 fw.init(m.uci)
26
27 s = m:section(NamedSection, "lan", "interface")
28 s.addremove = false
29
30 s:tab("general", translate("niu_general", "General Settings"))
31
32 ipaddr = s:taboption("general", Value, "ipaddr", translate("ipaddress"))
33
34 nm = s:taboption("general", Value, "netmask", translate("netmask"))
35 nm:value("255.255.255.0")
36 nm:value("255.255.0.0")
37 nm:value("255.0.0.0")
38
39
40
41 s:tab("expert", translate("niu_expert", "Expert Settings"))
42
43 mac = s:taboption("expert", Value, "macaddr", translate("macaddress"))
44
45 mtu = s:taboption("expert", Value, "mtu", "MTU")
46 mtu.isinteger = true
47
48 dns = s:taboption("expert", Value, "dns", translate("dnsserver"))
49 dns:depends("peerdns", "")
50
51
52 gw = s:taboption("expert", Value, "gateway", translate("gateway"))
53 bcast = s:taboption("expert", Value, "bcast", translate("broadcast"))
54
55
56 if has_ipv6 then
57         ip6addr = s:taboption("expert", Value, "ip6addr", translate("ip6address"), translate("cidr6"))
58         ip6gw = s:taboption("expert", Value, "ip6gw", translate("gateway6"))
59 end
60
61
62 br = s:taboption("expert", Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
63 br.enabled = "bridge"
64 br.rmempty = true
65
66 stp = s:taboption("expert", Flag, "stp", translate("a_n_i_stp"),
67         translate("a_n_i_stp1", "Enables the Spanning Tree Protocol on this bridge"))
68 stp:depends("type", "1")
69 stp.rmempty = true
70
71 ifname_single = s:taboption("expert", Value, "ifname_single", translate("interface"))
72 ifname_single.template = "cbi/network_ifacelist"
73 ifname_single.widget = "radio"
74 ifname_single.nobridges = true
75 ifname_single.rmempty = true
76 ifname_single:depends("type", "")
77
78 function ifname_single.cfgvalue(self, s)
79         return self.map.uci:get("network", s, "ifname")
80 end
81
82 function ifname_single.write(self, s, val)
83         local n = nw:get_network(s)
84         if n then n:ifname(val) end
85 end
86
87
88 ifname_multi = s:taboption("expert", MultiValue, "ifname_multi", translate("interface"))
89 ifname_multi.template = "cbi/network_ifacelist"
90 ifname_multi.nobridges = true
91 ifname_multi.widget = "checkbox"
92 ifname_multi:depends("type", "1")
93 ifname_multi.cfgvalue = ifname_single.cfgvalue
94 ifname_multi.write = ifname_single.write
95
96 for _, d in ipairs(nw:get_interfaces()) do
97         if not d:is_bridge() then
98                 ifname_single:value(d:name())
99                 ifname_multi:value(d:name())
100         end
101 end
102
103
104
105
106 return m