Can you let us know how can we use this to get status of utun interface?
This may get you at least half way there. This is all a bit fragile though and would recommend managing anything that involves a custom virtual interface from the Network Extension APIs.
#import <SystemConfiguration/SystemConfiguration.h>
-(void) testDynamicStore {
SCDynamicStoreCallBack callbackFunc;
CFDictionaryRef storeOptionsRef;
SCDynamicStoreRef storeRef;
callbackFunc = callbackFunction;
storeOptionsRef = CFDictionaryCreate(NULL,
(const void * *)&kSCDynamicStoreUseSessionKeys,
(const void * *)&kCFBooleanTrue,
1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
storeRef = SCDynamicStoreCreateWithOptions(NULL, CFSTR("SystemConfiguration"), storeOptionsRef,
callbackFunction, NULL);
CFRelease(storeOptionsRef);
/* To get the entire list of options available use a .* regex pattern */
//CFArrayRef keyList = SCDynamicStoreCopyKeyList(storeRef, CFSTR(".*"));
/* To get just a path on the utun interface */
CFArrayRef keyList = SCDynamicStoreCopyKeyList(storeRef, CFSTR("State:/Network/Interface/utun3/IPv6"));
//...
NSArray *nsKeyList = (__bridge NSArray*)keyList;
NSLog(@"NSKey Array: %@", nsKeyList.description);
if (keyList != NULL && CFArrayGetCount(keyList) > 0) {
CFArrayRef value = NULL;
value = (CFArrayRef) SCDynamicStoreCopyValue(storeRef, (CFStringRef) CFArrayGetValueAtIndex(keyList, 0));
NSArray *nsValue = (__bridge NSArray*)value;
NSLog(@"NSValue Array: %@", nsValue.description);
CFRelease(value);
} else {
NSLog(@"keyList array did not return anything");
}
CFRelease(keyList);
}
static void callbackFunction(SCDynamicStoreRef store, CFArrayRef changedKeys, void * context) {
NSArray *nsChangedKeys = (__bridge NSArray*)changedKeys;
NSLog(@"NSChanged Values Array: %@", nsChangedKeys.description);
}
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com