Merge remote branch 'remotes/origin/Teaman-IPTraffic' into Teaman-ND
[tomato.git] / release / src / router / www / advanced-access.asp
blob677e9cef69b321e407042acc8d565bcb9661b9b2
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2007 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
6 For use with Tomato Firmware only.
7 No part of this file may be used without permission.
8 LAN Access admin module by Augusto Bott
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(); %>] Advanced: LAN Access</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <% css(); %>
17 <script type='text/javascript' src='tomato.js'></script>
18 <style type='text/css'>
19 #la-grid .co1 {
20 text-align: center;
21 width: 30px;
23 #la-grid .co3,
24 #la-grid .co5 {
25 text-align: center;
26 width: 120px;
28 #la-grid .co6 {
29 text-align: center;
30 width: 250px;
32 #la-grid .co2,
33 #la-grid .co4 {
34 text-align: center;
37 #la-grid .centered {
38 text-align: center;
40 </style>
41 <script type='text/javascript' src='wireless.jsx?_http_id=<% nv(http_id); %>'></script>
42 <script type='text/javascript'>
43 <% nvram ("lan_ifname,lan1_ifname,lan2_ifname,lan3_ifname,lan_access");%>
45 var MAX_BRIDGE_ID = 3;
47 var la = new TomatoGrid();
48 la.setup = function() {
49 this.init('la-grid', 'sort', 50, [
50 { type: 'checkbox', prefix: '<div class="centered">', suffix: '</div>' },
51 { type: 'select', options: [[0, 'LAN (br0)'],[1, 'LAN1 (br1)'],[2, 'LAN2 (br2)'],[3, 'LAN3 (br3)']], prefix: '<div class="centered">', suffix: '</div>' },
52 { type: 'text', maxlen: 32 },
53 { type: 'select', options: [[0, 'LAN (br0)'],[1, 'LAN1 (br1)'],[2, 'LAN2 (br2)'],[3, 'LAN3 (br3)']], prefix: '<div class="centered">', suffix: '</div>' },
54 { type: 'text', maxlen: 32 },
55 { type: 'text', maxlen: 32 }]);
56 this.headerSet(['On', 'Src', 'Src Address', 'Dst', 'Dst Address', 'Description']);
58 var r = nvram.lan_access.split('>');
59 for (var i = 0; i < r.length; ++i) {
60 if(r[i].length) {
61 var l = r[i].split('<');
62 l[0] *= 1;
63 l[1] *= 1;
64 l[3] *= 1;
65 la.insertData(-1, [ l[0], l[1], l[2], l[3], l[4], l[5] ] );
69 la.recolor();
70 la.showNewEditor();
71 la.resetNewEditor();
74 la.sortCompare = function(a, b) {
75 var col = this.sortColumn;
76 var da = a.getRowData();
77 var db = b.getRowData();
78 var r;
80 switch (col) {
81 case 2: // src
82 case 4: // dst
83 r = cmpIP(da[col], db[col]);
84 break;
85 case 0: // on
86 case 1: // src br
87 case 3: // dst br
88 r = cmpInt(da[col], db[col]);
89 break;
90 default:
91 r = cmpText(da[col], db[col]);
92 break;
95 return this.sortAscending ? r : -r;
98 la.resetNewEditor = function() {
99 var f = fields.getAll(this.newEditor);
100 f[0].checked=true;
101 f[2].value='';
102 f[4].value='';
103 f[5].value='';
104 var total=0;
105 for (var i=0; i<= MAX_BRIDGE_ID; i++) {
106 var j = (i == 0) ? '' : i.toString();
107 if (nvram['lan' + j + '_ifname'].length < 1) {
108 f[1].options[i].disabled=true;
109 f[3].options[i].disabled=true;
110 } else {
111 ++total;
114 if((f[1].selectedIndex == f[3].selectedIndex) && (total > 1)) {
115 while (f[1].selectedIndex == f[3].selectedIndex) {
116 f[3].selectedIndex = (f[3].selectedIndex%(MAX_BRIDGE_ID+1)+1);
119 ferror.clearAll(fields.getAll(this.newEditor));
122 la.verifyFields = function(row, quiet) {
123 var f = fields.getAll(row);
125 for (var i=0; i<= MAX_BRIDGE_ID; i++) {
126 var j = (i == 0) ? '' : i.toString();
127 if (nvram['lan' + j + '_ifname'].length < 1) {
128 f[1].options[i].disabled=true;
129 f[3].options[i].disabled=true;
133 if(f[1].selectedIndex == f[3].selectedIndex) {
134 var m = 'Source and Destination interfaces must be different';
135 ferror.set(f[1], m, quiet);
136 ferror.set(f[3], m, quiet);
137 return 0;
139 ferror.clear(f[1]);
140 ferror.clear(f[3]);
142 f[2].value = f[2].value.trim();
143 f[4].value = f[4].value.trim();
145 if ((f[2].value.length) && (!v_iptaddr(f[2], quiet))) return 0;
146 if ((f[4].value.length) && (!v_iptaddr(f[4], quiet))) return 0;
148 ferror.clear(f[2]);
149 ferror.clear(f[4]);
151 f[5].value = f[5].value.replace(/>/g, '_');
152 if (!v_nodelim(f[5], quiet, 'Description')) return 0;
154 return 1;
157 la.dataToView = function(data) {
158 return [(data[0] != 0) ? 'On' : '',
159 ['LAN', 'LAN1', 'LAN2', 'LAN3'][data[1]],
160 data[2],
161 ['LAN', 'LAN1', 'LAN2', 'LAN3'][data[3]],
162 data[4],
163 data[5] ];
166 la.dataToFieldValues = function (data) {
167 return [(data[0] != 0) ? 'checked' : '',
168 data[1],
169 data[2],
170 data[3],
171 data[4],
172 data[5] ];
175 la.fieldValuesToData = function(row) {
176 var f = fields.getAll(row);
177 return [f[0].checked ? 1 : 0,
178 f[1].selectedIndex,
179 f[2].value,
180 f[3].selectedIndex,
181 f[4].value,
182 f[5].value ];
185 function save()
187 if (la.isEditing()) return;
188 la.resetNewEditor();
190 var fom = E('_fom');
191 var ladata = la.getAllData();
193 var s = '';
194 for (var i = 0; i < ladata.length; ++i) {
195 s += ladata[i].join('<') + '>';
197 fom.lan_access.value = s;
199 form.submit(fom, 0);
202 function init() {
203 la.setup();
206 </script>
207 </head>
208 <body onload='init()'>
209 <form id='_fom' method='post' action='tomato.cgi'>
210 <table id='container' cellspacing=0>
211 <tr><td colspan=2 id='header'>
212 <div class='title'>Tomato</div>
213 <div class='version'>Version <% version(); %></div>
214 </td></tr>
215 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
216 <td id='content'>
217 <div id='ident'><% ident(); %></div>
218 <input type='hidden' name='_nextpage' value='advanced-access.asp'>
219 <input type='hidden' name='_nextwait' value='10'>
220 <input type='hidden' name='_service' value='firewall-restart'>
221 <input type='hidden' name='lan_access'>
223 <div class='section-title'>LAN Access</div>
224 <div class='section'>
225 <table class='tomato-grid' cellspacing=1 id='la-grid'></table>
226 </div>
227 </div>
229 <div>
230 <ul>
231 <li><b>Src</b> - Source LAN bridge.</li>
232 <li><b>Src Address</b> <i>(optional)</i> - Source address allowed. Ex: "1.2.3.4", "1.2.3.4 - 2.3.4.5", "1.2.3.0/24".</li>
233 <li><b>Dst</b> - Destination LAN bridge.</li>
234 <li><b>Dst Address</b> <i>(optional)</i> - Destination address inside the LAN.</li>
235 </ul>
236 </div>
238 </td></tr>
239 <tr><td id='footer' colspan=2>
240 <span id='footer-msg'></span>
241 <input type='button' value='Save' id='save-button' onclick='save()'>
242 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
243 </td></tr>
244 </table>
245 </form>
246 </body>
247 </html>