apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/network_io/unix sa_common.c
Date Wed, 26 Dec 2001 21:18:26 GMT
trawick     01/12/26 13:18:26

  Modified:    .        CHANGES
               include  apr_network_io.h
               network_io/unix sa_common.c
  Log:
  Add apr_sockaddr_equal() for comparing APR sockaddrs.
  This handles v4-mapped IPv6 addresses.
  
  Revision  Changes    Path
  1.199     +4 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.198
  retrieving revision 1.199
  diff -u -r1.198 -r1.199
  --- CHANGES	2001/12/20 20:22:19	1.198
  +++ CHANGES	2001/12/26 21:18:26	1.199
  @@ -1,4 +1,8 @@
   Changes with APR b1  
  +
  +  *) Add apr_sockaddr_equal() for comparing APR sockaddrs.
  +     [Jeff Trawick]
  +
     *) Win32: apr_sendfile() should return APR_ENOTIMPL if
        oslevel < WINNT. [Bill Stoddard]
   
  
  
  
  1.114     +13 -0     apr/include/apr_network_io.h
  
  Index: apr_network_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_network_io.h,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- apr_network_io.h	2001/11/20 19:00:39	1.113
  +++ apr_network_io.h	2001/12/26 21:18:26	1.114
  @@ -631,6 +631,19 @@
                                            apr_sockaddr_t *sockaddr);
   
   /**
  + * See if the IP addresses in two APR socket addresses are
  + * equivalent.  Appropriate logic is present for comparing
  + * IPv4-mapped IPv6 addresses with IPv4 addresses.
  + *
  + * @param addr1 One of the APR socket addresses.
  + * @param addr2 The other APR socket address.
  + * @remark The return value will be non-zero if the addresses
  + * are equivalent.
  + */
  +APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1,
  +                                    const apr_sockaddr_t *addr2);
  +
  +/**
    * Setup the memory required for poll to operate properly
    * @param new_poll The poll structure to be used. 
    * @param num The number of socket descriptors to be polled.
  
  
  
  1.47      +26 -0     apr/network_io/unix/sa_common.c
  
  Index: sa_common.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sa_common.c,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- sa_common.c	2001/12/25 12:26:26	1.46
  +++ sa_common.c	2001/12/26 21:18:26	1.47
  @@ -606,6 +606,32 @@
       return errno;
   }
   
  +#define V4MAPPED_EQUAL(a,b)                                   \
  +((a)->sa.sin.sin_family == AF_INET &&                         \
  + (b)->sa.sin.sin_family == AF_INET6 &&                        \
  + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)(b)->ipaddr_ptr) &&  \
  + !memcmp((a)->ipaddr_ptr,                                     \
  +         &((struct in6_addr *)(b)->ipaddr_ptr)->s6_addr[12],  \
  +         (a)->ipaddr_len))
  +
  +APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1,
  +                                    const apr_sockaddr_t *addr2)
  +{
  +    if (addr1->ipaddr_len == addr2->ipaddr_len &&
  +        !memcmp(addr1->ipaddr_ptr, addr2->ipaddr_ptr, addr1->ipaddr_len)) {
  +        return 1;
  +    }
  +#if APR_HAVE_IPV6
  +    if (V4MAPPED_EQUAL(addr1, addr2)) {
  +        return 1;
  +    }
  +    if (V4MAPPED_EQUAL(addr2, addr1)) {
  +        return 1;
  +    }
  +#endif
  +    return 0; /* not equal */
  +}
  +
   static apr_status_t parse_network(apr_ipsubnet_t *ipsub, const char *network)
   {
       /* legacy syntax for ip addrs: a.b.c. ==> a.b.c.0/24 for example */
  
  
  

Mime
View raw message