Blame client/iOS/Misc/Reachability.h

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