diff options
author | Gerald Combs <gerald@wireshark.org> | 2007-06-11 18:26:09 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2007-06-11 18:26:09 +0000 |
commit | f60e81aaac118e5b3e71c62a77bff911087b0915 (patch) | |
tree | b753a8a627171614f46ecf5b8cba48cd34d5ceea /capture.c | |
parent | 68cdbd4e65f32e498f92cf90df5a2bad69295ae3 (diff) |
Fix compilation under VS6 (hopefully without breaking compilation
anywhere else). Instead of using getaddrinfo() and getnameinfo(),
promote inet_pton.c and inet_ntop.c to the top level and use those
routines instead.
(It's 2007, for crying out loud. Why is this even an issue?)
svn path=/trunk/; revision=22075
Diffstat (limited to 'capture.c')
-rw-r--r-- | capture.c | 50 |
1 files changed, 25 insertions, 25 deletions
@@ -48,8 +48,20 @@ #include <sys/socket.h> #endif -#ifdef HAVE_NETDB_H -#include <netdb.h> +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> /* needed to define AF_ values on UNIX */ +#endif + +#ifdef HAVE_WINSOCK2_H +#include <winsock2.h> /* needed to define AF_ values on Windows */ +#endif + +#ifdef NEED_INET_V6DEFS_H +# include "inet_v6defs.h" #endif #include <signal.h> @@ -594,9 +606,6 @@ capture_interface_list(int *err, char **err_str) gchar *name; if_info_t *if_info; if_addr_t *if_addr; - struct addrinfo *ai; - struct sockaddr_in *sa4; - struct sockaddr_in6 *sa6; g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List ..."); @@ -642,27 +651,18 @@ capture_interface_list(int *err, char **err_str) if_info->description = g_strdup(if_parts[1]); addr_parts = g_strsplit(if_parts[2], ",", 0); for (j = 0; addr_parts[j] != NULL; j++) { - /* XXX - We're failing to convert IPv6 addresses (on Ubuntu, at least) */ - if (getaddrinfo(addr_parts[j], NULL, NULL, &ai) == 0) { + if_addr = g_malloc0(sizeof(if_addr_t)); + if (inet_pton(AF_INET, addr_parts[j], &if_addr->ip_addr.ip4_addr)) { + if_addr->type = AT_IPv4; + } else if (inet_pton(AF_INET6, addr_parts[j], + &if_addr->ip_addr.ip6_addr)) { + if_addr->type = AT_IPv6; + } else { + g_free(if_addr); if_addr = NULL; - switch (ai->ai_family) { - case AF_INET: - if_addr = g_malloc0(sizeof(if_addr_t)); - if_addr->type = AT_IPv4; - sa4 = (struct sockaddr_in *) ai->ai_addr; - if_addr->ip_addr.ip4_addr = sa4->sin_addr.s_addr; - break; - case AF_INET6: - if_addr = g_malloc0(sizeof(if_addr_t)); - if_addr->type = AT_IPv6; - sa6 = (struct sockaddr_in6 *) ai->ai_addr; - memcpy(&if_addr->ip_addr.ip6_addr, sa6->sin6_addr.s6_addr, 16); - break; - } - if (if_addr) { - if_info->ip_addr = g_slist_append(if_info->ip_addr, if_addr); - } - freeaddrinfo(ai); + } + if (if_addr) { + if_info->ip_addr = g_slist_append(if_info->ip_addr, if_addr); } } if (strcmp(if_parts[3], "loopback") == 0) |