[SNMP4J] Opaque: Float: leads to Wrong ASN1

Sebastien sebastien.martagex at 3roam.com
Wed Apr 28 11:31:11 CEST 2010


Hi everyone,

Sorry in advance for my English, this is not my mother tongue.

This is the first time I post, and I'm having this problem for a long time.

My question is : Is there a way to get back Opaque:Float values with 
SNMP4J ?

I'm asking that because I did some test with NetSNMP and it gives me the 
following result (I replaced critical data with ###):
$ snmpget    -v 2c   -c ####   192.168.0.###   
1.3.6.1.4.1.####.33.1.1.49.109.100.117.49
SNMPv2-SMI::enterprises.####.33.1.1.49.109.100.117.49 = Opaque: Float: 
29.299999

[version 2C is used in the SNMPGET request]


But with SNMP4J, I don't know how to receive Opaque:Float.
I tried with the following Java code and I get the following error :  
"java.io.IOException: Wrong ASN.1 type. Not a string: -97 at position 1"

[PDU uses Version 1]
+---------------code-------------------
   public String getAnswer(OID oid) throws SNMPException,
           IOException {
             pdu = new PDUv1();
       pdu.add(new VariableBinding(oid));
       pdu.setType(PDU.GET);

       ResponseEvent response = null;
       response = snmp.send(pdu, target);

       Opaque op = 
(Opaque)response.getResponse().get(0).getVariable();               
       byte[] opByte = op.toByteArray();               // the content 
is  1.3.6.1.4.1.####.33.1.1.49.109.100.117.49 = 9f:78:04:41:eb:33:33
       ByteBuffer opByteBuff = ByteBuffer.wrap(opByte);
       BERInputStream opBis = new BERInputStream(opByteBuff);
       op.decodeBER(opBis);         // Here is where I get the error

   }



Thank you in advance.


More information about the SNMP4J mailing list