简体   繁体   English

如何在 Xamarin.Forms 中获取连接移动数据的客户端设备的 MAC 地址?

[英]How to get MAC address of a client device with connect mobile data in Xamarin.Forms?

In my client-server-solution I need the MAC addresses of frontend devices, running my Xamarin.Forms app.在我的客户端-服务器-解决方案中,我需要前端设备的 MAC 地址,运行我的 Xamarin.Forms 应用程序。 Currently I just have get Mac Address connected by Wifi is correct in info about device.目前,我刚刚通过Wifi连接的 Mac 地址在有关设备的信息中是正确的。 But, I used mobile data then get Mac Address in device not correct.但是,我使用mobile data然后在设备中获取的 Mac 地址不正确。

var lstAllNetWorkInfaces = NetworkInterface.GetAllNetworkInterfaces();
                        var ni = lstAllNetWorkInfaces.FirstOrDefault(intf => (intf.OperationalStatus == OperationalStatus.Up)
                                                             && (intf.NetworkInterfaceType == NetworkInterfaceType.Wireless80211
                                                                 || intf.NetworkInterfaceType == NetworkInterfaceType.Ethernet));
                        var hw = ni.GetPhysicalAddress();
                        physicalWifiAddress = string.Join(":", (from ma in hw.GetAddressBytes() select ma.ToString("X2")).ToArray());

Please let me know if there's a bug or if you found a better solution.请让我知道是否存在错误或您是否找到了更好的解决方案。

" Layer 2 (Data Link) - It provides a reliable signaling link between the mobile station (MS) and the network. Protocol is based on the LAPDm of ISDN " 第 2 层(数据链路) - 它在移动台 (MS) 和网络之间提供可靠的信令链路。协议基于 ISDN 的 LAPDm

Source is Does the OSI model also apply to mobile networks?来源是OSI model 是否也适用于移动网络? . .

So in 2G networks ARP is not used so MAC addresses are not a thing in that scenario.所以在 2G 网络中不使用 ARP,所以 MAC 地址在那种情况下不是一个东西。 You should consider other client authentication method.您应该考虑其他客户端身份验证方法。

I would suggest client side certificates, they work in any device.我建议客户端证书,它们适用于任何设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Xamarin.Forms中获取客户端设备的MAC地址? - How to get MAC address of a client device in Xamarin.Forms? 如何在 Xamarin 形式的代码后面获取 BLE 设备的 mac 地址? - How to get the mac address of BLE device in code behind in Xamarin forms? 如何在Xamarin.Forms中获取以前的数据 - How to get previous data in Xamarin.Forms 如何在Xamarin.Forms项目中连接WebServiceURL? - How to Connect WebServiceURL in Xamarin.Forms project? 如何在 xamarin.forms 中获取 ListView 的子项? - How to get children of the ListView in xamarin.forms? 获取当前的ip-address Xamarin.Forms(跨平台) - Get current ip-address Xamarin.Forms ( Cross Platform) 如何在Xamarin.forms上获取字节[]用于图像 - how to get byte[] for Image on Xamarin.forms 如何在 Xamarin.Forms 中获取连接的 SSID? - How to get the connected SSID in Xamarin.Forms? 移动架构:基于Xamarin:如何创建以数据为中心的移动应用程序? (例如,使用Xamarin.Forms / REST)? - Mobile-Architecture: Based on Xamarin: How to create a data-centric mobile app? (e.g. with Xamarin.Forms/REST)? 如何获取在Xamarin.Forms中的wifi模块上创建的服务器(而非Web服务器)的IP地址,而不是TCP服务器 - How do you get the IP address of a server (not a webserver) but a TCP server created on a wifi module in Xamarin.Forms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM