]> git.pld-linux.org Git - packages/arpwatch.git/blame - arpwatch-debian_13opt_allsubnets.patch
- release 2
[packages/arpwatch.git] / arpwatch-debian_13opt_allsubnets.patch
CommitLineData
e2fb63d0
TP
1Index: arpwatch/arpsnmp.c
2diff -u arpwatch/arpsnmp.c:1.1.1.1.2.2 arpwatch/arpsnmp.c:1.1.1.1.2.1.6.2
3--- arpwatch/arpsnmp.c:1.1.1.1.2.2 Tue Aug 10 11:14:13 2004
4+++ arpwatch/arpsnmp.c Fri Aug 13 02:17:33 2004
5@@ -63,7 +63,7 @@
6 /* Forwards */
7 int main(int, char **);
8 int readsnmp(char *);
9-int snmp_add(u_int32_t, u_char *, time_t, char *);
10+int snmp_add(u_int32_t, u_char *, time_t, char *, char *);
11 __dead void usage(void) __attribute__((volatile));
12
13 char *prog;
14@@ -143,22 +143,24 @@
15 static time_t now;
16
17 int
18-snmp_add(register u_int32_t a, register u_char *e, time_t t, register char *h)
19+snmp_add(register u_int32_t a, register u_char *e, time_t t, register char *h,
20+ char *interface)
21 {
22 /* Watch for ethernet broadcast */
23 if (MEMCMP(e, zero, 6) == 0 || MEMCMP(e, allones, 6) == 0) {
24- dosyslog(LOG_INFO, "ethernet broadcast", a, e, NULL);
25+ dosyslog(LOG_INFO, "ethernet broadcast", a, e, NULL,
26+ interface);
27 return (1);
28 }
29
30 /* Watch for some ip broadcast addresses */
31 if (a == 0 || a == 1) {
32- dosyslog(LOG_INFO, "ip broadcast", a, e, NULL);
33+ dosyslog(LOG_INFO, "ip broadcast", a, e, NULL, interface);
34 return (1);
35 }
36
37 /* Use current time (although it would be nice to subtract idle time) */
38- return (ent_add(a, e, now, h));
39+ return (ent_add(a, e, now, h, interface));
40 }
41
42 /* Process an snmp file */
43Index: arpwatch/arpwatch.8
44diff -u arpwatch/arpwatch.8:1.1.1.1.2.2 arpwatch/arpwatch.8:1.1.1.1.8.5
45--- arpwatch/arpwatch.8:1.1.1.1.2.2 Thu Aug 12 22:31:09 2004
46+++ arpwatch/arpwatch.8 Fri Aug 13 01:54:24 2004
47@@ -63,6 +63,13 @@
48 ]
49 .\" **
50 .\" **
51+.br
52+.ti +8
53+[
54+.B -a
55+]
56+.\" **
57+.\" **
58 .ad
59 .SH DESCRIPTION
60 .B Arpwatch
61@@ -127,6 +134,20 @@
62 .\" **
63 .\" **
64 .LP
65+(Debian)
66+.B -a
67+By default,
68+.B arpwatch
69+reports bogons (unless
70+.B -N
71+is given) for IP addresses that are in the same subnet than the
72+first IP address of the default interface. If this option is
73+specified,
74+.B arpwatch
75+will report bogons about every IP addresses.
76+.\" **
77+.\" **
78+.LP
79 Note that an empty
80 .I arp.dat
81 file must be created before the first time you run
82Index: arpwatch/arpwatch.c
83diff -u arpwatch/arpwatch.c:1.1.1.1.2.5 arpwatch/arpwatch.c:1.1.1.1.2.1.6.11
84--- arpwatch/arpwatch.c:1.1.1.1.2.5 Sat Aug 14 02:33:07 2004
85+++ arpwatch/arpwatch.c Sat Aug 14 02:34:27 2004
86@@ -141,6 +141,8 @@
87 int sanity_fddi(struct fddi_header *, struct ether_arp *, int);
88 __dead void usage(void) __attribute__((volatile));
89
90+static char *interface;
91+
92 int
93 main(int argc, char **argv)
94 {
95@@ -150,7 +152,7 @@
96 register int fd;
97 #endif
98 register pcap_t *pd;
99- register char *interface, *rfilename;
100+ register char *rfilename;
101 struct bpf_program code;
102 char errbuf[PCAP_ERRBUF_SIZE];
103 char options[] =
104@@ -172,6 +174,9 @@
105 "r:"
106 /**/
107 /**/
108+ "a"
109+ /**/
110+ /**/
111 ;
112
113 if (argv[0] == NULL)
114@@ -193,6 +198,10 @@
115 while ((op = getopt(argc, argv, options)) != EOF)
116 switch (op) {
117
118+ case 'a':
119+ ++allsubnets;
120+ break;
121+
122 case 'd':
123 ++debug;
124 #ifndef DEBUG
125@@ -401,29 +410,31 @@
126
127 /* Watch for bogons */
128 if (isbogon(sia)) {
129- dosyslog(LOG_INFO, "bogon", sia, sea, sha);
130- return;
131+ dosyslog(LOG_INFO, "bogon", sia, sea, sha, interface);
132+ if (!allsubnets) return;
133 }
134
135 /* Watch for ethernet broadcast */
136 if (MEMCMP(sea, zero, 6) == 0 || MEMCMP(sea, allones, 6) == 0 ||
137 MEMCMP(sha, zero, 6) == 0 || MEMCMP(sha, allones, 6) == 0) {
138- dosyslog(LOG_INFO, "ethernet broadcast", sia, sea, sha);
139+ dosyslog(LOG_INFO, "ethernet broadcast", sia, sea, sha,
140+ interface);
141 return;
142 }
143
144 /* Double check ethernet addresses */
145 if (MEMCMP(sea, sha, 6) != 0) {
146- dosyslog(LOG_INFO, "ethernet mismatch", sia, sea, sha);
147+ dosyslog(LOG_INFO, "ethernet mismatch", sia, sea, sha,
148+ interface);
149 return;
150 }
151
152 /* Got a live one */
153 t = h->ts.tv_sec;
154 can_checkpoint = 0;
155- if (!ent_add(sia, sea, t, NULL))
156- syslog(LOG_ERR, "ent_add(%s, %s, %ld) failed",
157- intoa(sia), e2str(sea), t);
158+ if (!ent_add(sia, sea, t, NULL, interface))
159+ syslog(LOG_ERR, "ent_add(%s, %s, %ld, %s) failed",
160+ intoa(sia), e2str(sea), t, interface);
161 can_checkpoint = 1;
162 }
163
164@@ -550,29 +561,31 @@
165
166 /* Watch for bogons */
167 if (isbogon(sia)) {
168- dosyslog(LOG_INFO, "bogon", sia, sea, sha);
169- return;
170+ dosyslog(LOG_INFO, "bogon", sia, sea, sha, interface);
171+ if (!allsubnets) return;
172 }
173
174 /* Watch for ethernet broadcast */
175 if (MEMCMP(sea, zero, 6) == 0 || MEMCMP(sea, allones, 6) == 0 ||
176 MEMCMP(sha, zero, 6) == 0 || MEMCMP(sha, allones, 6) == 0) {
177- dosyslog(LOG_INFO, "ethernet broadcast", sia, sea, sha);
178+ dosyslog(LOG_INFO, "ethernet broadcast", sia, sea, sha,
179+ interface);
180 return;
181 }
182
183 /* Double check ethernet addresses */
184 if (MEMCMP(sea, sha, 6) != 0) {
185- dosyslog(LOG_INFO, "ethernet mismatch", sia, sea, sha);
186+ dosyslog(LOG_INFO, "ethernet mismatch", sia, sea, sha,
187+ interface);
188 return;
189 }
190
191 /* Got a live one */
192 t = h->ts.tv_sec;
193 can_checkpoint = 0;
194- if (!ent_add(sia, sea, t, NULL))
195- syslog(LOG_ERR, "ent_add(%s, %s, %ld) failed",
196- intoa(sia), e2str(sea), t);
197+ if (!ent_add(sia, sea, t, NULL, interface))
198+ syslog(LOG_ERR, "ent_add(%s, %s, %ld, %s) failed",
199+ intoa(sia), e2str(sea), t, interface);
200 can_checkpoint = 1;
201 }
202
203@@ -785,6 +798,9 @@
204 "[-r file] "
205 /**/
206 /**/
207+ "[-a] "
208+ /**/
209+ /**/
210 "\n"
211 ;
212
213Index: arpwatch/db.c
214diff -u arpwatch/db.c:1.1.1.1 arpwatch/db.c:1.1.1.1.8.1
215--- arpwatch/db.c:1.1.1.1 Tue Apr 17 13:31:36 2001
216+++ arpwatch/db.c Fri Aug 13 02:17:33 2004
217@@ -64,6 +64,7 @@
218 u_char e[6]; /* ether address */
219 char h[34]; /* simple hostname */
220 time_t t; /* timestamp */
221+ char i[16]; /* interface */
222 };
223
224 /* Address info */
225@@ -80,13 +81,14 @@
226
227 static void alist_alloc(struct ainfo *);
228 int cmpeinfo(const void *, const void *);
229-static struct einfo *elist_alloc(u_int32_t, u_char *, time_t, char *);
230+static struct einfo *elist_alloc(u_int32_t, u_char *, time_t, char *, char *);
231 static struct ainfo *ainfo_find(u_int32_t);
232 static void check_hname(struct ainfo *);
233 struct ainfo *newainfo(void);
234
235 int
236-ent_add(register u_int32_t a, register u_char *e, time_t t, register char *h)
237+ent_add(register u_int32_t a, register u_char *e, time_t t, register char *h,
238+ char *interface)
239 {
240 register struct ainfo *ap;
241 register struct einfo *ep;
242@@ -103,7 +105,8 @@
243 ep = ap->elist[0];
244 if (MEMCMP(e, ep->e, 6) == 0) {
245 if (t - ep->t > NEWACTIVITY_DELTA) {
246- report("new activity", a, e, NULL, &t, &ep->t);
247+ report("new activity", a, e, NULL, &t, &ep->t,
248+ interface);
249 check_hname(ap);
250 }
251 ep->t = t;
252@@ -114,8 +117,8 @@
253 /* Check for a virgin ainfo record */
254 if (ap->ecount == 0) {
255 ap->ecount = 1;
256- ap->elist[0] = elist_alloc(a, e, t, h);
257- report("new station", a, e, NULL, &t, NULL);
258+ ap->elist[0] = elist_alloc(a, e, t, h, interface);
259+ report("new station", a, e, NULL, &t, NULL, interface);
260 return (1);
261 }
262
263@@ -133,9 +136,11 @@
264 if (t - t2 < FLIPFLIP_DELTA &&
265 (isdecnet(e) || isdecnet(e2)))
266 dosyslog(LOG_INFO,
267- "suppressed DECnet flip flop", a, e, e2);
268+ "suppressed DECnet flip flop", a, e, e2,
269+ interface);
270 else
271- report("flip flop", a, e, e2, &t, &t2);
272+ report("flip flop", a, e, e2, &t, &t2,
273+ interface);
274 ap->elist[1] = ap->elist[0];
275 ap->elist[0] = ep;
276 ep->t = t;
277@@ -151,7 +156,7 @@
278 e2 = ap->elist[0]->e;
279 t2 = ap->elist[0]->t;
280 dosyslog(LOG_NOTICE, "reused old ethernet address",
281- a, e, e2);
282+ a, e, e2, interface);
283 /* Shift entries down */
284 len = i * sizeof(ap->elist[0]);
285 BCOPY(&ap->elist[0], &ap->elist[1], len);
286@@ -165,12 +170,12 @@
287 /* New ether address */
288 e2 = ap->elist[0]->e;
289 t2 = ap->elist[0]->t;
290- report("changed ethernet address", a, e, e2, &t, &t2);
291+ report("changed ethernet address", a, e, e2, &t, &t2, interface);
292 /* Make room at head of list */
293 alist_alloc(ap);
294 len = ap->ecount * sizeof(ap->elist[0]);
295 BCOPY(&ap->elist[0], &ap->elist[1], len);
296- ap->elist[0] = elist_alloc(a, e, t, h);
297+ ap->elist[0] = elist_alloc(a, e, t, h, interface);
298 ++ap->ecount;
299 return (1);
300 }
301@@ -227,7 +232,7 @@
302 for (ap = &ainfo_table[i]; ap != NULL; ap = ap->next)
303 for (j = 0; j < ap->ecount; ++j) {
304 ep = ap->elist[j];
305- (*fn)(ap->a, ep->e, ep->t, ep->h);
306+ (*fn)(ap->a, ep->e, ep->t, ep->h, ep->i);
307 ++n;
308 }
309 return (n);
310@@ -259,7 +264,7 @@
311 /* Allocate and initialize a elist struct */
312 static struct einfo *
313 elist_alloc(register u_int32_t a, register u_char *e, register time_t t,
314- register char *h)
315+ register char *h, char *interface)
316 {
317 register struct einfo *ep;
318 register u_int size;
319@@ -286,6 +291,8 @@
320 if (h != NULL && !isdigit((int)*h))
321 strcpy(ep->h, h);
322 ep->t = t;
323+ if (interface != NULL)
324+ strncpy(ep->i, interface, 16);
325 return (ep);
326 }
327
328Index: arpwatch/db.h
329diff -u arpwatch/db.h:1.1.1.1 arpwatch/db.h:1.1.1.1.8.1
330--- arpwatch/db.h:1.1.1.1 Tue Apr 17 13:31:36 2001
331+++ arpwatch/db.h Fri Aug 13 02:17:33 2004
332@@ -1,10 +1,10 @@
333 /* @(#) $Header$ (LBL) */
334
335-typedef void (*ent_process)(u_int32_t, u_char *, time_t, char *);
336+typedef void (*ent_process)(u_int32_t, u_char *, time_t, char *, char *);
337
338 #ifdef DEBUG
339 void debugdump(void);
340 #endif
341-int ent_add(u_int32_t, u_char *, time_t, char *);
342+int ent_add(u_int32_t, u_char *, time_t, char *, char *);
343 int ent_loop(ent_process);
344 void sorteinfo(void);
345Index: arpwatch/file.c
346diff -u arpwatch/file.c:1.1.1.1 arpwatch/file.c:1.1.1.1.8.1
347--- arpwatch/file.c:1.1.1.1 Tue Apr 17 13:31:37 2001
348+++ arpwatch/file.c Fri Aug 13 02:17:33 2004
349@@ -69,6 +69,7 @@
350 u_int32_t a;
351 register time_t t;
352 register struct hostent *hp;
353+ char *interface;
354 char line[1024];
355 u_char e[6];
356
357@@ -117,6 +118,7 @@
358 if (cp2 == NULL) {
359 t = 0;
360 h = NULL;
361+ interface = NULL;
362 } else {
363 t = atoi(cp2);
364 h = strchr(cp2, '\t');
365@@ -126,11 +128,18 @@
366 while (*cp2 != '\n' && *cp2 != '\t' &&
367 *cp2 != '\0')
368 ++cp2;
369+ if (*cp2 == '\t') {
370+ *cp2++ = '\0';
371+ while (*cp2 != '\n' && *cp2 != '\t' &&
372+ *cp2 != '\0') ++cp2;
373+ } else {
374+ interface = NULL;
375+ }
376 *cp2 = '\0';
377 }
378 }
379
380- if (!(*fn)(a, e, t, h))
381+ if (!(*fn)(a, e, t, h, interface))
382 return(0);
383 }
384
385Index: arpwatch/file.h
386diff -u arpwatch/file.h:1.1.1.1 arpwatch/file.h:1.1.1.1.8.1
387--- arpwatch/file.h:1.1.1.1 Tue Apr 17 13:31:37 2001
388+++ arpwatch/file.h Fri Aug 13 02:17:33 2004
389@@ -1,5 +1,5 @@
390 /* @(#) $Header$ (LBL) */
391
392-typedef int (*file_process)(u_int32_t, u_char *, time_t, char *);
393+typedef int (*file_process)(u_int32_t, u_char *, time_t, char *, char *);
394
395 int file_loop(FILE *, file_process, const char *);
396Index: arpwatch/report.c
397diff -u arpwatch/report.c:1.1.1.1 arpwatch/report.c:1.1.1.1.8.1
398--- arpwatch/report.c:1.1.1.1 Tue Apr 17 13:31:37 2001
399+++ arpwatch/report.c Fri Aug 13 02:17:33 2004
400@@ -233,7 +233,8 @@
401
402 void
403 report(register char *title, register u_int32_t a, register u_char *e1,
404- register u_char *e2, register time_t *t1p, register time_t *t2p)
405+ register u_char *e2, register time_t *t1p, register time_t *t2p,
406+ char *interface)
407 {
408 register char *cp, *hn;
409 register int fd, pid;
410@@ -253,7 +254,7 @@
411
412 if (debug) {
413 if (debug > 1) {
414- dosyslog(LOG_NOTICE, title, a, e1, e2);
415+ dosyslog(LOG_NOTICE, title, a, e1, e2, interface);
416 return;
417 }
418 f = stdout;
419@@ -270,7 +271,7 @@
420 }
421
422 /* Syslog this event too */
423- dosyslog(LOG_NOTICE, title, a, e1, e2);
424+ dosyslog(LOG_NOTICE, title, a, e1, e2, interface);
425
426 /* Update child depth */
427 ++cdepth;
428@@ -302,16 +303,19 @@
429
430 (void)fprintf(f, "From: %s\n", watchee);
431 (void)fprintf(f, "To: %s\n", watcher);
432+ if (interface == NULL) interface = ""; /* shouldn't happen */
433 hn = gethname(a);
434 if (!isdigit(*hn))
435- (void)fprintf(f, "Subject: %s (%s)\n", title, hn);
436+ (void)fprintf(f, "Subject: %s (%s) %s\n", title, hn,
437+ interface);
438 else {
439- (void)fprintf(f, "Subject: %s\n", title);
440+ (void)fprintf(f, "Subject: %s %s\n", title, interface);
441 hn = unknown;
442 }
443 (void)putc('\n', f);
444 (void)fprintf(f, fmt, "hostname", hn);
445 (void)fprintf(f, fmt, "ip address", intoa(a));
446+ (void)fprintf(f, fmt, "interface", interface);
447 (void)fprintf(f, fmt, "ethernet address", e2str(e1));
448 if ((cp = ec_find(e1)) == NULL)
449 cp = unknown;
450Index: arpwatch/report.h
451diff -u arpwatch/report.h:1.1.1.1 arpwatch/report.h:1.1.1.1.8.1
452--- arpwatch/report.h:1.1.1.1 Tue Apr 17 13:31:37 2001
453+++ arpwatch/report.h Fri Aug 13 02:17:33 2004
454@@ -1,3 +1,3 @@
455 /* @(#) $Header$ (LBL) */
456
457-void report(char *, u_int32_t, u_char *, u_char *, time_t *, time_t *);
458+void report(char *, u_int32_t, u_char *, u_char *, time_t *, time_t *, char *);
459Index: arpwatch/util.c
460diff -u arpwatch/util.c:1.1.1.1.2.2 arpwatch/util.c:1.1.1.1.8.5
461--- arpwatch/util.c:1.1.1.1.2.2 Fri Aug 13 00:06:49 2004
462+++ arpwatch/util.c Fri Aug 13 02:17:33 2004
463@@ -63,11 +63,14 @@
464 int initializing = 1; /* true if initializing */
465 /**/
466 /**/
467+int allsubnets = 0; /* watch all attached subnets */
468+/**/
469+/**/
470
471 /* syslog() helper routine */
472 void
473 dosyslog(register int p, register char *s, register u_int32_t a,
474- register u_char *ea, register u_char *ha)
475+ register u_char *ea, register u_char *ha, char *interface)
476 {
477 char xbuf[64];
478
479@@ -84,23 +87,21 @@
480 }
481
482 if (debug)
483- fprintf(stderr, "%s: %s %s %s\n", prog, s, intoa(a), xbuf);
484+ fprintf(stderr, "%s: %s %s %s %s\n", prog, s, intoa(a),
485+ xbuf, interface);
486 else
487- syslog(p, "%s %s %s", s, intoa(a), xbuf);
488+ syslog(p, "%s %s %s %s", s, intoa(a), xbuf, interface);
489 }
490
491 static FILE *dumpf;
492
493 void
494 dumpone(register u_int32_t a, register u_char *e, register time_t t,
495- register char *h)
496+ register char *h, char *interface)
497 {
498- (void)fprintf(dumpf, "%s\t%s", e2str(e), intoa(a));
499- if (t != 0 || h != NULL)
500- (void)fprintf(dumpf, "\t%u", (u_int32_t)t);
501- if (h != NULL && *h != '\0')
502- (void)fprintf(dumpf, "\t%s", h);
503- (void)putc('\n', dumpf);
504+ (void)fprintf(dumpf, "%s\t%s\t%u\t%s\t%s\n", e2str(e), intoa(a),
505+ (u_int32_t)t, ((h != NULL)?h:""),
506+ ((interface != NULL)?interface:""));
507 }
508
509 int
510Index: arpwatch/util.h
511diff -u arpwatch/util.h:1.1.1.1.2.1 arpwatch/util.h:1.1.1.1.8.4
512--- arpwatch/util.h:1.1.1.1.2.1 Fri Aug 13 00:06:49 2004
513+++ arpwatch/util.h Fri Aug 13 02:17:33 2004
514@@ -1,8 +1,8 @@
515 /* @(#) $Header$ (LBL) */
516
517-void dosyslog(int, char *, u_int32_t, u_char *, u_char *);
518+void dosyslog(int, char *, u_int32_t, u_char *, u_char *, char *);
519 int dump(void);
520-void dumpone(u_int32_t, u_char *, time_t, char *);
521+void dumpone(u_int32_t, u_char *, time_t, char *, char *);
522 int readdata(void);
523 char *savestr(const char *);
524
525@@ -19,3 +19,6 @@
526 extern int initializing;
527 /**/
528 /**/
529+extern int allsubnets;
530+/**/
531+/**/
This page took 0.161387 seconds and 4 git commands to generate.