pypcapkit 1.0.3__cp310-none-any.whl → 1.1.0__cp310-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 +4 -1
- pcapkit/const/reg/apptype.py +19019 -19015
- pcapkit/corekit/fields/collections.py +14 -14
- 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 +108 -16
- pcapkit/protocols/data/__init__.py +4 -4
- pcapkit/protocols/data/internet/__init__.py +4 -4
- pcapkit/protocols/data/internet/mh.py +8 -6
- pcapkit/protocols/data/transport/__init__.py +4 -4
- pcapkit/protocols/data/transport/tcp.py +4 -4
- pcapkit/protocols/internet/mh.py +21 -21
- pcapkit/protocols/protocol.py +3 -2
- pcapkit/protocols/schema/__init__.py +4 -4
- pcapkit/protocols/schema/application/httpv2.py +17 -33
- 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 +12 -21
- pcapkit/protocols/schema/internet/mh.py +57 -86
- pcapkit/protocols/schema/misc/pcapng.py +182 -193
- pcapkit/protocols/schema/schema.py +252 -53
- pcapkit/protocols/schema/transport/__init__.py +4 -4
- pcapkit/protocols/schema/transport/tcp.py +54 -81
- pcapkit/protocols/transport/tcp.py +14 -14
- pcapkit/vendor/pcapng/option_type.py +29 -2
- pcapkit/vendor/reg/apptype.py +34 -4
- {pypcapkit-1.0.3.dist-info → pypcapkit-1.1.0.dist-info}/METADATA +1 -1
- {pypcapkit-1.0.3.dist-info → pypcapkit-1.1.0.dist-info}/RECORD +41 -41
- {pypcapkit-1.0.3.dist-info → pypcapkit-1.1.0.dist-info}/LICENSE +0 -0
- {pypcapkit-1.0.3.dist-info → pypcapkit-1.1.0.dist-info}/WHEEL +0 -0
- {pypcapkit-1.0.3.dist-info → pypcapkit-1.1.0.dist-info}/entry_points.txt +0 -0
- {pypcapkit-1.0.3.dist-info → pypcapkit-1.1.0.dist-info}/top_level.txt +0 -0
@@ -23,13 +23,30 @@ from pcapkit.protocols.link.link import Link
|
|
23
23
|
from pcapkit.protocols.misc.pcap.frame import Frame
|
24
24
|
from pcapkit.protocols.misc.pcapng import PCAPNG
|
25
25
|
from pcapkit.protocols.protocol import Protocol
|
26
|
+
from pcapkit.protocols.schema.application.httpv2 import FrameType as Schema_HTTP_FrameType
|
27
|
+
from pcapkit.protocols.schema.internet.hip import Parameter as Schema_HIP_Parameter
|
28
|
+
from pcapkit.protocols.schema.internet.hopopt import Option as Schema_HOPOPT_Option
|
29
|
+
from pcapkit.protocols.schema.internet.ipv4 import Option as Schema_IPv4_Option
|
30
|
+
from pcapkit.protocols.schema.internet.ipv6_opts import Option as Schema_IPv6_Opts_Option
|
31
|
+
from pcapkit.protocols.schema.internet.ipv6_route import \
|
32
|
+
RoutingType as Schema_IPv6_Route_RoutingType
|
33
|
+
from pcapkit.protocols.schema.internet.mh import CGAExtension as Schema_MH_CGAExtension
|
34
|
+
from pcapkit.protocols.schema.internet.mh import Option as Schema_MH_Option
|
35
|
+
from pcapkit.protocols.schema.internet.mh import Packet as Schema_MH_Packet
|
36
|
+
from pcapkit.protocols.schema.misc.pcapng import BlockType as Schema_PCAPNG_BlockType
|
37
|
+
from pcapkit.protocols.schema.misc.pcapng import DSBSecrets as Schema_PCAPNG_DSBSecrets
|
38
|
+
from pcapkit.protocols.schema.misc.pcapng import \
|
39
|
+
NameResolutionRecord as Schema_PCAPNG_NameResolutionRecord
|
40
|
+
from pcapkit.protocols.schema.misc.pcapng import Option as Schema_PCAPNG_Option
|
41
|
+
from pcapkit.protocols.schema.transport.tcp import MPTCP as Schema_TCP_MPTCP
|
42
|
+
from pcapkit.protocols.schema.transport.tcp import Option as Schema_TCP_Option
|
26
43
|
from pcapkit.protocols.transport.tcp import TCP
|
27
44
|
from pcapkit.protocols.transport.udp import UDP
|
28
45
|
from pcapkit.utilities.exceptions import RegistryError
|
29
46
|
from pcapkit.utilities.logging import logger
|
30
47
|
|
31
48
|
if TYPE_CHECKING:
|
32
|
-
from typing import Type
|
49
|
+
from typing import Optional, Type
|
33
50
|
|
34
51
|
from typing_extensions import Literal
|
35
52
|
|
@@ -288,7 +305,8 @@ def register_transtype(code: 'TransType', module: 'str', class_: 'str') -> 'None
|
|
288
305
|
|
289
306
|
|
290
307
|
# NOTE: pcapkit.protocols.internet.internet.IPv4
|
291
|
-
def register_ipv4_option(code: 'IPv4_OptionNumber', meth: 'str | tuple[IPv4_OptionParser, IPv4_OptionConstructor]'
|
308
|
+
def register_ipv4_option(code: 'IPv4_OptionNumber', meth: 'str | tuple[IPv4_OptionParser, IPv4_OptionConstructor]', *,
|
309
|
+
schema: 'Optional[Type[Schema_IPv4_Option]]' = None) -> 'None':
|
292
310
|
"""Register an option parser.
|
293
311
|
|
294
312
|
The function will register the given option parser to the
|
@@ -298,17 +316,22 @@ def register_ipv4_option(code: 'IPv4_OptionNumber', meth: 'str | tuple[IPv4_Opti
|
|
298
316
|
code: :class:`IPv4 <pcapkit.protocols.internet.internet.IPv4>` option code as
|
299
317
|
in :class:`~pcapkit.const.ipv4.option_number.OptionNumber`.
|
300
318
|
meth: Method name or callable to parse and/or construct the option.
|
319
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
320
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.internet.ipv4.Option`.
|
301
321
|
|
302
322
|
"""
|
303
323
|
if isinstance(meth, str) and not hasattr(IPv4, f'_read_opt_{meth}'):
|
304
324
|
raise RegistryError('method must be a valid IPv4 option parser function')
|
305
325
|
|
306
326
|
IPv4.register_option(code, meth)
|
327
|
+
if schema is not None:
|
328
|
+
Schema_IPv4_Option.register(code, schema)
|
307
329
|
logger.info('registered IPv4 option parser: %s', code.name)
|
308
330
|
|
309
331
|
|
310
332
|
# NOTE: pcapkit.protocols.internet.hip.HIP
|
311
|
-
def register_hip_parameter(code: 'HIP_Parameter', meth: 'str | tuple[HIP_ParameterParser, HIP_ParameterConstructor]'
|
333
|
+
def register_hip_parameter(code: 'HIP_Parameter', meth: 'str | tuple[HIP_ParameterParser, HIP_ParameterConstructor]', *,
|
334
|
+
schema: 'Optional[Type[Schema_HIP_Parameter]]' = None) -> 'None':
|
312
335
|
"""Register a parameter parser.
|
313
336
|
|
314
337
|
The function will register the given parameter parser to the
|
@@ -318,17 +341,22 @@ def register_hip_parameter(code: 'HIP_Parameter', meth: 'str | tuple[HIP_Paramet
|
|
318
341
|
code: :class:`~pcapkit.protocols.internet.hip.HIP` parameter code as
|
319
342
|
in :class:`~pcapkit.const.hip.parameter.Parameter`.
|
320
343
|
meth: Method name or callable to parse and/or construct the parameter.
|
344
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the parameter.
|
345
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.internet.hip.Parameter`.
|
321
346
|
|
322
347
|
"""
|
323
348
|
if isinstance(meth, str) and not hasattr(HIP, f'_read_param_{meth}'):
|
324
349
|
raise RegistryError('method must be a valid HIP parameter parser function')
|
325
350
|
|
326
351
|
HIP.register_parameter(code, meth)
|
352
|
+
if schema is not None:
|
353
|
+
Schema_HIP_Parameter.register(code, schema)
|
327
354
|
logger.info('registered HIP parameter parser: %s', code.name)
|
328
355
|
|
329
356
|
|
330
357
|
# NOTE: pcapkit.protocols.internet.hopopt.HOPOPT.__option__
|
331
|
-
def register_hopopt_option(code: 'IPv6_Option', meth: 'str | tuple[HOPOPT_OptionParser, HOPOPT_OptionConstructor]'
|
358
|
+
def register_hopopt_option(code: 'IPv6_Option', meth: 'str | tuple[HOPOPT_OptionParser, HOPOPT_OptionConstructor]', *,
|
359
|
+
schema: 'Optional[Type[Schema_HOPOPT_Option]]' = None) -> 'None':
|
332
360
|
"""Register an option parser.
|
333
361
|
|
334
362
|
The function will register the given option parser to the
|
@@ -338,17 +366,22 @@ def register_hopopt_option(code: 'IPv6_Option', meth: 'str | tuple[HOPOPT_Option
|
|
338
366
|
code: :class:`~pcapkit.protocols.internet.hopopt.HOPOPT` option code as
|
339
367
|
in :class:`~pcapkit.const.ipv6.option.Option`.
|
340
368
|
meth: Method name or callable to parse and/or construct the option.
|
369
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
370
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.internet.hopopt.Option`.
|
341
371
|
|
342
372
|
"""
|
343
373
|
if isinstance(meth, str) and not hasattr(HOPOPT, f'_read_opt_{meth}'):
|
344
374
|
raise RegistryError('method must be a valid HOPOPT option parser function')
|
345
375
|
|
346
376
|
HOPOPT.register_option(code, meth)
|
377
|
+
if schema is not None:
|
378
|
+
Schema_HOPOPT_Option.register(code, schema)
|
347
379
|
logger.info('registered HOPOPT option parser: %s', code.name)
|
348
380
|
|
349
381
|
|
350
382
|
# NOTE: pcapkit.protocols.internet.ipv6_opts.IPv6_Opts.__option__
|
351
|
-
def register_ipv6_opts_option(code: 'IPv6_Option', meth: 'str | tuple[IPv6_Opts_OptionParser, IPv6_Opts_OptionConstructor]'
|
383
|
+
def register_ipv6_opts_option(code: 'IPv6_Option', meth: 'str | tuple[IPv6_Opts_OptionParser, IPv6_Opts_OptionConstructor]', *,
|
384
|
+
schema: 'Optional[Type[Schema_IPv6_Opts_Option]]' = None) -> 'None':
|
352
385
|
"""Register an option parser.
|
353
386
|
|
354
387
|
The function will register the given option parser to the
|
@@ -358,17 +391,22 @@ def register_ipv6_opts_option(code: 'IPv6_Option', meth: 'str | tuple[IPv6_Opts_
|
|
358
391
|
code: :class:`IPv6-Opts <pcapkit.protocols.internet.ipv6_opts.IPv6_Opts>`
|
359
392
|
option code as in :class:`~pcapkit.const.ipv6.option.Option`.
|
360
393
|
meth: Method name or callable to parse and/or construct the option.
|
394
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
395
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.internet.ipv6_opts.Option`.
|
361
396
|
|
362
397
|
"""
|
363
398
|
if isinstance(meth, str) and not hasattr(IPv6_Opts, f'_read_opt_{meth}'):
|
364
399
|
raise RegistryError('method must be a valid IPv6-Opts option parser function')
|
365
400
|
|
366
401
|
IPv6_Opts.register_option(code, meth)
|
402
|
+
if schema is not None:
|
403
|
+
Schema_IPv6_Opts_Option.register(code, schema)
|
367
404
|
logger.info('registered IPv6-Opts option parser: %s', code.name)
|
368
405
|
|
369
406
|
|
370
407
|
# NOTE: pcapkit.protocols.internet.ipv6_route.IPv6_Route.__routing__
|
371
|
-
def register_ipv6_route_routing(code: 'IPv6_Routing', meth: 'str | tuple[IPv6_Route_TypeParser, IPv6_Route_TypeConstructor]'
|
408
|
+
def register_ipv6_route_routing(code: 'IPv6_Routing', meth: 'str | tuple[IPv6_Route_TypeParser, IPv6_Route_TypeConstructor]', *,
|
409
|
+
schema: 'Optional[Type[Schema_IPv6_Route_RoutingType]]' = None) -> 'None':
|
372
410
|
"""Register a routing data parser.
|
373
411
|
|
374
412
|
The function will register the given routing data parser to the
|
@@ -378,17 +416,22 @@ def register_ipv6_route_routing(code: 'IPv6_Routing', meth: 'str | tuple[IPv6_Ro
|
|
378
416
|
code: :class:`IPv6-Route <pcapkit.protocols.internet.ipv6_route.IPv6_Route>`
|
379
417
|
data type code as in :class:`~pcapkit.const.ipv6.routing.Routing`.
|
380
418
|
meth: Method name or callable to parse and/or construct the data.
|
419
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the routing data.
|
420
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.internet.ipv6_route.RoutingType`.
|
381
421
|
|
382
422
|
"""
|
383
423
|
if isinstance(meth, str) and not hasattr(IPv6_Route, f'_read_data_type_{meth}'):
|
384
424
|
raise RegistryError('method must be a valid IPv6-Route routing data parser function')
|
385
425
|
|
386
426
|
IPv6_Route.register_routing(code, meth)
|
427
|
+
if schema is not None:
|
428
|
+
Schema_IPv6_Route_RoutingType.register(code, schema)
|
387
429
|
logger.info('registered IPv6-Route routing data parser: %s', code.name)
|
388
430
|
|
389
431
|
|
390
432
|
# NOTE: pcapkit.protocols.internet.mh.MH.__message__
|
391
|
-
def register_mh_message(code: 'MH_Packet', meth: 'str | tuple[MH_PacketParser, MH_PacketConstructor]'
|
433
|
+
def register_mh_message(code: 'MH_Packet', meth: 'str | tuple[MH_PacketParser, MH_PacketConstructor]', *,
|
434
|
+
schema: 'Optional[Type[Schema_MH_Packet]]' = None) -> 'None':
|
392
435
|
"""Register a message type parser.
|
393
436
|
|
394
437
|
The function will register the given message type parser to the
|
@@ -398,17 +441,22 @@ def register_mh_message(code: 'MH_Packet', meth: 'str | tuple[MH_PacketParser, M
|
|
398
441
|
code: :class:`~pcapkit.protocols.internet.mh.MH>`
|
399
442
|
data type code as in :class:`~pcapkit.const.mh.packet.Packet`.
|
400
443
|
meth: Method name or callable to parse and/or construct the data.
|
444
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type.
|
445
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.internet.mh.Packet`.
|
401
446
|
|
402
447
|
"""
|
403
448
|
if isinstance(meth, str) and not hasattr(MH, f'_read_msg_{meth}'):
|
404
449
|
raise RegistryError('method must be a valid MH message type parser function')
|
405
450
|
|
406
451
|
MH.register_message(code, meth)
|
452
|
+
if schema is not None:
|
453
|
+
Schema_MH_Packet.register(code, schema)
|
407
454
|
logger.info('registered MH message type parser: %s', code.name)
|
408
455
|
|
409
456
|
|
410
457
|
# NOTE: pcapkit.protocols.internet.mh.MH.__option__
|
411
|
-
def register_mh_option(code: 'MH_Option', meth: 'str | tuple[MH_OptionParser, MH_OptionConstructor]'
|
458
|
+
def register_mh_option(code: 'MH_Option', meth: 'str | tuple[MH_OptionParser, MH_OptionConstructor]', *,
|
459
|
+
schema: 'Optional[Type[Schema_MH_Option]]' = None) -> 'None':
|
412
460
|
"""Register a option parser.
|
413
461
|
|
414
462
|
The function will register the given option parser to the
|
@@ -418,17 +466,22 @@ def register_mh_option(code: 'MH_Option', meth: 'str | tuple[MH_OptionParser, MH
|
|
418
466
|
code: :class:`~pcapkit.protocols.internet.mh.MH>`
|
419
467
|
data type code as in :class:`~pcapkit.const.mh.option.Option`.
|
420
468
|
meth: Method name or callable to parse and/or construct the data.
|
469
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type.
|
470
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.internet.mh.Option`.
|
421
471
|
|
422
472
|
"""
|
423
473
|
if isinstance(meth, str) and not hasattr(MH, f'_read_opt_{meth}'):
|
424
474
|
raise RegistryError('method must be a valid MH option parser function')
|
425
475
|
|
426
476
|
MH.register_option(code, meth)
|
477
|
+
if schema is not None:
|
478
|
+
Schema_MH_Option.register(code, schema)
|
427
479
|
logger.info('registered MH option parser: %s', code.name)
|
428
480
|
|
429
481
|
|
430
482
|
# NOTE: pcapkit.protocols.internet.mh.MH.__extension__
|
431
|
-
def register_mh_extension(code: 'MH_CGAExtension', meth: 'str | tuple[MH_ExtensionParser, MH_ExtensionConstructor]'
|
483
|
+
def register_mh_extension(code: 'MH_CGAExtension', meth: 'str | tuple[MH_ExtensionParser, MH_ExtensionConstructor]',
|
484
|
+
schema: 'Optional[Type[Schema_MH_CGAExtension]]' = None) -> 'None':
|
432
485
|
"""Register a CGA extension parser.
|
433
486
|
|
434
487
|
The function will register the given CGA extension to the
|
@@ -438,12 +491,16 @@ def register_mh_extension(code: 'MH_CGAExtension', meth: 'str | tuple[MH_Extensi
|
|
438
491
|
code: :class:`~pcapkit.protocols.internet.mh.MH>`
|
439
492
|
data type code as in :class:`~pcapkit.const.mh.cga_extension.CGAExtension`.
|
440
493
|
meth: Method name or callable to parse and/or construct the data.
|
494
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type.
|
495
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.internet.mh.CGAExtension`.
|
441
496
|
|
442
497
|
"""
|
443
498
|
if isinstance(meth, str) and not hasattr(MH, f'_read_ext_{meth}'):
|
444
499
|
raise RegistryError('method must be a valid MH CGA extension function')
|
445
500
|
|
446
501
|
MH.register_extension(code, meth)
|
502
|
+
if schema is not None:
|
503
|
+
Schema_MH_CGAExtension.register(code, schema)
|
447
504
|
logger.info('registered MH CGA extension: %s', code.name)
|
448
505
|
|
449
506
|
|
@@ -521,7 +578,8 @@ def register_tcp(code: 'int', module: 'str', class_: 'str') -> 'None':
|
|
521
578
|
|
522
579
|
|
523
580
|
# NOTE: pcapkit.protocols.transport.tcp.TCP.__option__
|
524
|
-
def register_tcp_option(code: 'TCP_Option', meth: 'str | tuple[TCP_OptionParser, TCP_OptionConstructor]'
|
581
|
+
def register_tcp_option(code: 'TCP_Option', meth: 'str | tuple[TCP_OptionParser, TCP_OptionConstructor]', *,
|
582
|
+
schema: 'Optional[Type[Schema_TCP_Option]]' = None) -> 'None':
|
525
583
|
"""Register an option parser.
|
526
584
|
|
527
585
|
The function will register the given option parser to the
|
@@ -531,17 +589,22 @@ def register_tcp_option(code: 'TCP_Option', meth: 'str | tuple[TCP_OptionParser,
|
|
531
589
|
code: :class:`~pcapkit.protocols.transport.tcp.TCP` option code as in
|
532
590
|
:class:`~pcapkit.const.tcp.option.Option`.
|
533
591
|
meth: Method name or callable to parse and/or construct the option.
|
592
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
593
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.transport.tcp.Option`.
|
534
594
|
|
535
595
|
"""
|
536
596
|
if isinstance(meth, str) and not hasattr(TCP, f'_read_mode_{meth}'):
|
537
597
|
raise RegistryError('method must be a TCP option parser function')
|
538
598
|
|
539
599
|
TCP.register_option(code, meth)
|
600
|
+
if schema is not None:
|
601
|
+
Schema_TCP_Option.register(code, schema)
|
540
602
|
logger.info('registered TCP option parser: %s', code.name)
|
541
603
|
|
542
604
|
|
543
605
|
# NOTE: pcapkit.protocols.transport.tcp.TCP.__mp_option__
|
544
|
-
def register_tcp_mp_option(code: 'TCP_MPTCPOption', meth: 'str | tuple[TCP_MPOptionParser, TCP_MPOptionConstructor]'
|
606
|
+
def register_tcp_mp_option(code: 'TCP_MPTCPOption', meth: 'str | tuple[TCP_MPOptionParser, TCP_MPOptionConstructor]', *,
|
607
|
+
schema: 'Optional[Type[Schema_TCP_MPTCP]]' = None) -> 'None':
|
545
608
|
"""Register an MPTCP option parser.
|
546
609
|
|
547
610
|
The function will register the given option parser to the
|
@@ -551,12 +614,16 @@ def register_tcp_mp_option(code: 'TCP_MPTCPOption', meth: 'str | tuple[TCP_MPOpt
|
|
551
614
|
code: Multipath :class:`~pcapkit.protocols.transport.tcp.TCP` option code as in
|
552
615
|
:class:`~pcapkit.const.tcp.mp_tcp_option.MPTCPOption`.
|
553
616
|
meth: Method name or callable to parse and/or construct the option.
|
617
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
618
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.transport.tcp.MPTCP`.
|
554
619
|
|
555
620
|
"""
|
556
621
|
if isinstance(meth, str) and not hasattr(TCP, f'_read_mptcp_{meth}'):
|
557
622
|
raise RegistryError('method must be a MPTCP option parser function')
|
558
623
|
|
559
624
|
TCP.register_mp_option(code, meth)
|
625
|
+
if schema is not None:
|
626
|
+
Schema_TCP_MPTCP.register(code, schema)
|
560
627
|
logger.info('registered MPTCP option parser: %s', code.name)
|
561
628
|
|
562
629
|
|
@@ -594,7 +661,8 @@ def register_udp(code: 'int', module: str, class_: str) -> 'None':
|
|
594
661
|
|
595
662
|
|
596
663
|
# NOTE: pcapkit.protocols.application.httpv2.HTTPv2.__frame__
|
597
|
-
def register_http_frame(code: 'HTTP_Frame', meth: 'str | tuple[HTTP_FrameParser, HTTP_FrameConstructor]'
|
664
|
+
def register_http_frame(code: 'HTTP_Frame', meth: 'str | tuple[HTTP_FrameParser, HTTP_FrameConstructor]', *,
|
665
|
+
schema: 'Optional[Type[Schema_HTTP_FrameType]]' = None) -> 'None':
|
598
666
|
"""Registered a frame parser.
|
599
667
|
|
600
668
|
The function will register the given frame parser to the
|
@@ -604,12 +672,16 @@ def register_http_frame(code: 'HTTP_Frame', meth: 'str | tuple[HTTP_FrameParser,
|
|
604
672
|
code: :class:`HTTP/2 <pcapkit.protocols.application.httpv2.HTTPv2>` frame type
|
605
673
|
code as in :class:`~pcapkit.const.http.frame.Frame`.
|
606
674
|
meth: Method name or callable to parse and/or construct the frame.
|
675
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the frame.
|
676
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.application.httpv2.FrameType`.
|
607
677
|
|
608
678
|
"""
|
609
679
|
if isinstance(meth, str) and not hasattr(HTTPv2, f'_read_http_{meth}'):
|
610
680
|
raise RegistryError('method must be a frame parser function')
|
611
681
|
|
612
682
|
HTTPv2.register_frame(code, meth)
|
683
|
+
if schema is not None:
|
684
|
+
Schema_HTTP_FrameType.register(code, schema)
|
613
685
|
logger.info('registered HTTP/2 frame parser: %s', code.name)
|
614
686
|
|
615
687
|
|
@@ -619,7 +691,8 @@ def register_http_frame(code: 'HTTP_Frame', meth: 'str | tuple[HTTP_FrameParser,
|
|
619
691
|
|
620
692
|
|
621
693
|
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__block__
|
622
|
-
def register_pcapng_block(code: 'PCAPNG_BlockType', meth: 'str | tuple[PCAPNG_BlockParser, PCAPNG_BlockConstructor]'
|
694
|
+
def register_pcapng_block(code: 'PCAPNG_BlockType', meth: 'str | tuple[PCAPNG_BlockParser, PCAPNG_BlockConstructor]', *,
|
695
|
+
schema: 'Optional[Type[Schema_PCAPNG_BlockType]]' = None) -> 'None':
|
623
696
|
"""Registered a block parser.
|
624
697
|
|
625
698
|
The function will register the given block parser to the
|
@@ -629,17 +702,22 @@ def register_pcapng_block(code: 'PCAPNG_BlockType', meth: 'str | tuple[PCAPNG_Bl
|
|
629
702
|
code: :class:`HTTP/2 <pcapkit.protocols.misc.pcapng.PCAPNG>` block type
|
630
703
|
code as in :class:`~pcapkit.const.pcapng.block_type.BlockType`.
|
631
704
|
meth: Method name or callable to parse and/or construct the block.
|
705
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the block.
|
706
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.misc.pcapng.BlockType`.
|
632
707
|
|
633
708
|
"""
|
634
709
|
if isinstance(meth, str) and not hasattr(PCAPNG, f'_read_block_{meth}'):
|
635
710
|
raise RegistryError('method must be a block parser function')
|
636
711
|
|
637
712
|
PCAPNG.register_block(code, meth)
|
713
|
+
if schema is not None:
|
714
|
+
Schema_PCAPNG_BlockType.register(code, schema)
|
638
715
|
logger.info('registered PCAP-NG block parser: %s', code.name)
|
639
716
|
|
640
717
|
|
641
718
|
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__option__
|
642
|
-
def register_pcapng_option(code: 'PCAPNG_OptionType', meth: 'str | tuple[PCAPNG_OptionParser, PCAPNG_OptionConstructor]'
|
719
|
+
def register_pcapng_option(code: 'PCAPNG_OptionType', meth: 'str | tuple[PCAPNG_OptionParser, PCAPNG_OptionConstructor]', *,
|
720
|
+
schema: 'Optional[Type[Schema_PCAPNG_Option]]' = None) -> 'None':
|
643
721
|
"""Registered a option parser.
|
644
722
|
|
645
723
|
The function will register the given option parser to the
|
@@ -649,17 +727,22 @@ def register_pcapng_option(code: 'PCAPNG_OptionType', meth: 'str | tuple[PCAPNG_
|
|
649
727
|
code: :class:`PCAPNG <pcapkit.protocols.misc.pcapng.PCAPNG>` option type
|
650
728
|
code as in :class:`~pcapkit.const.pcapng.option_type.OptionType`.
|
651
729
|
meth: Method name or callable to parse and/or construct the option.
|
730
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
731
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.misc.pcapng.Option`.
|
652
732
|
|
653
733
|
"""
|
654
734
|
if isinstance(meth, str) and not hasattr(PCAPNG, f'_read_option_{meth}'):
|
655
735
|
raise RegistryError('method must be a option parser function')
|
656
736
|
|
657
737
|
PCAPNG.register_option(code, meth)
|
738
|
+
if schema is not None:
|
739
|
+
Schema_PCAPNG_Option.register(code, schema)
|
658
740
|
logger.info('registered PCAP-NG option parser: %s', code.name)
|
659
741
|
|
660
742
|
|
661
743
|
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__record__
|
662
|
-
def register_pcapng_record(code: 'PCAPNG_RecordType', meth: 'str | tuple[PCAPNG_RecordParser, PCAPNG_RecordConstructor]'
|
744
|
+
def register_pcapng_record(code: 'PCAPNG_RecordType', meth: 'str | tuple[PCAPNG_RecordParser, PCAPNG_RecordConstructor]', *,
|
745
|
+
schema: 'Optional[Type[Schema_PCAPNG_NameResolutionRecord]]' = None) -> 'None':
|
663
746
|
"""Registered a name resolution record parser.
|
664
747
|
|
665
748
|
The function will register the given name resolution record parser to the
|
@@ -670,17 +753,22 @@ def register_pcapng_record(code: 'PCAPNG_RecordType', meth: 'str | tuple[PCAPNG_
|
|
670
753
|
resolution record type code as in :class:`~pcapkit.const.pcapng.record_type.RecordType`.
|
671
754
|
meth: Method name or callable to parse and/or construct the name
|
672
755
|
resolution record.
|
756
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the name resolution record.
|
757
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.misc.pcapng.NameResolutionRecord`.
|
673
758
|
|
674
759
|
"""
|
675
760
|
if isinstance(meth, str) and not hasattr(PCAPNG, f'_read_record_{meth}'):
|
676
761
|
raise RegistryError('method must be a name resolution record parser function')
|
677
762
|
|
678
763
|
PCAPNG.register_record(code, meth)
|
764
|
+
if schema is not None:
|
765
|
+
Schema_PCAPNG_NameResolutionRecord.register(code, schema)
|
679
766
|
logger.info('registered PCAP-NG name resolution record parser: %s', code.name)
|
680
767
|
|
681
768
|
|
682
769
|
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__secrets__
|
683
|
-
def register_pcapng_secrets(code: 'PCAPNG_SecretsType', meth: 'str | tuple[PCAPNG_SecretsParser, PCAPNG_SecretsConstructor]'
|
770
|
+
def register_pcapng_secrets(code: 'PCAPNG_SecretsType', meth: 'str | tuple[PCAPNG_SecretsParser, PCAPNG_SecretsConstructor]', *,
|
771
|
+
schema: 'Optional[Type[Schema_PCAPNG_DSBSecrets]]' = None) -> 'None':
|
684
772
|
"""Registered a decryption secrets parser.
|
685
773
|
|
686
774
|
The function will register the given decryption secrets parser to the
|
@@ -690,10 +778,14 @@ def register_pcapng_secrets(code: 'PCAPNG_SecretsType', meth: 'str | tuple[PCAPN
|
|
690
778
|
code: :class:`PCAPNG <pcapkit.protocols.misc.pcapng.PCAPNG>` decryption
|
691
779
|
secrets type code as in :class:`~pcapkit.const.pcapng.secrets_type.SecretsType`.
|
692
780
|
meth: Method name or callable to parse and/or construct the decryption secrets.
|
781
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the decryption secrets.
|
782
|
+
It should be a subclass of :class:`~pcapkit.protocols.schema.misc.pcapng.DSBSecrets`.
|
693
783
|
|
694
784
|
"""
|
695
785
|
if isinstance(meth, str) and not hasattr(PCAPNG, f'_read_secrets_{meth}'):
|
696
786
|
raise RegistryError('method must be a decryption secrets parser function')
|
697
787
|
|
698
788
|
PCAPNG.register_secrets(code, meth)
|
789
|
+
if schema is not None:
|
790
|
+
Schema_PCAPNG_DSBSecrets.register(code, schema)
|
699
791
|
logger.info('registered PCAP-NG decryption secrets parser: %s', code.name)
|
@@ -138,8 +138,8 @@ __all__ = [
|
|
138
138
|
'MH_HomeTestMessage', 'MH_CareofTestMessage', 'MH_BindingUpdateMessage', 'MH_BindingAcknowledgementMessage',
|
139
139
|
'MH_BindingErrorMessage',
|
140
140
|
'MH_Option',
|
141
|
-
'MH_UnassignedOption', 'MH_PadOption', '
|
142
|
-
'MH_NonceIndicesOption', '
|
141
|
+
'MH_UnassignedOption', 'MH_PadOption', 'MH_BindingRefreshAdviceOption', 'MH_AlternateCareofAddressOption',
|
142
|
+
'MH_NonceIndicesOption', 'MH_AuthorizationDataOption', 'MH_MobileNetworkPrefixOption',
|
143
143
|
'MH_LinkLayerAddressOption', 'MH_MNIDOption', 'MH_AuthOption', 'MH_MesgIDOption', 'MH_CGAParametersRequestOption',
|
144
144
|
'MH_CGAParametersOption', 'MH_SignatureOption', 'MH_PermanentHomeKeygenTokenOption', 'MH_CareofTestInitOption',
|
145
145
|
'MH_CareofTestOption',
|
@@ -152,8 +152,8 @@ __all__ = [
|
|
152
152
|
'TCP_Flags', 'TCP_SACKBlock',
|
153
153
|
'TCP_Option',
|
154
154
|
'TCP_UnassignedOption', 'TCP_EndOfOptionList', 'TCP_NoOperation', 'TCP_MaximumSegmentSize', 'TCP_WindowScale',
|
155
|
-
'TCP_SACKPermitted', 'TCP_SACK', 'TCP_Echo', 'TCP_EchoReply', '
|
156
|
-
'
|
155
|
+
'TCP_SACKPermitted', 'TCP_SACK', 'TCP_Echo', 'TCP_EchoReply', 'TCP_Timestamps', 'TCP_PartialOrderConnectionPermitted', # pylint: disable=line-too-long
|
156
|
+
'TCP_PartialOrderServiceProfile', 'TCP_CC', 'TCP_CCNew', 'TCP_CCEcho', 'TCP_AlternateChecksumRequest',
|
157
157
|
'TCP_AlternateChecksumData', 'TCP_MD5Signature', 'TCP_QuickStartResponse', 'TCP_UserTimeout',
|
158
158
|
'TCP_Authentication', 'TCP_FastOpenCookie',
|
159
159
|
'TCP_MPTCPCapableFlag',
|
@@ -179,12 +179,12 @@ from pcapkit.protocols.data.internet.mh import AuthOption as MH_AuthOption
|
|
179
179
|
from pcapkit.protocols.data.internet.mh import \
|
180
180
|
BindingAcknowledgementMessage as MH_BindingAcknowledgementMessage
|
181
181
|
from pcapkit.protocols.data.internet.mh import \
|
182
|
-
|
182
|
+
AuthorizationDataOption as MH_AuthorizationDataOption
|
183
183
|
from pcapkit.protocols.data.internet.mh import BindingErrorMessage as MH_BindingErrorMessage
|
184
184
|
from pcapkit.protocols.data.internet.mh import \
|
185
185
|
BindingRefreshRequestMessage as MH_BindingRefreshRequestMessage
|
186
186
|
from pcapkit.protocols.data.internet.mh import BindingUpdateMessage as MH_BindingUpdateMessage
|
187
|
-
from pcapkit.protocols.data.internet.mh import
|
187
|
+
from pcapkit.protocols.data.internet.mh import BindingRefreshAdviceOption as MH_BindingRefreshAdviceOption
|
188
188
|
from pcapkit.protocols.data.internet.mh import CareofTestInitMessage as MH_CareofTestInitMessage
|
189
189
|
from pcapkit.protocols.data.internet.mh import CareofTestInitOption as MH_CareofTestInitOption
|
190
190
|
from pcapkit.protocols.data.internet.mh import CareofTestMessage as MH_CareofTestMessage
|
@@ -287,8 +287,8 @@ __all__ = [
|
|
287
287
|
'MH_HomeTestMessage', 'MH_CareofTestMessage', 'MH_BindingUpdateMessage', 'MH_BindingAcknowledgementMessage',
|
288
288
|
'MH_BindingErrorMessage',
|
289
289
|
'MH_Option',
|
290
|
-
'MH_UnassignedOption', 'MH_PadOption', '
|
291
|
-
'MH_NonceIndicesOption', '
|
290
|
+
'MH_UnassignedOption', 'MH_PadOption', 'MH_BindingRefreshAdviceOption', 'MH_AlternateCareofAddressOption',
|
291
|
+
'MH_NonceIndicesOption', 'MH_AuthorizationDataOption', 'MH_MobileNetworkPrefixOption',
|
292
292
|
'MH_LinkLayerAddressOption', 'MH_MNIDOption', 'MH_AuthOption', 'MH_MesgIDOption', 'MH_CGAParametersRequestOption',
|
293
293
|
'MH_CGAParametersOption', 'MH_SignatureOption', 'MH_PermanentHomeKeygenTokenOption', 'MH_CareofTestInitOption',
|
294
294
|
'MH_CareofTestOption',
|
@@ -70,8 +70,8 @@ __all__ = [
|
|
70
70
|
'BindingErrorMessage',
|
71
71
|
|
72
72
|
'Option',
|
73
|
-
'UnassignedOption', 'PadOption', '
|
74
|
-
'NonceIndicesOption', '
|
73
|
+
'UnassignedOption', 'PadOption', 'BindingRefreshAdviceOption', 'AlternateCareofAddressOption',
|
74
|
+
'NonceIndicesOption', 'AuthorizationDataOption', 'MobileNetworkPrefixOption',
|
75
75
|
'LinkLayerAddressOption', 'MNIDOption', 'AuthOption', 'MesgIDOption', 'CGAParametersRequestOption',
|
76
76
|
'CGAParametersOption', 'SignatureOption', 'PermanentHomeKeygenTokenOption', 'CareofTestInitOption',
|
77
77
|
'CareofTestOption',
|
@@ -249,8 +249,7 @@ class BindingErrorMessage(MH):
|
|
249
249
|
options: 'OrderedMultiDict[Enum_Option, Option]') -> 'None': ...
|
250
250
|
|
251
251
|
|
252
|
-
|
253
|
-
|
252
|
+
# TODO: Implement other message types.
|
254
253
|
|
255
254
|
|
256
255
|
class Option(Data):
|
@@ -282,7 +281,7 @@ class PadOption(Option):
|
|
282
281
|
|
283
282
|
|
284
283
|
@info_final
|
285
|
-
class
|
284
|
+
class BindingRefreshAdviceOption(Option):
|
286
285
|
"""Data model for Binding Refresh Advice option."""
|
287
286
|
|
288
287
|
#: Refresh interval.
|
@@ -317,7 +316,7 @@ class NonceIndicesOption(Option):
|
|
317
316
|
|
318
317
|
|
319
318
|
@info_final
|
320
|
-
class
|
319
|
+
class AuthorizationDataOption(Option):
|
321
320
|
"""Data model for Binding Authorization Data option."""
|
322
321
|
|
323
322
|
#: Authenticator.
|
@@ -504,3 +503,6 @@ class CareofTestOption(Option):
|
|
504
503
|
|
505
504
|
if TYPE_CHECKING:
|
506
505
|
def __init__(self, type: 'Enum_Option', length: 'int', token: 'bytes') -> 'None': ...
|
506
|
+
|
507
|
+
|
508
|
+
# TODO: Implement other options.
|
@@ -37,11 +37,11 @@ from pcapkit.protocols.data.transport.tcp import Option as TCP_Option
|
|
37
37
|
from pcapkit.protocols.data.transport.tcp import \
|
38
38
|
PartialOrderConnectionPermitted as TCP_PartialOrderConnectionPermitted
|
39
39
|
from pcapkit.protocols.data.transport.tcp import \
|
40
|
-
|
40
|
+
PartialOrderServiceProfile as TCP_PartialOrderServiceProfile
|
41
41
|
from pcapkit.protocols.data.transport.tcp import QuickStartResponse as TCP_QuickStartResponse
|
42
42
|
from pcapkit.protocols.data.transport.tcp import SACKBlock as TCP_SACKBlock
|
43
43
|
from pcapkit.protocols.data.transport.tcp import SACKPermitted as TCP_SACKPermitted
|
44
|
-
from pcapkit.protocols.data.transport.tcp import
|
44
|
+
from pcapkit.protocols.data.transport.tcp import Timestamps as TCP_Timestamps
|
45
45
|
from pcapkit.protocols.data.transport.tcp import UnassignedOption as TCP_UnassignedOption
|
46
46
|
from pcapkit.protocols.data.transport.tcp import UserTimeout as TCP_UserTimeout
|
47
47
|
from pcapkit.protocols.data.transport.tcp import WindowScale as TCP_WindowScale
|
@@ -55,8 +55,8 @@ __all__ = [
|
|
55
55
|
'TCP_Flags', 'TCP_SACKBlock',
|
56
56
|
'TCP_Option',
|
57
57
|
'TCP_UnassignedOption', 'TCP_EndOfOptionList', 'TCP_NoOperation', 'TCP_MaximumSegmentSize', 'TCP_WindowScale',
|
58
|
-
'TCP_SACKPermitted', 'TCP_SACK', 'TCP_Echo', 'TCP_EchoReply', '
|
59
|
-
'
|
58
|
+
'TCP_SACKPermitted', 'TCP_SACK', 'TCP_Echo', 'TCP_EchoReply', 'TCP_Timestamps', 'TCP_PartialOrderConnectionPermitted', # pylint: disable=line-too-long
|
59
|
+
'TCP_PartialOrderServiceProfile', 'TCP_CC', 'TCP_CCNew', 'TCP_CCEcho', 'TCP_AlternateChecksumRequest',
|
60
60
|
'TCP_AlternateChecksumData', 'TCP_MD5Signature', 'TCP_QuickStartResponse', 'TCP_UserTimeout',
|
61
61
|
'TCP_Authentication', 'TCP_FastOpenCookie',
|
62
62
|
'TCP_MPTCPCapableFlag',
|
@@ -27,8 +27,8 @@ __all__ = [
|
|
27
27
|
|
28
28
|
'Option',
|
29
29
|
'UnassignedOption', 'EndOfOptionList', 'NoOperation', 'MaximumSegmentSize', 'WindowScale',
|
30
|
-
'SACKPermitted', 'SACK', 'Echo', 'EchoReply', '
|
31
|
-
'
|
30
|
+
'SACKPermitted', 'SACK', 'Echo', 'EchoReply', 'Timestamps', 'PartialOrderConnectionPermitted',
|
31
|
+
'PartialOrderServiceProfile', 'CC', 'CCNew', 'CCEcho', 'AlternateChecksumRequest',
|
32
32
|
'AlternateChecksumData', 'MD5Signature', 'QuickStartResponse', 'UserTimeout',
|
33
33
|
'Authentication', 'FastOpenCookie',
|
34
34
|
|
@@ -215,7 +215,7 @@ class EchoReply(Option):
|
|
215
215
|
|
216
216
|
|
217
217
|
@info_final
|
218
|
-
class
|
218
|
+
class Timestamps(Option):
|
219
219
|
"""Data model for TCP timestamp option."""
|
220
220
|
|
221
221
|
#: Timestamp .
|
@@ -236,7 +236,7 @@ class PartialOrderConnectionPermitted(Option):
|
|
236
236
|
|
237
237
|
|
238
238
|
@info_final
|
239
|
-
class
|
239
|
+
class PartialOrderServiceProfile(Option):
|
240
240
|
"""Data model for TCP partial order connection profile option."""
|
241
241
|
|
242
242
|
#: Start flag.
|