aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-util.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-07-18 19:44:41 +0000
committerGuy Harris <guy@alum.mit.edu>2004-07-18 19:44:41 +0000
commit1eed77c0a4e539bd3085df837c3193e540aa2dc3 (patch)
tree7019b0211da9d7d5af18a25cff7305c479b7409f /pcap-util.c
parent892091fe9583841a5064e830e5ae5ce3c91fe02d (diff)
downloadwireshark-1eed77c0a4e539bd3085df837c3193e540aa2dc3.tar.gz
wireshark-1eed77c0a4e539bd3085df837c3193e540aa2dc3.tar.bz2
wireshark-1eed77c0a4e539bd3085df837c3193e540aa2dc3.zip
Just because AF_INET6 is defined, that doesn't mean "struct
sockaddr_in6" is defined - the former, but not the latter, is defined in FreeBSD 3.4. Just copy the appropriate number of bytes from the "sa_data" field of a "struct sockaddr". svn path=/trunk/; revision=11413
Diffstat (limited to 'pcap-util.c')
-rw-r--r--pcap-util.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/pcap-util.c b/pcap-util.c
index c0b92c91c4..6f3a7e6fe2 100644
--- a/pcap-util.c
+++ b/pcap-util.c
@@ -198,30 +198,23 @@ void
if_info_add_address(if_info_t *if_info, struct sockaddr *addr)
{
if_addr_t *ip_addr;
- struct sockaddr_in *ai;
-#ifdef AF_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;
- ip_addr->ip_addr.ip4_addr =
- *((guint32 *)&(ai->sin_addr.s_addr));
+ memcpy((void *)&ip_addr->ip_addr.ip4_addr,
+ (void *)&addr->sa_data, 4);
if_info->ip_addr = g_slist_append(if_info->ip_addr, ip_addr);
break;
#ifdef AF_INET6
case AF_INET6:
- ai6 = (struct sockaddr_in6 *)addr;
ip_addr = g_malloc(sizeof(*ip_addr));
ip_addr->family = FAM_IPv6;
memcpy((void *)&ip_addr->ip_addr.ip6_addr,
- (void *)&ai6->sin6_addr.s6_addr,
- sizeof ip_addr->ip_addr.ip6_addr);
+ (void *)&addr->sa_data, 16);
if_info->ip_addr = g_slist_append(if_info->ip_addr, ip_addr);
break;
#endif