From 32d96e3d77d900203b7faba2d7937f8b3472f4d7 Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 18 Nov 2002 18:55:13 +0000 Subject: [PATCH] configd-53.1.tar.gz --- SystemConfiguration.fproj/CustomInfo.plist | 2 +- SystemConfiguration.fproj/DeviceOnHold.c | 116 +--- SystemConfiguration.fproj/LinkConfiguration.c | 571 ++++++++++++++++++ SystemConfiguration.fproj/LinkConfiguration.h | 121 ++++ SystemConfiguration.fproj/Makefile | 5 +- SystemConfiguration.fproj/Makefile.preamble | 1 + SystemConfiguration.fproj/PB.project | 8 +- SystemConfiguration.fproj/dy_framework.c | 178 ++++++ SystemConfiguration.fproj/dy_framework.h | 112 ++++ SystemConfiguration.fproj/genSCPreferences.c | 4 + 10 files changed, 998 insertions(+), 120 deletions(-) create mode 100644 SystemConfiguration.fproj/LinkConfiguration.c create mode 100644 SystemConfiguration.fproj/LinkConfiguration.h create mode 100644 SystemConfiguration.fproj/dy_framework.c create mode 100644 SystemConfiguration.fproj/dy_framework.h diff --git a/SystemConfiguration.fproj/CustomInfo.plist b/SystemConfiguration.fproj/CustomInfo.plist index 1f6eaa3..3150982 100644 --- a/SystemConfiguration.fproj/CustomInfo.plist +++ b/SystemConfiguration.fproj/CustomInfo.plist @@ -1,5 +1,5 @@ { CFBundleName = "SystemConfiguration"; CFBundleIdentifier = "com.apple.SystemConfiguration"; - CFBundleShortVersionString = "1.2.0"; + CFBundleShortVersionString = "1.3.0"; } diff --git a/SystemConfiguration.fproj/DeviceOnHold.c b/SystemConfiguration.fproj/DeviceOnHold.c index 88079cf..fbeea30 100644 --- a/SystemConfiguration.fproj/DeviceOnHold.c +++ b/SystemConfiguration.fproj/DeviceOnHold.c @@ -28,10 +28,7 @@ */ #include -#include -#include #include -#include #include #include @@ -42,6 +39,7 @@ #include #include +#include "dy_framework.h" #include "moh_msg.h" #include "moh.h" @@ -51,118 +49,6 @@ #define kIODeviceSupportsHoldKey "DeviceSupportsHold" -static void * -__loadIOKit(void) { - static const void *image = NULL; - if (NULL == image) { - const char *framework = "/System/Library/Frameworks/IOKit.framework/IOKit"; - struct stat statbuf; - const char *suffix = getenv("DYLD_IMAGE_SUFFIX"); - char path[MAXPATHLEN]; - - strcpy(path, framework); - if (suffix) strcat(path, suffix); - if (0 <= stat(path, &statbuf)) { - image = NSAddImage(path, NSADDIMAGE_OPTION_NONE); - } else { - image = NSAddImage(framework, NSADDIMAGE_OPTION_NONE); - } - } - return (void *)image; -} - - -static io_object_t -_IOIteratorNext(io_iterator_t iterator) -{ - static io_object_t (*dyfunc)(io_iterator_t) = NULL; - if (!dyfunc) { - void *image = __loadIOKit(); - if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOIteratorNext", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); - } - return dyfunc ? dyfunc(iterator) : 0; -} -#define IOIteratorNext _IOIteratorNext - - -static kern_return_t -_IOMasterPort(mach_port_t bootstrapPort, mach_port_t *masterPort) -{ - static kern_return_t (*dyfunc)(mach_port_t, mach_port_t *) = NULL; - if (!dyfunc) { - void *image = __loadIOKit(); - if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOMasterPort", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); - } - return dyfunc ? dyfunc(bootstrapPort, masterPort) : KERN_FAILURE; -} -#define IOMasterPort _IOMasterPort - - -static kern_return_t -_IOObjectRelease(io_object_t object) -{ - static kern_return_t (*dyfunc)(io_object_t) = NULL; - if (!dyfunc) { - void *image = __loadIOKit(); - if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOObjectRelease", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); - } - return dyfunc ? dyfunc(object) : KERN_FAILURE; -} -#define IOObjectRelease _IOObjectRelease - - -static kern_return_t -_IORegistryEntryCreateCFProperties(io_registry_entry_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, IOOptionBits options) -{ - static kern_return_t (*dyfunc)(io_registry_entry_t, CFMutableDictionaryRef *, CFAllocatorRef, IOOptionBits) = NULL; - if (!dyfunc) { - void *image = __loadIOKit(); - if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IORegistryEntryCreateCFProperties", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); - } - return dyfunc ? dyfunc(entry, properties, allocator, options) : KERN_FAILURE; -} -#define IORegistryEntryCreateCFProperties _IORegistryEntryCreateCFProperties - - -static kern_return_t -_IORegistryEntryGetPath(io_registry_entry_t entry, const io_name_t plane, io_string_t path) -{ - static kern_return_t (*dyfunc)(io_registry_entry_t, const io_name_t, io_string_t) = NULL; - if (!dyfunc) { - void *image = __loadIOKit(); - if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IORegistryEntryGetPath", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); - } - return dyfunc ? dyfunc(entry, plane, path) : KERN_FAILURE; -} -#define IORegistryEntryGetPath _IORegistryEntryGetPath - - -static kern_return_t -_IOServiceGetMatchingServices(mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t *existing) -{ - static kern_return_t (*dyfunc)(mach_port_t, CFDictionaryRef, io_iterator_t *) = NULL; - if (!dyfunc) { - void *image = __loadIOKit(); - if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOServiceGetMatchingServices", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); - } - return dyfunc ? dyfunc(masterPort, matching, existing) : KERN_FAILURE; -} -#define IOServiceGetMatchingServices _IOServiceGetMatchingServices - - -static CFMutableDictionaryRef -_IOServiceMatching(const char *name) -{ - static CFMutableDictionaryRef (*dyfunc)(const char *) = NULL; - if (!dyfunc) { - void *image = __loadIOKit(); - if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOServiceMatching", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); - } - return dyfunc ? dyfunc(name) : NULL; -} -#define IOServiceMatching _IOServiceMatching - - typedef struct { /* base CFType information */ diff --git a/SystemConfiguration.fproj/LinkConfiguration.c b/SystemConfiguration.fproj/LinkConfiguration.c new file mode 100644 index 0000000..159b4e0 --- /dev/null +++ b/SystemConfiguration.fproj/LinkConfiguration.c @@ -0,0 +1,571 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + * Modification History + * + * October 21, 2000 Allan Nathanson + * - initial revision + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include // for SCLog() +#include + +#include +#include +#include +#include "dy_framework.h" + + +static struct ifmedia_description ifm_subtype_shared_descriptions[] = + IFM_SUBTYPE_SHARED_DESCRIPTIONS; + +static struct ifmedia_description ifm_subtype_ethernet_descriptions[] = + IFM_SUBTYPE_ETHERNET_DESCRIPTIONS; + +static struct ifmedia_description ifm_shared_option_descriptions[] = + IFM_SHARED_OPTION_DESCRIPTIONS; + +static struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] = + IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS; + + +static char * +cfstring_to_cstring(CFStringRef cfstr, char *buf, int bufLen) +{ + CFIndex len = CFStringGetLength(cfstr); + + if (!buf) { + bufLen = len + 1; + buf = CFAllocatorAllocate(NULL, bufLen, 0); + } + + if (len >= bufLen) { + len = bufLen - 1; + } + + (void)CFStringGetBytes(cfstr, + CFRangeMake(0, len), + kCFStringEncodingASCII, + 0, + FALSE, + buf, + bufLen, + NULL); + buf[len] = '\0'; + + return buf; +} + + + +static CFDictionaryRef +__createMediaDictionary(int media_options, Boolean filter) +{ + CFMutableDictionaryRef dict = NULL; + int i; + CFMutableArrayRef options = NULL; + CFStringRef val; + + if (IFM_TYPE(media_options) != IFM_ETHER) { + return NULL; + } + + if (filter && (IFM_SUBTYPE(media_options) == IFM_NONE)) { + return NULL; /* filter */ + } + + dict = CFDictionaryCreateMutable(NULL, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + + /* subtype */ + + val = NULL; + for (i=0; !val && ifm_subtype_shared_descriptions[i].ifmt_string; i++) { + if (IFM_SUBTYPE(media_options) == ifm_subtype_shared_descriptions[i].ifmt_word) { + val = CFStringCreateWithCString(NULL, + ifm_subtype_shared_descriptions[i].ifmt_string, + kCFStringEncodingASCII); + break; + } + } + + for (i=0; !val && ifm_subtype_ethernet_descriptions[i].ifmt_string; i++) { + if (IFM_SUBTYPE(media_options) == ifm_subtype_ethernet_descriptions[i].ifmt_word) { + val = CFStringCreateWithCString(NULL, + ifm_subtype_ethernet_descriptions[i].ifmt_string, + kCFStringEncodingASCII); + break; + } + } + + if (val) { + CFDictionaryAddValue(dict, kSCPropNetEthernetMediaSubType, val); + CFRelease(val); + } + + /* options */ + + options = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + + while (IFM_OPTIONS(media_options) != 0) { + if (filter && (IFM_OPTIONS(media_options) & IFM_LOOP)) { + media_options &= ~IFM_LOOP; /* filter */ + continue; + } + + val = NULL; + for (i=0; !val && ifm_shared_option_descriptions[i].ifmt_string; i++) { + if (IFM_OPTIONS(media_options) & ifm_shared_option_descriptions[i].ifmt_word) { + val = CFStringCreateWithCString(NULL, + ifm_shared_option_descriptions[i].ifmt_string, + kCFStringEncodingASCII); + media_options &= ~ifm_shared_option_descriptions[i].ifmt_word; + break; + } + } + + for (i=0; !val && ifm_subtype_ethernet_option_descriptions[i].ifmt_string; i++) { + if (IFM_OPTIONS(media_options) & ifm_subtype_ethernet_option_descriptions[i].ifmt_word) { + val = CFStringCreateWithCString(NULL, + ifm_subtype_ethernet_option_descriptions[i].ifmt_string, + kCFStringEncodingASCII); + media_options &= ~ifm_shared_option_descriptions[i].ifmt_word; + break; + } + } + + if (val) { + CFArrayAppendValue(options, val); + CFRelease(val); + } + } + + CFDictionaryAddValue(dict, kSCPropNetEthernetMediaOptions, options); + CFRelease(options); + + return dict; +} + + +int +__createMediaOptions(CFDictionaryRef media_options) +{ + CFIndex i; + Boolean match; + int ifm_new = IFM_ETHER; + CFArrayRef options; + char *str; + CFStringRef val; + + /* set subtype */ + + val = CFDictionaryGetValue(media_options, kSCPropNetEthernetMediaSubType); + if (!isA_CFString(val)) { + return -1; + } + + str = cfstring_to_cstring(val, NULL, 0); + if (!str) { + return -1; + } + + match = FALSE; + for (i=0; !match && ifm_subtype_shared_descriptions[i].ifmt_string; i++) { + if (strcasecmp(str, ifm_subtype_shared_descriptions[i].ifmt_string) == 0) { + ifm_new |= ifm_subtype_shared_descriptions[i].ifmt_word; + match = TRUE; + break; + } + } + + for (i=0; !match && ifm_subtype_ethernet_descriptions[i].ifmt_string; i++) { + if (strcasecmp(str, ifm_subtype_ethernet_descriptions[i].ifmt_string) == 0) { + ifm_new |= ifm_subtype_ethernet_descriptions[i].ifmt_word; + match = TRUE; + break; + } + } + + CFAllocatorDeallocate(NULL, str); + + if (!match) { + return -1; /* if no subtype */ + } + + /* set options */ + + options = CFDictionaryGetValue(media_options, kSCPropNetEthernetMediaOptions); + if (!isA_CFArray(options)) { + return -1; + } + + for (i=0; i 0) { + media_list = (int *)CFAllocatorAllocate(NULL, ifm.ifm_count * sizeof(int), 0); + ifm.ifm_ulist = media_list; + if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifm) < 0) { + SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCGIFMEDIA) failed: %s"), strerror(errno)); + goto done; + } + } + + if (active) *active = NULL; + if (current) *current = NULL; + if (available) { + CFMutableArrayRef media_options; + + media_options = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + for (i=0; i= 0) (void)close(sock); + if (media_list) CFAllocatorDeallocate(NULL, media_list); + + return ok; +} + + +CFArrayRef +NetworkInterfaceCopyMediaSubTypes(CFArrayRef available) +{ + CFIndex i; + CFMutableArrayRef subTypes; + + if (!isA_CFArray(available)) { + return NULL; + } + + subTypes = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + for (i=0; i= 0) (void)close(sock); + + return ok; +} diff --git a/SystemConfiguration.fproj/LinkConfiguration.h b/SystemConfiguration.fproj/LinkConfiguration.h new file mode 100644 index 0000000..b09ba78 --- /dev/null +++ b/SystemConfiguration.fproj/LinkConfiguration.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + + +#ifndef _LINKCONFIGURATION_H +#define _LINKCONFIGURATION_H + +#include +#include + + +__BEGIN_DECLS + +/*! + @function NetworkInterfaceCopyMediaOptions + @discussion For the specified network interface, returns information + about the currently requested media options, the active media + options, and the media options which are available. + @param interface The desired network interface. + @param current A pointer to memory that will be filled with a CFDictionaryRef + representing the currently requested media options (subtype, options). + If NULL, the current options will not be returned. + @param active A pointer to memory that will be filled with a CFDictionaryRef + representing the active media options (subtype, options). + If NULL, the active options will not be returned. + @param available A pointer to memory that will be filled with a CFArrayRef + representing the possible media options (subtype, options). + If NULL, the available options will not be returned. + @param filter A boolean indicating whether the available options should be + filtered to exclude those options which would not normally be + requested by a user/admin (e.g. hw-loopback). + @result TRUE if requested information has been returned. + + */ +Boolean +NetworkInterfaceCopyMediaOptions( + CFStringRef interface, + CFDictionaryRef *current, + CFDictionaryRef *active, + CFArrayRef *available, + Boolean filter + ); + +/*! + @function NetworkInterfaceCopyMediaSubTypes + @discussion For the provided interface configuration options, return a list + of available media subtypes. + @param available The available options as returned by the + NetworkInterfaceCopyMediaOptions function. + @result An array of available media subtypes CFString's (e.g. 10BaseT/UTP, + 100baseTX, etc). NULL if no subtypes are available. + */ +CFArrayRef +NetworkInterfaceCopyMediaSubTypes( + CFArrayRef available + ); + +/*! + @function NetworkInterfaceCopyMediaSubTypes + @discussion For the provided interface configuration options and specific + subtype, return a list of available media options. + @param available The available options as returned by the + NetworkInterfaceCopyMediaOptions function. + @param subType The subtype + @result An array of available media options. Each of the available options + is returned as an array of CFString's (e.g. , + ). NULL if no options are available. + */ +CFArrayRef +NetworkInterfaceCopyMediaSubTypeOptions( + CFArrayRef available, + CFStringRef subType + ); + +/*! + @function NetworkInterfaceCopyMTU + @discussion + @param interface The desired network interface. + @param mtu_cur A pointer to memory that will be filled with the current + MTU setting for the interface. + @param mtu_min A pointer to memory that will be filled with the minimum + MTU setting for the interface. If negative, the minumum setting + could not be determined. + @param mtu_max A pointer to memory that will be filled with the maximum + MTU setting for the interface. If negative, the maximum setting + could not be determined. + @result TRUE if requested information has been returned. + + */ +Boolean +NetworkInterfaceCopyMTU( + CFStringRef interface, + int *mtu_cur, + int *mtu_min, + int *mtu_max + ); + + +__END_DECLS + +#endif /* _LINKCONFIGURATION_H */ + diff --git a/SystemConfiguration.fproj/Makefile b/SystemConfiguration.fproj/Makefile index d7fbd90..7297b5c 100644 --- a/SystemConfiguration.fproj/Makefile +++ b/SystemConfiguration.fproj/Makefile @@ -21,7 +21,7 @@ HFILES = SystemConfiguration.h SCPrivate.h SCDPlugin.h config_types.h\ SCValidation.h ppp_msg.h ppp.h v1Compatibility.h SCD.h\ SCDKeys.h SCP.h SCPPath.h SCDConsoleUser.h SCDHostName.h\ DHCPClientPreferences.h SCDynamicStoreCopyDHCPInfo.h moh_msg.h\ - moh.h DeviceOnHold.h + moh.h DeviceOnHold.h LinkConfiguration.h dy_framework.h CFILES = SCD.c SCDKeys.c SCDPrivate.c SCDPlugin.c SCDOpen.c SCDLock.c\ SCDUnlock.c SCDList.c SCDAdd.c SCDAddSession.c SCDGet.c\ @@ -34,7 +34,8 @@ CFILES = SCD.c SCDKeys.c SCDPrivate.c SCDPlugin.c SCDOpen.c SCDLock.c\ SCPUnlock.c SCPList.c SCPGet.c SCPAdd.c SCPSet.c SCPRemove.c\ SCPCommit.c SCPApply.c SCPPath.c SCDConsoleUser.c\ SCDHostName.c SCLocation.c SCNetwork.c SCProxies.c ppp.c\ - v1Compatibility.c DHCP.c moh.c DeviceOnHold.c + v1Compatibility.c DHCP.c moh.c DeviceOnHold.c\ + LinkConfiguration.c dy_framework.c OTHERSRCS = Makefile.preamble Makefile Makefile.postamble m.template\ h.template config.defs genSCPreferences.c CustomInfo.plist diff --git a/SystemConfiguration.fproj/Makefile.preamble b/SystemConfiguration.fproj/Makefile.preamble index feba1ec..d541ec9 100644 --- a/SystemConfiguration.fproj/Makefile.preamble +++ b/SystemConfiguration.fproj/Makefile.preamble @@ -146,6 +146,7 @@ OTHER_PRIVATE_HEADERS += SCPreferencesPrivate.h OTHER_PRIVATE_HEADERS += SCValidation.h OTHER_PRIVATE_HEADERS += SCDPlugin.h OTHER_PRIVATE_HEADERS += DeviceOnHold.h +OTHER_PRIVATE_HEADERS += LinkConfiguration.h # # XXX INSTALL V1 COMPATIBILITY HEADERS XXX diff --git a/SystemConfiguration.fproj/PB.project b/SystemConfiguration.fproj/PB.project index 4b815ad..1d21bfb 100644 --- a/SystemConfiguration.fproj/PB.project +++ b/SystemConfiguration.fproj/PB.project @@ -36,7 +36,9 @@ SCDynamicStoreCopyDHCPInfo.h, moh_msg.h, moh.h, - DeviceOnHold.h + DeviceOnHold.h, + LinkConfiguration.h, + dy_framework.h ); OTHER_LINKED = ( SCD.c, @@ -87,7 +89,9 @@ v1Compatibility.c, DHCP.c, moh.c, - DeviceOnHold.c + DeviceOnHold.c, + LinkConfiguration.c, + dy_framework.c ); OTHER_SOURCES = ( Makefile.preamble, diff --git a/SystemConfiguration.fproj/dy_framework.c b/SystemConfiguration.fproj/dy_framework.c new file mode 100644 index 0000000..d772f97 --- /dev/null +++ b/SystemConfiguration.fproj/dy_framework.c @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + * Modification History + * + * October 31, 2000 Allan Nathanson + * - initial revision + */ + + +#include +#include +#include +#include +#include + +#include "dy_framework.h" + + +static void * +__loadIOKit(void) { + static const void *image = NULL; + if (NULL == image) { + const char *framework = "/System/Library/Frameworks/IOKit.framework/IOKit"; + struct stat statbuf; + const char *suffix = getenv("DYLD_IMAGE_SUFFIX"); + char path[MAXPATHLEN]; + + strcpy(path, framework); + if (suffix) strcat(path, suffix); + if (0 <= stat(path, &statbuf)) { + image = NSAddImage(path, NSADDIMAGE_OPTION_NONE); + } else { + image = NSAddImage(framework, NSADDIMAGE_OPTION_NONE); + } + } + return (void *)image; +} + + +__private_extern__ CFMutableDictionaryRef +_IOBSDNameMatching(mach_port_t masterPort, unsigned int options, const char *bsdName) +{ + static CFMutableDictionaryRef (*dyfunc)(mach_port_t, unsigned int, const char *) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOBSDNameMatching", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(masterPort, options, bsdName) : NULL; +} + + +__private_extern__ io_object_t +_IOIteratorNext(io_iterator_t iterator) +{ + static io_object_t (*dyfunc)(io_iterator_t) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOIteratorNext", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(iterator) : 0; +} + + +__private_extern__ kern_return_t +_IOMasterPort(mach_port_t bootstrapPort, mach_port_t *masterPort) +{ + static kern_return_t (*dyfunc)(mach_port_t, mach_port_t *) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOMasterPort", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(bootstrapPort, masterPort) : KERN_FAILURE; +} + + +__private_extern__ kern_return_t +_IOObjectRelease(io_object_t object) +{ + static kern_return_t (*dyfunc)(io_object_t) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOObjectRelease", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(object) : KERN_FAILURE; +} + + +__private_extern__ CFTypeRef +_IORegistryEntryCreateCFProperty(io_registry_entry_t entry, CFStringRef key, CFAllocatorRef allocator, IOOptionBits options) +{ + static CFTypeRef (*dyfunc)(io_registry_entry_t, CFStringRef, CFAllocatorRef, IOOptionBits) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IORegistryEntryCreateCFProperty", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(entry, key, allocator, options) : NULL; +} + + +__private_extern__ kern_return_t +_IORegistryEntryCreateCFProperties(io_registry_entry_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, IOOptionBits options) +{ + static kern_return_t (*dyfunc)(io_registry_entry_t, CFMutableDictionaryRef *, CFAllocatorRef, IOOptionBits) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IORegistryEntryCreateCFProperties", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(entry, properties, allocator, options) : KERN_FAILURE; +} + + +__private_extern__ kern_return_t +_IORegistryEntryGetParentEntry(io_registry_entry_t entry, const io_name_t plane, io_registry_entry_t *parent) +{ + static kern_return_t (*dyfunc)(io_registry_entry_t, const io_name_t, io_registry_entry_t *) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IORegistryEntryGetParentEntry", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(entry, plane, parent) : NULL; +} + + +__private_extern__ kern_return_t +_IORegistryEntryGetPath(io_registry_entry_t entry, const io_name_t plane, io_string_t path) +{ + static kern_return_t (*dyfunc)(io_registry_entry_t, const io_name_t, io_string_t) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IORegistryEntryGetPath", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(entry, plane, path) : KERN_FAILURE; +} + + +__private_extern__ kern_return_t +_IOServiceGetMatchingServices(mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t *existing) +{ + static kern_return_t (*dyfunc)(mach_port_t, CFDictionaryRef, io_iterator_t *) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOServiceGetMatchingServices", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(masterPort, matching, existing) : KERN_FAILURE; +} + + +__private_extern__ CFMutableDictionaryRef +_IOServiceMatching(const char *name) +{ + static CFMutableDictionaryRef (*dyfunc)(const char *) = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOServiceMatching", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + } + return dyfunc ? dyfunc(name) : NULL; +} diff --git a/SystemConfiguration.fproj/dy_framework.h b/SystemConfiguration.fproj/dy_framework.h new file mode 100644 index 0000000..c53da68 --- /dev/null +++ b/SystemConfiguration.fproj/dy_framework.h @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + + +#ifndef _DY_FRAMEWORK_H +#define _DY_FRAMEWORK_H + +#include +#include +#include +#include + +__BEGIN_DECLS + +CFMutableDictionaryRef +_IOBSDNameMatching ( + mach_port_t masterPort, + unsigned int options, + const char *bsdName + ); +#define IOBSDNameMatching _IOBSDNameMatching + +io_object_t +_IOIteratorNext ( + io_iterator_t iterator + ); +#define IOIteratorNext _IOIteratorNext + +kern_return_t +_IOMasterPort ( + mach_port_t bootstrapPort, + mach_port_t *masterPort + ); +#define IOMasterPort _IOMasterPort + +kern_return_t +_IOObjectRelease ( + io_object_t object + ); +#define IOObjectRelease _IOObjectRelease + +CFTypeRef +_IORegistryEntryCreateCFProperty ( + io_registry_entry_t entry, + CFStringRef key, + CFAllocatorRef allocator, + IOOptionBits options + ); +#define IORegistryEntryCreateCFProperty _IORegistryEntryCreateCFProperty + +kern_return_t +_IORegistryEntryCreateCFProperties ( + io_registry_entry_t entry, + CFMutableDictionaryRef *properties, + CFAllocatorRef allocator, + IOOptionBits options + ); +#define IORegistryEntryCreateCFProperties _IORegistryEntryCreateCFProperties + +kern_return_t +_IORegistryEntryGetParentEntry ( + io_registry_entry_t entry, + const io_name_t plane, + io_registry_entry_t *parent + ); +#define IORegistryEntryGetParentEntry _IORegistryEntryGetParentEntry + +kern_return_t +_IORegistryEntryGetPath ( + io_registry_entry_t entry, + const io_name_t plane, + io_string_t path + ); +#define IORegistryEntryGetPath _IORegistryEntryGetPath + +kern_return_t +_IOServiceGetMatchingServices ( + mach_port_t masterPort, + CFDictionaryRef matching, + io_iterator_t *existing + ); +#define IOServiceGetMatchingServices _IOServiceGetMatchingServices + +CFMutableDictionaryRef +_IOServiceMatching ( + const char *name + ); +#define IOServiceMatching _IOServiceMatching + +__END_DECLS + +#endif /* _DY_FRAMEWORK_H */ + diff --git a/SystemConfiguration.fproj/genSCPreferences.c b/SystemConfiguration.fproj/genSCPreferences.c index cc54958..c4e845c 100644 --- a/SystemConfiguration.fproj/genSCPreferences.c +++ b/SystemConfiguration.fproj/genSCPreferences.c @@ -207,6 +207,7 @@ typedef enum { #define MACADDRESS "MACAddress" #define MANUAL "Manual" #define MEDIA "Media" +#define OPTIONS "Options" #define MODEM "Modem" #define MRU "MRU" #define MTU "MTU" @@ -400,6 +401,9 @@ struct { { COMMENT, "", NULL, NULL, NULL }, { COMMENT, "/*\n * " KEY_PREFIX NETENT ETHERNET " (Hardware) Entity Keys\n */", NULL, NULL, NULL }, + { DEFINE , NETPROP ETHERNET, MEDIA SUBTYPE, NULL, CFSTRING }, + { DEFINE , NETPROP ETHERNET, MEDIA OPTIONS, NULL, CFARRAY_CFSTRING }, + { DEFINE , NETPROP ETHERNET, MTU, NULL, CFNUMBER }, { COMMENT, "", NULL, NULL, NULL }, { COMMENT, "/*\n * " KEY_PREFIX NETENT INTERFACE " Entity Keys\n */", NULL }, -- 2.45.2