Commit d7a2dd8f authored by pdw's avatar pdw

Code tidy.

Documented config file.
Added screen-filter config option.
Added "pre-release" warning to configure.
parent 3932a7d1
......@@ -19,30 +19,24 @@
#define MAX_CONFIG_LINE 2048
typedef struct {
char * name;
int type;
} config_item_type;
config_item_type config_directives[] = {
{ "interface", CONFIG_TYPE_STRING },
{ "dns-resolution", CONFIG_TYPE_BOOL },
{ "port-resolution", CONFIG_TYPE_BOOL },
{ "filter-code", CONFIG_TYPE_STRING },
{ "show-bars", CONFIG_TYPE_BOOL },
{ "promiscuous", CONFIG_TYPE_BOOL },
{ "show-ports", CONFIG_TYPE_INT },
{ "hide-source", CONFIG_TYPE_INT },
{ "hide-destination", CONFIG_TYPE_INT },
{ "use-bytes", CONFIG_TYPE_INT },
{ "sort", CONFIG_TYPE_INT },
{ "line-display", CONFIG_TYPE_INT },
{ "show-totals", CONFIG_TYPE_INT },
{ "log-scale", CONFIG_TYPE_INT },
{ "max-bandwidth", CONFIG_TYPE_INT },
{ "net-filter", CONFIG_TYPE_INT },
{ "port-display", CONFIG_TYPE_INT },
{ NULL, 0}
char * config_directives[] = {
"interface",
"dns-resolution",
"port-resolution",
"filter-code",
"show-bars",
"promiscuous",
"hide-source",
"hide-destination",
"use-bytes",
"sort",
"line-display",
"show-totals",
"log-scale",
"max-bandwidth",
"net-filter",
"port-display",
NULL
};
stringmap config;
......@@ -50,9 +44,9 @@ stringmap config;
extern options_t options ;
int is_cfgdirective_valid(const char *s) {
config_item_type* t;
for (t = config_directives; t->name != NULL; ++t)
if (strcmp(s, t->name) == 0) return 1;
char* t;
for (t = config_directives[0]; t != NULL; ++t)
if (strcmp(s, t) == 0) return 1;
return 0;
}
......@@ -239,7 +233,6 @@ void config_set_string(const char *directive, const char* s) {
}
int read_config(char *file, int whinge_on_error) {
config_item_type* t;
void* o;
return read_config_file(file, whinge_on_error);
......
......@@ -390,3 +390,24 @@ AC_SUBST(ac_aux_dir)
AC_OUTPUT(Makefile config/Makefile)
if echo $VERSION | grep 'pre' ; then
AC_MSG_WARN([
******************************************************************************
This is a pre-release version. Pre-releases are subject to limited
announcements, and therefore limited circulation, as a means of testing
the more widely circulated final releases.
Please do not be surprised if this release is utterly, utterly broken. If you
do find this release to be utterly, utterly broken, do not assume that someone
else has spotted it. Instead, please drop a note on the mailing list,
or a brief email to me on pdw@ex-parrot.com
Thank you for taking the time to be the testing phase of this development
process.
Paul Warren
******************************************************************************
])
fi
......@@ -84,6 +84,10 @@ 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.
You may specify \fImask\fP as a dotted quad, such as /255.255.255.0, or as a
single number specifying the number of bits set in the netmask, such as /24.
.TP
\fB-c\fP \fIconfig file\fP
Specifies an alternate config file. If not specified, iftop will use
\fB~/.iftopc\fP if it exists. See below for a description of config files
.SH DISPLAY
......@@ -170,6 +174,75 @@ useful when the display order is frozen (see above).
\fBf\fP allows you to edit the filter code whilst iftop running. This
can lead to some unexpected behaviour.
.SH CONFIG FILE
iftop can read its configuration from a config file. If the \fB-c\fP option is
not specified, iftop will attempt to read its configuration from
\fB~/.iftoprc\fP, if it exists. Any command line options specified will
override settings in the config file.
The config file consists of one configuration directive per line. Each
directive is a name value pair, for example:
.nf
interface: eth0
.Sp
.fi
sets the network interface. The following config directives are supported:
.TP
\fBinterface:\fP \fIif\fP
Sets the network interface to \fIif\fP.
.TP
\fBdns-resolution:\fP \fI(yes|no)\fP
Controls reverse lookup of IP addresses.
.TP
\fBport-resolution:\fP \fI(yes|no)\fP
Controls conversion of port numbers to service names.
.TP
\fBfilter-code:\fP \fIbpf\fP
Sets the filter code to \fIbpf\fP.
.TP
\fBshow-bars:\fP \fI(yes|no)\fP
Controls display of bar graphs.
.TP
\fBpromiscuous:\fP \fI(yes|no)\fP
Puts the interface into promiscuous mode.
.TP
\fBport-display:\fP \fI(off|source-only|destination-only|on)\fP
Controls display of port numbers.
.TP
\fBhide-source:\fP \fI(yes|no)\fP
Hides source host names.
.TP
\fBhide-destination:\fP \fI(yes|no)\fP
Hides destination host names.
.TP
\fBuse-bytes:\fP \fI(yes|no)\fP
Use bytes for bandwidth display, rather than bits.
.TP
\fBsort:\fP \fI(2s|10s|40s|source|destination)\fP
Sets which column is used to sort the display.
.TP
\fBline-display:\fP \fI(two-line|one-line-both|one-line-sent|one-line-received)\fP
Controls the appearance of each item in the display.
.TP
\fBshow-totals:\fP \fI(yes|no)\fP
Shows cummulative total for each item.
.TP
\fBlog-scale:\fP \fI(yes|no)\fP
Use a logarithmic scale for bar graphs.
.TP
\fBmax-bandwidth:\fP \fIbw\fP
Fixes the maximum for the bar graph scale to \fIbw\fP, e.g. "10M"
.TP
\fBnet-filter:\fP \fInet/mask\fP
Defines an IP network boundary for determining packet direction.
.TP
\fBscreen-filter:\fP \fIregexp\fP
Sets a regular expression to filter screen output.
.SH QUIRKS (aka they're features, not bugs)
There are some circumstances in which iftop may not do what you expect. In
......@@ -207,6 +280,12 @@ changing the filter there may be entries on the display that are
disallowed by the current filter for up to 40s. DISPLAY FILTERING has
immediate effect and does not affect what is captured.
.SH FILES
.TP
\fB~/.iftoprc\fP
Configuration file for iftop.
.SH SEE ALSO
.BR tcpdump (8),
.BR pcap (3),
......
......@@ -50,8 +50,8 @@ static char *bad_interface_names[] = {
config_enumeration_type sort_enumeration[] = {
{ "2s", OPTION_SORT_DIV1 },
{ "10", OPTION_SORT_DIV2 },
{ "40", OPTION_SORT_DIV3 },
{ "10s", OPTION_SORT_DIV2 },
{ "40s", OPTION_SORT_DIV3 },
{ "source", OPTION_SORT_SRC },
{ "destination", OPTION_SORT_SRC },
{ NULL, -1 }
......@@ -496,5 +496,6 @@ void options_make() {
options_config_get_bool("log-scale", &options.log_scale);
options_config_get_bw_rate("max-bandwidth", &options.max_bandwidth);
options_config_get_enum("port-display", showports_enumeration, (int*)&options.showports);
options_config_get_string("screen-filter", &options.screenfilter);
options_config_get_net_filter();
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment