25e9b3af3b7fa398862e31cd86e9ffb91867ba7f
[project/luci.git] / protocols / core / luasrc / model / cbi / admin_network / proto_static.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.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
13 local map, section, net = ...
14 local ifc = net:get_interface()
15
16 local ipaddr, netmask, gateway, broadcast, dns, accept_ra, send_rs, ip6addr, ip6gw
17 local mtu, metric
18
19
20 ipaddr = section:taboption("general", Value, "ipaddr", translate("IPv4 address"))
21 ipaddr.datatype = "ip4addr"
22
23
24 netmask = section:taboption("general", Value, "netmask",
25 translate("IPv4 netmask"))
26
27 netmask.datatype = "ip4addr"
28 netmask:value("255.255.255.0")
29 netmask:value("255.255.0.0")
30 netmask:value("255.0.0.0")
31
32
33 gateway = section:taboption("general", Value, "gateway", translate("IPv4 gateway"))
34 gateway.datatype = "ip4addr"
35
36
37 broadcast = section:taboption("general", Value, "broadcast", translate("IPv4 broadcast"))
38 broadcast.datatype = "ip4addr"
39
40
41 dns = section:taboption("general", DynamicList, "dns",
42 translate("Use custom DNS servers"))
43
44 dns.datatype = "ipaddr"
45 dns.cast = "string"
46
47
48 if luci.model.network:has_ipv6() then
49
50 local ip6assign = section:taboption("general", Value, "ip6assign", translate("IPv6 assignment length"),
51 translate("Assign a part of given length of every public IPv6-prefix to this interface"))
52 ip6assign:value("", translate("disabled"))
53 ip6assign:value("64")
54 ip6assign.datatype = "max(64)"
55
56 local ip6hint = section:taboption("general", Value, "ip6hint", translate("IPv6 assignment hint"),
57 translate("Assign prefix parts using this hexadecimal subprefix ID for this interface."))
58
59 ip6addr = section:taboption("general", Value, "ip6addr", translate("IPv6 address"))
60 ip6addr.datatype = "ip6addr"
61
62
63 ip6gw = section:taboption("general", Value, "ip6gw", translate("IPv6 gateway"))
64 ip6gw.datatype = "ip6addr"
65
66
67 local ip6prefix = s:taboption("general", Value, "ip6prefix", translate("IPv6 routed prefix"),
68 translate("Public prefix routed to this device for distribution to clients."))
69 ip6prefix.datatype = "ip6addr"
70
71 end
72
73
74 luci.tools.proto.opt_macaddr(section, ifc, translate("Override MAC address"))
75
76
77 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
78 mtu.placeholder = "1500"
79 mtu.datatype = "max(9200)"
80
81
82 metric = section:taboption("advanced", Value, "metric",
83 translate("Use gateway metric"))
84
85 metric.placeholder = "0"
86 metric.datatype = "uinteger"