X-Git-Url: https://git.saurik.com/apple/configd.git/blobdiff_plain/dbf6a266c384fc8b55e00a396eebe5cb62e21547..1e2cbe6aa7461cd7abf510b7c26db26974657962:/Plugins/KernelEventMonitor/ev_ipv6.c?ds=inline diff --git a/Plugins/KernelEventMonitor/ev_ipv6.c b/Plugins/KernelEventMonitor/ev_ipv6.c index 47705c4..abe37ff 100644 --- a/Plugins/KernelEventMonitor/ev_ipv6.c +++ b/Plugins/KernelEventMonitor/ev_ipv6.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2002-2007, 2011 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -35,18 +35,6 @@ #define s6_addr16 __u6_addr.__u6_addr16 -#ifndef kSCPropNetIPv6DestAddresses -#define kSCPropNetIPv6DestAddresses SCSTR("DestAddresses") -#endif - -#ifndef kSCPropNetIPv6Flags -#define kSCPropNetIPv6Flags SCSTR("Flags") -#endif - -#ifndef kSCPropNetIPv6PrefixLength -#define kSCPropNetIPv6PrefixLength SCSTR("PrefixLength") -#endif - #ifdef NOTYET #ifndef kSCPropNetIPv6ScopeID #define kSCPropNetIPv6ScopeID SCSTR("ScopeID") @@ -197,7 +185,7 @@ appendScopeID(CFMutableDictionaryRef dict, struct sockaddr_in6 *sin6) static CFMutableDictionaryRef -getIF(CFStringRef key, CFMutableDictionaryRef oldIFs, CFMutableDictionaryRef newIFs) +copyIF(CFStringRef key, CFMutableDictionaryRef oldIFs, CFMutableDictionaryRef newIFs) { CFDictionaryRef dict = NULL; CFMutableDictionaryRef newDict = NULL; @@ -248,6 +236,7 @@ updateStore(const void *key, const void *value, void *context) } else if (dict) { cache_SCDynamicStoreRemoveValue(store, key); } + network_changed = TRUE; } return; @@ -278,7 +267,7 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) &kCFTypeDictionaryValueCallBacks); if (!ifap) { - if (getifaddrs(&ifap_temp) < 0) { + if (getifaddrs(&ifap_temp) == -1) { SCLog(TRUE, LOG_ERR, CFSTR("getifaddrs() failed: %s"), strerror(errno)); goto error; } @@ -303,9 +292,9 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) } } - if (sock < 0) { + if (sock == -1) { sock = dgram_socket(AF_INET6); - if (sock < 0) { + if (sock == -1) { SCLog(TRUE, LOG_NOTICE, CFSTR("interface_update_ipv6: socket open failed, %s"), strerror(errno)); goto error; } @@ -319,12 +308,13 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) 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]; @@ -348,17 +338,20 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) #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) { 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]; @@ -387,7 +380,7 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) kSCEntNetIPv6); CFRelease(interface); - newDict = getIF(key, oldIFs, newIFs); + newDict = copyIF(key, oldIFs, newIFs); CFDictionarySetValue(newIFs, key, newDict); CFRelease(newDict); @@ -399,7 +392,7 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) error : if (ifap_temp) freeifaddrs(ifap_temp); - if (sock >= 0) close(sock); + if (sock != -1) close(sock); CFRelease(oldIFs); CFRelease(newIFs);