Page 1 of 1

The value GETHASH is not of type (UNSIGNED-BYTE 8)

Posted: Sat Dec 10, 2016 3:24 am
by anaumov
Hello,

I try to use SNMP module (QuickLisp installation). I have a problem with data type for :md5 parameter:

Code: Select all

(defun get-info (hash)
  (format t "~A~%" (type-of (gethash "PASSWORD" hash)))
  (format t "~A~%"
    (snmp:with-open-session
      (s (gethash "HOST" hash)
        :user (gethash "USERNAME" hash)
        :auth '(:md5 (gethash "PASSWORD" hash)))    <-- here
      (snmp:snmp-walk s (gethash "OPTION" hash)))))
SBCL tells: The value GETHASH is not of type (UNSIGNED-BYTE 8) :?

If I try to use this code, it works:

Code: Select all

(defun get-info (hash) 
  (format t "~A~%"
    (snmp:with-open-session
      (s (gethash "HOST" hash)
        :user (gethash "USERNAME" hash)
        :auth '(:md5 "PaSsWoRd"))
      (snmp:snmp-walk s (gethash "OPTION" hash)))))
In this case a type of "PaSsWoRd" is (SIMPLE-ARRAY CHARACTER (8)) and if I check a type of (gethash "PASSWORD" hash) it tells me also (SIMPLE-ARRAY CHARACTER (8)). So data types are same, but in case of hash-table it doesn't work!

Does anybody know how to fix it? What exactly returns SBCL by calling gethash and why :md5 doesn't accept it?
Thank you!

Re: The value GETHASH is not of type (UNSIGNED-BYTE 8)

Posted: Sat Dec 10, 2016 4:05 pm
by David Mullen
It's a quoted list—you're passing in the literal expression (gethash "PASSWORD" hash) instead of its value.

Re: The value GETHASH is not of type (UNSIGNED-BYTE 8)

Posted: Sat Dec 10, 2016 5:22 pm
by anaumov
Thank you, you're right. I fixed it and this code works fine now!

Code: Select all

(defun get-info (hash)
  (format t "~A~%"
    (snmp:with-open-session
      (s (gethash "HOST" hash)
        :user (gethash "USERNAME" hash)
        :auth (list ':md5 (gethash "PASSWORD" hash)))
      (snmp:snmp-walk s (gethash "OPTION" hash)))))