2  * Copyright (c) 2003-2018 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@ 
  24 #ifndef _SCNETWORKREACHABILITYINTERNAL_H 
  25 #define _SCNETWORKREACHABILITYINTERNAL_H 
  27 #include <os/availability.h> 
  28 #include <TargetConditionals.h> 
  29 #include <sys/cdefs.h> 
  30 #include <CoreFoundation/CoreFoundation.h> 
  31 #include <CoreFoundation/CFRuntime.h> 
  32 #include <SystemConfiguration/SystemConfiguration.h> 
  33 #include <SystemConfiguration/SCPrivate.h> 
  34 #include <dispatch/dispatch.h> 
  37 #include <sys/socket.h> 
  41 #include <nw/private.h> 
  44 #pragma mark SCNetworkReachability 
  46 #define kSCNetworkReachabilityFlagsMask                 0x00ffffff      // top 8-bits reserved for implementation 
  56         ReachabilityRankNone                    
= 0, 
  57         ReachabilityRankConnectionRequired      
= 1, 
  58         ReachabilityRankReachable               
= 2 
  59 } ReachabilityRankType
; 
  62         // by-address SCNetworkReachability targets 
  63         reachabilityTypeAddress
, 
  64         reachabilityTypeAddressPair
, 
  65         // by-name SCNetworkReachability targets 
  68 } ReachabilityAddressType
; 
  70 #define isReachabilityTypeAddress(type)         (type < reachabilityTypeName) 
  71 #define isReachabilityTypeName(type)            (type >= reachabilityTypeName) 
  75         /* base CFType information */ 
  82         ReachabilityAddressType         type
; 
  84         /* target host name */ 
  85         nw_endpoint_t                   hostnameEndpoint
; 
  87         /* local & remote addresses */ 
  88         nw_endpoint_t                   localAddressEndpoint
; 
  89         nw_endpoint_t                   remoteAddressEndpoint
; 
  91         /* run loop source, callout, context, rl scheduling info */ 
  93         Boolean                         sentFirstUpdate
; 
  94         CFRunLoopSourceRef              rls
; 
  95         SCNetworkReachabilityCallBack   rlsFunction
; 
  96         SCNetworkReachabilityContext    rlsContext
; 
  97         CFMutableArrayRef               rlList
; 
  99         dispatch_queue_t                dispatchQueue
;          // SCNetworkReachabilitySetDispatchQueue 
 101         Boolean                         resolverBypass
;         // set this flag to bypass resolving the name 
 106         nw_parameters_t                 parameters
; 
 107         nw_path_evaluator_t             pathEvaluator
; 
 109         nw_parameters_t                 lastPathParameters
; 
 110         nw_resolver_t                   resolver
; 
 111         nw_resolver_status_t            lastResolverStatus
; 
 112         nw_array_t                      lastResolvedEndpoints
; 
 113         Boolean                         lastResolvedEndpointHasFlags
; 
 114         SCNetworkReachabilityFlags      lastResolvedEndpointFlags
; 
 115         uint                            lastResolvedEndpointInterfaceIndex
; 
 117 } SCNetworkReachabilityPrivate
, *SCNetworkReachabilityPrivateRef
; 
 120 // ------------------------------------------------------------ 
 125 static __inline__ ReachabilityRankType
 
 126 __SCNetworkReachabilityRank(SCNetworkReachabilityFlags flags
) 
 128         ReachabilityRankType    rank 
= ReachabilityRankNone
; 
 130         if ((flags 
& kSCNetworkReachabilityFlagsReachable
) != 0) { 
 131                 rank 
= ReachabilityRankReachable
; 
 132                 if ((flags 
& kSCNetworkReachabilityFlagsConnectionRequired
) != 0) { 
 133                         rank 
= ReachabilityRankConnectionRequired
; 
 142 #endif  // _SCNETWORKREACHABILITYINTERNAL_H