本文整理汇总了C++中Pdu::get_notify_enterprise方法的典型用法代码示例。如果您正苦于以下问题:C++ Pdu::get_notify_enterprise方法的具体用法?C++ Pdu::get_notify_enterprise怎么用?C++ Pdu::get_notify_enterprise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pdu
的用法示例。
在下文中一共展示了Pdu::get_notify_enterprise方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_trap_info
int wpdu::set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const
{
Oid enterprise;
Oid trapid; // validate caller has set this correctly
pdu.get_notify_id( trapid);
if ( !trapid.valid() || trapid.length() < 2 ) {
cmu_snmp::free_pdu( raw_pdu);
return SNMP_CLASS_INVALID_NOTIFYID;
}
raw_pdu->specific_type=0;
// TODO: object should emit numeric instead of this kind of mess...
if ( trapid == coldStart)
raw_pdu->trap_type = V1_COLD_START; // cold start
else if ( trapid == warmStart)
raw_pdu->trap_type = V1_WARM_START; // warm start
else if( trapid == linkDown)
raw_pdu->trap_type = V1_LINK_DOWN; // link down
else if ( trapid == linkUp)
raw_pdu->trap_type = V1_LINK_UP; // link up
else if ( trapid == authenticationFailure )
raw_pdu->trap_type = V1_AUTH_FAILURE; // authentication failure
else if ( trapid == egpNeighborLoss)
raw_pdu->trap_type = V1_EGP_NEIGHBOR_LOSS; // egp neighbor loss
else {
raw_pdu->trap_type = V1_ENT_SPECIFIC; // enterprise specific
// last oid subid is the specific value
// if 2nd to last subid is "0", remove it
// enterprise is always the notify oid prefix
raw_pdu->specific_type = (int) trapid[(int) (trapid.length() - 1)];
trapid.trim(1);
if ( trapid[(int)(trapid.length() - 1)] == 0 )
trapid.trim(1);
enterprise = trapid;
}
if ( raw_pdu->trap_type != V1_ENT_SPECIFIC)
pdu.get_notify_enterprise( enterprise);
if ( enterprise.length() > 0) {
// note!! To the contrary, enterprise OID val is
// copied here and raw_pdu->enterprise is freed in free_pdu
// as it should be (HDN)
// these are hooks into an SNMP++ oid
// and therefor the raw_pdu enterprise
// should not free them. null them out!!
SmiLPOID rawOid;
rawOid = enterprise.oidval();
// HDN - enterprise is a local object, cannot simply assign pointer
//raw_pdu->enterprise = rawOid->ptr;
raw_pdu->enterprise_length = (int) rawOid->len;
ACE_NEW_RETURN(raw_pdu->enterprise,
oid[raw_pdu->enterprise_length],-1);
ACE_OS::memcpy((char *)raw_pdu->enterprise,(char *)rawOid->ptr,
raw_pdu->enterprise_length * sizeof(oid));
}
TimeTicks timestamp;
pdu.get_notify_timestamp( timestamp);
raw_pdu->time = ( unsigned long) timestamp;
// HDN - set agent addr using the local hostname if possible
char localHostName[MAXHOSTNAMELEN];
Snmp::get_host_name(localHostName, MAXHOSTNAMELEN);
if (ACE_OS::strlen(localHostName) > 0) {
GenAddress addr(localHostName);
OctetStr octet;
addr.to_octet(octet);
ACE_OS::memcpy(&(raw_pdu->agent_addr.sin_addr),
octet.data(),
octet.length());
}
return 0;
}