|
@ -300,46 +300,3 @@ validate_hostname(const char *hostname, const int hostname_len) |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
print_addrinfo(struct addrinfo *ai) |
|
|
|
|
|
{ |
|
|
|
|
|
char ipstr[INET6_ADDRSTRLEN]; |
|
|
|
|
|
unsigned short int port = 0; |
|
|
|
|
|
memset(ipstr, 0, INET6_ADDRSTRLEN); |
|
|
|
|
|
|
|
|
|
|
|
printf("addrinfo=>{"); |
|
|
|
|
|
printf("ai_flags="); |
|
|
|
|
|
switch (ai->ai_flags) { |
|
|
|
|
|
case AI_PASSIVE: printf("AI_PASSIVE"); break; |
|
|
|
|
|
case AI_CANONNAME: printf("AI_CANONNAME"); break; |
|
|
|
|
|
default: printf("ERROR(%d)", ai->ai_flags); |
|
|
|
|
|
} |
|
|
|
|
|
printf(", ai_family="); |
|
|
|
|
|
switch (ai->ai_family) { |
|
|
|
|
|
case AF_INET: |
|
|
|
|
|
dns_ntop(AF_INET, &(((struct sockaddr_in *)ai->ai_addr)->sin_addr), ipstr, INET_ADDRSTRLEN); |
|
|
|
|
|
port = htons(((struct sockaddr_in *)ai->ai_addr)->sin_port); |
|
|
|
|
|
printf("AF_INET"); |
|
|
|
|
|
break; |
|
|
|
|
|
case AF_INET6: |
|
|
|
|
|
dns_ntop(AF_INET6, &(((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr), ipstr, INET6_ADDRSTRLEN); |
|
|
|
|
|
port = htons(((struct sockaddr_in6 *)ai->ai_addr)->sin6_port); |
|
|
|
|
|
printf("AF_INET6"); |
|
|
|
|
|
break; |
|
|
|
|
|
case AF_UNSPEC: printf("AF_UNSPEC"); break; |
|
|
|
|
|
default: printf("ERROR(%d)", ai->ai_family); |
|
|
|
|
|
} |
|
|
|
|
|
printf(", ai_socktype="); |
|
|
|
|
|
switch (ai->ai_socktype) { |
|
|
|
|
|
case SOCK_STREAM: printf("SOCK_STREAM"); break; |
|
|
|
|
|
case SOCK_DGRAM: printf("SOCK_SGRAM"); break; |
|
|
|
|
|
default: printf("ERROR(%d)", ai->ai_socktype); |
|
|
|
|
|
} |
|
|
|
|
|
printf(", ai_protocol=%d", ai->ai_protocol); |
|
|
|
|
|
printf(", ai_addrlen=%d", ai->ai_addrlen); |
|
|
|
|
|
printf(", ai_addr=%s:%d", ipstr, port); |
|
|
|
|
|
printf(", ai_canonname=%s", ai->ai_canonname); |
|
|
|
|
|
printf(", ai_next=%p", ai->ai_next); |
|
|
|
|
|
printf("}\n"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|