__private_extern__
void
interface_update_idle_state(const char *if_name)
{
	CFStringRef		if_name_cf;
	CFStringRef		key;
	int			ref;

	/* We will only update the SCDynamicStore if the idle ref count
	 * is still 0 */
	ref = socket_reference_count(if_name);
	if (ref != 0) {
		return;
	}

	if_name_cf = CFStringCreateWithCString(NULL, if_name,
					       kCFStringEncodingASCII);

	key = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL,
							    kSCDynamicStoreDomainState,
							    if_name_cf,
							    kSCEntNetIdleRoute);

	cache_SCDynamicStoreNotifyValue(store, key);
	CFRelease(key);
	CFRelease(if_name_cf);
	return;
}
Beispiel #2
0
__private_extern__
void
ipv6_duplicated_address(const char * if_name, const struct in6_addr * addr,
			int hw_len, const void * hw_addr)
{
	uint8_t	*		hw_addr_bytes = (uint8_t *)hw_addr;
	int			i;
	CFStringRef		if_name_cf;
	CFMutableStringRef	key;
	char			ntopbuf[INET6_ADDRSTRLEN];
	CFStringRef		prefix;

	if_name_cf = CFStringCreateWithCString(NULL, if_name,
					       kCFStringEncodingASCII);
	prefix = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL,
							       kSCDynamicStoreDomainState,
							       if_name_cf,
							       kSCEntNetIPv6DuplicatedAddress);
	ntopbuf[0] = '\0';
	(void)inet_ntop(AF_INET6, addr, ntopbuf, sizeof(ntopbuf));
	key = CFStringCreateMutableCopy(NULL, 0, prefix);
	CFStringAppendFormat(key, NULL, CFSTR("/%s"), ntopbuf);
	for (i = 0; i < hw_len; i++) {
	    CFStringAppendFormat(key, NULL, CFSTR("%s%02x"),
				 (i == 0) ? "/" : ":", hw_addr_bytes[i]);
	}
	cache_SCDynamicStoreNotifyValue(store, key);
	CFRelease(key);
	CFRelease(prefix);
	CFRelease(if_name_cf);
}