On 01/08/2013 23:33, Hiroki Sato wrote:
Ulrich Spörlein <u...@freebsd.org> wrote
in <20130108184051.gi35...@acme.spoerlein.net>:
uq> After setting this, it now looks like this:
uq> root@acme: ~# ip6addrctl
uq> Prefix Prec Label Use
uq> ::1/128 50 0 0
uq> ::/0 40 1 0
uq> 2002::/16 30 2 0
uq> ::/96 20 3 0
uq> ::ffff:0.0.0.0/96 10 4 0
uq>
uq> And even sendmail is happily finding the sockets to bind to. Thanks for the
hint!
I think this just hides the problem. If gshapiro@'s explanation is
correct, no ::ffff:0.0.0.0/96 address should be returned if the name
resolution works fine...
-- Hiroki
getipnodebyname(xx, AF_INET6, AI_DEFAULT|AI_ALL) does this:-
If a host has both IPv6 and IPv4 addresses, both are returned.
The IPv4 address is presented as a mapped address.
The order in which the addresses are returns depends on the
address selection policy (_hpreorder in lib/libc/net/name6.c)
#include <netinet/in.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
static void resolve(const char *);
int main(int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++) {
resolve(argv[i]);
}
return 0;
}
static void resolve(const char *hostname)
{
struct hostent *h;
char **a;
int i;
int e = 0;
h = getipnodebyname(hostname, AF_INET6, AI_DEFAULT|AI_ALL, &e);
if (!h) {
return;
}
printf("h_name: %s\n", h->h_name);
for (a = h->h_aliases; *a; a++) {
printf(" alias: %s\n", *a);
}
printf("h_addrtype: %d\n", h->h_addrtype);
printf("h_length: %d\n", h->h_length);
for (a = h->h_addr_list; *a; a++) {
printf("h_length: %d\n", h->h_length);
printf(" address: 0x");
for (i = 0; i < h->h_length; i++) {
printf("%02x", (unsigned char)(*a)[i]);
}
printf("\n");
}
}
prefer_ipv4:
$ ./a.out youtube.com
h_name: youtube.com
h_addrtype: 28
h_length: 16
h_length: 16
address: 0x00000000000000000000ffffadc241be
h_length: 16
address: 0x00000000000000000000ffffadc2415b
h_length: 16
address: 0x00000000000000000000ffffadc2415d
h_length: 16
address: 0x00000000000000000000ffffadc24188
h_length: 16
address: 0x2a00145040130c00000000000000005b
prefer_ipv6:
$ ./a.out youtube.com
h_name: youtube.com
h_addrtype: 28
h_length: 16
h_length: 16
address: 0x2a00145040130c00000000000000005b
h_length: 16
address: 0x00000000000000000000ffffadc2415b
h_length: 16
address: 0x00000000000000000000ffffadc2415d
h_length: 16
address: 0x00000000000000000000ffffadc24188
h_length: 16
address: 0x00000000000000000000ffffadc241be
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"