Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

SOFIAPUBFUN int su_cmp_sockaddr ( su_sockaddr_t const *  a,
su_sockaddr_t const *  b 
)

Compare two socket addresses

Definition at line 545 of file su.c.

References su_cmp_sockaddr(), su_sockaddr_u::su_family, and su_sockaddr_u::su_sin.

Referenced by action_determine_nattype(), su_cmp_sockaddr(), and test_sockaddr().

{
  int rv;

  /* Check that a and b are non-NULL */
  if ((rv = (a != NULL) - (b != NULL)) || a == NULL /* && b == NULL */)
    return rv;

  if ((rv = a->su_family - b->su_family))
    return rv;

  if (a->su_family == AF_INET)
    rv = memcmp(&a->su_sin.sin_addr, &b->su_sin.sin_addr,
            sizeof(struct in_addr));
#if SU_HAVE_IN6
  else if (a->su_family == AF_INET6)
    rv = memcmp(&a->su_sin6.sin6_addr, &b->su_sin6.sin6_addr,
            sizeof(struct in6_addr));
#endif
  else
    rv = memcmp(a, b, sizeof(struct sockaddr));

  if (rv)
    return rv;

  return a->su_port - b->su_port;
}


Generated by  Doxygen 1.6.0   Back to index