7b810b8f441ad53db56b2e9b61dbf0a6e4bc31ab
[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", "Configure Local Network", "These settings affect the devices in your local network. "..
21 "Usually you do not need to change anything here for your router to work correctly.")
22
23 nw.init(m.uci)
24
25 s = m:section(NamedSection, "lan", "interface", "Network Settings")
26 s.addremove = false
27
28 s:tab("general", translate("General Settings"))
29
30 ipaddr = s:taboption("general", Value, "ipaddr", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
31
32 nm = s:taboption("general", Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"))
33 nm:value("255.255.255.0")
34 nm:value("255.255.0.0")
35 nm:value("255.0.0.0")
36
37
38
39 s:tab("expert", translate("Expert Settings"))
40
41 mac = s:taboption("expert", Value, "macaddr", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
42
43 mtu = s:taboption("expert", Value, "mtu", "MTU")
44 mtu.isinteger = true
45
46 dns = s:taboption("expert", Value, "dns", translate("<abbr title=\"Domain Name System\">DNS</abbr>-Server"))
47 dns:depends("peerdns", "")
48
49
50 gw = s:taboption("expert", Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
51 bcast = s:taboption("expert", Value, "bcast", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Broadcast"))
52
53
54 if has_ipv6 then
55         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"))
56         ip6gw = s:taboption("expert", Value, "ip6gw", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
57 end
58
59
60 stp = s:taboption("expert", Flag, "stp", translate("Enable <abbr title=\"Spanning Tree Protocol\">STP</abbr>"),
61         translate("Enables the Spanning Tree Protocol on this bridge"))
62
63 ifname_multi = s:taboption("expert", MultiValue, "ifname_multi", translate("Interface"))
64 ifname_multi.template = "cbi/network_ifacelist"
65 ifname_multi.nobridges = true
66 ifname_multi.widget = "checkbox"
67
68 function ifname_multi.cfgvalue(self, s)
69         return self.map.uci:get("network", s, "ifname")
70 end
71
72 function ifname_multi.write(self, s, val)
73         local n = nw:get_network(s)
74         if n then n:ifname(val) end
75 end
76
77 for _, d in ipairs(nw:get_interfaces()) do
78         if not d:is_bridge() then
79                 ifname_multi:value(d:name())
80         end
81 end
82
83
84 m2 = Map("dhcp")
85
86 s = m2:section(TypedSection, "dhcp", "DHCP")
87 s.anonymous = true
88 s.addremove = false
89 s.dynamic = false
90
91 s:tab("general", translate("General Settings"))
92
93 s:depends("interface", "lan")
94
95 enable = s:taboption("general", ListValue, "ignore", "Automatic address assignment for network devices", "")
96 enable:value(0, translate("enable"))
97 enable:value(1, translate("disable"))
98
99
100 s:tab("expert", translate("Expert Settings"))
101 start = s:taboption("expert", Value, "start", translate("First leased address"))
102 limit = s:taboption("expert", Value, "limit", translate("Number of leased addresses"), "")
103 time = s:taboption("expert", Value, "leasetime", "Lease Time")
104 local dd = s:taboption("expert", Flag, "dynamicdhcp", "Also generate addresses for unknown devices")
105 dd.rmempty = false
106 dd.default = "1"
107
108
109 return m, m2