diff options
author | Thomas Habets <thomas@habets.se> | 2014-06-17 15:18:36 +0100 |
---|---|---|
committer | Thomas Habets <thomas@habets.se> | 2014-06-17 15:18:36 +0100 |
commit | d1493a9706beb7ce0e0c47817bab3c5ec4959255 (patch) | |
tree | 2d361f3edf8ad2d38d83ef3997974bda7a404cc8 | |
parent | 14161e0a29c4238b169de351729fb0a0b0ac89bd (diff) | |
download | arping-d1493a9706beb7ce0e0c47817bab3c5ec4959255.tar.gz |
Added -P, to send ARP replies instead of ARP requests.
This can be useful with -U.
Fixes #15.
-rw-r--r-- | doc/arping.8 | 2 | ||||
-rw-r--r-- | doc/arping.yodl | 1 | ||||
-rwxr-xr-x | extra/testing.exp | 1 | ||||
-rw-r--r-- | src/arping.c | 13 |
4 files changed, 13 insertions, 4 deletions
diff --git a/doc/arping.8 b/doc/arping.8 index df54d31..c0ba019 100644 --- a/doc/arping.8 +++ b/doc/arping.8 @@ -79,6 +79,8 @@ Don\(cq\&t guess, use the specified interface\&. .IP "\-p" Turn on promiscious mode on interface, use this if you don\(cq\&t \(dq\&own\(dq\& the MAC address you are using\&. +.IP "\-P" +Send ARP replies instead of requests\&. Useful with \-U\&. .IP "\-q" Does not display messages, except error messages\&. .IP "\-r" diff --git a/doc/arping.yodl b/doc/arping.yodl index 55e5aad..f570afa 100644 --- a/doc/arping.yodl +++ b/doc/arping.yodl @@ -63,6 +63,7 @@ switch is not given, -i disables this smartness. dit(-i em(interface)) Don't guess, use the specified interface. dit(-p) Turn on promiscious mode on interface, use this if you don't "own" the MAC address you are using. + dit(-P) Send ARP replies instead of requests. Useful with -U. dit(-q) Does not display messages, except error messages. dit(-r) Raw output: only the MAC/IP address is displayed for each reply. dit(-R) Raw output: Like -r but shows "the other one", can be combined with diff --git a/extra/testing.exp b/extra/testing.exp index e96c281..fcc3765 100755 --- a/extra/testing.exp +++ b/extra/testing.exp @@ -38,6 +38,7 @@ # * -B # * -d # * -p +# * -P # * -U # * Mac ping without -T. # diff --git a/src/arping.c b/src/arping.c index 42cac3a..a1c8bb7 100644 --- a/src/arping.c +++ b/src/arping.c @@ -159,6 +159,7 @@ static int reverse_beep = 0; /* beep when expected reply absent. -e */ static int alsototal = 0; /* print sent as well as received. -u */ static int addr_must_be_same = 0; /* -A */ static int unsolicited = 0; /* -U */ +static int send_reply = 0; /* Send reply instead of request. -P */ static int finddup = 0; /* finddup mode. -d */ static int dupfound = 0; /* set to 1 if dup found */ @@ -495,7 +496,7 @@ extended_usage() " with -r.\n" " -s MAC Set source MAC address. You may need to use -p with this.\n" " -S IP Like -b and -0 but with set source address. Note that this may\n" - " get the arping unanswered if the target does not have routing to\n" + " get the arping unanswered if the target does not have routing to\n" " the IP. If you don't own the IP you are using, you may need to\n" " turn on promiscious mode on the interface (with -p). With this\n" " switch you can find out what IP-address a host has without tak-\n" @@ -508,6 +509,7 @@ extended_usage() " $ arping -S <IP-B> -s <MAC-B> -p <MAC-A>\n" " -p Turn on promiscious mode on interface, use this if you don't\n" " \"own\" the MAC address you are using.\n" + " -P Send ARP replies instead of requests. Useful with -U.\n" " -u Show index=received/sent instead of just index=received when\n" " pinging MACs.\n" " -U Send unsolicited ARP.\n" @@ -527,7 +529,7 @@ standard_usage() { printf("ARPing %s, by Thomas Habets <thomas@habets.se>\n", version); - printf("usage: arping [ -0aAbdDeFpqrRuUv ] [ -w <us> ] " + printf("usage: arping [ -0aAbdDeFpPqrRuUv ] [ -w <us> ] " "[ -W <sec> ] " "[ -S <host/ip> ]\n" " " @@ -767,7 +769,7 @@ pingip_send() ETHERTYPE_IP, ETH_ALEN, IP_ALEN, - ARPOP_REQUEST, + send_reply ? ARPOP_REPLY : ARPOP_REQUEST, srcmac, (uint8_t*)&srcip, unsolicited ? (uint8_t*)ethxmas : (uint8_t*)ethnull, @@ -1210,7 +1212,7 @@ int main(int argc, char **argv) memcpy(dstmac, ethxmas, ETH_ALEN); while (EOF != (c = getopt(argc, argv, - "0aAbBC:c:dDeFhi:I:pqrRs:S:t:T:uUvw:W:"))) { + "0aAbBC:c:dDeFhi:I:pPqrRs:S:t:T:uUvw:W:"))) { switch(c) { case '0': srcip = 0; @@ -1266,6 +1268,9 @@ int main(int argc, char **argv) case 'p': promisc = 1; break; + case 'P': + send_reply = 1; + break; case 'q': display = QUIET; break; |