Fix nvram size for router with more than 32kB of nvram.
[tomato.git] / release / src / router / www / advanced-routing.asp
blob68af279ab5b3be223d0e820d814955f73ee52a0c
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(); %>] Advanced: Routing</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <% css(); %>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
20 <style type='text/css'>
21 #ara-grid .co1, #ara-grid .co2, #ara-grid .co3 {
22 width: 20%;
24 #ara-grid .co4 {
25 width: 6%;
27 #ara-grid .co5 {
28 width: 34%;
31 #ars-grid .co1, #ars-grid .co2, #ars-grid .co3 {
32 width: 20%;
34 #ars-grid .co4 {
35 width: 6%;
37 #ars-grid .co5 {
38 width: 10%;
40 #ars-grid .co6 {
41 width: 24%;
43 </style>
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() {
54 var i, a;
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) {
59 a = activeroutes[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) {
86 var r;
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]]);
91 this.showNewEditor();
92 this.resetNewEditor();
95 ars.resetNewEditor = function() {
96 var i, e;
98 e = fields.getAll(this.newEditor);
100 if(nvram.lan_ifname.length < 1)
101 e[4].options[0].disabled=true;
102 else
103 e[4].options[0].disabled=false;
104 if(nvram.lan1_ifname.length < 1)
105 e[4].options[1].disabled=true;
106 else
107 e[4].options[1].disabled=false;
108 if(nvram.lan2_ifname.length < 1)
109 e[4].options[2].disabled=true;
110 else
111 e[4].options[2].disabled=false;
112 if(nvram.lan3_ifname.length < 1)
113 e[4].options[3].disabled=true;
114 else
115 e[4].options[3].disabled=false;
117 ferror.clearAll(e);
118 for (i = 0; i < e.length; ++i) {
119 var f = e[i];
120 if (f.selectedIndex) f.selectedIndex = 0;
121 else f.value = '';
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;
143 return 1;
146 function save()
148 if (ars.isEditing()) return;
150 var fom = E('_fom');
151 var data = ars.getAllData();
152 var r = [];
153 for (var i = 0; i < data.length; ++i) r.push(data[i].join('<'));
154 fom.routes_static.value = r.join('>');
156 /* ZEBRA-BEGIN */
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';
164 /* ZEBRA-END */
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';
169 /* EMF-BEGIN */
170 fom.emf_enable.value = E('_f_emf').checked ? 1 : 0;
171 if (fom.emf_enable.value != nvram.emf_enable) fom._service.value = '*';
172 /* EMF-END */
174 form.submit(fom, 1);
177 function submit_complete()
179 reloadPage();
182 function earlyInit()
184 ara.setup();
185 ars.setup();
188 function init()
190 ara.recolor();
191 ars.recolor();
193 </script>
194 </head>
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>
201 </td></tr>
202 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
203 <td id='content'>
204 <div id='ident'><% ident(); %></div>
206 <!-- / / / -->
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>
228 </div>
230 <div class='section-title'>Static Routing Table</div>
231 <div class='section'>
232 <table class='tomato-grid' id='ars-grid'></table>
233 </div>
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 },
240 /* ZEBRA-BEGIN */
241 { title: 'RIPv1 &amp; 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 != '')) },
247 /* ZEBRA-END */
248 /* EMF-BEGIN */
249 { title: 'Efficient Multicast Forwarding', name: 'f_emf', type: 'checkbox', value: nvram.emf_enable != '0' },
250 /* EMF-END */
251 { title: 'DHCP Routes', name: 'f_dhcp_routes', type: 'checkbox', value: nvram.dhcp_routes != '0' },
253 </script>
254 </div>
257 <!-- / / / -->
259 </td></tr>
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();'>
264 </td></tr>
265 </table>
266 </form>
267 <script type='text/javascript'>earlyInit(); verifyFields(null, 1);</script>
268 </body>
269 </html>