NIU: More LAN settings, initial WAN
[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
18 local has_ipv6 = nw:has_ipv6()
19
20 m = Map("network", translate("m_n_lan"))
21
22 nw.init(m.uci)
23
24 s = m:section(NamedSection, "lan", "interface")
25 s.addremove = false
26
27 s:tab("general", translate("niu_general", "General Settings"))
28
29 ipaddr = s:taboption("general", Value, "ipaddr", translate("ipaddress"))
30
31 nm = s:taboption("general", Value, "netmask", translate("netmask"))
32 nm:value("255.255.255.0")
33 nm:value("255.255.0.0")
34 nm:value("255.0.0.0")
35
36
37
38 s:tab("expert", translate("niu_expert", "Expert Settings"))
39
40 mac = s:taboption("expert", Value, "macaddr", translate("macaddress"))
41
42 mtu = s:taboption("expert", Value, "mtu", "MTU")
43 mtu.isinteger = true
44
45 dns = s:taboption("expert", Value, "dns", translate("dnsserver"))
46 dns:depends("peerdns", "")
47
48
49 gw = s:taboption("expert", Value, "gateway", translate("gateway"))
50 bcast = s:taboption("expert", Value, "bcast", translate("broadcast"))
51
52
53 if has_ipv6 then
54         ip6addr = s:taboption("expert", Value, "ip6addr", translate("ip6address"), translate("cidr6"))
55         ip6gw = s:taboption("expert", Value, "ip6gw", translate("gateway6"))
56 end
57
58
59 stp = s:taboption("expert", Flag, "stp", translate("a_n_i_stp"),
60         translate("a_n_i_stp1", "Enables the Spanning Tree Protocol on this bridge"))
61
62 ifname_multi = s:taboption("expert", MultiValue, "ifname_multi", translate("interface"))
63 ifname_multi.template = "cbi/network_ifacelist"
64 ifname_multi.nobridges = true
65 ifname_multi.widget = "checkbox"
66
67 function ifname_multi.cfgvalue(self, s)
68         return self.map.uci:get("network", s, "ifname")
69 end
70
71 function ifname_multi.write(self, s, val)
72         local n = nw:get_network(s)
73         if n then n:ifname(val) end
74 end
75
76 for _, d in ipairs(nw:get_interfaces()) do
77         if not d:is_bridge() then
78                 ifname_multi:value(d:name())
79         end
80 end
81
82
83 m2 = Map("dhcp", "DHCP")
84
85 s = m2:section(TypedSection, "dhcp", "DHCP-Server")
86 s.anonymous = true
87 s.addremove = false
88 s.dynamic = false
89
90 s:tab("general", translate("niu_general", "General Settings"))
91
92 s:depends("interface", "lan")
93
94 enable = s:taboption("general", ListValue, "ignore", translate("enable"), "")
95 enable:value(0, translate("enable"))
96 enable:value(1, translate("disable"))
97
98
99 s:tab("expert", translate("niu_expert", "Expert Settings"))
100 start = s:taboption("expert", Value, "start", translate("m_n_d_firstaddress"))
101 limit = s:taboption("expert", Value, "limit", translate("m_n_d_numleases"), "")
102 time = s:taboption("expert", Value, "leasetime")
103
104
105 return m, m2