[SNMP4J] receiving not snmp msgs
Frank Fock
fock at agentpp.com
Tue Nov 8 00:59:36 CET 2011
Hi Alexander,
A PDU listener can only receive PDUs. If the PDU cannot be
parsed from the packet - bad luck.
However, you can use the TransportListener to get the packet
bytes.
Best regards,
Frank
Am 07.11.2011 12:14, schrieb Александр Литвинов:
> Hello. I'm using 2.0.2 version of snmp4j. And I have a question.
> I have multi-thread snmp server and it works great.
> But if incomming msg isn't in smnp format, i've got an error (server continues work). And the "processPdu" method isn't called.
> I want to know, what incoming to my server. In what way can i get incoming not snmp msg?
> It would be great if i could get it as array of bytes.
>
>
> i use following code:
> ========================================================
> public synchronized void listen(TransportIpAddress address) throws IOException
> {
> AbstractTransportMapping transport;
> if (address instanceof TcpAddress)
> {
> transport = new DefaultTcpTransportMapping((TcpAddress) address);
> }
> else
> {
> transport = new DefaultUdpTransportMapping((UdpAddress) address);
> }
> ThreadPool threadPool = ThreadPool.create("DispatcherPool", 10);
> MessageDispatcher mtDispatcher = new MultiThreadedMessageDispatcher(threadPool, new MessageDispatcherImpl());
>
> mtDispatcher.addMessageProcessingModel(new MPv1());
> mtDispatcher.addMessageProcessingModel(new MPv2c());
>
> SecurityProtocols.getInstance().addDefaultProtocols();
> SecurityProtocols.getInstance().addPrivacyProtocol(new Priv3DES());
>
> CommunityTarget target = new CommunityTarget();
> target.setCommunity( new OctetString("public"));
>
> Snmp snmp = new Snmp(mtDispatcher, transport);
> snmp.addCommandResponder(this);
>
> transport.listen();
> System.out.println(" Bind Success: Listening on " + address);
> try
> {
> this.wait();
> }
> catch (InterruptedException ex)
> {
> System.err.println(ex.getMessage());
> Thread.currentThread().interrupt();
> }
> }
> ---------------------------------------
> public synchronized void processPdu(CommandResponderEvent cmdRespEvent)
> {
> //some operations with pdu
> }</p>==========================================
>
>
> Best regarsds,
> Alexander.
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
More information about the SNMP4J
mailing list