2 * Copyright (c) 2000-2020 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 #include <sys/cdefs.h>
28 #include <sys/socket.h>
30 #include <sys/syslog.h>
31 #include <mach/message.h>
33 #include <os/log_private.h>
34 #include <os/variant_private.h>
35 #include <sys/sysctl.h>
37 #include <CoreFoundation/CoreFoundation.h>
39 /* SCDynamicStore SPIs */
40 #include <SystemConfiguration/SCDynamicStorePrivate.h>
41 #include <SystemConfiguration/SCDynamicStoreCopySpecificPrivate.h>
42 #include <SystemConfiguration/SCDynamicStoreSetSpecificPrivate.h>
44 /* SCPreferences SPIs */
45 #include <SystemConfiguration/SCPreferencesPrivate.h>
46 #include <SystemConfiguration/SCPreferencesGetSpecificPrivate.h>
47 #include <SystemConfiguration/SCPreferencesSetSpecificPrivate.h>
49 /* [private] Schema Definitions (for SCDynamicStore and SCPreferences) */
50 #include <SystemConfiguration/SCSchemaDefinitionsPrivate.h>
52 /* SCNetworkConfiguration SPIs */
53 #include <SystemConfiguration/SCNetworkConfigurationPrivate.h>
55 /* SCNetworkConnection SPIs */
56 #include <SystemConfiguration/SCNetworkConnectionPrivate.h>
59 #include <SystemConfiguration/SCPreferencesKeychainPrivate.h>
66 /* "server" defines */
67 #if !TARGET_OS_SIMULATOR
68 #define _SC_SERVER_PROG "configd"
69 #else // !TARGET_OS_SIMULATOR
70 #define _SC_SERVER_PROG "configd_sim"
71 #endif // !TARGET_OS_SIMULATOR
74 /* atomic operations */
75 #define _SC_ATOMIC_CMPXCHG(p, o, n) __sync_bool_compare_and_swap((p), (o), (n))
76 #define _SC_ATOMIC_INC(p) __sync_fetch_and_add((p), 1) // return (n++);
77 #define _SC_ATOMIC_DEC(p) __sync_sub_and_fetch((p), 1) // return (--n);
78 #define _SC_ATOMIC_ZERO(p) __sync_fetch_and_and((p), 0) // old_n = n; n = 0; return(old_n);
83 #define SYSTEMCONFIGURATION_FRAMEWORK_PATH "/System/Library/Frameworks/SystemConfiguration.framework"
85 #define SYSTEMCONFIGURATION_FRAMEWORK_PATH "/System/Library/PrivateFrameworks/SystemConfiguration.framework"
89 /* get-network-info script path */
91 #define SYSTEMCONFIGURATION_GET_NETWORK_INFO_PATH SYSTEMCONFIGURATION_FRAMEWORK_PATH "/Resources/get-network-info"
93 #define SYSTEMCONFIGURATION_GET_NETWORK_INFO_PATH SYSTEMCONFIGURATION_FRAMEWORK_PATH "/get-network-info"
97 /* crash report(s) directory path */
99 #define _SC_CRASH_DIR "/Library/Logs/DiagnosticReports"
101 #define _SC_CRASH_DIR "/Library/Logs/CrashReporter"
105 /* framework debugging/logging variables */
106 typedef CF_ENUM(int, _SCLogDestination
) {
107 kSCLogDestinationFile
= 0, // if SC messages should be written to stdout/stderr
108 kSCLogDestinationDefault
= 1, // if SC messages should be logged w/os_log(3)
109 kSCLogDestinationBoth
= 2, // if SC messages should be logged AND written to stdout/stderr
110 kSCLogDestinationBoth_NoTime
= 3, // if SC messages should be logged AND written to stdout/stderr (w/o timestamp)
113 extern int _sc_debug
; /* non-zero if debugging enabled */
114 extern _SCLogDestination _sc_log
;
115 extern int _sc_verbose
; /* non-zero if verbose logging enabled */
120 #define _SC_NOTIFY_PREFIX "com.apple.system.config"
121 #define _SC_NOTIFY_NETWORK_CHANGE _SC_NOTIFY_PREFIX ".network_change"
122 #define _SC_NOTIFY_NETWORK_CHANGE_DNS _SC_NOTIFY_NETWORK_CHANGE ".dns"
123 #define _SC_NOTIFY_NETWORK_CHANGE_NWI _SC_NOTIFY_NETWORK_CHANGE ".nwi"
124 #define _SC_NOTIFY_NETWORK_CHANGE_PROXY _SC_NOTIFY_PREFIX ".proxy_change"
128 @group SCNetworkReachabilityCreateWithOptions #defines
129 @discussion The following defines the keys and values that can
130 be passed to the SCNetworkReachabilityCreateWithOptions
135 @constant kSCNetworkReachabilityOptionNodeName
136 @discussion A CFString that will be passed to getaddrinfo(3). An acceptable
137 value is either a valid host name or a numeric host address string
138 consisting of a dotted decimal IPv4 address or an IPv6 address.
140 #define kSCNetworkReachabilityOptionNodeName CFSTR("nodename")
143 @constant kSCNetworkReachabilityOptionLocalAddress
144 @discussion A CFData wrapping a "struct sockaddr" that represents
145 local address associated with a network connection.
147 #define kSCNetworkReachabilityOptionLocalAddress CFSTR("local-address")
150 @constant kSCNetworkReachabilityOptionPTRAddress
151 @discussion A CFData wrapping a "struct sockaddr" that represents
152 the reverse-address to be queried.
154 #define kSCNetworkReachabilityOptionPTRAddress CFSTR("ptr-address")
157 @constant kSCNetworkReachabilityOptionRemoteAddress
158 @discussion A CFData wrapping a "struct sockaddr" that represents
159 remote address associated with a network connection.
161 #define kSCNetworkReachabilityOptionRemoteAddress CFSTR("remote-address")
164 @constant kSCNetworkReachabilityOptionInterface
165 @discussion A CFString specifying that the reachability query should be
166 limited to the provided network interface (e.g. "en0", "en1", ...).
168 #define kSCNetworkReachabilityOptionInterface CFSTR("interface")
172 @constant kSCNetworkReachabilityOptionConnectionOnDemandBypass
173 @discussion A CFBoolean that indicates if we should bypass the VPNOnDemand
174 checks for this target.
176 #define kSCNetworkReachabilityOptionConnectionOnDemandBypass CFSTR("ConnectionOnDemandBypass")
179 @constant kSCNetworkReachabilityOptionResolverBypass
180 @discussion A CFBoolean that indicates if we should bypass resolving any
181 node names. Instead, the status of the DNS server configuration
182 associated with the name will be returned. */
183 #define kSCNetworkReachabilityOptionResolverBypass CFSTR("ResolverBypass")
187 @constant kSCNetworkReachabilityOptionServerBypass
188 @discussion A CFBoolean that indicates if we should bypass usage of the
189 SCNetworkReachability "server" for this target.
191 #define kSCNetworkReachabilityOptionServerBypass CFSTR("ServerBypass")
204 #pragma mark SCError()
208 @function _SCErrorSet
209 @discussion Sets the last SystemConfiguration.framework API error code.
210 @param error The error encountered.
212 void _SCErrorSet (int error
);
216 #pragma mark Serialization/Unserialization
220 @function _SCSerialize
221 @discussion Serialize a CFPropertyList object for passing
223 @param obj CFPropertyList object to serialize
224 @param xml A pointer to a CFDataRef, NULL if data should be
226 @param dataRef A pointer to the newly allocated/serialized data
227 @param dataLen A pointer to the length in bytes of the newly
228 allocated/serialized data
230 Boolean
_SCSerialize (CFPropertyListRef obj
,
236 @function _SCUnserialize
237 @discussion Unserialize a stream of bytes passed from/to configd
238 into a CFPropertyList object.
239 @param obj A pointer to memory that will be filled with the CFPropertyList
240 associated with the stream of bytes.
241 @param xml CFDataRef with the serialized data
242 @param dataRef A pointer to the serialized data
243 @param dataLen A pointer to the length of the serialized data
245 Specify either "xml" or "data/dataLen".
247 Boolean
_SCUnserialize (CFPropertyListRef
*obj
,
253 @function _SCSerializeString
254 @discussion Serialize a CFString object for passing
256 @param str CFString key to serialize
257 @param data A pointer to a CFDataRef, NULL if storage should be
259 @param dataRef A pointer to the newly allocated/serialized data
260 @param dataLen A pointer to the length in bytes of the newly
261 allocated/serialized data
263 Boolean
_SCSerializeString (CFStringRef str
,
269 @function _SCUnserializeString
270 @discussion Unserialize a stream of bytes passed from/to configd
271 into a CFString object.
272 @param str A pointer to memory that will be filled with the CFString
273 associated with the stream of bytes.
274 @param utf8 CFDataRef with the serialized data
275 @param dataRef A pointer to the serialized data
276 @param dataLen A pointer to the length of the serialized data
278 Specify either "utf8" or "data/dataLen".
280 Boolean
_SCUnserializeString (CFStringRef
*str
,
286 @function _SCSerializeData
287 @discussion Serialize a CFData object for passing
289 @param data CFData key to serialize
290 @param dataRef A pointer to the newly allocated/serialized data
291 @param dataLen A pointer to the length in bytes of the newly
292 allocated/serialized data
294 Boolean
_SCSerializeData (CFDataRef data
,
299 @function _SCUnserializeData
300 @discussion Unserialize a stream of bytes passed from/to configd
301 into a CFData object.
302 @param data A pointer to memory that will be filled with the CFData
303 associated with the stream of bytes.
304 @param dataRef A pointer to the serialized data
305 @param dataLen A pointer to the length of the serialized data
307 Boolean
_SCUnserializeData (CFDataRef
*data
,
312 @function _SCSerializeMultiple
313 @discussion Convert a CFDictionary containing a set of CFPropertlyList
314 values into a CFDictionary containing a set of serialized CFData
316 @param dict The CFDictionary with CFPropertyList values.
317 @result The serialized CFDictionary with CFData values
320 CFDictionaryRef
_SCSerializeMultiple (CFDictionaryRef dict
);
323 @function _SCUnserializeMultiple
324 @discussion Convert a CFDictionary containing a set of CFData
325 values into a CFDictionary containing a set of serialized
326 CFPropertlyList values.
327 @param dict The CFDictionary with CFData values.
328 @result The serialized CFDictionary with CFPropertyList values
331 CFDictionaryRef
_SCUnserializeMultiple (CFDictionaryRef dict
);
338 @function _SCCreatePropertyListFromResource
339 @discussion Reads a property list referenced by a file URL.
340 @param url The file URL.
341 @result The CFPropertyList content of the URL.
344 _SCCreatePropertyListFromResource (CFURLRef url
);
348 #pragma mark String conversion
352 @function _SC_cfstring_to_cstring
353 @discussion Extracts a C-string from a CFString.
354 @param cfstr The CFString to extract the data from.
355 @param buf A user provided buffer of the specified length. If NULL,
356 a new buffer will be allocated to contain the C-string. It
357 is the responsiblity of the caller to free an allocated
359 @param bufLen The size of the user provided buffer.
360 @param encoding The string encoding
361 @result If the extraction (conversion) is successful then a pointer
362 to the user provided (or allocated) buffer is returned, NULL
363 if the string could not be extracted.
365 char * _SC_cfstring_to_cstring (CFStringRef cfstr
,
368 CFStringEncoding encoding
);
371 * @function _SC_sockaddr_to_string
372 * @discussion Formats a "struct sockaddr" for reporting
373 * @param address The address to format
374 * @param buf A user provided buffer of the specified length.
375 * @param bufLen The size of the user provided buffer.
377 void _SC_sockaddr_to_string (const struct sockaddr
*address
,
383 * @function _SC_string_to_sockaddr
384 * @discussion Parses a string into a "struct sockaddr"
385 * @param str The address string to parse
386 * @param af Allowed address families (AF_UNSPEC, AF_INET, AF_INET6)
387 * @param buf A user provided buffer of the specified length; NULL
388 * if a new buffer should be allocated (and deallocated by the
390 * @param bufLen The size of the user provided buffer.
391 * @result A pointer to the parsed "struct sockaddr"; NULL if
392 * the string could not be parsed as an IP[v6] address.
395 _SC_string_to_sockaddr (const char *str
,
401 * @function _SC_trimDomain
402 * @discussion Trims leading and trailing "."s from a domain or host name
403 * @param domain The domain name to trim
404 * @result The trimmed domain name.
407 CFStringRef
_SC_trimDomain (CFStringRef domain
);
411 #pragma mark Mach IPC
415 @function _SC_sendMachMessage
416 @discussion Sends a trivial mach message (one with just a
417 message ID) to the specified port.
418 @param port The mach port.
419 @param msg_id The message id.
421 void _SC_sendMachMessage (mach_port_t port
,
422 mach_msg_id_t msg_id
);
430 @function _SC_LOG_DEFAULT
431 @discussion A function returning a default os_log_t object to be
432 used for [SystemConfiguration] logging.
433 @result The os_log_t object
435 os_log_t
_SC_LOG_DEFAULT (void);
439 @function _SC_syslog_os_log_mapping
440 @discussion Maps a syslog logging level to an os_log level.
441 @param level The syslog logging level
442 @result The os_log level
444 os_log_type_t
_SC_syslog_os_log_mapping (int level
);
448 @function _SCCopyDescription
449 @discussion Returns a formatted textual description of a CF object.
450 @param cf The CFType object (a generic reference of type CFTypeRef) from
451 which to derive a description.
452 @param formatOptions A dictionary containing formatting options for the object.
453 @result A string that contains a formatted description of cf.
455 CFStringRef
_SCCopyDescription (CFTypeRef cf
,
456 CFDictionaryRef formatOptions
);
461 @discussion Conditionally issue a log message.
462 @param condition A boolean value indicating if the message should be logged
463 @param level A syslog(3) logging priority.
464 @param formatString The format string
466 void SCLog (Boolean condition
,
468 CFStringRef formatString
,
469 ...) CF_FORMAT_FUNCTION(3, 4);
474 @discussion Issue an os_log() message.
476 Note: By default, the log messages will be associated with the
477 "com.apple.SystemConfiguration" subsystem. This behavior
478 can be overwritten by #define'ing SC_LOG_HANDLE with the name
479 of an os_log_t global (or a function that returns an os_log_t)
480 *BEFORE* this header is #include'd. In that case, the noted
481 log handle will be used.
482 @param level The syslog(3 logging priority.
483 @param __string The format string
484 @result The specified message will be written to the unified logging system.
488 #ifndef SC_LOG_HANDLE_TYPE
489 #define SC_LOG_HANDLE_TYPE
490 #endif // SC_LOG_HANDLE_TYPE
491 SC_LOG_HANDLE_TYPE os_log_t
SC_LOG_HANDLE(void);
492 #else // SC_LOG_HANDLE
493 #define SC_LOG_HANDLE _SC_LOG_DEFAULT // use [SC] default os_log handle
494 #endif // !SC_LOG_HANDLE
497 #define SC_log(__level, __format, ...) \
499 os_log_t __handle = SC_LOG_HANDLE(); \
500 os_log_type_t __type = _SC_syslog_os_log_mapping(__level); \
502 if (__SC_log_enabled(__level, __handle, __type)) { \
503 size_t __pack_size = os_log_pack_size(__format, ##__VA_ARGS__); \
505 _Pragma("clang diagnostic push") \
506 _Pragma("clang diagnostic ignored \"-Wvla\"") \
507 _Pragma("clang diagnostic ignored \"-Wgnu-statement-expression\"") \
508 os_log_pack_decl(__pack, __pack_size); \
509 os_log_pack_fill(__pack, __pack_size, errno, __format, ##__VA_ARGS__); \
510 _Pragma("clang diagnostic pop") \
512 __SC_log_send(__level, __handle, __type, __pack); \
517 @function __SC_log_enabled
518 @discussion Checks to see whether a log message will be issued
519 @param level A syslog(3) logging priority. If less than 0, log message is multi-line
520 @param log The os_log_t handle (for logging)
521 @param type The os_log_type_t type (for logging)
523 Boolean
__SC_log_enabled (int level
,
528 @function __SC_log_send
529 @discussion Issue an os_log_pack message w/os_log(3), syslog(3), or printf(3).
530 The specified message will be written to the system message
532 @param level A syslog(3) logging priority. If less than 0, log message is multi-line
533 @param log The os_log_t handle (for logging)
534 @param type The os_log_type_t type (for logging)
535 @param pack The os_log_pack_t message
537 void __SC_log_send (int level
,
547 @discussion Conditionally issue a debug message.
548 The message will be written to the specified output stream.
549 @param condition A boolean value indicating if the message should be written
550 @param stream The output stream for the log message.
551 @param formatString The format string
553 void SCPrint (Boolean condition
,
555 CFStringRef formatString
,
556 ...) CF_FORMAT_FUNCTION(3, 4);
564 @function SCNetworkProxiesCopyMatching
565 @discussion Return the proxy configurations matching a target host
566 and/or one associated with a specific network interface.
567 @param globalConfiguration the proxy dictionary currently returned
568 by SCDynamicStoreCopyProxies().
569 @param server A CFString specying the hostname of interest; NULL if
570 no specific hostname should be used in selecting the proxy
572 @param interface A CFString specifying that the proxy configuration
573 for the provided network interface (e.g. "en0", "en1", ...)
574 should be returned; NULL if proxy usage will not be scoped
576 @result A CFArray containing the proxy configurations associated
577 with the requested server and/or network interface.
581 SCNetworkProxiesCopyMatching (CFDictionaryRef globalConfiguration
,
583 CFStringRef interface
) API_AVAILABLE(macos(10.7)) SPI_AVAILABLE(ios(5.0), tvos(9.0), watchos(1.0), bridgeos(1.0));
585 #define kSCProxiesMatchServer CFSTR("Server") /* CFString */
586 #define kSCProxiesMatchInterface CFSTR("Interface") /* CFString */
587 #define kSCProxiesMatchExecutableUUID CFSTR("UUID") /* CFUUID */
590 @function SCNetworkProxiesCopyMatchingWithOptions
591 @discussion Return the proxy configurations matching a target host
592 and/or one associated with a specific network interface.
593 @param globalConfiguration the proxy dictionary currently returned
594 by SCDynamicStoreCopyProxies().
595 @param options A dictionary containing any (or none) of the following:
596 key value description
597 ------------------------------------------------------------------------------------------------
598 kSCProxiesMatchServer CFString The hostname of interest; do not include if no
599 specific hostname should be used in selecting the
600 proxy configurations.
601 kSCProxiesMatchInterface CFString If present, specifies the network interface
602 (e.g. "en0", "en1", ...) whose proxy configuration
603 should be returned. If not present, then proxy usage
604 will not be scoped to an interface.
605 kSCProxiesMatchExecutableUUID CFUUID If present, specifies the Mach-O UUID of the executable
606 on whose behalf the match operation is being performed.
607 If kSCProxiesMatchInterface is present then this option
608 is ignored. If not present, then the Mach-O UUID of
609 the current process is used. The Mach-O UUID is used
610 to match application-specific proxy configurations
611 (i.e., if per-app VPN rules are in effect).
612 @result A CFArray containing the proxy configurations associated with the given options.
615 SCNetworkProxiesCopyMatchingWithOptions (CFDictionaryRef globalConfiguration
,
616 CFDictionaryRef options
) API_AVAILABLE(macos(10.10)) SPI_AVAILABLE(ios(8.0), tvos(9.0), watchos(1.0), bridgeos(1.0));
618 extern const CFStringRef kSCProxiesNoGlobal
;
621 @function SCNetworkProxiesCreateProxyAgentData
622 @discussion Returns a serialized representation of a proxy configuration.
623 @param proxyConfig A dictionary representing a proxy configuration
624 @result returns a CFData representing a proxy configuration. This data is
625 readable by all "config-agents" (Agents with domain as "SystemConfig")
626 via config_agent_copy_proxy_information().
627 You must release the returned value.
630 SCNetworkProxiesCreateProxyAgentData (CFDictionaryRef proxyConfig
) API_AVAILABLE(macos(10.12)) SPI_AVAILABLE(ios(10.0), tvos(10.0), watchos(3.0), bridgeos(3.0));
633 @function SCDynamicStoreCopyProxiesWithOptions
634 @discussion Return the proxy configurations matching the provided
636 @param store An SCDynamicStoreRef representing the dynamic store
637 session that should be used for communication with the server.
638 If NULL, a temporary session will be used.
639 @param options A dictionary of proxy options which can include 1 (or more) of the following :
640 key value description
641 ---------------------------------------------------------------------------------------
642 kSCProxiesNoGlobal CFBoolean Bypass any "global" proxy configuration
644 @result Returns a dictionary containing key-value pairs that represent
645 the current internet proxy settings;
646 NULL if no proxy settings have been defined or if an error
648 You must release the returned value.
651 SCDynamicStoreCopyProxiesWithOptions (SCDynamicStoreRef store
,
652 CFDictionaryRef options
) API_AVAILABLE(macos(10.9)) SPI_AVAILABLE(ios(7.0), tvos(9.0), watchos(1.0), bridgeos(1.0));
655 #pragma mark Reachability
659 @function SCNetworkReachabilityCopyResolvedAddress
660 @discussion Return the resolved addresses associated with the
662 @result A CFArray[CFData], where each CFData is a (struct sockaddr)
665 SCNetworkReachabilityCopyResolvedAddress (SCNetworkReachabilityRef target
,
669 @function SCNetworkReachabilityCreateWithOptions
670 @discussion Creates a reference to a specified network host. The
671 options allow the caller to specify the node name and/or
672 the service name. This reference can be used later to
673 monitor the reachability of the target host.
674 @param allocator The CFAllocator that should be used to allocate
675 memory for the SCNetworkReachability object.
676 This parameter may be NULL in which case the current
677 default CFAllocator is used. If this reference is not
678 a valid CFAllocator, the behavior is undefined.
679 @param options A CFDictionary containing options specifying the
680 network host. The options reflect the arguments that would
681 be passed to getaddrinfo().
683 SCNetworkReachabilityRef
684 SCNetworkReachabilityCreateWithOptions (CFAllocatorRef allocator
,
685 CFDictionaryRef options
);
688 @function _SC_checkResolverReachabilityByAddress
689 @discussion Check the reachability of a reverse DNS query
692 _SC_checkResolverReachabilityByAddress (SCDynamicStoreRef
*storeP
,
693 SCNetworkReachabilityFlags
*flags
,
695 struct sockaddr
*sa
);
698 @function SCNetworkReachabilityGetInterfaceIndex
699 @discussion Returns the interface index associated with network interface that will
700 be used to interact with the target host.
701 @param target The SCNetworkReachability reference associated with the address or
702 name to be checked for reachability.
703 @result Returns the interface index associated with the target. Returning -1 means that
704 the target is not reachable.
707 SCNetworkReachabilityGetInterfaceIndex (SCNetworkReachabilityRef target
);
713 @function _SC_domainEndsWithDomain
714 @discussion Checks if one domain is a subset of another
715 @param compare_domain The domain to be compared.
716 @param match_domain The domain to be matched.
717 @return TRUE if the match_domain is contained in the compare_domain.
721 _SC_domainEndsWithDomain (CFStringRef compare_domain
,
722 CFStringRef match_domain
);
725 @function _SC_hostMatchesDomain
726 @discussion Checks if a hostname matches a domain. "*" not accepted as a domain. Top-level domain matching not supported.
727 The algorithm is as follows:
729 1. Trim .’s and *’s from the front and back of hostname and domain.
730 2. If the number of .’s left in the hostname and domain are equal, require an exact match.
731 3. Else, if the number of .’s in the hostname is greater than the number of .’s in the domain, and the number of .’s in the domain is greater than zero, append a . to the front of the domain and do a suffix match on the hostname.
735 www.apple.com > * : NO
736 www.apple.com > apple.com : YES
737 www.badapple.com > apple.com : NO
738 www.apple.com > .com : NO
739 foobar > foobar : YES
740 www.apple.com > www.apple.com : YES
741 www.apple.com... > .*.apple.com. : YES
743 @param hostname The specific hostname to check.
744 @param domain The domain to be matched.
745 @return TRUE if the hostname matches the domain. FALSE otherwise.
748 _SC_hostMatchesDomain (CFStringRef hostname
,
755 #if !TARGET_OS_IPHONE
757 * DOS encoding/codepage
760 _SC_dos_encoding_and_codepage (CFStringEncoding macEncoding
,
762 CFStringEncoding
*dosEncoding
,
763 UInt32
*dosCodepage
);
764 #endif // !TARGET_OS_IPHONE
771 _SC_getApplicationBundleID (void);
777 _SC_CFBundleGet (void);
780 _SC_CFBundleCopyNonLocalizedString (CFBundleRef bundle
,
783 CFStringRef tableName
);
793 _SC_CFMachPortCreateWithPort (const char * portDescription
,
795 CFMachPortCallBack callout
,
796 CFMachPortContext
*context
);
801 static __inline__ Boolean
802 _SC_CFEqual(CFTypeRef val1
, CFTypeRef val2
)
807 if (val1
!= NULL
&& val2
!= NULL
) {
808 return CFEqual(val1
, val2
);
813 static __inline__ Boolean
814 _SC_isAppleInternal()
816 static Boolean isInternal
;
817 static dispatch_once_t once
;
819 dispatch_once(&once
, ^{
820 isInternal
= os_variant_has_internal_content("com.apple.SystemConfiguration");
827 _SC_isInstallEnvironment (void);
829 #define MODEL CFSTR("Model")
832 _SC_hw_model (Boolean trim
);
835 _SC_dlopen (const char *framework
);
841 #ifdef DEBUG_MACH_PORT_ALLOCATIONS
842 #define __MACH_PORT_DEBUG(cond, str, port) \
844 if (cond) _SC_logMachPortReferences(str, port); \
846 #else // DEBUG_MACH_PORT_ALLOCATIONS
847 #define __MACH_PORT_DEBUG(cond, str, port)
848 #endif // DEBUG_MACH_PORT_ALLOCATIONS
851 _SC_logMachPortStatus (void);
854 _SC_logMachPortReferences (const char *str
,
858 _SC_copyBacktrace (void);
861 _SC_crash (const char *crash_info
,
862 CFStringRef notifyHeader
,
863 CFStringRef notifyMessage
);
865 static __inline__
void
866 _SC_crash_once (const char *crash_info
,
867 CFStringRef notifyHeader
,
868 CFStringRef notifyMessage
)
870 static dispatch_once_t once
;
872 _dispatch_once(&once
, ^{
873 _SC_crash(crash_info
, notifyHeader
, notifyMessage
);
878 _SC_getconninfo (int socket
,
879 struct sockaddr_storage
*src_addr
,
880 struct sockaddr_storage
*dest_addr
,
886 #endif /* _SCPRIVATE_H */