On Thu, Mar 17, 2005 at 09:39:57PM -0500, Edward Rudd wrote:
> Why is the family set to APR_INET6 for an IPV4 incoming connection, and is
> there a way for me to *truly* figure out how the connection really came in
> originally.

whenOn Linux, the default is to use IPv4 mapped IPv6 addresses, see the
recently released RFC4038 for more details, but in summary; Apache binds
to :: and IPv4 packets are accepted on this socket - they get addresses
that look like; ::ffff:192.0.2.0, APR generally hides this as much as it
can, but the family will be set to APR_INET6 because after all - it is
an IPv6 socket.

A block like:

#if APR_HAVE_IPV6
    if (sockaddr->family == AF_INET6 &&
        IN6_IS_ADDR_V4MAPPED((struct in6_addr *)sockaddr->ipaddr_ptr)) {
                /* Address is IPv4-mapped-IPv6 */
    }
#endif      

... will let you determine it's mapped nature. But it might be easier
to bind to the local sockaddr from the existing connected socket, it
should also be mapped, and even if you bind to say ::ffff:192.0.2.1
with family = INET6 the OS will translate that into a plain old
IPv4 bind on 192.0.2.1.

-- 
Colm MacC�rthaigh                        Public Key: [EMAIL PROTECTED]

Reply via email to