Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conversions from IPv4 to IPv4-Mapped IPv6 addresses. #13

Open
jgonian opened this issue Jun 30, 2016 · 0 comments
Open

Add conversions from IPv4 to IPv4-Mapped IPv6 addresses. #13

jgonian opened this issue Jun 30, 2016 · 0 comments

Comments

@jgonian
Copy link
Owner

jgonian commented Jun 30, 2016

As mentioned in #9, extending the library in order to support conversions of an IPv4 address to an IPv4-Mapped IPv6 address and vice-versa could be useful in the case where we want to use IPv6 for dealing with both IPv4 and IPv6. Conversion should be according to section 2.5.5 of RFC 4291.

As an example:

// IP addresses
Ipv4 ipv4Address = Ipv4.parse("192.168.0.0");
Ipv6 ipv6Address = Ipv6.of(ipv4Address)            // ::ffff:c0a8:0
Ipv6 ipv6Address = ipv4Address.asIpv4MappedIpv6(); // ::ffff:c0a8:0
boolean ... = ipv6Address.isIpv4MappedIpv6()       // true

// IP ranges
Ipv4Range ipv4Range = Ipv4Range.parse("192.168.0.0/32")
Ipv6Range ipv6Range = ipv4range.asIpv4MappedIpv6();  // ::ffff:c0a8:0/120
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant