Manojcode
Manojcode

Reputation: 41

decoding DHCP Giaddr, Yiaddr, Ciaddr, siaddr fields with dpkt - python issue

Whenever I try to load Giaddr (or YIADDR Ciaddr, siaddr ) for any DHCP packet it prints random string of numbers. ( this happens for each n every packet I load)

Am I doing something wrong or it's a bug in code?

code

dh = dpkt.dhcp.DHCP(udp.data)
print dh.giaddr

output : 182435815

I am pretty sure that my giaddr(relay ip) is 10.223.191.231 - confirmed in wireshark for this packet.

Upvotes: 1

Views: 786

Answers (1)

Kiran Bandla
Kiran Bandla

Reputation: 686

Your output is correct. You have a the integer value of the address. To print the dotted-decimal version, you can do this:

>>> import struct
>>> socket.inet_ntoa(struct.pack(">L",x))
'10.223.191.231'

Upvotes: 1

Related Questions