查找Android设备上IPv6全局范围地址 [英] Find IPv6 global scope address on Android device

查看:530
本文介绍了查找Android设备上IPv6全局范围地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方法来确定我的测试用的Andr​​oid设备上,全球IPv6地址。现在,我已经获得了来自Android的API,如下面的code接口的列表:

I am looking for a way to determine the global IPv6 address on my android device for testing purpose. Now, what I have obtained a list of interfaces from Android API as the following code:

NetworkInterface netInt: NetworkInterface.getNetworkInterfaces()

netInt 实际上包含设备上的所有接口的列表。例如,你可以从下面的列表。(只是名单的一部分)见

netInt actually contains a list of all the interfaces on the devices. for example, as you can see from the following list..(just a part of the list)

[dummy0][2][/fe80::d878:d9ff:fe94:eeae%dummy0%2]
[rmnet_data0][7][/fe80::e03:fac6:8232:95d6%rmnet_data0%7]
                [/2607:fb90:543:e9dd:e03:fac6:8232:95d6%7%7]

我用一些公共IPv6站点,并意识到,我的公开IPv6地址 2607:FB90:543:e9dd:E03:fac6:8232:95d6 。我想看看是否有要提取 2607可靠的方法:因为95d6%7%7 从数组:FB90:543:e9dd:E03:fac6:8232阵列改变所有的时间和从设备到设备的索引。

I use some public IPv6 site and realized that my public IPv6 address is 2607:fb90:543:e9dd:e03:fac6:8232:95d6. I would like to see if there is a reliable way to to extract 2607:fb90:543:e9dd:e03:fac6:8232:95d6%7%7 from the array since the index of the array changing all the time and from devices to devices.

我AP preciate你的帮助。

I appreciate your help.

推荐答案

您需要哪些检查是第一个地址字是4个字符,第一个字符是2或3。如果数组元素满足这两个条件下,它是一个全局地址。然后,您可以清理周围的垃圾得到有效的地址。

What you need to check for is that the first address word is 4 characters and the first character is a 2 or a 3. If the array element meets those two conditions, it is a global address. You can then clean up the surrounding garbage to get a valid address.

注意:IPv6允许多个全局地址被分配到的接口。事实上,一些操作系统上做这个目的的安全性。

Note: IPv6 allows multiple global addresses to be assigned to an interface. In fact, some OSes do that on purpose for security.

编辑:
对于IPv6全球单播地址的定义是: 2000 :: / 3 。这个收益率 2000 :: 3ffff:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 。参见:<一href=\"http://www.iana.org/assignments/ipv6-unicast-address-assignments/ipv6-unicast-address-assignments.xhtml\"相对=nofollow>全球单播IPv6地址分配

The definition for an IPv6 Global Unicast address is 2000::/3. This yields 2000:: to 3ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff. See: IPv6 Global Unicast Address Assignments

Note
The assignable Global Unicast Address space is defined in [RFC4291] as
being the address block defined by the prefix 2000::/3. All address
space in this block not listed in the table below is reserved by IANA
for future allocation.

IPv6允许任意数量的IPv6的接口上的地址,你可以用它们作为传入或传出。

IPv6 allows any number of IPv6 addresses on an interface, and you can use them as either incoming or outgoing.

这篇关于查找Android设备上IPv6全局范围地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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