Skip to content

Commit 3e04b57

Browse files
committed
minor bugfix for pcapng protocol (method name typo)
1 parent 1a6aea9 commit 3e04b57

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

pcapkit/protocols/misc/pcapng.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ def read(self, length: 'Optional[int]' = None, *, _read: 'bool' = True,
864864
Structure of PCAP-NG file blocks:
865865
866866
.. code-block:: text
867+
867868
1 2 3
868869
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
869870
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -1753,7 +1754,7 @@ def _read_block_dsb(self, schema: 'Schema_DecryptionSecretsBlock', *,
17531754
if isinstance(name, str):
17541755
meth_name = f'_read_secrets_{name}'
17551756
meth = cast('SecretsParser',
1756-
getattr(self, meth_name, self._read_secrest_unknown))
1757+
getattr(self, meth_name, self._read_secrets_unknown))
17571758
else:
17581759
meth = name[0]
17591760
secrets_data = meth(schema.secrets_data, block=schema)
@@ -3097,7 +3098,7 @@ def _read_record_ipv6(self, schema: 'Schema_IPv6Record', *,
30973098
)
30983099
return record
30993100

3100-
def _read_secrest_unknown(self, schema: 'Schema_UnknownSecrets', *,
3101+
def _read_secrets_unknown(self, schema: 'Schema_UnknownSecrets', *,
31013102
block: 'Schema_DecryptionSecretsBlock') -> 'Data_UnknownSecrets':
31023103
"""Read PCAP-NG unknown secrets.
31033104
@@ -3148,7 +3149,7 @@ def _read_secrets_zigbee_nwk(self, schema: 'Schema_ZigBeeNWKKey', *,
31483149
31493150
Structure of ZigBee NWK Key secrets:
31503151
3151-
.. code-block::
3152+
.. code-block:: text
31523153
31533154
0 1 2 3
31543155
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -4339,6 +4340,37 @@ def _make_option_if_fcslen(self, type: 'Enum_OptionType', option: 'Optional[Data
43394340
fcslen=fcs_length,
43404341
)
43414342

4343+
def _make_option_if_tsoffset(self, type: 'Enum_OptionType', option: 'Optional[Data_IF_TSOffsetOption]' = None, *,
4344+
offset: 'int' = 0,
4345+
**kwargs: 'Any') -> 'Schema_IF_TSOffsetOption':
4346+
"""Make PCAP-NG ``if_tsoffset`` option.
4347+
4348+
Args:
4349+
type: Option type.
4350+
option: Option data model.
4351+
offset: Timestamp offset in seconds.
4352+
**kwargs: Arbitrary keyword arguments.
4353+
4354+
Returns:
4355+
Constructed option schema.
4356+
4357+
"""
4358+
if self._type != Enum_BlockType.Interface_Description_Block:
4359+
raise ProtocolError(f'PCAP-NG: [if_tsoffset] option must be in Interface Description Block, '
4360+
f'but found in {self._type} block.')
4361+
if self._opt[type] > 0:
4362+
raise ProtocolError(f'PCAP-NG: [if_tsoffset] option must be only one, '
4363+
f'but {self._opt[type] + 1} found.')
4364+
4365+
if option is not None:
4366+
offset = option.offset
4367+
4368+
return Schema_IF_TSOffsetOption(
4369+
type=type,
4370+
length=8,
4371+
tsoffset=offset,
4372+
)
4373+
43424374
def _make_option_if_hardware(self, type: 'Enum_OptionType', option: 'Optional[Data_IF_HardwareOption]' = None, *,
43434375
hardware: 'str' = platform.processor(),
43444376
**kwargs: 'Any') -> 'Schema_IF_HardwareOption':

0 commit comments

Comments
 (0)