All.

I am writting an SNMP mamanger to perform GET / SET and receive INFORM
messages from an SNMP agent.
The agent is using SNMP V3.

I have looked through the list, and I think that I am creating the
PDU, Target and adding the USM correctly. (below is the code).
But, when I send the PDU to the SNMP agent, I get a usmNotInTimeWindow
(1.3.6.1.6.3.15.1.1.2.0).

>From looking at the code below, am I doing it correctly?

I userstand that the agent uses SHA authentication, but I am unsure if
I need to specify the ContextEngineID of AuthoritiveEngineID when I
create and send the PDU.

--Aidan

====Adding USM user===
 OctetString localEngineID = new OctetString(MPv3.createLocalEngineID());
 USM usm = new USM(SecurityProtocols.getInstance(),
                            new OctetString(localEngineID), 0);

 // add user to the USM
 UsmUser user = new UsmUser(
                                            new OctetString("UserName"),
                            AuthSHA.ID,
                            new OctetString("password")
                           null, null
                           );

SecurityModels.getInstance().addSecurityModel(usm);
snmp.getUSM().addUser(user.getSecurityName(), user);
====

===Send GET===
Address targetAddress = GenericAddress.parse("udp:172.16.100.246/161");

UsmUserEntry userEntry = snmp.getUSM().getUserTable().getUser(new
OctetString("UserName"));

UserTarget target = new UserTarget();
target.setSecurityLevel(SecurityLevel.AUTH_NOPRIV);
target.setSecurityName(userEntry.getUsmUser().getSecurityName());
target.setVersion(SnmpConstants.version3);
target.setAddress(targetAddress);
target.setRetries(1);
target.setTimeout(5000);

ScopedPDU pdu = new ScopedPDU();
pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.1.3")));
pdu.setType(PDU.GETNEXT);

ResponseEvent e = snmp.send(pdu, target);
if (e != null)
{
 ScopedPDU pduR = (ScopedPDU)e.getResponse();
}


=============
_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to