1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
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
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'
>
17 <script type='text/javascript' src='tomato.js'
></script>
18 <style type='text/css'
>
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
) {
61 var l
= r
[i
].split('<');
65 la
.insertData(-1, [ l
[0], l
[1], l
[2], l
[3], l
[4], l
[5] ] );
74 la
.sortCompare = function(a
, b
) {
75 var col
= this.sortColumn
;
76 var da
= a
.getRowData();
77 var db
= b
.getRowData();
83 r
= cmpIP(da
[col
], db
[col
]);
88 r
= cmpInt(da
[col
], db
[col
]);
91 r
= cmpText(da
[col
], db
[col
]);
95 return this.sortAscending
? r
: -r
;
98 la
.resetNewEditor = function() {
99 var f
= fields
.getAll(this.newEditor
);
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;
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
);
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;
151 f
[5].value
= f
[5].value
.replace(/>/g
, '_');
152 if (!v_nodelim(f
[5], quiet
, 'Description')) return 0;
157 la
.dataToView = function(data
) {
158 return [(data
[0] != 0) ? 'On' : '',
159 ['LAN', 'LAN1', 'LAN2', 'LAN3'][data
[1]],
161 ['LAN', 'LAN1', 'LAN2', 'LAN3'][data
[3]],
166 la
.dataToFieldValues = function (data
) {
167 return [(data
[0] != 0) ? 'checked' : '',
175 la
.fieldValuesToData = function(row
) {
176 var f
= fields
.getAll(row
);
177 return [f
[0].checked
? 1 : 0,
187 if (la
.isEditing()) return;
191 var ladata
= la
.getAllData();
194 for (var i
= 0; i
< ladata
.length
; ++i
) {
195 s
+= ladata
[i
].join('<') + '>';
197 fom
.lan_access
.value
= s
;
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>
215 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
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>
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>
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();'
>