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
4e6b940b
Commit
4e6b940b
authored
Oct 18, 2002
by
pdw
Browse files
Added on-line help.
parent
45ccb4e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
TODO
View file @
4e6b940b
Things to do for iftop
$Id$
* Turn off services resolution.
* IP types other than v4?
* Which average to use for the bar graph? Show several and peaks? Colours?
...
...
options.c
View file @
4e6b940b
...
...
@@ -71,6 +71,7 @@ static void set_defaults() {
options
.
aggregate_src
=
0
;
options
.
aggregate_dest
=
0
;
options
.
paused
=
0
;
options
.
showhelp
=
0
;
}
static
void
die
(
char
*
msg
)
{
...
...
options.h
View file @
4e6b940b
...
...
@@ -42,6 +42,7 @@ typedef struct {
int
aggregate_src
;
int
aggregate_dest
;
int
paused
;
int
showhelp
;
}
options_t
;
...
...
ui.c
View file @
4e6b940b
...
...
@@ -24,6 +24,25 @@
#define HISTORY_DIVISIONS 3
#define BARGRAPH_INTERVAL 1
/* which division used for bars. */
#define HELP_MESSAGE \
"Host display:\n"\
" r - toggle DNS host resolution \n"\
" s - toggle show source host\n"\
" d - toggle show destination host\n"\
"\nPort display:\n"\
" R - toggle service resolution \n"\
" S - toggle show source port \n"\
" D - toggle show destination port\n"\
" p - toggle port display\n"\
"\nGeneral:\n"\
" P - pause display\n"\
" h - toggle this help display\n"\
" b - toggle bar graph display\n"\
" q - quit\n"\
"\niftop, version " IFTOP_VERSION
/* 1, 15 and 60 seconds */
int
history_divs
[
HISTORY_DIVISIONS
]
=
{
1
,
5
,
20
};
...
...
@@ -384,52 +403,57 @@ void ui_print() {
attron
(
A_REVERSE
);
addstr
(
" s "
);
attroff
(
A_REVERSE
);
addstr
(
options
.
aggregate_src
?
"
aggregate off
"
:
"
aggregat
e src "
);
addstr
(
options
.
aggregate_src
?
"
show src
"
:
"
hid
e src "
);
attron
(
A_REVERSE
);
addstr
(
" d "
);
attroff
(
A_REVERSE
);
addstr
(
options
.
aggregate_dest
?
"
aggregate off
"
:
"
aggregat
e dest "
);
addstr
(
options
.
aggregate_dest
?
"
show dest
"
:
"
hid
e dest "
);
draw_bar_scale
(
&
y
);
if
(
options
.
showhelp
)
{
mvaddstr
(
y
,
0
,
HELP_MESSAGE
);
}
else
{
/* Screen layout: we have 2 * HISTORY_DIVISIONS 6-character wide history
* items, and so can use COLS - 12 * HISTORY_DIVISIONS to print the two
* host names. */
/* Screen layout: we have 2 * HISTORY_DIVISIONS 6-character wide history
* items, and so can use COLS - 12 * HISTORY_DIVISIONS to print the two
* host names. */
while
((
nn
=
sorted_list_next_item
(
&
screen_list
,
nn
))
!=
NULL
)
{
int
x
=
0
,
L
;
host_pair_line
*
screen_line
=
(
host_pair_line
*
)
nn
->
data
;
while
((
nn
=
sorted_list_next_item
(
&
screen_list
,
nn
))
!=
NULL
)
{
int
x
=
0
,
L
;
host_pair_line
*
screen_line
=
(
host_pair_line
*
)
nn
->
data
;
if
(
y
<
LINES
-
4
)
{
L
=
(
COLS
-
8
*
HISTORY_DIVISIONS
-
4
)
/
2
;
if
(
L
>
sizeof
hostname
)
{
L
=
sizeof
hostname
;
}
if
(
y
<
LINES
-
4
)
{
L
=
(
COLS
-
8
*
HISTORY_DIVISIONS
-
4
)
/
2
;
if
(
L
>
sizeof
hostname
)
{
L
=
sizeof
hostname
;
}
sprint_host
(
line
,
&
(
screen_line
->
ap
.
src
),
screen_line
->
ap
.
src_port
,
screen_line
->
ap
.
protocol
,
L
);
sprint_host
(
line
,
&
(
screen_line
->
ap
.
src
),
screen_line
->
ap
.
src_port
,
screen_line
->
ap
.
protocol
,
L
);
//sprintf(line, "%-*s", L, hostname);
mvaddstr
(
y
,
x
,
line
);
x
+=
L
;
//sprintf(line, "%-*s", L, hostname);
mvaddstr
(
y
,
x
,
line
);
x
+=
L
;
mvaddstr
(
y
,
x
,
" => "
);
mvaddstr
(
y
+
1
,
x
,
" <= "
);
mvaddstr
(
y
,
x
,
" => "
);
mvaddstr
(
y
+
1
,
x
,
" <= "
);
x
+=
4
;
x
+=
4
;
sprint_host
(
line
,
&
(
screen_line
->
ap
.
dst
),
screen_line
->
ap
.
dst_port
,
screen_line
->
ap
.
protocol
,
L
);
sprint_host
(
line
,
&
(
screen_line
->
ap
.
dst
),
screen_line
->
ap
.
dst_port
,
screen_line
->
ap
.
protocol
,
L
);
mvaddstr
(
y
,
x
,
line
);
draw_line_totals
(
y
,
screen_line
);
mvaddstr
(
y
,
x
,
line
);
draw_line_totals
(
y
,
screen_line
);
}
y
+=
2
;
}
y
+=
2
;
}
}
...
...
@@ -518,6 +542,11 @@ void ui_loop() {
tick
(
1
);
break
;
case
'h'
:
options
.
showhelp
=
!
options
.
showhelp
;
tick
(
1
);
break
;
case
'b'
:
options
.
showbars
=
!
options
.
showbars
;
tick
(
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