[SNMP4J] SNMP trap message parsing using SNMP4J APIs

Murali Natarajan murali.natarajan at jpmchase.com
Tue Oct 5 15:53:37 CEST 2010


I tried with a couple more changes as:
OctetString authEngine = new OctetString("12345"); /* this is the id of the sending test engine */
usm.addUser(securityName,authEngine,user);

And still getting -1414 error. Could this be authentication failure?

Trying to understand how to authenticate the a) sending engine id b) security name c) passwords etc that use a certain authPassphrase and privpassPhrase. The sender program sets all these values.

How do I authenticate these in the standalone POJO that is getting the payload via another listener program? And extract the PDU from the payload?

Murali Natarajan
CIG TSS Admin Center Architecture 
312-954-1670
murali.natarajan at jpmchase.com

-----Original Message-----
From: Murali Natarajan 
Sent: Wednesday, September 29, 2010 7:21 PM
To: 'Mackay, Scott'
Cc: 'snmp4j at agentpp.org'
Subject: RE: [SNMP4J] SNMP trap message parsing using SNMP4J APIs

Your suggestion below works well for V1 and V2 traps. For V3, I am getting a -1414 return code. I am using a test client that sends data like this:
-v 3 -u newUser -A abc12345 -X abc12345 -a md5 -x DES ....... etc as command line parameters for a user id of 'newuser' with both passphrases='abc12345'along with several other parameters to build the VBS[]. This is a proven test client - I don't suspect any issues with the way it works to create and send out SNMP traps.

My receiving end code fragment is as follows. It is not using SNMP listener but another program that listens on a UDP port and hands over whatever it gets to my code below - which I need to process for traps.


securityName = new OctetString("newUser");
			    
			    OctetString authPassphrase = new OctetString("abc12345");
			    OctetString privPassphrase = new OctetString("abc12345");
			    OID authProtocol = AuthMD5.ID;
			    OID privProtocol = PrivDES.ID;
		
				byte[] localEngineID =
					MPv3.createLocalEngineID();
		
			    USM usm = new USM(SecurityProtocols.getInstance(),
			                      new OctetString(localEngineID), 0);
			 // Add the configured user to the USM
			    UsmUser user = new UsmUser(securityName, authProtocol, authPassphrase,privProtocol, privPassphrase);
	
			   	usm.addUser(securityName,user);
			    SecurityModels.getInstance().addSecurityModel(usm);
			    MessageProcessingModel messageProcessingModelV3 = new MPv3(usm); 
				// notifications
				
				int status = messageProcessingModelV3.prepareDataElements(messageDispatcher,
						addy, berStream, messageProcessingModelInt,
						securityModel, securityName, securityLevel, mutablePDU,
						sendPduHandle, maxSizeResponseScopedPDU,


						statusInformation, stateReference);


pdu = mutablePDU.getPdu();
				scopedPDU = (ScopedPDU) pdu;
	
				if (status==SnmpConstants.SNMP_MP_OK)
					System.out.println("Trap V3 type received OK");
				else


					System.out.println("MPV3 call status = "+status);

My printline statements output is as follows. Otherwise, there are no runtime errors but PDU is null:

MPV3 call status = -1414
Trap V3 type received : (-96)
Using SNMP4J: PDU to string: GET[reqestID=0, errorStatus=0, errorIndex=0, VBS[]]
Using SNMP4J: scopedPDU to string: GET[reqestID=0, errorStatus=0, errorIndex=0, VBS[]]
Using SNMP4J: PDU size = 0
Using SNMP4J: securityModel = 3
Using SNMP4J: securityName = newUser
Using SNMP4J: securityLevel = 3

Murali Natarajan
CIG TSS Admin Center Architecture 
312-954-1670
murali.natarajan at jpmchase.com

-----Original Message-----
From: Mackay, Scott [mailto:scott.mackay at progeny.net] 
Sent: Tuesday, August 10, 2010 12:33 PM
To: Murali Natarajan
Cc: snmp4j at agentpp.org
Subject: RE: [SNMP4J] SNMP trap message parsing using SNMP4J APIs


Have you looked at the MessageProcessingModel (and MPv3,MPv1, MPv2c)?  There is a method prepareDataElements() which seems responsible for converting streams into the SNMP4j classes though I have not done that myself.

-Scott

-----Original Message-----
From: Murali Natarajan [mailto:murali.natarajan at jpmchase.com]
Sent: Tue 8/10/2010 1:20 PM
To: Shlomo
Cc: Mackay, Scott; snmp4j at agentpp.org
Subject: RE: [SNMP4J] SNMP trap message parsing using SNMP4J APIs
 
Nope.

This part is being handled by another tool. It will receive the incoming trap and return a byte []. That is my starting point 1) to convert that into a trap object 2) extract details from there etc

Murali Natarajan
CIG TSS Admin Center Architecture
312-954-1670
murali.natarajan at jpmchase.com<mailto:murali.natarajan at jpmchase.com>

From: Shlomo [mailto:shlomo at tikalk.com]
Sent: Tuesday, August 10, 2010 11:50 AM
To: Murali Natarajan
Cc: Mackay, Scott; snmp4j at agentpp.org
Subject: Re: [SNMP4J] SNMP trap message parsing using SNMP4J APIs

Hi,
Is this what you need?

public void processPdu(
CommandResponderEvent e) {
         logger.debug("processPdu start ...");
         PDU command = e.getPDU();
         if (command != null) {
           System.out.println(command.toString());

On Tue, Aug 10, 2010 at 7:40 PM, Murali Natarajan <murali.natarajan at jpmchase.com<mailto:murali.natarajan at jpmchase.com>> wrote:
Yes but in my case the difference is some other code (not the SNMP4J listeners) is receiving the incoming trap as a byte array. So I need to:

1. Convert this byte array to a trap object or a PDU; figure out what version etc in doing that conversion
2. Extract information from the trap object.

It is for the step 1, I am looking for APIs in SNMP4J.

Thanks.

Murali Natarajan
CIG TSS Admin Center Architecture
312-954-1670
murali.natarajan at jpmchase.com<mailto:murali.natarajan at jpmchase.com>

-----Original Message-----
From: Mackay, Scott [mailto:scott.mackay at progeny.net<mailto:scott.mackay at progeny.net>]
Sent: Tuesday, August 10, 2010 4:23 AM
To: Murali Natarajan; snmp4j at agentpp.org<mailto:snmp4j at agentpp.org>
Subject: RE: [SNMP4J] SNMP trap message parsing using SNMP4J APIs


A good method is following the steps used in the SnmpRequest.java from the source code.  The code is located in src/org/snmp4j/tools/console and is 1 file.  As a note, if you are in that directory you can run the jarred version for comparison as: "java -cp ../../../../../dist/snmp4j-1.10.2.jar org.snmp4j/tools/console/SnmpRequest"
You will notice there is an option, -Ol, which will listen for traps and such.  I would follow through the code on how that is set up, waited on, and processed.


-Scott

-----Original Message-----
From: snmp4j-bounces at agentpp.org<mailto:snmp4j-bounces at agentpp.org> on behalf of Murali Natarajan
Sent: Mon 8/9/2010 3:56 PM
To: snmp4j at agentpp.org<mailto:snmp4j at agentpp.org>
Subject: (nwl)  [SNMP4J] SNMP trap message parsing using SNMP4J APIs

Hi,

I have an SNMP trap message being received as a byte array by an ESB tool. I am trying to understand how to parse and extract the trap message details (OIDs, their values, etc) from this byte array - using SNMP4J APIs.

Is there a reference sample code available for this? If not, what are the specific APIs to use etc?

Murali Natarajan
CIG TSS Admin Center Architecture
312-954-1670
murali.natarajan at jpmchase.com<mailto:murali.natarajan at jpmchase.com><mailto:murali.natarajan at jpmchase.com<mailto:murali.natarajan at jpmchase.com>>



This communication is for informational purposes only. It is not
intended as an offer or solicitation for the purchase or sale of
any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not
warranted as to completeness or accuracy and are subject to change
without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.

Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to European legal entities.
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org<mailto:SNMP4J at agentpp.org>
http://lists.agentpp.org/mailman/listinfo/snmp4j

_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org<mailto:SNMP4J at agentpp.org>
http://lists.agentpp.org/mailman/listinfo/snmp4j






More information about the SNMP4J mailing list