From f723bc2ef1e04c2e67f6b80070d2e92be54c4f31 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 15 Jun 2009 07:33:41 -0700 Subject: [PATCH] Restore find_interface_by_mac() --- Shorewall/lib.base | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Shorewall/lib.base b/Shorewall/lib.base index 837b52f94..6ba82b93e 100644 --- a/Shorewall/lib.base +++ b/Shorewall/lib.base @@ -598,6 +598,32 @@ chain_exists() # $1 = chain name qt $IPTABLES -L $1 -n } +# +# Find the interface with the passed MAC address +# + +find_interface_by_mac() { + local mac + mac=$1 + local first + local second + local rest + local dev + + ip link list | while read first second rest; do + case $first in + *:) + dev=$second + ;; + *) + if [ "$second" = $mac ]; then + echo ${dev%:} + return + fi + esac + done +} + # # Find interface address--returns the first IP address assigned to the passed # device