*/
public SnmpPduRequest snmpReceivedGet(SnmpPduPacket pdu, boolean getNext)
{
try
{
SnmpPduRequest response = null;
int pduLength = pdu.getLength();
final boolean trace = log.isTraceEnabled();
if (trace)
log.trace("requestId=" + pdu.getRequestId() + ", pduLength="
+ pduLength + ", getNext=" + getNext);
SnmpVarBind[] vblist = new SnmpVarBind[pduLength];
int errorStatus = SnmpPduPacket.ErrNoError;
int errorIndex = 0;
// Process for each varibind in the request
for (int i = 0; i < pduLength; i++)
{
boolean good = true;
SnmpVarBind vb = pdu.getVarBindAt(i);
SnmpObjectId oid = vb.getName();
if (getNext)
{
/*
* We call getNextOid() to find out what is the next valid OID
* instance in the supported MIB (sub-)tree. Assign that OID to the
* VB List and then proceed same as that of get request. If the
* passed oid is already the last, we flag it.
*/
ComparableSnmpObjectId coid = new ComparableSnmpObjectId(oid);
oid = getNextOid(coid, true);
if (oid == null)
{
good = false;
}
else
{
pdu.setVarBindAt(i, new SnmpVarBind(oid));
}
}
if (oid!=null)
vblist[i] = new SnmpVarBind(oid);
else
vblist[i] = new SnmpVarBind(vb.getName()); // oid passed in
if (trace)
log.trace("oid=" + oid);
SnmpSyntax result = null;
if (good && bindings != null)
result = getValueFor(oid);
if (trace)
log.trace("got result of " + result);
if (result == null || !good)
{
errorStatus = SnmpPduPacket.ErrNoSuchName;
errorIndex = i + 1;
log.debug("Error Occured " + vb.getName().toString());
}
else
{
vblist[i].setValue(result);
log.debug("Varbind[" + i + "] := "
+ vblist[i].getName().toString());
log.debug(" --> " + vblist[i].getValue().toString());
}
} // for ...
response = new SnmpPduRequest(SnmpPduPacket.RESPONSE, vblist);
response.setErrorStatus(errorStatus);
response.setErrorIndex(errorIndex);
return response;
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();