/*
- * Copyright (c) 2002-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2002-2007, 2011, 2013 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static CFMutableDictionaryRef
-getIF(CFStringRef key, CFMutableDictionaryRef oldIFs, CFMutableDictionaryRef newIFs)
+copyIF(CFStringRef key, CFMutableDictionaryRef oldIFs, CFMutableDictionaryRef newIFs)
{
CFDictionaryRef dict = NULL;
CFMutableDictionaryRef newDict = NULL;
kSCEntNetIPv6);
CFRelease(interface);
- newDict = getIF(key, oldIFs, newIFs);
+ newDict = copyIF(key, oldIFs, newIFs);
- sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
+ /* ALIGN: ifa->ifa_addr aligned (getifaddrs), cast ok. */
+ sin6 = (struct sockaddr_in6 *)(void *)ifa->ifa_addr;
/* XXX: embedded link local addr check */
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr)) {
u_int16_t index;
index = sin6->sin6_addr.s6_addr16[1];
#ifdef NOTYET
appendScopeID (newDict, sin6);
#endif /* NOTYET */
- appendPrefixLen(newDict, (struct sockaddr_in6 *)ifa->ifa_netmask);
+ /* ALIGN: ifa should be aligned (from getifaddrs), cast ok.
+ * appendPrefixLen expect byte alignment */
+ appendPrefixLen(newDict, (struct sockaddr_in6 *)(void *)ifa->ifa_netmask);
appendFlags (newDict, flags6);
- if (ifa->ifa_flags & IFF_POINTOPOINT) {
+ if (ifa->ifa_flags & IFF_POINTOPOINT
+ && ifa->ifa_dstaddr != NULL) {
struct sockaddr_in6 *dst6;
- dst6 = (struct sockaddr_in6 *)ifa->ifa_dstaddr;
+ /* ALIGN: ifa should be aligned (from getifaddrs), cast ok. */
+ dst6 = (struct sockaddr_in6 *)(void *)ifa->ifa_dstaddr;
/* XXX: embedded link local addr check */
- if (IN6_IS_ADDR_LINKLOCAL(&dst6->sin6_addr)) {
+ if (IN6_IS_ADDR_LINKLOCAL(&dst6->sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL(&dst6->sin6_addr)) {
u_int16_t index;
index = dst6->sin6_addr.s6_addr16[1];
kSCEntNetIPv6);
CFRelease(interface);
- newDict = getIF(key, oldIFs, newIFs);
+ newDict = copyIF(key, oldIFs, newIFs);
CFDictionarySetValue(newIFs, key, newDict);
CFRelease(newDict);