Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/source/pcapkit/protocols/internet/hopopt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,15 @@ Type Stubs
Auxiliary Functions
~~~~~~~~~~~~~~~~~~~

The option helpers are shared with
:mod:`~pcapkit.protocols.schema.internet.ipv6_opts` and documented in
:mod:`pcapkit.protocols.schema.internet.ipv6_option`. The functions below bind
them to this module's error prefix and option schemas;
:func:`~pcapkit.protocols.schema.internet.ipv6_option.rpl_opt_sub_tlv_len` and
:func:`~pcapkit.protocols.schema.internet.ipv6_option.pad_opt_data_len` are
used unchanged.

.. autofunction:: pcapkit.protocols.schema.internet.hopopt.mpl_opt_seed_id_len
.. autofunction:: pcapkit.protocols.schema.internet.hopopt.pad_opt_data_len
.. autofunction:: pcapkit.protocols.schema.internet.hopopt.calipso_pad_len
.. autofunction:: pcapkit.protocols.schema.internet.hopopt.mpl_opt_pad_len

Expand Down
1 change: 1 addition & 0 deletions docs/source/pcapkit/protocols/internet/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internet layer, with detailed implementation and methods.
ipv6_opts
ipv6_route
hopopt
ipv6_option
ipsec
ah
esp
Expand Down
31 changes: 31 additions & 0 deletions docs/source/pcapkit/protocols/internet/ipv6_option.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
IPv6 Options - Shared Option Helpers
====================================

.. module:: pcapkit.protocols.schema.internet.ipv6_option

:mod:`pcapkit.protocols.schema.internet.ipv6_option` contains the field helpers
shared by the option schemas of
:mod:`~pcapkit.protocols.schema.internet.hopopt` (HOPOPT) and
:mod:`~pcapkit.protocols.schema.internet.ipv6_opts` (IPv6-Opts), since both
headers carry the same IPv6 options [*]_. A helper that reports an error takes
the header's name as ``prefix``, and a selector takes the header's option
schemas. Each header module binds them in a function of the same name, which
is what its fields use.

Auxiliary Functions
-------------------

.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.rpl_opt_sub_tlv_len
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.mpl_opt_seed_id_len
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.pad_opt_data_len
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.calipso_pad_len
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.mpl_opt_pad_len

.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.smf_dpd_data_selector
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.smf_i_dpd_tid_selector
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.smf_i_dpd_id_len
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_option.quick_start_data_selector

.. rubric:: Footnotes

.. [*] https://www.rfc-editor.org/rfc/rfc8200#section-4.2
9 changes: 8 additions & 1 deletion docs/source/pcapkit/protocols/internet/ipv6_opts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,15 @@ Type Stubs
Auxiliary Functions
~~~~~~~~~~~~~~~~~~~

The option helpers are shared with
:mod:`~pcapkit.protocols.schema.internet.hopopt` and documented in
:mod:`pcapkit.protocols.schema.internet.ipv6_option`. The functions below bind
them to this module's error prefix and option schemas;
:func:`~pcapkit.protocols.schema.internet.ipv6_option.rpl_opt_sub_tlv_len` and
:func:`~pcapkit.protocols.schema.internet.ipv6_option.pad_opt_data_len` are
used unchanged.

.. autofunction:: pcapkit.protocols.schema.internet.ipv6_opts.mpl_opt_seed_id_len
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_opts.pad_opt_data_len
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_opts.calipso_pad_len
.. autofunction:: pcapkit.protocols.schema.internet.ipv6_opts.mpl_opt_pad_len

Expand Down
15 changes: 15 additions & 0 deletions docs/source/pcapkit/protocols/misc/byteorder.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Byte Order - Shared Byte-Order Helpers
======================================

.. module:: pcapkit.protocols.schema.misc.byteorder

:mod:`pcapkit.protocols.schema.misc.byteorder` contains the field callback that
reads a capture file's byte order out of the packet data. It is shared by the
PCAP frame header (:mod:`~pcapkit.protocols.schema.misc.pcap.frame`) and the
PCAP-NG blocks (:mod:`~pcapkit.protocols.schema.misc.pcapng`).

Auxiliary Functions
-------------------

.. autofunction:: pcapkit.protocols.schema.misc.byteorder.byteorder_callback
.. autofunction:: pcapkit.protocols.schema.misc.byteorder.packet_byteorder
1 change: 1 addition & 0 deletions docs/source/pcapkit/protocols/misc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ indication of empty payload, the PCAP header classes, and the PCAP-NG

pcap
pcapng
byteorder
raw
null
6 changes: 5 additions & 1 deletion docs/source/pcapkit/protocols/misc/pcapng.rst
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,11 @@ Type Stubs
Auxiliary Functions
-------------------

.. autofunction:: pcapkit.protocols.schema.misc.pcapng.byteorder_callback
The byte order of every block but the Section Header Block is read by
:func:`~pcapkit.protocols.schema.misc.byteorder.byteorder_callback`, which is
shared with the PCAP frame header and documented in
:mod:`pcapkit.protocols.schema.misc.byteorder`.

.. autofunction:: pcapkit.protocols.schema.misc.pcapng.shb_byteorder_callback
.. autofunction:: pcapkit.protocols.schema.misc.pcapng.pcapng_block_selector
.. autofunction:: pcapkit.protocols.schema.misc.pcapng.dsb_secrets_selector
Expand Down
5 changes: 3 additions & 2 deletions examples/generators/endian.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
instead of the file's produced the right answer anyway.

That is how GitHub issue #605 survived: ``Frame.unpack`` seeded the byte order
under the key ``bytesorder`` where ``byteorder_callback`` in
:file:`pcapkit/protocols/schema/misc/pcap/frame.py` reads ``byteorder``, so the
under the key ``bytesorder`` where ``byteorder_callback`` -- then in
:file:`pcapkit/protocols/schema/misc/pcap/frame.py`, now in
:file:`pcapkit/protocols/schema/misc/byteorder.py` -- reads ``byteorder``, so the
lookup always missed and always fell back to :data:`sys.byteorder`. Reading a
big-endian capture then byte-swapped ``ts_sec``, ``ts_usec``, ``incl_len`` and
``orig_len`` -- and because ``incl_len`` is the payload length, the first record
Expand Down
2 changes: 1 addition & 1 deletion pcapkit/corekit/fields/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def nested_packet_context(packet: 'dict[str, Any]') -> 'dict[str, Any]':
reserved ``__packet__`` key, for a callback that needs to name the
outer schema specifically rather than whichever schema happens to
declare a given field -- see
:func:`pcapkit.protocols.schema.misc.pcapng.packet_byteorder` and
:func:`pcapkit.protocols.schema.misc.byteorder.packet_byteorder` and
:meth:`~pcapkit.protocols.schema.misc.pcapng.BlockType.post_process`
for why that distinction matters, and note that both already
hand-roll this exact fallback and so are unaffected by (and do not
Expand Down
Loading
Loading