Hi,

The trap PDU is malformed regarding the used OIDs (the structure cannot exists in properly constructed SMI MIB),
but that is not the cause for your specific problem here.
Just use the UsmUser constructor with localization engine ID parameter and put there the "localEngineIdInBytes".

Best regards,
Frank

Am 06.09.2015 um 18:50 schrieb N, Ravikiran:
HI All,

I am using the below snippet code for sending the SNMPv3 trap with Authoritative Engine 
ID. I am getting the exception  as " Message processing model 3 returned error: 
Unknown security name".
While debugging snmp4j jar I have identified mismatch between Engine ID 
inserted into the UsmUserTable and EngineId used for retrieval of UsmUser from 
the UsmUserTable. Please help me through this problem.

My Code for sending V3 trap is as below:

byte[] localEngineIdInBytes = MPv3.createLocalEngineID();
USM usm = new USM(SecurityProtocols.getInstance(),
                     new OctetString(localEngineIdInBytes), 0);  //Local Engine 
Id


ScopedPDU pdu = new ScopedPDU();
                                                                 pdu.setContextName(new 
OctetString("ContextName"));
                                                                 
pdu.setContextEngineID(new OctetString(localEngineIdInBytes)); // Context 
Engine ID
                                                                 
pdu.setType(ScopedPDU.TRAP);

                                                       long sysUpTime = 
(System.currentTimeMillis() - start) / 10;

                                                       pdu.add(new VariableBinding(new 
OID(trapOid + ".7"), new TimeTicks(sysUpTime)));
                                                       pdu.add(new VariableBinding(new 
OID(trapOid + ".8"), new OID(trapOid)));
                                                                 pdu.add(new VariableBinding(new 
OID(trapOid + ".1"), new OctetString("ssid")));
                                                                 pdu.add(new VariableBinding(new 
OID(trapOid + ".2"), new OctetString("1234")));
                                                                 pdu.add(new VariableBinding(new 
OID(trapOid + ".3"), new OctetString("CRI")));
                                                                 pdu.add(new VariableBinding(new 
OID(trapOid + ".4"), new OctetString("PROCESS")));
                                                                 pdu.add(new 
VariableBinding(new OID(trapOid + ".5"), new OctetString(new 
Date().toString())));
                                                                 pdu.add(new VariableBinding(new 
OID(trapOid + ".6"), new OctetString("message")));


TransportMapping transport = new DefaultUdpTransportMapping();
Address targetAddress = GenericAddress.parse("udp:127.0.0.1/" + port);

UserTarget comtarget = new UserTarget();
                                                         
comtarget.setVersion(SnmpConstants.version3);
                                                         
comtarget.setAddress(targetAddress);
                                                         
comtarget.setRetries(2);
                                                         
comtarget.setTimeout(5000);
                                                         comtarget.setSecurityName(new 
OctetString("abhi"));
                                                         
comtarget.setSecurityModel(3);
                                                         
comtarget.setSecurityLevel(SecurityLevel.AUTH_PRIV);




SecurityModels.getInstance().addSecurityModel(usm);

                                                                   SNMP snmp = 
new Snmp(transport);

                                                         snmp.getUSM().addUser(new 
OctetString("abhi"), new OctetString(localEngineIdInBytes),),   // 
Authoratative Engine ID
                                                                                 new 
UsmUser(new OctetString("abhi"), AuthSHA.ID,
                                                                                          
                               new OctetString("12345678"), PrivDES.ID,
                                                                                          
                               new OctetString("12345678")));

snmp.send(pdu, comtarget);
snmp.close();

Regards,
Ravikiran N

_______________________________________________
SNMP4J mailing list
[email protected]
https://oosnmp.net/mailman/listinfo/snmp4j

--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231

_______________________________________________
SNMP4J mailing list
[email protected]
https://oosnmp.net/mailman/listinfo/snmp4j

Reply via email to