Here are some idioms I see in other IPv6-enabled code which I think
should be supported in APR.  Part of this has a bearing on my comments
to you post below. 

  1) stream socket server

     a. (normal) get me a darn socket, I don't care which kind

        API:     apr_create_socket(, AF_UNSPEC, SOCK_STREAM, ...)

                 (AF_UNSPEC could be anything to tell APR we don't
                 care what kind of socket)
                                        
        APR gets AF_INET6 if possible, falls back to AF_INET

     b. hmmm... user told me to bind to a certain local interface 
        address... I need to resolve the address (could be hostname
        or numeric address string -- I shouldn't have to care) then
        get the right kind of socket

        API:     apr_gethostbyname(&sa, hostname-or-nas, AF_UNSPEC, flags) 
                 set-port-in-sockaddr
                 apr_create_socket(&sock, 
                                   whatever-family-chosen-in-apr_gethostbyname, 
                                   SOCK_STREAM, ...)
                 apr_bind(sock, sa)

  2) stream socket client:

     a. (normal) user gave me a client hostname (or numeric address
        string -- I shouldn't have to care)...  I need to resolve the
        address then get the right kind of socket

        API:     apr_gethostbyname(&sa, hostname-or-nas, AF_UNSPEC,
                                   flags)
                 set-port-in-sockaddr
                 apr_create_socket(&sock, 
                                   whatever-family-chosen-in-apr_gethostbyname, 
                                   SOCK_STREAM, ...)
                 apr_connect(sock, sa)

     b. same as 2a, but user told me to use a certain address family
        (e.g., via "-4" or "-6" command-line parameter); this is
        needed when IPv4 and IPv6 network connectivity is different...
        you want to talk to host xyz with both types of addresses, but
        6bone is down at the moment so you need to force IPv4

        API:     same as 2a, except you pass AF_INET or AF_INET6
                 instead of AF_UNSPEC to apr_gethostbyname()

"David Reid" <[EMAIL PROTECTED]> writes:

> 1.  Modify connect to take an apr_sockaddr_t instead of a hostname...  This
> is a simple change so I'll make it sooner rather than later.

yes...

> ??? Do we change apr_gethostbyname to return an apr_sockaddr_t?

yes...

> This would then give
>     apr_sockaddr_t *sa;
>     apr_gethostbyname(&sa, "hostname", pool);
>     apr_connect(sock, sa);

We need to add more arguments: address family for sure and possibly
flags.  Look at getaddrinfo().  And do we want to add an optional
service name/port number parameter?  That would build the complete
sockaddr for us.

> 2. Are we agreed on Jeff's suggestions of
> Add apr_pool_t * to apr_sockaddr_t.
> apr_status_t apr_get_address(char **hostname, apr_interface_e which,
> apr_socket_t *sock);
> apr_status_t apr_get_nas(char **addr, apr_sockaddr_t *sa);
> These are new additions sos houldn't interfere with any existing
> code.

I am.

In addition to the changes you mentioned, I see apr_create_socket() as
extremely important in the short run and I think we should think about
apr_bind() working like apr_connect() (in other words, taking an
apr_sockaddr_t).  That makes sense when the user has told us the local
interface address and we have to resolve it anyway.  We have to keep
it from being painful when we just have the port number.

> 3. Before we can take this further, I guess we need to add the following
> though...

I'll let others comment on this stuff.  I'm much more concerned about
getting enough IPv6 enabled in APR so we can test it properly.  Apache
needs can come a little later (for me, at least).

-- 
Jeff Trawick | [EMAIL PROTECTED] | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Reply via email to