SSID: Respect ASCII character Label.
[tomato.git] / release / src / router / www / qoslimit.asp
blob48ab70730cd150cf9e1af281eaf699caa874076a
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 Copyright (C) 2011 Deon 'PrinceAMD' Thomas
8 rate limit & connection limit from Conanxu,
9 adapted by Victek, Shibby, PrinceAMD, Phykris
11 For use with Tomato Firmware only.
12 No part of this file may be used without permission.
13 -->
14 <html>
15 <head>
16 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
17 <meta name='robots' content='noindex,nofollow'>
18 <title>[<% ident(); %>] Bandwidth Limiter</title>
19 <link rel='stylesheet' type='text/css' href='tomato.css'>
20 <link rel='stylesheet' type='text/css' href='color.css'>
21 <script type='text/javascript' src='tomato.js'></script>
23 <!-- / / / -->
24 <style type='text/css'>
25 #qosg-grid {
26 width: 100%;
28 #qosg-grid .co1 {
29 width: 30%;
31 #qosg-grid .co2,
32 #qosg-grid .co3,
33 #qosg-grid .co4,
34 #qosg-grid .co5,
35 #qosg-grid .co6,
36 #qosg-grid .co7,
37 #qosg-grid .co8 {
38 width: 10%;
40 </style>
42 <script type='text/javascript' src='debug.js'></script>
44 <script type='text/javascript'>
45 // <% nvram("qosl_enable,qos_ibw,qos_obw,qosl_rules,lan_ipaddr,lan_netmask"); %>
47 var class_prio = [['0','Highest'],['1','High'],['2','Normal'],['3','Low'],['4','Lowest']];
48 var class_tcp = [['0','nolimit']];
49 var class_udp = [['0','nolimit']];
50 for (var i = 1; i <= 100; ++i) {
51 class_tcp.push([i*10, i*10+'']);
52 class_udp.push([i, i + '/s']);
54 var qosg = new TomatoGrid();
56 qosg.setup = function() {
57 this.init('qosg-grid', '', 80, [
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(['IP or IP Range or MAC Address', 'DLRate', 'DLCeil', 'ULRate', 'ULCeil', 'Priority', 'TCP Limit', 'UDP Limit']);
67 var qoslimitrules = nvram.qosl_rules.split('>');
68 for (var i = 0; i < qoslimitrules.length; ++i) {
69 var t = qoslimitrules[i].split('<');
70 if (t.length == 8) this.insertData(-1, t);
72 this.showNewEditor();
73 this.resetNewEditor();
76 qosg.dataToView = function(data) {
77 return [data[0],data[1]+'kbps',data[2]+'kbps',data[3]+'kbps',data[4]+'kbps',class_prio[data[5]*1][1],class_tcp[data[6]*1/10][1],class_udp[data[7]*1][1]];
80 qosg.resetNewEditor = function() {
81 var f, c, n;
83 var f = fields.getAll(this.newEditor);
84 ferror.clearAll(f);
85 if ((c = cookie.get('addqoslimit')) != null) {
86 cookie.set('addqoslimit', '', 0);
87 c = c.split(',');
88 if (c.length == 2) {
89 f[0].value = c[0];
90 f[1].value = '';
91 f[2].value = '';
92 f[3].value = '';
93 f[4].value = '';
94 f[5].selectedIndex = '2';
95 f[6].selectedIndex = '0';
96 f[7].selectedIndex = '0';
97 return;
101 f[0].value = '';
102 f[1].value = '';
103 f[2].value = '';
104 f[3].value = '';
105 f[4].value = '';
106 f[5].selectedIndex = '2';
107 f[6].selectedIndex = '0';
108 f[7].selectedIndex = '0';
112 qosg.exist = function(f, v)
114 var data = this.getAllData();
115 for (var i = 0; i < data.length; ++i) {
116 if (data[i][f] == v) return true;
118 return false;
121 qosg.existID = function(id)
123 return this.exist(0, id);
126 qosg.existIP = function(ip)
128 if (ip == "0.0.0.0") return true;
129 return this.exist(1, ip);
132 qosg.checkRate = function(rate)
134 var s = parseInt(rate, 10);
135 if( isNaN(s) || s <= 0 || a >= 100000 ) return true;
136 return false;
139 qosg.checkRateCeil = function(rate, ceil)
141 var r = parseInt(rate, 10);
142 var c = parseInt(ceil, 10);
143 if( r > c ) return true;
144 return false;
147 qosg.verifyFields = function(row, quiet)
149 var ok = 1;
150 var f = fields.getAll(row);
151 var s;
153 if(v_macip(f[0], quiet, 0, nvram.lan_ipaddr, nvram.lan_netmask)) {
154 if(this.existIP(f[0].value)) {
155 ferror.set(f[0], 'duplicate IP or MAC address', quiet);
156 ok = 0;
160 if( this.checkRate(f[1].value)) {
161 ferror.set(f[1], 'DLRate must between 1 and 99999', quiet);
162 ok = 0;
165 if( this.checkRate(f[2].value)) {
166 ferror.set(f[2], 'DLCeil must between 1 and 99999', quiet);
167 ok = 0;
170 if( this.checkRateCeil(f[1].value, f[2].value)) {
171 ferror.set(f[2], 'DLCeil must be greater than DLRate', quiet);
172 ok = 0;
175 if( this.checkRate(f[3].value)) {
176 ferror.set(f[3], 'ULRate must between 1 and 99999', quiet);
177 ok = 0;
180 if( this.checkRate(f[4].value)) {
181 ferror.set(f[4], 'ULCeil must between 1 and 99999', quiet);
182 ok = 0;
185 if( this.checkRateCeil(f[3].value, f[4].value)) {
186 ferror.set(f[4], 'ULCeil must be greater than ULRate', quiet);
187 ok = 0;
190 return ok;
193 function verifyFields(focused, quiet)
195 var a = !E('_f_qosl_enable').checked;
197 E('_qos_ibw').disabled = a;
198 E('_qos_obw').disabled = a;
200 elem.display(PR('_qos_ibw'), PR('_qos_obw'), !a);
202 return 1;
205 function save()
207 if (qosg.isEditing()) return;
209 var data = qosg.getAllData();
210 var qoslimitrules = '';
211 var i;
213 if (data.length != 0) qoslimitrules += data[0].join('<');
214 for (i = 1; i < data.length; ++i) {
215 qoslimitrules += '>' + data[i].join('<');
218 var fom = E('_fom');
219 fom.qosl_enable.value = E('_f_qosl_enable').checked ? 1 : 0;
220 fom.qosl_rules.value = qoslimitrules;
221 form.submit(fom, 1);
224 function init()
226 qosg.recolor();
228 </script>
229 </head>
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>
236 </td></tr>
237 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
238 <td id='content'>
239 <div id='ident'><% ident(); %></div>
241 <!-- / / / -->
243 <input type='hidden' name='_nextpage' value='qos-qoslimit.asp'>
244 <input type='hidden' name='_nextwait' value='10'>
245 <input type='hidden' name='_service' value='qoslimit-restart'>
247 <input type='hidden' name='qosl_enable'>
248 <input type='hidden' name='qosl_rules'>
250 <div id='qoslimit'>
252 <div class='section-title'>Bandwidth Limiter</div>
253 <div class='section'>
254 <script type='text/javascript'>
255 createFieldTable('', [
256 { title: 'Enable Limiter', name: 'f_qosl_enable', type: 'checkbox', suffix: ' <i>(BW Limiter and QoS cannot work at once!)</i>', value: nvram.qosl_enable != '0' },
257 { title: 'Max Download Bandwidth <small>(same as used by QOS)', name: 'qos_ibw', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qos_ibw },
258 { title: 'Max Upload Bandwidth <small>(same as used by QOS)', name: 'qos_obw', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qos_obw }
260 </script>
261 <br>
262 <table class='tomato-grid' id='qosg-grid'></table>
263 <div>
264 <ul>
265 <li><b>IP Address / IP Range:</b>
266 <li>Example: 192.168.1.5 for one IP.
267 <li>Example: 192.168.1.4-7 for IP 192.168.1.4 to 192.168.1.7
268 <li>Example: 4-7 for IP Range .4 to .7
269 <li><b>The IP Range devices will share the Bandwidth</b>
270 <li><b>MAC Address</b> Example: 00:2E:3C:6A:22:D8
271 </ul>
272 </div>
273 </div>
275 <br>
277 <!-- / / / -->
279 </td></tr>
280 <tr><td id='footer' colspan=2>
281 <span id='footer-msg'></span>
282 <input type='button' value='Save' id='save-button' onclick='save()'>
283 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
284 </td></tr>
285 </table>
286 </form>
287 <script type='text/javascript'>qosg.setup(); verifyFields(null, 1);</script>
288 </body>
289 </html>