SCNetworkReachabilityInternal.h [plain text]
#ifndef _SCNETWORKREACHABILITYINTERNAL_H
#define _SCNETWORKREACHABILITYINTERNAL_H
#include <os/availability.h>
#include <TargetConditionals.h>
#include <sys/cdefs.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFRuntime.h>
#include <SystemConfiguration/SystemConfiguration.h>
#include <SystemConfiguration/SCPrivate.h>
#include <dispatch/dispatch.h>
#include <netdb.h>
#include <sys/socket.h>
#include <net/if.h>
#include <xpc/xpc.h>
#include <nw/private.h>
#pragma mark -
#pragma mark SCNetworkReachability
#define kSCNetworkReachabilityFlagsMask 0x00ffffff // top 8-bits reserved for implementation
typedef enum {
NO = 0,
YES,
UNKNOWN
} lazyBoolean;
typedef enum {
ReachabilityRankNone = 0,
ReachabilityRankConnectionRequired = 1,
ReachabilityRankReachable = 2
} ReachabilityRankType;
typedef enum {
reachabilityTypeAddress,
reachabilityTypeAddressPair,
reachabilityTypeName,
reachabilityTypePTR
} ReachabilityAddressType;
#define isReachabilityTypeAddress(type) (type < reachabilityTypeName)
#define isReachabilityTypeName(type) (type >= reachabilityTypeName)
typedef struct {
CFRuntimeBase cfBase;
pthread_mutex_t lock;
ReachabilityAddressType type;
nw_endpoint_t hostnameEndpoint;
nw_endpoint_t localAddressEndpoint;
nw_endpoint_t remoteAddressEndpoint;
Boolean scheduled;
Boolean sentFirstUpdate;
CFRunLoopSourceRef rls;
SCNetworkReachabilityCallBack rlsFunction;
SCNetworkReachabilityContext rlsContext;
CFMutableArrayRef rlList;
dispatch_queue_t dispatchQueue;
Boolean resolverBypass;
char log_prefix[32];
nw_parameters_t parameters;
nw_path_evaluator_t pathEvaluator;
nw_path_t lastPath;
nw_parameters_t lastPathParameters;
nw_resolver_t resolver;
nw_resolver_status_t lastResolverStatus;
nw_array_t lastResolvedEndpoints;
Boolean lastResolvedEndpointHasFlags;
SCNetworkReachabilityFlags lastResolvedEndpointFlags;
uint lastResolvedEndpointInterfaceIndex;
} SCNetworkReachabilityPrivate, *SCNetworkReachabilityPrivateRef;
__BEGIN_DECLS
static __inline__ ReachabilityRankType
__SCNetworkReachabilityRank(SCNetworkReachabilityFlags flags)
{
ReachabilityRankType rank = ReachabilityRankNone;
if ((flags & kSCNetworkReachabilityFlagsReachable) != 0) {
rank = ReachabilityRankReachable;
if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0) {
rank = ReachabilityRankConnectionRequired;
}
}
return rank;
}
__END_DECLS
#endif // _SCNETWORKREACHABILITYINTERNAL_H