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

You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Post Reply
anaumov
Posts: 10
Joined: Thu Sep 15, 2011 4:13 am
Location: Germany
Contact:

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

Post by anaumov » Sat Dec 10, 2016 3:24 am

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!

David Mullen
Posts: 78
Joined: Mon Dec 01, 2014 12:29 pm
Contact:

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

Post by David Mullen » Sat Dec 10, 2016 4:05 pm

It's a quoted list—you're passing in the literal expression (gethash "PASSWORD" hash) instead of its value.

anaumov
Posts: 10
Joined: Thu Sep 15, 2011 4:13 am
Location: Germany
Contact:

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

Post by anaumov » Sat Dec 10, 2016 5:22 pm

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

Post Reply