Merge branch 'Tomato-RAF' into tomato-shibby
[tomato.git] / release / src / router / www / basic-ipv6.asp
blob4fc1aba1f42b8a111a8a90327ee6f76583ae1ced
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <title>[<% ident(); %>] Basic: IPv6</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <link rel='stylesheet' type='text/css' href='color.css'>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
21 <script type='text/javascript' src='debug.js'></script>
23 <script type='text/javascript'>
24 // <% nvram("ipv6_prefix,ipv6_prefix_length,ipv6_radvd,ipv6_accept_ra,ipv6_rtr_addr,ipv6_service,ipv6_dns,ipv6_tun_addr,ipv6_tun_addrlen,ipv6_ifname,ipv6_tun_v4end,ipv6_tun_mtu,ipv6_tun_ttl"); %>
26 nvram.ipv6_accept_ra = fixInt(nvram.ipv6_accept_ra, 0, 3, 0);
28 function verifyFields(focused, quiet)
30 var i;
31 var ok = 1;
32 var a, b, c;
34 // --- visibility ---
36 var vis = {
37 _ipv6_service: 1,
38 _ipv6_prefix: 1,
39 _ipv6_prefix_length: 1,
40 _f_ipv6_rtr_addr_auto: 1,
41 _f_ipv6_rtr_addr: 1,
42 _f_ipv6_dns_1: 1,
43 _f_ipv6_dns_2: 1,
44 _f_ipv6_dns_3: 1,
45 _f_ipv6_radvd: 1,
46 _f_ipv6_accept_ra_wan: 1,
47 _f_ipv6_accept_ra_lan: 1,
48 _ipv6_tun_v4end: 1,
49 _ipv6_ifname: 1,
50 _ipv6_tun_addr: 1,
51 _ipv6_tun_addrlen: 1,
52 _ipv6_tun_ttl: 1,
53 _ipv6_tun_mtu: 1
56 switch(E('_ipv6_service').value) {
57 case '':
58 vis._ipv6_ifname = 0;
59 vis._f_ipv6_rtr_addr_auto = 0;
60 vis._f_ipv6_rtr_addr = 0;
61 vis._f_ipv6_dns_1 = 0;
62 vis._f_ipv6_dns_2 = 0;
63 vis._f_ipv6_dns_3 = 0;
64 vis._f_ipv6_radvd = 0;
65 vis._f_ipv6_accept_ra_wan = 0;
66 vis._f_ipv6_accept_ra_lan = 0;
67 // fall through
68 case 'other':
69 vis._ipv6_prefix = 0;
70 vis._ipv6_prefix_length = 0;
71 E('_f_ipv6_rtr_addr_auto').value = 1;
72 vis._ipv6_tun_v4end = 0;
73 vis._ipv6_tun_addr = 0;
74 vis._ipv6_tun_addrlen = 0;
75 vis._ipv6_tun_ttl = 0;
76 vis._ipv6_tun_mtu = 0;
77 break;
78 case 'native-pd':
79 vis._ipv6_prefix = 0;
80 vis._f_ipv6_rtr_addr_auto = 0;
81 vis._f_ipv6_rtr_addr = 0;
82 // fall through
83 case 'native':
84 vis._ipv6_ifname = 0;
85 vis._ipv6_tun_v4end = 0;
86 vis._ipv6_tun_addr = 0;
87 vis._ipv6_tun_addrlen = 0;
88 vis._ipv6_tun_ttl = 0;
89 vis._ipv6_tun_mtu = 0;
90 break;
91 case 'sit':
92 break;
95 if (vis._f_ipv6_rtr_addr_auto && E('_f_ipv6_rtr_addr_auto').value == 0) {
96 vis._f_ipv6_rtr_addr = 2;
99 for (a in vis) {
100 b = E(a);
101 c = vis[a];
102 b.disabled = (c != 1);
103 PR(b).style.display = c ? '' : 'none';
106 // --- verify ---
108 if (vis._ipv6_ifname == 1) {
109 if (E('_ipv6_service').value != 'other') {
110 if (!v_length('_ipv6_ifname', quiet || !ok, 2)) ok = 0;
112 else ferror.clear('_ipv6_ifname');
115 /* REMOVE-BEGIN
116 // Length
117 a = [['_ipv6_ifname', 2]];
118 for (i = a.length - 1; i >= 0; --i) {
119 v = a[i];
120 if ((vis[v[0]]) && (!v_length(v[0], quiet || !ok, v[1]))) ok = 0;
122 REMOVE-END */
124 // IP address
125 a = ['_ipv6_tun_v4end'];
126 for (i = a.length - 1; i >= 0; --i)
127 if ((vis[a[i]]) && (!v_ip(a[i], quiet || !ok))) ok = 0;
129 // range
130 a = [['_ipv6_prefix_length', 3, 64], ['_ipv6_tun_addrlen', 3, 127], ['_ipv6_tun_ttl', 0, 255]];
131 for (i = a.length - 1; i >= 0; --i) {
132 b = a[i];
133 if ((vis[b[0]]) && (!v_range(b[0], quiet || !ok, b[1], b[2]))) ok = 0;
136 // mtu
137 b = '_ipv6_tun_mtu';
138 if (vis[b]) {
139 if ((!v_range(b, 1, 0, 0)) && (!v_range(b, quiet || !ok, 1280, 1480))) ok = 0;
140 else ferror.clear(E(b));
143 // IPv6 address
144 a = ['_ipv6_prefix', '_ipv6_tun_addr'];
145 for (i = a.length - 1; i >= 0; --i)
146 if ((vis[a[i]]) && (!v_ipv6_addr(a[i], quiet || !ok))) ok = 0;
148 if (vis._f_ipv6_rtr_addr == 2 && ok) {
149 b = E('_ipv6_prefix');
150 ip = ZeroIPv6PrefixBits(b.value, E('_ipv6_prefix_length').value);
151 b.value = ip;
152 E('_f_ipv6_rtr_addr').value = ip + '1';
155 // optional IPv6 address
156 a = ['_f_ipv6_rtr_addr', '_f_ipv6_dns_1', '_f_ipv6_dns_2', '_f_ipv6_dns_3'];
157 for (i = a.length - 1; i >= 0; --i)
158 if ((vis[a[i]]==1) && (E(a[i]).value.length > 0) && (!v_ipv6_addr(a[i], quiet || !ok))) ok = 0;
160 return ok;
163 function earlyInit()
165 verifyFields(null, 1);
168 function joinIPv6Addr(a) {
169 var r, i, s;
171 r = [];
172 for (i = 0; i < a.length; ++i) {
173 s = CompressIPv6Address(a[i]);
174 if ((s) && (s != '')) r.push(s);
176 return r.join(' ');
179 function save()
181 var a, b, c;
182 var i;
184 if (!verifyFields(null, false)) return;
186 var fom = E('_fom');
188 fom.ipv6_dns.value = joinIPv6Addr([fom.f_ipv6_dns_1.value, fom.f_ipv6_dns_2.value, fom.f_ipv6_dns_3.value]);
189 fom.ipv6_radvd.value = fom.f_ipv6_radvd.checked ? 1 : 0;
191 fom.ipv6_accept_ra.value = 0;
192 if (fom.f_ipv6_accept_ra_wan.checked) fom.ipv6_accept_ra.value |= 1;
193 if (fom.f_ipv6_accept_ra_lan.checked) fom.ipv6_accept_ra.value |= 2;
195 switch(E('_ipv6_service').value) {
196 case 'other':
197 fom.ipv6_prefix_length.value = 64;
198 fom.ipv6_prefix.value = '';
199 fom.ipv6_rtr_addr.value = fom.f_ipv6_rtr_addr.value;
200 break;
201 case 'native-pd':
202 fom.ipv6_prefix.value = '';
203 fom.ipv6_rtr_addr.value = '';
204 break;
205 default:
206 fom.ipv6_rtr_addr.disabled = fom.f_ipv6_rtr_addr_auto.disabled;
207 if (fom.f_ipv6_rtr_addr_auto.value == 1)
208 fom.ipv6_rtr_addr.value = fom.f_ipv6_rtr_addr.value;
209 else
210 fom.ipv6_rtr_addr.value = '';
214 form.submit(fom, 1);
217 </script>
219 </head>
220 <body>
221 <form id='_fom' method='post' action='tomato.cgi'>
222 <table id='container' cellspacing=0>
223 <tr><td colspan=2 id='header'>
224 <div class='title'>Tomato</div>
225 <div class='version'>Version <% version(); %></div>
226 </td></tr>
227 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
228 <td id='content'>
229 <div id='ident'><% ident(); %></div>
231 <!-- / / / -->
233 <input type='hidden' name='_nextpage' value='basic-ipv6.asp'>
234 <input type='hidden' name='_nextwait' value='10'>
235 <input type='hidden' name='_service' value='*'>
237 <input type='hidden' name='ipv6_radvd'>
238 <input type='hidden' name='ipv6_dns'>
239 <input type='hidden' name='ipv6_rtr_addr'>
240 <input type='hidden' name='ipv6_accept_ra'>
242 <div class='section-title'>IPv6 Configuration</div>
243 <div class='section'>
244 <script type='text/javascript'>
245 dns = nvram.ipv6_dns.split(/\s+/);
247 createFieldTable('', [
248 { title: 'IPv6 Service Type', name: 'ipv6_service', type: 'select',
249 options: [['', 'Disabled'],['native','Native IPv6 from ISP'],['native-pd','DHCPv6 with Prefix Delegation'],['sit','6in4 Static Tunnel'],['other','Other (Manual Configuration)']],
250 value: nvram.ipv6_service },
251 { title: 'IPv6 WAN Interface', name: 'ipv6_ifname', type: 'text', maxlen: 8, size: 10, value: nvram.ipv6_ifname },
252 null,
253 { title: 'Assigned IPv6 Prefix', name: 'ipv6_prefix', type: 'text', maxlen: 46, size: 48, value: nvram.ipv6_prefix },
254 { title: 'Prefix Length', name: 'ipv6_prefix_length', type: 'text', maxlen: 3, size: 5, value: nvram.ipv6_prefix_length },
255 { title: 'Router IPv6 Address', multi: [
256 { name: 'f_ipv6_rtr_addr_auto', type: 'select', options: [['0', 'Default'],['1','Manual']], value: (nvram.ipv6_rtr_addr == '' ? '0' : '1') },
257 { name: 'f_ipv6_rtr_addr', type: 'text', maxlen: 46, size: 48, value: nvram.ipv6_rtr_addr }
258 ] },
259 { title: 'Static DNS', name: 'f_ipv6_dns_1', type: 'text', maxlen: 46, size: 48, value: dns[0] || '' },
260 { title: '', name: 'f_ipv6_dns_2', type: 'text', maxlen: 46, size: 48, value: dns[1] || '' },
261 { title: '', name: 'f_ipv6_dns_3', type: 'text', maxlen: 46, size: 48, value: dns[2] || '' },
262 { title: 'Enable Router Advertisements', name: 'f_ipv6_radvd', type: 'checkbox', value: nvram.ipv6_radvd != '0' },
263 { title: 'Accept RA from', multi: [
264 { suffix: '&nbsp; WAN &nbsp;&nbsp;&nbsp;', name: 'f_ipv6_accept_ra_wan', type: 'checkbox', value: (nvram.ipv6_accept_ra & 1) },
265 { suffix: '&nbsp; LAN &nbsp;', name: 'f_ipv6_accept_ra_lan', type: 'checkbox', value: (nvram.ipv6_accept_ra & 2) }
266 ] },
267 null,
268 { title: 'Tunnel Remote Endpoint (IPv4 Address)', name: 'ipv6_tun_v4end', type: 'text', maxlen: 15, size: 17, value: nvram.ipv6_tun_v4end },
269 { title: 'Tunnel Client IPv6 Address', multi: [
270 { name: 'ipv6_tun_addr', type: 'text', maxlen: 46, size: 48, value: nvram.ipv6_tun_addr, suffix: ' / ' },
271 { name: 'ipv6_tun_addrlen', type: 'text', maxlen: 3, size: 5, value: nvram.ipv6_tun_addrlen }
272 ] },
273 { title: 'Tunnel MTU', name: 'ipv6_tun_mtu', type: 'text', maxlen: 4, size: 8, value: nvram.ipv6_tun_mtu, suffix: ' <small>(0 for default)</small>' },
274 { title: 'Tunnel TTL', name: 'ipv6_tun_ttl', type: 'text', maxlen: 3, size: 8, value: nvram.ipv6_tun_ttl }
276 </script>
277 </div>
279 <br>
280 <script type='text/javascript'>show_notice1('<% notice("ip6tables"); %>');</script>
282 <!-- / / / -->
284 </td></tr>
285 <tr><td id='footer' colspan=2>
286 <span id='footer-msg'></span>
287 <input type='button' value='Save' id='save-button' onclick='save()'>
288 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
289 </td></tr>
290 </table>
291 </form>
292 <script type='text/javascript'>earlyInit()</script>
293 <div style='height:100px'></div>
294 </body>
295 </html>