Blame client/iOS/Misc/Reachability.h

Packit Service fa4841
/*
Packit Service bb5c11
 
Packit Service fa4841
 File: Reachability.h
Packit Service fa4841
 Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
Packit Service bb5c11
 
Packit Service fa4841
 Version: 2.2
Packit Service bb5c11
 
Packit Service fa4841
 Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Inc.
Packit Service fa4841
 ("Apple") in consideration of your agreement to the following terms, and your
Packit Service fa4841
 use, installation, modification or redistribution of this Apple software
Packit Service fa4841
 constitutes acceptance of these terms.  If you do not agree with these terms,
Packit Service fa4841
 please do not use, install, modify or redistribute this Apple software.
Packit Service bb5c11
 
Packit Service fa4841
 In consideration of your agreement to abide by the following terms, and subject
Packit Service fa4841
 to these terms, Apple grants you a personal, non-exclusive license, under
Packit Service fa4841
 Apple's copyrights in this original Apple software (the "Apple Software"), to
Packit Service fa4841
 use, reproduce, modify and redistribute the Apple Software, with or without
Packit Service fa4841
 modifications, in source and/or binary forms; provided that if you redistribute
Packit Service fa4841
 the Apple Software in its entirety and without modifications, you must retain
Packit Service fa4841
 this notice and the following text and disclaimers in all such redistributions
Packit Service fa4841
 of the Apple Software.
Packit Service fa4841
 Neither the name, trademarks, service marks or logos of Apple Inc. may be used
Packit Service fa4841
 to endorse or promote products derived from the Apple Software without specific
Packit Service fa4841
 prior written permission from Apple.  Except as expressly stated in this notice,
Packit Service fa4841
 no other rights or licenses, express or implied, are granted by Apple herein,
Packit Service fa4841
 including but not limited to any patent rights that may be infringed by your
Packit Service fa4841
 derivative works or by other works in which the Apple Software may be
Packit Service fa4841
 incorporated.
Packit Service bb5c11
 
Packit Service fa4841
 The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
Packit Service fa4841
 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
Packit Service fa4841
 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
Packit Service fa4841
 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
Packit Service fa4841
 COMBINATION WITH YOUR PRODUCTS.
Packit Service bb5c11
 
Packit Service fa4841
 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
Packit Service fa4841
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Packit Service fa4841
 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit Service fa4841
 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
Packit Service fa4841
 DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
Packit Service fa4841
 CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
Packit Service fa4841
 APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service bb5c11
 
Packit Service fa4841
 Copyright (C) 2010 Apple Inc. All Rights Reserved.
Packit Service bb5c11
 
Packit Service fa4841
*/
Packit Service fa4841
Packit Service bb5c11
Packit Service fa4841
#import <Foundation/Foundation.h>
Packit Service fa4841
#import <SystemConfiguration/SystemConfiguration.h>
Packit Service fa4841
#import <netinet/in.h>
Packit Service fa4841
Packit Service bb5c11
typedef enum {
Packit Service fa4841
	NotReachable = 0,
Packit Service fa4841
	ReachableViaWiFi = 1,
Packit Service fa4841
	ReachableViaWWAN = 2
Packit Service fa4841
} NetworkStatus;
Packit Service fa4841
#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
Packit Service fa4841
Packit Service bb5c11
@interface Reachability: NSObject
Packit Service fa4841
{
Packit Service fa4841
	BOOL localWiFiRef;
Packit Service fa4841
	SCNetworkReachabilityRef reachabilityRef;
Packit Service fa4841
}
Packit Service fa4841
Packit Service bb5c11
//reachabilityWithHostName- Use to check the reachability of a particular host name. 
Packit Service bb5c11
+ (Reachability*) reachabilityWithHostName: (NSString*) hostName;
Packit Service fa4841
Packit Service bb5c11
//reachabilityWithAddress- Use to check the reachability of a particular IP address. 
Packit Service bb5c11
+ (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
Packit Service fa4841
Packit Service bb5c11
//reachabilityForInternetConnection- checks whether the default route is available.  
Packit Service fa4841
//  Should be used by applications that do not connect to a particular host
Packit Service bb5c11
+ (Reachability*) reachabilityForInternetConnection;
Packit Service fa4841
Packit Service bb5c11
//reachabilityForLocalWiFi- checks whether a local wifi connection is available.
Packit Service bb5c11
+ (Reachability*) reachabilityForLocalWiFi;
Packit Service fa4841
Packit Service bb5c11
//Start listening for reachability notifications on the current run loop
Packit Service bb5c11
- (BOOL) startNotifier;
Packit Service bb5c11
- (void) stopNotifier;
Packit Service fa4841
Packit Service bb5c11
- (NetworkStatus) currentReachabilityStatus;
Packit Service bb5c11
//WWAN may be available, but not active until a connection has been established.
Packit Service bb5c11
//WiFi may require a connection for VPN on Demand.
Packit Service bb5c11
- (BOOL) connectionRequired;
Packit Service fa4841
@end
Packit Service bb5c11
Packit Service bb5c11