fix "IP outside LAN" warning
[tomato.git] / release / src / router / www / new-qoslimit.asp
blobea9da5d6bf2a88457585dc00f634c18d1787f68d
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2008 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(); %>] New: QoS Limit</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 #qosg-grid {
22 width: 100%;
24 #qosg-grid .co1 {
25 width: 5%;
27 #qosg-grid .co2 {
28 width: 25%;
30 #qosg-grid .co3,
31 #qosg-grid .co4,
32 #qosg-grid .co5,
33 #qosg-grid .co6,
34 #qosg-grid .co7,
35 #qosg-grid .co8,
36 #qosg-grid .co9 {
37 width: 10%;
39 </style>
41 <script type='text/javascript' src='debug.js'></script>
43 <script type='text/javascript'>
44 // <% nvram("new_qoslimit_enable,qos_ibw,qos_obw,new_qoslimit_rules,lan_ipaddr,lan_netmask"); %>
46 var class_prio = [['0','Highest'],['1','High'],['2','Normal'],['3','Low'],['4','Lowest']];
47 var class_tcp = [['0','nolimit']];
48 var class_udp = [['0','nolimit']];
49 for (var i = 1; i <= 100; ++i) {
50 class_tcp.push([i*10, i*10+'']);
51 class_udp.push([i, i + '/s']);
53 var qosg = new TomatoGrid();
55 qosg.setup = function() {
56 this.init('qosg-grid', '', 40, [
57 { type: 'text', maxlen: 2 },
58 { type: 'text', maxlen: 31 },
59 { type: 'text', maxlen: 6 },
60 { type: 'text', maxlen: 6 },
61 { type: 'text', maxlen: 6 },
62 { type: 'text', maxlen: 6 },
63 { type: 'select', options: class_prio },
64 { type: 'select', options: class_tcp },
65 { type: 'select', options: class_udp }]);
66 this.headerSet(['TC Tag', 'IP | IP Range | MAC Address', 'DLRate', 'DLCeil', 'ULRate', 'ULCeil', 'Priority', 'TCP Limit', 'UDP Limit']);
67 var qoslimitrules = nvram.new_qoslimit_rules.split('>');
68 for (var i = 0; i < qoslimitrules.length; ++i) {
69 var t = qoslimitrules[i].split('<');
70 if (t.length == 9) this.insertData(-1, t);
72 this.showNewEditor();
73 this.resetNewEditor();
76 qosg.dataToView = function(data) {
77 return [data[0],data[1],data[2]+'kbps',data[3]+'kbps',data[4]+'kbps',data[5]+'kbps',class_prio[data[6]*1][1],class_tcp[data[7]*1/10][1],class_udp[data[8]*1][1]];
80 qosg.resetNewEditor = function() {
81 var f = fields.getAll(this.newEditor);
82 var data = this.getAllData();
83 var tag = '9';
85 for (var i = 0; i < data.length; ++i) {
86 if (parseInt(data[i][0], 10) > parseInt(tag, 10))
87 tag = data[i][0];
90 tag = parseInt(tag, 10)+1;
92 f[0].value = tag+'';
93 f[1].value = '';
94 f[2].value = '';
95 f[3].value = '';
96 f[4].value = '';
97 f[5].value = '';
98 f[6].selectedIndex = '2';
99 f[7].selectedIndex = '0';
100 f[8].selectedIndex = '0';
101 ferror.clearAll(fields.getAll(this.newEditor));
104 qosg.exist = function(f, v)
106 var data = this.getAllData();
107 for (var i = 0; i < data.length; ++i) {
108 if (data[i][f] == v) return true;
110 return false;
113 qosg.existID = function(id)
115 return this.exist(0, id);
118 qosg.existIP = function(ip)
120 if (ip == "0.0.0.0") return true;
121 return this.exist(1, ip);
124 qosg.checkRate = function(rate)
126 var s = parseInt(rate, 10);
127 if( isNaN(s) || s <= 0 || a >= 100000 ) return true;
128 return false;
131 qosg.checkRateCeil = function(rate, ceil)
133 var r = parseInt(rate, 10);
134 var c = parseInt(ceil, 10);
135 if( r > c ) return true;
136 return false;
139 qosg.verifyFields = function(row, quiet)
141 var ok = 1;
142 var f = fields.getAll(row);
143 var s;
145 if (v_range(f[0], quiet, 10, 99)) {
146 if(this.existID(f[0].value)) {
147 ferror.set(f[0], 'ID must between 10 and 99', quiet);
148 ok = 0;
152 if (v_ip(f[1], quiet)) {
153 if(this.existIP(f[1].value)) {
154 ferror.set(f[1], 'duplicate IP address', quiet);
155 ok = 0;
159 if(v_macip(f[1], quiet, 0, nvram.lan_ipaddr, nvram.lan_netmask)) {
160 if(this.existIP(f[1].value)) {
161 ferror.set(f[1], 'duplicate MAC address', quiet);
162 ok = 0;
166 if( this.checkRate(f[2].value)) {
167 ferror.set(f[2], 'DLRate must between 1 and 99999', quiet);
168 ok = 0;
171 if( this.checkRate(f[3].value)) {
172 ferror.set(f[3], 'DLCeil must between 1 and 99999', quiet);
173 ok = 0;
176 if( this.checkRateCeil(f[2].value, f[3].value)) {
177 ferror.set(f[3], 'DLCeil must be greater than DLRate', quiet);
178 ok = 0;
181 if( this.checkRate(f[4].value)) {
182 ferror.set(f[4], 'ULRate must between 1 and 99999', quiet);
183 ok = 0;
186 if( this.checkRate(f[5].value)) {
187 ferror.set(f[5], 'ULCeil must between 1 and 99999', quiet);
188 ok = 0;
191 if( this.checkRateCeil(f[4].value, f[5].value)) {
192 ferror.set(f[5], 'ULCeil must be greater than ULRate', quiet);
193 ok = 0;
196 return ok;
199 function verifyFields(focused, quiet)
201 return 1;
204 function save()
206 if (qosg.isEditing()) return;
208 var data = qosg.getAllData();
209 var qoslimitrules = '';
210 var i;
212 if (data.length != 0) qoslimitrules += data[0].join('<');
213 for (i = 1; i < data.length; ++i) {
214 qoslimitrules += '>' + data[i].join('<');
217 var fom = E('_fom');
218 fom.new_qoslimit_enable.value = E('_f_new_qoslimit_enable').checked ? 1 : 0;
219 fom.new_qoslimit_rules.value = qoslimitrules;
220 form.submit(fom, 1);
223 function init()
225 qosg.recolor();
227 </script>
228 </head>
229 <body onload='init()'>
230 <form id='_fom' method='post' action='tomato.cgi'>
231 <table id='container' cellspacing=0>
232 <tr><td colspan=2 id='header'>
233 <div class='title'>Tomato</div>
234 <div class='version'>Version <% version(); %></div>
235 </td></tr>
236 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
237 <td id='content'>
238 <div id='ident'><% ident(); %></div>
240 <!-- / / / -->
242 <input type='hidden' name='_nextpage' value='new-qoslimit.asp'>
243 <input type='hidden' name='_nextwait' value='10'>
244 <input type='hidden' name='_service' value='qoslimit-restart'>
246 <input type='hidden' name='new_qoslimit_enable'>
247 <input type='hidden' name='new_qoslimit_rules'>
249 <div class='section-title'>QoS Limit</div>
250 <div class='section'>
251 <script type='text/javascript'>
252 createFieldTable('', [
253 { title: 'Enable Limiter', name: 'f_new_qoslimit_enable', type: 'checkbox', value: nvram.new_qoslimit_enable != '0' },
254 { title: 'Set Max Available Download Bandwidth <small>(also used for QOS)', name: 'qos_ibw', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qos_ibw },
255 { title: 'Set Max Available Upload Bandwidth <small>(also used for QOS)', name: 'qos_obw', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qos_obw }
257 </script>
258 <br>
259 <table class='tomato-grid' id='qosg-grid'></table>
260 </div>
262 <!-- / / / -->
264 </td></tr>
265 <tr><td id='footer' colspan=2>
266 <span id='footer-msg'></span>
267 <input type='button' value='Save' id='save-button' onclick='save()'>
268 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
269 </td></tr>
270 </table>
271 </form>
272 <script type='text/javascript'>qosg.setup();</script>
273 </body>
274 </html>