Merge pull request #1250 from dibdot/luci-app-travelmate
[project/luci.git] / modules / luci-base / luasrc / model / cbi / admin_network / proto_static.lua
1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local map, section, net = ...
5 local ifc = net:get_interface()
6
7 local ipaddr, netmask, gateway, broadcast, dns, accept_ra, send_rs, ip6addr, ip6gw
8 local mtu, metric
9
10
11 ipaddr = section:taboption("general", Value, "ipaddr", translate("IPv4 address"))
12 ipaddr.datatype = "ip4addr"
13
14
15 netmask = section:taboption("general", Value, "netmask",
16         translate("IPv4 netmask"))
17
18 netmask.datatype = "ip4addr"
19 netmask:value("255.255.255.0")
20 netmask:value("255.255.0.0")
21 netmask:value("255.0.0.0")
22
23
24 gateway = section:taboption("general", Value, "gateway", translate("IPv4 gateway"))
25 gateway.datatype = "ip4addr"
26
27
28 broadcast = section:taboption("general", Value, "broadcast", translate("IPv4 broadcast"))
29 broadcast.datatype = "ip4addr"
30
31
32 dns = section:taboption("general", DynamicList, "dns",
33         translate("Use custom DNS servers"))
34
35 dns.datatype = "ipaddr"
36 dns.cast     = "string"
37
38
39 if luci.model.network:has_ipv6() then
40
41         local ip6assign = section:taboption("general", Value, "ip6assign", translate("IPv6 assignment length"),
42                 translate("Assign a part of given length of every public IPv6-prefix to this interface"))
43         ip6assign:value("", translate("disabled"))
44         ip6assign:value("64")
45         ip6assign.datatype = "max(64)"
46
47         local ip6hint = section:taboption("general", Value, "ip6hint", translate("IPv6 assignment hint"),
48                 translate("Assign prefix parts using this hexadecimal subprefix ID for this interface."))
49         for i=33,64 do ip6hint:depends("ip6assign", i) end
50
51         ip6addr = section:taboption("general", Value, "ip6addr", translate("IPv6 address"))
52         ip6addr.datatype = "ip6addr"
53         ip6addr:depends("ip6assign", "")
54
55
56         ip6gw = section:taboption("general", Value, "ip6gw", translate("IPv6 gateway"))
57         ip6gw.datatype = "ip6addr"
58         ip6gw:depends("ip6assign", "")
59
60
61         local ip6prefix = s:taboption("general", Value, "ip6prefix", translate("IPv6 routed prefix"),
62                 translate("Public prefix routed to this device for distribution to clients."))
63         ip6prefix.datatype = "ip6addr"
64         ip6prefix:depends("ip6assign", "")
65
66         local ip6ifaceid = s:taboption("general", Value, "ip6ifaceid", translate("IPv6 suffix"),
67                 translate("Optional. Allowed values: 'eui64', 'random', fixed value like '::1' " ..
68                         "or '::1:2'. When IPv6 prefix (like 'a:b:c:d::') is received from a " ..
69                         "delegating server, use the suffix (like '::1') to form the IPv6 address " ..
70                         "('a:b:c:d::1') for the interface."))
71         ip6ifaceid.datatype = "ip6hostid"
72         ip6ifaceid.placeholder = "::1"
73         ip6ifaceid.rmempty = true
74
75 end
76
77
78 luci.tools.proto.opt_macaddr(section, ifc, translate("Override MAC address"))
79
80
81 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
82 mtu.placeholder = "1500"
83 mtu.datatype    = "max(9200)"
84
85
86 metric = section:taboption("advanced", Value, "metric",
87         translate("Use gateway metric"))
88
89 metric.placeholder = "0"
90 metric.datatype    = "uinteger"