123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #import <Foundation/Foundation.h>
- #import <SystemConfiguration/SystemConfiguration.h>
- #import <sys/socket.h>
- #import <netinet/in.h>
- #import <netinet6/in6.h>
- #import <arpa/inet.h>
- #import <ifaddrs.h>
- #import <netdb.h>
- #if TARGET_OS_IPHONE
- #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
- #define NEEDS_DISPATCH_RETAIN_RELEASE 0
- #else // iOS 5.X or earlier
- #define NEEDS_DISPATCH_RETAIN_RELEASE 1
- #endif
- #else
- #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
- #define NEEDS_DISPATCH_RETAIN_RELEASE 0
- #else
- #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
- #endif
- #endif
- extern NSString *const kReachabilityChangedNotification;
- typedef enum
- {
-
- NotReachable = 0,
- ReachableViaWiFi = 2,
- ReachableViaWWAN = 1
- } NetworkStatus;
- @class Reachability;
- typedef void (^NetworkReachable)(Reachability * reachability);
- typedef void (^NetworkUnreachable)(Reachability * reachability);
- @interface Reachability : NSObject
- @property (nonatomic, copy) NetworkReachable reachableBlock;
- @property (nonatomic, copy) NetworkUnreachable unreachableBlock;
- @property (nonatomic, assign) BOOL reachableOnWWAN;
- +(Reachability*)reachabilityWithHostname:(NSString*)hostname;
- +(Reachability*)reachabilityForInternetConnection;
- +(Reachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
- +(Reachability*)reachabilityForLocalWiFi;
- -(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
- -(BOOL)startNotifier;
- -(void)stopNotifier;
- -(BOOL)isReachable;
- -(BOOL)isReachableViaWWAN;
- -(BOOL)isReachableViaWiFi;
- -(BOOL)isConnectionRequired;
- -(BOOL)connectionRequired;
- -(BOOL)isConnectionOnDemand;
- -(BOOL)isInterventionRequired;
- -(NetworkStatus)currentReachabilityStatus;
- -(SCNetworkReachabilityFlags)reachabilityFlags;
- -(NSString*)currentReachabilityString;
- -(NSString*)currentReachabilityFlags;
- @end
|