gpt4 book ai didi

java - 解码 ByteBuffer,snmp 陷阱消息的结果

转载 作者:行者123 更新时间:2023-12-01 15:48:52 24 4
gpt4 key购买 nike

我用它来接收 snmpv1 陷阱消息:

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 吗?

最佳答案

我完全错了。

感谢我的一位同事,更正如下(忽略上面的内容):

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

命令包含所有信息,无需解码任何内容。

关于java - 解码 ByteBuffer,snmp 陷阱消息的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6536466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com