#!/bin/sh

. ../eval_tools.sh

HEADER "if snmpnetstat finds the running agent in udpTable"

# on some systems the agent needs to be run as root to access udpTable
# - else force skip
case "x`uname -s`" in
  xAIX)     [ "x`id -u`" != "x0" ] && SKIP;;
  xHP-UX)   [ "x`id -u`" != "x0" ] && SKIP;;
  xIRIX*)   [ "x`id -u`" != "x0" ] && SKIP;;
  xNetBSD)  [ "x`id -u`" != "x0" ] && SKIP;;
  xOpenBSD) [ "x`id -u`" != "x0" ] && SKIP;;
  xOSF1)    [ "x`id -u`" != "x0" ] && SKIP;;
esac

SKIPIF DISABLE_SNMPV2C
SKIPIFNOT USING_MIBII_UDPTABLE_MODULE

# snmpnetstat only works with UDP
[ "x$SNMP_TRANSPORT_SPEC" = "x" -o "x$SNMP_TRANSPORT_SPEC" = "xudp" ] || SKIP

# make sure snmpnetstat can be executed
SNMPNETSTAT="${SNMP_UPDIR}/apps/snmpnetstat/snmpnetstat"
[ -x "$SNMPNETSTAT" ] || SKIP

snmp_version=v2c
. ./Sv2cconfig

#
# Begin test
#

STARTAGENT

CAPTURE "$SNMPNETSTAT -Cn -Cp udp -$snmp_version -c testcommunity $SNMP_TEST_DEST$SNMP_SNMPD_PORT"
CHECKORDIE "127.0.0.1.$SNMP_SNMPD_PORT"

STOPAGENT
FINISHED
