protocols/6x4: make local ip6addr of 6in4 interfaces optional
[project/luci.git] / protocols / 6x4 / luasrc / model / cbi / admin_network / proto_6in4.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
15 local ipaddr, peeraddr, ip6addr, tunnelid, username, password
16 local defaultroute, metric, ttl, mtu
17
18
19 ipaddr = s:taboption("general", Value, "ipaddr",
20         translate("Local IPv4 address"),
21         translate("Leave empty to use the current WAN address"))
22
23 ipaddr.datatype = "ip4addr"
24
25
26 peeraddr = s:taboption("general", Value, "peeraddr",
27         translate("Remote IPv4 address"),
28         translate("This is usually the address of the nearest PoP operated by the tunnel broker"))
29
30 peeraddr.rmempty  = false
31 peeraddr.datatype = "ip4addr"
32
33
34 ip6addr = s:taboption("general", Value, "ip6addr",
35         translate("Local IPv6 address"),
36         translate("This is the local endpoint address assigned by the tunnel broker, it usually ends with <code>:2</code>"))
37
38 ip6addr.datatype = "ip6addr"
39
40
41 local update = section:taboption("general", Flag, "_update",
42         translate("Dynamic tunnel"),
43         translate("Enable HE.net dynamic endpoint update"))
44
45 update.enabled  = "1"
46 update.disabled = "0"
47
48 function update.write() end
49 function update.remove() end
50 function update.cfgvalue(self, section)
51         return (tonumber(m:get(section, "tunnelid")) ~= nil)
52                 and self.enabled or self.disabled
53 end
54
55
56 tunnelid = section:taboption("general", Value, "tunnelid", translate("Tunnel ID"))
57 tunnelid.datatype = "uinteger"
58 tunnelid:depends("_update", update.enabled)
59
60
61 username = section:taboption("general", Value, "username",
62         translate("HE.net user ID"),
63         translate("This is the 32 byte hex encoded user ID, not the login name"))
64
65 username:depends("_update", update.enabled)
66
67
68 password = section:taboption("general", Value, "password", translate("HE.net password"))
69 password.password = true
70 password:depends("_update", update.enabled)
71
72
73 defaultroute = section:taboption("advanced", Flag, "defaultroute",
74         translate("Default gateway"),
75         translate("If unchecked, no default route is configured"))
76
77 defaultroute.default = defaultroute.enabled
78
79
80 metric = section:taboption("advanced", Value, "metric",
81         translate("Use gateway metric"))
82
83 metric.placeholder = "0"
84 metric.datatype    = "uinteger"
85 metric:depends("defaultroute", defaultroute.enabled)
86
87
88 ttl = section:taboption("advanced", Value, "ttl", translate("Use TTL on tunnel interface"))
89 ttl.placeholder = "64"
90 ttl.datatype    = "range(1,255)"
91
92
93 mtu = section:taboption("advanced", Value, "mtu", translate("Use MTU on tunnel interface"))
94 mtu.placeholder = "1280"
95 mtu.datatype    = "max(1500)"