Skip to content
This repository was archived by the owner on Jan 17, 2023. It is now read-only.

Added support for IPv6 to Reachability #3174

Merged
merged 3 commits into from
Nov 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AFNetworking/AFNetworkReachabilityManager.h
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
Creates and returns a network reachability manager for the socket address.
@param address The socket address (`sockaddr_in`) used to evaluate network reachability.
@param address The socket address (`sockaddr_in6`) used to evaluate network reachability.
@return An initialized network reachability manager, actively monitoring the specified socket address.
*/
7 changes: 7 additions & 0 deletions AFNetworking/AFNetworkReachabilityManager.m
Original file line number Diff line number Diff line change
@@ -144,10 +144,17 @@ + (instancetype)managerForAddress:(const void *)address {

+ (instancetype)manager
{
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
struct sockaddr_in6 address;
bzero(&address, sizeof(address));
address.sin6_len = sizeof(address);
address.sin6_family = AF_INET6;
#else
struct sockaddr_in address;
bzero(&address, sizeof(address));
address.sin_len = sizeof(address);
address.sin_family = AF_INET;
#endif
return [self managerForAddress:&address];
}

9 changes: 1 addition & 8 deletions Tests/Tests/AFNetworkReachabilityManagerTests.m
Original file line number Diff line number Diff line change
@@ -36,14 +36,7 @@ - (void)setUp {

//both of these manager objects should always be reachable when the tests are run
self.domainReachability = [AFNetworkReachabilityManager managerForDomain:@"localhost"];

//don't use the shared manager because it retains state between tests
//but recreate it each time in the same way that the shared manager is created
struct sockaddr_in address;
bzero(&address, sizeof(address));
address.sin_len = sizeof(address);
address.sin_family = AF_INET;
self.addressReachability = [AFNetworkReachabilityManager managerForAddress:&address];
self.addressReachability = [AFNetworkReachabilityManager manager];
}

- (void)tearDown