| 1545 | |
| 1546 | class PcapReader(RawPcapReader): |
| 1547 | def __init__(self, filename, fdesc=None, magic=None): # type: ignore |
| 1548 | # type: (str, IO[bytes], bytes) -> None |
| 1549 | RawPcapReader.__init__(self, filename, fdesc, magic) |
| 1550 | try: |
| 1551 | self.LLcls = conf.l2types.num2layer[ |
| 1552 | self.linktype |
| 1553 | ] # type: Type[Packet] |
| 1554 | except KeyError: |
| 1555 | warning("PcapReader: unknown LL type [%i]/[%#x]. Using Raw packets" % (self.linktype, self.linktype)) # noqa: E501 |
| 1556 | if conf.raw_layer is None: |
| 1557 | # conf.raw_layer is set on import |
| 1558 | import scapy.packet # noqa: F401 |
| 1559 | self.LLcls = conf.raw_layer |
| 1560 | |
| 1561 | def __enter__(self): |
| 1562 | # type: () -> PcapReader |