On Tue, 15 Jan 2002, Hrvoje Niksic wrote:

> > 1. Now if IPv6 enabled it only fetch IPv6 IPv4 sites faile
>
> This is a problem, and part of the reason why the patch is so simple in its
> current form.

It is indeed. If done correctly, using the proper API, there won't be any
difference between IPv6 and IPv4 host names. AFAIK, getaddrinfo() is
preferred over gethostbyname2().

> A correct patch must modify struct address_list to hold a list of IP
> addresses, each of which can be either an IPv4 address or an IPv6 address.
> It could be something like:
>
> struct ip_address {
>   enum { ADDR_IPV4, ADDR_IPV6 } type;
>   union {
>     ipv4_address ipv4;
>     ipv6_address ipv6;
>   } addr;
> };

I'd suggest that you instead pass around a 'struct hostent *' on IPv4 only
platforms, and on IPv6-enabled you pass around the 'addrinfo *' as returned
by the getaddrinfo() call.

Both pointers would contain a list of IP addresses. The hostent struct
pointer in the good old ugly style in the h_addr_list[] array, and the
addrinfo in the POSIX defined linked-list way.

When I modified (lib)curl over to this approach, many things became easier.

> with the appropriate #ifdefs for when IPv6 is not available. ipv6_address
> might also need to contain the "scope" information.  (I don't know what
> that is, but I trust that you do.  I've been told that IPv6 addresses were
> "scoped".)

IPv6 addresses are scoped, but that is nothing you have to care about as mere
application writer (unless you really want to of course). If you just keep
the list of addresses in the addrinfo struct and you try all them when you
connect, then it'll work transparantly.

> Also, you should get rid of the global variable named as vaguely as
> `family'.  Also, for FTP we need to support the extended IPv6 commands.

... actually, the "extended IPv6 commands" are not IPv6-specific but work
just as good on IPv4-systems. If the server have them implemented that is.

--
      Daniel Stenberg - http://daniel.haxx.se - +46-705-44 31 77
   ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol

Reply via email to