我正在尝试从 Android 中的 IPv4 地址合成 IPv6 地址(无论是 native 代码还是 Java 本身),如 RFC-7050 中所述。在 NAT64 后面使用。
在 iOS 中工作时,可以通过调用 getaddrinfo
来使用此选项,但是 Android 的 getaddrinfo
实现似乎只会合成 IPv6 主机名,而不是 IPv4 地址.
在 iOS 上,在 NAT64 之后,以下代码将在变量 res
的地址列表中生成合成的 IPv6 地址。但是,在 Android 上,相同的 native 代码将生成 IPv4 地址,除非我将主机名而不是 IPv4 地址传递给 getaddrinfo
。
struct addrinfo *res;
getaddrinfo("x.x.x.x", "80", NULL, &res);
编辑
I do know that Android implements CLAT/464lat, however that doesn't cover all devices and networks. One prime example would be a NAT64 network behind an IPv4 only network.
Example: Internet -> IPv4 Only Network -> NAT64 Network -> Client
The client would have a local IPv6 address under RFC-4193 (I believe) but only be able to access the internet through it's NAT64 gateway, meaning that the NAT64 will have to translate addresses before sending them upstream.
So what I need is a way to generate the prefix for the synthesized IPv6 address
Ideally, we would need to synthesize an IPv6 address in order to reach the IPv4 endpoint.
最佳答案
这可能是也可能不是您的答案:
您不需要在 Android 上合成地址。它具有 464xlat,可模拟 NAT64 网络上的 IPv4 堆栈,因此您的应用程序可以仅使用 IPv4,Android 将负责幕后的映射。
iOS 和 Android 之间的区别在于 Android 在堆栈中实现了 IPv4 模拟。 Apple 决定保持 IP 堆栈干净,并为开发人员提供工具(如 getaddrinfo)来自行进行映射。不同的设计决策。
关于android - 在 Android 上从 IPv4 地址合成 IPv4 映射的 IPv6 地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45579355/