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: 5 additions & 4 deletions pcapkit/protocols/internet/hopopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ def make(self,
# NOTE: No options is not the same as no options area. The header is at
# least 8 octets, 2 of them the fixed part, so the remaining 6 must be
# padding options. Passing the empty list through the same path produces
# them; returning ``[], 0`` would declare an 8-octet header and emit 2.
# them; returning ``[], 0`` would emit the 2 fixed octets alone, under a
# ``Hdr Ext Len`` that ``(0 - 6) // 8`` makes ``-1``.
options_value, total_length = self._make_hopopt_options(
options if options is not None else [])

Expand Down Expand Up @@ -1349,8 +1350,8 @@ def _make_pad_options(self, offset: 'int') -> 'tuple[list[Schema_PadOption], int
the alignment is computed from ``offset`` rather than from the
length of the option just emitted. Aligning each option to 8 octets
on its own leaves the options area a multiple of 8, whereas
:meth:`read` sizes it as ``hdr_ext_len * 8 + 6``, six short of a
multiple of 8; the header would declare 6 octets more than it
:meth:`read` sizes it as ``hdr_ext_len * 8 + 6``, two short of a
multiple of 8; the header would declare 2 octets fewer than it
carried.

A ``PadN`` option spends two octets on its own type and
Expand Down Expand Up @@ -1391,7 +1392,7 @@ def _make_hopopt_options(self, options: 'list[Schema_Option | tuple[Enum_Option,
The returned length is that of the options area alone, the value
:meth:`make` derives the ``Hdr Ext Len`` field from. Since the two
octets of the fixed header precede it, an options area is well
formed only when it is 6 octets short of a multiple of 8 --
formed only when it is 2 octets short of a multiple of 8 --
including when it holds no real options at all, in which case it is
6 octets of pure padding rather than empty.

Expand Down
9 changes: 5 additions & 4 deletions pcapkit/protocols/internet/ipv6_opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ def make(self,
# NOTE: No options is not the same as no options area. The header is at
# least 8 octets, 2 of them the fixed part, so the remaining 6 must be
# padding options. Passing the empty list through the same path produces
# them; returning ``[], 0`` would declare an 8-octet header and emit 2.
# them; returning ``[], 0`` would emit the 2 fixed octets alone, under a
# ``Hdr Ext Len`` that ``(0 - 6) // 8`` makes ``-1``.
options_value, total_length = self._make_ipv6_opts(
options if options is not None else [])

Expand Down Expand Up @@ -1338,8 +1339,8 @@ def _make_pad_options(self, offset: 'int') -> 'tuple[list[Schema_PadOption], int
length of the option that has just been emitted. Aligning each
option to 8 octets on its own leaves the options area a multiple of
8 octets long, whereas :meth:`read` sizes it as
``hdr_ext_len * 8 + 6`` -- six short of a multiple of 8 -- so the
header would declare 6 octets more than it carried.
``hdr_ext_len * 8 + 6`` -- two short of a multiple of 8 -- so the
header would declare 2 octets fewer than it carried.

A ``PadN`` option spends two octets on its own type and
``Opt Data Len`` fields before any padding data, so occupying
Expand Down Expand Up @@ -1379,7 +1380,7 @@ def _make_ipv6_opts(self, options: 'list[Schema_Option | tuple[Enum_Option, dict
The returned length is that of the options area alone, the value
:meth:`make` derives the ``Hdr Ext Len`` field from. Since the two
octets of the fixed header precede it, an options area is well
formed only when it is 6 octets short of a multiple of 8 --
formed only when it is 2 octets short of a multiple of 8 --
including when it holds no real options at all, in which case it is
6 octets of pure padding rather than empty.

Expand Down
4 changes: 2 additions & 2 deletions pcapkit/protocols/schema/internet/hip.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ class R1CounterParameter(Parameter, code=[Enum_Parameter.R1_Counter,
#: order", so the width is stated twice and inferred from neither.
#: :rfc:`5201#section-5.2.3` gives the same 4 + 8 layout, so there is no
#: version under which four octets is right, and both codes that reach this
#: class -- ``R1_Counter`` (128, HIPv1) and ``R1_COUNTER`` (129) -- are
#: affected. With the four ``reserved`` octets the contents are 12 octets,
#: class -- ``R1_Counter`` (128, HIPv1) and ``R1_COUNTER`` (129) -- take
#: the eight. With the four ``reserved`` octets the contents are 12 octets,
#: which :rfc:`7401` Section 5.2.1's arithmetic pads to a 16-octet record.
counter: 'int' = UInt64Field()
#: Padding.
Expand Down
Loading