1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
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.
16 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
17 <meta name='robots' content='noindex,nofollow'
>
18 <title>[<%
ident(); %>] QoS - 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>
24 <style type='text/css'
>
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,qosl_denable,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', '', 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 | IP Range | 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
);
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() {
83 var f
= fields
.getAll(this.newEditor
);
85 if ((c
= cookie
.get('addqoslimit')) != null) {
86 cookie
.set('addqoslimit', '', 0);
94 f
[5].selectedIndex
= '2';
95 f
[6].selectedIndex
= '0';
96 f
[7].selectedIndex
= '0';
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;
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;
139 qosg
.checkRateCeil = function(rate
, ceil
)
141 var r
= parseInt(rate
, 10);
142 var c
= parseInt(ceil
, 10);
143 if( r
> c
) return true;
147 qosg
.verifyFields = function(row
, quiet
)
150 var f
= fields
.getAll(row
);
154 if (v_ip(f[0], quiet)) {
155 if(this.existIP(f[0].value)) {
156 ferror.set(f[0], 'duplicate IP address', quiet);
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
);
168 if( this.checkRate(f
[1].value
)) {
169 ferror
.set(f
[1], 'DLRate must between 1 and 99999', quiet
);
173 if( this.checkRate(f
[2].value
)) {
174 ferror
.set(f
[2], 'DLCeil must between 1 and 99999', quiet
);
178 if( this.checkRateCeil(f
[1].value
, f
[2].value
)) {
179 ferror
.set(f
[2], 'DLCeil must be greater than DLRate', quiet
);
183 if( this.checkRate(f
[3].value
)) {
184 ferror
.set(f
[3], 'ULRate must between 1 and 99999', quiet
);
188 if( this.checkRate(f
[4].value
)) {
189 ferror
.set(f
[4], 'ULCeil must between 1 and 99999', quiet
);
193 if( this.checkRateCeil(f
[3].value
, f
[4].value
)) {
194 ferror
.set(f
[4], 'ULCeil must be greater than ULRate', quiet
);
201 function verifyFields(focused
, quiet
)
203 var a
= !E('_f_qosl_enable').checked
;
204 var b
= !E('_f_qosl_denable').checked
;
206 E('_qos_ibw').disabled
= a
;
207 E('_qos_obw').disabled
= a
;
208 E('_f_qosl_denable').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
);
225 if (qosg
.isEditing()) return;
227 var data
= qosg
.getAllData();
228 var qoslimitrules
= '';
231 if (data
.length
!= 0) qoslimitrules
+= data
[0].join('<');
232 for (i
= 1; i
< data
.length
; ++i
) {
233 qoslimitrules
+= '>' + data
[i
].join('<');
237 fom
.qosl_enable
.value
= E('_f_qosl_enable').checked
? 1 : 0;
238 fom
.qosl_denable
.value
= E('_f_qosl_denable').checked
? 1 : 0;
239 fom
.qosl_rules
.value
= qoslimitrules
;
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>
256 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
258 <div id='ident'
><%
ident(); %></div>
262 <input type='hidden' name='_nextpage' value='qos-qoslimit.asp'
>
263 <input type='hidden' name='_nextwait' value='
10'
>
264 <input type='hidden' name='_service' value='qoslimit-restart'
>
266 <input type='hidden' name='qosl_enable'
>
267 <input type='hidden' name='qosl_rules'
>
268 <input type='hidden' name='qosl_denable'
>
273 <div class='section-title'
>Bandwidth Limiter - QOS
</div>
274 <div class='section'
>
275 <script type='text/javascript'
>
276 createFieldTable('', [
277 { title
: 'Enable Limiter', name
: 'f_qosl_enable', type
: 'checkbox', value
: nvram
.qosl_enable
!= '0' },
278 { title
: 'Max Download Bandwidth <small>(also used by QOS)', name
: 'qos_ibw', type
: 'text', maxlen
: 6, size
: 8, suffix
: ' <small>kbit/s</small>', value
: nvram
.qos_ibw
},
279 { title
: 'Max Upload Bandwidth <small>(also used by QOS)', name
: 'qos_obw', type
: 'text', maxlen
: 6, size
: 8, suffix
: ' <small>kbit/s</small>', value
: nvram
.qos_obw
}
283 <table class='tomato-grid' id='qosg-grid'
></table>
289 <li><b>IP Address / IP Range
</b> - e.g.
192.168.1.5 or
192.168.1.45-
57 or
45-
57 - A range of IP's will
<b>share
</b> the bandwidth.
<br>
295 <div class='section-title'
>Default Class rate/ceiling for unlisted IP's
</div>
296 <div class='section'
>
297 <script type='text/javascript'
>
298 createFieldTable('', [
299 { title
: 'Enable', name
: 'f_qosl_denable', type
: 'checkbox', value
: nvram
.qosl_denable
== '1'},
300 { title
: 'Download rate', name
: 'qosl_dlr', type
: 'text', maxlen
: 6, size
: 8, suffix
: ' <small>kbit/s</small>', value
: nvram
.qosl_dlr
},
301 { title
: 'Download ceil', name
: 'qosl_dlc', type
: 'text', maxlen
: 6, size
: 8, suffix
: ' <small>kbit/s</small>', value
: nvram
.qosl_dlc
},
302 { title
: 'Upload rate', name
: 'qosl_ulr', type
: 'text', maxlen
: 6, size
: 8, suffix
: ' <small>kbit/s</small>', value
: nvram
.qosl_ulr
},
303 { title
: 'Upload ceil', name
: 'qosl_ulc', type
: 'text', maxlen
: 6, size
: 8, suffix
: ' <small>kbit/s</small>', value
: nvram
.qosl_ulc
},
304 { title
: 'TCP Limit', name
: 'qosl_tcp', type
: 'select', options
:
315 ['1000', '1000']], value
: nvram
.qosl_tcp
},
316 { title
: 'UDP limit', name
: 'qosl_udp', type
: 'select', options
:
324 ['100', '100/s']], value
: nvram
.qosl_udp
}
332 <li><b>Default Class
</b> - All clients not included in the list will
<b>share
</b> the Default Rate/Ceiling setting.
341 <tr><td id='footer' colspan=
2>
342 <span id='footer-msg'
></span>
343 <input type='button' value='Save' id='save-button' onclick='save()'
>
344 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'
>
348 <script type='text/javascript'
>qosg
.setup(); verifyFields(null, 1);</script>