{
CFBundleName = "SystemConfiguration";
CFBundleIdentifier = "com.apple.SystemConfiguration";
- CFBundleShortVersionString = "1.2.0";
+ CFBundleShortVersionString = "1.3.0";
}
*/
#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
#include <mach/mach.h>
-#include <mach-o/dyld.h>
#include <pthread.h>
#include <CoreFoundation/CoreFoundation.h>
#include <SystemConfiguration/SCPrivate.h>
#include <IOKit/IOKitLib.h>
+#include "dy_framework.h"
#include "moh_msg.h"
#include "moh.h"
#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 */
--- /dev/null
+/*
+ * 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 <ajn@apple.com>
+ * - initial revision
+ */
+
+
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <net/if_media.h>
+#include <net/if_types.h>
+
+#include <SystemConfiguration/SystemConfiguration.h>
+#include <SystemConfiguration/SCPrivate.h> // for SCLog()
+#include <SystemConfiguration/SCValidation.h>
+
+#include <IOKit/IOKitLib.h>
+#include <IOKit/network/IONetworkInterface.h>
+#include <IOKit/network/IONetworkController.h>
+#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<CFArrayGetCount(options); i++) {
+ CFIndex j;
+
+ val = CFArrayGetValueAtIndex(options, i);
+ if (!isA_CFString(val)) {
+ return -1;
+ }
+
+ str = cfstring_to_cstring(val, NULL, 0);
+ if (!str) {
+ return -1;
+ }
+
+
+ match = FALSE;
+ for (j=0; !match && ifm_shared_option_descriptions[j].ifmt_string; j++) {
+ if (strcasecmp(str, ifm_shared_option_descriptions[j].ifmt_string) == 0) {
+ ifm_new |= ifm_shared_option_descriptions[j].ifmt_word;
+ match = TRUE;
+ break;
+ }
+ }
+
+ for (j=0; !match && ifm_subtype_ethernet_option_descriptions[j].ifmt_string; j++) {
+ if (strcasecmp(str, ifm_subtype_ethernet_option_descriptions[j].ifmt_string) == 0) {
+ ifm_new |= ifm_subtype_ethernet_option_descriptions[j].ifmt_word;
+ match = TRUE;
+ break;
+ }
+ }
+
+ CFAllocatorDeallocate(NULL, str);
+
+ if (!match) {
+ return -1; /* if no option */
+ }
+ }
+
+ return ifm_new;
+}
+
+
+Boolean
+NetworkInterfaceCopyMediaOptions(CFStringRef interface,
+ CFDictionaryRef *current,
+ CFDictionaryRef *active,
+ CFArrayRef *available,
+ Boolean filter)
+{
+ int i;
+ struct ifmediareq ifm;
+ int *media_list = NULL;
+ Boolean ok = FALSE;
+ int sock = -1;
+
+ bzero((char *)&ifm, sizeof(ifm));
+
+ (void)cfstring_to_cstring(interface, ifm.ifm_name, sizeof(ifm.ifm_name));
+
+ sock = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sock < 0) {
+ SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno));
+ goto done;
+ }
+
+ if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifm) < 0) {
+// SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCGIFMEDIA) failed: %s"), strerror(errno));
+ goto done;
+ }
+
+ if (ifm.ifm_count > 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<ifm.ifm_count; i++) {
+ CFDictionaryRef options;
+
+ options = __createMediaDictionary(media_list[i], filter);
+ if (!options) {
+ continue;
+ }
+
+ if (active && (*active == NULL) && (ifm.ifm_active == media_list[i])) {
+ *active = CFRetain(options);
+ }
+
+ if (current && (*current == NULL) && (ifm.ifm_current == media_list[i])) {
+ *current = CFRetain(options);
+ }
+
+ if (!CFArrayContainsValue(media_options, CFRangeMake(0, CFArrayGetCount(media_options)), options)) {
+ CFArrayAppendValue(media_options, options);
+ }
+
+ CFRelease(options);
+ }
+ *available = (CFArrayRef)media_options;
+ }
+
+ if (active && (*active == NULL)) {
+ *active = __createMediaDictionary(ifm.ifm_active, FALSE);
+ }
+
+ if (current && (*current == NULL)) {
+ if (active && (ifm.ifm_active == ifm.ifm_current)) {
+ if (*active) *current = CFRetain(active);
+ } else {
+ *current = __createMediaDictionary(ifm.ifm_current, FALSE);
+ }
+ }
+
+ ok = TRUE;
+
+ done :
+
+ if (sock >= 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<CFArrayGetCount(available); i++) {
+ CFDictionaryRef options;
+ CFStringRef subType;
+
+ options = CFArrayGetValueAtIndex(available, i);
+ if (!isA_CFDictionary(options)) {
+ continue;
+ }
+
+ subType = CFDictionaryGetValue(options, kSCPropNetEthernetMediaSubType);
+ if (!isA_CFString(subType)) {
+ continue;
+ }
+
+ if (!CFArrayContainsValue(subTypes, CFRangeMake(0, CFArrayGetCount(subTypes)), subType)) {
+ CFArrayAppendValue(subTypes, subType);
+ }
+ }
+
+ if (CFArrayGetCount(subTypes) == 0) {
+ CFRelease(subTypes);
+ subTypes = NULL;
+ }
+
+ return subTypes;
+}
+
+
+CFArrayRef
+NetworkInterfaceCopyMediaSubTypeOptions(CFArrayRef available,
+ CFStringRef subType)
+{
+ CFIndex i;
+ CFMutableArrayRef subTypeOptions;
+
+ if (!isA_CFArray(available)) {
+ return NULL;
+ }
+
+ subTypeOptions = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+ for (i=0; i<CFArrayGetCount(available); i++) {
+ CFDictionaryRef options;
+ CFArrayRef mediaOptions;
+ CFStringRef mediaSubType;
+
+ options = CFArrayGetValueAtIndex(available, i);
+ if (!isA_CFDictionary(options)) {
+ continue;
+ }
+
+ mediaSubType = CFDictionaryGetValue(options, kSCPropNetEthernetMediaSubType);
+ if (!isA_CFString(mediaSubType) || !CFEqual(subType, mediaSubType)) {
+ continue;
+ }
+
+ mediaOptions = CFDictionaryGetValue(options, kSCPropNetEthernetMediaOptions);
+ if (!isA_CFArray(mediaOptions)) {
+ continue;
+ }
+
+ if (!CFArrayContainsValue(subTypeOptions, CFRangeMake(0, CFArrayGetCount(subTypeOptions)), mediaOptions)) {
+ CFArrayAppendValue(subTypeOptions, mediaOptions);
+ }
+ }
+
+ if (CFArrayGetCount(subTypeOptions) == 0) {
+ CFRelease(subTypeOptions);
+ subTypeOptions = NULL;
+ }
+
+ return subTypeOptions;
+}
+
+
+Boolean
+NetworkInterfaceCopyMTU(CFStringRef interface,
+ int *mtu_cur,
+ int *mtu_min,
+ int *mtu_max)
+{
+ struct ifreq ifr;
+ Boolean ok = FALSE;
+ int sock = -1;
+
+ bzero((char *)&ifr, sizeof(ifr));
+ (void)cfstring_to_cstring(interface, ifr.ifr_name, sizeof(ifr.ifr_name));
+
+ sock = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sock < 0) {
+ SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno));
+ goto done;
+ }
+
+ if (ioctl(sock, SIOCGIFMTU, (caddr_t)&ifr) < 0) {
+// SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCGIFMTU) failed: %s"), strerror(errno));
+ goto done;
+ }
+
+ if (mtu_cur) *mtu_cur = ifr.ifr_mtu;
+
+ /* get valid MTU range */
+
+ if (mtu_min || mtu_max) {
+ char ifName[IFNAMSIZ+1];
+ int ifType = 0;
+ io_iterator_t io_iter = 0;
+ io_registry_entry_t io_interface = 0;
+ io_registry_entry_t io_controller = 0;
+ kern_return_t kr;
+ mach_port_t masterPort = MACH_PORT_NULL;
+ CFMutableDictionaryRef matchingDict;
+
+ /* assume that we don't know */
+
+ if (mtu_min) *mtu_min = -1;
+ if (mtu_max) *mtu_max = -1;
+
+ /* look for a matching interface in the IORegistry */
+
+ (void)cfstring_to_cstring(interface, ifName, sizeof(ifName));
+ matchingDict = IOBSDNameMatching(masterPort, 0, ifName);
+ if (matchingDict) {
+ /* Note: IOServiceGetMatchingServices consumes a reference on the 'matchingDict' */
+ kr = IOServiceGetMatchingServices(masterPort, matchingDict, &io_iter);
+ if ((kr == KERN_SUCCESS) && io_iter) {
+ /* should only have a single match */
+ io_interface = IOIteratorNext(io_iter);
+ }
+ if (io_iter) IOObjectRelease(io_iter);
+ }
+
+ /* found an interface with the given BSD name, get its parent */
+
+ if (io_interface) {
+ CFNumberRef num;
+
+ /*
+ * get the interface type
+ */
+ num = IORegistryEntryCreateCFProperty(io_interface, CFSTR(kIOInterfaceType), NULL, kNilOptions);
+ if (num) {
+ if (isA_CFNumber(num)) {
+ CFNumberGetValue(num, kCFNumberIntType, &ifType);
+ }
+ CFRelease(num);
+ }
+
+ /*
+ * ...and the property we are REALLY interested is in the controller,
+ * which is the parent of the interface object.
+ */
+ (void)IORegistryEntryGetParentEntry(io_interface, kIOServicePlane, &io_controller);
+
+ IOObjectRelease(io_interface);
+ }
+
+ if (io_controller) {
+ CFNumberRef num;
+
+ num = IORegistryEntryCreateCFProperty(io_controller, CFSTR(kIOMaxPacketSize), NULL, kNilOptions);
+ if (num) {
+ if (isA_CFNumber(num)) {
+ int value;
+
+ /*
+ * Get the value and subtract the FCS bytes and Ethernet header
+ * sizes from the maximum frame size reported by the controller
+ * to get the MTU size. The 14 byte media header can be found
+ * in the registry, but not the size for the trailing FCS bytes.
+ */
+ CFNumberGetValue(num, kCFNumberIntType, &value);
+
+ if (ifType == IFT_ETHER) {
+ value -= (ETHER_HDR_LEN + ETHER_CRC_LEN);
+ }
+
+ if (mtu_min) *mtu_min = IF_MINMTU;
+ if (mtu_max) *mtu_max = value;
+ }
+ CFRelease(num);
+ }
+
+ IOObjectRelease(io_controller);
+ }
+ }
+
+ ok = TRUE;
+
+ done :
+
+ if (sock >= 0) (void)close(sock);
+
+ return ok;
+}
--- /dev/null
+/*
+ * 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 <sys/cdefs.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+
+__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. <half-duplex>,
+ <full-duplex,flow-control>). 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 */
+
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\
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
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
SCDynamicStoreCopyDHCPInfo.h,
moh_msg.h,
moh.h,
- DeviceOnHold.h
+ DeviceOnHold.h,
+ LinkConfiguration.h,
+ dy_framework.h
);
OTHER_LINKED = (
SCD.c,
v1Compatibility.c,
DHCP.c,
moh.c,
- DeviceOnHold.c
+ DeviceOnHold.c,
+ LinkConfiguration.c,
+ dy_framework.c
);
OTHER_SOURCES = (
Makefile.preamble,
--- /dev/null
+/*
+ * 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 <ajn@apple.com>
+ * - initial revision
+ */
+
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <mach-o/dyld.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+#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;
+}
--- /dev/null
+/*
+ * 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 <sys/cdefs.h>
+#include <mach/mach.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <IOKit/IOKitLib.h>
+
+__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 */
+
#define MACADDRESS "MACAddress"
#define MANUAL "Manual"
#define MEDIA "Media"
+#define OPTIONS "Options"
#define MODEM "Modem"
#define MRU "MRU"
#define MTU "MTU"
{ 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 },