apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apr/network_io/unix sa_common.c
Date Wed, 13 Dec 2000 22:30:22 GMT
trawick     00/12/13 14:30:22

  Modified:    .        CHANGES configure.in
               include  apr_network_io.h
               network_io/unix sa_common.c
  Log:
  Add apr_getnameinfo(), which uses getnameinfo() when APR_HAVE_IPV6 is
  defined.  APR_HAVE_IPV6 will only be defined if getnameinfo() is present.
  
  Still to do: Switch to this in Apache and axe apr_get_hostname().
  
  OS/2 and Win32 logic for reporting getaddrinfo() failures is from existing
  code.  The OS/2 code doesn't look right to me (need to add APR_OS_START_xyz?)
  I'm not sure what is needed for pre-BONE BeOS.
  
  Revision  Changes    Path
  1.21      +6 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- CHANGES	2000/12/12 14:47:35	1.20
  +++ CHANGES	2000/12/13 22:30:19	1.21
  @@ -1,3 +1,9 @@
  +Changes with APR b1
  +
  +  *) Add apr_getnameinfo(), a replacement for apr_get_hostname() which
  +     supports IPv6 and will be friendlier for use with eventual 
  +     SOCK_DGRAM support.  [Jeff Trawick]
  +
   Changes with APR a9
   
     *) Removed the iconv implementation from the i18n/unix/iconv branch.
  
  
  
  1.188     +8 -2      apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apr/configure.in,v
  retrieving revision 1.187
  retrieving revision 1.188
  diff -u -r1.187 -r1.188
  --- configure.in	2000/12/12 12:42:03	1.187
  +++ configure.in	2000/12/13 22:30:19	1.188
  @@ -758,7 +758,9 @@
   echo $ac_n "${nl}Checking for IPv6 Networking support...${nl}"
   dnl # Start of checking for IPv6 support...
   AC_SEARCH_LIBS(getaddrinfo, inet6)
  +AC_SEARCH_LIBS(getnameinfo, inet6)
   APR_CHECK_WORKING_GETADDRINFO
  +AC_CHECK_FUNCS(getnameinfo)
   AC_CHECK_FUNCS(getipnodebyname)
   AC_CHECK_FUNCS(getipnodebyaddr)
   APR_CHECK_SOCKADDR_IN6
  @@ -766,8 +768,12 @@
   have_ipv6="0"
   if test "x$have_sockaddr_in6" = "x1"; then
       if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
  -        have_ipv6="1"
  -        AC_MSG_RESULT("yes")
  +        if test "x$ac_cv_func_getnameinfo" = "xyes"; then
  +            have_ipv6="1"
  +            AC_MSG_RESULT("yes")
  +        else
  +            AC_MSG_RESULT("no -- no getnameinfo")
  +        fi
       else
           AC_MSG_RESULT("no -- no working getaddrinfo")
       fi
  
  
  
  1.89      +10 -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.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- apr_network_io.h	2000/12/07 18:10:25	1.88
  +++ apr_network_io.h	2000/12/13 22:30:21	1.89
  @@ -306,6 +306,16 @@
                                apr_pool_t *p);
   
   /**
  + * Look up the host name from an apr_sockaddr_t.
  + * @param hostname The hostname.
  + * @param sa The apr_sockaddr_t.
  + * @param flags Special processing flags.
  + */
  +apr_status_t apr_getnameinfo(char **hostname,
  +                             apr_sockaddr_t *sa,
  +                             apr_int32_t flags);
  +                             
  +/**
    * Parse hostname/IP address with scope id and port.
    *
    * Any of the following strings are accepted:
  
  
  
  1.19      +51 -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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- sa_common.c	2000/12/13 22:17:20	1.18
  +++ sa_common.c	2000/12/13 22:30:22	1.19
  @@ -385,6 +385,57 @@
       return APR_SUCCESS;
   }
   
  +apr_status_t apr_getnameinfo(char **hostname, apr_sockaddr_t *sockaddr, 
  +                             apr_int32_t flags)
  +{
  +#if defined(HAVE_GETNAMEINFO) && APR_HAVE_IPV6
  +    int rc;
  +#if defined(NI_MAXHOST)
  +    char tmphostname[NI_MAXHOST];
  +#else
  +    char tmphostname[256];
  +#endif
  +
  +    h_errno = 0; /* don't know if it is portable for getnameinfo() to set h_errno */
  +    rc = getnameinfo((const struct sockaddr *)&sockaddr->sa, sockaddr->salen,
  +                     tmphostname, sizeof(tmphostname), NULL, 0,
  +                     /* flags != 0 ? flags : */  NI_NAMEREQD);
  +    if (rc != 0) {
  +        *hostname = NULL;
  +        /* XXX I have no idea if this is okay.  I don't see any info
  +         * about getnameinfo() returning anything other than good or bad.
  +         */
  +        if (h_errno) {
  +            return h_errno + APR_OS_START_SYSERR;
  +        }
  +        else {
  +            return APR_NOTFOUND;
  +        }
  +    }
  +    *hostname = sockaddr->hostname = apr_pstrdup(sockaddr->pool, 
  +                                                 tmphostname);
  +    return APR_SUCCESS;
  +#else
  +    struct hostent *hptr;
  +
  +    hptr = gethostbyaddr((char *)&sockaddr->sa.sin.sin_addr, 
  +                         sizeof(struct in_addr), 
  +                         AF_INET);
  +    if (hptr) {
  +        *hostname = sockaddr->hostname = apr_pstrdup(sockaddr->pool, hptr->h_name);
  +        return APR_SUCCESS;
  +    }
  +    *hostname = NULL;
  +#if defined(WIN32)
  +    return apr_get_netos_error();
  +#elif defined(OS2)
  +    return h_errno;
  +#else
  +    return h_errno + APR_OS_START_SYSERR;
  +#endif
  +#endif
  +}
  +
   apr_status_t apr_getservbyname(apr_sockaddr_t *sockaddr, const char *servname)
   {
       struct servent *se;
  
  
  

Mime
View raw message