2011-06-30 132 views
0

我用这个来接收SNMPv1陷阱消息的SNMP陷阱消息的结果:解码字节缓冲区,

transport.addTransportListener(new TransportListener() { 
    public void processMessage(TransportMapping transportmapping, 
      Address address, ByteBuffer byteBuffer) { 
     BERInputStream berStream = new BERInputStream(byteBuffer); 
     BER.decodeString(berStream, new BER.MutableByte()); 
    } 
)}; 

我的问题是,我不知道如何解析byteBuffer获取数据代理以清晰的方式发送。 这就是我得到如果我现在执行我的代码:

java.io.IOException: Wrong ASN.1 type. Not a string: 48 at position 1 

我已经试过一些其他MutableType秒,但我真的很困惑要使用哪一个。 这是正确的吗?你知道使用哪个MutableType吗?

+0

您可以向您的发帖添加示例消息吗? – Robert

+0

@Robert:看到我的回答,我做错了。 –

回答

1

我这样做完全错了。

感谢我的同事,这里的校正(忽略以上):

Snmp snmp = new Snmp(transport); 
CommandResponder trapPrinter = new CommandResponder() { 
    public synchronized void processPdu(CommandResponderEvent e) { 
     PDU command = e.getPDU(); 
    } 
}; 

command包含了所有的信息,无需任何解码。