Hi Simon,
Your approach will not work for SNMPv3.
For SNMPv3 you need to implement your own
TransportMapping that wraps your existing
transport.
Best regards,
Frank
simon sew wrote:
>
>
> Hi there,
>
> I’ve just started learning about SNMP4j.
>
>
>
> Currently I have this problem.
>
> I would like to integrate the SNMP4j into my existing
> application.
>
> The problem now is that we have already have an existing
> TCP/UDP listener.
>
> If possible, we would like to keep it as usual.
>
>
>
> I tried to bypass your listener and it works for snmp v1 and
> v2c.
>
> However when I tried with v3. It wont work. I can received
> the log but it didn’t get processed.
>
>
>
> Could you redirect me into the correct path.
>
>
>
> Regards,
>
> Simon
>
>
>
> P/S : Here is some of the my code. (Sorry for my bad
> English)
>
>
>
>
> threadPool = ThreadPool.create("Trap", 2);
>
>
> dispatcher = new
> MultiThreadedMessageDispatcher(threadPool,
>
>
> new
> MessageDispatcherImpl());
>
>
> listenAddress =
> GenericAddress.parse(System.getProperty(
>
>
> "snmp4j.listenAddress", "udp:0.0.0.0/0"));
>
>
>
>
> if (listenAddress instanceof UdpAddress) {
>
>
> transport = new
> DefaultUdpTransportMapping(
>
>
> (UdpAddress) listenAddress);
>
>
> } else {
>
>
> transport = new
> DefaultTcpTransportMapping(
>
>
> (TcpAddress) listenAddress);
>
>
> }
>
>
>
>
> snmp = new Snmp(dispatcher, transport);
>
>
> snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1());
>
>
> snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
>
>
>
>
> SecurityProtocols.getInstance().addDefaultProtocols();
>
>
> byte[] localEngineID
> = ((MPv3)
> snmp.getMessageProcessingModel(MessageProcessingModel.MPv3)).createLocalEngineID();
>
>
> USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(
>
>
> localEngineID), 0);
>
>
> SecurityModels.getInstance().addSecurityModel(usm);
>
>
> snmp.setLocalEngine(localEngineID,
> 0, 0);
>
>
>
>
> usm.addUser(
>
>
> new OctetString("simon_user"),
>
>
> new UsmUser(new OctetString("simon_user"),
>
>
> AuthMD5.ID,
>
>
> new OctetString("simon_password"),
>
>
> PrivDES.ID,
>
>
> new OctetString("simon_des")));
>
>
> snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3());
>
>
>
>
> snmp.addCommandResponder(this);
>
>
>
>
> //I use this to bypass the listener (works for v1,v2c not v3)
>
>
> ((DefaultUdpTransportMapping) transport).fireProcessMessage(
>
>
> new
> UdpAddress(InetAddress.getByName("192.168.2.157"), 162),
>
>
> bis);
>
>
>
>
> ...
>
>
> public void
> processPdu(CommandResponderEvent event) {
>
>
> ….
>
>
> _________________________________________________________________
> Join the Fantasy Football club and win cash prizes here!
> http://fantasyfootball.malaysia.msn.com
> _______________________________________________
> SNMP4J mailing list
> [email protected]
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com
_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j