iOS 获得WIFI的MAC地址
来源:互联网 发布:最短路问题的算法例题 编辑:程序博客网 时间:2024/06/14 22:07
调用: [类名 getMacAddress]
e.g. mac = @”02:48:00:00:00:00”
+ (NSString *)getMacAddress{ int mib[6]; size_t len; char *buf; unsigned char *ptr; struct if_msghdr *ifm; struct sockaddr_dl *sdl; mib[0] = CTL_NET; mib[1] = AF_ROUTE; mib[2] = 0; mib[3] = AF_LINK; mib[4] = NET_RT_IFLIST; if ((mib[5] = if_nametoindex("en0")) == 0) { printf("Error: if_nametoindex error/n"); return NULL; } if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) { printf("Error: sysctl, take 1/n"); return NULL; } if ((buf = malloc(len)) == NULL) { printf("Could not allocate memory. error!/n"); return NULL; } if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { printf("Error: sysctl, take 2"); return NULL; } ifm = (struct if_msghdr *)buf; sdl = (struct sockaddr_dl *)(ifm + 1); ptr = (unsigned char *)LLADDR(sdl); NSString *outstring = [NSString stringWithFormat:@"%02x:%02x:%02x:%02x:%02x:%02x", *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)]; free(buf); return [outstring uppercaseString];}
阅读全文
0 0
- iOS 获得WIFI的MAC地址
- iOS上获得MAC地址
- iOS上获得MAC地址
- 获得Mac的地址
- iOS 获取Wifi的SSID及MAC地址
- iOS 获取Wifi的SSID及MAC地址
- iOS 获取Wifi的SSID及MAC地址
- Android 获取WIFI MAC地址的方法
- WiFi设备MAC地址的获取-----安卓端
- WiFi设备MAC地址的获取-----服务器端
- ubuntu 更改wifi的mac地址
- ASP获得网卡的MAC地址
- 获得用户(客户端)的MAC地址
- 获得MAC地址的四个方法
- 获得MAC地址的四个方法
- 获得MAC地址的四个方法
- 用VB获得机器的MAC地址
- 用Winpcap获得网卡的MAC地址
- 进程与线程的一个简单解释
- AIML技术
- 解决shell中(php thinker)方向键 ^[[A ^[[B 以及小键盘不能用情况
- Oracle函数Rank
- 当已经安装了anaconda2可不可以让anaconda3与2共存
- iOS 获得WIFI的MAC地址
- 如何做出实用而强大的数据地图?
- 字符串相加
- Win7迅雷影音播放器右键菜单的字幕选项是灰色的解决方法
- cipher工具彻底删除硬盘文件方法介绍
- docker简单操作
- MySQL的语句执行顺序
- protel四层板及内电层分割入门
- java servlet 几种页面跳转的方法