janvanbesien / java-ipv6

Java library to represent IPv6 addresses, networks, and related concepts
Apache License 2.0
85 stars 33 forks source link

IPv4 support #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Consider a form of IPv4 support.

For example:
Ipv4 conversion, as I want to store both ipv4addresses and ipv6addresses in my 
key-value store, preferably in one common format. In this way I convert every 
input of my application into an ipv6 address internally, instead of having to 
make two sets of app-logic for the different address types. Would be nice if 
the library could detect that a ipv6 address is a valid ipv4 address and be 
able to print it as such.

Would IPv4 mapped IPv6 addresses be a good idea to tackle this?

http://en.wikipedia.org/wiki/IPv6#IPv4-mapped_IPv6_addresses

Original issue reported on code.google.com by janvanbesien@gmail.com on 6 Apr 2013 at 7:56

GoogleCodeExporter commented 9 years ago
This would have my vote, yes. Another possibility would be to just store the 32 
bits of ipv4 address as the least significant bit in an all-bits-zero ipv6, but 
according to the referred wiki this is deprecated in the spec for some reason. 

Original comment by kees.vd....@gmail.com on 7 Apr 2013 at 6:49

GoogleCodeExporter commented 9 years ago

Original comment by janvanbesien@gmail.com on 8 Apr 2013 at 9:26

GoogleCodeExporter commented 9 years ago
Added isIPv4MappedAddress method.

Original comment by janvanbesien@gmail.com on 10 Apr 2013 at 11:42

GoogleCodeExporter commented 9 years ago
Added support in toString to print IPv4Mapped addresses with ::ffff:1.2.3.4 
notation and provided support in fromString method to parse such strings.

Original comment by janvanbesien@gmail.com on 10 Apr 2013 at 12:56

GoogleCodeExporter commented 9 years ago

Original comment by janvanbesien@gmail.com on 12 Apr 2013 at 10:14

GoogleCodeExporter commented 9 years ago
Great, thanks!

Original comment by kees.vd....@gmail.com on 12 Apr 2013 at 1:46