private DatagramPacket makeResponsePacket(DatagramPacket reqPacket) {
DatagramPacket respPacket = null ;
// Transform the request packet into a request SnmpMessage
//
SnmpMessage reqMsg = new SnmpMessage() ;
try {
reqMsg.decodeMessage(reqPacket.getData(), reqPacket.getLength()) ;
reqMsg.address = reqPacket.getAddress() ;
reqMsg.port = reqPacket.getPort() ;
}
catch(SnmpStatusException x) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"makeResponsePacket", "packet decoding failed", x);
}
reqMsg = null ;
((SnmpAdaptorServer)adaptorServer).incSnmpInASNParseErrs(1) ;
}
// Make the response SnmpMessage if any
//
SnmpMessage respMsg = null ;
if (reqMsg != null) {
respMsg = makeResponseMessage(reqMsg) ;
}
// Try to transform the response SnmpMessage into response packet.
// NOTE: we overwrite the request packet.
//
if (respMsg != null) {
try {
reqPacket.setLength(respMsg.encodeMessage(reqPacket.getData())) ;
respPacket = reqPacket ;
}
catch(SnmpTooBigException x) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"makeResponsePacket", "response message is too big");
}
try {
respMsg = newTooBigMessage(reqMsg) ;
reqPacket.setLength(respMsg.encodeMessage(reqPacket.getData())) ;
respPacket = reqPacket ;
}
catch(SnmpTooBigException xx) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,