Cosmetic changes to the terminology in the UI:
[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 bridge = (arg[1] == "bridgelan")
17 local niulib = require "luci.niulib"
18 local fs = require "nixio.fs"
19 local has_ipv6 = fs.access("/proc/net/ipv6_route")
20
21 m = Map("network", translate("Configure Local Network"), bridge and
22 translate([[The wireless network will be connected directly to your local network.
23 Make sure you to assign any address to this device that is in the same subnet
24 of the other devices in your network but that is not already occupied.
25 If you have a DHCP-Server in this network you may also choose DHCP for address configuration.]])
26 or translate("These settings affect the devices in your local network. "..
27 "Usually you do not need to change anything here for this device to work correctly."))
28
29 s = m:section(NamedSection, "lan", "interface", "Network Settings")
30 s.addremove = false
31
32 s:tab("general", translate("General Settings"))
33 s:tab("expert", translate("Expert Settings"))
34
35 p = s:taboption("expert", ListValue, "proto", translate("Address Configuration"))
36 p.default = "static"
37 p:value("static", translate("Static Configuration"))
38 p:value("dhcp", "DHCP")
39
40
41 ipaddr = s:taboption("general", Value, "ipaddr", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
42 ipaddr.default = "192.168.0.1"
43 ipaddr:depends("proto", "static")
44
45 nm = s:taboption("general", Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"))
46 nm.default = "255.255.255.0"
47 nm:value("255.255.255.0")
48 nm:value("255.255.0.0")
49 nm:value("255.0.0.0")
50 nm:depends("proto", "static")
51
52
53 mac = s:taboption("expert", Value, "macaddr", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
54
55 mtu = s:taboption("expert", Value, "mtu", "MTU")
56 mtu.isinteger = true
57
58 dns = s:taboption("expert", Value, "dns", translate("<abbr title=\"Domain Name System\">DNS</abbr>-Server"))
59 dns:depends("peerdns", "")
60
61
62 gw = s:taboption(bridge and "general" or "expert", Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
63 gw:depends("proto", "static")
64
65 bcast = s:taboption("expert", Value, "bcast", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Broadcast"))
66 bcast:depends("proto", "static")
67
68
69 if has_ipv6 then
70         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"))
71         ip6addr:depends("proto", "static")
72         ip6gw = s:taboption("expert", Value, "ip6gw", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
73         ip6gw:depends("proto", "static")
74 end
75
76 emerg = s:taboption("expert", Value, "_emergv4", translate("Emergency Access Address"),
77 translate([[In case the DHCP request fails you will still be able to access this device using given IP 
78 by configuring your computer to an address in the same subnet and netmask 255.255.255.0.]]))
79 emerg:depends("proto", "dhcp")
80 emerg:value("", translate("disable"))
81 emerg.default = "169.254.255.169"
82
83
84 stp = s:taboption("expert", Flag, "stp", translate("Enable <abbr title=\"Spanning Tree Protocol\">STP</abbr>"),
85         translate("Enables the Spanning Tree Protocol on this bridge"))
86
87 ifname_multi = s:taboption("expert", MultiValue, "ifname", translate("Interface"))
88 ifname_multi.widget = "checkbox"
89 for _, eth in ipairs(niulib.eth_get_available("lan")) do
90         ifname_multi:value(eth, translate("Ethernet-Adapter (%s)") % eth)
91 end
92
93
94 m2 = Map("dhcp")
95
96 s = m2:section(TypedSection, "dhcp", "DHCP")
97 s.anonymous = true
98 s.addremove = false
99 s.dynamic = false
100
101 s:tab("general", translate("General Settings"))
102
103 s:depends("interface", "lan")
104
105 enable = s:taboption("general", ListValue, "ignore", translate("Automatic address assignment for network devices"),
106 bridge and 
107 translate("Note: Be careful that you do not accidently two DHCP servers in the same network with overlapping address ranges.")
108 or "")
109 enable:value(0, translate("enable"), {["network.lan.proto"] = "static"})
110 enable:value(1, translate("disable"))
111
112
113 s:tab("expert", translate("Expert Settings"))
114 start = s:taboption("expert", Value, "start", translate("First leased address"))
115 start:depends("ignore", "0")
116 start.default = "100"
117
118 limit = s:taboption("expert", Value, "limit", translate("Number of leased addresses"), "")
119 limit:depends("ignore", "0")
120 limit.default = "150"
121
122 time = s:taboption("expert", Value, "leasetime", translate("Lease Time"))
123 time:depends("ignore", "0")
124 time.default = "12h"
125
126 local dd = s:taboption("expert", Flag, "dynamicdhcp", translate("Also generate addresses for unknown devices"))
127 dd.rmempty = false
128 dd.default = "1"
129 dd:depends("ignore", "0")
130
131 return m, m2