[package] add mac-to-devinfo (#5373)
[openwrt/svn-archive/archive.git] / net / mac-to-devinfo / files / netdiscover-to-devinfo
1 #!/bin/sh
2
3 MACTODEV=mac-to-devinfo
4 NETDISCOVER=netdiscover
5
6 if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
7 echo "Usage: netdiscover-to-devinfo IP-range Interface Timeout"
8 exit 1
9 fi
10
11 prep-devinfo
12 OLDIFS=$IFS
13 IFS='
14 '
15 for line in $($NETDISCOVER -t $3 -k -m -i $2 -r $1); do
16 IFS=$OLDIFS
17 IP=$(echo $line | tr -s \ | cut -f1 -d\ )
18 MAC=$(echo $line | tr -s \ | cut -f2 -d\ )
19 echo "$IP"" | ""$($MACTODEV $MAC)"
20 OLDIFS=$IFS
21 IFS='
22 '
23 done
24
25 IFS=$OLDIFS
26