Tomato 1.28
[tomato/tomato-null.git] / release / src / router / www / advanced-routing.asp
blobe62cfda04b807f393a39daa1535e9917523832bc
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 <link rel='stylesheet' type='text/css' href='color.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: 15%;
24 #ara-grid .co4 {
25 width: 6%;
27 #ara-grid .co5 {
28 width: 49%;
31 #ars-grid .co1, #ars-grid .co2, #ars-grid .co3 {
32 width: 15%;
34 #ars-grid .co4 {
35 width: 6%;
37 #ars-grid .co5 {
38 width: 10%;
40 #ars-grid .co6 {
41 width: 39%;
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,lan_ifname,wan_ifname"); %>
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', '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.wan_ifname) a[0] += ' (WAN)';
62 this.insertData(-1, [a[1],a[2],a[3],a[4],a[0]]);
67 var ars = new TomatoGrid();
69 ars.verifyFields = function(row, quiet) {
70 var f = fields.getAll(row);
71 f[5].value = f[5].value.replace('>', '_');
72 return v_ip(f[0], quiet) && v_ip(f[1], quiet) && v_netmask(f[2], quiet) && v_range(f[3], quiet, 0, 10);
75 ars.setup = function() {
76 this.init('ars-grid', '', 20, [
77 { type: 'text', maxlen: 15 }, { type: 'text', maxlen: 15 }, { type: 'text', maxlen: 15 },
78 { type: 'text', maxlen: 3 }, { type: 'select', options: [['LAN','LAN'],['WAN','WAN']] }, { type: 'text', maxlen: 32 }]);
79 this.headerSet(['Destination', 'Gateway', 'Subnet Mask', 'Metric', 'Interface', 'Description']);
80 var routes = nvram.routes_static.split('>');
81 for (var i = 0; i < routes.length; ++i) {
82 var r;
83 if (r = routes[i].match(/^(.+)<(.+)<(.+)<(\d+)<(LAN|WAN)<(.*)$/)) {
84 this.insertData(-1, [r[1], r[2], r[3], r[4], r[5],r[6]]);
87 this.showNewEditor();
88 this.resetNewEditor();
92 function verifyFields(focused, quiet)
94 return 1;
97 function save()
99 if (ars.isEditing()) return;
101 var fom = E('_fom');
102 var data = ars.getAllData();
103 var r = [];
104 for (var i = 0; i < data.length; ++i) r.push(data[i].join('<'));
105 fom.routes_static.value = r.join('>');
107 var wan = '0';
108 var lan = '0';
109 switch (E('_dr_setting').value) {
110 case '1':
111 lan = '1 2';
112 break;
113 case '2':
114 wan = '1 2';
115 break;
116 case '3':
117 lan = '1 2';
118 wan = '1 2';
119 break;
121 fom.dr_lan_tx.value = fom.dr_lan_rx.value = lan;
122 fom.dr_wan_tx.value = fom.dr_wan_rx.value = wan;
124 fom.lan_stp.value = E('_f_stp').checked ? 1 : 0;
126 form.submit(fom, 1);
129 function earlyInit()
131 ara.setup();
132 ars.setup();
135 function init()
137 ara.recolor();
138 ars.recolor();
140 </script>
141 </head>
142 <body onload='init()'>
143 <form id='_fom' method='post' action='tomato.cgi'>
144 <table id='container' cellspacing=0>
145 <tr><td colspan=2 id='header'>
146 <div class='title'>Tomato</div>
147 <div class='version'>Version <% version(); %></div>
148 </td></tr>
149 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
150 <td id='content'>
151 <div id='ident'><% ident(); %></div>
153 <!-- / / / -->
155 <input type='hidden' name='_nextpage' value='advanced-routing.asp'>
156 <input type='hidden' name='_service' value='routing-restart'>
158 <input type='hidden' name='routes_static'>
159 <input type='hidden' name='lan_stp'>
160 <input type='hidden' name='dr_lan_tx'>
161 <input type='hidden' name='dr_lan_rx'>
162 <input type='hidden' name='dr_wan_tx'>
163 <input type='hidden' name='dr_wan_rx'>
165 <div class='section-title'>Current Routing Table</div>
166 <div class='section'>
167 <table class='tomato-grid' id='ara-grid'></table>
168 </div>
170 <div class='section-title'>Static Routing Table</div>
171 <div class='section'>
172 <table class='tomato-grid' id='ars-grid'></table>
173 </div>
175 <div class='section-title'>Miscellaneous</div>
176 <div class='section'>
177 <script type='text/javascript'>
178 createFieldTable('', [
179 { title: 'Mode', name: 'wk_mode', type: 'select', options: [['gateway','Gateway'],['router','Router']], value: nvram.wk_mode },
180 { title: 'RIPv1 &amp; v2', name: 'dr_setting', type: 'select', options: [[0,'Disabled'],[1,'LAN'],[2,'WAN'],[3,'Both']], value: nvram.dr_setting },
181 { title: 'Spanning-Tree Protocol', name: 'f_stp', type: 'checkbox', value: nvram.lan_stp != '0' },
183 </script>
184 </div>
187 <!-- / / / -->
189 </td></tr>
190 <tr><td id='footer' colspan=2>
191 <span id='footer-msg'></span>
192 <input type='button' value='Save' id='save-button' onclick='save()'>
193 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
194 </td></tr>
195 </table>
196 </form>
197 <script type='text/javascript'>earlyInit()</script>
198 </body>
199 </html>