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

IPv6 string representation #25

Open
jimmykao89 opened this issue Aug 31, 2020 · 2 comments
Open

IPv6 string representation #25

jimmykao89 opened this issue Aug 31, 2020 · 2 comments
Labels

Comments

@jimmykao89
Copy link

Hi,

I was wondering, do the strings output from iptools conform to RFC 5952 for IPv6? Thanks

@bd808
Copy link
Owner

bd808 commented Aug 31, 2020

I believe it mostly is, but there is not a strong conformance test suite to ensure this. I tried the explicit examples from https://tools.ietf.org/html/rfc5952#page-10 and they all seem to be output as the RFC suggests:

>>> from iptools.ipv6 import (ip2long, long2ip)
>>> long2ip(ip2long("2001:0db8::0001"))
'2001:db8::1'
>>> long2ip(ip2long("2001:db8:0:0:0:0:2:1"))
'2001:db8::2:1'
>>> long2ip(ip2long("2001:db8::1:1:1:1:1"))
'2001:db8:0:1:1:1:1:1'
>>> long2ip(ip2long("2001:db8:0:0:1:0:0:1"))
'2001:db8::1:0:0:1'

There is currently no special output handling for IPv4-Mapped addresses. This is recommended in RFC 5952, but not required.

>>> long2ip(ip2long("::ffff:192.0.2.1"))
'::ffff:c000:201'

@bd808 bd808 added the question label Aug 31, 2020
@jimmykao89
Copy link
Author

Ok, thanks for the speedy reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants