Added 6 test case for sending traps from snmpd.
The test cases includes traps or informs, statically configured trapsess in
snmpd.conf and dynamically configured traps using snmpset
Note; Dynamic configuration is not working in 5.8.rc3. I will file a BUG for this
See https://sourceforge.net/p/net-snmp/bugs/2872/
Hmm ... I don't see any attachments? Is the actual patch perhaps missing?
Now it is
Note; I have only run the tests on Linux, and I have some code to convert IPv4 and IPv6 to full hex values that may not work on other platform.
In the patch I found the following: $((16#$i)). What is this supposed to do? I haven't found any documentation of the # operator in the bash manual (https://www.gnu.org/software/bash/manual/bash.html#Shell-Arithmetic).
The "$((16#$i))" converts the hexaddress from the IPv6 address to the decimal value, e.g
"$echo $((16#a))
10
"
At the end of https://www.gnu.org/software/bash/manual/bash.html#Shell-Arithmetic, the "#" is described
"Constants with a leading 0 are interpreted as octal numbers. A leading ‘0x’ or ‘0X’ denotes hexadecimal. Otherwise, numbers take the form [base#]n, where the optional base is a decimal number between 2 and 64 representing the arithmetic base, and n is a number in that base. If base# is omitted, then base 10 is used. When specifying n, the digits greater than 9 are represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’, in that order. If base is less than or equal to 36, lowercase and uppercase letters may be used interchangeably to represent numbers between 10 and 35."
I found an error in the ipv6_2_hex function:
diff --git a/testing/fulltests/default/Sv3usmtraps b/testing/fulltests/default/Sv3usmtraps
index 06f14cf6a..fd7ca8e13 100644
--- a/testing/fulltests/default/Sv3usmtraps
+++ b/testing/fulltests/default/Sv3usmtraps
@@ -43,11 +43,10 @@ ipv4_2_hex ()
ipv6_2_hex ()
{
- # remove the ':' at the end of the first argument
- local host=$(echo $1 | sed s'/.$//')
+ # if ':' at the end of the host, remove it!
+ local host=$(echo $1 | sed s'/:$//')
local port=$2
echo $host | grep :: >/dev/null
if [ $? = 0 ]; then
no_of_colons=$(echo $host | tr -d -c ':' | awk '{ print length; }')
@@ -64,8 +63,21 @@ ipv6_2_hex ()
4)
host=$(echo $host | sed 's/::/:0:0:0:0:/')
;;
esac
fi
+
for i in $(echo $host | tr ':' ' '); do
printf "%04x" $(echo $((16#$i)))
done
The full patch with the fix is appended
There were some issues with this script on Ubuntu (uses dash) and also on Solaris. Can you have a look at the attached script?
Looks OK, even if we may remove the handling of ":" at the end of the IPv4 and IPv6. This was inheritet from some code that passed the portno as the last part of the IP address.
On the other it works as is, so keep it.