#include "pcap-util.h"
#include "pcap-util-int.h"
-#ifndef WIN32
+#ifndef _WIN32
#include <netinet/in.h>
#endif
void
if_info_add_address(if_info_t *if_info, struct sockaddr *addr)
{
+ if_addr_t *ip_addr;
struct sockaddr_in *ai;
- guint32 *ip_addr;
+#ifdef INET6
+ struct sockaddr_in6 *ai6;
+#endif
switch (addr->sa_family) {
case AF_INET:
ai = (struct sockaddr_in *)addr;
ip_addr = g_malloc(sizeof(*ip_addr));
- *ip_addr = *((guint32 *)&(ai->sin_addr.s_addr));
+ ip_addr->type = AT_IPv4;
+ ip_addr->ip_addr.ip4_addr =
+ *((guint32 *)&(ai->sin_addr.s_addr));
+ if_info->ip_addr = g_slist_append(if_info->ip_addr, ip_addr);
+ break;
+
+#ifdef INET6
+ case AF_INET6:
+ ai6 = (struct sockaddr_in6 *)addr;
+ ip_addr = g_malloc(sizeof(*ip_addr));
+ ip_addr->type = AT_IPv6;
+ memcpy((void *)&ip_addr->ip_addr.ip6_addr,
+ (void *)&ai6->sin6_addr.s6_addr,
+ sizeof ip_addr->ip_addr.ip6_addr);
if_info->ip_addr = g_slist_append(if_info->ip_addr, ip_addr);
break;
+#endif
}
}
#ifdef HAVE_PCAP_FINDALLDEVS
/*
- * Get all IPv4 address information, and the loopback flag, for the given
+ * Get all IP address information, and the loopback flag, for the given
* interface.
*/
static void
static void
free_if_info_addr_cb(gpointer addr, gpointer user_data _U_)
{
- g_free(addr);
+ g_free(addr);
}
static void
if (if_info->description != NULL)
g_free(if_info->description);
- g_slist_foreach(if_info->ip_addr, free_if_info_addr_cb, NULL);
- g_slist_free(if_info->ip_addr);
+ g_slist_foreach(if_info->ip_addr, free_if_info_addr_cb, NULL);
+ g_slist_free(if_info->ip_addr);
}
void
/* Let them set it to the type it is; reject any other request. */
if (get_pcap_linktype(pch, devname) == dlt)
return NULL; /* no error */
- return "That DLT is not one of the DLTs supported by this device";
+ return "That DLT isn't one of the DLTs supported by this device";
#endif
}