packages/net/mac-to-devinfo/files/smap-to-devinfo
florian 1ecb72b961 [package] add mac-to-devinfo (#5373)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@16712 3c298f89-4303-0410-b956-a3cf2f4a3e73
2009-07-06 11:38:01 +00:00

38 lines
835 B
Bash

#!/bin/sh
IPTODEV=ip-to-devinfo
SMAP=smap
if [ "$1" == "-h" ] || [ "$2" == "-h" ] || [ -z "$1" ]; then
echo "Usage: $0 IP-Range [port,port,...]"
fi
if [ -n "$2" ]; then
FIELD=1
curport="$(echo $2 | cut -f$FIELD -d, )"
while [ "$curport" != "" ]; do
PORTS="$curport $PORTS"
FIELD=$(($FIELD + 1))
curport="$(echo $2 | cut -f$FIELD -d, )"
done
fi
prep-devinfo
if [ -z "$PORTS" ]; then
PORTS=5060
fi
for port in $PORTS; do
for sip_device in $($SMAP -p $port $1 | grep -E -v 'host.? scanned' | grep 'SIP enabled' | cut -f1 -d: ); do
if [ -x "$(which httping)" ]; then
if httping -G -q -o 401,200 -c 2 -h $sip_device; then
echo "$sip_device"" | ""$($IPTODEV $sip_device)"" | ""http://$sip_device/"
continue
fi
fi
echo "$sip_device"" | ""$(IPTODEV $sip_device)"" | "" - "
done
done