NewLionwang / dpkt

Automatically exported from code.google.com/p/dpkt
Other
0 stars 0 forks source link

ip.src and ip.dst return gibberish values #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
try using ip.src or ip.dst, returns are not as expected :-/

What is the expected output? What do you see instead?
expected: 10.42.0.something
got: *$

What version of the product are you using? On what operating system?
1.6 on ubuntu

Please provide any additional information below.

Original issue reported on code.google.com by till.sal...@gmail.com on 26 Jan 2010 at 4:55

GoogleCodeExporter commented 8 years ago
ip.src and ip.dst are stored as four raw bytes, not as printable strings.

Do the following:
import socket
...
print socket.inet_ntoa( ip.src )

Original comment by brampton on 26 Jan 2010 at 5:11

GoogleCodeExporter commented 8 years ago
You can convert the rawbyte character to int with built-in function ord,

ie:

>>> '.'.join([str(ord(c)) for c in ip.src])

Outputs something like: '10.1.0.233' 

Original comment by allisonv...@gmail.com on 3 Feb 2010 at 1:21

GoogleCodeExporter commented 8 years ago

Original comment by dugsong on 3 Feb 2010 at 2:14

GoogleCodeExporter commented 8 years ago
Here is a patch for ip.py that shows the ip in readable form when you use 
repr().
This issue has been brought up before. 

Original comment by alrho...@gmail.com on 3 Feb 2010 at 11:27

Attachments: