#!/bin/sh
#
#   Written by Alexander Clouter (alexander.clouter@ic.ac.uk)
#   based on the Utility Script 'findnet' by Andrew McMillan
#
#   $1 is the DEVICE we are testing (ie eth0)
#   $2 is the HWADDR we are trying to find
#   $3 is the IP we are trying to find
#

ifconfig $1 0.0.0.0 > /dev/null 2>&1

if (arping -f -w1 -D -I $1 $3 | grep -e $2 > /dev/null 2>&1) ; then
  # echo "found $2"
  #   Leave the interface running in this case
  RESULT=0
else
  # echo "Not found"
  RESULT=1
fi

exit $RESULT
