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

Class Ether

scapy/layers/l2.py:281–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279
280
281class Ether(Packet):
282 name = "Ethernet"
283 fields_desc = [DestMACField("dst"),
284 SourceMACField("src"),
285 XShortEnumField("type", 0x9000, ETHER_TYPES)]
286 __slots__ = ["_defrag_pos"]
287
288 def hashret(self):
289 # type: () -> bytes
290 return struct.pack("H", self.type) + self.payload.hashret()
291
292 def answers(self, other):
293 # type: (Packet) -> int
294 if isinstance(other, Ether):
295 if self.type == other.type:
296 return self.payload.answers(other.payload)
297 return 0
298
299 def mysummary(self):
300 # type: () -> str
301 return self.sprintf("%src% > %dst% (%type%)")
302
303 @classmethod
304 def dispatch_hook(cls, _pkt=None, *args, **kargs):
305 # type: (Optional[bytes], *Any, **Any) -> Type[Packet]
306 if _pkt and len(_pkt) >= 14:
307 if struct.unpack("!H", _pkt[12:14])[0] <= 1500:
308 return Dot3
309 return cls
310
311
312class Dot3(Packet):

Callers 15

read_packetMethod · 0.90
encapMethod · 0.90
decapMethod · 0.90
deal_common_pktMethod · 0.90
dhcp_requestFunction · 0.90
make_replyMethod · 0.90
make_replyMethod · 0.90
neighsolFunction · 0.90
ns_reply_callbackFunction · 0.90
na_reply_callbackFunction · 0.90
reply_callbackFunction · 0.90
NDP_Attack_NS_SpoofingFunction · 0.90

Calls 3

XShortEnumFieldClass · 0.90
DestMACFieldClass · 0.85
SourceMACFieldClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…