Merge branch 'tomato-RT' into Toastman-RT
[tomato.git] / release / src / router / www / forward-basic-ipv6.asp
blob7b12860e0dc9d0eb52a9c75b891dbd995db66678
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(); %>] Forwarding: 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 <!-- / / / -->
20 <style type='text/css'>
21 #fo-grid .co1 {
22 width: 25px;
23 text-align: center;
25 #fo-grid .co2 {
26 width: 70px;
28 #fo-grid .co3 {
29 width: 145px;
31 #fo-grid .co4 {
32 width: 140px;
34 #fo-grid .co5 {
35 width: 80px;
37 #fo-grid .co7 {
38 width: 300px;
41 </style>
43 <script type='text/javascript' src='debug.js'></script>
45 <script type='text/javascript'>
47 // <% nvram("ipv6_portforward"); %>
49 var fog = new TomatoGrid();
51 fog.sortCompare = function(a, b) {
52 var col = this.sortColumn;
53 var da = a.getRowData();
54 var db = b.getRowData();
55 var r;
57 switch (col) {
58 case 0: // on
59 case 1: // proto
60 case 4: // ports
61 r = cmpInt(da[col], db[col]);
62 break;
63 default:
64 r = cmpText(da[col], db[col]);
65 break;
68 return this.sortAscending ? r : -r;
71 fog.dataToView = function(data) {
72 return [(data[0] != '0') ? 'On' : '', ['TCP', 'UDP', 'Both'][data[1] - 1], (data[2].match(/(.+)-(.+)/)) ? (RegExp.$1 + ' -<br>' + RegExp.$2) : data[2], data[3], data[4], data[5]];
75 fog.fieldValuesToData = function(row) {
76 var f = fields.getAll(row);
77 return [f[0].checked ? 1 : 0, f[1].value, f[2].value, f[3].value, f[4].value, f[5].value];
80 fog.verifyFields = function(row, quiet) {
81 var f = fields.getAll(row);
83 f[2].value = f[2].value.trim();
84 if ((f[2].value.length) && (!_v_iptaddr(f[2], quiet, 0, 0, 1))) return 0;
86 f[3].value = f[3].value.trim();
87 if ((f[3].value.length) && !v_hostname(f[3], 1)) {
88 if (!v_ipv6_addr(f[3], quiet)) return 0;
91 if (!v_iptport(f[4], quiet)) return 0;
93 f[5].value = f[5].value.replace(/>/g, '_');
94 if (!v_nodelim(f[5], quiet, 'Description')) return 0;
95 return 1;
98 fog.resetNewEditor = function() {
99 var f = fields.getAll(this.newEditor);
100 f[0].checked = 1;
101 f[1].selectedIndex = 0;
102 f[2].value = '';
103 f[3].value = '';
104 f[4].value = '';
105 f[5].value = '';
106 ferror.clearAll(fields.getAll(this.newEditor));
109 fog.setup = function() {
110 this.init('fo-grid', 'sort', 50, [
111 { type: 'checkbox' },
112 { type: 'select', options: [[1, 'TCP'],[2, 'UDP'],[3,'Both']] },
113 { type: 'text', maxlen: 140 },
114 { type: 'text', maxlen: 140 },
115 { type: 'text', maxlen: 16 },
116 { type: 'text', maxlen: 32 }]);
117 this.headerSet(['On', 'Proto', 'Src Address', 'Dest Address', 'Dest Ports', 'Description']);
118 var nv = nvram.ipv6_portforward.split('>');
119 for (var i = 0; i < nv.length; ++i) {
120 var r;
122 if (r = nv[i].match(/^(\d)<(\d)<(.*)<(.*)<(.+?)<(.*)$/)) {
123 r[1] *= 1;
124 r[2] *= 1;
125 r[5] = r[5].replace(/:/g, '-');
126 fog.insertData(-1, r.slice(1, 7));
129 fog.sort(5);
130 fog.showNewEditor();
133 function srcSort(a, b)
135 if (a[2].length) return -1;
136 if (b[2].length) return 1;
137 return 0;
140 function save()
142 if (fog.isEditing()) return;
144 var data = fog.getAllData().sort(srcSort);
145 var s = '';
146 for (var i = 0; i < data.length; ++i) {
147 data[i][4] = data[i][4].replace(/-/g, ':');
148 s += data[i].join('<') + '>';
150 var fom = E('_fom');
151 fom.ipv6_portforward.value = s;
152 form.submit(fom, 0, 'tomato.cgi');
155 function init()
157 fog.recolor();
158 fog.resetNewEditor();
160 </script>
161 </head>
162 <body onload='init()'>
163 <form id='_fom' method='post' action='javascript:{}'>
164 <table id='container' cellspacing=0>
165 <tr><td colspan=2 id='header'>
166 <div class='title'>Tomato</div>
167 <div class='version'>Version <% version(); %></div>
168 </td></tr>
169 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
170 <td id='content'>
171 <div id='ident'><% ident(); %></div>
173 <!-- / / / -->
175 <input type='hidden' name='_nextpage' value='forward-basic-ipv6.asp'>
176 <input type='hidden' name='_service' value='firewall-restart'>
178 <input type='hidden' name='ipv6_portforward'>
180 <div class='section-title'>IPv6 Port Forwarding</div>
181 <div class='section'>
182 <table class='tomato-grid' cellspacing=1 id='fo-grid'></table>
183 <script type='text/javascript'>fog.setup();</script>
184 </div>
186 <div>
187 Opens access to ports on machines inside the LAN, but does <b>not</b> re-map ports.
188 <ul>
189 <li><b>Src Address</b> <i>(optional)</i> - Forward only if from this address. Ex: "2001:4860:800b::/48", "me.example.com".
190 <li><b>Dest Address</b> <i>(optional)</i> - The destination address inside the LAN.
191 <li><b>Dest Ports</b> - The ports to be opened for forwarding. Ex: "2345", "200,300", "200-300,400".
192 </ul>
193 </div>
195 <br>
196 <script type='text/javascript'>show_notice1('<% notice("ip6tables"); %>');</script>
198 <!-- / / / -->
200 </td></tr>
201 <tr><td id='footer' colspan=2>
202 <span id='footer-msg'></span>
203 <input type='button' value='Save' id='save-button' onclick='save()'>
204 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
205 </td></tr>
206 </table>
207 </form>
208 </body>
209 </html>