是否可以获得SSID&应用程序中当前连接的WiFi网络的MAC地址 [英] Is it possible to get the SSID & MAC Address of Currently connected WiFi Network in an App

查看:192
本文介绍了是否可以获得SSID&应用程序中当前连接的WiFi网络的MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来获取我项目中当前连接的WiFi网络的MAC地址和SSID。我使用了 Tony Million的Reachability 来决定用户何时使用WiFi网络并且正在测试 Kenial的NICInfo 只是发现它只提供了iPhone的WiFi MAC地址。虽然这两个项目都以自己的方式帮助很大,但他们并没有完成工作。
我想知道是否有公共API(对于某些Apple App Approval)或某些后门来实现这一点。

I am looking for a way to get both the MAC Adress and the SSID of the currently connected WiFi Network in my project. I have used Tony Million's Reachability to decide when the user is on a WiFi network or not and was testing Kenial's NICInfo only to find out that it only provides the iPhone's WiFi MAC Address. Although both projects helped greatly in there own way, they do not get the job done. I am wondering if there is a public API (for certain Apple App Approval) or some back door to achieve this.

推荐答案

这涉及以下几个方面:


  1. 获取SSID - 这与MAC地址问题无关。为此,请检查以下答案: iPhone获取没有私人图书馆的SSID 。我不知道从其他答案中重新发布代码的礼仪是什么,所以我只是链接。

  1. Getting SSID - This is independent of the MAC address issue. For this, check this SO answer: iPhone get SSID without private library. I don't know what the etiquette is regarding re-posting code from other answers so I'll just link.

获取MAC地址 - 因为大多数网络运营在第3层(被称为,谁会猜到,网络层 - http:// en .wikipedia.org / wiki / OSI_model )和MAC地址位于第2层(数据链路层),您首先需要获取WiFi接口网关的IP地址。只是旁注 - 问题应该被表述为我如何获得当前连接的WiFi网络的SSID和WiFi路由器/网关的MAC地址。任何人,要获得网关地址,请看这个答案:如何在iPhone上获取WIFI网关地址?

Getting MAC address - since the majority of networking operates at Layer 3 (which is called, who would have guessed, the Network Layer - http://en.wikipedia.org/wiki/OSI_model) and the MAC address is at Layer 2 (the Data Link layer) you'll first need to get the IP address of the gateway of the WiFi interface. Just a side note - the question should be phrased as 'How do I get the SSID of the currently connected WiFi network and the MAC address of the WiFi router/gateway'. Anywho, to get the gateway address, see this SO answer: How to get the WIFI gateway address on the iPhone?

一旦有了这个,你需要使用ARP(地址解析)将其转换为MAC地址协议,是所有网络用于将IP地址转换为MAC地址的协议。网络接口不通过IP进行通信,它们通过MAC进行通信,因此这实际上始终在任何地方发生。实际上,在PC / Mac上访问ARP表非常容易。对于iOS,我找到了这个将IP地址转换为MAC地址的答案:获取ARP iPhone / iPad上的桌子

Once you have that, you need to convert it to a MAC address using ARP (Address Resolution Protocol, which is the protocol that all networks use to convert IP addresses to MAC addresses). Network interfaces don't communicate via IP, they communicate via MAC, so this actually happens everywhere, all the time. It's actually pretty easy to access the ARP table on a PC/Mac. For iOS, I found this SO answer to convert an IP address to a MAC address: Getting ARP table on iPhone/iPad

这篇关于是否可以获得SSID&应用程序中当前连接的WiFi网络的MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆