5df1e2a8ec28ef952a0765af3b29894cd278656d
3 MACTODEV
=mac-to-devinfo
7 echo "$0: -i interferace -r ip-range [options]"
9 echo "-r ip-range range to probe (CIDR, e.g. 192.168.2.0/24)"
10 echo "-i interface interface to use in scan"
11 echo "-t timeout time to rate for arp responses for device detection"
12 echo "-p port[,port...] command-separated lists of ports to scan for SIP responses"
13 echo "-c repeat_count Number of times to send each request (default 1)"
14 echo "-s sleepreq ms to wait between sending arp requests"
15 echo "-x Assume we're running on an Xcelerator IP"
20 while getopts "r:i:t:p:c:s:xh" param
; do
56 if [ "$IPRANGE" = "" ]; then
57 echo "Must specify an ip range"
62 if [ "$INTERFACE" = "" ]; then
63 echo "Must speciy the interface"
68 if [ "$TIMEOUT" = "" ]; then
75 if [ -n "$PORTARG" ]; then
78 if [ -z "$(echo $PORTLIST | grep ',')" ]; then
83 curport
="$(echo $PORTLIST | cut -f$FIELD -d, )"
84 while [ "$curport" != "$oldcurport" ]; do
85 PORTS
="$curport $PORTS"
87 oldcurport
="$(echo $PORTLIST | cut -f$FIELD -d, )"
88 curport
="$(echo $PORTLIST | cut -f$FIELD -d, )"
99 if [ -n "$REPEATCOUNT" ]; then
100 REPEAT
="-c $REPEATCOUNT"
103 for line
in $
(sh
-c "netdiscover -t $TIMEOUT -k -m -i $INTERFACE -r $IPRANGE $REPEAT $SLEEPREQ 2>/dev/null" |
grep -E '[0-9]([0-9]?[0-9])?.[0-9]([0-9]?[0-9])?.[0-9]([0-9]?[0-9])?.[0-9]([0-9]?[0-9])?.[0-9]([0-9]?[0-9])?'); do
105 IP
=$
(echo $line |
tr -s \ | cut
-f1 -d\
)
106 MAC
=$
(echo $line |
tr -s \ | cut
-f2 -d\
)
108 if [ -n "$PORTS" ]; then
109 for port
in $PORTS; do
111 if [ "$XIP" = "TRUE" ]; then
114 for sip_device
in $
(smap
-p $port $IP </dev
/null |
grep -E -v 'host.? scanned' |
grep 'SIP enabled' | cut
-f1 -d: ); do
115 if [ -x "$(which httping)" ]; then
116 if httping
-G -q -o 401,200 -c 2 -h $sip_device; then
117 echo "$sip_device"" | ""$($MACTODEV $XIP_PORT $MAC)"" | ""http://$sip_device/"
121 echo "$sip_device"" | ""$(MACTODEV $XIP_PORT $MAC)"" | "" - "
125 for sip_device
in $
(smap
$IP </dev
/null |
grep -E -v 'host.? scanned' |
grep 'SIP enabled' | cut
-f1 -d: ); do
126 if [ -x "$(which httping)" ]; then
127 if httping
-G -q -o 401,200 -c 2 -h $sip_device; then
128 echo "$sip_device"" | ""$($MACTODEV $MAC $XIP_PORT)"" | ""http://$sip_device/"
132 echo "$sip_device"" | ""$($MACTODEV $MAC $XIP_PORT)"" | "" - "