| 279 | |
| 280 | |
| 281 | class 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 | |
| 312 | class Dot3(Packet): |
no test coverage detected
searching dependent graphs…