├── example1.png
├── example2.png
├── iOS MAC addr
├── iOS MAC addr.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── project.pbxproj
└── iOS MAC addr
│ ├── MDNS.h
│ ├── ICMP.h
│ ├── AppDelegate.h
│ ├── main.m
│ ├── ARP.h
│ ├── Address.h
│ ├── ViewController.h
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Info.plist
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── ICMP.m
│ ├── AppDelegate.m
│ ├── MDNS.m
│ ├── ViewController.m
│ ├── Address.m
│ ├── Reachability
│ ├── Reachability.h
│ └── Reachability.m
│ └── ARP.m
├── .gitignore
└── README.md
/example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QbsuranAlang/iOSGetMACAddress/HEAD/example1.png
--------------------------------------------------------------------------------
/example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QbsuranAlang/iOSGetMACAddress/HEAD/example2.png
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS X
2 | .DS_Store
3 |
4 | # Xcode
5 | build/
6 | *.pbxuser
7 | !default.pbxuser
8 | *.mode1v3
9 | !default.mode1v3
10 | *.mode2v3
11 | !default.mode2v3
12 | *.perspectivev3
13 | !default.perspectivev3
14 | xcuserdata
15 | *.xccheckout
16 | profile
17 | *.moved-aside
18 | DerivedData
19 | *.hmap
20 | *.xccheckout
21 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/MDNS.h:
--------------------------------------------------------------------------------
1 | //
2 | // MDNS.h
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/3/13.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MDNS : NSObject
12 |
13 | + (nullable NSString *)getMacAddressFromMDNS;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/ICMP.h:
--------------------------------------------------------------------------------
1 | //
2 | // ICMP.h
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ICMP : NSObject
12 |
13 | + (void)sendICMPEchoRequestTo: (nonnull NSString *)ipAddress;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/ARP.h:
--------------------------------------------------------------------------------
1 | //
2 | // ARP.h
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ARP : NSObject
12 |
13 | /**
14 | * @return nil on error, otherwise return mac address
15 | */
16 | + (nullable NSString *)walkMACAddressOf: (nonnull NSString *)ipAddress;
17 |
18 | /**
19 | * @return nil on error, otherwise return mac address
20 | */
21 | + (nullable NSString *)MACAddressOf: (nonnull NSString *)ipAddress;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/Address.h:
--------------------------------------------------------------------------------
1 | //
2 | // Address.h
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | #define DUMMY_MAC_ADDR @"02:00:00:00:00:00"
13 | @interface Address : NSObject
14 |
15 | + (nonnull NSString *)currentIPAddressOf: (nonnull NSString *)device;
16 | + (nullable NSString *)IPv4Ntop: (in_addr_t)addr;
17 | + (in_addr_t)IPv4Pton: (nonnull NSString *)IPAddr;
18 | + (nullable NSString *)linkLayerNtop: (nonnull struct sockaddr_dl *)sdl;
19 | + (BOOL)macAddress: (nonnull NSString *)addr1 isEqualTo:(nonnull NSString *)addr2;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 | @property (weak, nonatomic) IBOutlet UILabel *iosVersionLabel;
13 | - (IBAction)getMacAddress:(id)sender;
14 | @property (weak, nonatomic) IBOutlet UIButton *getAddressButton;
15 |
16 | @property (weak, nonatomic) IBOutlet UILabel *macAddress1Label;
17 | @property (weak, nonatomic) IBOutlet UILabel *macAddress2Label;
18 | @property (weak, nonatomic) IBOutlet UILabel *macAddress3Label;
19 |
20 |
21 |
22 |
23 | @end
24 |
25 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iOSGetMACAddress
2 | iOS another way to get mac address after iOS 7.
3 |
4 | ## Why
5 | Since iOS 7.0, you cannot easily using ```sysctl()``` or ```ioctl()``` to get MAC address(normal way).
6 |
7 |
8 | [Link (the most bottom)](https://developer.apple.com/library/content/releasenotes/General/WhatsNewIniOS/Articles/iOS7.html)
9 |
10 | ```
11 | In iOS 7 and later, if you ask for the MAC address of an iOS device, the system returns the value 02:00:00:00:00:00.
12 | If you need to identify the device, use the identifierForVendor property of UIDevice instead.
13 | (Apps that need an identifier for their own advertising purposes should consider using the advertisingIdentifier property of ASIdentifierManager instead.)
14 | ```
15 |
16 | ## Way1: iOS version is less than or equal to 10.1
17 | 1. Connect to any Wi-Fi.
18 | 2. Get current IP address of Wi-Fi.
19 | 1. Send ICMP echo request(ping) to the IP address.(not the IP address, 127.0.0.1)
20 | 2. Walk whole ARP table to search the MAC address of current IP address of Wi-Fi.
21 | 3. Get your MAC address.
22 |
23 | ## Way2: iOS version is less than or equal to 10.2.1
24 | 1. Connect to any Wi-Fi.
25 | 2. Get current IP address of Wi-Fi.
26 | 1. Send ICMP echo request(ping) to the IP address.(not the IP address, 127.0.0.1)
27 | 2. Get an ARP entry by current IP address of Wi-Fi.
28 | 3. Get your MAC address.
29 |
30 | ## Way3: iOS version is greater than 10.1(or lesser version)
31 | 1. Connect to any Wi-Fi.
32 | 2. Get current IP address of Wi-Fi.
33 | 1. Send MDNS query that question "\_apple-mobdev2.\_tcp.local" with PTR record.
34 | 2. Response data will content MAC address.
35 | 3. Get your MAC address.
36 |
37 | ## Result
38 | Include 2 different iOS version.
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/ICMP.m:
--------------------------------------------------------------------------------
1 | //
2 | // ICMP.m
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import "ICMP.h"
10 | #import
11 | #import
12 | #import
13 | #import "Address.h"
14 | #import
15 |
16 | @implementation ICMP
17 |
18 | static u_int16_t checksum(u_int16_t *data, int len);
19 |
20 | + (void)sendICMPEchoRequestTo: (nonnull NSString *)ipAddress {
21 | int s = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
22 |
23 | if(s < 0) {
24 | perror("socket()");
25 | return;
26 | }//end if
27 |
28 | char buffer[256];
29 | struct icmp *icmp = (struct icmp *)buffer;
30 |
31 | //fill icmp header
32 | memset(buffer, 0, sizeof(buffer));
33 | icmp->icmp_type = ICMP_ECHO;
34 | icmp->icmp_code = 0;
35 | icmp->icmp_seq = arc4random();
36 | icmp->icmp_id = arc4random();
37 | icmp->icmp_cksum = 0;
38 | icmp->icmp_cksum = checksum((u_int16_t *)buffer, sizeof(buffer));
39 |
40 | //fill destination address
41 | struct sockaddr_in dest;
42 | memset(&dest, 0, sizeof(dest));
43 | dest.sin_family = AF_INET;
44 | dest.sin_addr.s_addr = [Address IPv4Pton:ipAddress];
45 | dest.sin_len = sizeof(dest);
46 |
47 | if(sendto(s, buffer, sizeof(buffer), 0, (struct sockaddr *)&dest, sizeof(dest)) < 0) {
48 | perror("sendto()");
49 | }//end if
50 |
51 | close(s);
52 | }//end sendICMPEchoRequestTo:
53 |
54 | static u_int16_t checksum(u_int16_t *data, int len) {
55 | u_int32_t sum = 0;
56 |
57 | for (; len > 1; len -= 2) {
58 | sum += *data++;
59 | if (sum & 0x80000000)
60 | sum = (sum & 0xffff) + (sum >> 16);
61 | }
62 |
63 | if (len == 1) {
64 | u_int16_t i = 0;
65 | *(u_char*) (&i) = *(u_char *) data;
66 | sum += i;
67 | }
68 |
69 | while (sum >> 16)
70 | sum = (sum & 0xffff) + (sum >> 16);
71 |
72 | return ~sum;
73 | }
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/MDNS.m:
--------------------------------------------------------------------------------
1 | //
2 | // MDNS.m
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/3/13.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import "MDNS.h"
10 | #import "Address.h"
11 | #import
12 | #import
13 |
14 | #define MDNS_PORT 5353
15 | #define QUERY_NAME "_apple-mobdev2._tcp.local"
16 | @implementation MDNS
17 |
18 | + (nullable NSString *)getMacAddressFromMDNS {
19 | res_init();
20 |
21 | //get currnet ip address
22 | NSString *ip = [Address currentIPAddressOf:@"en0"];
23 | if(ip == nil) {
24 | fprintf(stderr, "could not get current IP address of en0\n");
25 | return nil;
26 | }//end if
27 |
28 | //set port and destination
29 | _res.nsaddr_list[0].sin_family = AF_INET;
30 | _res.nsaddr_list[0].sin_port = htons(MDNS_PORT);
31 | _res.nsaddr_list[0].sin_addr.s_addr = [Address IPv4Pton:ip];
32 | _res.nscount = 1;
33 |
34 | unsigned char response[NS_PACKETSZ];
35 | int len;
36 | //send mdns query
37 | if((len = res_query(QUERY_NAME, ns_c_in, ns_t_ptr, response, sizeof(response))) < 0) {
38 | fprintf(stderr, "res_search(): %s\n", hstrerror(h_errno));
39 | return nil;
40 | }//end if
41 |
42 | //parse mdns message
43 | ns_msg handle;
44 | if(ns_initparse(response, len, &handle) < 0) {
45 | fprintf(stderr, "ns_initparse(): %s\n", hstrerror(h_errno));
46 | return nil;
47 | }//end if
48 |
49 | //get answer length
50 | len = ns_msg_count(handle, ns_s_an);
51 | if(len < 0) {
52 | fprintf(stderr, "ns_msg_count return zero\n");
53 | return nil;
54 | }//end if
55 |
56 | //try to get mac address from data
57 | NSString *macAddress = nil;
58 | for(int i = 0 ; i < len ; i++) {
59 | ns_rr rr;
60 | ns_parserr(&handle, ns_s_an, 0, &rr);
61 |
62 | if(ns_rr_class(rr) == ns_c_in &&
63 | ns_rr_type(rr) == ns_t_ptr &&
64 | !strcmp(ns_rr_name(rr), QUERY_NAME)) {
65 | char *ptr = (char *)(ns_rr_rdata(rr) + 1);
66 | int l = (int)strcspn(ptr, "@");
67 |
68 | char *tmp = calloc(l + 1, sizeof(char));
69 | if(!tmp) {
70 | perror("calloc()");
71 | continue;
72 | }//end if
73 | memcpy(tmp, ptr, l);
74 | macAddress = [NSString stringWithUTF8String:tmp];
75 | free(tmp);
76 | }//end if
77 | }//end for each
78 |
79 | return macAddress;
80 | }//end getMacAddressFromMDNS
81 |
82 | @end
83 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "Reachability.h"
11 | #import "Address.h"
12 | #import "ICMP.h"
13 | #import "ARP.h"
14 | #import "MDNS.h"
15 |
16 | @interface ViewController ()
17 |
18 | @property (nonatomic, strong) Reachability *wifiReachability;
19 |
20 | @end
21 |
22 | @implementation ViewController
23 |
24 | - (void)viewDidLoad {
25 | [super viewDidLoad];
26 | // Do any additional setup after loading the view, typically from a nib.
27 |
28 | _iosVersionLabel.text = [NSString stringWithFormat:@"iOS: %@", [[UIDevice currentDevice] systemVersion]];
29 |
30 | //wifi notification
31 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
32 | _wifiReachability = [Reachability reachabilityForLocalWiFi];
33 | [_wifiReachability startNotifier];
34 | [self reachabilityChanged:nil];
35 | }
36 |
37 |
38 | - (void)didReceiveMemoryWarning {
39 | [super didReceiveMemoryWarning];
40 | // Dispose of any resources that can be recreated.
41 | }
42 |
43 | - (void)dealloc {
44 | [_wifiReachability stopNotifier];
45 | }
46 |
47 | - (void) reachabilityChanged:(NSNotification *)note {
48 | if(self.wifiReachability.currentReachabilityStatus == NotReachable) {
49 | [_getAddressButton setTitle:@"No Wi-Fi Connection" forState:UIControlStateNormal];
50 | [_getAddressButton setEnabled:NO];
51 | }//end if
52 | else {
53 | [_getAddressButton setTitle:@"Get MAC Address" forState:UIControlStateNormal];
54 | [_getAddressButton setEnabled:YES];
55 | }//end else
56 | }
57 |
58 | - (IBAction)getMacAddress:(id)sender {
59 | NSString *mac = nil;
60 | NSString *ip = [Address currentIPAddressOf:@"en0"];
61 |
62 | //way 1
63 | [ICMP sendICMPEchoRequestTo:ip];
64 | mac = [ARP walkMACAddressOf:ip];
65 | _macAddress1Label.text = [NSString stringWithFormat:@"(Way1)MAC Address: %@",
66 | mac ? mac : @"Not Found"];
67 |
68 | //way 2
69 | [ICMP sendICMPEchoRequestTo:ip]; //just for way2 regular steps
70 | mac = [ARP MACAddressOf:ip];
71 | _macAddress2Label.text = [NSString stringWithFormat:@"(Way2)MAC Address: %@",
72 | mac ? mac : @"Not Found"];
73 |
74 | //way 3
75 | mac = [MDNS getMacAddressFromMDNS];
76 | _macAddress3Label.text = [NSString stringWithFormat:@"(Way3)MAC Address: %@",
77 | mac ? mac : @"Not Found"];
78 | }
79 | @end
80 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/Address.m:
--------------------------------------------------------------------------------
1 | //
2 | // Address.m
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import "Address.h"
10 | #import
11 | #import
12 | #import
13 | #import
14 |
15 | @implementation Address
16 |
17 | + (nonnull NSString *)currentIPAddressOf: (nonnull NSString *)device {
18 | struct ifaddrs *addrs;
19 | NSString *ipAddress = nil;
20 |
21 | if(getifaddrs(&addrs) != 0) {
22 | return nil;
23 | }//end if
24 |
25 | //get ipv4 address
26 | for(struct ifaddrs *addr = addrs ; addr ; addr = addr->ifa_next) {
27 | if(!strcmp(addr->ifa_name, [device UTF8String])) {
28 | if(addr->ifa_addr) {
29 | struct sockaddr_in *in_addr = (struct sockaddr_in *)addr->ifa_addr;
30 | if(in_addr->sin_family == AF_INET) {
31 | ipAddress = [Address IPv4Ntop:in_addr->sin_addr.s_addr];
32 | break;
33 | }//end if
34 | }//end if
35 | }//end if
36 | }//end for
37 |
38 | freeifaddrs(addrs);
39 | return ipAddress;
40 | }//end currentIPAddressOf:
41 |
42 | + (nullable NSString *)IPv4Ntop: (in_addr_t)addr {
43 | char buffer[INET_ADDRSTRLEN] = {0};
44 | return inet_ntop(AF_INET, &addr, buffer, sizeof(buffer)) ?
45 | [NSString stringWithUTF8String:buffer] : nil;
46 | }//end IPv4Ntop:
47 |
48 | + (in_addr_t)IPv4Pton: (nonnull NSString *)IPAddr {
49 | in_addr_t network = INADDR_NONE;
50 | return inet_pton(AF_INET, [IPAddr UTF8String], &network) == 1 ?
51 | network : INADDR_NONE;
52 | }//end IPv4Pton:
53 |
54 | + (nullable NSString *)linkLayerNtop: (nonnull struct sockaddr_dl *)sdl {
55 | if(sdl->sdl_alen == 0) {
56 | return nil;
57 | }//end if
58 |
59 | NSMutableString *buf = [[NSMutableString alloc] initWithString:@""];
60 | char *cp = (char *)LLADDR(sdl);
61 | int n;
62 |
63 | if ((n = sdl->sdl_alen) > 0) {
64 | while (--n >= 0) {
65 | [buf appendFormat:@"%02x%s", *cp++ & 0xff, n > 0 ? ":" : ""];
66 | }//end if
67 | }//end if
68 |
69 | return [NSString stringWithString:buf];
70 | }//end linkLayerNtop:
71 |
72 | + (BOOL)macAddress: (nonnull NSString *)addr1 isEqualTo:(nonnull NSString *)addr2 {
73 | struct ether_addr ether_addr1, ether_addr2;
74 |
75 | struct ether_addr *tmp;
76 |
77 | tmp = ether_aton(([addr1 UTF8String]));
78 | if(!tmp)
79 | return NO;
80 | memcpy(ðer_addr1, tmp, sizeof(ether_addr1));
81 |
82 | tmp = ether_aton([addr2 UTF8String]);
83 | if(!tmp)
84 | return NO;
85 | memcpy(ðer_addr2, tmp, sizeof(ether_addr2));
86 |
87 | return memcmp(ðer_addr1, ðer_addr2, sizeof(struct ether_addr)) == 0 ? YES : NO;
88 | }//end macAddress: isEqualTo:
89 |
90 | @end
91 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/Reachability/Reachability.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | File: Reachability.h
4 | Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
5 |
6 | Version: 2.2
7 |
8 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
9 | ("Apple") in consideration of your agreement to the following terms, and your
10 | use, installation, modification or redistribution of this Apple software
11 | constitutes acceptance of these terms. If you do not agree with these terms,
12 | please do not use, install, modify or redistribute this Apple software.
13 |
14 | In consideration of your agreement to abide by the following terms, and subject
15 | to these terms, Apple grants you a personal, non-exclusive license, under
16 | Apple's copyrights in this original Apple software (the "Apple Software"), to
17 | use, reproduce, modify and redistribute the Apple Software, with or without
18 | modifications, in source and/or binary forms; provided that if you redistribute
19 | the Apple Software in its entirety and without modifications, you must retain
20 | this notice and the following text and disclaimers in all such redistributions
21 | of the Apple Software.
22 | Neither the name, trademarks, service marks or logos of Apple Inc. may be used
23 | to endorse or promote products derived from the Apple Software without specific
24 | prior written permission from Apple. Except as expressly stated in this notice,
25 | no other rights or licenses, express or implied, are granted by Apple herein,
26 | including but not limited to any patent rights that may be infringed by your
27 | derivative works or by other works in which the Apple Software may be
28 | incorporated.
29 |
30 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
31 | WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
32 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 | PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
34 | COMBINATION WITH YOUR PRODUCTS.
35 |
36 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
37 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 | ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
40 | DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
41 | CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
42 | APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 |
44 | Copyright (C) 2010 Apple Inc. All Rights Reserved.
45 |
46 | */
47 |
48 |
49 | #import
50 | #import
51 | #import
52 |
53 | typedef enum {
54 | NotReachable = 0,
55 | ReachableViaWiFi,
56 | ReachableViaWWAN
57 | } NetworkStatus;
58 | #define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
59 |
60 | @interface Reachability: NSObject
61 | {
62 | BOOL localWiFiRef;
63 | SCNetworkReachabilityRef reachabilityRef;
64 | }
65 |
66 | //reachabilityWithHostName- Use to check the reachability of a particular host name.
67 | + (Reachability*) reachabilityWithHostName: (NSString*) hostName;
68 |
69 | //reachabilityWithAddress- Use to check the reachability of a particular IP address.
70 | + (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
71 |
72 | //reachabilityForInternetConnection- checks whether the default route is available.
73 | // Should be used by applications that do not connect to a particular host
74 | + (Reachability*) reachabilityForInternetConnection;
75 |
76 | //reachabilityForLocalWiFi- checks whether a local wifi connection is available.
77 | + (Reachability*) reachabilityForLocalWiFi;
78 |
79 | //Start listening for reachability notifications on the current run loop
80 | - (BOOL) startNotifier;
81 | - (void) stopNotifier;
82 |
83 | - (NetworkStatus) currentReachabilityStatus;
84 | //WWAN may be available, but not active until a connection has been established.
85 | //WiFi may require a connection for VPN on Demand.
86 | - (BOOL) connectionRequired;
87 | @end
88 |
89 |
90 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/ARP.m:
--------------------------------------------------------------------------------
1 | //
2 | // ARP.m
3 | // iOS MAC addr
4 | //
5 | // Created by TUTU on 2017/2/28.
6 | // Copyright © 2017年 TUTU. All rights reserved.
7 | //
8 |
9 | #import "ARP.h"
10 | #import "Address.h"
11 | #import
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 |
18 |
19 | #ifndef RTF_LLINFO
20 | #define RTF_LLINFO 0x400 /* generated by link layer (e.g. ARP) */
21 | #endif /* RTF_LLINFO */
22 |
23 | #ifndef RTM_GET
24 | #define RTM_GET 0x4 /* Report Metrics */
25 | #endif /* RTM_GET */
26 |
27 | #ifndef RTA_DST
28 | #define RTA_DST 0x1 /* destination sockaddr present */
29 | #endif /* RTA_DST */
30 |
31 | #ifdef RTM_VERSION
32 | #undef RTM_VERSION
33 | #endif /* RTM_VERSION */
34 | #define RTM_VERSION 5 // important, version 2 won't work
35 |
36 | #define BUFLEN (sizeof(struct rt_msghdr) + 512)
37 |
38 | /* copy from net/route.h */
39 | #ifndef _NET_ROUTE_H_
40 | /*
41 | * These numbers are used by reliable protocols for determining
42 | * retransmission behavior and are included in the routing structure.
43 | */
44 | struct rt_metrics {
45 | u_int32_t rmx_locks; /* Kernel leaves these values alone */
46 | u_int32_t rmx_mtu; /* MTU for this path */
47 | u_int32_t rmx_hopcount; /* max hops expected */
48 | int32_t rmx_expire; /* lifetime for route, e.g. redirect */
49 | u_int32_t rmx_recvpipe; /* inbound delay-bandwidth product */
50 | u_int32_t rmx_sendpipe; /* outbound delay-bandwidth product */
51 | u_int32_t rmx_ssthresh; /* outbound gateway buffer limit */
52 | u_int32_t rmx_rtt; /* estimated round trip time */
53 | u_int32_t rmx_rttvar; /* estimated rtt variance */
54 | u_int32_t rmx_pksent; /* packets sent using this route */
55 | u_int32_t rmx_filler[4]; /* will be used for T/TCP later */
56 | };
57 |
58 | /*
59 | * Structures for routing messages.
60 | */
61 | struct rt_msghdr {
62 | u_short rtm_msglen; /* to skip over non-understood messages */
63 | u_char rtm_version; /* future binary compatibility */
64 | u_char rtm_type; /* message type */
65 | u_short rtm_index; /* index for associated ifp */
66 | int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
67 | int rtm_addrs; /* bitmask identifying sockaddrs in msg */
68 | pid_t rtm_pid; /* identify sender */
69 | int rtm_seq; /* for sender to identify action */
70 | int rtm_errno; /* why failed */
71 | int rtm_use; /* from rtentry */
72 | u_int32_t rtm_inits; /* which metrics we are initializing */
73 | struct rt_metrics rtm_rmx; /* metrics themselves */
74 | };
75 | #endif /* _NET_ROUTE_H_ */
76 |
77 | /* copy from netinet/if_ether.h */
78 | #ifndef _NETINET_IF_ETHER_H_
79 | struct sockaddr_inarp {
80 | u_char sin_len;
81 | u_char sin_family;
82 | u_short sin_port;
83 | struct in_addr sin_addr;
84 | struct in_addr sin_srcaddr;
85 | u_short sin_tos;
86 | u_short sin_other;
87 | #define SIN_PROXY 0x1
88 | #define SIN_ROUTER 0x2
89 | };
90 | #endif /* _NETINET_IF_ETHER_H_ */
91 |
92 | #ifndef SA_SIZE
93 | #define SA_SIZE(sa) \
94 | ( (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ? \
95 | sizeof(uint32_t) : \
96 | 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(uint32_t) - 1) ) )
97 | #endif
98 |
99 | @implementation ARP
100 |
101 | + (nullable NSString *)walkMACAddressOf: (nonnull NSString *)ipAddress {
102 | int mib[6];
103 | size_t needed;
104 | char *lim, *buf, *newbuf, *next;
105 | struct rt_msghdr *rtm;
106 | struct sockaddr_inarp *sin2;
107 | struct sockaddr_dl *sdl;
108 | int st;
109 |
110 | mib[0] = CTL_NET;
111 | mib[1] = PF_ROUTE;
112 | mib[2] = 0;
113 | mib[3] = AF_INET;
114 | mib[4] = NET_RT_FLAGS;
115 | mib[5] = RTF_LLINFO;
116 | if(sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
117 | perror("sysctl()");
118 | return nil;
119 | }//end if
120 |
121 | if(needed == 0) { /* empty table */
122 | return nil;
123 | }
124 |
125 | buf = NULL;
126 | for(;;) {
127 | newbuf = realloc(buf, needed);
128 | if(newbuf == NULL) {
129 | perror("realloc()");
130 | if(buf != NULL) {
131 | free(buf);
132 | }//end if
133 | return nil;
134 | }//end if
135 | buf = newbuf;
136 | st = sysctl(mib, 6, buf, &needed, NULL, 0);
137 | if(st == 0 || errno != ENOMEM)
138 | break;
139 | needed += needed / 8;
140 | }//end for
141 |
142 | NSString *macAddress = nil;
143 | in_addr_t searchIpAddress = [Address IPv4Pton:ipAddress];
144 |
145 | lim = buf + needed;
146 | for(next = buf; next < lim; next += rtm->rtm_msglen) {
147 | rtm = (struct rt_msghdr *)next;
148 | sin2 = (struct sockaddr_inarp *)(rtm + 1);
149 | sdl = (struct sockaddr_dl *)((char *)sin2 + SA_SIZE(sin2));
150 | if(searchIpAddress == sin2->sin_addr.s_addr) {
151 | macAddress = [Address linkLayerNtop:sdl];
152 | break;
153 | }//end if found
154 | }//end for
155 | free(buf);
156 |
157 | return macAddress;
158 | }//end walkMACAddressOf:
159 |
160 | + (nullable NSString *)MACAddressOf: (nonnull NSString *)ipAddress {
161 | static int seq = 0;
162 | int sockfd = socket(AF_ROUTE, SOCK_RAW, 0);
163 | if(sockfd < 0) {
164 | perror("socket()");
165 | return nil;
166 | }//end if
167 |
168 | unsigned char buf[BUFLEN];
169 |
170 | //rtm message buffer
171 | memset(buf, 0, sizeof(buf));
172 | struct rt_msghdr *rtm = (struct rt_msghdr *)buf;
173 | rtm->rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
174 | rtm->rtm_version = RTM_VERSION;
175 | rtm->rtm_type = RTM_GET;
176 | rtm->rtm_addrs = RTA_DST;
177 | rtm->rtm_flags = RTF_LLINFO;
178 | rtm->rtm_pid = getpid();
179 | rtm->rtm_seq = ++seq;
180 |
181 | //socket address
182 | struct sockaddr_in *sin = (struct sockaddr_in *)(rtm + 1);
183 | sin->sin_len = sizeof(struct sockaddr_in);
184 | sin->sin_family = AF_INET;
185 | sin->sin_addr.s_addr = [Address IPv4Pton:ipAddress];
186 |
187 | //send message
188 | write(sockfd, rtm, rtm->rtm_msglen);
189 |
190 | ssize_t n = read(sockfd, buf, BUFLEN);
191 | close(sockfd);
192 |
193 | if(n < 0) {
194 | perror("read()");
195 | return nil;
196 | }//end if
197 |
198 | NSString *macAddress = nil;
199 | if (n != 0) {
200 | struct sockaddr_dl *sdl = (struct sockaddr_dl *)(buf + sizeof(struct rt_msghdr) + sizeof(struct sockaddr_inarp));
201 | macAddress = [Address linkLayerNtop:sdl];
202 | }//end if
203 | return macAddress;
204 | }//end MACAddressOf:
205 |
206 | @end
207 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
30 |
36 |
43 |
49 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr/Reachability/Reachability.m:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | File: Reachability.m
4 | Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
5 |
6 | Version: 2.2
7 |
8 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
9 | ("Apple") in consideration of your agreement to the following terms, and your
10 | use, installation, modification or redistribution of this Apple software
11 | constitutes acceptance of these terms. If you do not agree with these terms,
12 | please do not use, install, modify or redistribute this Apple software.
13 |
14 | In consideration of your agreement to abide by the following terms, and subject
15 | to these terms, Apple grants you a personal, non-exclusive license, under
16 | Apple's copyrights in this original Apple software (the "Apple Software"), to
17 | use, reproduce, modify and redistribute the Apple Software, with or without
18 | modifications, in source and/or binary forms; provided that if you redistribute
19 | the Apple Software in its entirety and without modifications, you must retain
20 | this notice and the following text and disclaimers in all such redistributions
21 | of the Apple Software.
22 | Neither the name, trademarks, service marks or logos of Apple Inc. may be used
23 | to endorse or promote products derived from the Apple Software without specific
24 | prior written permission from Apple. Except as expressly stated in this notice,
25 | no other rights or licenses, express or implied, are granted by Apple herein,
26 | including but not limited to any patent rights that may be infringed by your
27 | derivative works or by other works in which the Apple Software may be
28 | incorporated.
29 |
30 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
31 | WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
32 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 | PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
34 | COMBINATION WITH YOUR PRODUCTS.
35 |
36 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
37 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 | ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
40 | DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
41 | CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
42 | APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 |
44 | Copyright (C) 2010 Apple Inc. All Rights Reserved.
45 |
46 | */
47 |
48 | #import
49 | #import
50 | #import
51 | #import
52 | #import
53 | #import
54 |
55 | #import
56 |
57 | #import "Reachability.h"
58 |
59 | #define kShouldPrintReachabilityFlags 0
60 |
61 | static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
62 | {
63 | #if kShouldPrintReachabilityFlags
64 |
65 | NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
66 | (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
67 | (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
68 |
69 | (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
70 | (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
71 | (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
72 | (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
73 | (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
74 | (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
75 | (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
76 | comment
77 | );
78 | #endif
79 | }
80 |
81 |
82 | @implementation Reachability
83 | static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
84 | {
85 | #pragma unused (target, flags)
86 | NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
87 | NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
88 |
89 | //We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
90 | // in case someon uses the Reachablity object in a different thread.
91 | NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
92 |
93 | Reachability* noteObject = (Reachability*) info;
94 | // Post a notification to notify the client that the network reachability changed.
95 | [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject];
96 |
97 | [myPool release];
98 | }
99 |
100 | - (BOOL) startNotifier
101 | {
102 | BOOL retVal = NO;
103 | SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL};
104 | if(SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context))
105 | {
106 | if(SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode))
107 | {
108 | retVal = YES;
109 | }
110 | }
111 | return retVal;
112 | }
113 |
114 | - (void) stopNotifier
115 | {
116 | if(reachabilityRef!= NULL)
117 | {
118 | SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
119 | }
120 | }
121 |
122 | - (void) dealloc
123 | {
124 | [self stopNotifier];
125 | if(reachabilityRef!= NULL)
126 | {
127 | CFRelease(reachabilityRef);
128 | }
129 | [super dealloc];
130 | }
131 |
132 | + (Reachability*) reachabilityWithHostName: (NSString*) hostName;
133 | {
134 | Reachability* retVal = NULL;
135 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
136 | if(reachability!= NULL)
137 | {
138 | retVal= [[[self alloc] init] autorelease];
139 | if(retVal!= NULL)
140 | {
141 | retVal->reachabilityRef = reachability;
142 | retVal->localWiFiRef = NO;
143 | }
144 | }
145 | return retVal;
146 | }
147 |
148 | + (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
149 | {
150 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
151 | Reachability* retVal = NULL;
152 | if(reachability!= NULL)
153 | {
154 | retVal= [[[self alloc] init] autorelease];
155 | if(retVal!= NULL)
156 | {
157 | retVal->reachabilityRef = reachability;
158 | retVal->localWiFiRef = NO;
159 | }
160 | }
161 | return retVal;
162 | }
163 |
164 | + (Reachability*) reachabilityForInternetConnection;
165 | {
166 | struct sockaddr_in zeroAddress;
167 | bzero(&zeroAddress, sizeof(zeroAddress));
168 | zeroAddress.sin_len = sizeof(zeroAddress);
169 | zeroAddress.sin_family = AF_INET;
170 | return [self reachabilityWithAddress: &zeroAddress];
171 | }
172 |
173 | + (Reachability*) reachabilityForLocalWiFi;
174 | {
175 | struct sockaddr_in localWifiAddress;
176 | bzero(&localWifiAddress, sizeof(localWifiAddress));
177 | localWifiAddress.sin_len = sizeof(localWifiAddress);
178 | localWifiAddress.sin_family = AF_INET;
179 | // IN_LINKLOCALNETNUM is defined in as 169.254.0.0
180 | localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
181 | Reachability* retVal = [self reachabilityWithAddress: &localWifiAddress];
182 | if(retVal!= NULL)
183 | {
184 | retVal->localWiFiRef = YES;
185 | }
186 | return retVal;
187 | }
188 |
189 | #pragma mark Network Flag Handling
190 |
191 | - (NetworkStatus) localWiFiStatusForFlags: (SCNetworkReachabilityFlags) flags
192 | {
193 | PrintReachabilityFlags(flags, "localWiFiStatusForFlags");
194 |
195 | BOOL retVal = NotReachable;
196 | if((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect))
197 | {
198 | retVal = ReachableViaWiFi;
199 | }
200 | return retVal;
201 | }
202 |
203 | - (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags
204 | {
205 | PrintReachabilityFlags(flags, "networkStatusForFlags");
206 | if ((flags & kSCNetworkReachabilityFlagsReachable) == 0)
207 | {
208 | // if target host is not reachable
209 | return NotReachable;
210 | }
211 |
212 | BOOL retVal = NotReachable;
213 |
214 | if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
215 | {
216 | // if target host is reachable and no connection is required
217 | // then we'll assume (for now) that your on Wi-Fi
218 | retVal = ReachableViaWiFi;
219 | }
220 |
221 |
222 | if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||
223 | (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
224 | {
225 | // ... and the connection is on-demand (or on-traffic) if the
226 | // calling application is using the CFSocketStream or higher APIs
227 |
228 | if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
229 | {
230 | // ... and no [user] intervention is needed
231 | retVal = ReachableViaWiFi;
232 | }
233 | }
234 |
235 | if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
236 | {
237 | // ... but WWAN connections are OK if the calling application
238 | // is using the CFNetwork (CFSocketStream?) APIs.
239 | retVal = ReachableViaWWAN;
240 | }
241 | return retVal;
242 | }
243 |
244 | - (BOOL) connectionRequired;
245 | {
246 | NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
247 | SCNetworkReachabilityFlags flags;
248 | if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
249 | {
250 | return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
251 | }
252 | return NO;
253 | }
254 |
255 | - (NetworkStatus) currentReachabilityStatus
256 | {
257 | NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
258 | NetworkStatus retVal = NotReachable;
259 | SCNetworkReachabilityFlags flags;
260 | if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
261 | {
262 | if(localWiFiRef)
263 | {
264 | retVal = [self localWiFiStatusForFlags: flags];
265 | }
266 | else
267 | {
268 | retVal = [self networkStatusForFlags: flags];
269 | }
270 | }
271 | return retVal;
272 | }
273 | @end
274 |
--------------------------------------------------------------------------------
/iOS MAC addr/iOS MAC addr.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | D715C2301E6582B800AC8829 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D715C22F1E6582B800AC8829 /* main.m */; };
11 | D715C2331E6582B800AC8829 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D715C2321E6582B800AC8829 /* AppDelegate.m */; };
12 | D715C2361E6582B800AC8829 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D715C2351E6582B800AC8829 /* ViewController.m */; };
13 | D715C2391E6582B800AC8829 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D715C2371E6582B800AC8829 /* Main.storyboard */; };
14 | D715C23B1E6582B800AC8829 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D715C23A1E6582B800AC8829 /* Assets.xcassets */; };
15 | D715C23E1E6582B800AC8829 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D715C23C1E6582B800AC8829 /* LaunchScreen.storyboard */; };
16 | D715C2481E65844300AC8829 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = D715C2471E65844300AC8829 /* Reachability.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
17 | D715C24C1E65865300AC8829 /* ICMP.m in Sources */ = {isa = PBXBuildFile; fileRef = D715C24B1E65865300AC8829 /* ICMP.m */; };
18 | D715C24F1E65868000AC8829 /* Address.m in Sources */ = {isa = PBXBuildFile; fileRef = D715C24E1E65868000AC8829 /* Address.m */; };
19 | D715C2551E658A8C00AC8829 /* ARP.m in Sources */ = {isa = PBXBuildFile; fileRef = D715C2541E658A8C00AC8829 /* ARP.m */; };
20 | D7D0769A1E76B2A8002A2060 /* MDNS.m in Sources */ = {isa = PBXBuildFile; fileRef = D7D076991E76B2A8002A2060 /* MDNS.m */; };
21 | /* End PBXBuildFile section */
22 |
23 | /* Begin PBXFileReference section */
24 | D715C22B1E6582B800AC8829 /* iOS MAC addr.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS MAC addr.app"; sourceTree = BUILT_PRODUCTS_DIR; };
25 | D715C22F1E6582B800AC8829 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
26 | D715C2311E6582B800AC8829 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
27 | D715C2321E6582B800AC8829 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
28 | D715C2341E6582B800AC8829 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
29 | D715C2351E6582B800AC8829 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
30 | D715C2381E6582B800AC8829 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
31 | D715C23A1E6582B800AC8829 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
32 | D715C23D1E6582B800AC8829 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
33 | D715C23F1E6582B800AC8829 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
34 | D715C2461E65844300AC8829 /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = ""; };
35 | D715C2471E65844300AC8829 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = ""; };
36 | D715C24A1E65865300AC8829 /* ICMP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ICMP.h; sourceTree = ""; };
37 | D715C24B1E65865300AC8829 /* ICMP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ICMP.m; sourceTree = ""; };
38 | D715C24D1E65868000AC8829 /* Address.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Address.h; sourceTree = ""; };
39 | D715C24E1E65868000AC8829 /* Address.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Address.m; sourceTree = ""; };
40 | D715C2531E658A8C00AC8829 /* ARP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARP.h; sourceTree = ""; };
41 | D715C2541E658A8C00AC8829 /* ARP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARP.m; sourceTree = ""; };
42 | D7D076981E76B2A8002A2060 /* MDNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MDNS.h; sourceTree = ""; };
43 | D7D076991E76B2A8002A2060 /* MDNS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MDNS.m; sourceTree = ""; };
44 | /* End PBXFileReference section */
45 |
46 | /* Begin PBXFrameworksBuildPhase section */
47 | D715C2281E6582B800AC8829 /* Frameworks */ = {
48 | isa = PBXFrameworksBuildPhase;
49 | buildActionMask = 2147483647;
50 | files = (
51 | );
52 | runOnlyForDeploymentPostprocessing = 0;
53 | };
54 | /* End PBXFrameworksBuildPhase section */
55 |
56 | /* Begin PBXGroup section */
57 | D715C2221E6582B800AC8829 = {
58 | isa = PBXGroup;
59 | children = (
60 | D715C22D1E6582B800AC8829 /* iOS MAC addr */,
61 | D715C22C1E6582B800AC8829 /* Products */,
62 | );
63 | sourceTree = "";
64 | };
65 | D715C22C1E6582B800AC8829 /* Products */ = {
66 | isa = PBXGroup;
67 | children = (
68 | D715C22B1E6582B800AC8829 /* iOS MAC addr.app */,
69 | );
70 | name = Products;
71 | sourceTree = "";
72 | };
73 | D715C22D1E6582B800AC8829 /* iOS MAC addr */ = {
74 | isa = PBXGroup;
75 | children = (
76 | D715C2451E65844300AC8829 /* Reachability */,
77 | D715C2311E6582B800AC8829 /* AppDelegate.h */,
78 | D715C2321E6582B800AC8829 /* AppDelegate.m */,
79 | D715C2341E6582B800AC8829 /* ViewController.h */,
80 | D715C2351E6582B800AC8829 /* ViewController.m */,
81 | D715C2371E6582B800AC8829 /* Main.storyboard */,
82 | D715C23A1E6582B800AC8829 /* Assets.xcassets */,
83 | D715C23C1E6582B800AC8829 /* LaunchScreen.storyboard */,
84 | D715C23F1E6582B800AC8829 /* Info.plist */,
85 | D715C22E1E6582B800AC8829 /* Supporting Files */,
86 | D715C24A1E65865300AC8829 /* ICMP.h */,
87 | D715C24B1E65865300AC8829 /* ICMP.m */,
88 | D715C24D1E65868000AC8829 /* Address.h */,
89 | D715C24E1E65868000AC8829 /* Address.m */,
90 | D715C2531E658A8C00AC8829 /* ARP.h */,
91 | D715C2541E658A8C00AC8829 /* ARP.m */,
92 | D7D076981E76B2A8002A2060 /* MDNS.h */,
93 | D7D076991E76B2A8002A2060 /* MDNS.m */,
94 | );
95 | path = "iOS MAC addr";
96 | sourceTree = "";
97 | };
98 | D715C22E1E6582B800AC8829 /* Supporting Files */ = {
99 | isa = PBXGroup;
100 | children = (
101 | D715C22F1E6582B800AC8829 /* main.m */,
102 | );
103 | name = "Supporting Files";
104 | sourceTree = "";
105 | };
106 | D715C2451E65844300AC8829 /* Reachability */ = {
107 | isa = PBXGroup;
108 | children = (
109 | D715C2461E65844300AC8829 /* Reachability.h */,
110 | D715C2471E65844300AC8829 /* Reachability.m */,
111 | );
112 | path = Reachability;
113 | sourceTree = "";
114 | };
115 | /* End PBXGroup section */
116 |
117 | /* Begin PBXNativeTarget section */
118 | D715C22A1E6582B800AC8829 /* iOS MAC addr */ = {
119 | isa = PBXNativeTarget;
120 | buildConfigurationList = D715C2421E6582B800AC8829 /* Build configuration list for PBXNativeTarget "iOS MAC addr" */;
121 | buildPhases = (
122 | D715C2271E6582B800AC8829 /* Sources */,
123 | D715C2281E6582B800AC8829 /* Frameworks */,
124 | D715C2291E6582B800AC8829 /* Resources */,
125 | );
126 | buildRules = (
127 | );
128 | dependencies = (
129 | );
130 | name = "iOS MAC addr";
131 | productName = "iOS MAC addr";
132 | productReference = D715C22B1E6582B800AC8829 /* iOS MAC addr.app */;
133 | productType = "com.apple.product-type.application";
134 | };
135 | /* End PBXNativeTarget section */
136 |
137 | /* Begin PBXProject section */
138 | D715C2231E6582B800AC8829 /* Project object */ = {
139 | isa = PBXProject;
140 | attributes = {
141 | LastUpgradeCheck = 0820;
142 | ORGANIZATIONNAME = TUTU;
143 | TargetAttributes = {
144 | D715C22A1E6582B800AC8829 = {
145 | CreatedOnToolsVersion = 8.1;
146 | DevelopmentTeam = 88VL98WHS8;
147 | ProvisioningStyle = Automatic;
148 | };
149 | };
150 | };
151 | buildConfigurationList = D715C2261E6582B800AC8829 /* Build configuration list for PBXProject "iOS MAC addr" */;
152 | compatibilityVersion = "Xcode 3.2";
153 | developmentRegion = English;
154 | hasScannedForEncodings = 0;
155 | knownRegions = (
156 | en,
157 | Base,
158 | );
159 | mainGroup = D715C2221E6582B800AC8829;
160 | productRefGroup = D715C22C1E6582B800AC8829 /* Products */;
161 | projectDirPath = "";
162 | projectRoot = "";
163 | targets = (
164 | D715C22A1E6582B800AC8829 /* iOS MAC addr */,
165 | );
166 | };
167 | /* End PBXProject section */
168 |
169 | /* Begin PBXResourcesBuildPhase section */
170 | D715C2291E6582B800AC8829 /* Resources */ = {
171 | isa = PBXResourcesBuildPhase;
172 | buildActionMask = 2147483647;
173 | files = (
174 | D715C23E1E6582B800AC8829 /* LaunchScreen.storyboard in Resources */,
175 | D715C23B1E6582B800AC8829 /* Assets.xcassets in Resources */,
176 | D715C2391E6582B800AC8829 /* Main.storyboard in Resources */,
177 | );
178 | runOnlyForDeploymentPostprocessing = 0;
179 | };
180 | /* End PBXResourcesBuildPhase section */
181 |
182 | /* Begin PBXSourcesBuildPhase section */
183 | D715C2271E6582B800AC8829 /* Sources */ = {
184 | isa = PBXSourcesBuildPhase;
185 | buildActionMask = 2147483647;
186 | files = (
187 | D715C24F1E65868000AC8829 /* Address.m in Sources */,
188 | D715C2551E658A8C00AC8829 /* ARP.m in Sources */,
189 | D715C24C1E65865300AC8829 /* ICMP.m in Sources */,
190 | D7D0769A1E76B2A8002A2060 /* MDNS.m in Sources */,
191 | D715C2361E6582B800AC8829 /* ViewController.m in Sources */,
192 | D715C2331E6582B800AC8829 /* AppDelegate.m in Sources */,
193 | D715C2481E65844300AC8829 /* Reachability.m in Sources */,
194 | D715C2301E6582B800AC8829 /* main.m in Sources */,
195 | );
196 | runOnlyForDeploymentPostprocessing = 0;
197 | };
198 | /* End PBXSourcesBuildPhase section */
199 |
200 | /* Begin PBXVariantGroup section */
201 | D715C2371E6582B800AC8829 /* Main.storyboard */ = {
202 | isa = PBXVariantGroup;
203 | children = (
204 | D715C2381E6582B800AC8829 /* Base */,
205 | );
206 | name = Main.storyboard;
207 | sourceTree = "";
208 | };
209 | D715C23C1E6582B800AC8829 /* LaunchScreen.storyboard */ = {
210 | isa = PBXVariantGroup;
211 | children = (
212 | D715C23D1E6582B800AC8829 /* Base */,
213 | );
214 | name = LaunchScreen.storyboard;
215 | sourceTree = "";
216 | };
217 | /* End PBXVariantGroup section */
218 |
219 | /* Begin XCBuildConfiguration section */
220 | D715C2401E6582B800AC8829 /* Debug */ = {
221 | isa = XCBuildConfiguration;
222 | buildSettings = {
223 | ALWAYS_SEARCH_USER_PATHS = NO;
224 | CLANG_ANALYZER_NONNULL = YES;
225 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
226 | CLANG_CXX_LIBRARY = "libc++";
227 | CLANG_ENABLE_MODULES = YES;
228 | CLANG_ENABLE_OBJC_ARC = YES;
229 | CLANG_WARN_BOOL_CONVERSION = YES;
230 | CLANG_WARN_CONSTANT_CONVERSION = YES;
231 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
232 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
233 | CLANG_WARN_EMPTY_BODY = YES;
234 | CLANG_WARN_ENUM_CONVERSION = YES;
235 | CLANG_WARN_INFINITE_RECURSION = YES;
236 | CLANG_WARN_INT_CONVERSION = YES;
237 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
238 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
239 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
240 | CLANG_WARN_UNREACHABLE_CODE = YES;
241 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
242 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
243 | COPY_PHASE_STRIP = NO;
244 | DEBUG_INFORMATION_FORMAT = dwarf;
245 | ENABLE_STRICT_OBJC_MSGSEND = YES;
246 | ENABLE_TESTABILITY = YES;
247 | GCC_C_LANGUAGE_STANDARD = gnu99;
248 | GCC_DYNAMIC_NO_PIC = NO;
249 | GCC_NO_COMMON_BLOCKS = YES;
250 | GCC_OPTIMIZATION_LEVEL = 0;
251 | GCC_PREPROCESSOR_DEFINITIONS = (
252 | "DEBUG=1",
253 | "$(inherited)",
254 | );
255 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
256 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
257 | GCC_WARN_UNDECLARED_SELECTOR = YES;
258 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
259 | GCC_WARN_UNUSED_FUNCTION = YES;
260 | GCC_WARN_UNUSED_VARIABLE = YES;
261 | IPHONEOS_DEPLOYMENT_TARGET = 10.1;
262 | MTL_ENABLE_DEBUG_INFO = YES;
263 | ONLY_ACTIVE_ARCH = YES;
264 | SDKROOT = iphoneos;
265 | TARGETED_DEVICE_FAMILY = "1,2";
266 | };
267 | name = Debug;
268 | };
269 | D715C2411E6582B800AC8829 /* Release */ = {
270 | isa = XCBuildConfiguration;
271 | buildSettings = {
272 | ALWAYS_SEARCH_USER_PATHS = NO;
273 | CLANG_ANALYZER_NONNULL = YES;
274 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
275 | CLANG_CXX_LIBRARY = "libc++";
276 | CLANG_ENABLE_MODULES = YES;
277 | CLANG_ENABLE_OBJC_ARC = YES;
278 | CLANG_WARN_BOOL_CONVERSION = YES;
279 | CLANG_WARN_CONSTANT_CONVERSION = YES;
280 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
281 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
282 | CLANG_WARN_EMPTY_BODY = YES;
283 | CLANG_WARN_ENUM_CONVERSION = YES;
284 | CLANG_WARN_INFINITE_RECURSION = YES;
285 | CLANG_WARN_INT_CONVERSION = YES;
286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
287 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
288 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
289 | CLANG_WARN_UNREACHABLE_CODE = YES;
290 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
291 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
292 | COPY_PHASE_STRIP = NO;
293 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
294 | ENABLE_NS_ASSERTIONS = NO;
295 | ENABLE_STRICT_OBJC_MSGSEND = YES;
296 | GCC_C_LANGUAGE_STANDARD = gnu99;
297 | GCC_NO_COMMON_BLOCKS = YES;
298 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
299 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
300 | GCC_WARN_UNDECLARED_SELECTOR = YES;
301 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
302 | GCC_WARN_UNUSED_FUNCTION = YES;
303 | GCC_WARN_UNUSED_VARIABLE = YES;
304 | IPHONEOS_DEPLOYMENT_TARGET = 10.1;
305 | MTL_ENABLE_DEBUG_INFO = NO;
306 | SDKROOT = iphoneos;
307 | TARGETED_DEVICE_FAMILY = "1,2";
308 | VALIDATE_PRODUCT = YES;
309 | };
310 | name = Release;
311 | };
312 | D715C2431E6582B800AC8829 /* Debug */ = {
313 | isa = XCBuildConfiguration;
314 | buildSettings = {
315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
316 | DEVELOPMENT_TEAM = 88VL98WHS8;
317 | INFOPLIST_FILE = "iOS MAC addr/Info.plist";
318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
319 | OTHER_LDFLAGS = "-lresolv";
320 | PRODUCT_BUNDLE_IDENTIFIER = "com.TUTU.iOS-MAC-addr";
321 | PRODUCT_NAME = "$(TARGET_NAME)";
322 | };
323 | name = Debug;
324 | };
325 | D715C2441E6582B800AC8829 /* Release */ = {
326 | isa = XCBuildConfiguration;
327 | buildSettings = {
328 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
329 | DEVELOPMENT_TEAM = 88VL98WHS8;
330 | INFOPLIST_FILE = "iOS MAC addr/Info.plist";
331 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
332 | OTHER_LDFLAGS = "-lresolv";
333 | PRODUCT_BUNDLE_IDENTIFIER = "com.TUTU.iOS-MAC-addr";
334 | PRODUCT_NAME = "$(TARGET_NAME)";
335 | };
336 | name = Release;
337 | };
338 | /* End XCBuildConfiguration section */
339 |
340 | /* Begin XCConfigurationList section */
341 | D715C2261E6582B800AC8829 /* Build configuration list for PBXProject "iOS MAC addr" */ = {
342 | isa = XCConfigurationList;
343 | buildConfigurations = (
344 | D715C2401E6582B800AC8829 /* Debug */,
345 | D715C2411E6582B800AC8829 /* Release */,
346 | );
347 | defaultConfigurationIsVisible = 0;
348 | defaultConfigurationName = Release;
349 | };
350 | D715C2421E6582B800AC8829 /* Build configuration list for PBXNativeTarget "iOS MAC addr" */ = {
351 | isa = XCConfigurationList;
352 | buildConfigurations = (
353 | D715C2431E6582B800AC8829 /* Debug */,
354 | D715C2441E6582B800AC8829 /* Release */,
355 | );
356 | defaultConfigurationIsVisible = 0;
357 | defaultConfigurationName = Release;
358 | };
359 | /* End XCConfigurationList section */
360 | };
361 | rootObject = D715C2231E6582B800AC8829 /* Project object */;
362 | }
363 |
--------------------------------------------------------------------------------