Skip to content

Commit 8fcee46

Browse files
authored
fix(pcapng): keep captured padding octets on rebuild (#1437) (#1441)
1 parent 7c62038 commit 8fcee46

4 files changed

Lines changed: 373 additions & 14 deletions

File tree

‎pcapkit/protocols/data/misc/pcapng.py‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ class Option(Data):
8989
#: Option data length.
9090
length: 'int'
9191

92+
if TYPE_CHECKING:
93+
#: Padding of the option value to 32 bits, as captured; present only
94+
#: when it is not all zeros (:issue:`1437`).
95+
padding: 'bytes'
96+
9297

9398
@info_final
9499
class UnknownOption(Option):
@@ -147,6 +152,10 @@ class SectionHeaderBlock(PCAPNG):
147152
options: 'OrderedMultiDict[Enum_OptionType, Option]'
148153

149154
if TYPE_CHECKING:
155+
#: Octets after ``opt_endofopt``, as captured; present only when the
156+
#: option area holds any (:issue:`1437`).
157+
padding_opts: 'bytes'
158+
150159
def __init__(self, type: 'Enum_BlockType', length: 'int', byteorder: 'Literal["big", "little"]',
151160
version: 'VersionInfo', # pylint: disable=unused-argument
152161
section_length: 'int', options: 'OrderedMultiDict[Enum_OptionType, Option]') -> None: ...
@@ -343,6 +352,13 @@ class InterfaceDescriptionBlock(PCAPNG):
343352
options: 'OrderedMultiDict[Enum_OptionType, Option]'
344353

345354
if TYPE_CHECKING:
355+
#: Reserved octets, as captured; present only when they are not all
356+
#: zeros (:issue:`1437`).
357+
reserved: 'bytes'
358+
#: Octets after ``opt_endofopt``, as captured; present only when the
359+
#: option area holds any (:issue:`1437`).
360+
padding_opts: 'bytes'
361+
346362
def __init__(self, type: 'Enum_BlockType', length: 'int', linktype: 'Enum_LinkType',
347363
snaplen: 'int', options: 'OrderedMultiDict[Enum_OptionType, Option]') -> None: ...
348364

@@ -475,6 +491,12 @@ class EnhancedPacketBlock(PCAPNG):
475491
options: 'OrderedMultiDict[Enum_OptionType, Option]'
476492

477493
if TYPE_CHECKING:
494+
#: Padding of the packet data to 32 bits, as captured; present only when
495+
#: it is not all zeros (:issue:`1437`).
496+
padding_data: 'bytes'
497+
#: Octets after ``opt_endofopt``, as captured; present only when the
498+
#: option area holds any (:issue:`1437`).
499+
padding_opts: 'bytes'
478500
#: Protocol chain.
479501
protocols: 'str'
480502

@@ -508,6 +530,9 @@ def __post_init__(self) -> 'None':
508530
)
509531

510532
if TYPE_CHECKING:
533+
#: Padding of the packet data to 32 bits, as captured; present only when
534+
#: it is not all zeros (:issue:`1437`).
535+
padding_data: 'bytes'
511536
#: Protocol chain.
512537
protocols: 'str'
513538

@@ -530,6 +555,11 @@ class NameResolutionRecord(Data):
530555
#: Record value length.
531556
length: 'int'
532557

558+
if TYPE_CHECKING:
559+
#: Padding of the record value to 32 bits, as captured; present only
560+
#: when it is not all zeros (:issue:`1437`).
561+
padding: 'bytes'
562+
533563

534564
@info_final
535565
class UnknownRecord(NameResolutionRecord):
@@ -637,6 +667,9 @@ def __post_init__(self) -> 'None':
637667
)
638668

639669
if TYPE_CHECKING:
670+
#: Octets after ``opt_endofopt``, as captured; present only when the
671+
#: option area holds any (:issue:`1437`).
672+
padding_opts: 'bytes'
640673
#: Name resolution mapping (IP address -> name).
641674
mapping: 'MultiDict[IPv4Address | IPv6Address, str]'
642675
#: Name resolution mapping (name -> IP address).
@@ -744,6 +777,10 @@ class InterfaceStatisticsBlock(PCAPNG):
744777
options: 'OrderedMultiDict[Enum_OptionType, Option]'
745778

746779
if TYPE_CHECKING:
780+
#: Octets after ``opt_endofopt``, as captured; present only when the
781+
#: option area holds any (:issue:`1437`).
782+
padding_opts: 'bytes'
783+
747784
def __init__(self, type: 'Enum_BlockType', length: 'int', interface_id: 'int', timestamp: 'dt_type',
748785
timestamp_epoch: 'Decimal', options: 'OrderedMultiDict[Enum_OptionType, Option]') -> 'None': ...
749786

@@ -847,6 +884,13 @@ class DecryptionSecretsBlock(PCAPNG):
847884
options: 'OrderedMultiDict[Enum_OptionType, Option]'
848885

849886
if TYPE_CHECKING:
887+
#: Padding of the secrets data to 32 bits, as captured; present only when
888+
#: it is not all zeros (:issue:`1437`).
889+
padding_data: 'bytes'
890+
#: Octets after ``opt_endofopt``, as captured; present only when the
891+
#: option area holds any (:issue:`1437`).
892+
padding_opts: 'bytes'
893+
850894
def __init__(self, type: 'Enum_BlockType', length: 'int', secrets_type: 'Enum_SecretsType',
851895
secrets_length: 'int', secrets_data: 'DSBSecrets',
852896
options: 'OrderedMultiDict[Enum_OptionType, Option]') -> 'None': ...
@@ -948,6 +992,12 @@ class PacketBlock(PCAPNG):
948992
options: 'OrderedMultiDict[Enum_OptionType, Option]'
949993

950994
if TYPE_CHECKING:
995+
#: Padding of the packet data to 32 bits, as captured; present only when
996+
#: it is not all zeros (:issue:`1437`).
997+
padding_data: 'bytes'
998+
#: Octets after ``opt_endofopt``, as captured; present only when the
999+
#: option area holds any (:issue:`1437`).
1000+
padding_opts: 'bytes'
9511001
#: Protocol chain.
9521002
protocols: 'str'
9531003

0 commit comments

Comments
 (0)