MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / www / new-qoslimit.asp
blob233070cd7197f853df6b80298e710bf1903b75bf
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(); %>] New: IP/Range BW 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("new_qoslimit_enable,qos_ibw,qos_obw,new_qoslimit_rules,lan_ipaddr,lan_netmask,qosl_enable,qosl_dlr,qosl_dlc,qosl_ulr,qosl_ulc,qosl_udp,qosl_tcp"); %>
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', '', 40, [
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 | 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 == 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('addbwlimit')) != null) {
86 cookie.set('addbwlimit', '', 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;
154 if (v_ip(f[0], quiet)) {
155 if(this.existIP(f[0].value)) {
156 ferror.set(f[0], 'duplicate IP address', quiet);
157 ok = 0;
161 if(v_macip(f[0], quiet, 0, nvram.lan_ipaddr, nvram.lan_netmask)) {
162 if(this.existIP(f[0].value)) {
163 ferror.set(f[0], 'duplicate IP or MAC address', quiet);
164 ok = 0;
168 if( this.checkRate(f[1].value)) {
169 ferror.set(f[1], 'DLRate must between 1 and 99999', quiet);
170 ok = 0;
173 if( this.checkRate(f[2].value)) {
174 ferror.set(f[2], 'DLCeil must between 1 and 99999', quiet);
175 ok = 0;
178 if( this.checkRateCeil(f[1].value, f[2].value)) {
179 ferror.set(f[2], 'DLCeil must be greater than DLRate', quiet);
180 ok = 0;
183 if( this.checkRate(f[3].value)) {
184 ferror.set(f[3], 'ULRate must between 1 and 99999', quiet);
185 ok = 0;
188 if( this.checkRate(f[4].value)) {
189 ferror.set(f[4], 'ULCeil must between 1 and 99999', quiet);
190 ok = 0;
193 if( this.checkRateCeil(f[3].value, f[4].value)) {
194 ferror.set(f[4], 'ULCeil must be greater than ULRate', quiet);
195 ok = 0;
198 return ok;
201 function verifyFields(focused, quiet)
203 var a = !E('_f_new_qoslimit_enable').checked;
204 var b = !E('_f_qosl_enable').checked;
206 E('_qos_ibw').disabled = a;
207 E('_qos_obw').disabled = a;
208 E('_f_qosl_enable').disabled = a;
210 E('_qosl_dlr').disabled = b || a;
211 E('_qosl_dlc').disabled = b || a;
212 E('_qosl_ulr').disabled = b || a;
213 E('_qosl_ulc').disabled = b || a;
214 E('_qosl_tcp').disabled = b || a;
215 E('_qosl_udp').disabled = b || a;
217 elem.display(PR('_qos_ibw'), PR('_qos_obw'), !a);
218 elem.display(PR('_qosl_dlr'), PR('_qosl_dlc'), PR('_qosl_ulr'), PR('_qosl_ulc'), PR('_qosl_tcp'), PR('_qosl_udp'), !a && !b);
220 return 1;
223 function save()
225 if (qosg.isEditing()) return;
227 var data = qosg.getAllData();
228 var qoslimitrules = '';
229 var i;
231 if (data.length != 0) qoslimitrules += data[0].join('<');
232 for (i = 1; i < data.length; ++i) {
233 qoslimitrules += '>' + data[i].join('<');
236 var fom = E('_fom');
237 fom.new_qoslimit_enable.value = E('_f_new_qoslimit_enable').checked ? 1 : 0;
238 fom.qosl_enable.value = E('_f_qosl_enable').checked ? 1 : 0;
239 fom.new_qoslimit_rules.value = qoslimitrules;
240 form.submit(fom, 1);
243 function init()
245 qosg.recolor();
247 </script>
248 </head>
249 <body onload='init()'>
250 <form id='_fom' method='post' action='tomato.cgi'>
251 <table id='container' cellspacing=0>
252 <tr><td colspan=2 id='header'>
253 <div class='title'>Tomato</div>
254 <div class='version'>Version <% version(); %></div>
255 </td></tr>
256 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
257 <td id='content'>
258 <div id='ident'><% ident(); %></div>
260 <!-- / / / -->
262 <input type='hidden' name='_nextpage' value='new-qoslimit.asp'>
263 <input type='hidden' name='_nextwait' value='10'>
264 <input type='hidden' name='_service' value='qoslimit-restart'>
266 <input type='hidden' name='new_qoslimit_enable'>
267 <input type='hidden' name='new_qoslimit_rules'>
268 <input type='hidden' name='qosl_enable'>
271 <div id='bwlimit'>
273 <div class='section-title'>Bandwidth Limiter</div>
274 <div class='section'>
275 <script type='text/javascript'>
276 createFieldTable('', [
277 { title: 'Enable Limiter', name: 'f_new_qoslimit_enable', type: 'checkbox', value: nvram.new_qoslimit_enable != '0' },
278 { title: 'Max Available Download <br><small>(same as used in QoS)</small>', name: 'qos_ibw', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qos_ibw },
279 { title: 'Max Available Upload <br><small>(same as used in QoS)</small>', name: 'qos_obw', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qos_obw }
281 </script>
282 <br>
283 <table class='tomato-grid' id='qosg-grid'></table>
284 <div>
285 <ul>
286 <li><b>IP Address / IP Range:</b>
287 <li>Example: 192.168.1.5 for one IP.
288 <li>Example: 192.168.1.4-7 for IP 192.168.1.4 to 192.168.1.7
289 <li>Example: 4-7 for IP Range .4 to .7
290 <li><b>The IP Range devices will share the Bandwidth</b>
291 <li><b>MAC Address</b> Example: 00:2E:3C:6A:22:D8
292 </ul>
293 </div>
294 </div>
296 <br>
298 <div class='section-title'>Default Class rate/ceiling for unlisted MAC / IP's</div>
299 <div class='section'>
300 <script type='text/javascript'>
301 createFieldTable('', [
302 { title: 'Enable', name: 'f_qosl_enable', type: 'checkbox', value: nvram.qosl_enable == '1'},
303 { title: 'Download rate', name: 'qosl_dlr', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qosl_dlr },
304 { title: 'Download ceil', name: 'qosl_dlc', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qosl_dlc },
305 { title: 'Upload rate', name: 'qosl_ulr', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qosl_ulr },
306 { title: 'Upload ceil', name: 'qosl_ulc', type: 'text', maxlen: 6, size: 8, suffix: ' <small>kbit/s</small>', value: nvram.qosl_ulc },
307 { title: 'TCP Limit', name: 'qosl_tcp', type: 'select', options:
308 [['0', 'no limit'],
309 ['1', '1'],
310 ['2', '2'],
311 ['5', '5'],
312 ['10', '10'],
313 ['20', '20'],
314 ['50', '50'],
315 ['100', '100'],
316 ['200', '200'],
317 ['500', '500'],
318 ['1000', '1000']], value: nvram.qosl_tcp },
319 { title: 'UDP limit', name: 'qosl_udp', type: 'select', options:
320 [['0', 'no limit'],
321 ['1', '1/s'],
322 ['2', '2/s'],
323 ['5', '5/s'],
324 ['10', '10/s'],
325 ['20', '20/s'],
326 ['50', '50/s'],
327 ['100', '100/s']], value: nvram.qosl_udp }
329 </script>
330 <div>
331 <ul>
332 <li><b>Default Class</b> - IP / MAC's non included in the list will take the Default Rate/Ceiling setting
333 <li><b>The bandwitdh will be shared by all unlisted hosts.</b>
334 </ul>
335 </div>
336 </div>
337 </div>
339 <!-- / / / -->
341 </td></tr>
342 <tr><td id='footer' colspan=2>
343 <span id='footer-msg'></span>
344 <input type='button' value='Save' id='save-button' onclick='save()'>
345 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
346 </td></tr>
347 </table>
348 </form>
349 <script type='text/javascript'>qosg.setup(); verifyFields(null, 1);</script>
350 </body>
351 </html>