if (req.type != req.pduGetBulkRequestPdu) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"reduceResponsePdu", "cannot remove anything");
}
throw new SnmpTooBigException(acceptedVbCount) ;
}
// We're going to reduce the varbind list.
// First determine which items should be removed.
// Next duplicate and replace the existing list by the reduced one.
//
// acceptedVbCount is the number of varbind which have been
// successfully encoded before reaching bufferSize:
// * when it is >= 2, we split the varbindlist at this
// position (-1 to be safe),
// * when it is 1, we only put one (big?) item in the varbindlist
// * when it is 0 (in fact, acceptedVbCount is not available),
// we split the varbindlist by 2.
//
int vbCount = resp.varBindList.length ;
if (acceptedVbCount >= 3)
vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ;
else if (acceptedVbCount == 1)
vbCount = 1 ;
else // acceptedCount == 0 ie it is unknown
vbCount = resp.varBindList.length / 2 ;
if (vbCount < 1) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"reduceResponsePdu", "cannot remove anything");
}
throw new SnmpTooBigException(acceptedVbCount) ;
}
else {
SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ;
for (int i = 0 ; i < vbCount ; i++) {
newVbList[i] = resp.varBindList[i] ;