423b4dfbe8036e1f823cc7d51cc5d56db9799990
[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 niulib = require "luci.niulib"
17 local fs = require "nixio.fs"
18 local has_ipv6 = fs.access("/proc/net/ipv6_route")
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 s = m:section(NamedSection, "lan", "interface", "Network Settings")
24 s.addremove = false
25
26 s:tab("general", translate("General Settings"))
27
28 ipaddr = s:taboption("general", Value, "ipaddr", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
29 ipaddr.default = "192.168.0.1"
30 ipaddr:depends("proto", "static")
31
32 nm = s:taboption("general", Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"))
33 nm.default = "255.255.255.0"
34 nm:value("255.255.255.0")
35 nm:value("255.255.0.0")
36 nm:value("255.0.0.0")
37 nm:depends("proto", "static")
38
39
40
41 s:tab("expert", translate("Expert Settings"))
42
43 p = s:taboption("expert", ListValue, "proto", translate("Connection Protocol"))
44 p.default = "static"
45 p:value("static", translate("Static Ethernet"))
46 p:value("dhcp", "DHCP")
47
48 mac = s:taboption("expert", Value, "macaddr", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
49
50 mtu = s:taboption("expert", Value, "mtu", "MTU")
51 mtu.isinteger = true
52
53 dns = s:taboption("expert", Value, "dns", translate("<abbr title=\"Domain Name System\">DNS</abbr>-Server"))
54 dns:depends("peerdns", "")
55
56
57 gw = s:taboption("expert", Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
58 gw:depends("proto", "static")
59
60 bcast = s:taboption("expert", Value, "bcast", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Broadcast"))
61 bcast:depends("proto", "static")
62
63
64 if has_ipv6 then
65         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"))
66         ip6addr:depends("proto", "static")
67         ip6gw = s:taboption("expert", Value, "ip6gw", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
68         ip6gw:depends("proto", "static")
69 end
70
71 emerg = s:taboption("expert", Value, "_emergv4", translate("Emergency Access Address"))
72 emerg:depends("proto", "dhcp")
73 emerg.default = "169.254.255.169"
74
75
76 stp = s:taboption("expert", Flag, "stp", translate("Enable <abbr title=\"Spanning Tree Protocol\">STP</abbr>"),
77         translate("Enables the Spanning Tree Protocol on this bridge"))
78
79 ifname_multi = s:taboption("expert", MultiValue, "ifname", translate("Interface"))
80 ifname_multi.widget = "checkbox"
81 for _, eth in ipairs(niulib.eth_get_available("lan")) do
82         ifname_multi:value(eth, translate("Ethernet-Adapter (%s)") % eth)
83 end
84
85
86
87 m2 = Map("dhcp")
88
89 s = m2:section(TypedSection, "dhcp", "DHCP")
90 s.anonymous = true
91 s.addremove = false
92 s.dynamic = false
93
94 s:tab("general", translate("General Settings"))
95
96 s:depends("interface", "lan")
97
98 enable = s:taboption("general", ListValue, "ignore", "Automatic address assignment for network devices", "")
99 enable:value(0, translate("enable"), {["network.lan.proto"] = "static"})
100 enable:value(1, translate("disable"))
101
102
103 s:tab("expert", translate("Expert Settings"))
104 start = s:taboption("expert", Value, "start", translate("First leased address"))
105 start:depends("ignore", "0")
106
107 limit = s:taboption("expert", Value, "limit", translate("Number of leased addresses"), "")
108 limit:depends("ignore", "0")
109
110 time = s:taboption("expert", Value, "leasetime", "Lease Time")
111 time:depends("ignore", "0")
112
113 local dd = s:taboption("expert", Flag, "dynamicdhcp", "Also generate addresses for unknown devices")
114 dd.rmempty = false
115 dd.default = "1"
116 dd:depends("ignore", "0")
117
118
119 return m, m2