-
-#if TARGET_OS_EMBEDDED
-static void
-nc_print_VPN_app_info(CFStringRef appInfo, CFDictionaryRef appInfoDict)
-{
- CFStringRef appName = NULL;
- Boolean isEnabled = FALSE;
- CFStringRef paddedAppInfo = NULL;
- CFStringRef paddedAppName = NULL;
-
- if (appInfo == NULL) {
- return;
- }
-
- isEnabled = VPNConfigurationIsVPNTypeEnabled(appInfo);
-
- CFDictionaryGetValueIfPresent(appInfoDict, CFSTR("CFBundleDisplayName"), (const void **)&appName);
- paddedAppName = copy_padded_string((appName == NULL) ? CFSTR("") : appName, 12, NULL, NULL);
- paddedAppInfo = copy_padded_string(appInfo, 30, NULL, NULL);
-
- SCPrint(TRUE, stdout, CFSTR("%@ %@ [%@]\n"),
- isEnabled ? CFSTR("(Enabled) ") : CFSTR("(Disabled)"),
- paddedAppName,
- appInfo);
-
- my_CFRelease(&paddedAppName);
- my_CFRelease(&paddedAppInfo);
-}
-#endif
-
-/* -----------------------------------------------------------------------------
- ----------------------------------------------------------------------------- */
-#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
-static void
-nc_listvpn(int argc, char **argv)
-{
-
- CFDictionaryRef appDict = NULL;
- CFArrayRef appinfo = NULL;
- int i, j, count, subtypecount;
- const void * * keys = NULL;
- CFMutableDictionaryRef optionsDict = NULL;
- const void * * values = NULL;
- CFStringRef vpntype = NULL;
-
- optionsDict = CFDictionaryCreateMutable(NULL, 0,
- &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionarySetValue(optionsDict, kLookupApplicationTypeKey, kApplicationTypeUser);
- CFDictionarySetValue(optionsDict, kLookupAttributeKey, CFSTR("UIVPNPlugin"));
-
- appDict = MobileInstallationLookup(optionsDict);
- if (!isA_CFDictionary(appDict))
- goto done;
-
- count = CFDictionaryGetCount(appDict);
- if (count > 0) {
- keys = (const void * *)malloc(sizeof(CFTypeRef) * count);
- values = (const void * *)malloc(sizeof(CFTypeRef) * count);
-
- CFDictionaryGetKeysAndValues(appDict, keys, values);
- for (i=0; i<count; i++) {
- appinfo = CFDictionaryGetValue(values[i], CFSTR("UIVPNPlugin"));
- if (appinfo) {
-
-
-
- if (isA_CFString(appinfo)) {
- nc_print_VPN_app_info((CFStringRef)appinfo, (CFDictionaryRef)values[i]);
- }
- else if (isA_CFArray(appinfo)) {
- subtypecount = CFArrayGetCount((CFArrayRef)appinfo);
- for(j=0; j<subtypecount; j++) {
- vpntype = (CFStringRef)CFArrayGetValueAtIndex((CFArrayRef)appinfo, j);
- nc_print_VPN_app_info(vpntype, (CFDictionaryRef)values[i]);
- }
- }
- }
- }
- }
-done:
- if (keys) free(keys);
- if (values) free(values);
- my_CFRelease(&optionsDict);
- my_CFRelease(&appDict);
-
- exit(0);
-}
-#endif // TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
-