| 1 |
# |
| 2 |
# The T18* tests have a great deal of commonality. |
| 3 |
# We factor that out into this file. |
| 4 |
# |
| 5 |
# Usage: |
| 6 |
# HEADER ... |
| 7 |
# INITV4 or INITV6 |
| 8 |
# CONFIGAGENT ... |
| 9 |
# RUNTEST |
| 10 |
# |
| 11 |
|
| 12 |
INIT() { |
| 13 |
# We need to set $SNMP_TEST_DEST to a real IP address; we have a helper script |
| 14 |
# to determine this |
| 15 |
MYIP=`perl ../support/myip $1` |
| 16 |
if [ $? -ne 0 ] |
| 17 |
then |
| 18 |
SKIP "can not determine my IP" |
| 19 |
fi |
| 20 |
|
| 21 |
if [ "$1" = "ipv6" ] |
| 22 |
then |
| 23 |
SNMP_TEST_DEST="[${MYIP}]": |
| 24 |
else |
| 25 |
SNMP_TEST_DEST=${MYIP}: |
| 26 |
fi |
| 27 |
|
| 28 |
# Standard V2c configuration |
| 29 |
. ./Sv2cconfig |
| 30 |
|
| 31 |
CONFIGTRAPD authcommunity log public |
| 32 |
CONFIGTRAPD agentxsocket /dev/null |
| 33 |
|
| 34 |
# Tracing that helps understand what is being done |
| 35 |
AGENT_FLAGS="$AGENT_FLAGS -Dtdomain,netsnmp_sockaddr,netsnmp_udp" |
| 36 |
} |
| 37 |
|
| 38 |
INITV4() { |
| 39 |
localhost=127.0.0.1 |
| 40 |
snmptrapd_log_regex="UDP: \[${localhost}\]:[0-9]*->\[" |
| 41 |
INIT |
| 42 |
} |
| 43 |
|
| 44 |
INITV6() { |
| 45 |
localhost=::1 |
| 46 |
snmptrapd_log_regex="\[UDP/IPv6: \[${localhost}\]:[0-9]*\]" |
| 47 |
SNMP_TRANSPORT_SPEC=udp6 |
| 48 |
INIT ipv6 |
| 49 |
} |
| 50 |
|
| 51 |
RUNTEST() { |
| 52 |
STARTTRAPD |
| 53 |
|
| 54 |
STARTAGENT |
| 55 |
|
| 56 |
# We just rely on the coldstart trap, so there is no active test here. |
| 57 |
|
| 58 |
STOPAGENT |
| 59 |
|
| 60 |
STOPTRAPD |
| 61 |
|
| 62 |
# Check that the coldstart trap packet was sourced from localhost |
| 63 |
# (IPv4 uses <addr>-><addr>; IPv6 uses just [UDP/IPv6: <addr>], |
| 64 |
# so match either "-" or "]" after the port.) |
| 65 |
CHECKTRAPDCOUNT atleastone "${snmptrapd_log_regex}" |
| 66 |
|
| 67 |
FINISHED |
| 68 |
} |