NIU: More restructuring, Add: change password, hostname
[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", "Local Network")
21
22 nw.init(m.uci)
23
24 s = m:section(NamedSection, "lan", "interface", "Network Settings")
25 s.addremove = false
26
27 s:tab("general", translate("General Settings"))
28
29 ipaddr = s:taboption("general", Value, "ipaddr", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
30
31 nm = s:taboption("general", Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-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("Expert Settings"))
39
40 mac = s:taboption("expert", Value, "macaddr", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
41
42 mtu = s:taboption("expert", Value, "mtu", "MTU")
43 mtu.isinteger = true
44
45 dns = s:taboption("expert", Value, "dns", translate("<abbr title=\"Domain Name System\">DNS</abbr>-Server"))
46 dns:depends("peerdns", "")
47
48
49 gw = s:taboption("expert", Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
50 bcast = s:taboption("expert", Value, "bcast", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Broadcast"))
51
52
53 if has_ipv6 then
54 ip6addr = s:taboption("expert", Value, "ip6addr", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address"), translate("<abbr title=\"Classless Inter-Domain Routing\">CIDR</abbr>-Notation: address/prefix"))
55 ip6gw = s:taboption("expert", Value, "ip6gw", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
56 end
57
58
59 stp = s:taboption("expert", Flag, "stp", translate("Enable <abbr title=\"Spanning Tree Protocol\">STP</abbr>"),
60 translate("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")
84
85 s = m2:section(TypedSection, "dhcp", "DHCP")
86 s.anonymous = true
87 s.addremove = false
88 s.dynamic = false
89
90 s:tab("general", translate("General Settings"))
91
92 s:depends("interface", "lan")
93
94 enable = s:taboption("general", ListValue, "ignore", "Automatic address assignment for network devices", "")
95 enable:value(0, translate("enable"))
96 enable:value(1, translate("disable"))
97
98
99 s:tab("expert", translate("Expert Settings"))
100 start = s:taboption("expert", Value, "start", translate("First leased address"))
101 limit = s:taboption("expert", Value, "limit", translate("Number of leased addresses"), "")
102 time = s:taboption("expert", Value, "leasetime", "Lease Time")
103
104
105 return m, m2