[AGENT++] Questions Jochen Katz

Jochen Katz katz at agentpp.com
Tue Nov 22 21:21:01 CET 2011


Hi,

>> Is unsigned int a 64 bit value? Then replace scope and scope_ptr by
>> a 32bit type and tell me if this fixed it.

> Sorry, I omitted some information yesterday. This crash only occurs
> on solaris sparc(64bit) platform.     It works normal on solaris
> x86(64bit) platform.    Unsigned int is already 32bit but the size of
> the pointer is 64bit.        Following are the size of the basic
> types in the solaris sparc(64bit) system.                int : 32bit
> unsigned int : 32bit      long  : 64bit      unsigned long : 64bit
> short : 16bit      unsigned short : 16bit
> I have no idea how to fix it. Could you give me some advice ?

the pointer size should not matter, but if int is 32 bit I can only
think of an unaligned access. So I suggest the following (untested):

unsigned int IpAddress::get_scope() const
{
  ADDRESS_TRACE;
  if (!valid_flag)
    return (unsigned int)-1; // don't use uninitialized memory

  if ((ip_version != version_ipv6) || (!have_ipv6_scope))
    return (unsigned int)-1;

 unsigned int scope;
 memcpy(&scope, address_buffer + IP6LEN_NO_SCOPE, 4);
 return ntohl(scope);
}

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

Regards,
  Jochen



More information about the AGENTPP mailing list