Blob Blame History Raw
--- a/arpwatch.8	2016-03-02 13:06:36.712324185 +0100
+++ b/arpwatch.8	2016-03-02 13:07:03.091306605 +0100
@@ -27,7 +27,7 @@ arpwatch - keep track of ethernet/ip add
 .na
 .B arpwatch
 [
-.B -dN
+.B -dNp
 ] [
 .B -f
 .I datafile
@@ -70,6 +70,10 @@ background and emailing the reports. Ins
 .IR stderr .
 .LP
 The
+.B -p
+flag disables promiscuous mode.
+.LP
+The
 .B -f
 flag is used to set the ethernet/ip address database filename.
 The default is
--- a/arpwatch.c	2016-03-02 13:06:36.723324178 +0100
+++ b/arpwatch.c	2016-03-02 13:11:20.650134958 +0100
@@ -162,7 +162,7 @@ void dropprivileges(const char* user)
 }
 
 char *
-try_dev(char *interface, pcap_t **pd, int *linktype, char *errbuf)
+try_dev(char *interface, pcap_t **pd, int *linktype, int promisc, char *errbuf)
 {
 	register int snaplen, timeout;
 
@@ -170,7 +170,7 @@ try_dev(char *interface, pcap_t **pd, in
 				  sizeof(struct fddi_header)) + sizeof(struct ether_arp);
 	timeout = 1000;
 
-	*pd = pcap_open_live(interface, snaplen, 1, timeout, errbuf);
+	*pd = pcap_open_live(interface, snaplen, promisc, timeout, errbuf);
 	if (NULL == *pd) {
 		syslog(LOG_ERR, "pcap open %s: %s", interface,  errbuf);
 		return NULL;
@@ -187,14 +187,14 @@ try_dev(char *interface, pcap_t **pd, in
 }
 
 char *
-iterate_dev(char *arginterface, pcap_t **pd, int *linktype, char *errbuf)
+iterate_dev(char *arginterface, pcap_t **pd, int *linktype, int promisc, char *errbuf)
 {
 	static char interface[IF_NAMESIZE + 1];
 	pcap_if_t *alldevs;
 	pcap_if_t *dev;
 
 	if (NULL != arginterface) {
-		return try_dev(arginterface, pd, linktype, errbuf);
+		return try_dev(arginterface, pd, linktype, promisc, errbuf);
 	} else {
 		if (pcap_findalldevs(&alldevs, errbuf) == -1) {
 			(void)fprintf(stderr, "%s: lookup_device: %s\n",
@@ -203,7 +203,7 @@ iterate_dev(char *arginterface, pcap_t *
 		}
 		for (dev = alldevs; dev && (arginterface == NULL); dev = dev->next) {
 			strncpy(interface, dev->name, strlen(dev->name)+1);
-			arginterface = try_dev(interface, pd, linktype, errbuf);
+			arginterface = try_dev(interface, pd, linktype, promisc, errbuf);
 		}
 		pcap_freealldevs(alldevs);
 		return arginterface;
@@ -224,6 +224,7 @@ main(int argc, char **argv)
 	struct bpf_program code;
 	char errbuf[PCAP_ERRBUF_SIZE];
 	char* serveruser = NULL;
+	int promisc = 1;
 
 	if (argv[0] == NULL)
 		prog = "arpwatch";
@@ -242,7 +243,7 @@ main(int argc, char **argv)
 	linktype = -1;
 	rfilename = NULL;
 	pd = NULL;
-	while ((op = getopt(argc, argv, "df:i:n:Nr:u:e:s:")) != EOF)
+	while ((op = getopt(argc, argv, "df:i:n:Nr:u:e:s:p")) != EOF)
 		switch (op) {
 
 		case 'd':
@@ -304,6 +305,10 @@ main(int argc, char **argv)
 			}
 			break;
 
+		case 'p':
+			--promisc;
+			break;
+
 		default:
 			usage();
 		}
@@ -317,7 +322,7 @@ main(int argc, char **argv)
 	} else {
 
 		/* Determine interface if not specified */
-		interface = iterate_dev(interface, &pd, &linktype, errbuf);
+		interface = iterate_dev(interface, &pd, &linktype, promisc, errbuf);
 		if (interface == NULL) {
 			(void)fprintf(stderr, "%s: lookup_device: no suitable interface found\n",
 						  prog);