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

Packed binary representation #14

Closed
GoogleCodeExporter opened this issue Mar 18, 2015 · 5 comments
Closed

Packed binary representation #14

GoogleCodeExporter opened this issue Mar 18, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

Some protocols and applications (for example DNS or joining multicast
groups via socket.setsockopt) need a binary representation of an IP
address. For IPv4 addresses, socket.inet_aton can be used. On some
platforms supporting IPv6, socket.inet_pton can be used for IPv4 and IPv6
addresses. However, this excludes platforms with  (not socket.has_ipv6 or
sys.platform == 'win32').
A property ("packed") should be defined for the IPv4 and IPv6 classes and
return a binary representation (bytes in Python3+, str otherwise).
Additionally, as soon as the code is ported to python3, calling
IP(bytes_instance) should yield an IP i so that i.packed == bytes_instance .

Original issue reported on code.google.com by phihag.de@gmail.com on 6 Mar 2009 at 11:46

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Note that this issue was erroneously created in Rietveld as well as google  
code - I did not realise issues in rietveld do not refer to those in google 
code  
until after I opened the issue at google code. Sorry for that!

[Edit] Corrected some formatting mistakes

Original comment by phihag.de@gmail.com on 8 Mar 2009 at 9:43

Attachments:

@GoogleCodeExporter
Copy link
Author

Implemented in rev68.

Original comment by phihag.de@gmail.com on 13 Apr 2009 at 3:49

@GoogleCodeExporter
Copy link
Author

When using the dpkt library, the IP's are in the binary form.   

src = ipaddr.IP( int( ip.src.encode('hex'), 16 ) ).

I guess this isn't the end of the world, but I haven't profiled to see if there 
is a
faster way.

Original comment by noahcamp...@gmail.com on 20 May 2009 at 10:01

@GoogleCodeExporter
Copy link
Author

Version 1.1.0 provides a .packed property.

Original comment by mshields+personal@google.com on 1 Jun 2009 at 10:59

  • Changed state: Fixed

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