New IPv6 integration
[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 ip6prefix = s:taboption("general", Value, "ip6prefix",
42         translate("IPv6 routed prefix"),
43         translate("This is the prefix routed to you by the tunnel broker for use by clients"))
44
45 ip6prefix.datatype = "ip6addr"
46
47
48 local update = section:taboption("general", Flag, "_update",
49         translate("Dynamic tunnel"),
50         translate("Enable HE.net dynamic endpoint update"))
51
52 update.enabled  = "1"
53 update.disabled = "0"
54
55 function update.write() end
56 function update.remove() end
57 function update.cfgvalue(self, section)
58         return (tonumber(m:get(section, "tunnelid")) ~= nil)
59                 and self.enabled or self.disabled
60 end
61
62
63 tunnelid = section:taboption("general", Value, "tunnelid", translate("Tunnel ID"))
64 tunnelid.datatype = "uinteger"
65 tunnelid:depends("_update", update.enabled)
66
67
68 username = section:taboption("general", Value, "username",
69         translate("HE.net user ID"),
70         translate("This is the 32 byte hex encoded user ID, not the login name"))
71
72 username:depends("_update", update.enabled)
73
74
75 password = section:taboption("general", Value, "password", translate("HE.net password"))
76 password.password = true
77 password:depends("_update", update.enabled)
78
79
80 defaultroute = section:taboption("advanced", Flag, "defaultroute",
81         translate("Default gateway"),
82         translate("If unchecked, no default route is configured"))
83
84 defaultroute.default = defaultroute.enabled
85
86
87 metric = section:taboption("advanced", Value, "metric",
88         translate("Use gateway metric"))
89
90 metric.placeholder = "0"
91 metric.datatype    = "uinteger"
92 metric:depends("defaultroute", defaultroute.enabled)
93
94
95 ttl = section:taboption("advanced", Value, "ttl", translate("Use TTL on tunnel interface"))
96 ttl.placeholder = "64"
97 ttl.datatype    = "range(1,255)"
98
99
100 mtu = section:taboption("advanced", Value, "mtu", translate("Use MTU on tunnel interface"))
101 mtu.placeholder = "1280"
102 mtu.datatype    = "max(1500)"