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
This commit is contained in:
parent
892091fe95
commit
1eed77c0a4
1 changed files with 3 additions and 10 deletions
13
pcap-util.c
13
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
|
||||
|
|
Loading…
Reference in a new issue