1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
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.
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>
20 <style type='text/css'
>
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
);
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();
85 for (var i
= 0; i
< data
.length
; ++i
) {
86 if (parseInt(data
[i
][0], 10) > parseInt(tag
, 10))
90 tag
= parseInt(tag
, 10)+1;
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;
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;
131 qosg
.checkRateCeil = function(rate
, ceil
)
133 var r
= parseInt(rate
, 10);
134 var c
= parseInt(ceil
, 10);
135 if( r
> c
) return true;
139 qosg
.verifyFields = function(row
, quiet
)
142 var f
= fields
.getAll(row
);
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
);
152 if (v_ip(f[1], quiet)) {
153 if(this.existIP(f[1].value)) {
154 ferror.set(f[1], 'duplicate IP address', quiet);
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
);
166 if( this.checkRate(f
[2].value
)) {
167 ferror
.set(f
[2], 'DLRate must between 1 and 99999', quiet
);
171 if( this.checkRate(f
[3].value
)) {
172 ferror
.set(f
[3], 'DLCeil must between 1 and 99999', quiet
);
176 if( this.checkRateCeil(f
[2].value
, f
[3].value
)) {
177 ferror
.set(f
[3], 'DLCeil must be greater than DLRate', quiet
);
181 if( this.checkRate(f
[4].value
)) {
182 ferror
.set(f
[4], 'ULRate must between 1 and 99999', quiet
);
186 if( this.checkRate(f
[5].value
)) {
187 ferror
.set(f
[5], 'ULCeil must between 1 and 99999', quiet
);
191 if( this.checkRateCeil(f
[4].value
, f
[5].value
)) {
192 ferror
.set(f
[5], 'ULCeil must be greater than ULRate', quiet
);
199 function verifyFields(focused
, quiet
)
206 if (qosg
.isEditing()) return;
208 var data
= qosg
.getAllData();
209 var qoslimitrules
= '';
212 if (data
.length
!= 0) qoslimitrules
+= data
[0].join('<');
213 for (i
= 1; i
< data
.length
; ++i
) {
214 qoslimitrules
+= '>' + data
[i
].join('<');
218 fom
.new_qoslimit_enable
.value
= E('_f_new_qoslimit_enable').checked
? 1 : 0;
219 fom
.new_qoslimit_rules
.value
= qoslimitrules
;
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>
236 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
238 <div id='ident'
><%
ident(); %></div>
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
}
259 <table class='tomato-grid' id='qosg-grid'
></table>
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();'
>
272 <script type='text/javascript'
>qosg
.setup();</script>