MCPcopy Create free account
hub / github.com/secdev/scapy / BOOTP

Class BOOTP

scapy/layers/dhcp.py:91–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89
90
91class BOOTP(Packet):
92 name = "BOOTP"
93 fields_desc = [
94 ByteEnumField("op", 1, {1: "BOOTREQUEST", 2: "BOOTREPLY"}),
95 ByteEnumField("htype", 1, HARDWARE_TYPES),
96 ByteField("hlen", 6),
97 ByteField("hops", 0),
98 XIntField("xid", 0),
99 ShortField("secs", 0),
100 FlagsField("flags", 0, 16, "???????????????B"),
101 IPField("ciaddr", "0.0.0.0"),
102 IPField("yiaddr", "0.0.0.0"),
103 IPField("siaddr", "0.0.0.0"),
104 IPField("giaddr", "0.0.0.0"),
105 _BOOTP_chaddr("chaddr", b"", length=16),
106 StrFixedLenField("sname", b"", length=64),
107 StrFixedLenField("file", b"", length=128),
108 StrEnumField("options", b"", {dhcpmagic: "DHCP magic"})]
109
110 def guess_payload_class(self, payload):
111 if self.options[:len(dhcpmagic)] == dhcpmagic:
112 return DHCP
113 else:
114 return Packet.guess_payload_class(self, payload)
115
116 def extract_padding(self, s):
117 if self.options[:len(dhcpmagic)] == dhcpmagic:
118 # set BOOTP options to DHCP magic cookie and make rest a payload of DHCP options # noqa: E501
119 payload = self.options[len(dhcpmagic):]
120 self.options = self.options[:len(dhcpmagic)]
121 return payload, None
122 else:
123 return b"", None
124
125 def hashret(self):
126 return struct.pack("!I", self.xid)
127
128 def answers(self, other):
129 if not isinstance(other, BOOTP):
130 return 0
131 return self.xid == other.xid
132
133
134class _DHCPByteFieldListField(FieldListField):

Callers 1

dhcp_requestFunction · 0.85

Calls 9

ByteEnumFieldClass · 0.90
ByteFieldClass · 0.90
XIntFieldClass · 0.90
ShortFieldClass · 0.90
FlagsFieldClass · 0.90
IPFieldClass · 0.90
StrFixedLenFieldClass · 0.90
StrEnumFieldClass · 0.90
_BOOTP_chaddrClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…