![]() |
Ignite Tools
|
00001 /* 00002 00003 File: Reachability.h 00004 Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs. 00005 00006 Version: 2.2 00007 00008 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. 00009 ("Apple") in consideration of your agreement to the following terms, and your 00010 use, installation, modification or redistribution of this Apple software 00011 constitutes acceptance of these terms. If you do not agree with these terms, 00012 please do not use, install, modify or redistribute this Apple software. 00013 00014 In consideration of your agreement to abide by the following terms, and subject 00015 to these terms, Apple grants you a personal, non-exclusive license, under 00016 Apple's copyrights in this original Apple software (the "Apple Software"), to 00017 use, reproduce, modify and redistribute the Apple Software, with or without 00018 modifications, in source and/or binary forms; provided that if you redistribute 00019 the Apple Software in its entirety and without modifications, you must retain 00020 this notice and the following text and disclaimers in all such redistributions 00021 of the Apple Software. 00022 Neither the name, trademarks, service marks or logos of Apple Inc. may be used 00023 to endorse or promote products derived from the Apple Software without specific 00024 prior written permission from Apple. Except as expressly stated in this notice, 00025 no other rights or licenses, express or implied, are granted by Apple herein, 00026 including but not limited to any patent rights that may be infringed by your 00027 derivative works or by other works in which the Apple Software may be 00028 incorporated. 00029 00030 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 00031 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 00032 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00033 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 00034 COMBINATION WITH YOUR PRODUCTS. 00035 00036 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 00037 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00038 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00039 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR 00040 DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF 00041 CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF 00042 APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00043 00044 Copyright (C) 2010 Apple Inc. All Rights Reserved. 00045 00046 */ 00047 00048 #import <netinet/in.h> 00049 #import <Foundation/Foundation.h> 00050 #import <SystemConfiguration/SystemConfiguration.h> 00051 00052 #define Reachability UA_Reachability 00053 #define NetworkStatus UA_NetworkStatus 00054 00055 typedef enum { 00056 UA_NotReachable = 0, 00057 UA_ReachableViaWiFi, 00058 UA_ReachableViaWWAN 00059 } NetworkStatus; 00060 #define kUA_ReachabilityChangedNotification @"kNetworkReachabilityChangedNotification" 00061 00062 @interface Reachability: NSObject 00063 { 00064 BOOL localWiFiRef; 00065 SCNetworkReachabilityRef reachabilityRef; 00066 } 00067 00068 //reachabilityWithHostName- Use to check the reachability of a particular host name. 00069 + (Reachability*) reachabilityWithHostName: (NSString*) hostName; 00070 00071 //reachabilityWithAddress- Use to check the reachability of a particular IP address. 00072 + (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress; 00073 00074 //reachabilityForInternetConnection- checks whether the default route is available. 00075 // Should be used by applications that do not connect to a particular host 00076 + (Reachability*) reachabilityForInternetConnection; 00077 00078 //reachabilityForLocalWiFi- checks whether a local wifi connection is available. 00079 + (Reachability*) reachabilityForLocalWiFi; 00080 00081 //Start listening for reachability notifications on the current run loop 00082 - (BOOL) startNotifier; 00083 - (void) stopNotifier; 00084 00085 - (NetworkStatus) currentReachabilityStatus; 00086 //WWAN may be available, but not active until a connection has been established. 00087 //WiFi may require a connection for VPN on Demand. 00088 - (BOOL) connectionRequired; 00089 @end 00090 00091