Commit e7c96c16 authored by chris's avatar chris
Browse files

""

parent 57afc62a
......@@ -65,11 +65,9 @@ tags :
etags *.c *.h
depend: $(SRCS)
$(CPP) -MM $(SRCS) > depend
$(CPP) $(CFLAGS) -MM $(SRCS) > depend
nodepend:
rm -f depend
include depend
......@@ -11,7 +11,7 @@ iftop - display bandwidth usage on an interface by host
.SH SYNOPSIS
\fBiftop\fP \fB-h\fP |
[\fB-d\fP] [\fB-p\fP] [\fB-i\fP \fIinterface\fP] [\fB-f\fP \fIfilter code\fP]
[\fB-d\fP] [\fB-p\fP] [\fB-i\fP \fIinterface\fP] [\fB-f\fP \fIfilter code\fP] [\fB-n\fP \fInet\fP/\fImask\fP]
.SH DESCRIPTION
\fBiftop\fP listens to network traffic on a named \fIinterface\fP, or \fBeth0\fP
......@@ -68,7 +68,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/mask\fP
\fB-n\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.
......
......@@ -15,6 +15,7 @@
#include <curses.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include "iftop.h"
#include "addr_hash.h"
......
......@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "options.h"
......@@ -35,18 +36,27 @@ void die(char *msg) {
void set_net_filter(char* arg) {
char* mask;
mask = strstr(arg, "/");
if(mask == NULL) {
mask = strchr(arg, '/');
if (mask == NULL) {
die("Could not parse net/mask\n");
}
*mask = '\0';
mask++;
if(inet_aton(arg, &options.netfilternet) == 0) {
if (inet_aton(arg, &options.netfilternet) == 0)
die("Invalid network address\n");
}
if(inet_aton(mask, &options.netfiltermask) == 0) {
die("Invalid network mask\n");
}
/* Accept a netmask like /24 or /255.255.255.0. */
if (!mask[strspn(mask, "0123456789")]) {
int n;
n = atoi(mask);
if (n > 32)
die("Invalid netmask");
else {
uint32_t mm = 0xffffffffl;
mm >>= n;
options.netfiltermask.s_addr = htonl(~mm);
}
} else if (inet_aton(mask, &options.netfiltermask) == 0)
die("Invalid netmask\n");
options.netfilter = 1;
......@@ -58,7 +68,7 @@ void usage(FILE *fp) {
fprintf(fp,
"iftop: display bandwidth usage on an interface by host\n"
"\n"
"Synopsis: iftop -h | [-d] [-p] [-i interface] [-f filter code]\n"
"Synopsis: iftop -h | [-d] [-p] [-i interface] [-f filter code] [-n net/mask]\n"
"\n"
" -h display this message\n"
" -d don't do hostname lookups\n"
......@@ -69,7 +79,7 @@ void usage(FILE *fp) {
" (default: none, but only IP packets are counted)\n"
" -n network/netmask show traffic flows in/out of network\n"
"\n"
"iftop, version " IFTOP_VERSION "copyright (c) 2002 Paul Warren <pdw@ex-parrot.com>\n"
"iftop, version " IFTOP_VERSION " copyright (c) 2002 Paul Warren <pdw@ex-parrot.com>\n"
);
}
......
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