概述
ipv6地址处理
代码的一部分::::
char host[NI_MAXHOST];
if(family == AF_INET6)
{
if(strcmp(ifa->ifa_name, eth) == 0)
{
s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
if (s != 0)
{
printf("getnameinfo() failed: %sn", gai_strerror(s));
exit(EXIT_FAILURE);
}
printf("%sn", host);
/* 结果是 fe80::20c:29ff:fe6b:2516%eth0 */
/**************************************
gdb 跟踪是-------------------:
(gdb) p host
$1="fe80::20c:29ff:fe6b:2516%eth0 00 00 00a 00 00 00 00 00 00 00260354260367377177 00 00(345377367377177 00 00340 71336367377177 00 00X246377367377177 00 00 01331336367377177 00 00 00 00 00 00377177 00 00 00 00 00 00 00 00 00 00b350377377377177 00 00X263377367377177 00 00 00 00 00 00 00 00 00 00 02", '