Menu

#1369 Added testcases for snmpv3 usm trap sent from snmpd

backport-needed
open
nobody
None
5
2018-06-27
2018-06-17
No

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

Discussion

  • Bart Van Assche

    Bart Van Assche - 2018-06-17

    Hmm ... I don't see any attachments? Is the actual patch perhaps missing?

     
  • Anders Wallin

    Anders Wallin - 2018-06-17

    Now it is

     
  • Anders Wallin

    Anders Wallin - 2018-06-17

    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.

     
  • Bart Van Assche

    Bart Van Assche - 2018-06-22

    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).

     
  • Anders Wallin

    Anders Wallin - 2018-06-25

    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."

     
  • Anders Wallin

    Anders Wallin - 2018-06-25

    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

    • printf "0x"
      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:/')
      ;;
    • 3)
    • host=$(echo $host | sed 's/::/:0:0:0:0:0:/')
    • ;;
    • 2)
    • echo $host | grep "^::" > /dev/null
    • if [ $? = 0 ]; then
    • host=$(echo $host | sed 's/::/0:0:0:0:0:0:0:/')
    • else
    • host=$(echo $host | sed 's/::/:0:0:0:0:0:0:/')
    • fi
    • ;;
      esac
      fi
      +
    • printf "0x"
      for i in $(echo $host | tr ':' ' '); do
      printf "%04x" $(echo $((16#$i)))
      done

    The full patch with the fix is appended

     
  • Bart Van Assche

    Bart Van Assche - 2018-06-27

    There were some issues with this script on Ubuntu (uses dash) and also on Solaris. Can you have a look at the attached script?

     
  • Anders Wallin

    Anders Wallin - 2018-06-27

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.