* value didn't match the type
*/
private AsnObject createAsnValue(SnmpRequest request)
throws SnmpException {
MibType type = request.getType();
String value = request.getValue();
if (type.hasTag(MibTypeTag.UNIVERSAL_CATEGORY, 2)) {
// INTEGER & Integer32
return new AsnInteger(parseInteger(value));
} else if (type.hasTag(MibTypeTag.UNIVERSAL_CATEGORY, 4)) {
// OCTET STRING
return new AsnOctets(value);
} else if (type.hasTag(MibTypeTag.UNIVERSAL_CATEGORY, 6)) {
// OBJECT IDENTIFIER
return new AsnObjectId(value);
} else if (type.hasTag(MibTypeTag.APPLICATION_CATEGORY, 0)) {
// IPAddress
return new AsnOctets(parseInetAddress(value));
} else if (type.hasTag(MibTypeTag.APPLICATION_CATEGORY, 1)) {
// Counter
return new AsnUnsInteger(parseInteger(value),
SnmpConstants.COUNTER);
} else if (type.hasTag(MibTypeTag.APPLICATION_CATEGORY, 2)) {
// Gauge
return new AsnUnsInteger(parseInteger(value),
SnmpConstants.GAUGE);
} else if (type.hasTag(MibTypeTag.APPLICATION_CATEGORY, 3)) {
// TimeTicks
return new AsnUnsInteger(parseInteger(value),
SnmpConstants.TIMETICKS);
} else if (type.hasTag(MibTypeTag.APPLICATION_CATEGORY, 4)) {
// Opaque
return new AsnOctets(value);
} else if (type.hasTag(MibTypeTag.APPLICATION_CATEGORY, 6)) {
// Counter64
return new AsnUnsInteger64(parseLong(value));
} else {
throw new SnmpException("Unsupported MIB type: " + type);
}