Add support for DUA dissection. Now all SIGTRAN protocols are supported...
[obnox/wireshark/wip.git] / pcap-util.c
index a1e9feb8cfe3cde629fc8569ff8f80bcf813b819..38565f4e8767310946793d0d907636e447caa199 100644 (file)
@@ -50,7 +50,7 @@
 #include "pcap-util.h"
 #include "pcap-util-int.h"
 
-#ifndef WIN32
+#ifndef _WIN32
 #include <netinet/in.h>
 #endif
 
@@ -197,23 +197,40 @@ if_info_new(char *name, char *description)
 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
@@ -265,7 +282,7 @@ get_interface_list_findalldevs(int *err, char *err_str)
 static void
 free_if_info_addr_cb(gpointer addr, gpointer user_data _U_)
 {
-    g_free(addr);
+       g_free(addr);
 }
 
 static void
@@ -277,8 +294,8 @@ free_if_cb(gpointer data, gpointer user_data _U_)
        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
@@ -409,7 +426,7 @@ set_pcap_linktype(pcap_t *pch, char *devname
        /* 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
 }