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 },
81 { type
: 'text', maxlen
: 3 }, { type
: 'select', options
: [['LAN','LAN'],['LAN1','LAN1'],['LAN2','LAN2'],['LAN3','LAN3'],['WAN','WAN'],['MAN','MAN']] }, { type
: 'text', maxlen
: 32 }]);
83 this.headerSet(['Destination', 'Gateway', 'Subnet Mask', 'Metric', 'Interface', 'Description']);
84 var routes
= nvram
.routes_static
.split('>');
85 for (var i
= 0; i
< routes
.length
; ++i
) {
87 if (r
= routes
[i
].match(/^(.+)<(.+)<(.+)<(\d+)<(LAN|LAN1|LAN2|LAN3|WAN|MAN)<(.*)$/)) {
88 this.insertData(-1, [r
[1], r
[2], r
[3], r
[4], r
[5],r
[6]]);
92 this.resetNewEditor();
95 ars
.resetNewEditor = function() {
98 e
= fields
.getAll(this.newEditor
);
100 if(nvram
.lan_ifname
.length
< 1)
101 e
[4].options
[0].disabled
=true;
103 e
[4].options
[0].disabled
=false;
104 if(nvram
.lan1_ifname
.length
< 1)
105 e
[4].options
[1].disabled
=true;
107 e
[4].options
[1].disabled
=false;
108 if(nvram
.lan2_ifname
.length
< 1)
109 e
[4].options
[2].disabled
=true;
111 e
[4].options
[2].disabled
=false;
112 if(nvram
.lan3_ifname
.length
< 1)
113 e
[4].options
[3].disabled
=true;
115 e
[4].options
[3].disabled
=false;
118 for (i
= 0; i
< e
.length
; ++i
) {
120 if (f
.selectedIndex
) f
.selectedIndex
= 0;
123 try { if (e
.length
) e
[0].focus(); } catch (er
) { }
126 function verifyFields(focused
, quiet
)
128 E('_f_dr_lan').disabled
= (nvram
.lan_ifname
.length
< 1);
129 if (E('_f_dr_lan').disabled
)
130 E('_f_dr_lan').checked
= false;
131 E('_f_dr_lan1').disabled
= (nvram
.lan1_ifname
.length
< 1);
132 if (E('_f_dr_lan1').disabled
)
133 E('_f_dr_lan1').checked
= false;
134 E('_f_dr_lan2').disabled
= (nvram
.lan2_ifname
.length
< 1);
135 if (E('_f_dr_lan2').disabled
)
136 E('_f_dr_lan2').checked
= false;
137 E('_f_dr_lan3').disabled
= (nvram
.lan3_ifname
.length
< 1);
138 if (E('_f_dr_lan3').disabled
)
139 E('_f_dr_lan3').checked
= false;
140 E('_f_dr_wan').disabled
= (nvram
.wan_proto
.length
== 'disabled');
141 if (E('_f_dr_wan').disabled
)
142 E('_f_dr_wan').checked
= false;
148 if (ars
.isEditing()) return;
151 var data
= ars
.getAllData();
153 for (var i
= 0; i
< data
.length
; ++i
) r
.push(data
[i
].join('<'));
154 fom
.routes_static
.value
= r
.join('>');
158 fom
.dr_lan_tx
.value
= fom
.dr_lan_rx
.value
= (E('_f_dr_lan').checked
) ? '1 2' : '0';
159 fom
.dr_lan1_tx
.value
= fom
.dr_lan1_rx
.value
= (E('_f_dr_lan1').checked
) ? '1 2' : '0';
160 fom
.dr_lan2_tx
.value
= fom
.dr_lan2_rx
.value
= (E('_f_dr_lan2').checked
) ? '1 2' : '0';
161 fom
.dr_lan3_tx
.value
= fom
.dr_lan3_rx
.value
= (E('_f_dr_lan3').checked
) ? '1 2' : '0';
162 fom
.dr_wan_tx
.value
= fom
.dr_wan_rx
.value
= (E('_f_dr_wan').checked
) ? '1 2' : '0';
166 fom
.dhcp_routes
.value
= E('_f_dhcp_routes').checked
? '1' : '0';
167 fom
._service
.value
= (fom
.dhcp_routes
.value
!= nvram
.dhcp_routes
) ? 'wan-restart' : 'routing-restart';
170 fom
.emf_enable
.value
= E('_f_emf').checked
? 1 : 0;
171 if (fom
.emf_enable
.value
!= nvram
.emf_enable
) fom
._service
.value
= '*';
177 function submit_complete()
195 <body onload='init()'
>
196 <form id='_fom' method='post' action='tomato.cgi'
>
197 <table id='container' cellspacing=
0>
198 <tr><td colspan=
2 id='header'
>
199 <div class='title'
>Tomato
</div>
200 <div class='version'
>Version <%
version(); %></div>
202 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
204 <div id='ident'
><%
ident(); %></div>
208 <input type='hidden' name='_nextpage' value='advanced-routing.asp'
>
209 <input type='hidden' name='_service' value='routing-restart'
>
211 <input type='hidden' name='routes_static'
>
212 <input type='hidden' name='dhcp_routes'
>
213 <input type='hidden' name='emf_enable'
>
214 <input type='hidden' name='dr_lan_tx'
>
215 <input type='hidden' name='dr_lan_rx'
>
216 <input type='hidden' name='dr_lan1_tx'
>
217 <input type='hidden' name='dr_lan1_rx'
>
218 <input type='hidden' name='dr_lan2_tx'
>
219 <input type='hidden' name='dr_lan2_rx'
>
220 <input type='hidden' name='dr_lan3_tx'
>
221 <input type='hidden' name='dr_lan3_rx'
>
222 <input type='hidden' name='dr_wan_tx'
>
223 <input type='hidden' name='dr_wan_rx'
>
225 <div class='section-title'
>Current Routing Table
</div>
226 <div class='section'
>
227 <table class='tomato-grid' id='ara-grid'
></table>
230 <div class='section-title'
>Static Routing Table
</div>
231 <div class='section'
>
232 <table class='tomato-grid' id='ars-grid'
></table>
235 <div class='section-title'
>Miscellaneous
</div>
236 <div class='section'
>
237 <script type='text/javascript'
>
238 createFieldTable('', [
239 { title
: 'Mode', name
: 'wk_mode', type
: 'select', options
: [['gateway','Gateway'],['router','Router']], value
: nvram
.wk_mode
},
241 { title
: 'RIPv1 & v2' },
242 { title
: 'LAN', indent
: 2, name
: 'f_dr_lan', type
: 'checkbox', value
: ((nvram
.dr_lan_rx
!= '0') && (nvram
.dr_lan_rx
!= '')) },
243 { title
: 'LAN1', indent
: 2, name
: 'f_dr_lan1', type
: 'checkbox', value
: ((nvram
.dr_lan1_rx
!= '0') && (nvram
.dr_lan1_rx
!= '')) },
244 { title
: 'LAN2', indent
: 2, name
: 'f_dr_lan2', type
: 'checkbox', value
: ((nvram
.dr_lan2_rx
!= '0') && (nvram
.dr_lan2_rx
!= '')) },
245 { title
: 'LAN3', indent
: 2, name
: 'f_dr_lan3', type
: 'checkbox', value
: ((nvram
.dr_lan3_rx
!= '0') && (nvram
.dr_lan3_rx
!= '')) },
246 { title
: 'WAN', indent
: 2, name
: 'f_dr_wan', type
: 'checkbox', value
: ((nvram
.dr_wan_rx
!= '0') && (nvram
.dr_wan_rx
!= '')) },
249 { title
: 'Efficient Multicast Forwarding', name
: 'f_emf', type
: 'checkbox', value
: nvram
.emf_enable
!= '0' },
251 { title
: 'DHCP Routes', name
: 'f_dhcp_routes', type
: 'checkbox', value
: nvram
.dhcp_routes
!= '0' },
260 <tr><td id='footer' colspan=
2>
261 <span id='footer-msg'
></span>
262 <input type='button' value='Save' id='save-button' onclick='save()'
>
263 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'
>
267 <script type='text/javascript'
>earlyInit(); verifyFields(null, 1);</script>