1 Index: arpwatch/arpsnmp.c
2 diff -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
7 int main(int, 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));
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,
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,
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);
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));
42 /* Process an snmp file */
43 Index: arpwatch/arpwatch.8
44 diff -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
69 +reports bogons (unless
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
75 +will report bogons about every IP addresses.
81 file must be created before the first time you run
82 Index: arpwatch/arpwatch.c
83 diff -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
87 int sanity_fddi(struct fddi_header *, struct ether_arp *, int);
88 __dead void usage(void) __attribute__((volatile));
90 +static char *interface;
93 main(int argc, char **argv)
99 - register char *interface, *rfilename;
100 + register char *rfilename;
101 struct bpf_program code;
102 char errbuf[PCAP_ERRBUF_SIZE];
115 while ((op = getopt(argc, argv, options)) != EOF)
125 @@ -401,29 +410,31 @@
127 /* Watch for bogons */
129 - dosyslog(LOG_INFO, "bogon", sia, sea, sha);
131 + dosyslog(LOG_INFO, "bogon", sia, sea, sha, interface);
132 + if (!allsubnets) return;
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,
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,
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);
164 @@ -550,29 +561,31 @@
166 /* Watch for bogons */
168 - dosyslog(LOG_INFO, "bogon", sia, sea, sha);
170 + dosyslog(LOG_INFO, "bogon", sia, sea, sha, interface);
171 + if (!allsubnets) return;
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,
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,
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);
214 diff -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
218 u_char e[6]; /* ether address */
219 char h[34]; /* simple hostname */
220 time_t t; /* timestamp */
221 + char i[16]; /* interface */
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);
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,
240 register struct ainfo *ap;
241 register struct einfo *ep;
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,
253 /* Check for a virgin ainfo record */
254 if (ap->ecount == 0) {
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);
264 if (t - t2 < FLIPFLIP_DELTA &&
265 (isdecnet(e) || isdecnet(e2)))
267 - "suppressed DECnet flip flop", a, e, e2);
268 + "suppressed DECnet flip flop", a, e, e2,
271 - report("flip flop", a, e, e2, &t, &t2);
272 + report("flip flop", a, e, e2, &t, &t2,
274 ap->elist[1] = ap->elist[0];
278 e2 = ap->elist[0]->e;
279 t2 = ap->elist[0]->t;
280 dosyslog(LOG_NOTICE, "reused old ethernet address",
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 */
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);
302 for (ap = &ainfo_table[i]; ap != NULL; ap = ap->next)
303 for (j = 0; j < ap->ecount; ++j) {
305 - (*fn)(ap->a, ep->e, ep->t, ep->h);
306 + (*fn)(ap->a, ep->e, ep->t, ep->h, ep->i);
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,
315 + register char *h, char *interface)
317 register struct einfo *ep;
320 if (h != NULL && !isdigit((int)*h))
323 + if (interface != NULL)
324 + strncpy(ep->i, interface, 16);
329 diff -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
333 /* @(#) $Header$ (LBL) */
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 *);
339 void debugdump(void);
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);
345 Index: arpwatch/file.c
346 diff -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
352 register struct hostent *hp;
364 h = strchr(cp2, '\t');
365 @@ -126,11 +128,18 @@
366 while (*cp2 != '\n' && *cp2 != '\t' &&
369 + if (*cp2 == '\t') {
371 + while (*cp2 != '\n' && *cp2 != '\t' &&
372 + *cp2 != '\0') ++cp2;
380 - if (!(*fn)(a, e, t, h))
381 + if (!(*fn)(a, e, t, h, interface))
385 Index: arpwatch/file.h
386 diff -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
390 /* @(#) $Header$ (LBL) */
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 *);
395 int file_loop(FILE *, file_process, const char *);
396 Index: arpwatch/report.c
397 diff -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
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,
408 register char *cp, *hn;
409 register int fd, pid;
414 - dosyslog(LOG_NOTICE, title, a, e1, e2);
415 + dosyslog(LOG_NOTICE, title, a, e1, e2, interface);
422 /* Syslog this event too */
423 - dosyslog(LOG_NOTICE, title, a, e1, e2);
424 + dosyslog(LOG_NOTICE, title, a, e1, e2, interface);
426 /* Update child depth */
428 @@ -302,16 +303,19 @@
430 (void)fprintf(f, "From: %s\n", watchee);
431 (void)fprintf(f, "To: %s\n", watcher);
432 + if (interface == NULL) interface = ""; /* shouldn't happen */
435 - (void)fprintf(f, "Subject: %s (%s)\n", title, hn);
436 + (void)fprintf(f, "Subject: %s (%s) %s\n", title, hn,
439 - (void)fprintf(f, "Subject: %s\n", title);
440 + (void)fprintf(f, "Subject: %s %s\n", title, interface);
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)
450 Index: arpwatch/report.h
451 diff -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
455 /* @(#) $Header$ (LBL) */
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 *);
459 Index: arpwatch/util.c
460 diff -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
464 int initializing = 1; /* true if initializing */
467 +int allsubnets = 0; /* watch all attached subnets */
471 /* syslog() helper routine */
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)
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),
487 - syslog(p, "%s %s %s", s, intoa(a), xbuf);
488 + syslog(p, "%s %s %s %s", s, intoa(a), xbuf, interface);
494 dumpone(register u_int32_t a, register u_char *e, register time_t t,
496 + register char *h, char *interface)
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:""));
510 Index: arpwatch/util.h
511 diff -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
515 /* @(#) $Header$ (LBL) */
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 *);
520 -void dumpone(u_int32_t, u_char *, time_t, char *);
521 +void dumpone(u_int32_t, u_char *, time_t, char *, char *);
523 char *savestr(const char *);
526 extern int initializing;
529 +extern int allsubnets;