1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
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.
12 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
13 <meta name='robots' content='noindex,nofollow'
>
14 <title>[<%
ident(); %>] Advanced: Routing
</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'
>
17 <script type='text/javascript' src='tomato.js'
></script>
20 <style type='text/css'
>
21 #ara-grid .co1
, #ara-grid
.co2
, #ara-grid
.co3
{
31 #ars-grid .co1
, #ars-grid
.co2
, #ars-grid
.co3
{
45 <script type='text/javascript' src='debug.js'
></script>
47 <script type='text/javascript'
>
48 // <% nvram("wk_mode,dr_setting,lan_stp,routes_static,dhcp_routes,lan_ifname,lan1_ifname,lan2_ifname,lan3_ifname,wan_ifname,wan_iface,emf_enable,dr_lan_rx,dr_lan1_rx,dr_lan2_rx,dr_lan3_rx,dr_wan_rx,wan_proto"); %>
49 // <% activeroutes(); %>
51 var ara
= new TomatoGrid();
53 ara
.setup = function() {
56 this.init('ara-grid', 'sort');
57 this.headerSet(['Destination', 'Gateway / Next Hop', 'Subnet Mask', 'Metric', 'Interface']);
58 for (i
= 0; i
< activeroutes
.length
; ++i
) {
60 if (a
[0] == nvram
.lan_ifname
) a
[0] += ' (LAN)';
61 else if (a
[0] == nvram
.lan1_ifname
) a
[0] += ' (LAN1)';
62 else if (a
[0] == nvram
.lan2_ifname
) a
[0] += ' (LAN2)';
63 else if (a
[0] == nvram
.lan3_ifname
) a
[0] += ' (LAN3)';
64 else if (a
[0] == nvram
.wan_iface
) a
[0] += ' (WAN)';
65 else if (a
[0] == nvram
.wan_ifname
) a
[0] += ' (MAN)';
66 this.insertData(-1, [a
[1],a
[2],a
[3],a
[4],a
[0]]);
70 var ars
= new TomatoGrid();
72 ars
.verifyFields = function(row
, quiet
) {
73 var f
= fields
.getAll(row
);
74 f
[5].value
= f
[5].value
.replace('>', '_');
75 return v_ip(f
[0], quiet
) && v_ip(f
[1], quiet
) && v_netmask(f
[2], quiet
) && v_range(f
[3], quiet
, 0, 10) && v_nodelim(f
[5], quiet
, 'Description');
78 ars
.setup = function() {
79 this.init('ars-grid', '', 20, [
80 { type
: 'text', maxlen
: 15 }, { type
: 'text', maxlen
: 15 }, { type
: 'text', maxlen
: 15 },
82 { type
: 'text', maxlen
: 3 }, { type
: 'select', options
: [['LAN','LAN'],['LAN1','LAN1'],['LAN2','LAN2'],['LAN3','LAN3'],['WAN','WAN'],['MAN','MAN']] }, { type
: 'text', maxlen
: 32 }]);
85 { type
: 'text', maxlen
: 3 }, { type
: 'select', options
: [['LAN','LAN'],['WAN','WAN'],['MAN','MAN']] }, { type
: 'text', maxlen
: 32 }]);
88 this.headerSet(['Destination', 'Gateway', 'Subnet Mask', 'Metric', 'Interface', 'Description']);
89 var routes
= nvram
.routes_static
.split('>');
90 for (var i
= 0; i
< routes
.length
; ++i
) {
92 if (r
= routes
[i
].match(/^(.+)<(.+)<(.+)<(\d+)<(LAN|LAN1|LAN2|LAN3|WAN|MAN)<(.*)$/)) {
93 this.insertData(-1, [r
[1], r
[2], r
[3], r
[4], r
[5],r
[6]]);
97 this.resetNewEditor();
100 ars
.resetNewEditor = function() {
103 e
= fields
.getAll(this.newEditor
);
106 if(nvram
.lan_ifname
.length
< 1)
107 e
[4].options
[0].disabled
=true;
109 e
[4].options
[0].disabled
=false;
110 if(nvram
.lan1_ifname
.length
< 1)
111 e
[4].options
[1].disabled
=true;
113 e
[4].options
[1].disabled
=false;
114 if(nvram
.lan2_ifname
.length
< 1)
115 e
[4].options
[2].disabled
=true;
117 e
[4].options
[2].disabled
=false;
118 if(nvram
.lan3_ifname
.length
< 1)
119 e
[4].options
[3].disabled
=true;
121 e
[4].options
[3].disabled
=false;
125 for (i
= 0; i
< e
.length
; ++i
) {
127 if (f
.selectedIndex
) f
.selectedIndex
= 0;
130 try { if (e
.length
) e
[0].focus(); } catch (er
) { }
133 function verifyFields(focused
, quiet
)
136 E('_f_dr_lan').disabled
= (nvram
.lan_ifname
.length
< 1);
137 if (E('_f_dr_lan').disabled
)
138 E('_f_dr_lan').checked
= false;
139 E('_f_dr_lan1').disabled
= (nvram
.lan1_ifname
.length
< 1);
140 if (E('_f_dr_lan1').disabled
)
141 E('_f_dr_lan1').checked
= false;
142 E('_f_dr_lan2').disabled
= (nvram
.lan2_ifname
.length
< 1);
143 if (E('_f_dr_lan2').disabled
)
144 E('_f_dr_lan2').checked
= false;
145 E('_f_dr_lan3').disabled
= (nvram
.lan3_ifname
.length
< 1);
146 if (E('_f_dr_lan3').disabled
)
147 E('_f_dr_lan3').checked
= false;
148 E('_f_dr_wan').disabled
= (nvram
.wan_proto
.length
== 'disabled');
149 if (E('_f_dr_wan').disabled
)
150 E('_f_dr_wan').checked
= false;
157 if (ars
.isEditing()) return;
160 var data
= ars
.getAllData();
162 for (var i
= 0; i
< data
.length
; ++i
) r
.push(data
[i
].join('<'));
163 fom
.routes_static
.value
= r
.join('>');
171 switch (E('_dr_setting').value
) {
183 fom
.dr_lan_tx
.value
= fom
.dr_lan_rx
.value
= lan
;
184 fom
.dr_wan_tx
.value
= fom
.dr_wan_rx
.value
= wan
;
188 fom
.dr_lan_tx
.value
= fom
.dr_lan_rx
.value
= (E('_f_dr_lan').checked
) ? '1 2' : '0';
189 fom
.dr_lan1_tx
.value
= fom
.dr_lan1_rx
.value
= (E('_f_dr_lan1').checked
) ? '1 2' : '0';
190 fom
.dr_lan2_tx
.value
= fom
.dr_lan2_rx
.value
= (E('_f_dr_lan2').checked
) ? '1 2' : '0';
191 fom
.dr_lan3_tx
.value
= fom
.dr_lan3_rx
.value
= (E('_f_dr_lan3').checked
) ? '1 2' : '0';
192 fom
.dr_wan_tx
.value
= fom
.dr_wan_rx
.value
= (E('_f_dr_wan').checked
) ? '1 2' : '0';
198 fom
.lan_stp
.value
= E('_f_stp').checked
? 1 : 0;
201 fom
.dhcp_routes
.value
= E('_f_dhcp_routes').checked
? '1' : '0';
202 fom
._service
.value
= (fom
.dhcp_routes
.value
!= nvram
.dhcp_routes
) ? 'wan-restart' : 'routing-restart';
205 fom
.emf_enable
.value
= E('_f_emf').checked
? 1 : 0;
206 if (fom
.emf_enable
.value
!= nvram
.emf_enable
) fom
._service
.value
= '*';
212 function submit_complete()
230 <body onload='init()'
>
231 <form id='_fom' method='post' action='tomato.cgi'
>
232 <table id='container' cellspacing=
0>
233 <tr><td colspan=
2 id='header'
>
234 <div class='title'
>Tomato
</div>
235 <div class='version'
>Version <%
version(); %></div>
237 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
239 <div id='ident'
><%
ident(); %></div>
243 <input type='hidden' name='_nextpage' value='advanced-routing.asp'
>
244 <input type='hidden' name='_service' value='routing-restart'
>
246 <input type='hidden' name='routes_static'
>
247 <input type='hidden' name='dhcp_routes'
>
248 <input type='hidden' name='emf_enable'
>
249 <!-- NOVLAN-BEGIN -->
250 <input type='hidden' name='lan_stp'
>
252 <input type='hidden' name='dr_lan_tx'
>
253 <input type='hidden' name='dr_lan_rx'
>
255 <input type='hidden' name='dr_lan1_tx'
>
256 <input type='hidden' name='dr_lan1_rx'
>
257 <input type='hidden' name='dr_lan2_tx'
>
258 <input type='hidden' name='dr_lan2_rx'
>
259 <input type='hidden' name='dr_lan3_tx'
>
260 <input type='hidden' name='dr_lan3_rx'
>
262 <input type='hidden' name='dr_wan_tx'
>
263 <input type='hidden' name='dr_wan_rx'
>
265 <div class='section-title'
>Current Routing Table
</div>
266 <div class='section'
>
267 <table class='tomato-grid' id='ara-grid'
></table>
270 <div class='section-title'
>Static Routing Table
</div>
271 <div class='section'
>
272 <table class='tomato-grid' id='ars-grid'
></table>
275 <div class='section-title'
>Miscellaneous
</div>
276 <div class='section'
>
277 <script type='text/javascript'
>
278 createFieldTable('', [
279 { title
: 'Mode', name
: 'wk_mode', type
: 'select', options
: [['gateway','Gateway'],['router','Router']], value
: nvram
.wk_mode
},
282 { title
: 'RIPv1 & v2' },
283 { title
: 'LAN', indent
: 2, name
: 'f_dr_lan', type
: 'checkbox', value
: ((nvram
.dr_lan_rx
!= '0') && (nvram
.dr_lan_rx
!= '')) },
284 { title
: 'LAN1', indent
: 2, name
: 'f_dr_lan1', type
: 'checkbox', value
: ((nvram
.dr_lan1_rx
!= '0') && (nvram
.dr_lan1_rx
!= '')) },
285 { title
: 'LAN2', indent
: 2, name
: 'f_dr_lan2', type
: 'checkbox', value
: ((nvram
.dr_lan2_rx
!= '0') && (nvram
.dr_lan2_rx
!= '')) },
286 { title
: 'LAN3', indent
: 2, name
: 'f_dr_lan3', type
: 'checkbox', value
: ((nvram
.dr_lan3_rx
!= '0') && (nvram
.dr_lan3_rx
!= '')) },
287 { title
: 'WAN', indent
: 2, name
: 'f_dr_wan', type
: 'checkbox', value
: ((nvram
.dr_wan_rx
!= '0') && (nvram
.dr_wan_rx
!= '')) },
290 { title
: 'RIPv1 & v2', name
: 'dr_setting', type
: 'select', options
: [[0,'Disabled'],[1,'LAN'],[2,'WAN'],[3,'Both']], value
: nvram
.dr_setting
},
294 { title
: 'Efficient Multicast Forwarding', name
: 'f_emf', type
: 'checkbox', value
: nvram
.emf_enable
!= '0' },
296 { title
: 'DHCP Routes', name
: 'f_dhcp_routes', type
: 'checkbox', value
: nvram
.dhcp_routes
!= '0' },
298 { title
: 'Spanning-Tree Protocol', name
: 'f_stp', type
: 'checkbox', value
: nvram
.lan_stp
!= '0' }
308 <tr><td id='footer' colspan=
2>
309 <span id='footer-msg'
></span>
310 <input type='button' value='Save' id='save-button' onclick='save()'
>
311 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'
>
315 <script type='text/javascript'
>earlyInit(); verifyFields(null, 1);</script>