Oid agentxcpp::generate_v1_snmpTrapOID(generic_trap_t generic_trap, quint32 specific_trap) { // We need the OID of the SNMPv1 traps. These are defined here. // // First we define a "helper" OID: static const Oid snmpTraps_oid(snmpMIBObjects_oid, "5"); // // Some traps according to RFC 1907: static const Oid snmpTraps_coldStart_oid(snmpTraps_oid, "1"); static const Oid snmpTraps_warmStart_oid(snmpTraps_oid, "2"); static const Oid snmpTraps_authenticationFailure_oid(snmpTraps_oid, "5"); // // Some traps according to RFC 1573: static const Oid snmpTraps_linkDown_oid(snmpTraps_oid, "3"); static const Oid snmpTraps_linkUp_oid(snmpTraps_oid, "4"); // Finally, egpNeighborLoss. According to RC 1907 it is defined in RFC // 1213, however, the latter doesn't define it. On the other hand, // RFC 2089 defines egpNeighborLoss as 1.3.6.1.6.3.1.1.5.6, which is // snmpTraps.6 and corresponds to the comment in RFC 1907, so we use this // one: static const Oid snmpTraps_egpNeighborLoss_oid(snmpTraps_oid, "6"); // calculate the value of snmpTrapOID.0 according to RFC 1908: Oid value; switch(generic_trap) { case coldStart: value = snmpTraps_coldStart_oid; break; case warmStart: value = snmpTraps_warmStart_oid; break; case linkDown: value = snmpTraps_linkDown_oid; break; case linkUp: value = snmpTraps_linkUp_oid; break; case authenticationFailure: value = snmpTraps_authenticationFailure_oid; break; case egpNeighborLoss: value = snmpTraps_egpNeighborLoss_oid; break; case enterpriseSpecific: value = enterprises_oid; value.push_back(0); value.push_back(specific_trap); break; default: // invalid generic_trap value! throw(inval_param()); } // Create and return varbind return value; }
/** * \brief Convert the value to an OID. * * The conversion is done according to RFC 2578, * 7.7. "Mapping of the INDEX clause". The created OID * has exactly 4 subids which corresponds to the 4 * integers of the IP address. */ virtual Oid toOid() const { Oid oid; oid.push_back(v[0]); oid.push_back(v[1]); oid.push_back(v[2]); oid.push_back(v[3]); return oid; }
Oid OctetStringVariable::toOid() const { // There are fixed length string, but don't support them currently. bool fixedLength = false; Oid oid; // Store string length if needed if(!fixedLength) { oid.push_back(v.size()); } // Store string for(binary::const_iterator i = v.begin(); i != v.end(); ++i) { oid.push_back(*i); } return oid; }
/** * \brief Convert the value to an OID. * * The conversion is done according to RFC 2578, * 7.7. "Mapping of the INDEX clause". The value is * converted to an Oid with a single subid. * * This method should not be overridden. * * \note If a TIMETICK is used in an INDEX clause, the * value 0 should be avoided according to * RFC 2578, 7.7. "Mapping of the INDEX clause". */ virtual Oid toOid() const { Oid oid; oid.push_back(v); return oid; }