e140d68ab4
via -n, use it instead of bailing out. Allows to run arpwatch on interface without IP address. Bump pkgrevision.
82 lines
1.9 KiB
Text
82 lines
1.9 KiB
Text
$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);
|
|
}
|