Question

I have an DHCP packet received. I want to obtain the number of the option from that packet. E.g. server_id option has number 53. I need to do this in scapy.

I tried if pkt[DHCP].options[i] == 53: do something but dosen't work.

Was it helpful?

Solution

Solved.

Options field are a tuples. To acces a value of an option you have to use

if pkt[DHCP].options[i][j] == 53: do something

where i -is the number of the option(starts from 0) and j - is the value or the name of the option(j=0 is the name, and j=1 is the value).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top