b8a7dd34ae4d29ce704ccd564b054c440c9ef129
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / ifaces.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
15
16 s = m:section(TypedSection, "interface", "")
17 s.addremove = true
18 s:exclude("loopback")
19 s:depends("proto", "static")
20 s:depends("proto", "dhcp")
21
22 p = s:option(ListValue, "proto", translate("protocol"))
23 p:value("static", translate("static"))
24 p:value("dhcp", "DHCP")
25 p.default = "static"
26
27 br = s:option(Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
28 br.enabled = "bridge"
29 br.rmempty = true
30
31 ifname = s:option(Value, "ifname", translate("interface"))
32 ifname.rmempty = true
33 for i,d in ipairs(luci.sys.net.devices()) do
34         if d ~= "lo" then
35                 ifname:value(d)
36         end
37 end
38
39 s:option(Value, "ipaddr", translate("ipaddress"))
40
41 nm = s:option(Value, "netmask", translate("netmask"))
42 nm:depends("proto", "static")
43 nm:value("255.255.255.0")
44 nm:value("255.255.0.0")
45 nm:value("255.0.0.0")
46
47 gw = s:option(Value, "gateway", translate("gateway"))
48 gw:depends("proto", "static")
49 gw.rmempty = true
50
51 dns = s:option(Value, "dns", translate("dnsserver"))
52 dns:depends("proto", "static")
53 dns.optional = true
54
55 mtu = s:option(Value, "mtu", "MTU")
56 mtu.optional = true
57 mtu.isinteger = true
58
59 mac = s:option(Value, "macaddr", translate("macaddress"))
60 mac.optional = true
61
62 return m