summaryrefslogtreecommitdiff
path: root/net/arpwatch/patches/patch-ac
blob: 0cf8be8b333404343588a664249e92bb70179c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
$NetBSD: patch-ac,v 1.10 2006/04/15 09:54:20 bouyer Exp $

--- arpwatch.c.orig	2004-01-22 23:18:20.000000000 +0100
+++ arpwatch.c	2006-04-12 12:36:25.000000000 +0200
@@ -107,6 +107,8 @@
 
 char *prog;
 
+char *Watcher = NULL;
+
 int can_checkpoint;
 int swapped;
 int nobogons;
@@ -119,9 +121,9 @@
 	u_int32_t netmask;
 };
 
-static struct nets *nets;
-static int nets_ind;
-static int nets_size;
+static struct nets *nets = NULL;
+static int nets_ind = 0;
+static int nets_size = 0;
 
 extern int optind;
 extern int opterr;
@@ -170,7 +172,7 @@
 	interface = NULL;
 	rfilename = NULL;
 	pd = NULL;
-	while ((op = getopt(argc, argv, "df:i:n:Nr:")) != EOF)
+	while ((op = getopt(argc, argv, "df:i:m:n:Nr:")) != EOF)
 		switch (op) {
 
 		case 'd':
@@ -189,6 +191,10 @@
 			interface = optarg;
 			break;
 
+		case 'm':
+			Watcher = optarg;
+			break;
+
 		case 'n':
 			if (!addnet(optarg))
 				usage();
@@ -223,9 +229,24 @@
 
 		/* Determine network and netmask */
 		if (pcap_lookupnet(interface, &net, &netmask, errbuf) < 0) {
-			(void)fprintf(stderr, "%s: bad interface %s: %s\n",
-			    prog, interface, errbuf);
-			exit(1);
+			/* use the first -n parameter if available */
+			if (nets != NULL) {
+				net = nets[0].net;
+				netmask = nets[0].netmask;
+				/*
+				 * use 2 separate printf, intoa() uses
+				 * a static buffer.
+				 */
+				printf("%s %s: %s, using %s",
+				    prog, interface, errbuf,
+				    intoa(net));
+				printf("/%s\n", intoa(netmask));
+			} else {
+				(void)fprintf(stderr,
+				    "%s: bad interface %s: %s\n",
+				    prog, interface, errbuf);
+				exit(1);
+			}
 		}
 
 		/* Drop into the background if not debugging */
@@ -751,6 +772,6 @@
 
 	(void)fprintf(stderr, "Version %s\n", version);
 	(void)fprintf(stderr, "usage: %s [-dN] [-f datafile] [-i interface]"
-	    " [-n net[/width]] [-r file]\n", prog);
+	    " [-m email] [-n net[/width]] [-r file]\n", prog);
 	exit(1);
 }