Parse broadcast arp responses via arping (iputils) properly

ARP replies may/do contain two MAC addresses when using iputils's
arping so we have to use the first one because it's always the "From"
address - which is what we want.

Thanks to Stefan Knoblich <s.knoblich@axsentis.de> for the fixed pattern.

Reported-by: cl@exomail.to
X-Gentoo-Bug: 379181
X-Gentoo-Bug-URL: https://bugs.gentoo.org/379181
This commit is contained in:
Stefan Knoblich 2011-09-17 00:06:00 +02:00 committed by Christian Ruppert
parent 539c4e5872
commit 645bbf2e0f

View File

@ -40,7 +40,7 @@ arping_address()
[ -z "$(_get_inet_address)" ] && opts="${opts} -D"
foundmac="$(arping -w "${w}" ${opts} -f -I "${IFACE}" "${ip}" 2>/dev/null | \
sed -n -e 'y/abcdef/ABCDEF/' -e 's/.*\[\([^]]*\)\].*/\1/p')"
sed -n -e 'y/abcdef/ABCDEF/' -e 's/[^[]*\[\([^]]*\)\].*/\1/p')"
fi
[ -z "${foundmac}" ] && return 1