ThomasHabets / arping

ARP Ping
http://www.habets.pp.se/synscan/programs.php
GNU General Public License v2.0
398 stars 62 forks source link

Update arping.c #14

Closed tolysz closed 10 years ago

tolysz commented 10 years ago

Make arping -c n exit after receiving n IPs arping -i eth0 -w 3000000 -qrc1 '00:11:22:33:44:55' will try at most for 3 seconds to get the IP.

ThomasHabets commented 10 years ago

What are you trying to do? This changes the semantics of -c from "perform this many attempts" to "wait for this many replies" without waiting to see if the last reply had any duplicates. But it only does this for pinging MAC addresses.

tolysz commented 10 years ago

The -c in conjunction with -w is what I want to get i.e. terminate on whichever event will occur first either we reach the count or the timeout. The patch only affects the the pingmac which is highly unlikely to have duplicates i.e. two identical MAC addresses having a different address each. The semantic for normal pingip was unchanged.

ThomasHabets commented 10 years ago

Sounds like you actually want just the first reply, and a different feature from simply throwing -w and -c together.

tolysz commented 10 years ago

:) Yes, I want just the first reply -c 1 but with -c 10 will it be the first 10 replies: arping -i eth0 -w 30000000 -qrc10 'FF:FF:FF:FF:FF:FF' would print first 10 IP addresses on the net or wait 30s whichever will be first. So I guess it needs to be some new option i.e. -C n only listen the first n responses (but funny enough numrecvd@pingmac_recv counts just that)

ThomasHabets commented 10 years ago

If you're not in a hurry you can just do: arping -c 10 -r | head -1

But otherwise it sounds like "exit at first reply", without parameters should work.

tolysz commented 10 years ago

arping -i eth0 -w 10000000 -qrc1 'FF:FF:FF:FF:FF:FF' | head -1 Does print 1 line but after waiting 10s stdbuf -o 0 arping -i eth0 -w 10000000 -qrc1 'FF:FF:FF:FF:FF:FF' | head -1 quits aftrer 1 but only because it still has something to write thus is killed by SIGPIPE stdbuf -o 0 arping1 -i eth0 -w 10000000 -qrc1 '01:23:45:67:89:AB' | head -1 print 1 line then waits 10s (as is not killed because is not writing)

There is a new pull which adds -C n

ThomasHabets commented 10 years ago

Sorry for the delay. I've been thinking about how this feature should best be implemented, and if needs a "wait for a total of X time" as well, and how that should look.

ThomasHabets commented 10 years ago

This was bug #13. I've implemented something close to this pull request, replacing it. Thanks.

https://github.com/ThomasHabets/arping/commit/850c5a4b81969956efef6ed30a0df47bd57afe7c

tolysz commented 10 years ago

Nice.