SnmpResponseHandlerpublic class SnmpResponseHandler extends Object This class is used to handle received inform request responses.
This classes parses the SNMP inform response packet to obtain the corresponding inform request. |
Fields Summary |
---|
SnmpAdaptorServer | adaptor | SnmpQManager | snmpq | String | dbgTag |
Methods Summary |
---|
void | debug(java.lang.String func, java.lang.Throwable exception)
debug(dbgTag, func, exception);
| void | debug(java.lang.String clz, java.lang.String func, java.lang.String info)
Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_ADAPTOR_SNMP, clz, func, info);
| void | debug(java.lang.String clz, java.lang.String func, java.lang.Throwable exception)
Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_ADAPTOR_SNMP, clz, func, exception);
| void | debug(java.lang.String func, java.lang.String info)
debug(dbgTag, func, info);
| boolean | isDebugOn()
return Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_ADAPTOR_SNMP);
| boolean | isTraceOn()
return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_ADAPTOR_SNMP);
| public synchronized void | processDatagram(java.net.DatagramPacket dgrm)
byte []data = dgrm.getData();
int datalen = dgrm.getLength();
if (isTraceOn()) {
trace("processDatagram", "Received from " + dgrm.getAddress().toString() + " Length = " + datalen +
"\nDump : \n" + SnmpMessage.dumpHexBuffer(data, 0, datalen));
}
try {
SnmpMessage msg = new SnmpMessage();
msg.decodeMessage(data, datalen);
msg.address = dgrm.getAddress();
msg.port = dgrm.getPort();
// Retreive the PDU factory of the SNMP adaptor to decode the received inform response.
//
SnmpPduFactory pduFactory = adaptor.getPduFactory();
if (pduFactory == null) {
if (isDebugOn()) {
debug("processDatagram", "Dropping packet. Unable to find the pdu factory of the SNMP adaptor server");
}
}
else {
SnmpPduPacket snmpProt = (SnmpPduPacket)pduFactory.decodeSnmpPdu(msg);
if (snmpProt == null) {
if (isDebugOn()) {
debug("processDatagram", "Dropping packet. Pdu factory returned a null value");
}
}
else if (snmpProt instanceof SnmpPduRequest) {
SnmpPduRequest pduReq = (SnmpPduRequest)snmpProt;
SnmpInformRequest req = snmpq.removeRequest(pduReq.requestId) ;
if (req != null) {
req.invokeOnResponse(pduReq);
} else {
if (isDebugOn()) {
debug("processDatagram", "Dropping packet. Unable to find corresponding for InformRequestId = " + pduReq.requestId);
}
}
}
else {
if (isDebugOn()) {
debug("processDatagram", "Dropping packet. The packet does not contain an inform response");
}
}
snmpProt = null ;
}
} catch (Exception e) {
if (isDebugOn()) {
debug("processDatagram", "Exception while processsing");
debug("processDatagram", e);
}
}
| void | trace(java.lang.String clz, java.lang.String func, java.lang.String info)
Trace.send(Trace.LEVEL_TRACE, Trace.INFO_ADAPTOR_SNMP, clz, func, info);
| void | trace(java.lang.String func, java.lang.String info)
trace(dbgTag, func, info);
|
|