> From: Doug Hardie <bc...@lafn.org> > Date: Thu, 12 Jul 2012 14:21:38 -0700 > Subject: Re: IPv6 && getaddrinfo(3C) > > On 12 July 2012, at 07:24, Matthias Apitz wrote: > > > Hello, > > > > I'm playing around with IPv6 code on a FreeBSD 9 system and can't get > > getaddrinfo(3C) to do what it should do as stated in its man page: > > accept an IPv6 and IPv4 IP addr, it only works with the IPv6 form: > > > > $ ./a.out ::1 > > host: ::1 read: SSH-2.0-OpenSSH_5.6p1 FreeBSD-20101111 > > $ ./a.out 127.0.0.1 > > host: 127.0.0.1 ssh: getaddrinfo failed code 8: hostname nor servname > > provided, or not known > > $ telnet 127.0.0.1 22 > > Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. > > SSH-2.0-OpenSSH_5.6p1 FreeBSD-20101111 > > > > the used C-code is attached below; what I'm doing wrong in the code? > > > > Thanks > > > > matthias > > > > /* IPv6 client code using getaddrinfo */ > > > > #include <stdlib.h> > > #include <sys/types.h> > > #include <sys/socket.h> > > #include <netinet/in.h> > > #include <stdio.h> > > #include <netdb.h> > > #include <string.h> > > > > > > main(argc, argv) /* client side */ > > int argc; char *argv[]; > > { > > > > struct addrinfo req, *ans; int code, s, n; char buf[1024]; > > > > memset(&req, 0, sizeof(req)); > > req.ai_flags = AI_ADDRCONFIG|AI_NUMERICHOST; > > req.ai_family = AF_INET6; /* Same as AF_INET6. */
Isn't the setting of 'req.ai_family', above, going to guarantee that something that "looks like" an IPv4 address will not be considered valid? After all, what *POSSIBLE* _IPv6_info_ is there about an IPv4 address? Per the manpage example, try PF_UNSPEC. _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"