Skip to Main Content
Essential SNMP, 2nd Edition
book

Essential SNMP, 2nd Edition

by Douglas Mauro, Kevin Schmidt
September 2005
Beginner content levelBeginner
462 pages
12h 56m
English
O'Reilly Media, Inc.
Content preview from Essential SNMP, 2nd Edition

Receiving Traps and Informs

We've split up the SNMPv2c and SNMPv3 trap receivers into two separate classes, V2TrapReceiver and V3TrapReceiver. These classes implement CommandResponder. This means that we must implement a method that has the following signature:

    public synchronized void processPdu(CommandResponderEvent e) {
    ...
    }

The processPdu method is responsible for handling incoming requests. Since SnmpWalk supports SNMPv3, we have to be able to respond to discovery requests from an authoritative SNMP engine.

Tip

With the other SNMP applications, we created transport objects that were a combination of the IP address and port on a remote machine. With a trap or inform receiver, we create a target object, but the IP address is the IP of the local Ethernet interface we wish to bind to, along with the port (default for traps is 162).

Consider the following code sequence:

 _threadPool = ThreadPool.create("DispatcherPool", _numThreads); MessageDispatcher mtDispatcher = new MultiThreadedMessageDispatcher(_threadPool, new MessageDispatcherImpl()); // add message processing models mtDispatcher.addMessageProcessingModel(new MPv2c()); // add all security protocols SecurityProtocols.getInstance().addDefaultProtocols(); CommunityTarget target = new CommunityTarget(); if(target != null) { target.setCommunity(_comm); _target = target; } else { System.out.println("Unable to create Target object"); System.exit(-1); } _snmp = new Snmp(mtDispatcher, _transport); if(_snmp != null){ _snmp.addCommandResponder(this); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Essential SNMP

Essential SNMP

Douglas Mauro, Kevin Schmidt
UNIX and Linux System Administration Handbook, 5th Edition

UNIX and Linux System Administration Handbook, 5th Edition

Trent R. Hein, Evi Nemeth, Garth Snyder, Ben Whaley, Dan Mackin

Publisher Resources

ISBN: 0596008406Supplemental ContentErrata Page