use of org.opennms.netmgt.snmp.TrapIdentity in project opennms by OpenNMS.
the class TrapUtils method getTrapData.
/**
* Gets the trap identity.
*
* @param trapNotification the trap notification
* @return the identity
*/
public static TrapData getTrapData(TrapInformation trapNotification) {
if (trapNotification instanceof Snmp4JV1TrapInformation) {
Snmp4JV1TrapInformation info = (Snmp4JV1TrapInformation) trapNotification;
TrapIdentity identity = info.getTrapIdentity();
TrapData data = new TrapData(identity.getEnterpriseId(), identity.getGeneric(), identity.getSpecific());
for (int i = 0; i < info.getPduLength(); i++) {
VariableBinding v = info.getVarBindAt(i);
SnmpValue value = new Snmp4JValue(v.getVariable());
data.addParameter("." + v.getOid().toString(), value.toDisplayString());
}
return data;
} else if (trapNotification instanceof Snmp4JV2TrapInformation) {
Snmp4JV2TrapInformation info = (Snmp4JV2TrapInformation) trapNotification;
TrapIdentity identity = info.getTrapIdentity();
TrapData data = new TrapData(identity.getEnterpriseId(), identity.getGeneric(), identity.getSpecific());
for (int i = 0; i < info.getPduLength(); i++) {
VariableBinding v = info.getVarBindAt(i);
SnmpValue value = new Snmp4JValue(v.getVariable());
data.addParameter("." + v.getOid().toString(), value.toDisplayString());
}
return data;
}
return null;
}
use of org.opennms.netmgt.snmp.TrapIdentity in project opennms by OpenNMS.
the class V2TrapInformation method getTrapIdentity.
@Override
public TrapIdentity getTrapIdentity() {
// Get the value for the snmpTrapOID
SnmpObjectId snmpTrapOid = (SnmpObjectId) m_pdu.getVarBindAt(V2TrapInformation.SNMP_TRAP_OID_INDEX).getValue();
SnmpObjectId lastVarBindOid = m_pdu.getVarBindAt(getPduLength() - 1).getName();
SnmpSyntax lastVarBindValue = m_pdu.getVarBindAt(getPduLength() - 1).getValue();
return new TrapIdentity(SnmpObjId.get(snmpTrapOid.getIdentifiers()), SnmpObjId.get(lastVarBindOid.getIdentifiers()), new JoeSnmpValue(lastVarBindValue));
}
Aggregations