"ssn_range" needs to be a copy of "global_ssn_range", so that it's not
[obnox/wireshark/wip.git] / pcap-util.c
index 6f3a7e6fe2484a07d7bd3daf88063768b6bf4ad8..f2cb31cac6694475938bf6c3cd65bf524fbc1ffd 100644 (file)
@@ -50,7 +50,7 @@
 #include "pcap-util.h"
 #include "pcap-util-int.h"
 
-#ifndef WIN32
+#ifndef _WIN32
 #include <netinet/in.h>
 #endif
 
@@ -198,23 +198,30 @@ void
 if_info_add_address(if_info_t *if_info, struct sockaddr *addr)
 {
        if_addr_t *ip_addr;
+       struct sockaddr_in *ai;
+#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->family = FAM_IPv4;
-               memcpy((void *)&ip_addr->ip_addr.ip4_addr,
-                   (void *)&addr->sa_data, 4);
+               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 AF_INET6
+#ifdef INET6
        case AF_INET6:
+               ai6 = (struct sockaddr_in6 *)addr;
                ip_addr = g_malloc(sizeof(*ip_addr));
-               ip_addr->family = FAM_IPv6;
+               ip_addr->type = AT_IPv6;
                memcpy((void *)&ip_addr->ip_addr.ip6_addr,
-                   (void *)&addr->sa_data, 16);
+                   (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