MCPcopy Index your code
hub / github.com/secdev/scapy / __init__

Method __init__

scapy/utils.py:1626–1661  ·  view source on GitHub ↗
(self, filename, fdesc=None, magic=None)

Source from the content-addressed store, hash-verified

1624 "process_information"])
1625
1626 def __init__(self, filename, fdesc=None, magic=None): # type: ignore
1627 # type: (str, IO[bytes], bytes) -> None
1628 self.filename = filename
1629 self.f = fdesc
1630 # A list of (linktype, snaplen, tsresol); will be populated by IDBs.
1631 self.interfaces = [] # type: List[Tuple[int, int, Dict[str, Any]]]
1632 self.default_options = {
1633 "tsresol": 1000000
1634 }
1635 self.blocktypes: Dict[
1636 int,
1637 Callable[
1638 [bytes, int],
1639 Optional[Tuple[bytes, RawPcapNgReader.PacketMetadata]]
1640 ]] = {
1641 1: self._read_block_idb,
1642 2: self._read_block_pkt,
1643 3: self._read_block_spb,
1644 6: self._read_block_epb,
1645 10: self._read_block_dsb,
1646 0x80000001: self._read_block_pib,
1647 }
1648 self.endian = "!" # Will be overwritten by first SHB
1649 self.process_information = [] # type: List[Dict[str, Any]]
1650
1651 if magic != b"\x0a\x0d\x0d\x0a": # PcapNg:
1652 raise Scapy_Exception(
1653 "Not a pcapng capture file (bad magic: %r)" % magic
1654 )
1655
1656 try:
1657 self._read_block_shb()
1658 except EOFError:
1659 raise Scapy_Exception(
1660 "The first SHB of the pcapng file is malformed !"
1661 )
1662
1663 def _read_block(self, size=MTU):
1664 # type: (int) -> Optional[Tuple[bytes, RawPcapNgReader.PacketMetadata]] # noqa: E501

Callers

nothing calls this directly

Calls 2

_read_block_shbMethod · 0.95
Scapy_ExceptionClass · 0.90

Tested by

no test coverage detected