Line 0
Link Here
|
|
|
1 |
--- display.c.orig Sun Aug 23 21:51:48 1998 |
2 |
+++ display.c Fri Dec 6 12:17:55 2002 |
3 |
@@ -54,6 +54,7 @@ |
4 |
static int l_nflag, l_eflag; |
5 |
static int n_entries; |
6 |
static int err_pos; |
7 |
+extern struct t_entry t_mask; /* traffic mask */ |
8 |
|
9 |
void |
10 |
init_display(reinit) |
11 |
@@ -282,6 +284,13 @@ |
12 |
packets_total++; |
13 |
bytes_total += e->bytes; |
14 |
j = page * page_size; |
15 |
+ |
16 |
+ e->src.s_addr &= t_mask.src.s_addr; |
17 |
+ e->dst.s_addr &= t_mask.dst.s_addr; |
18 |
+ e->sport &= t_mask.sport; |
19 |
+ e->dport &= t_mask.dport; |
20 |
+ e->proto &= t_mask.proto; |
21 |
+ |
22 |
for (i = 0; i < n_entry; i++) { |
23 |
if (memcmp(&e->eh, &entries[i].eh, sizeof(e->eh)) == 0 && |
24 |
e->src.s_addr == entries[i].src.s_addr && |
25 |
--- trafshow.c.orig Fri Aug 28 00:15:57 1998 |
26 |
+++ trafshow.c Fri Dec 6 12:34:09 2002 |
27 |
@@ -48,6 +48,7 @@ |
28 |
int pflag = 0; /* don't put the interface into promiscuous mode */ |
29 |
int kflag = 1; /* disable keyboard input checking */ |
30 |
int eflag = 0; /* show ethernet traffic rather than ip */ |
31 |
+struct t_entry t_mask; /* traffic mask */ |
32 |
|
33 |
/* global variables */ |
34 |
char *program_name; /* myself */ |
35 |
@@ -78,6 +79,12 @@ |
36 |
extern int abort_on_misalignment(); |
37 |
extern pcap_handler lookup_if(); |
38 |
|
39 |
+ t_mask.src.s_addr = 0xffffffff; /* all bits valid */ |
40 |
+ t_mask.dst.s_addr = 0xffffffff; /* all bits valid */ |
41 |
+ t_mask.sport = 0xffff; /* all bits valid */ |
42 |
+ t_mask.dport = 0xffff; /* all bits valid */ |
43 |
+ t_mask.proto = 0xffff; /* all bits valid */ |
44 |
+ |
45 |
cnt = -1; |
46 |
device_name = NULL; |
47 |
infile = NULL; |
48 |
@@ -94,7 +87,7 @@ |
49 |
|
50 |
if (abort_on_misalignment(ebuf) < 0) error(0, ebuf); |
51 |
|
52 |
- while ((op = getopt(argc, argv, "c:CefF:i:knNOpr:t:vh?")) != EOF) |
53 |
+ while ((op = getopt(argc, argv, "c:CefF:i:kmnNOpr:t:vh?")) != EOF) |
54 |
switch (op) { |
55 |
case 'C': |
56 |
#ifdef HAVE_SLCURSES |
57 |
@@ -114,6 +121,40 @@ |
58 |
break; |
59 |
case 'k': |
60 |
kflag = 0; |
61 |
+ break; |
62 |
+ case 'm': |
63 |
+ t_mask.src.s_addr = 0; |
64 |
+ t_mask.dst.s_addr = 0; |
65 |
+ t_mask.sport = 0; |
66 |
+ t_mask.dport = 0; |
67 |
+ t_mask.proto = 0; |
68 |
+ for (;optind + 1 <= argc;) { |
69 |
+ char *s = argv[optind]; |
70 |
+ u_int32_t arg = 0xffffffff; |
71 |
+ int save=optind; |
72 |
+ |
73 |
+ optind++; |
74 |
+ if (optind + 1 <= argc && |
75 |
+ isdigit(*(argv[optind])) ) { |
76 |
+ arg = strtoul(argv[optind], NULL, 0); |
77 |
+ optind++; |
78 |
+ } |
79 |
+ |
80 |
+ if (!strcmp(s, "src-ip")) |
81 |
+ t_mask.src.s_addr = htonl(arg); |
82 |
+ else if (!strcmp(s, "dst-ip")) |
83 |
+ t_mask.dst.s_addr = htonl(arg); |
84 |
+ else if (!strcmp(s, "src-port")) |
85 |
+ t_mask.sport = htons((u_short)(arg)); |
86 |
+ else if (!strcmp(s, "dst-port")) |
87 |
+ t_mask.dport = htons((u_short)(arg)); |
88 |
+ else if (!strcmp(s, "proto")) |
89 |
+ t_mask.proto = arg; |
90 |
+ else { |
91 |
+ optind = save; |
92 |
+ break; |
93 |
+ } |
94 |
+ } |
95 |
break; |
96 |
case 'n': |
97 |
++nflag; |
98 |
--- trafshow.1.orig Fri Aug 28 09:37:38 1998 |
99 |
+++ trafshow.1 Tue Apr 15 22:32:21 2003 |
100 |
@@ -42,6 +42,16 @@ |
101 |
.B \-k |
102 |
Disable input keyboard checking. It is intended to avoid loss of packets. |
103 |
.TP |
104 |
+.B \-m |
105 |
+[src-ip M] [dst-ip M] [src-port M] [dst-port M] [proto M] |
106 |
+.br |
107 |
+Mask the specified field with mask M (which should be specified |
108 |
+as an hex number e.g. 0xffff0000) before further processing |
109 |
+of the packet. This allows to aggregate traffic in the display |
110 |
+to ease analysis. |
111 |
+.br |
112 |
+.The masks for all field not specified will be set to 0. |
113 |
+.TP |
114 |
.B \-n |
115 |
Don't convert host addresses and port numbers to names. |
116 |
.TP |
117 |
|
118 |
|
119 |
|