@@ -47,10 +47,15 @@ class PyPCAPFile(EngineBase['PCAPFilePacket']):
4747 objects, as `PyPCAPFile`_ 0.12.0 drops records the ``default`` engine
4848 reads -- see :meth:`_read_records`,
4949 * disables IPv6 reassembly, warning as it does so, while leaving IPv4 and
50- TCP reassembly and TCP flow tracing in place, and
50+ TCP reassembly and TCP flow tracing in place,
5151 * leaves TCP over IPv6 out of TCP reassembly and flow tracing, with one
5252 :exc:`~pcapkit.utilities.warnings.AttributeWarning` per capture -- see
53- :mod:`pcapkit.toolkit.pypcapfile`.
53+ :mod:`pcapkit.toolkit.pypcapfile` -- and
54+ * leaves the frames of a link type `PyPCAPFile`_ has no decoder for
55+ undecoded, from which :mod:`pcapkit.toolkit.pypcapfile` reads the IP
56+ packet of the BSD loopback and raw-IP ones itself, as the ``default``
57+ engine dissects it (see
58+ :data:`~pcapkit.toolkit.pypcapfile.READ_LINKTYPES`).
5459
5560 The engine stops decoding at the network layer rather than descending into
5661 the transport layer. `PyPCAPFile`_ decoders *replace* the payload bytes of
@@ -184,8 +189,10 @@ def run(self) -> 'None':
184189 support such operations.
185190 * if IPv6 reassembly is enabled, as :mod:`pcapfile` has no IPv6
186191 decoder.
187- * if :mod:`pcapfile` has no decoder for the savefile's link layer
188- type, in which case frames are left undecoded.
192+ * if the savefile's link layer type is left unread: neither
193+ :mod:`pcapfile` has a decoder for it nor
194+ :mod:`pcapkit.toolkit.pypcapfile` reads it (see
195+ :meth:`_get_decoder`).
189196
190197 Raises:
191198 FormatError: If the file format is not supported, i.e., not a PCAP
@@ -302,20 +309,27 @@ def _get_decoder(self, linktype: 'int') -> 'Optional[Callable[..., Any]]':
302309 The decoder class, or :data:`None` when :mod:`pcapfile` has none.
303310
304311 Warns:
305- AttributeWarning: If no decoder is available, as frames will then be
306- left hexlified -- see :meth:`run` -- and no reassembly or flow
307- tracing is possible.
312+ AttributeWarning: If no decoder is available and the link layer type
313+ is none of the :data:`~pcapkit.toolkit.pypcapfile.READ_LINKTYPES`,
314+ as frames will then be left hexlified -- see :meth:`run` -- and
315+ no reassembly or flow tracing is possible. The frames of those
316+ link types are left undecoded too, but reassembly and flow
317+ tracing read the IP packet in them, as the ``default`` engine
318+ does, so nothing is lost there to warn of.
308319
309320 """
321+ from pcapkit .toolkit .pypcapfile import READ_LINKTYPES # isort:skip
322+
310323 try :
311324 decoder = self ._expkg .linklayer .clookup (linktype )
312325 except IndexError : # malformed entry in ``pcapfile.linklayer.__LL_TYPES__``
313326 decoder = None
314327
315328 if not callable (decoder ):
316- warn (f'unrecognised link layer protocol: { self ._dlink !r} ; frames will be left '
317- 'undecoded and all analysis functions ignored' , AttributeWarning ,
318- stacklevel = stacklevel ())
329+ if linktype not in READ_LINKTYPES :
330+ warn (f'unrecognised link layer protocol: { self ._dlink !r} ; frames will be left '
331+ 'undecoded and all analysis functions ignored' , AttributeWarning ,
332+ stacklevel = stacklevel ())
319333 return None
320334 return decoder
321335
0 commit comments