I'm trying to synthesize an IPv6 address from an IPv4 address in Android (either in native code or in Java itself) as documented in RFC-7050 for use while behind NAT64.
When working in iOS this option was available through a call to getaddrinfo
, however it seems that Android's implementation of getaddrinfo
will only synthesize IPv6 for hostnames, and not IPv4 addresses.
On iOS, while behind NAT64, the following code would generate a synthesized IPv6 address inside the variable res
's address list. However, on Android the same native code will generate an IPv4 address unless I pass a host name instead of an IPv4 address to getaddrinfo
.
struct addrinfo *res;
getaddrinfo("x.x.x.x", "80", NULL, &res);
Edit
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.