Randomly renamed options and buttons.
Stopped whinging about default config file not existing. 0.15pre2
This commit is contained in:
@@ -8,6 +8,8 @@ Unattributed items are by Paul Warren and Chris Lightfoot.
|
|||||||
* Added linear bar scales (default) ("L")
|
* Added linear bar scales (default) ("L")
|
||||||
* Added fixed upper limit for bandwidth
|
* Added fixed upper limit for bandwidth
|
||||||
* Choose which average bars display ("B")
|
* Choose which average bars display ("B")
|
||||||
|
* Renamed some buttons and command line options
|
||||||
|
* Added config file support
|
||||||
|
|
||||||
* Fixed the search for libpcap in the configure script
|
* Fixed the search for libpcap in the configure script
|
||||||
Thomas Schwinge <tschwinge@gmx.net>
|
Thomas Schwinge <tschwinge@gmx.net>
|
||||||
@@ -81,7 +83,7 @@ Unattributed items are by Paul Warren and Chris Lightfoot.
|
|||||||
* Minor fix to netmask handling (specifying /32 was broken)
|
* Minor fix to netmask handling (specifying /32 was broken)
|
||||||
|
|
||||||
* Updated RPM spec file
|
* Updated RPM spec file
|
||||||
Iain Lea <iain@bricbrac.de>
|
Iain Lea <iain@bricbrac.de>
|
||||||
|
|
||||||
* Added pause functionality (P)
|
* Added pause functionality (P)
|
||||||
* Changed behaviour of source/dest traffic aggregation
|
* Changed behaviour of source/dest traffic aggregation
|
||||||
|
|||||||
12
TODO
12
TODO
@@ -3,13 +3,9 @@ $Id$
|
|||||||
|
|
||||||
* Add configurable offset for DLT_RAW
|
* Add configurable offset for DLT_RAW
|
||||||
|
|
||||||
* Search for BSD interface names - need to know what to look for.
|
|
||||||
|
|
||||||
* IP types other than v4?
|
* IP types other than v4?
|
||||||
|
|
||||||
* Config file.
|
* Write config file
|
||||||
|
|
||||||
* Which average to use for the bar graph? - add option to choose
|
|
||||||
|
|
||||||
* Show several and peaks? Colours?
|
* Show several and peaks? Colours?
|
||||||
|
|
||||||
@@ -20,10 +16,8 @@ $Id$
|
|||||||
|
|
||||||
* Specify max link, then show %age capacity.
|
* Specify max link, then show %age capacity.
|
||||||
|
|
||||||
* Turn off port resolution => add to config file
|
|
||||||
|
|
||||||
* Linear bar graphs.
|
|
||||||
|
|
||||||
* Count obscured connections.
|
* Count obscured connections.
|
||||||
|
|
||||||
* Startup warnings cause pause.
|
* Startup warnings cause pause.
|
||||||
|
|
||||||
|
* Re-merge spec file
|
||||||
|
|||||||
13
cfgfile.c
13
cfgfile.c
@@ -66,7 +66,7 @@ int config_init() {
|
|||||||
* stringmap of the results. Prints errors to stderr, rather than using
|
* stringmap of the results. Prints errors to stderr, rather than using
|
||||||
* syslog, since this file is called at program startup. Returns 1 on success
|
* syslog, since this file is called at program startup. Returns 1 on success
|
||||||
* or 0 on failure. */
|
* or 0 on failure. */
|
||||||
int read_config_file(const char *f) {
|
int read_config_file(const char *f, int whinge) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *line;
|
char *line;
|
||||||
@@ -76,7 +76,7 @@ int read_config_file(const char *f) {
|
|||||||
|
|
||||||
fp = fopen(f, "rt");
|
fp = fopen(f, "rt");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
fprintf(stderr, "%s: %s\n", f, strerror(errno));
|
if(whinge) fprintf(stderr, "%s: %s\n", f, strerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,14 +238,9 @@ void config_set_string(const char *directive, const char* s) {
|
|||||||
stringmap_insert(config, directive, item_ptr(xstrdup(s)));
|
stringmap_insert(config, directive, item_ptr(xstrdup(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_config(char *file) {
|
int read_config(char *file, int whinge_on_error) {
|
||||||
config_item_type* t;
|
config_item_type* t;
|
||||||
void* o;
|
void* o;
|
||||||
|
|
||||||
read_config_file(file);
|
return read_config_file(file, whinge_on_error);
|
||||||
if(config == NULL) {
|
|
||||||
fprintf(stderr,"Unable to read config file\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ AC_CONFIG_AUX_DIR(config)
|
|||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
|
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
AM_INIT_AUTOMAKE(iftop, "0.15pre1")
|
AM_INIT_AUTOMAKE(iftop, "0.15pre2")
|
||||||
|
|
||||||
AC_DEFINE_UNQUOTED(IFTOP_VERSION, "$VERSION", [The iftop version number])
|
AC_DEFINE_UNQUOTED(IFTOP_VERSION, "$VERSION", [The iftop version number])
|
||||||
|
|
||||||
|
|||||||
11
iftop.8
11
iftop.8
@@ -11,7 +11,7 @@ iftop - display bandwidth usage on an interface by host
|
|||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
\fBiftop\fP \fB-h\fP |
|
\fBiftop\fP \fB-h\fP |
|
||||||
[\fB-npbBP\fP] [\fB-i\fP \fIinterface\fP] [\fB-f\fP \fIfilter code\fP] [\fB-N\fP \fInet\fP/\fImask\fP]
|
[\fB-nNpbBP\fP] [\fB-i\fP \fIinterface\fP] [\fB-f\fP \fIfilter code\fP] [\fB-F\fP \fInet\fP/\fImask\fP]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBiftop\fP listens to network traffic on a named \fIinterface\fP, or on the
|
\fBiftop\fP listens to network traffic on a named \fIinterface\fP, or on the
|
||||||
@@ -53,7 +53,10 @@ slow?
|
|||||||
Print a summary of usage.
|
Print a summary of usage.
|
||||||
.TP
|
.TP
|
||||||
\fB-n\fP
|
\fB-n\fP
|
||||||
Don't do hostname lookups. This setting may be altered at run time.
|
Don't do hostname lookups.
|
||||||
|
.TP
|
||||||
|
\fB-N\fP
|
||||||
|
Do not resolve port number to service names
|
||||||
.TP
|
.TP
|
||||||
\fB-p\fP
|
\fB-p\fP
|
||||||
Run in promiscuous mode, so that traffic which does not pass directly through
|
Run in promiscuous mode, so that traffic which does not pass directly through
|
||||||
@@ -63,7 +66,7 @@ the specified interface is also counted.
|
|||||||
Turn on port display.
|
Turn on port display.
|
||||||
.TP
|
.TP
|
||||||
\fB-b\fP
|
\fB-b\fP
|
||||||
Don't display bar graphs of traffic. This setting may be altered at run time.
|
Don't display bar graphs of traffic.
|
||||||
.TP
|
.TP
|
||||||
\fB-B\fP
|
\fB-B\fP
|
||||||
Display bandwidth rates in bytes/sec rather than bits/sec.
|
Display bandwidth rates in bytes/sec rather than bits/sec.
|
||||||
@@ -75,7 +78,7 @@ Listen to packets on \fIinterface\fP.
|
|||||||
Use \fIfilter code\fP to select the packets to count. Only IP packets are ever
|
Use \fIfilter code\fP to select the packets to count. Only IP packets are ever
|
||||||
counted, so the specified code is evaluated as \fB(\fP\fIfilter code\fP\fB) and ip\fP.
|
counted, so the specified code is evaluated as \fB(\fP\fIfilter code\fP\fB) and ip\fP.
|
||||||
.TP
|
.TP
|
||||||
\fB-N\fP \fInet\fP/\fImask\fP
|
\fB-F\fP \fInet\fP/\fImask\fP
|
||||||
Specifies a network for traffic analysis. If specified, iftop will only
|
Specifies a network for traffic analysis. If specified, iftop will only
|
||||||
include packets flowing in to or out of the given network, and packet direction
|
include packets flowing in to or out of the given network, and packet direction
|
||||||
is determined relative to the network boundary, rather than to the interface.
|
is determined relative to the network boundary, rather than to the interface.
|
||||||
|
|||||||
4
iftop.c
4
iftop.c
@@ -518,11 +518,13 @@ int main(int argc, char **argv) {
|
|||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
struct sigaction sa = {};
|
struct sigaction sa = {};
|
||||||
|
|
||||||
|
/* TODO: tidy this up */
|
||||||
/* read command line options and config file */
|
/* read command line options and config file */
|
||||||
config_init();
|
config_init();
|
||||||
options_set_defaults();
|
options_set_defaults();
|
||||||
options_read_args(argc, argv);
|
options_read_args(argc, argv);
|
||||||
read_config(options.config_file);
|
/* If a config was explicitly specified, whinge if it can't be found */
|
||||||
|
read_config(options.config_file, options.config_file_specified);
|
||||||
options_make();
|
options_make();
|
||||||
|
|
||||||
sa.sa_handler = finish;
|
sa.sa_handler = finish;
|
||||||
|
|||||||
61
options.c
61
options.c
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
options_t options;
|
options_t options;
|
||||||
|
|
||||||
char optstr[] = "+i:f:nN:hpbBPm:";
|
char optstr[] = "+i:f:nNF:hpbBPm:c:";
|
||||||
|
|
||||||
/* Global options. */
|
/* Global options. */
|
||||||
|
|
||||||
@@ -143,16 +143,17 @@ void options_set_defaults() {
|
|||||||
options.log_scale = 0;
|
options.log_scale = 0;
|
||||||
options.bar_interval = 1;
|
options.bar_interval = 1;
|
||||||
|
|
||||||
|
/* Figure out the name for the config file */
|
||||||
s = getenv("HOME");
|
s = getenv("HOME");
|
||||||
if(s != NULL) {
|
if(s != NULL) {
|
||||||
int i = strlen(s) + 9 + 1;
|
int i = strlen(s) + 9 + 1;
|
||||||
options.config_file = xmalloc(i);
|
options.config_file = xmalloc(i);
|
||||||
snprintf(options.config_file,i,"%s/.iftoprc",s);
|
snprintf(options.config_file,i,"%s/.iftoprc",s);
|
||||||
fprintf(stderr,options.config_file);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
options.config_file = xstrdup("iftoprc");
|
options.config_file = xstrdup("iftoprc");
|
||||||
}
|
}
|
||||||
|
options.config_file_specified = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,6 +240,7 @@ static void usage(FILE *fp) {
|
|||||||
"\n"
|
"\n"
|
||||||
" -h display this message\n"
|
" -h display this message\n"
|
||||||
" -n don't do hostname lookups\n"
|
" -n don't do hostname lookups\n"
|
||||||
|
" -N don't convery port numbers to services\n"
|
||||||
" -p run in promiscuous mode (show traffic between other\n"
|
" -p run in promiscuous mode (show traffic between other\n"
|
||||||
" hosts on the same network segment)\n"
|
" hosts on the same network segment)\n"
|
||||||
" -b don't display a bar graph of traffic\n"
|
" -b don't display a bar graph of traffic\n"
|
||||||
@@ -246,9 +248,10 @@ static void usage(FILE *fp) {
|
|||||||
" -i interface listen on named interface\n"
|
" -i interface listen on named interface\n"
|
||||||
" -f filter code use filter code to select packets to count\n"
|
" -f filter code use filter code to select packets to count\n"
|
||||||
" (default: none, but only IP packets are counted)\n"
|
" (default: none, but only IP packets are counted)\n"
|
||||||
" -N net/mask show traffic flows in/out of network\n"
|
" -F net/mask show traffic flows in/out of network\n"
|
||||||
" -P show ports as well as hosts\n"
|
" -P show ports as well as hosts\n"
|
||||||
" -m limit sets the upper limit for the bandwidth scale\n"
|
" -m limit sets the upper limit for the bandwidth scale\n"
|
||||||
|
" -c config file specifies an alternative configuration file\n"
|
||||||
"\n"
|
"\n"
|
||||||
"iftop, version " IFTOP_VERSION "\n"
|
"iftop, version " IFTOP_VERSION "\n"
|
||||||
"copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors\n"
|
"copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors\n"
|
||||||
@@ -266,39 +269,49 @@ void options_read_args(int argc, char **argv) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
config_set_string("dns-resolution","true");
|
config_set_string("dns-resolution","true");
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
|
||||||
config_set_string("interface", optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
config_set_string("filter-code", optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'p':
|
|
||||||
config_set_string("promiscuous", "true");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'P':
|
|
||||||
config_set_string("port-display", "on");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
config_set_string("net-filter", optarg);
|
config_set_string("port-resolution","true");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'i':
|
||||||
|
config_set_string("interface", optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'f':
|
||||||
|
config_set_string("filter-code", optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'p':
|
||||||
|
config_set_string("promiscuous", "true");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'P':
|
||||||
|
config_set_string("port-display", "on");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'F':
|
||||||
|
config_set_string("net-filter", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
config_set_string("max-bandwidth", optarg);
|
config_set_string("max-bandwidth", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
config_set_string("show-bars", "true");
|
config_set_string("show-bars", "true");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'B':
|
case 'B':
|
||||||
config_set_string("use-bytes", "true");
|
config_set_string("use-bytes", "true");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
xfree(options.config_file);
|
||||||
|
options.config_file = xstrdup(optarg);
|
||||||
|
options.config_file_specified = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ typedef struct {
|
|||||||
struct in_addr netfiltermask;
|
struct in_addr netfiltermask;
|
||||||
|
|
||||||
char *config_file;
|
char *config_file;
|
||||||
|
int config_file_specified;
|
||||||
|
|
||||||
} options_t;
|
} options_t;
|
||||||
|
|
||||||
|
|||||||
8
ui.c
8
ui.c
@@ -34,13 +34,13 @@
|
|||||||
|
|
||||||
#define HELP_MESSAGE \
|
#define HELP_MESSAGE \
|
||||||
"Host display: General:\n"\
|
"Host display: General:\n"\
|
||||||
" r - toggle DNS host resolution P - pause display\n"\
|
" n - toggle DNS host resolution P - pause display\n"\
|
||||||
" s - toggle show source host h - toggle this help display\n"\
|
" s - toggle show source host h - toggle this help display\n"\
|
||||||
" d - toggle show destination host b - toggle bar graph display\n"\
|
" d - toggle show destination host b - toggle bar graph display\n"\
|
||||||
" t - cycle line display mode B - cycle bar graph average\n"\
|
" t - cycle line display mode B - cycle bar graph average\n"\
|
||||||
" T - toggle cummulative line totals\n"\
|
" T - toggle cummulative line totals\n"\
|
||||||
"Port display: j/k - scroll display\n"\
|
"Port display: j/k - scroll display\n"\
|
||||||
" R - toggle service resolution f - edit filter code\n"\
|
" N - toggle service resolution f - edit filter code\n"\
|
||||||
" S - toggle show source port l - set screen filter\n"\
|
" S - toggle show source port l - set screen filter\n"\
|
||||||
" D - toggle show destination port L - lin/log scales\n"\
|
" D - toggle show destination port L - lin/log scales\n"\
|
||||||
" p - toggle port display ! - shell command\n"\
|
" p - toggle port display ! - shell command\n"\
|
||||||
@@ -807,7 +807,7 @@ void ui_loop() {
|
|||||||
foad = 1;
|
foad = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'n':
|
||||||
if(options.dnsresolution) {
|
if(options.dnsresolution) {
|
||||||
options.dnsresolution = 0;
|
options.dnsresolution = 0;
|
||||||
showhelp("DNS resolution off");
|
showhelp("DNS resolution off");
|
||||||
@@ -819,7 +819,7 @@ void ui_loop() {
|
|||||||
tick(1);
|
tick(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R':
|
case 'N':
|
||||||
if(options.portresolution) {
|
if(options.portresolution) {
|
||||||
options.portresolution = 0;
|
options.portresolution = 0;
|
||||||
showhelp("Port resolution off");
|
showhelp("Port resolution off");
|
||||||
|
|||||||
Reference in New Issue
Block a user