summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.pp.se>2009-11-05 13:40:38 +0100
committerThomas Habets <thomas@habets.pp.se>2009-11-05 13:40:38 +0100
commit767e5c4b8a0dc19503b2582e5be5331a48f54216 (patch)
tree9d77d1d6427a9d6f253f1815f9937c2da24bb4d9
parentef19db0a3e420a60b5c3c5c02e87b23d923532a5 (diff)
downloadarping-767e5c4b8a0dc19503b2582e5be5331a48f54216.tar.gz
Fixed -d option: return 1 if dups are found
-rw-r--r--src/arping.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/arping.c b/src/arping.c
index b3d9b0d..578147b 100644
--- a/src/arping.c
+++ b/src/arping.c
@@ -124,6 +124,7 @@ static int verbose = 0;
static int alsototal = 0;
/*static int pingmac = 0; */
static int finddup = 0;
+static int dupfound = 0;
static unsigned int numsent = 0;
static unsigned int numrecvd = 0;
static unsigned int numdots = 0;
@@ -135,6 +136,7 @@ static uint8_t ethnull[ETH_ALEN];
static uint8_t ethxmas[ETH_ALEN];
static char srcmac[ETH_ALEN];
static char dstmac[ETH_ALEN];
+static char lastreplymac[ETH_ALEN];
volatile int time_to_die = 0;
@@ -668,6 +670,13 @@ pingip_recv(const char *unused, struct pcap_pkthdr *h,
}
printf("\n");
}
+ if (numrecvd) {
+ if (memcmp(lastreplymac,
+ heth->_802_3_shost, ETH_ALEN)) {
+ dupfound = 1;
+ }
+ }
+ memcpy(lastreplymac, heth->_802_3_shost, ETH_ALEN);
numrecvd++;
}
@@ -990,6 +999,7 @@ int main(int argc, char **argv)
break;
case 'd':
finddup = 1;
+ display = QUIET;
break;
case 'D':
display = DOT;
@@ -1106,6 +1116,10 @@ int main(int argc, char **argv)
setvbuf(stdout, NULL, _IONBF, 0);
}
+ if (finddup && maxcount == -1) {
+ maxcount = 3;
+ }
+
parm = (optind < argc) ? argv[optind] : NULL;
/*
@@ -1328,5 +1342,9 @@ int main(int argc, char **argv)
100.0 - 100.0 * (float)(numrecvd)/(float)numsent);
}
- return !numrecvd;
+ if (finddup) {
+ return dupfound;
+ } else {
+ return !numrecvd;
+ }
}