Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Paul Warren
iftop
Commits
ba1bdd7a
Commit
ba1bdd7a
authored
Oct 25, 2002
by
pdw
Browse files
Added "freeze order" option. Talk about feature creep :-)
parent
6ea79204
Changes
4
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
ba1bdd7a
...
...
@@ -5,7 +5,7 @@
# $Id$
#
VERSION
=
0.10pre
2
VERSION
=
0.10pre
3
# C compiler to use.
#CC = gcc
...
...
options.c
View file @
ba1bdd7a
...
...
@@ -97,6 +97,7 @@ static void set_defaults() {
options
.
bandwidth_in_bytes
=
0
;
options
.
sort
=
OPTION_SORT_DIV2
;
options
.
screenfilter
=
NULL
;
options
.
freezeorder
=
0
;
}
static
void
die
(
char
*
msg
)
{
...
...
options.h
View file @
ba1bdd7a
...
...
@@ -50,6 +50,7 @@ typedef struct {
option_sort_t
sort
;
char
*
screenfilter
;
int
freezeorder
;
}
options_t
;
...
...
ui.c
View file @
ba1bdd7a
...
...
@@ -47,6 +47,7 @@
" 1/2/3 - sort by 1st/2nd/3rd column\n"\
" < - sort by source name\n"\
" > - sort by dest name\n"\
" o - freeze current order\n"\
"\n"\
"iftop, version " IFTOP_VERSION
...
...
@@ -292,7 +293,7 @@ void screen_list_init() {
sorted_list_initialise
(
&
screen_list
);
}
void
screen_
data
_clear
()
{
void
screen_
list
_clear
()
{
sorted_list_node
*
nn
=
NULL
;
peaksent
=
peakrecv
=
peaktotal
=
0
;
while
((
nn
=
sorted_list_next_item
(
&
screen_list
,
nn
))
!=
NULL
)
{
...
...
@@ -337,6 +338,18 @@ void make_screen_list() {
}
}
/*
* Zeros all data in the screen hash, but does not remove items.
*/
void
screen_hash_clear
()
{
hash_node_type
*
n
=
NULL
;
while
(
hash_next_item
(
screen_hash
,
&
n
)
==
HASH_STATUS_OK
)
{
host_pair_line
*
hpl
=
(
host_pair_line
*
)
n
->
rec
;
memset
(
hpl
->
recv
,
0
,
sizeof
(
hpl
->
recv
));
memset
(
hpl
->
sent
,
0
,
sizeof
(
hpl
->
sent
));
}
}
void
analyse_data
()
{
hash_node_type
*
n
=
NULL
;
...
...
@@ -346,7 +359,13 @@ void analyse_data() {
memset
(
&
totals
,
0
,
sizeof
totals
);
screen_data_clear
();
if
(
options
.
freezeorder
)
{
screen_hash_clear
();
}
else
{
screen_list_clear
();
hash_delete_all
(
screen_hash
);
}
while
(
hash_next_item
(
history
,
&
n
)
==
HASH_STATUS_OK
)
{
history_type
*
d
=
(
history_type
*
)
n
->
rec
;
...
...
@@ -356,6 +375,7 @@ void analyse_data() {
int
tsent
,
trecv
;
tsent
=
trecv
=
0
;
ap
=
*
(
addr_pair
*
)
n
->
key
;
/* Aggregate hosts, if required */
...
...
@@ -399,9 +419,10 @@ void analyse_data() {
}
make_screen_list
();
if
(
!
options
.
freezeorder
)
{
make_screen_list
();
}
hash_delete_all
(
screen_hash
);
calculate_totals
();
...
...
@@ -750,6 +771,16 @@ void ui_loop() {
case
'P'
:
options
.
paused
=
!
options
.
paused
;
break
;
case
'o'
:
if
(
options
.
freezeorder
)
{
options
.
freezeorder
=
0
;
showhelp
(
"Order unfrozen"
);
}
else
{
options
.
freezeorder
=
1
;
showhelp
(
"Order frozen"
);
}
break
;
case
'1'
:
options
.
sort
=
OPTION_SORT_DIV1
;
showhelp
(
"Sort by col 1"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment