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