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 fixed upper limit for bandwidth
|
||||
* 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
|
||||
Thomas Schwinge <tschwinge@gmx.net>
|
||||
|
||||
12
TODO
12
TODO
@@ -3,13 +3,9 @@ $Id$
|
||||
|
||||
* Add configurable offset for DLT_RAW
|
||||
|
||||
* Search for BSD interface names - need to know what to look for.
|
||||
|
||||
* IP types other than v4?
|
||||
|
||||
* Config file.
|
||||
|
||||
* Which average to use for the bar graph? - add option to choose
|
||||
* Write config file
|
||||
|
||||
* Show several and peaks? Colours?
|
||||
|
||||
@@ -20,10 +16,8 @@ $Id$
|
||||
|
||||
* Specify max link, then show %age capacity.
|
||||
|
||||
* Turn off port resolution => add to config file
|
||||
|
||||
* Linear bar graphs.
|
||||
|
||||
* Count obscured connections.
|
||||
|
||||
* 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
|
||||
* syslog, since this file is called at program startup. Returns 1 on success
|
||||
* or 0 on failure. */
|
||||
int read_config_file(const char *f) {
|
||||
int read_config_file(const char *f, int whinge) {
|
||||
int ret = 0;
|
||||
FILE *fp;
|
||||
char *line;
|
||||
@@ -76,7 +76,7 @@ int read_config_file(const char *f) {
|
||||
|
||||
fp = fopen(f, "rt");
|
||||
if (!fp) {
|
||||
fprintf(stderr, "%s: %s\n", f, strerror(errno));
|
||||
if(whinge) fprintf(stderr, "%s: %s\n", f, strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -238,14 +238,9 @@ void config_set_string(const char *directive, const char* 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;
|
||||
void* o;
|
||||
|
||||
read_config_file(file);
|
||||
if(config == NULL) {
|
||||
fprintf(stderr,"Unable to read config file\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return read_config_file(file, whinge_on_error);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ AC_CONFIG_AUX_DIR(config)
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
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])
|
||||
|
||||
|
||||
11
iftop.8
11
iftop.8
@@ -11,7 +11,7 @@ iftop - display bandwidth usage on an interface by host
|
||||
|
||||
.SH SYNOPSIS
|
||||
\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
|
||||
\fBiftop\fP listens to network traffic on a named \fIinterface\fP, or on the
|
||||
@@ -53,7 +53,10 @@ slow?
|
||||
Print a summary of usage.
|
||||
.TP
|
||||
\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
|
||||
\fB-p\fP
|
||||
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.
|
||||
.TP
|
||||
\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
|
||||
\fB-B\fP
|
||||
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
|
||||
counted, so the specified code is evaluated as \fB(\fP\fIfilter code\fP\fB) and ip\fP.
|
||||
.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
|
||||
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.
|
||||
|
||||
4
iftop.c
4
iftop.c
@@ -518,11 +518,13 @@ int main(int argc, char **argv) {
|
||||
pthread_t thread;
|
||||
struct sigaction sa = {};
|
||||
|
||||
/* TODO: tidy this up */
|
||||
/* read command line options and config file */
|
||||
config_init();
|
||||
options_set_defaults();
|
||||
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();
|
||||
|
||||
sa.sa_handler = finish;
|
||||
|
||||
21
options.c
21
options.c
@@ -29,7 +29,7 @@
|
||||
|
||||
options_t options;
|
||||
|
||||
char optstr[] = "+i:f:nN:hpbBPm:";
|
||||
char optstr[] = "+i:f:nNF:hpbBPm:c:";
|
||||
|
||||
/* Global options. */
|
||||
|
||||
@@ -143,16 +143,17 @@ void options_set_defaults() {
|
||||
options.log_scale = 0;
|
||||
options.bar_interval = 1;
|
||||
|
||||
/* Figure out the name for the config file */
|
||||
s = getenv("HOME");
|
||||
if(s != NULL) {
|
||||
int i = strlen(s) + 9 + 1;
|
||||
options.config_file = xmalloc(i);
|
||||
snprintf(options.config_file,i,"%s/.iftoprc",s);
|
||||
fprintf(stderr,options.config_file);
|
||||
}
|
||||
else {
|
||||
options.config_file = xstrdup("iftoprc");
|
||||
}
|
||||
options.config_file_specified = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -239,6 +240,7 @@ static void usage(FILE *fp) {
|
||||
"\n"
|
||||
" -h display this message\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"
|
||||
" hosts on the same network segment)\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"
|
||||
" -f filter code use filter code to select packets to count\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"
|
||||
" -m limit sets the upper limit for the bandwidth scale\n"
|
||||
" -c config file specifies an alternative configuration file\n"
|
||||
"\n"
|
||||
"iftop, version " IFTOP_VERSION "\n"
|
||||
"copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors\n"
|
||||
@@ -269,6 +272,10 @@ void options_read_args(int argc, char **argv) {
|
||||
config_set_string("dns-resolution","true");
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
config_set_string("port-resolution","true");
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
config_set_string("interface", optarg);
|
||||
break;
|
||||
@@ -285,7 +292,7 @@ void options_read_args(int argc, char **argv) {
|
||||
config_set_string("port-display", "on");
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
case 'F':
|
||||
config_set_string("net-filter", optarg);
|
||||
break;
|
||||
|
||||
@@ -301,6 +308,12 @@ void options_read_args(int argc, char **argv) {
|
||||
config_set_string("use-bytes", "true");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
xfree(options.config_file);
|
||||
options.config_file = xstrdup(optarg);
|
||||
options.config_file_specified = 1;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
fprintf(stderr, "iftop: unknown option -%c\n", optopt);
|
||||
usage(stderr);
|
||||
|
||||
@@ -78,6 +78,7 @@ typedef struct {
|
||||
struct in_addr netfiltermask;
|
||||
|
||||
char *config_file;
|
||||
int config_file_specified;
|
||||
|
||||
} options_t;
|
||||
|
||||
|
||||
8
ui.c
8
ui.c
@@ -34,13 +34,13 @@
|
||||
|
||||
#define HELP_MESSAGE \
|
||||
"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"\
|
||||
" d - toggle show destination host b - toggle bar graph display\n"\
|
||||
" t - cycle line display mode B - cycle bar graph average\n"\
|
||||
" T - toggle cummulative line totals\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"\
|
||||
" D - toggle show destination port L - lin/log scales\n"\
|
||||
" p - toggle port display ! - shell command\n"\
|
||||
@@ -807,7 +807,7 @@ void ui_loop() {
|
||||
foad = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'n':
|
||||
if(options.dnsresolution) {
|
||||
options.dnsresolution = 0;
|
||||
showhelp("DNS resolution off");
|
||||
@@ -819,7 +819,7 @@ void ui_loop() {
|
||||
tick(1);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
case 'N':
|
||||
if(options.portresolution) {
|
||||
options.portresolution = 0;
|
||||
showhelp("Port resolution off");
|
||||
|
||||
Reference in New Issue
Block a user