[AGENT++] Questions

qqbao qqbao at fiberhome.com.cn
Mon Nov 21 05:26:34 CET 2011


Hello, 
I encountered some problems.

Question 1:
In my application, I would like to have two Snmp objects to receive traps at the same time. One object is for ipv4, and the other object is for ipv6. It works normal in windows system, but failed in suse_linux_11_x64 system when I called notify_register() like below: 

// ---------------------------------------------
int iStatus = 0;
Snmp *pTrapSnmp = new Snmp(iStatus); // ipv4
if (!pTrapSnmp || SNMP_CLASS_SUCCESS != iStatus)
{
return false;
}
iStatus = 0;
Snmp *pTrapSnmp_V6 = new Snmp(iStatus, 0, true);
if (!pTrapSnmp_V6 || SNMP_CLASS_SUCCESS != iStatus)
{
return false;
}

TargetCollection oTargets;     
OidCollection oTrapids;
iStatus = pTrapSnmp->notify_register(oTrapids, oTargets, 
&Trap_Callback, this); // OK!
if (SNMP_CLASS_SUCCESS != iStatus)
{
return false;
}

iStatus = pTrapSnmp_V6->notify_register(oTrapids, oTargets, 
&Trap_Callback, this);  // Failed! return -21. 
if (SNMP_CLASS_SUCCESS != iStatus)
{
return false;
}

...

// ---------------------------------------------

How can I fix it?

Question 3:
In Sun Solaris10 system (64bit), the ipv6 version of snmp++ library crashed in the following code:

// ---------------------------------------------
file: snmp++/src/address.cpp

unsigned int IpAddress::get_scope() const
{
  ADDRESS_TRACE;
  if (valid_flag)
  {
    const unsigned int *scope;
    if ((ip_version == version_ipv6) && (have_ipv6_scope))
      scope = (const unsigned int*)(address_buffer + IP6LEN_NO_SCOPE);
    else
      return (unsigned int)-1;
    return ntohl(*scope); // Crashed !
  }
  return (unsigned int)-1; // don't use uninitialized memory
}

bool IpAddress::set_scope(const unsigned int scope)
{
  ADDRESS_TRACE;
  if (!valid_flag || (ip_version != version_ipv6))
      return false;
  unsigned int *scope_ptr = (unsigned int*)(address_buffer + IP6LEN_NO_SCOPE);
  *scope_ptr = htonl(scope);  // Crashed !
  addr_changed = true;
  smival.value.string.len = IP6LEN_WITH_SCOPE;
  have_ipv6_scope = true;
  return true;
}

// ---------------------------------------------

How can I fix it?

2011-11-21 



Qiquan Bao



More information about the AGENTPP mailing list