Writes a single packet to the pcap file. :param packet: bytes for a single packet :type packet: bytes :param linktype: linktype value associated with the packet :type linktype: int :param sec: time the packet was captured, in seconds since epoch. If
(self, # type: ignore
packet, # type: bytes
linktype, # type: int
sec=None, # type: Optional[float]
usec=None, # type: Optional[int]
caplen=None, # type: Optional[int]
wirelen=None, # type: Optional[int]
ifname=None, # type: Optional[bytes]
direction=None, # type: Optional[int]
comments=None, # type: Optional[List[bytes]]
)
| 2579 | options=opts)) |
| 2580 | |
| 2581 | def _write_packet(self, # type: ignore |
| 2582 | packet, # type: bytes |
| 2583 | linktype, # type: int |
| 2584 | sec=None, # type: Optional[float] |
| 2585 | usec=None, # type: Optional[int] |
| 2586 | caplen=None, # type: Optional[int] |
| 2587 | wirelen=None, # type: Optional[int] |
| 2588 | ifname=None, # type: Optional[bytes] |
| 2589 | direction=None, # type: Optional[int] |
| 2590 | comments=None, # type: Optional[List[bytes]] |
| 2591 | ): |
| 2592 | # type: (...) -> None |
| 2593 | """ |
| 2594 | Writes a single packet to the pcap file. |
| 2595 | |
| 2596 | :param packet: bytes for a single packet |
| 2597 | :type packet: bytes |
| 2598 | :param linktype: linktype value associated with the packet |
| 2599 | :type linktype: int |
| 2600 | :param sec: time the packet was captured, in seconds since epoch. If |
| 2601 | not supplied, defaults to now. |
| 2602 | :type sec: float |
| 2603 | :param caplen: The length of the packet in the capture file. If not |
| 2604 | specified, uses ``len(packet)``. |
| 2605 | :type caplen: int |
| 2606 | :param wirelen: The length of the packet on the wire. If not |
| 2607 | specified, uses ``caplen``. |
| 2608 | :type wirelen: int |
| 2609 | :param comment: UTF-8 string containing human-readable comment text |
| 2610 | that is associated to the current block. Line separators |
| 2611 | SHOULD be a carriage-return + linefeed ('\r\n') or |
| 2612 | just linefeed ('\n'); either form may appear and |
| 2613 | be considered a line separator. The string is not |
| 2614 | zero-terminated. |
| 2615 | :type bytes |
| 2616 | :param ifname: UTF-8 string containing the |
| 2617 | name of the device used to capture data. |
| 2618 | The string is not zero-terminated. |
| 2619 | :type bytes |
| 2620 | :param direction: 0 = information not available, |
| 2621 | 1 = inbound, |
| 2622 | 2 = outbound |
| 2623 | :type int |
| 2624 | :return: None |
| 2625 | :rtype: None |
| 2626 | """ |
| 2627 | if caplen is None: |
| 2628 | caplen = len(packet) |
| 2629 | if wirelen is None: |
| 2630 | wirelen = caplen |
| 2631 | |
| 2632 | ifid = self.interfaces2id.get(ifname, None) |
| 2633 | if ifid is None: |
| 2634 | ifid = max(self.interfaces2id.values()) + 1 |
| 2635 | self.interfaces2id[ifname] = ifid |
| 2636 | self._write_block_idb(linktype=linktype, ifname=ifname) |
| 2637 | |
| 2638 | # EPB flags (32 bits). |
nothing calls this directly
no test coverage detected