Browse Source

Fix #912

pull/925/head
Max Lv 8 years ago
parent
commit
6d57b3cb56
2 changed files with 0 additions and 47 deletions
  1. 43
      src/netutils.c
  2. 4
      src/netutils.h

43
src/netutils.c

@ -300,46 +300,3 @@ validate_hostname(const char *hostname, const int hostname_len)
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");
}

4
src/netutils.h

@ -27,8 +27,6 @@
#include <netdb.h>
#elif !defined(__MINGW32__)
#include <netinet/tcp.h>
#else
#include "win32.h"
#endif
// only enable TCP_FASTOPEN on linux
@ -95,6 +93,4 @@ int sockaddr_cmp_addr(struct sockaddr_storage *addr1,
int validate_hostname(const char *hostname, const int hostname_len);
void print_addrinfo(struct addrinfo *ai);
#endif
Loading…
Cancel
Save