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(); %>] 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"); %>
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
);
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
);
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
);
160 if( this.checkRate(f
[1].value
)) {
161 ferror
.set(f
[1], 'DLRate must between 1 and 99999', quiet
);
165 if( this.checkRate(f
[2].value
)) {
166 ferror
.set(f
[2], 'DLCeil must between 1 and 99999', quiet
);
170 if( this.checkRateCeil(f
[1].value
, f
[2].value
)) {
171 ferror
.set(f
[2], 'DLCeil must be greater than DLRate', quiet
);
175 if( this.checkRate(f
[3].value
)) {
176 ferror
.set(f
[3], 'ULRate must between 1 and 99999', quiet
);
180 if( this.checkRate(f
[4].value
)) {
181 ferror
.set(f
[4], 'ULCeil must between 1 and 99999', quiet
);
185 if( this.checkRateCeil(f
[3].value
, f
[4].value
)) {
186 ferror
.set(f
[4], 'ULCeil must be greater than ULRate', quiet
);
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
);
207 if (qosg
.isEditing()) return;
209 var data
= qosg
.getAllData();
210 var qoslimitrules
= '';
213 if (data
.length
!= 0) qoslimitrules
+= data
[0].join('<');
214 for (i
= 1; i
< data
.length
; ++i
) {
215 qoslimitrules
+= '>' + data
[i
].join('<');
219 fom
.qosl_enable
.value
= E('_f_qosl_enable').checked
? 1 : 0;
220 fom
.qosl_rules
.value
= qoslimitrules
;
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>
237 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
239 <div id='ident'
><%
ident(); %></div>
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'
>
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
}
262 <table class='tomato-grid' id='qosg-grid'
></table>
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
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();'
>
287 <script type='text/javascript'
>qosg
.setup(); verifyFields(null, 1);</script>