pypcapkit 1.0.3.post3__pp38-none-any.whl → 1.1.0.post1__pp38-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pcapkit/__init__.py +1 -1
- pcapkit/const/pcapng/option_type.py +25 -1
- pcapkit/const/reg/apptype.py +25 -1
- pcapkit/corekit/fields/collections.py +4 -5
- pcapkit/corekit/fields/field.py +33 -8
- pcapkit/corekit/fields/ipaddress.py +0 -1
- pcapkit/corekit/fields/misc.py +14 -19
- pcapkit/corekit/fields/numbers.py +2 -3
- pcapkit/corekit/fields/strings.py +2 -3
- pcapkit/corekit/infoclass.py +59 -6
- pcapkit/corekit/protochain.py +8 -1
- pcapkit/foundation/registry/protocols.py +30 -51
- pcapkit/protocols/data/__init__.py +4 -4
- pcapkit/protocols/data/internet/__init__.py +4 -4
- pcapkit/protocols/data/internet/mh.py +4 -4
- pcapkit/protocols/data/transport/__init__.py +4 -4
- pcapkit/protocols/data/transport/tcp.py +4 -4
- pcapkit/protocols/internet/mh.py +20 -20
- pcapkit/protocols/protocol.py +3 -2
- pcapkit/protocols/schema/__init__.py +4 -4
- pcapkit/protocols/schema/application/httpv2.py +16 -29
- pcapkit/protocols/schema/internet/__init__.py +4 -4
- pcapkit/protocols/schema/internet/hip.py +62 -111
- pcapkit/protocols/schema/internet/hopopt.py +46 -48
- pcapkit/protocols/schema/internet/ipv4.py +36 -41
- pcapkit/protocols/schema/internet/ipv6_opts.py +48 -52
- pcapkit/protocols/schema/internet/ipv6_route.py +9 -20
- pcapkit/protocols/schema/internet/mh.py +49 -84
- pcapkit/protocols/schema/misc/pcapng.py +178 -195
- pcapkit/protocols/schema/schema.py +252 -53
- pcapkit/protocols/schema/transport/__init__.py +4 -4
- pcapkit/protocols/schema/transport/tcp.py +52 -83
- pcapkit/protocols/transport/tcp.py +14 -14
- pcapkit/vendor/pcapng/option_type.py +25 -1
- pcapkit/vendor/reg/apptype.py +25 -1
- {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/METADATA +1 -1
- {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/RECORD +41 -41
- {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/LICENSE +0 -0
- {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/WHEEL +0 -0
- {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/entry_points.txt +0 -0
- {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/top_level.txt +0 -0
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
import base64
|
6
6
|
import collections
|
7
|
+
import collections.abc
|
7
8
|
import io
|
8
9
|
import struct
|
9
10
|
import sys
|
@@ -25,7 +26,7 @@ from pcapkit.corekit.fields.numbers import (EnumField, Int32Field, Int64Field, N
|
|
25
26
|
UInt8Field, UInt16Field, UInt32Field, UInt64Field)
|
26
27
|
from pcapkit.corekit.fields.strings import BitField, BytesField, PaddingField, StringField
|
27
28
|
from pcapkit.corekit.multidict import MultiDict, OrderedMultiDict
|
28
|
-
from pcapkit.protocols.schema.schema import Schema, schema_final
|
29
|
+
from pcapkit.protocols.schema.schema import EnumSchema, Schema, schema_final
|
29
30
|
from pcapkit.utilities.exceptions import FieldValueError, ProtocolError, stacklevel
|
30
31
|
from pcapkit.utilities.logging import SPHINX_TYPE_CHECKING
|
31
32
|
from pcapkit.utilities.warnings import ProtocolWarning, warn
|
@@ -60,7 +61,7 @@ __all__ = [
|
|
60
61
|
|
61
62
|
if TYPE_CHECKING:
|
62
63
|
from ipaddress import IPv4Address, IPv4Interface, IPv6Address, IPv6Interface
|
63
|
-
from typing import Any, Callable, DefaultDict, Optional, Type
|
64
|
+
from typing import Any, Callable, DefaultDict, Iterable, Optional, Type
|
64
65
|
|
65
66
|
from typing_extensions import Literal, Self
|
66
67
|
|
@@ -192,11 +193,11 @@ def pcapng_block_selector(packet: 'dict[str, Any]') -> 'Field':
|
|
192
193
|
|
193
194
|
See Also:
|
194
195
|
* :class:`pcapkit.const.pcapng.block_type.BlockType`
|
195
|
-
* :
|
196
|
+
* :class:`pcapkit.protocols.schema.misc.pcapng.BlockType`
|
196
197
|
|
197
198
|
"""
|
198
199
|
block_type = packet['type'] # type: Enum_BlockType
|
199
|
-
schema =
|
200
|
+
schema = BlockType.registry[block_type]
|
200
201
|
return SchemaField(length=packet['__length__'], schema=schema)
|
201
202
|
|
202
203
|
|
@@ -216,17 +217,14 @@ def dsb_secrets_selector(packet: 'dict[str, Any]') -> 'Field':
|
|
216
217
|
wrapped :class:`~pcapkit.protocols.schema.misc.pcapng.DSBSecrets`
|
217
218
|
subclass instance.
|
218
219
|
|
220
|
+
See Also:
|
221
|
+
* :class:`pcapkit.const.pcapng.secrets_type.Secrets_Type`
|
222
|
+
* :class:`pcapkit.protocols.schema.misc.pcapng.DSBSecrets`
|
223
|
+
|
219
224
|
"""
|
220
225
|
secrets_type = packet['secrets_type'] # type: int
|
221
|
-
|
222
|
-
|
223
|
-
if secrets_type == Enum_SecretsType.WireGuard_Key_Log:
|
224
|
-
return SchemaField(length=packet['secrets_length'], schema=WireGuardKeyLog)
|
225
|
-
if secrets_type == Enum_SecretsType.ZigBee_NWK_Key:
|
226
|
-
return SchemaField(length=packet['secrets_length'], schema=ZigBeeNWKKey)
|
227
|
-
if secrets_type == Enum_SecretsType.ZigBee_APS_Key:
|
228
|
-
return SchemaField(length=packet['secrets_length'], schema=ZigBeeAPSKey)
|
229
|
-
return SchemaField(length=packet['secrets_length'], schema=UnknownSecrets)
|
226
|
+
schema = DSBSecrets.registry[secrets_type]
|
227
|
+
return SchemaField(length=packet['secrets_length'], schema=schema)
|
230
228
|
|
231
229
|
|
232
230
|
class OptionEnumField(EnumField):
|
@@ -306,9 +304,11 @@ class PCAPNG(Schema):
|
|
306
304
|
def __init__(self, type: 'Enum_BlockType', block: 'BlockType | bytes') -> 'None': ...
|
307
305
|
|
308
306
|
|
309
|
-
class BlockType(
|
307
|
+
class BlockType(EnumSchema[Enum_BlockType]):
|
310
308
|
"""Header schema for PCAP-NG file blocks."""
|
311
309
|
|
310
|
+
__default__ = lambda: UnknownBlock
|
311
|
+
|
312
312
|
def post_process(self, packet: 'dict[str, Any]') -> 'Schema':
|
313
313
|
"""Revise ``schema`` data after unpacking process.
|
314
314
|
|
@@ -350,9 +350,94 @@ class UnknownBlock(BlockType):
|
|
350
350
|
def __init__(self, length: 'int', body: 'bytes', length2: 'int') -> 'None': ...
|
351
351
|
|
352
352
|
|
353
|
-
class Option(
|
353
|
+
class Option(EnumSchema[Enum_OptionType]):
|
354
354
|
"""Header schema for PCAP-NG file options."""
|
355
355
|
|
356
|
+
__additional__ = ['__enum__', '__namespace__']
|
357
|
+
__excluded__ = ['__enum__', '__namespace__']
|
358
|
+
|
359
|
+
#: Namespace of PCAP-NG option type numbers.
|
360
|
+
__namespace__: 'str' = None # type: ignore[assignment]
|
361
|
+
#: Mapping of PCAP-NG option type numbers to schemas.
|
362
|
+
__enum__: 'DefaultDict[str, DefaultDict[Enum_OptionType, Type[Option]]]' = collections.defaultdict(
|
363
|
+
lambda: Option.registry['opt'], {
|
364
|
+
'opt': collections.defaultdict(lambda: UnknownOption),
|
365
|
+
'if': collections.defaultdict(lambda: UnknownOption),
|
366
|
+
'epb': collections.defaultdict(lambda: UnknownOption),
|
367
|
+
'ns': collections.defaultdict(lambda: UnknownOption),
|
368
|
+
'isb': collections.defaultdict(lambda: UnknownOption),
|
369
|
+
'dsb': collections.defaultdict(lambda: UnknownOption),
|
370
|
+
'pack': collections.defaultdict(lambda: UnknownOption),
|
371
|
+
},
|
372
|
+
)
|
373
|
+
|
374
|
+
def __init_subclass__(cls, /, code: 'Optional[Enum_OptionType | Iterable[Enum_OptionType]]' = None,
|
375
|
+
namespace: 'Optional[str]' = None, *args: 'Any', **kwargs: 'Any') -> 'None':
|
376
|
+
"""Register option type to :attr:`__enum__` mapping.
|
377
|
+
|
378
|
+
Args:
|
379
|
+
code: Option type code. It can be either a single option type enumeration
|
380
|
+
or a list of option type enumerations.
|
381
|
+
namespace: Namespace of option type enumeration. If not given, the value
|
382
|
+
will be inferred from the option type code.
|
383
|
+
*args: Arbitrary positional arguments.
|
384
|
+
**kwargs: Arbitrary keyword arguments.
|
385
|
+
|
386
|
+
If ``code`` is provided, the subclass will be registered to the
|
387
|
+
:attr:`__enum__` mapping with the given ``code``. If ``code`` is
|
388
|
+
not given, the subclass will not be registered.
|
389
|
+
|
390
|
+
Examples:
|
391
|
+
|
392
|
+
.. code-block:: python
|
393
|
+
|
394
|
+
from pcapkit.const.pcapng.option_type import OptionType as Enum_OptionType
|
395
|
+
from pcapkit.protocols.schema.misc.pcapng improt Option
|
396
|
+
|
397
|
+
class NewOption(Option, namespace='opt', code=Enum_OptionType.opt_new):
|
398
|
+
...
|
399
|
+
|
400
|
+
See Also:
|
401
|
+
- :class:`pcapkit.const.pcapng.option_type.OptionType`
|
402
|
+
|
403
|
+
"""
|
404
|
+
if namespace is not None:
|
405
|
+
cls.__namespace__ = namespace
|
406
|
+
|
407
|
+
if code is not None:
|
408
|
+
if namespace is None:
|
409
|
+
namespace = cast('Optional[str]', cls.__namespace__)
|
410
|
+
|
411
|
+
if not isinstance(code, Enum_OptionType):
|
412
|
+
for _code in code:
|
413
|
+
Option.register(_code, cls, namespace)
|
414
|
+
else:
|
415
|
+
Option.register(code, cls, namespace)
|
416
|
+
super().__init_subclass__()
|
417
|
+
|
418
|
+
@staticmethod
|
419
|
+
def register(code: 'Enum_OptionType', cls: 'Type[Option]', ns: 'Optional[str]' = None) -> 'None':
|
420
|
+
"""Register option type to :attr:`__enum__` mapping.
|
421
|
+
|
422
|
+
Args:
|
423
|
+
code: Option type code.
|
424
|
+
cls: Option type schema.
|
425
|
+
ns: Namespace of option type enumeration. If not given, the value
|
426
|
+
will be inferred from the option type code.
|
427
|
+
|
428
|
+
"""
|
429
|
+
if ns is None:
|
430
|
+
ns = code.name.split('_')[0]
|
431
|
+
|
432
|
+
if ns == 'opt':
|
433
|
+
for key in Option.registry:
|
434
|
+
Option.registry[key][code] = cls
|
435
|
+
elif ns in Option.registry:
|
436
|
+
Option.registry[ns][code] = cls
|
437
|
+
else:
|
438
|
+
Option.registry[ns] = Option.registry['opt'].copy()
|
439
|
+
Option.registry[ns][code] = cls
|
440
|
+
|
356
441
|
if TYPE_CHECKING:
|
357
442
|
#: Option type.
|
358
443
|
type: 'Enum_OptionType'
|
@@ -360,7 +445,7 @@ class Option(Schema):
|
|
360
445
|
length: 'int'
|
361
446
|
|
362
447
|
|
363
|
-
class _OPT_Option(Option):
|
448
|
+
class _OPT_Option(Option, namespace='opt'):
|
364
449
|
"""Header schema for ``opt_*`` options."""
|
365
450
|
|
366
451
|
#: Option type.
|
@@ -383,7 +468,7 @@ class UnknownOption(_OPT_Option):
|
|
383
468
|
|
384
469
|
|
385
470
|
@schema_final
|
386
|
-
class EndOfOption(_OPT_Option):
|
471
|
+
class EndOfOption(_OPT_Option, code=Enum_OptionType.opt_endofopt):
|
387
472
|
"""Header schema for PCAP-NG file ``opt_endofopt`` options."""
|
388
473
|
|
389
474
|
if TYPE_CHECKING:
|
@@ -391,7 +476,7 @@ class EndOfOption(_OPT_Option):
|
|
391
476
|
|
392
477
|
|
393
478
|
@schema_final
|
394
|
-
class CommentOption(_OPT_Option):
|
479
|
+
class CommentOption(_OPT_Option, code=Enum_OptionType.opt_comment):
|
395
480
|
"""Header schema for PCAP-NG file ``opt_comment`` options."""
|
396
481
|
|
397
482
|
#: Comment text.
|
@@ -404,7 +489,10 @@ class CommentOption(_OPT_Option):
|
|
404
489
|
|
405
490
|
|
406
491
|
@schema_final
|
407
|
-
class CustomOption(_OPT_Option
|
492
|
+
class CustomOption(_OPT_Option, code=[Enum_OptionType.opt_custom_2988,
|
493
|
+
Enum_OptionType.opt_custom_2989,
|
494
|
+
Enum_OptionType.opt_custom_19372,
|
495
|
+
Enum_OptionType.opt_custom_19373]):
|
408
496
|
"""Header schema for PCAP-NG file ``opt_custom`` options."""
|
409
497
|
|
410
498
|
#: Private enterprise number (PEN).
|
@@ -419,7 +507,7 @@ class CustomOption(_OPT_Option):
|
|
419
507
|
|
420
508
|
|
421
509
|
@schema_final
|
422
|
-
class SectionHeaderBlock(BlockType):
|
510
|
+
class SectionHeaderBlock(BlockType, code=Enum_BlockType.Section_Header_Block):
|
423
511
|
"""Header schema for PCAP-NG Section Header Block (SHB)."""
|
424
512
|
|
425
513
|
#: Fast forward field to test the byteorder.
|
@@ -441,14 +529,7 @@ class SectionHeaderBlock(BlockType):
|
|
441
529
|
length=lambda pkt: pkt['length'] - 28,
|
442
530
|
base_schema=_OPT_Option,
|
443
531
|
type_name='type',
|
444
|
-
registry=
|
445
|
-
Enum_OptionType.opt_endofopt: EndOfOption,
|
446
|
-
Enum_OptionType.opt_comment: CommentOption,
|
447
|
-
Enum_OptionType.opt_custom_2988: CustomOption,
|
448
|
-
Enum_OptionType.opt_custom_2989: CustomOption,
|
449
|
-
Enum_OptionType.opt_custom_19372: CustomOption,
|
450
|
-
Enum_OptionType.opt_custom_19373: CustomOption,
|
451
|
-
}),
|
532
|
+
registry=Option.registry['opt'],
|
452
533
|
eool=Enum_OptionType.opt_endofopt,
|
453
534
|
)
|
454
535
|
#: Padding.
|
@@ -510,7 +591,7 @@ class SectionHeaderBlock(BlockType):
|
|
510
591
|
length2: 'int') -> 'None': ...
|
511
592
|
|
512
593
|
|
513
|
-
class _IF_Option(Option):
|
594
|
+
class _IF_Option(Option, namespace='if'):
|
514
595
|
"""Header schema for ``if_*`` options."""
|
515
596
|
|
516
597
|
#: Option type.
|
@@ -520,7 +601,7 @@ class _IF_Option(Option):
|
|
520
601
|
|
521
602
|
|
522
603
|
@schema_final
|
523
|
-
class IF_NameOption(_IF_Option):
|
604
|
+
class IF_NameOption(_IF_Option, code=Enum_OptionType.if_name):
|
524
605
|
"""Header schema for PCAP-NG file ``if_name`` options."""
|
525
606
|
|
526
607
|
#: Interface name.
|
@@ -533,7 +614,7 @@ class IF_NameOption(_IF_Option):
|
|
533
614
|
|
534
615
|
|
535
616
|
@schema_final
|
536
|
-
class IF_DescriptionOption(_IF_Option):
|
617
|
+
class IF_DescriptionOption(_IF_Option, code=Enum_OptionType.if_description):
|
537
618
|
"""Header schema for PCAP-NG file ``if_description`` options."""
|
538
619
|
|
539
620
|
#: Interface description.
|
@@ -546,7 +627,7 @@ class IF_DescriptionOption(_IF_Option):
|
|
546
627
|
|
547
628
|
|
548
629
|
@schema_final
|
549
|
-
class IF_IPv4AddrOption(_IF_Option):
|
630
|
+
class IF_IPv4AddrOption(_IF_Option, code=Enum_OptionType.if_IPv4addr):
|
550
631
|
"""Header schema for PCAP-NG file ``if_IPv4addr`` options."""
|
551
632
|
|
552
633
|
#: IPv4 interface.
|
@@ -559,7 +640,7 @@ class IF_IPv4AddrOption(_IF_Option):
|
|
559
640
|
|
560
641
|
|
561
642
|
@schema_final
|
562
|
-
class IF_IPv6AddrOption(_IF_Option):
|
643
|
+
class IF_IPv6AddrOption(_IF_Option, code=Enum_OptionType.if_IPv6addr):
|
563
644
|
"""Header schema for PCAP-NG file ``if_IPv6addr`` options."""
|
564
645
|
|
565
646
|
#: IPv6 interface.
|
@@ -572,7 +653,7 @@ class IF_IPv6AddrOption(_IF_Option):
|
|
572
653
|
|
573
654
|
|
574
655
|
@schema_final
|
575
|
-
class IF_MACAddrOption(_IF_Option):
|
656
|
+
class IF_MACAddrOption(_IF_Option, code=Enum_OptionType.if_MACaddr):
|
576
657
|
"""Header schema for PCAP-NG file ``if_MACaddr`` options."""
|
577
658
|
|
578
659
|
#: MAC interface.
|
@@ -585,7 +666,7 @@ class IF_MACAddrOption(_IF_Option):
|
|
585
666
|
|
586
667
|
|
587
668
|
@schema_final
|
588
|
-
class IF_EUIAddrOption(_IF_Option):
|
669
|
+
class IF_EUIAddrOption(_IF_Option, code=Enum_OptionType.if_EUIaddr):
|
589
670
|
"""Header schema for PCAP-NG file ``if_EUIaddr`` options."""
|
590
671
|
|
591
672
|
#: EUI interface.
|
@@ -598,7 +679,7 @@ class IF_EUIAddrOption(_IF_Option):
|
|
598
679
|
|
599
680
|
|
600
681
|
@schema_final
|
601
|
-
class IF_SpeedOption(_IF_Option):
|
682
|
+
class IF_SpeedOption(_IF_Option, code=Enum_OptionType.if_speed):
|
602
683
|
"""Header schema for PCAP-NG file ``if_speed`` options."""
|
603
684
|
|
604
685
|
#: Interface speed, in bits per second.
|
@@ -611,7 +692,7 @@ class IF_SpeedOption(_IF_Option):
|
|
611
692
|
|
612
693
|
|
613
694
|
@schema_final
|
614
|
-
class IF_TSResolOption(_IF_Option):
|
695
|
+
class IF_TSResolOption(_IF_Option, code=Enum_OptionType.if_tsresol):
|
615
696
|
"""Header schema for PCAP-NG file ``if_tsresol`` options."""
|
616
697
|
|
617
698
|
#: Interface timestamp resolution, in units per second.
|
@@ -644,7 +725,7 @@ class IF_TSResolOption(_IF_Option):
|
|
644
725
|
|
645
726
|
|
646
727
|
@schema_final
|
647
|
-
class IF_TZoneOption(_IF_Option):
|
728
|
+
class IF_TZoneOption(_IF_Option, code=Enum_OptionType.if_tzone):
|
648
729
|
"""Header schema for PCAP-NG file ``if_tzone`` options."""
|
649
730
|
|
650
731
|
#: Interface time zone (as in seconds difference from GMT).
|
@@ -657,7 +738,7 @@ class IF_TZoneOption(_IF_Option):
|
|
657
738
|
|
658
739
|
|
659
740
|
@schema_final
|
660
|
-
class IF_FilterOption(_IF_Option):
|
741
|
+
class IF_FilterOption(_IF_Option, code=Enum_OptionType.if_filter):
|
661
742
|
"""Header schema for PCAP-NG file ``if_filter`` options."""
|
662
743
|
|
663
744
|
#: Filter code.
|
@@ -672,7 +753,7 @@ class IF_FilterOption(_IF_Option):
|
|
672
753
|
|
673
754
|
|
674
755
|
@schema_final
|
675
|
-
class IF_OSOption(_IF_Option):
|
756
|
+
class IF_OSOption(_IF_Option, code=Enum_OptionType.if_os):
|
676
757
|
"""Header schema for PCAP-NG file ``if_os`` options."""
|
677
758
|
|
678
759
|
#: OS information.
|
@@ -685,7 +766,7 @@ class IF_OSOption(_IF_Option):
|
|
685
766
|
|
686
767
|
|
687
768
|
@schema_final
|
688
|
-
class IF_FCSLenOption(_IF_Option):
|
769
|
+
class IF_FCSLenOption(_IF_Option, code=Enum_OptionType.if_fcslen):
|
689
770
|
"""Header schema for PCAP-NG file ``if_fcslen`` options."""
|
690
771
|
|
691
772
|
#: FCS length.
|
@@ -698,7 +779,7 @@ class IF_FCSLenOption(_IF_Option):
|
|
698
779
|
|
699
780
|
|
700
781
|
@schema_final
|
701
|
-
class IF_TSOffsetOption(_IF_Option):
|
782
|
+
class IF_TSOffsetOption(_IF_Option, code=Enum_OptionType.if_tsoffset):
|
702
783
|
"""Header schema for PCAP-NG file ``if_tsoffset`` options."""
|
703
784
|
|
704
785
|
#: Timestamp offset (in seconds).
|
@@ -711,7 +792,7 @@ class IF_TSOffsetOption(_IF_Option):
|
|
711
792
|
|
712
793
|
|
713
794
|
@schema_final
|
714
|
-
class IF_HardwareOption(_IF_Option):
|
795
|
+
class IF_HardwareOption(_IF_Option, code=Enum_OptionType.if_hardware):
|
715
796
|
"""Header schema for PCAP-NG file ``if_hardware`` options."""
|
716
797
|
|
717
798
|
#: Hardware information.
|
@@ -724,7 +805,7 @@ class IF_HardwareOption(_IF_Option):
|
|
724
805
|
|
725
806
|
|
726
807
|
@schema_final
|
727
|
-
class IF_TxSpeedOption(_IF_Option):
|
808
|
+
class IF_TxSpeedOption(_IF_Option, code=Enum_OptionType.if_txspeed):
|
728
809
|
"""Header schema for PCAP-NG file ``if_txspeed`` options."""
|
729
810
|
|
730
811
|
#: Interface transmit speed, in bits per second.
|
@@ -737,7 +818,7 @@ class IF_TxSpeedOption(_IF_Option):
|
|
737
818
|
|
738
819
|
|
739
820
|
@schema_final
|
740
|
-
class IF_RxSpeedOption(_IF_Option):
|
821
|
+
class IF_RxSpeedOption(_IF_Option, code=Enum_OptionType.if_rxspeed):
|
741
822
|
"""Header schema for PCAP-NG file ``if_rxspeed`` options."""
|
742
823
|
|
743
824
|
#: Interface receive speed, in bits per second.
|
@@ -750,7 +831,7 @@ class IF_RxSpeedOption(_IF_Option):
|
|
750
831
|
|
751
832
|
|
752
833
|
@schema_final
|
753
|
-
class InterfaceDescriptionBlock(BlockType):
|
834
|
+
class InterfaceDescriptionBlock(BlockType, code=Enum_BlockType.Interface_Description_Block):
|
754
835
|
"""Header schema for PCAP-NG Interface Description Block (IDB)."""
|
755
836
|
|
756
837
|
#: Block total length.
|
@@ -766,30 +847,7 @@ class InterfaceDescriptionBlock(BlockType):
|
|
766
847
|
length=lambda pkt: pkt['length'] - 20,
|
767
848
|
base_schema=_IF_Option,
|
768
849
|
type_name='type',
|
769
|
-
registry=
|
770
|
-
Enum_OptionType.opt_endofopt: EndOfOption,
|
771
|
-
Enum_OptionType.opt_comment: CommentOption,
|
772
|
-
Enum_OptionType.opt_custom_2988: CustomOption,
|
773
|
-
Enum_OptionType.opt_custom_2989: CustomOption,
|
774
|
-
Enum_OptionType.opt_custom_19372: CustomOption,
|
775
|
-
Enum_OptionType.opt_custom_19373: CustomOption,
|
776
|
-
Enum_OptionType.if_name: IF_NameOption,
|
777
|
-
Enum_OptionType.if_description: IF_DescriptionOption,
|
778
|
-
Enum_OptionType.if_IPv4addr: IF_IPv4AddrOption,
|
779
|
-
Enum_OptionType.if_IPv6addr: IF_IPv6AddrOption,
|
780
|
-
Enum_OptionType.if_MACaddr: IF_MACAddrOption,
|
781
|
-
Enum_OptionType.if_EUIaddr: IF_EUIAddrOption,
|
782
|
-
Enum_OptionType.if_speed: IF_SpeedOption,
|
783
|
-
Enum_OptionType.if_tsresol: IF_TSResolOption,
|
784
|
-
Enum_OptionType.if_tzone: IF_TZoneOption,
|
785
|
-
Enum_OptionType.if_filter: IF_FilterOption,
|
786
|
-
Enum_OptionType.if_os: IF_OSOption,
|
787
|
-
Enum_OptionType.if_fcslen: IF_FCSLenOption,
|
788
|
-
Enum_OptionType.if_tsoffset: IF_TSOffsetOption,
|
789
|
-
Enum_OptionType.if_hardware: IF_HardwareOption,
|
790
|
-
Enum_OptionType.if_txspeed: IF_TxSpeedOption,
|
791
|
-
Enum_OptionType.if_rxspeed: IF_RxSpeedOption,
|
792
|
-
}),
|
850
|
+
registry=Option.registry['if'],
|
793
851
|
eool=Enum_OptionType.opt_endofopt,
|
794
852
|
)
|
795
853
|
#: Padding.
|
@@ -802,7 +860,7 @@ class InterfaceDescriptionBlock(BlockType):
|
|
802
860
|
options: 'list[Option | bytes] | bytes', length2: 'int') -> 'None': ...
|
803
861
|
|
804
862
|
|
805
|
-
class _EPB_Option(Option):
|
863
|
+
class _EPB_Option(Option, namespace='epb'):
|
806
864
|
"""Header schema for ``epb_*`` options."""
|
807
865
|
|
808
866
|
#: Option type.
|
@@ -812,7 +870,7 @@ class _EPB_Option(Option):
|
|
812
870
|
|
813
871
|
|
814
872
|
@schema_final
|
815
|
-
class EPB_FlagsOption(_EPB_Option):
|
873
|
+
class EPB_FlagsOption(_EPB_Option, code=Enum_OptionType.epb_flags):
|
816
874
|
"""Header schema for PCAP-NG ``epb_flags`` options."""
|
817
875
|
|
818
876
|
#: Flags.
|
@@ -837,7 +895,7 @@ class EPB_FlagsOption(_EPB_Option):
|
|
837
895
|
|
838
896
|
|
839
897
|
@schema_final
|
840
|
-
class EPB_HashOption(_EPB_Option):
|
898
|
+
class EPB_HashOption(_EPB_Option, code=Enum_OptionType.epb_hash):
|
841
899
|
"""Header schema for PCAP-NG ``epb_hash`` options."""
|
842
900
|
|
843
901
|
#: Hash algorithm.
|
@@ -852,7 +910,7 @@ class EPB_HashOption(_EPB_Option):
|
|
852
910
|
|
853
911
|
|
854
912
|
@schema_final
|
855
|
-
class EPB_DropCountOption(_EPB_Option):
|
913
|
+
class EPB_DropCountOption(_EPB_Option, code=Enum_OptionType.epb_dropcount):
|
856
914
|
"""Header schema for PCAP-NG ``epb_dropcount`` options."""
|
857
915
|
|
858
916
|
#: Number of packets dropped by the interface.
|
@@ -865,7 +923,7 @@ class EPB_DropCountOption(_EPB_Option):
|
|
865
923
|
|
866
924
|
|
867
925
|
@schema_final
|
868
|
-
class EPB_PacketIDOption(_EPB_Option):
|
926
|
+
class EPB_PacketIDOption(_EPB_Option, code=Enum_OptionType.epb_packetid):
|
869
927
|
"""Header schema for PCAP-NG ``epb_packetid`` options."""
|
870
928
|
|
871
929
|
#: Packet ID.
|
@@ -878,7 +936,7 @@ class EPB_PacketIDOption(_EPB_Option):
|
|
878
936
|
|
879
937
|
|
880
938
|
@schema_final
|
881
|
-
class EPB_QueueOption(_EPB_Option):
|
939
|
+
class EPB_QueueOption(_EPB_Option, code=Enum_OptionType.epb_queue):
|
882
940
|
"""Header schema for PCAP-NG ``epb_queue`` options."""
|
883
941
|
|
884
942
|
#: Queue ID.
|
@@ -891,7 +949,7 @@ class EPB_QueueOption(_EPB_Option):
|
|
891
949
|
|
892
950
|
|
893
951
|
@schema_final
|
894
|
-
class EPB_VerdictOption(_EPB_Option):
|
952
|
+
class EPB_VerdictOption(_EPB_Option, code=Enum_OptionType.epb_verdict):
|
895
953
|
"""Header schema for PCAP-NG ``epb_verdict`` options."""
|
896
954
|
|
897
955
|
#: Verdict type.
|
@@ -906,7 +964,7 @@ class EPB_VerdictOption(_EPB_Option):
|
|
906
964
|
|
907
965
|
|
908
966
|
@schema_final
|
909
|
-
class EnhancedPacketBlock(BlockType):
|
967
|
+
class EnhancedPacketBlock(BlockType, code=Enum_BlockType.Enhanced_Packet_Block):
|
910
968
|
"""Header schema for PCAP-NG Enhanced Packet Block (EPB)."""
|
911
969
|
|
912
970
|
__payload__ = 'packet_data'
|
@@ -932,20 +990,7 @@ class EnhancedPacketBlock(BlockType):
|
|
932
990
|
length=lambda pkt: pkt['length'] - 32 - pkt['captured_len'] - len(pkt['padding_data']),
|
933
991
|
base_schema=_EPB_Option,
|
934
992
|
type_name='type',
|
935
|
-
registry=
|
936
|
-
Enum_OptionType.opt_endofopt: EndOfOption,
|
937
|
-
Enum_OptionType.opt_comment: CommentOption,
|
938
|
-
Enum_OptionType.opt_custom_2988: CustomOption,
|
939
|
-
Enum_OptionType.opt_custom_2989: CustomOption,
|
940
|
-
Enum_OptionType.opt_custom_19372: CustomOption,
|
941
|
-
Enum_OptionType.opt_custom_19373: CustomOption,
|
942
|
-
Enum_OptionType.epb_flags: EPB_FlagsOption,
|
943
|
-
Enum_OptionType.epb_hash: EPB_HashOption,
|
944
|
-
Enum_OptionType.epb_dropcount: EPB_DropCountOption,
|
945
|
-
Enum_OptionType.epb_packetid: EPB_PacketIDOption,
|
946
|
-
Enum_OptionType.epb_queue: EPB_QueueOption,
|
947
|
-
Enum_OptionType.epb_verdict: EPB_VerdictOption,
|
948
|
-
}),
|
993
|
+
registry=Option.registry['epb'],
|
949
994
|
eool=Enum_OptionType.opt_endofopt,
|
950
995
|
)
|
951
996
|
#: Padding.
|
@@ -961,7 +1006,7 @@ class EnhancedPacketBlock(BlockType):
|
|
961
1006
|
|
962
1007
|
|
963
1008
|
@schema_final
|
964
|
-
class SimplePacketBlock(BlockType):
|
1009
|
+
class SimplePacketBlock(BlockType, code=Enum_BlockType.Simple_Packet_Block):
|
965
1010
|
"""Header schema for PCAP-NG Simple Packet Block (SPB)."""
|
966
1011
|
|
967
1012
|
__payload__ = 'packet_data'
|
@@ -984,9 +1029,11 @@ class SimplePacketBlock(BlockType):
|
|
984
1029
|
length2: 'int') -> 'None': ...
|
985
1030
|
|
986
1031
|
|
987
|
-
class NameResolutionRecord(
|
1032
|
+
class NameResolutionRecord(EnumSchema[Enum_RecordType]):
|
988
1033
|
"""Header schema for PCAP-NG NRB records."""
|
989
1034
|
|
1035
|
+
__default__ = lambda: UnknownRecord
|
1036
|
+
|
990
1037
|
#: Record type.
|
991
1038
|
type: 'Enum_RecordType' = EnumField(length=2, namespace=Enum_RecordType, callback=byteorder_callback)
|
992
1039
|
#: Record value length.
|
@@ -1007,7 +1054,7 @@ class UnknownRecord(NameResolutionRecord):
|
|
1007
1054
|
|
1008
1055
|
|
1009
1056
|
@schema_final
|
1010
|
-
class EndRecord(NameResolutionRecord):
|
1057
|
+
class EndRecord(NameResolutionRecord, code=Enum_RecordType.nrb_record_end):
|
1011
1058
|
"""Header schema for PCAP-NG ``nrb_record_end`` records."""
|
1012
1059
|
|
1013
1060
|
if TYPE_CHECKING:
|
@@ -1015,7 +1062,7 @@ class EndRecord(NameResolutionRecord):
|
|
1015
1062
|
|
1016
1063
|
|
1017
1064
|
@schema_final
|
1018
|
-
class IPv4Record(NameResolutionRecord):
|
1065
|
+
class IPv4Record(NameResolutionRecord, code=Enum_RecordType.nrb_record_ipv4):
|
1019
1066
|
"""Header schema for PCAP-NG NRB ``nrb_record_ipv4`` records."""
|
1020
1067
|
|
1021
1068
|
#: IPv4 address.
|
@@ -1046,7 +1093,7 @@ class IPv4Record(NameResolutionRecord):
|
|
1046
1093
|
|
1047
1094
|
|
1048
1095
|
@schema_final
|
1049
|
-
class IPv6Record(NameResolutionRecord):
|
1096
|
+
class IPv6Record(NameResolutionRecord, code=Enum_RecordType.nrb_record_ipv6):
|
1050
1097
|
"""Header schema for PCAP-NG NRB ``nrb_record_ipv4`` records."""
|
1051
1098
|
|
1052
1099
|
#: IPv4 address.
|
@@ -1076,7 +1123,7 @@ class IPv6Record(NameResolutionRecord):
|
|
1076
1123
|
def __init__(self, type: 'Enum_RecordType', length: 'int', ip: 'IPv6Address | str | bytes | int', resol: 'str') -> 'None': ...
|
1077
1124
|
|
1078
1125
|
|
1079
|
-
class _NS_Option(Option):
|
1126
|
+
class _NS_Option(Option, namespace='ns'):
|
1080
1127
|
"""Header schema for ``ns_*`` options."""
|
1081
1128
|
|
1082
1129
|
#: Option type.
|
@@ -1086,7 +1133,7 @@ class _NS_Option(Option):
|
|
1086
1133
|
|
1087
1134
|
|
1088
1135
|
@schema_final
|
1089
|
-
class NS_DNSNameOption(_NS_Option):
|
1136
|
+
class NS_DNSNameOption(_NS_Option, code=Enum_OptionType.ns_dnsname):
|
1090
1137
|
"""Header schema for PCAP-NG ``ns_dnsname`` option."""
|
1091
1138
|
|
1092
1139
|
#: DNS name.
|
@@ -1097,7 +1144,7 @@ class NS_DNSNameOption(_NS_Option):
|
|
1097
1144
|
|
1098
1145
|
|
1099
1146
|
@schema_final
|
1100
|
-
class NS_DNSIP4AddrOption(_NS_Option):
|
1147
|
+
class NS_DNSIP4AddrOption(_NS_Option, code=Enum_OptionType.ns_dnsIP4addr):
|
1101
1148
|
"""Header schema for PCAP-NG ``ns_dnsIP4addr`` option."""
|
1102
1149
|
|
1103
1150
|
#: IPv4 address.
|
@@ -1108,7 +1155,7 @@ class NS_DNSIP4AddrOption(_NS_Option):
|
|
1108
1155
|
|
1109
1156
|
|
1110
1157
|
@schema_final
|
1111
|
-
class NS_DNSIP6AddrOption(_NS_Option):
|
1158
|
+
class NS_DNSIP6AddrOption(_NS_Option, code=Enum_OptionType.ns_dnsIP6addr):
|
1112
1159
|
"""Header schema for PCAP-NG ``ns_dnsIP6addr`` option."""
|
1113
1160
|
|
1114
1161
|
#: IPv6 address.
|
@@ -1119,7 +1166,7 @@ class NS_DNSIP6AddrOption(_NS_Option):
|
|
1119
1166
|
|
1120
1167
|
|
1121
1168
|
@schema_final
|
1122
|
-
class NameResolutionBlock(BlockType):
|
1169
|
+
class NameResolutionBlock(BlockType, code=Enum_BlockType.Name_Resolution_Block):
|
1123
1170
|
"""Header schema for PCAP-NG Name Resolution Block (NRB)."""
|
1124
1171
|
|
1125
1172
|
#: Record total length.
|
@@ -1129,11 +1176,7 @@ class NameResolutionBlock(BlockType):
|
|
1129
1176
|
length=lambda pkt: pkt['length'] - 12,
|
1130
1177
|
base_schema=NameResolutionRecord,
|
1131
1178
|
type_name='type',
|
1132
|
-
registry=
|
1133
|
-
Enum_RecordType.nrb_record_end: EndRecord,
|
1134
|
-
Enum_RecordType.nrb_record_ipv4: IPv4Record,
|
1135
|
-
Enum_RecordType.nrb_record_ipv6: IPv6Record,
|
1136
|
-
}),
|
1179
|
+
registry=NameResolutionRecord.registry,
|
1137
1180
|
eool=Enum_RecordType.nrb_record_end,
|
1138
1181
|
)
|
1139
1182
|
#: Options.
|
@@ -1141,17 +1184,7 @@ class NameResolutionBlock(BlockType):
|
|
1141
1184
|
length=lambda pkt: pkt['__option_padding__'] - 4 if pkt['__option_padding__'] else 0,
|
1142
1185
|
base_schema=_NS_Option,
|
1143
1186
|
type_name='type',
|
1144
|
-
registry=
|
1145
|
-
Enum_OptionType.opt_endofopt: EndOfOption,
|
1146
|
-
Enum_OptionType.opt_comment: CommentOption,
|
1147
|
-
Enum_OptionType.opt_custom_2988: CustomOption,
|
1148
|
-
Enum_OptionType.opt_custom_2989: CustomOption,
|
1149
|
-
Enum_OptionType.opt_custom_19372: CustomOption,
|
1150
|
-
Enum_OptionType.opt_custom_19373: CustomOption,
|
1151
|
-
Enum_OptionType.ns_dnsname: NS_DNSNameOption,
|
1152
|
-
Enum_OptionType.ns_dnsIP4addr: NS_DNSIP4AddrOption,
|
1153
|
-
Enum_OptionType.ns_dnsIP6addr: NS_DNSIP6AddrOption,
|
1154
|
-
}),
|
1187
|
+
registry=Option.registry['ns'],
|
1155
1188
|
eool=Enum_OptionType.opt_endofopt,
|
1156
1189
|
)
|
1157
1190
|
#: Padding.
|
@@ -1195,7 +1228,7 @@ class NameResolutionBlock(BlockType):
|
|
1195
1228
|
options: 'list[Option | bytes] | bytes', length2: 'int') -> 'None': ...
|
1196
1229
|
|
1197
1230
|
|
1198
|
-
class _ISB_Option(Option):
|
1231
|
+
class _ISB_Option(Option, namespace='isb'):
|
1199
1232
|
"""Header schema for ``isb_*`` options."""
|
1200
1233
|
|
1201
1234
|
#: Option type.
|
@@ -1205,7 +1238,7 @@ class _ISB_Option(Option):
|
|
1205
1238
|
|
1206
1239
|
|
1207
1240
|
@schema_final
|
1208
|
-
class ISB_StartTimeOption(_ISB_Option):
|
1241
|
+
class ISB_StartTimeOption(_ISB_Option, code=Enum_OptionType.isb_starttime):
|
1209
1242
|
"""Header schema for PCAP-NG ``isb_starttime`` option."""
|
1210
1243
|
|
1211
1244
|
#: Timestamp (higher 32 bits).
|
@@ -1218,7 +1251,7 @@ class ISB_StartTimeOption(_ISB_Option):
|
|
1218
1251
|
|
1219
1252
|
|
1220
1253
|
@schema_final
|
1221
|
-
class ISB_EndTimeOption(_ISB_Option):
|
1254
|
+
class ISB_EndTimeOption(_ISB_Option, code=Enum_OptionType.isb_endtime):
|
1222
1255
|
"""Header schema for PCAP-NG ``isb_endtime`` option."""
|
1223
1256
|
|
1224
1257
|
#: Timestamp (higher 32 bits).
|
@@ -1231,7 +1264,7 @@ class ISB_EndTimeOption(_ISB_Option):
|
|
1231
1264
|
|
1232
1265
|
|
1233
1266
|
@schema_final
|
1234
|
-
class ISB_IFRecvOption(_ISB_Option):
|
1267
|
+
class ISB_IFRecvOption(_ISB_Option, code=Enum_OptionType.isb_ifrecv):
|
1235
1268
|
"""Header schema for PCAP-NG ``isb_ifrecv`` option."""
|
1236
1269
|
|
1237
1270
|
#: Number of packets received.
|
@@ -1242,7 +1275,7 @@ class ISB_IFRecvOption(_ISB_Option):
|
|
1242
1275
|
|
1243
1276
|
|
1244
1277
|
@schema_final
|
1245
|
-
class ISB_IFDropOption(_ISB_Option):
|
1278
|
+
class ISB_IFDropOption(_ISB_Option, code=Enum_OptionType.isb_ifdrop):
|
1246
1279
|
"""Header schema for PCAP-NG ``isb_ifdrop`` option."""
|
1247
1280
|
|
1248
1281
|
#: Number of packets dropped.
|
@@ -1253,7 +1286,7 @@ class ISB_IFDropOption(_ISB_Option):
|
|
1253
1286
|
|
1254
1287
|
|
1255
1288
|
@schema_final
|
1256
|
-
class ISB_FilterAcceptOption(_ISB_Option):
|
1289
|
+
class ISB_FilterAcceptOption(_ISB_Option, code=Enum_OptionType.isb_filteraccept):
|
1257
1290
|
"""Header schema for PCAP-NG ``isb_filteraccept`` option."""
|
1258
1291
|
|
1259
1292
|
#: Number of packets accepted by filter.
|
@@ -1264,7 +1297,7 @@ class ISB_FilterAcceptOption(_ISB_Option):
|
|
1264
1297
|
|
1265
1298
|
|
1266
1299
|
@schema_final
|
1267
|
-
class ISB_OSDropOption(_ISB_Option):
|
1300
|
+
class ISB_OSDropOption(_ISB_Option, code=Enum_OptionType.isb_osdrop):
|
1268
1301
|
"""Header schema for PCAP-NG ``isb_osdrop`` option."""
|
1269
1302
|
|
1270
1303
|
#: Number of packets dropped by OS.
|
@@ -1275,7 +1308,7 @@ class ISB_OSDropOption(_ISB_Option):
|
|
1275
1308
|
|
1276
1309
|
|
1277
1310
|
@schema_final
|
1278
|
-
class ISB_UsrDelivOption(_ISB_Option):
|
1311
|
+
class ISB_UsrDelivOption(_ISB_Option, code=Enum_OptionType.isb_usrdeliv):
|
1279
1312
|
"""Header schema for PCAP-NG ``isb_usrdeliv`` option."""
|
1280
1313
|
|
1281
1314
|
#: Number of packets delivered to user.
|
@@ -1302,21 +1335,7 @@ class InterfaceStatisticsBlock(BlockType):
|
|
1302
1335
|
length=lambda pkt: pkt['length'] - 20,
|
1303
1336
|
base_schema=_ISB_Option,
|
1304
1337
|
type_name='type',
|
1305
|
-
registry=
|
1306
|
-
Enum_OptionType.opt_endofopt: EndOfOption,
|
1307
|
-
Enum_OptionType.opt_comment: CommentOption,
|
1308
|
-
Enum_OptionType.opt_custom_2988: CustomOption,
|
1309
|
-
Enum_OptionType.opt_custom_2989: CustomOption,
|
1310
|
-
Enum_OptionType.opt_custom_19372: CustomOption,
|
1311
|
-
Enum_OptionType.opt_custom_19373: CustomOption,
|
1312
|
-
Enum_OptionType.isb_starttime: ISB_StartTimeOption,
|
1313
|
-
Enum_OptionType.isb_endtime: ISB_EndTimeOption,
|
1314
|
-
Enum_OptionType.isb_ifrecv: ISB_IFRecvOption,
|
1315
|
-
Enum_OptionType.isb_ifdrop: ISB_IFDropOption,
|
1316
|
-
Enum_OptionType.isb_filteraccept: ISB_FilterAcceptOption,
|
1317
|
-
Enum_OptionType.isb_osdrop: ISB_OSDropOption,
|
1318
|
-
Enum_OptionType.isb_usrdeliv: ISB_UsrDelivOption,
|
1319
|
-
}),
|
1338
|
+
registry=Option.registry['isb'],
|
1320
1339
|
eool=Enum_OptionType.opt_endofopt,
|
1321
1340
|
)
|
1322
1341
|
#: Padding.
|
@@ -1331,7 +1350,7 @@ class InterfaceStatisticsBlock(BlockType):
|
|
1331
1350
|
|
1332
1351
|
|
1333
1352
|
@schema_final
|
1334
|
-
class SystemdJournalExportBlock(BlockType):
|
1353
|
+
class SystemdJournalExportBlock(BlockType, code=Enum_BlockType.systemd_Journal_Export_Block):
|
1335
1354
|
"""Header schema for PCAP-NG :manpage:`systemd(1)` Journal Export Block."""
|
1336
1355
|
|
1337
1356
|
#: Block total length.
|
@@ -1383,9 +1402,11 @@ class SystemdJournalExportBlock(BlockType):
|
|
1383
1402
|
def __init__(self, length: 'int', entry: 'bytes', length2: 'int') -> 'None': ...
|
1384
1403
|
|
1385
1404
|
|
1386
|
-
class DSBSecrets(
|
1405
|
+
class DSBSecrets(EnumSchema[Enum_SecretsType]):
|
1387
1406
|
"""Header schema for DSB secrets data."""
|
1388
1407
|
|
1408
|
+
__default__ = lambda: UnknownSecrets
|
1409
|
+
|
1389
1410
|
|
1390
1411
|
@schema_final
|
1391
1412
|
class UnknownSecrets(DSBSecrets):
|
@@ -1399,7 +1420,7 @@ class UnknownSecrets(DSBSecrets):
|
|
1399
1420
|
|
1400
1421
|
|
1401
1422
|
@schema_final
|
1402
|
-
class TLSKeyLog(DSBSecrets):
|
1423
|
+
class TLSKeyLog(DSBSecrets, code=Enum_SecretsType.TLS_Key_Log):
|
1403
1424
|
"""Header schema for TLS Key Log secrets data."""
|
1404
1425
|
|
1405
1426
|
#: TLS key log data.
|
@@ -1438,7 +1459,7 @@ class TLSKeyLog(DSBSecrets):
|
|
1438
1459
|
|
1439
1460
|
|
1440
1461
|
@schema_final
|
1441
|
-
class WireGuardKeyLog(DSBSecrets):
|
1462
|
+
class WireGuardKeyLog(DSBSecrets, code=Enum_SecretsType.WireGuard_Key_Log):
|
1442
1463
|
"""Header schema for WireGuard Key Log secrets data."""
|
1443
1464
|
|
1444
1465
|
#: WireGuard key log data.
|
@@ -1478,7 +1499,7 @@ class WireGuardKeyLog(DSBSecrets):
|
|
1478
1499
|
|
1479
1500
|
|
1480
1501
|
@schema_final
|
1481
|
-
class ZigBeeNWKKey(DSBSecrets):
|
1502
|
+
class ZigBeeNWKKey(DSBSecrets, code=Enum_SecretsType.ZigBee_NWK_Key):
|
1482
1503
|
"""Header schema for ZigBee NWK Key and ZigBee PANID secrets data."""
|
1483
1504
|
|
1484
1505
|
#: AES-128 NKW key.
|
@@ -1493,7 +1514,7 @@ class ZigBeeNWKKey(DSBSecrets):
|
|
1493
1514
|
|
1494
1515
|
|
1495
1516
|
@schema_final
|
1496
|
-
class ZigBeeAPSKey(DSBSecrets):
|
1517
|
+
class ZigBeeAPSKey(DSBSecrets, code=Enum_SecretsType.ZigBee_APS_Key):
|
1497
1518
|
"""Header schema for ZigBee APS Key secrets data."""
|
1498
1519
|
|
1499
1520
|
#: AES-128 APS key.
|
@@ -1511,7 +1532,7 @@ class ZigBeeAPSKey(DSBSecrets):
|
|
1511
1532
|
def __init__(self, key: 'bytes', panid: 'int', addr_low: 'int', addr_high: 'int') -> 'None': ...
|
1512
1533
|
|
1513
1534
|
|
1514
|
-
class _DSB_Option(Option):
|
1535
|
+
class _DSB_Option(Option, namespace='dsb'):
|
1515
1536
|
"""Header schema for ``dsb_*`` options."""
|
1516
1537
|
|
1517
1538
|
#: Option type.
|
@@ -1521,7 +1542,7 @@ class _DSB_Option(Option):
|
|
1521
1542
|
|
1522
1543
|
|
1523
1544
|
@schema_final
|
1524
|
-
class DecryptionSecretsBlock(BlockType):
|
1545
|
+
class DecryptionSecretsBlock(BlockType, code=Enum_BlockType.Decryption_Secrets_Block):
|
1525
1546
|
"""Header schema for PCAP-NG Decryption Secrets Block (DSB)."""
|
1526
1547
|
|
1527
1548
|
#: Block total length.
|
@@ -1541,14 +1562,7 @@ class DecryptionSecretsBlock(BlockType):
|
|
1541
1562
|
length=lambda pkt: pkt['length'] - 20 - pkt['secrets_length'] - len(pkt['padding_data']),
|
1542
1563
|
base_schema=_DSB_Option,
|
1543
1564
|
type_name='type',
|
1544
|
-
registry=
|
1545
|
-
Enum_OptionType.opt_endofopt: EndOfOption,
|
1546
|
-
Enum_OptionType.opt_comment: CommentOption,
|
1547
|
-
Enum_OptionType.opt_custom_2988: CustomOption,
|
1548
|
-
Enum_OptionType.opt_custom_2989: CustomOption,
|
1549
|
-
Enum_OptionType.opt_custom_19372: CustomOption,
|
1550
|
-
Enum_OptionType.opt_custom_19373: CustomOption,
|
1551
|
-
}),
|
1565
|
+
registry=Option.registry['dsb'],
|
1552
1566
|
eool=Enum_OptionType.opt_endofopt,
|
1553
1567
|
)
|
1554
1568
|
#: Padding.
|
@@ -1563,7 +1577,8 @@ class DecryptionSecretsBlock(BlockType):
|
|
1563
1577
|
|
1564
1578
|
|
1565
1579
|
@schema_final
|
1566
|
-
class CustomBlock(BlockType
|
1580
|
+
class CustomBlock(BlockType, code=[Enum_BlockType.Custom_Block_that_rewriters_can_copy_into_new_files,
|
1581
|
+
Enum_BlockType.Custom_Block_that_rewriters_should_not_copy_into_new_files]):
|
1567
1582
|
"""Header schema for PCAP-NG Custom Block (CB)."""
|
1568
1583
|
|
1569
1584
|
#: Block total length.
|
@@ -1581,7 +1596,7 @@ class CustomBlock(BlockType):
|
|
1581
1596
|
def __init__(self, length: 'int', pen: 'int', data: 'bytes', length2: 'int') -> 'None': ...
|
1582
1597
|
|
1583
1598
|
|
1584
|
-
class _PACK_Option(Option):
|
1599
|
+
class _PACK_Option(Option, namespace='pack'):
|
1585
1600
|
"""Header schema for ``pack_*`` options."""
|
1586
1601
|
|
1587
1602
|
#: Option type.
|
@@ -1591,7 +1606,7 @@ class _PACK_Option(Option):
|
|
1591
1606
|
|
1592
1607
|
|
1593
1608
|
@schema_final
|
1594
|
-
class PACK_FlagsOption(_PACK_Option):
|
1609
|
+
class PACK_FlagsOption(_PACK_Option, code=Enum_OptionType.pack_flags):
|
1595
1610
|
"""Header schema for PCAP-NG ``pack_flags`` options."""
|
1596
1611
|
|
1597
1612
|
#: Flags.
|
@@ -1616,7 +1631,7 @@ class PACK_FlagsOption(_PACK_Option):
|
|
1616
1631
|
|
1617
1632
|
|
1618
1633
|
@schema_final
|
1619
|
-
class PACK_HashOption(_PACK_Option):
|
1634
|
+
class PACK_HashOption(_PACK_Option, code=Enum_OptionType.pack_hash):
|
1620
1635
|
"""Header schema for PCAP-NG ``pack_hash`` options."""
|
1621
1636
|
|
1622
1637
|
#: Hash algorithm.
|
@@ -1631,7 +1646,7 @@ class PACK_HashOption(_PACK_Option):
|
|
1631
1646
|
|
1632
1647
|
|
1633
1648
|
@schema_final
|
1634
|
-
class PacketBlock(BlockType):
|
1649
|
+
class PacketBlock(BlockType, code=Enum_BlockType.Packet_Block):
|
1635
1650
|
"""Header schema for PCAP-NG Packet Block (obsolete)."""
|
1636
1651
|
|
1637
1652
|
__payload__ = 'packet_data'
|
@@ -1659,16 +1674,7 @@ class PacketBlock(BlockType):
|
|
1659
1674
|
length=lambda pkt: pkt['length'] - 32 - pkt['captured_length'] - len(pkt['padding_data']),
|
1660
1675
|
base_schema=_PACK_Option,
|
1661
1676
|
type_name='type',
|
1662
|
-
registry=
|
1663
|
-
Enum_OptionType.opt_endofopt: EndOfOption,
|
1664
|
-
Enum_OptionType.opt_comment: CommentOption,
|
1665
|
-
Enum_OptionType.opt_custom_2988: CustomOption,
|
1666
|
-
Enum_OptionType.opt_custom_2989: CustomOption,
|
1667
|
-
Enum_OptionType.opt_custom_19372: CustomOption,
|
1668
|
-
Enum_OptionType.opt_custom_19373: CustomOption,
|
1669
|
-
Enum_OptionType.pack_flags: EPB_FlagsOption,
|
1670
|
-
Enum_OptionType.pack_hash: EPB_HashOption,
|
1671
|
-
}),
|
1677
|
+
registry=Option.registry['pack'],
|
1672
1678
|
eool=Enum_OptionType.opt_endofopt,
|
1673
1679
|
)
|
1674
1680
|
#: Padding.
|
@@ -1681,26 +1687,3 @@ class PacketBlock(BlockType):
|
|
1681
1687
|
timestamp_high: 'int', timestamp_low: 'int', captured_length: 'int',
|
1682
1688
|
original_length: 'int', packet_data: 'bytes | Protocol | Schema',
|
1683
1689
|
options: 'list[Option | bytes] | bytes', length2: 'int') -> 'None': ...
|
1684
|
-
|
1685
|
-
|
1686
|
-
#: DefaultDict[Enum_BlockType, Type[BlockType]]: Mapping of PCAP-NG block type numbers to schemas.
|
1687
|
-
MAP_PCAPNG_BLOCK = collections.defaultdict(lambda: UnknownBlock, {
|
1688
|
-
Enum_BlockType.Section_Header_Block: SectionHeaderBlock,
|
1689
|
-
Enum_BlockType.Interface_Description_Block: InterfaceDescriptionBlock,
|
1690
|
-
Enum_BlockType.Enhanced_Packet_Block: EnhancedPacketBlock,
|
1691
|
-
Enum_BlockType.Simple_Packet_Block: SimplePacketBlock,
|
1692
|
-
Enum_BlockType.Name_Resolution_Block: NameResolutionBlock,
|
1693
|
-
Enum_BlockType.systemd_Journal_Export_Block: SystemdJournalExportBlock,
|
1694
|
-
Enum_BlockType.Decryption_Secrets_Block: DecryptionSecretsBlock,
|
1695
|
-
Enum_BlockType.Custom_Block_that_rewriters_can_copy_into_new_files: CustomBlock,
|
1696
|
-
Enum_BlockType.Custom_Block_that_rewriters_should_not_copy_into_new_files: CustomBlock,
|
1697
|
-
Enum_BlockType.Packet_Block: PacketBlock,
|
1698
|
-
}) # type: DefaultDict[Enum_BlockType | int, Type[BlockType]]
|
1699
|
-
|
1700
|
-
#: DefaultDict[Enum_SecretsType, Type[DSBSecrets]]: Mapping of PCAP-NG description secrets type numbers to schemas.
|
1701
|
-
MAP_DSB_SECRETS = collections.defaultdict(lambda: UnknownSecrets, {
|
1702
|
-
Enum_SecretsType.TLS_Key_Log: TLSKeyLog,
|
1703
|
-
Enum_SecretsType.WireGuard_Key_Log: WireGuardKeyLog,
|
1704
|
-
Enum_SecretsType.ZigBee_NWK_Key: ZigBeeNWKKey,
|
1705
|
-
Enum_SecretsType.ZigBee_APS_Key: ZigBeeAPSKey,
|
1706
|
-
}) # type: DefaultDict[Enum_SecretsType | int, Type[DSBSecrets]]
|