Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 87428 Details for
Bug 134253
[baselayout] arping with MAC address recognition
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
MAC address recognition patch
arping_sh-mac-address.patch (text/plain), 3.52 KB, created by
Oldrich Jedlicka
on 2006-05-24 12:17:31 UTC
(
hide
)
Description:
MAC address recognition patch
Filename:
MIME Type:
Creator:
Oldrich Jedlicka
Created:
2006-05-24 12:17:31 UTC
Size:
3.52 KB
patch
obsolete
>diff -ur orig/lib/rcscripts/net/arping.sh change_mac/lib/rcscripts/net/arping.sh >--- orig/lib/rcscripts/net/arping.sh 2006-05-10 17:20:10.000000000 +0200 >+++ change_mac/lib/rcscripts/net/arping.sh 2006-05-24 21:05:45.000000000 +0200 >@@ -27,27 +27,56 @@ > # If neither arping (net-misc/iputils) or arping2 (net-analyzer/arping) > # is installed then we return 1 > arping_address_exists() { >- local iface="$1" address="${2%%/*}" i >+ local iface="$1" ip="${2%%/*}" mac="$3" i found_mac > > # We only handle IPv4 addresses >- [[ ${address} != *.*.*.* ]] && return 1 >+ [[ ${ip} != *.*.*.* && ${ip} != *.*.*.*\[*:*:*:*:*:*\] ]] && return 1 > > # 0.0.0.0 isn't a valid address - and some lusers have configured this >- [[ ${address} == "0.0.0.0" || ${address} == "0" ]] && return 1 >+ [[ ${ip} == "0.0.0.0" || ${ip} == "0" ]] && return 1 > > # We need to bring the interface up to test > interface_exists "${iface}" || return 1 > interface_up "${iface}" > > if [[ -x /sbin/arping ]] ; then >- /sbin/arping -q -c 2 -w 3 -D -f -I "${iface}" "${address}" \ >- &>/dev/null || return 0 >+ if [[ -n ${mac} ]] ; then >+ found_mac="`\ >+ /sbin/arping -c 2 -w 3 -D -f \ >+ -I "${iface}" "${ip}" \ >+ 2>/dev/null | \ >+ /bin/sed -n 's/.*\\[\\([^]]*\\)\\].*/\\1/p' | \ >+ /bin/tr [:lower:] [:upper:]`" >+ [[ ${found_mac} == ${mac} ]] && return 0 >+ else >+ /sbin/arping -q -c 2 -w 3 -D -f -I "${iface}" "${ip}" \ >+ &>/dev/null || return 0 >+ fi > elif [[ -x /usr/sbin/arping2 ]] ; then >- for (( i=0; i<3; i++ )) ; do >- /usr/sbin/arping2 -0 -c 1 -i "${iface}" "${address}" \ >- &>/dev/null && return 0 >- done >+ if [[ -n ${mac} ]]; then >+ for (( i=0; i<3; i++ )) ; do >+ found_mac="`\ >+ /usr/sbin/arping2 -r -0 -c 1 -i "${iface}" "${ip}" \ >+ 2>/dev/null`" >+ if [[ $? == 0 ]]; then >+ found_mac=$(echo ${found_mac} | \ >+ /bin/tr [:lower:] [:upper:]) >+ [[ ${found_mac} == ${mac} ]] && return 0 >+ break >+ fi >+ done >+ else >+ for (( i=0; i<3; i++ )) ; do >+ /usr/sbin/arping2 -0 -c 1 -i "${iface}" "${ip}" \ >+ &>/dev/null && return 0 >+ done >+ fi > fi >+ >+ if [[ -n ${mac} && -n ${found_mac} ]] ; then >+ vewarn "Found ${ip}, but MAC ${found_mac} doesn't match" >+ fi >+ > return 1 > } > >@@ -56,7 +85,7 @@ > # arpings a list of gateways > # If one is foung then apply it's configuration > arping_start() { >- local iface="$1" gateways x conf i >+ local iface="$1" gateways x ip mac conf i > > interface_exists "${iface}" true || return 1 > >@@ -71,9 +100,22 @@ > eindent > > for x in ${!gateways}; do >- vebegin "${x}" >- if arping_address_exists "${iface}" "${x}" ; then >- for i in ${x//./ } ; do >+ >+ # Separate ip address and MAC address >+ ip="${x%%\[*\]}" >+ mac="${x}[" >+ mac="${mac#*\[}" >+ mac="${mac%\[}" >+ mac="${mac%\]}" >+ >+ if [ -n ${mac} ]; then >+ vebegin "${ip} (MAC $mac)" >+ else >+ vebegin "${ip}" >+ fi >+ >+ if arping_address_exists "${iface}" "${ip}" "${mac}"; then >+ for i in ${ip//./ } ; do > if [[ ${#i} == "2" ]] ; then > conf="${conf}0${i}" > elif [[ ${#i} == "1" ]] ; then >@@ -82,9 +124,20 @@ > conf="${conf}${i}" > fi > done >+ if [[ -n ${mac} ]]; then >+ conf="${conf}_" >+ for i in ${mac//:/ } ; do >+ conf="${conf}${i}" >+ done >+ conf=$(echo ${conf} | tr [:lower:] [:upper:]) >+ fi > veend 0 > eoutdent >- veinfo "Configuring ${iface} for ${x}" >+ if [ -n ${mac} ]; then >+ veinfo "Configuring ${iface} for ${ip} (MAC ${mac})" >+ else >+ veinfo "Configuring ${iface} for ${ip}" >+ fi > configure_variables "${iface}" "${conf}" > > # Call the system module as we've aleady passed it by ....
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 134253
: 87428 |
87429
|
87970
|
87982