diff options
author | Thomas Habets <thomas@habets.pp.se> | 2003-04-07 17:38:44 +0000 |
---|---|---|
committer | Thomas Habets <thomas@habets.pp.se> | 2003-04-07 17:38:44 +0000 |
commit | c0c7db51b7899c0bc6799b9005f33e4570176f87 (patch) | |
tree | f08620a6081ee8d76607830153efaeddbc36e312 | |
parent | d60ec73f417727a32b7aa02d29391732bcf1c016 (diff) | |
download | arping-c0c7db51b7899c0bc6799b9005f33e4570176f87.tar.gz |
-A
-rwxr-xr-x | arping-scan-net.sh | 27 | ||||
-rw-r--r-- | arping.8 | 4 | ||||
-rw-r--r-- | arping.c | 41 | ||||
-rw-r--r-- | arping.yodl | 3 |
4 files changed, 60 insertions, 15 deletions
diff --git a/arping-scan-net.sh b/arping-scan-net.sh index e22abe3..0908eb7 100755 --- a/arping-scan-net.sh +++ b/arping-scan-net.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: arping-scan-net.sh 546 2002-02-12 18:17:47Z marvin $ +# $Id: arping-scan-net.sh 859 2003-04-07 17:38:44Z marvin $ # # Copyright (C) 2002 Thomas Habets <thomas@habets.pp.se> # @@ -20,11 +20,15 @@ trap "exit 0" INT -TARGET_MAC="0:60:93:34:91:99" - -if [ "$1" != "" ]; then - TARGET_MAC="$1" +if [ "$1" = "" ]; then + echo + echo "Usage: $0 <mac address>" + echo "" + echo " Sorry, it's not more configurable than that, edit the source" + echo + exit 1 fi +TARGET_MAC="$1" # # first number after 'seq' is range start, second is range end @@ -32,17 +36,18 @@ fi # default is [192-192].[168-168].[0-0].[0-255] # # -# If you think this is useful, tell me and I'll incorperate it into arping +# I may put this functionality into ARPing one day if people seem to like it. # for a in $(seq 192 192); do for b in $(seq 168 168); do - for c in $(seq 0 0); do + for c in $(seq 42 42); do for d in $(seq 0 255); do - arping -q -c 1 -T $a.$b.$c.$d $TARGET_MAC - if [ $? == 0 ]; then - echo "Got answer with address: $a.$b.$c.$d" - fi + sh -c "arping -q -c 1 -T $a.$b.$c.$d $TARGET_MAC -A + if [ \$? == 0 ]; then + echo Got answer with address: $a.$b.$c.$d + fi" & done + wait done done done @@ -84,6 +84,10 @@ Set target MAC address to use when pinging IP address\&. Only send \fIcount\fP requests\&. .IP "-i \fIinterface\fP" Use the specified interface\&. +.IP "-A" +Only count addresses matching requested address (This *WILL* +break most things you do\&. Only useful if you are arpinging many +hosts at once\&. See arping-scan-net\&.sh for an example)\&. .PP .SH "BUGS" .PP @@ -12,7 +12,7 @@ * * Also finds out IP of specified MAC * - * $Id: arping.c 793 2003-02-04 20:22:23Z marvin $ + * $Id: arping.c 859 2003-04-07 17:38:44Z marvin $ */ /* * Copyright (C) 2000-2002 Thomas Habets <thomas@habets.pp.se> @@ -31,6 +31,26 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* + * Note to self: + * Test this on each platform: + * command expected response + * arping host pongs + * arping -a host audiable pongs + * arping mac pongs + * arping -a mac audiable pongs + * arping -A host nothing + * arping -A mac nothing + * arping -A host -t mac nothing + * arping -A mac -T ip nothing + * arping -r host mac + * arping -R host ip + * arping -r mac ip + * arping -R mac mac + * arping -rR mac mac ip + * ./arping-scan-net.sh mac ip + * + */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -78,7 +98,7 @@ #define DEBUG(a) #endif -const float version = 1.06; +const float version = 1.07; struct ether_addr *mymac; static u_char eth_xmas[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -113,6 +133,7 @@ static unsigned int rawoutput = 0; static unsigned int quiet = 0; static unsigned int nullip = 0; static unsigned int is_promisc = 0; +static unsigned int addr_must_be_same = 0; static void sigint(int i) { @@ -142,7 +163,7 @@ static void usage(int ret) { printf("ARPing %1.2f, by Thomas Habets <thomas@habets.pp.se>\n", version); - printf("usage: arping [ -qvrRd0bp ] [ -S <host/ip> ] [ -T <host/ip ]" + printf("usage: arping [ -qvrRd0bpAa ] [ -S <host/ip> ] [ -T <host/ip ]" " [ -s <MAC> ]\n" " [ -t <MAC> ] [ -c <count> ] [ -i <interface> ] " "<host/ip/MAC | -B>\n"); @@ -255,6 +276,9 @@ static void handlepacket(const char *unused, struct pcap_pkthdr *h, && !memcmp(eth->h_dest, eth_source, ETH_ALEN)) { u_char *cp = eth->h_source; + if (addr_must_be_same && (dip != hip->saddr)) { + return; + } numrecvd++; if (!rawoutput) { printf("%d bytes from ", h->len); @@ -306,6 +330,12 @@ static void handlepacket(const char *unused, struct pcap_pkthdr *h, u_int32_t ip; memcpy(&ip, (char*)harp + harp->ar_hln + sizeof(struct arphdr), 4); + if (addr_must_be_same + && (memcmp((u_char*)harp+sizeof(struct arphdr), + eth_target, ETH_ALEN))) { + return; + } + if (dip == ip) { cp = (u_char*)harp + sizeof(struct arphdr); if (!rawoutput && !finddup) { @@ -374,8 +404,11 @@ int main(int argc, char **argv) memcpy(eth_target, eth_xmas, ETH_ALEN); - while ((c = getopt(argc, argv, "0bdS:T:Bvhi:rRc:qs:t:pa")) != EOF) { + while ((c = getopt(argc, argv, "0bdS:T:Bvhi:rRc:qs:t:paA")) != EOF) { switch (c) { + case 'A': + addr_must_be_same = 1; + break; case 'a': beep = 1; break; diff --git a/arping.yodl b/arping.yodl index ecd7b2b..ca62e42 100644 --- a/arping.yodl +++ b/arping.yodl @@ -69,6 +69,9 @@ em(Example): \ dit(-t em(MAC)) Set target MAC address to use when pinging IP address. dit(-c em(count)) Only send em(count) requests. dit(-i em(interface)) Use the specified interface. + dit(-A) Only count addresses matching requested address (This *WILL* + break most things you do. Only useful if you are arpinging many + hosts at once. See arping-scan-net.sh for an example). enddit() manpagebugs() |