1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 Filtering/Extensions on this QoS/Transfer Rates page
8 Copyright (C) 2011 Augusto Bott
9 http://code.google.com/p/tomato-sdhc-vlan/
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: View Per-Connection Transfer Rates
</title>
19 <link rel='stylesheet' type='text/css' href='tomato.css'
>
21 <script type='text/javascript' src='tomato.js'
></script>
25 <style type='text/css'
>
34 <script type='text/javascript' src='debug.js'
></script>
35 <script type='text/javascript' src='protocols.js'
></script>
36 <script type='text/javascript' src='interfaces.js'
></script>
38 <script type='text/javascript'
>
39 // <% nvram('lan_ipaddr,lan1_ipaddr,lan2_ipaddr,lan3_ipaddr,lan_netmask,lan1_netmask,lan2_netmask,lan3_netmask,t_hidelr'); %>
43 readDelay
= fixInt('<% cgi_get("delay"); %>', 2, 30, 2);
52 if ((queue
.length
== 0) || (xob
)) return;
55 xob
.onCompleted = function(text
, xml
) {
57 for (var i
= 0; i
< resolve_data
.length
; ++i
) {
58 var r
= resolve_data
[i
];
59 if (r
[1] == '') r
[1] = r
[0];
61 if (lock
== 0) grid
.setName(r
[0], r
[1]);
63 if (queue
.length
== 0) {
64 if ((lock
== 0) && (resolveCB
) && (grid
.sortColumn
== 4)) grid
.resort();
66 else setTimeout(resolve
, 500);
69 xob
.onError = function(ex
) {
73 xob
.post('resolve.cgi', 'ip=' + queue
.splice(0, 20).join(','));
80 function resolveChanged()
84 b
= E('_f_autoresolve').checked
? 1 : 0;
87 cookie
.set('qos_ctr_resolve', b
);
89 if (b
) grid
.resolveAll();
94 function thresChanged()
98 b
= E('_f_excludebythreshold').checked
? fixInt('<% cgi_get("thres"); %>', 100, 10000000, 100) : 0;
101 cookie
.set('qos_ctr_thres', b
);
102 ref
.postData
= 'exec=ctrate&arg0=' + readDelay
+ '&arg1=' + thres
;
103 if (!ref
.running
) ref
.once
= 1;
104 E('loading').style
.visibility
= '';
109 var grid
= new TomatoGrid();
111 grid
.dataToView = function(data
) {
113 for (var col
= 0; col
< data
.length
; ++col
) {
117 s
= (data
[col
] / (readDelay
* 1024)).toFixed(1);
128 grid
.sortCompare = function(a
, b
) {
130 var col
= obj
.sortColumn
;
131 var da
= a
.getRowData();
132 var db
= b
.getRowData();
140 r
= cmpInt(da
[col
], db
[col
]);
144 var a
= fixIP(da
[col
]);
145 var b
= fixIP(db
[col
]);
146 if ((a
!= null) && (b
!= null)) {
147 r
= aton(a
) - aton(b
);
151 r
= cmpText(da
[col
], db
[col
]);
154 return obj
.sortAscending
? r
: -r
;
157 grid
.onClick = function(cell
) {
159 var ip
= row
.getRowData()[3];
160 if (this.lastClicked
!= row
) {
161 this.lastClicked
= row
;
162 if (ip
.indexOf('<') == -1) {
164 row
.style
.cursor
= 'wait';
173 grid
.resolveAll = function()
175 var i
, ip
, row
, q
, cols
, j
;
179 for (i
= 1; i
< this.tb
.rows
.length
; ++i
) {
180 row
= this.tb
.rows
[i
];
181 for (j
= cols
.length
-1; j
>= 0; j
--) {
182 ip
= row
.getRowData()[cols
[j
]];
183 if (ip
.indexOf('<') == -1) {
188 row
.style
.cursor
= 'wait';
196 grid
.setName = function(ip
, name
) {
197 var i
, row
, data
, cols
, j
;
200 for (i
= this.tb
.rows
.length
- 1; i
> 0; --i
) {
201 row
= this.tb
.rows
[i
];
202 data
= row
.getRowData();
203 for (j
= cols
.length
-1; j
>= 0; j
--) {
204 if (data
[cols
[j
]] == ip
) {
205 data
[cols
[j
]] = name
+ ((ip
.indexOf(':') != -1) ? '<br>' : ' ') + '<small>(' + ip
+ ')</small>';
206 row
.setRowData(data
);
207 row
.cells
[cols
[j
]].innerHTML
= data
[cols
[j
]];
208 row
.style
.cursor
= 'default';
214 grid
.setup = function() {
215 this.init('grid', 'sort');
216 this.headerSet(['Proto', 'Source', 'S Port', 'Destination', 'D Port', 'UL Rate', 'DL Rate']);
219 var ref
= new TomatoRefresh('update.cgi', '', 0, 'qos_ctrate');
221 var numconntotal
= 0;
222 var numconnshown
= 0;
224 ref
.refresh = function(text
)
226 var i
, b
, d
, cols
, j
;
241 grid
.lastClicked
= null;
242 grid
.removeAllData();
253 for (i
= 0; i
< ctrate
.length
; ++i
) {
258 if (E('_f_excludegw').checked
) {
259 if ((b
[1] == nvram
.lan_ipaddr
) || (b
[2] == nvram
.lan_ipaddr
) ||
260 (b
[1] == nvram
.lan1_ipaddr
) || (b
[2] == nvram
.lan1_ipaddr
) ||
261 (b
[1] == nvram
.lan2_ipaddr
) || (b
[2] == nvram
.lan2_ipaddr
) ||
262 (b
[1] == nvram
.lan3_ipaddr
) || (b
[2] == nvram
.lan3_ipaddr
) ||
263 (b
[1] == '127.0.0.1') || (b
[2] == '127.0.0.1') ) {
268 if (E('_f_excludebcast').checked
) {
269 if ((b
[2] == getBroadcastAddress(getNetworkAddress(nvram
.lan_ipaddr
,nvram
.lan_netmask
),nvram
.lan_netmask
)) ||
270 (b
[2] == getBroadcastAddress(getNetworkAddress(nvram
.lan1_ipaddr
,nvram
.lan1_netmask
),nvram
.lan1_netmask
)) ||
271 (b
[2] == getBroadcastAddress(getNetworkAddress(nvram
.lan2_ipaddr
,nvram
.lan2_netmask
),nvram
.lan2_netmask
)) ||
272 (b
[2] == getBroadcastAddress(getNetworkAddress(nvram
.lan3_ipaddr
,nvram
.lan3_netmask
),nvram
.lan3_netmask
)) ||
273 (b
[2] == '255.255.255.255') || (b
[2] == '0.0.0.0') ) {
278 if (E('_f_excludemcast').checked
) {
279 var mmin
= 3758096384; // aton('224.0.0.0') == 3758096384
280 var mmax
= 4026531839; // aton('239.255.255.255') == 4026531839
281 if (((aton(b
[1]) >= mmin
) && (aton(b
[1]) <= mmax
)) ||
282 ((aton(b
[2]) >= mmin
) && (aton(b
[2]) <= mmax
))) {
287 if (filteripe
.length
>0) {
289 for (x
= 0; x
< filteripe
.length
; ++x
) {
290 if ((b
[1] == filteripe
[x
]) || (b
[2] == filteripe
[x
])) {
295 if (fskip
== 1) continue;
298 if (filterip
.length
>0) {
300 for (x
= 0; x
< filterip
.length
; ++x
) {
301 if ((b
[1] == filterip
[x
]) || (b
[2] == filterip
[x
])) {
306 if (fskip
== 1) continue;
309 for (j
= cols
.length
-1; j
>= 0; j
--) {
311 if (cache
[ip
] != null) {
313 b
[cols
[j
]] = cache
[ip
] + ((ip
.indexOf(':') != -1) ? '<br>' : ' ') + '<small>(' + ip
+ ')</small>';
329 d
= [protocols
[b
[0]] || b
[0], b
[1], b
[3], b
[2], b
[4], b
[5], b
[6]];
330 var row
= grid
.insertData(-1, d
);
331 if (cursor
) row
.style
.cursor
= cursor
;
338 setTimeout(function() { E('loading').style
.visibility
= 'hidden'; }, 100);
342 if (resolveCB
) resolve();
344 if (numconnshown
!= numconntotal
)
345 E('numtotalconn').innerHTML
='<small><i>(showing ' + numconnshown
+ ' out of ' + numconntotal
+ ' connections)</i></small>';
347 E('numtotalconn').innerHTML
='<small><i>(' + numconntotal
+ ' connections)</i></small>';
354 if (((c
= cookie
.get('qos_ctr_resolve')) != null) && (c
== '1')) {
355 E('_f_autoresolve').checked
= resolveCB
= 1;
358 if (((c
= cookie
.get('qos_ctr_bcast')) != null) && (c
== '1')) {
359 E('_f_excludebcast').checked
= bcastCB
= 1;
362 if (((c
= cookie
.get('qos_ctr_mcast')) != null) && (c
== '1')) {
363 E('_f_excludemcast').checked
= mcastCB
= 1;
366 if (((c
= cookie
.get('qos_ctr_filters')) != null) && (c
== '1')) {
367 E('sesdivfilters').style
.display
='';
370 if ((thres
= cookie
.get('qos_ctr_thres')) == null || isNaN(thres
*= 1)) {
374 E('_f_excludebythreshold').checked
= (thres
!= 0);
376 ref
.postData
= 'exec=ctrate&arg0=' + readDelay
+ '&arg1=' + thres
;
379 if (!ref
.running
) ref
.once
= 1;
383 function dofilter() {
384 if (E('_f_filter_ip').value
.length
>6) {
385 filterip
= E('_f_filter_ip').value
.split(',');
390 if (E('_f_filter_ipe').value
.length
>6) {
391 filteripe
= E('_f_filter_ipe').value
.split(',');
400 function toggleFiltersVisibility(){
401 if(E('sesdivfilters').style
.display
=='') {
402 E('sesdivfilters').style
.display
='none';
403 cookie
.set('qos_ctr_filters', 0);
405 E('sesdivfilters').style
.display
='';
406 cookie
.set('qos_ctr_filters', 1);
410 function verifyFields(focused
, quiet
)
414 b
= E('_f_excludebcast').checked
? 1 : 0;
417 cookie
.set('qos_ctr_bcast', b
);
420 b
= E('_f_excludemcast').checked
? 1 : 0;
423 cookie
.set('qos_ctr_mcast', b
);
434 <body onload='init()'
>
435 <form id='_fom' action='javascript:{}'
>
436 <table id='container' cellspacing=
0>
437 <tr><td colspan=
2 id='header'
>
438 <div class='title'
>Tomato
</div>
439 <div class='version'
>Version <%
version(); %></div>
441 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
443 <div id='ident'
><%
ident(); %></div>
449 <div class='section-title' id='stitle' onclick='document.
location=
"qos-graphs.asp"' style='cursor:pointer'
>Transfer Rates:
<span id='numtotalconn'
></span></div>
450 <div class='section'
>
451 <table id='grid' class='tomato-grid'
style=
"float:left" cellspacing=
1></table>
453 <div id='loading'
><br><b>Loading...
</b></div>
460 <div class='section-title'
>Filters:
<small><i><a href='javascript:toggleFiltersVisibility();'
>(Toggle Visibility)
</a></i></small></div>
461 <div class='section' id='sesdivfilters' style='display:none'
>
462 <script type='text/javascript'
>
465 c
.push({ title
: 'Only these IPs', name
: 'f_filter_ip', size
: 50, maxlen
: 255, type
: 'text', suffix
: ' <small>(Comma separated list)</small>' });
466 c
.push({ title
: 'Exclude these IPs', name
: 'f_filter_ipe', size
: 50, maxlen
: 255, type
: 'text', suffix
: ' <small>(Comma separated list)</small>' });
467 c
.push({ title
: 'Exclude gateway traffic', name
: 'f_excludegw', type
: 'checkbox', value
: ((nvram
.t_hidelr
) == '1' ? 1 : 0) });
468 c
.push({ title
: 'Exclude broadcasts', name
: 'f_excludebcast', type
: 'checkbox' });
469 c
.push({ title
: 'Exclude multicast', name
: 'f_excludemcast', type
: 'checkbox' });
470 c
.push({ title
: 'Ignore inactive connections', name
: 'f_excludebythreshold', type
: 'checkbox' });
471 c
.push({ title
: 'Auto resolve addresses', name
: 'f_autoresolve', type
: 'checkbox' });
472 createFieldTable('',c
);
480 <tr><td id='footer' colspan=
2>
481 <script type='text/javascript'
>genStdRefresh(1,1,'ref.toggle()');</script>