Boolean SCBondInterfaceSetMode(SCBondInterfaceRef bond, CFNumberRef mode) { int mode_num; if (!isA_SCBondInterface(bond) || !isA_CFNumber(mode)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } if (CFNumberGetValue(mode, kCFNumberIntType, &mode_num) == FALSE) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } switch (mode_num) { case IF_BOND_MODE_LACP: case IF_BOND_MODE_STATIC: break; default: _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } return (_SCBondInterfaceSetMode(bond, mode)); }
SCNetworkSetRef SCNetworkSetCopy(SCPreferencesRef prefs, CFStringRef setID) { CFDictionaryRef entity; CFStringRef path; SCNetworkSetPrivateRef setPrivate; if (!isA_CFString(setID)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } path = SCPreferencesPathKeyCreateSet(NULL, setID); entity = SCPreferencesPathGetValue(prefs, path); CFRelease(path); if (!isA_CFDictionary(entity)) { _SCErrorSet(kSCStatusNoKey); return NULL; } setPrivate = __SCNetworkSetCreatePrivate(NULL, prefs, setID); assert(setPrivate != NULL); // mark set as "old" (already established) setPrivate->established = TRUE; return (SCNetworkSetRef)setPrivate; }
Boolean SCVLANInterfaceRemove(SCVLANInterfaceRef vlan) { CFStringRef vlan_if; SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)vlan; Boolean ok; CFStringRef path; if (!isA_SCVLANInterface(vlan)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } if (interfacePrivate->prefs == NULL) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } vlan_if = SCNetworkInterfaceGetBSDName(vlan); path = CFStringCreateWithFormat(NULL, NULL, CFSTR("/%@/%@/%@"), kSCPrefVirtualNetworkInterfaces, kSCNetworkInterfaceTypeVLAN, vlan_if); ok = SCPreferencesPathRemoveValue(interfacePrivate->prefs, path); CFRelease(path); return ok; }
Boolean SCDynamicStoreAddWatchedKey(SCDynamicStoreRef store, CFStringRef key, Boolean isRegex) { SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; kern_return_t status; CFDataRef utfKey; /* serialized key */ xmlData_t myKeyRef; CFIndex myKeyLen; int sc_status; if (store == NULL) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoStoreSession); return FALSE; } if (storePrivate->server == MACH_PORT_NULL) { /* sorry, you must have an open session to play */ _SCErrorSet(kSCStatusNoStoreServer); return FALSE; } /* serialize the key */ if (!_SCSerializeString(key, &utfKey, (void **)&myKeyRef, &myKeyLen)) { _SCErrorSet(kSCStatusFailed); return FALSE; } retry : /* send the key to the server */ status = notifyadd(storePrivate->server, myKeyRef, myKeyLen, isRegex, (int *)&sc_status); if (__SCDynamicStoreCheckRetryAndHandleError(store, status, &sc_status, "SCDynamicStoreAddWatchedKey notifyadd()")) { goto retry; } /* clean up */ CFRelease(utfKey); if (sc_status != kSCStatusOK) { _SCErrorSet(sc_status); return FALSE; } if (isRegex) { addKey(&storePrivate->patterns, key); } else { addKey(&storePrivate->keys, key); } return TRUE; }
Boolean SCDynamicStoreRemoveValue(SCDynamicStoreRef store, CFStringRef key) { SCDynamicStorePrivateRef storePrivate; kern_return_t status; CFDataRef utfKey; /* serialized key */ xmlData_t myKeyRef; CFIndex myKeyLen; int sc_status; if (store == NULL) { store = __SCDynamicStoreNullSession(); if (store == NULL) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoStoreSession); return FALSE; } } storePrivate = (SCDynamicStorePrivateRef)store; if (storePrivate->server == MACH_PORT_NULL) { /* sorry, you must have an open session to play */ _SCErrorSet(kSCStatusNoStoreServer); return FALSE; } /* serialize the key */ if (!_SCSerializeString(key, &utfKey, (void **)&myKeyRef, &myKeyLen)) { _SCErrorSet(kSCStatusFailed); return FALSE; } retry : /* send the key to the server */ status = configremove(storePrivate->server, myKeyRef, myKeyLen, (int *)&sc_status); if (__SCDynamicStoreCheckRetryAndHandleError(store, status, &sc_status, "SCDynamicStoreRemoveValue configremove()")) { goto retry; } /* clean up */ CFRelease(utfKey); if (sc_status != kSCStatusOK) { _SCErrorSet(sc_status); return FALSE; } return TRUE; }
Boolean SCNetworkSetRemoveService(SCNetworkSetRef set, SCNetworkServiceRef service) { SCNetworkInterfaceRef interface; CFArrayRef interface_config = NULL; Boolean ok; CFStringRef path; int sc_status = kSCStatusOK; SCNetworkServicePrivateRef servicePrivate = (SCNetworkServicePrivateRef)service; SCNetworkSetPrivateRef setPrivate = (SCNetworkSetPrivateRef)set; if (!isA_SCNetworkSet(set)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } if (!isA_SCNetworkService(service) || (servicePrivate->prefs == NULL)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } // remove service from ServiceOrder _serviceOrder_remove(set, service); // get the [deep] interface configuration settings interface = SCNetworkServiceGetInterface(service); if (interface != NULL) { interface_config = __SCNetworkInterfaceCopyDeepConfiguration(set, interface); if (interface_config != NULL) { // remove the interface configuration from all sets which contain this service. __SCNetworkInterfaceSetDeepConfiguration(set, interface, NULL); } } // remove the link between "set" and the "service" path = SCPreferencesPathKeyCreateSetNetworkServiceEntity(NULL, setPrivate->setID, servicePrivate->serviceID, NULL); ok = SCPreferencesPathRemoveValue(setPrivate->prefs, path); if (!ok) { sc_status = SCError(); // preserve the error } CFRelease(path); // push the [deep] interface configuration [back] into all sets which contain the service. if (interface_config != NULL) { __SCNetworkInterfaceSetDeepConfiguration(set, interface, interface_config); } if (interface_config != NULL) CFRelease(interface_config); if (!ok) { _SCErrorSet(sc_status); } return ok; }
Boolean SCDynamicStoreNotifyCancel(SCDynamicStoreRef store) { SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; kern_return_t status; int sc_status; if (store == NULL) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoStoreSession); return FALSE; } switch (storePrivate->notifyStatus) { case NotifierNotRegistered : /* if no notifications have been registered */ return TRUE; case Using_NotifierInformViaRunLoop : CFRunLoopSourceInvalidate(storePrivate->rls); storePrivate->rls = NULL; return TRUE; case Using_NotifierInformViaDispatch : (void) SCDynamicStoreSetDispatchQueue(store, NULL); return TRUE; default : break; } if (storePrivate->server == MACH_PORT_NULL) { /* sorry, you must have an open session to play */ sc_status = kSCStatusNoStoreServer; goto done; } status = notifycancel(storePrivate->server, (int *)&sc_status); if (__SCDynamicStoreCheckRetryAndHandleError(store, status, &sc_status, "SCDynamicStoreNotifyCancel notifycancel()")) { sc_status = kSCStatusOK; } done : /* set notifier inactive */ storePrivate->notifyStatus = NotifierNotRegistered; if (sc_status != kSCStatusOK) { _SCErrorSet(sc_status); return FALSE; } return TRUE; }
Boolean SCNetworkSetSetServiceOrder(SCNetworkSetRef set, CFArrayRef newOrder) { CFDictionaryRef dict; CFMutableDictionaryRef newDict; Boolean ok; CFStringRef path; SCNetworkSetPrivateRef setPrivate = (SCNetworkSetPrivateRef)set; if (!isA_SCNetworkSet(set)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } if (isA_CFArray(newOrder)) { CFIndex i; CFIndex n = CFArrayGetCount(newOrder); for (i = 0; i < n; i++) { CFStringRef serviceID; serviceID = CFArrayGetValueAtIndex(newOrder, i); if (!isA_CFString(serviceID)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } } } else { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } path = SCPreferencesPathKeyCreateSetNetworkGlobalEntity(NULL, setPrivate->setID, kSCEntNetIPv4); if (path == NULL) { return FALSE; } dict = SCPreferencesPathGetValue(setPrivate->prefs, path); if (dict != NULL) { newDict = CFDictionaryCreateMutableCopy(NULL, 0, dict); } else { newDict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } CFDictionarySetValue(newDict, kSCPropNetServiceOrder, newOrder); ok = SCPreferencesPathSetValue(setPrivate->prefs, path, newDict); CFRelease(newDict); CFRelease(path); return ok; }
Boolean SCDynamicStoreNotifySignal(SCDynamicStoreRef store, pid_t pid, int sig) { SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; kern_return_t status; int sc_status; task_t task; if (store == NULL) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoStoreSession); return FALSE; } if (storePrivate->server == MACH_PORT_NULL) { /* sorry, you must have an open session to play */ _SCErrorSet(kSCStatusNoStoreServer); return FALSE; } if (storePrivate->notifyStatus != NotifierNotRegistered) { /* sorry, you can only have one notification registered at once */ _SCErrorSet(kSCStatusNotifierActive); return FALSE; } status = task_for_pid(mach_task_self(), pid, &task); if (status != KERN_SUCCESS) { SC_log(LOG_ERR, "task_for_pid() failed: %s", mach_error_string(status)); _SCErrorSet(status); return FALSE; } retry : status = notifyviasignal(storePrivate->server, task, sig, (int *)&sc_status); if (__SCDynamicStoreCheckRetryAndHandleError(store, status, &sc_status, "SCDynamicStoreNotifySignal notifyviasignal()")) { goto retry; } if (status != KERN_SUCCESS) { _SCErrorSet(status); return FALSE; } /* set notifier active */ storePrivate->notifyStatus = Using_NotifierInformViaSignal; return TRUE; }
CFRunLoopSourceRef SCDynamicStoreCreateRunLoopSource(CFAllocatorRef allocator, SCDynamicStoreRef store, CFIndex order) { SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; if (store == NULL) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoStoreSession); return NULL; } if (storePrivate->server == MACH_PORT_NULL) { /* sorry, you must have an open session to play */ _SCErrorSet(kSCStatusNoStoreServer); return NULL; } switch (storePrivate->notifyStatus) { case NotifierNotRegistered : case Using_NotifierInformViaRunLoop : /* OK to enable runloop notification */ break; default : /* sorry, you can only have one notification registered at once */ _SCErrorSet(kSCStatusNotifierActive); return NULL; } if (storePrivate->rls != NULL) { CFRetain(storePrivate->rls); } else { CFRunLoopSourceContext context = { 0 // version , (void *)store // info , rlsRetain // retain , rlsRelease // release , rlsCopyDescription // copyDescription , CFEqual // equal , CFHash // hash , rlsSchedule // schedule , rlsCancel // cancel , rlsPerform // perform }; storePrivate->rls = CFRunLoopSourceCreate(allocator, order, &context); if (storePrivate->rls == NULL) { _SCErrorSet(kSCStatusFailed); } } return storePrivate->rls; }
CFArrayRef SCPreferencesCopyKeyList(SCPreferencesRef prefs) { CFAllocatorRef allocator; CFArrayRef keys; SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; CFIndex prefsCnt; const void ** prefsKeys; if (prefs == NULL) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoPrefsSession); return NULL; } __SCPreferencesAccess(prefs); allocator = CFGetAllocator(prefs); prefsCnt = CFDictionaryGetCount(prefsPrivate->prefs); if (prefsCnt > 0) { prefsKeys = CFAllocatorAllocate(allocator, prefsCnt * sizeof(CFStringRef), 0); CFDictionaryGetKeysAndValues(prefsPrivate->prefs, prefsKeys, NULL); keys = CFArrayCreate(allocator, prefsKeys, prefsCnt, &kCFTypeArrayCallBacks); CFAllocatorDeallocate(allocator, prefsKeys); } else { keys = CFArrayCreate(allocator, NULL, 0, &kCFTypeArrayCallBacks); } return keys; }
static Boolean __bond_set_mode(int s, CFStringRef bond_if, CFNumberRef mode) { struct if_bond_req breq; struct ifreq ifr; int mode_num; mode_num = IF_BOND_MODE_LACP; if (mode != NULL) { CFNumberGetValue(mode, kCFNumberIntType, &mode_num); } // bond interface bzero(&ifr, sizeof(ifr)); (void) _SC_cfstring_to_cstring(bond_if, ifr.ifr_name, sizeof(ifr.ifr_name), kCFStringEncodingASCII); ifr.ifr_data = (caddr_t)&breq; bzero(&breq, sizeof(breq)); breq.ibr_op = IF_BOND_OP_SET_MODE; breq.ibr_ibru.ibru_int_val = mode_num; if (ioctl(s, SIOCSIFBOND, (caddr_t)&ifr) == -1) { _SCErrorSet(errno); SCLog(TRUE, LOG_ERR, CFSTR("could not set mode to %d on bond \"%@\": %s"), mode, bond_if, strerror(errno)); return FALSE; } return TRUE; }
static Boolean __vlan_clear(int s, CFStringRef interface_if) { struct ifreq ifr; struct vlanreq vreq; bzero(&ifr, sizeof(ifr)); bzero(&vreq, sizeof(vreq)); // interface (void) _SC_cfstring_to_cstring(interface_if, ifr.ifr_name, sizeof(ifr.ifr_name), kCFStringEncodingASCII); ifr.ifr_data = (caddr_t)&vreq; // clear physical interface bzero(&vreq.vlr_parent, sizeof(vreq.vlr_parent)); // clear tag vreq.vlr_tag = 0; // update physical interface and tag if (ioctl(s, SIOCSIFVLAN, (caddr_t)&ifr) == -1) { SCLog(TRUE, LOG_ERR, CFSTR("ioctl(SIOCSIFVLAN) failed: %s"), strerror(errno)); _SCErrorSet(kSCStatusFailed); return FALSE; } return TRUE; }
CFArrayRef /* of serviceID CFStringRef's */ SCNetworkSetGetServiceOrder(SCNetworkSetRef set) { CFDictionaryRef dict; CFStringRef path; CFArrayRef serviceOrder; SCNetworkSetPrivateRef setPrivate = (SCNetworkSetPrivateRef)set; if (!isA_SCNetworkSet(set)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } path = SCPreferencesPathKeyCreateSetNetworkGlobalEntity(NULL, setPrivate->setID, kSCEntNetIPv4); if (path == NULL) { return NULL; } dict = SCPreferencesPathGetValue(setPrivate->prefs, path); CFRelease(path); if (!isA_CFDictionary(dict)) { return NULL; } serviceOrder = CFDictionaryGetValue(dict, kSCPropNetServiceOrder); serviceOrder = isA_CFArray(serviceOrder); return serviceOrder; }
Boolean SCNetworkCheckReachabilityByAddress(const struct sockaddr *address, socklen_t addrlen, SCNetworkConnectionFlags *flags) { SCNetworkReachabilityRef networkAddress; Boolean ok; struct sockaddr_storage ss; if (!address || (addrlen == 0) || (addrlen > (int)sizeof(struct sockaddr_storage))) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } bzero(&ss, sizeof(ss)); bcopy(address, &ss, addrlen); ss.ss_len = addrlen; networkAddress = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&ss); if (networkAddress == NULL) { return FALSE; } ok = SCNetworkReachabilityGetFlags(networkAddress, flags); CFRelease(networkAddress); return ok; }
static Boolean __bond_remove_interface(int s, CFStringRef bond_if, CFStringRef interface_if) { struct if_bond_req breq; struct ifreq ifr; // bond interface bzero(&ifr, sizeof(ifr)); (void) _SC_cfstring_to_cstring(bond_if, ifr.ifr_name, sizeof(ifr.ifr_name), kCFStringEncodingASCII); ifr.ifr_data = (caddr_t)&breq; // bond member to remove bzero(&breq, sizeof(breq)); breq.ibr_op = IF_BOND_OP_REMOVE_INTERFACE; (void) _SC_cfstring_to_cstring(interface_if, breq.ibr_ibru.ibru_if_name, sizeof(breq.ibr_ibru.ibru_if_name), kCFStringEncodingASCII); // remove bond member if (ioctl(s, SIOCSIFBOND, (caddr_t)&ifr) == -1) { _SCErrorSet(errno); SCLog(TRUE, LOG_ERR, CFSTR("could not remove interface \"%@\" from bond \"%@\": %s"), interface_if, bond_if, strerror(errno)); return FALSE; } return TRUE; }
void SCPreferencesSynchronize(SCPreferencesRef prefs) { SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; if (!isA_SCPreferences(prefs)) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoPrefsSession); return; } if (prefsPrivate->authorizationData != NULL) { __SCPreferencesSynchronize_helper(prefs); } if (prefsPrivate->prefs != NULL) { CFRelease(prefsPrivate->prefs); prefsPrivate->prefs = NULL; } if (prefsPrivate->signature != NULL) { CFRelease(prefsPrivate->signature); prefsPrivate->signature = NULL; } prefsPrivate->accessed = FALSE; prefsPrivate->changed = FALSE; return; }
Boolean SCNetworkSetSetSelectedVPNService(SCNetworkSetRef set, SCNetworkServiceRef service) { Boolean ok = TRUE; CFArrayRef services; if (!isA_SCNetworkSet(set)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } if (!isA_SCNetworkService(service) || !_SCNetworkServiceIsVPN(service)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } services = SCNetworkSetCopyServices(set); if (services != NULL) { CFIndex i; CFIndex n = CFArrayGetCount(services); if (!CFArrayContainsValue(services, CFRangeMake(0, n), service)) { // if selected service not a member of the current set _SCErrorSet(kSCStatusInvalidArgument); ok = FALSE; goto done; } for (i = 0; ok && (i < n); i++) { SCNetworkServiceRef vpn; vpn = CFArrayGetValueAtIndex(services, i); if (!_SCNetworkServiceIsVPN(vpn)) { // if not VPN service continue; } ok = SCNetworkServiceSetEnabled(vpn, CFEqual(service, vpn)); } } done : if (services != NULL) CFRelease(services); return ok; }
static Boolean _SCBondInterfaceSetMode(SCBondInterfaceRef bond, CFNumberRef mode) { SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)bond; Boolean needs_release = FALSE; Boolean ok = TRUE; assert(bond != NULL); if (mode == NULL) { int mode_num = IF_BOND_MODE_LACP; mode = CFNumberCreate(NULL, kCFNumberIntType, &mode_num); needs_release = TRUE; } // set mode in the stored preferences if (interfacePrivate->prefs != NULL) { CFDictionaryRef dict; CFMutableDictionaryRef newDict; CFStringRef path; path = CFStringCreateWithFormat(NULL, NULL, CFSTR("/%@/%@/%@"), kSCPrefVirtualNetworkInterfaces, kSCNetworkInterfaceTypeBond, interfacePrivate->entity_device); dict = SCPreferencesPathGetValue(interfacePrivate->prefs, path); if (!isA_CFDictionary(dict)) { // if the prefs are confused CFRelease(path); _SCErrorSet(kSCStatusFailed); ok = FALSE; goto done; } newDict = CFDictionaryCreateMutableCopy(NULL, 0, dict); CFDictionarySetValue(newDict, kSCPropVirtualNetworkInterfacesBondMode, mode); if (!CFEqual(dict, newDict)) { ok = SCPreferencesPathSetValue(interfacePrivate->prefs, path, newDict); } CFRelease(newDict); CFRelease(path); } if (ok) { CFRetain(mode); if (interfacePrivate->bond.mode != NULL) { CFRelease(interfacePrivate->bond.mode); } interfacePrivate->bond.mode = mode; } done : if (needs_release) CFRelease(mode); return ok; }
__private_extern__ Boolean __setPrefsConfiguration(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef config, Boolean keepInactive) { CFDictionaryRef curConfig; CFMutableDictionaryRef newConfig = NULL; Boolean ok; if ((config != NULL) && !isA_CFDictionary(config)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } curConfig = SCPreferencesPathGetValue(prefs, path); if (config != NULL) { newConfig = CFDictionaryCreateMutableCopy(NULL, 0, config); } if (keepInactive) { if (config == NULL) { newConfig = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } if (isA_CFDictionary(curConfig) && CFDictionaryContainsKey(curConfig, kSCResvInactive)) { // if currently disabled CFDictionarySetValue(newConfig, kSCResvInactive, kCFBooleanTrue); } else { // if currently enabled CFDictionaryRemoveValue(newConfig, kSCResvInactive); } } // set new configuration if (_SC_CFEqual(curConfig, newConfig)) { // if no change if (newConfig != NULL) CFRelease(newConfig); ok = TRUE; } else if (newConfig != NULL) { // if new configuration (or we are preserving a disabled state) ok = SCPreferencesPathSetValue(prefs, path, newConfig); CFRelease(newConfig); } else { ok = SCPreferencesPathRemoveValue(prefs, path); if (!ok && (SCError() == kSCStatusNoKey)) { ok = TRUE; } } return ok; }
CFNumberRef SCBondInterfaceGetMode(SCBondInterfaceRef bond) { SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)bond; if (!isA_SCBondInterface(bond)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } return (interfacePrivate->bond.mode); }
Boolean SCPreferencesUnscheduleFromRunLoop(SCPreferencesRef prefs, CFRunLoopRef runLoop, CFStringRef runLoopMode) { if (!isA_SCPreferences(prefs) || (runLoop == NULL) || (runLoopMode == NULL)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } return __SCPreferencesUnscheduleFromRunLoop(prefs, runLoop, runLoopMode); }
CFArrayRef SCBondInterfaceGetMemberInterfaces(SCBondInterfaceRef bond) { SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)bond; if (!isA_SCBondInterface(bond)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } return interfacePrivate->bond.interfaces; }
CFStringRef SCNetworkSetGetSetID(SCNetworkSetRef set) { SCNetworkSetPrivateRef setPrivate = (SCNetworkSetPrivateRef)set; if (!isA_SCNetworkSet(set)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } return setPrivate->setID; }
CFDictionaryRef SCBondInterfaceGetOptions(SCBondInterfaceRef bond) { SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)bond; if (!isA_SCBondInterface(bond)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } return interfacePrivate->bond.options; }
SCNetworkInterfaceRef SCVLANInterfaceGetPhysicalInterface(SCVLANInterfaceRef vlan) { SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)vlan; if (!isA_SCVLANInterface(vlan)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } return interfacePrivate->vlan.interface; }
CFNumberRef SCVLANInterfaceGetTag(SCVLANInterfaceRef vlan) { SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)vlan; if (!isA_SCVLANInterface(vlan)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } return interfacePrivate->vlan.tag; }
CFDictionaryRef SCVLANInterfaceGetOptions(SCVLANInterfaceRef vlan) { SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)vlan; if (!isA_SCVLANInterface(vlan)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } return interfacePrivate->vlan.options; }
CFPropertyListRef SCPreferencesGetValue(SCPreferencesRef prefs, CFStringRef key) { SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; CFPropertyListRef value; if (prefs == NULL) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoPrefsSession); return NULL; } __SCPreferencesAccess(prefs); value = CFDictionaryGetValue(prefsPrivate->prefs, key); if (value == NULL) { _SCErrorSet(kSCStatusNoKey); } return value; }
Boolean SCPreferencesRemoveValue(SCPreferencesRef prefs, CFStringRef key) { SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; if (prefs == NULL) { /* sorry, you must provide a session */ _SCErrorSet(kSCStatusNoPrefsSession); return FALSE; } __SCPreferencesAccess(prefs); if (!CFDictionaryContainsKey(prefsPrivate->prefs, key)) { _SCErrorSet(kSCStatusNoKey); return FALSE; } CFDictionaryRemoveValue(prefsPrivate->prefs, key); prefsPrivate->changed = TRUE; return TRUE; }