diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2004-04-09 13:25:23 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2004-04-09 13:25:23 +0000 |
commit | 641657c87b1285b2e428469540c9506e37c04eb6 (patch) | |
tree | 6e86edef934366055c430908b1e1ed779c102c9b /otherlibs/unix/gethost.c | |
parent | b9ba49e3101057a1197e5a3cad2ac66abdb0ed9b (diff) |
Support IPv6
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6193 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/unix/gethost.c')
-rw-r--r-- | otherlibs/unix/gethost.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/otherlibs/unix/gethost.c b/otherlibs/unix/gethost.c index 5b3252d59..3e3e5f971 100644 --- a/otherlibs/unix/gethost.c +++ b/otherlibs/unix/gethost.c @@ -43,8 +43,15 @@ extern int socket_domain_table[]; static value alloc_one_addr(char const *a) { struct in_addr addr; - memmove (&addr, a, entry_h_length); - return alloc_inet_addr(addr.s_addr); +#ifdef HAS_IPV6 + struct in6_addr addr6; + if (entry_h_length == 16) { + memmove(&addr6, a, 16); + return alloc_inet6_addr(&addr6); + } +#endif + memmove (&addr, a, 4); + return alloc_inet_addr(&addr); } static value alloc_host_entry(struct hostent *entry) @@ -75,7 +82,7 @@ static value alloc_host_entry(struct hostent *entry) CAMLprim value unix_gethostbyaddr(value a) { - uint32 adr = GET_INET_ADDR(a); + struct in_addr adr = GET_INET_ADDR(a); struct hostent * hp; #if HAS_GETHOSTBYADDR_R == 7 struct hostent h; |