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.
Files changed (41) hide show
  1. pcapkit/__init__.py +1 -1
  2. pcapkit/const/pcapng/option_type.py +25 -1
  3. pcapkit/const/reg/apptype.py +25 -1
  4. pcapkit/corekit/fields/collections.py +4 -5
  5. pcapkit/corekit/fields/field.py +33 -8
  6. pcapkit/corekit/fields/ipaddress.py +0 -1
  7. pcapkit/corekit/fields/misc.py +14 -19
  8. pcapkit/corekit/fields/numbers.py +2 -3
  9. pcapkit/corekit/fields/strings.py +2 -3
  10. pcapkit/corekit/infoclass.py +59 -6
  11. pcapkit/corekit/protochain.py +8 -1
  12. pcapkit/foundation/registry/protocols.py +30 -51
  13. pcapkit/protocols/data/__init__.py +4 -4
  14. pcapkit/protocols/data/internet/__init__.py +4 -4
  15. pcapkit/protocols/data/internet/mh.py +4 -4
  16. pcapkit/protocols/data/transport/__init__.py +4 -4
  17. pcapkit/protocols/data/transport/tcp.py +4 -4
  18. pcapkit/protocols/internet/mh.py +20 -20
  19. pcapkit/protocols/protocol.py +3 -2
  20. pcapkit/protocols/schema/__init__.py +4 -4
  21. pcapkit/protocols/schema/application/httpv2.py +16 -29
  22. pcapkit/protocols/schema/internet/__init__.py +4 -4
  23. pcapkit/protocols/schema/internet/hip.py +62 -111
  24. pcapkit/protocols/schema/internet/hopopt.py +46 -48
  25. pcapkit/protocols/schema/internet/ipv4.py +36 -41
  26. pcapkit/protocols/schema/internet/ipv6_opts.py +48 -52
  27. pcapkit/protocols/schema/internet/ipv6_route.py +9 -20
  28. pcapkit/protocols/schema/internet/mh.py +49 -84
  29. pcapkit/protocols/schema/misc/pcapng.py +178 -195
  30. pcapkit/protocols/schema/schema.py +252 -53
  31. pcapkit/protocols/schema/transport/__init__.py +4 -4
  32. pcapkit/protocols/schema/transport/tcp.py +52 -83
  33. pcapkit/protocols/transport/tcp.py +14 -14
  34. pcapkit/vendor/pcapng/option_type.py +25 -1
  35. pcapkit/vendor/reg/apptype.py +25 -1
  36. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/METADATA +1 -1
  37. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/RECORD +41 -41
  38. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/LICENSE +0 -0
  39. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/WHEEL +0 -0
  40. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/entry_points.txt +0 -0
  41. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.post1.dist-info}/top_level.txt +0 -0
@@ -17,7 +17,7 @@ from pcapkit.corekit.fields.misc import (ConditionalField, ForwardMatchField, Pa
17
17
  from pcapkit.corekit.fields.numbers import (EnumField, NumberField, UInt8Field, UInt16Field,
18
18
  UInt32Field, UInt64Field)
19
19
  from pcapkit.corekit.fields.strings import BitField, BytesField, PaddingField
20
- from pcapkit.protocols.schema.schema import Schema, schema_final
20
+ from pcapkit.protocols.schema.schema import EnumSchema, Schema, schema_final
21
21
  from pcapkit.utilities.exceptions import FieldError
22
22
  from pcapkit.utilities.logging import SPHINX_TYPE_CHECKING
23
23
 
@@ -26,8 +26,8 @@ __all__ = [
26
26
 
27
27
  'Option',
28
28
  'UnassignedOption', 'EndOfOptionList', 'NoOperation', 'MaximumSegmentSize', 'WindowScale',
29
- 'SACKPermitted', 'SACK', 'Echo', 'EchoReply', 'Timestamp', 'PartialOrderConnectionPermitted',
30
- 'PartialOrderConnectionProfile', 'CC', 'CCNew', 'CCEcho', 'AlternateChecksumRequest',
29
+ 'SACKPermitted', 'SACK', 'Echo', 'EchoReply', 'Timestamps', 'PartialOrderConnectionPermitted',
30
+ 'PartialOrderServiceProfile', 'CC', 'CCNew', 'CCEcho', 'AlternateChecksumRequest',
31
31
  'AlternateChecksumData', 'MD5Signature', 'QuickStartResponse', 'UserTimeout',
32
32
  'Authentication', 'FastOpenCookie',
33
33
 
@@ -196,23 +196,20 @@ def mptcp_data_selector(pkt: 'dict[str, Any]') -> 'Field':
196
196
  :class:`~pcapkit.protocols.schema.transport.tcp.MPTCP` subclass
197
197
  instance.
198
198
 
199
- See Also:
200
- * :class:`pcapkit.const.tcp.mp_tcp_option.MPTCPOption`
201
- * :data:`pcapkit.protocols.schema.transport.tcp.MAP_MPTCP_DATA`
202
-
203
199
  """
204
200
  subtype = Enum_MPTCPOption.get(pkt['test']['subtype'])
205
201
  pkt['test']['subtype'] = subtype
206
- schema = MAP_MPTCP_DATA[subtype]
202
+ schema = MPTCP.registry[subtype]
207
203
 
208
- if subtype == Enum_MPTCPOption.MP_JOIN and schema is MPTCPUnknown:
204
+ if subtype == Enum_MPTCPOption.MP_JOIN and schema is MPTCPJoin: # placeholder
209
205
  if pkt['flags']['syn'] == 1 and pkt['flags']['ack'] == 0:
210
- return SchemaField(length=pkt['test']['length'], schema=MPTCPJoinSYN)
211
- if pkt['flags']['syn'] == 1 and pkt['flags']['ack'] == 1:
212
- return SchemaField(length=pkt['test']['length'], schema=MPTCPJoinSYNACK)
213
- if pkt['flags']['syn'] == 0 and pkt['flags']['ack'] == 1:
214
- return SchemaField(length=pkt['test']['length'], schema=MPTCPJoinACK)
215
- raise FieldError(f'TCP: [OptNo {Enum_Option.Multipath_TCP}] {Enum_MPTCPOption.MP_JOIN} invalid flags')
206
+ schema = MPTCPJoinSYN
207
+ elif pkt['flags']['syn'] == 1 and pkt['flags']['ack'] == 1:
208
+ schema = MPTCPJoinSYNACK
209
+ elif pkt['flags']['syn'] == 0 and pkt['flags']['ack'] == 1:
210
+ schema = MPTCPJoinACK
211
+ else:
212
+ raise FieldError(f'TCP: [OptNo {Enum_Option.Multipath_TCP}] {Enum_MPTCPOption.MP_JOIN} invalid flags')
216
213
  return SchemaField(length=pkt['test']['length'], schema=schema)
217
214
 
218
215
 
@@ -287,9 +284,11 @@ class PortEnumField(EnumField):
287
284
  return self._namespace.get(value, proto=Enum_TransportProtocol.tcp)
288
285
 
289
286
 
290
- class Option(Schema):
287
+ class Option(EnumSchema[Enum_Option]):
291
288
  """Header schema for TCP options."""
292
289
 
290
+ __default__ = lambda: UnassignedOption
291
+
293
292
  #: Option kind.
294
293
  kind: 'Enum_Option' = EnumField(length=1, namespace=Enum_Option)
295
294
  #: Option length.
@@ -326,7 +325,7 @@ class UnassignedOption(Option):
326
325
 
327
326
 
328
327
  @schema_final
329
- class EndOfOptionList(Option):
328
+ class EndOfOptionList(Option, code=Enum_Option.End_of_Option_List):
330
329
  """Header schema for TCP end of option list."""
331
330
 
332
331
  if TYPE_CHECKING:
@@ -334,7 +333,7 @@ class EndOfOptionList(Option):
334
333
 
335
334
 
336
335
  @schema_final
337
- class NoOperation(Option):
336
+ class NoOperation(Option, code=Enum_Option.No_Operation):
338
337
  """Header schema for TCP no operation."""
339
338
 
340
339
  if TYPE_CHECKING:
@@ -342,7 +341,7 @@ class NoOperation(Option):
342
341
 
343
342
 
344
343
  @schema_final
345
- class MaximumSegmentSize(Option):
344
+ class MaximumSegmentSize(Option, code=Enum_Option.Maximum_Segment_Size):
346
345
  """Header schema for TCP max segment size option."""
347
346
 
348
347
  #: Maximum segment size.
@@ -353,7 +352,7 @@ class MaximumSegmentSize(Option):
353
352
 
354
353
 
355
354
  @schema_final
356
- class WindowScale(Option):
355
+ class WindowScale(Option, code=Enum_Option.Window_Scale):
357
356
  """Header schema for TCP window scale option."""
358
357
 
359
358
  #: Window scale (shift count).
@@ -364,7 +363,7 @@ class WindowScale(Option):
364
363
 
365
364
 
366
365
  @schema_final
367
- class SACKPermitted(Option):
366
+ class SACKPermitted(Option, code=Enum_Option.SACK_Permitted):
368
367
  """Header schema for TCP SACK permitted option."""
369
368
 
370
369
  if TYPE_CHECKING:
@@ -385,7 +384,7 @@ class SACKBlock(Schema):
385
384
 
386
385
 
387
386
  @schema_final
388
- class SACK(Option):
387
+ class SACK(Option, code=Enum_Option.SACK):
389
388
  """Header schema for TCP SACK option."""
390
389
 
391
390
  #: Selected ACK data.
@@ -399,7 +398,7 @@ class SACK(Option):
399
398
 
400
399
 
401
400
  @schema_final
402
- class Echo(Option):
401
+ class Echo(Option, code=Enum_Option.Echo):
403
402
  """Header schema for TCP echo option."""
404
403
 
405
404
  #: Info to be echoed.
@@ -410,7 +409,7 @@ class Echo(Option):
410
409
 
411
410
 
412
411
  @schema_final
413
- class EchoReply(Option):
412
+ class EchoReply(Option, code=Enum_Option.Echo_Reply):
414
413
  """Header schema for TCP echo reply option."""
415
414
 
416
415
  #: Echoed info.
@@ -421,7 +420,7 @@ class EchoReply(Option):
421
420
 
422
421
 
423
422
  @schema_final
424
- class Timestamp(Option):
423
+ class Timestamps(Option, code=Enum_Option.Timestamps):
425
424
  """Header schema for TCP timestamps option."""
426
425
 
427
426
  #: Timestamp value.
@@ -434,7 +433,7 @@ class Timestamp(Option):
434
433
 
435
434
 
436
435
  @schema_final
437
- class PartialOrderConnectionPermitted(Option):
436
+ class PartialOrderConnectionPermitted(Option, code=Enum_Option.Partial_Order_Connection_Permitted):
438
437
  """Header schema for TCP partial order connection permitted option."""
439
438
 
440
439
  if TYPE_CHECKING:
@@ -442,7 +441,7 @@ class PartialOrderConnectionPermitted(Option):
442
441
 
443
442
 
444
443
  @schema_final
445
- class PartialOrderConnectionProfile(Option):
444
+ class PartialOrderServiceProfile(Option, code=Enum_Option.Partial_Order_Service_Profile):
446
445
  """Header schema for TCP partial order connection service profile option."""
447
446
 
448
447
  #: Profile data.
@@ -456,7 +455,7 @@ class PartialOrderConnectionProfile(Option):
456
455
 
457
456
 
458
457
  @schema_final
459
- class CC(Option):
458
+ class CC(Option, code=Enum_Option.CC):
460
459
  """Header schema for TCP CC option."""
461
460
 
462
461
  #: Connection count.
@@ -467,7 +466,7 @@ class CC(Option):
467
466
 
468
467
 
469
468
  @schema_final
470
- class CCNew(Option):
469
+ class CCNew(Option, code=Enum_Option.CC_NEW):
471
470
  """Header schema for TCP connection count (new) option."""
472
471
 
473
472
  #: Connection count.
@@ -478,7 +477,7 @@ class CCNew(Option):
478
477
 
479
478
 
480
479
  @schema_final
481
- class CCEcho(Option):
480
+ class CCEcho(Option, code=Enum_Option.CC_ECHO):
482
481
  """Header schema for TCP connection count (echo) option."""
483
482
 
484
483
  #: Connection count.
@@ -489,7 +488,7 @@ class CCEcho(Option):
489
488
 
490
489
 
491
490
  @schema_final
492
- class AlternateChecksumRequest(Option):
491
+ class AlternateChecksumRequest(Option, code=Enum_Option.TCP_Alternate_Checksum_Request):
493
492
  """Header schema for TCP alternate checksum request option."""
494
493
 
495
494
  #: Checksum algorithm.
@@ -500,7 +499,7 @@ class AlternateChecksumRequest(Option):
500
499
 
501
500
 
502
501
  @schema_final
503
- class AlternateChecksumData(Option):
502
+ class AlternateChecksumData(Option, code=Enum_Option.TCP_Alternate_Checksum_Data):
504
503
  """Header schema for TCP alternate checksum data option."""
505
504
 
506
505
  #: Checksum data.
@@ -511,7 +510,7 @@ class AlternateChecksumData(Option):
511
510
 
512
511
 
513
512
  @schema_final
514
- class MD5Signature(Option):
513
+ class MD5Signature(Option, code=Enum_Option.MD5_Signature_Option):
515
514
  """Header schema for TCP MD5 signature option."""
516
515
 
517
516
  #: MD5 digest.
@@ -522,7 +521,7 @@ class MD5Signature(Option):
522
521
 
523
522
 
524
523
  @schema_final
525
- class QuickStartResponse(Option):
524
+ class QuickStartResponse(Option, code=Enum_Option.Quick_Start_Response):
526
525
  """Header schema for TCP quick start response option."""
527
526
 
528
527
  #: Flags.
@@ -541,7 +540,7 @@ class QuickStartResponse(Option):
541
540
 
542
541
 
543
542
  @schema_final
544
- class UserTimeout(Option):
543
+ class UserTimeout(Option, code=Enum_Option.User_Timeout_Option):
545
544
  """Header schema for TCP user timeout option."""
546
545
 
547
546
  #: Granularity and user timeout.
@@ -555,7 +554,7 @@ class UserTimeout(Option):
555
554
 
556
555
 
557
556
  @schema_final
558
- class Authentication(Option):
557
+ class Authentication(Option, code=Enum_Option.TCP_Authentication_Option):
559
558
  """Header schema for TCP authentication option."""
560
559
 
561
560
  #: Key ID.
@@ -598,9 +597,15 @@ class _MPTCP(Schema):
598
597
  return ret
599
598
 
600
599
 
601
- class MPTCP(Option):
600
+ # register ``_MPTCP`` as ``Multipath_TCP`` option
601
+ Option.register(Enum_Option.Multipath_TCP, _MPTCP)
602
+
603
+
604
+ class MPTCP(EnumSchema[Enum_MPTCPOption]):
602
605
  """Header schema for Multipath TCP options."""
603
606
 
607
+ __enum__: 'DefaultDict[Enum_MPTCPOption, Type[MPTCP]]' = collections.defaultdict(lambda: MPTCPUnknown)
608
+
604
609
  if TYPE_CHECKING:
605
610
  #: MPTCP subtype.
606
611
  subtype: 'Enum_MPTCPOption'
@@ -623,7 +628,7 @@ class MPTCPUnknown(MPTCP):
623
628
 
624
629
 
625
630
  @schema_final
626
- class MPTCPCapable(MPTCP):
631
+ class MPTCPCapable(MPTCP, code=Enum_MPTCPOption.MP_CAPABLE):
627
632
  """Header schema for Multipath TCP capable option."""
628
633
 
629
634
  #: Subtype and version.
@@ -649,7 +654,7 @@ class MPTCPCapable(MPTCP):
649
654
  def __init__(self, kind: 'Enum_Option', length: 'int', test: 'MPTCPSubtypeCapable', flags: 'MPTCPCapableFlags', skey: 'int', rkey: 'Optional[int]') -> 'None': ...
650
655
 
651
656
 
652
- class MPTCPJoin(MPTCP):
657
+ class MPTCPJoin(MPTCP, code=Enum_MPTCPOption.MP_JOIN): # register as a placeholder
653
658
  """Header schema for Multipath TCP join option."""
654
659
 
655
660
 
@@ -711,7 +716,7 @@ class MPTCPJoinACK(MPTCPJoin):
711
716
 
712
717
 
713
718
  @schema_final
714
- class MPTCPDSS(MPTCP):
719
+ class MPTCPDSS(MPTCP, code=Enum_MPTCPOption.DSS):
715
720
  """Header schema for Multipath TCP DSS option."""
716
721
 
717
722
  #: Subtype and flags.
@@ -757,7 +762,7 @@ class MPTCPDSS(MPTCP):
757
762
 
758
763
 
759
764
  @schema_final
760
- class MPTCPAddAddress(MPTCP):
765
+ class MPTCPAddAddress(MPTCP, code=Enum_MPTCPOption.ADD_ADDR):
761
766
  """Header schema for Multipath TCP add address option."""
762
767
 
763
768
  #: Subtype and IP version.
@@ -782,7 +787,7 @@ class MPTCPAddAddress(MPTCP):
782
787
 
783
788
 
784
789
  @schema_final
785
- class MPTCPRemoveAddress(MPTCP):
790
+ class MPTCPRemoveAddress(MPTCP, code=Enum_MPTCPOption.REMOVE_ADDR):
786
791
  """Header schema for Multipath TCP remove address option."""
787
792
 
788
793
  #: Subtype.
@@ -800,7 +805,7 @@ class MPTCPRemoveAddress(MPTCP):
800
805
 
801
806
 
802
807
  @schema_final
803
- class MPTCPPriority(MPTCP):
808
+ class MPTCPPriority(MPTCP, code=Enum_MPTCPOption.MP_PRIO):
804
809
  """Header schema for Multipath TCP priority option."""
805
810
 
806
811
  #: Subtype.
@@ -819,7 +824,7 @@ class MPTCPPriority(MPTCP):
819
824
 
820
825
 
821
826
  @schema_final
822
- class MPTCPFallback(MPTCP):
827
+ class MPTCPFallback(MPTCP, code=Enum_MPTCPOption.MP_FAIL):
823
828
  """Header schema for Multipath TCP fallback option."""
824
829
 
825
830
  #: Subtype.
@@ -834,7 +839,7 @@ class MPTCPFallback(MPTCP):
834
839
 
835
840
 
836
841
  @schema_final
837
- class MPTCPFastclose(MPTCP):
842
+ class MPTCPFastclose(MPTCP, code=Enum_MPTCPOption.MP_FASTCLOSE):
838
843
  """Header schema for Multipath TCP fastclose option."""
839
844
 
840
845
  #: Subtype.
@@ -849,7 +854,7 @@ class MPTCPFastclose(MPTCP):
849
854
 
850
855
 
851
856
  @schema_final
852
- class FastOpenCookie(Option):
857
+ class FastOpenCookie(Option, code=Enum_Option.TCP_Fast_Open_Cookie):
853
858
  """"Header schema for TCP Fast Open option."""
854
859
 
855
860
  #: Cookie.
@@ -901,31 +906,8 @@ class TCP(Schema):
901
906
  length=lambda pkt: pkt['offset']['offset'] * 4 - 20,
902
907
  base_schema=Option,
903
908
  type_name='kind',
909
+ registry=Option.registry,
904
910
  eool=Enum_Option.End_of_Option_List,
905
- registry=collections.defaultdict(lambda: UnassignedOption, {
906
- Enum_Option.End_of_Option_List: EndOfOptionList,
907
- Enum_Option.No_Operation: NoOperation,
908
- Enum_Option.Maximum_Segment_Size: MaximumSegmentSize,
909
- Enum_Option.Window_Scale: WindowScale,
910
- Enum_Option.SACK_Permitted: SACKPermitted,
911
- Enum_Option.SACK: SACK,
912
- Enum_Option.Echo: Echo,
913
- Enum_Option.Echo_Reply: EchoReply,
914
- Enum_Option.Timestamps: Timestamp,
915
- Enum_Option.Partial_Order_Connection_Permitted: PartialOrderConnectionPermitted,
916
- Enum_Option.Partial_Order_Service_Profile: PartialOrderConnectionProfile,
917
- Enum_Option.CC: CC,
918
- Enum_Option.CC_NEW: CCNew,
919
- Enum_Option.CC_ECHO: CCEcho,
920
- Enum_Option.TCP_Alternate_Checksum_Request: AlternateChecksumRequest,
921
- Enum_Option.TCP_Alternate_Checksum_Data: AlternateChecksumData,
922
- Enum_Option.MD5_Signature_Option: MD5Signature,
923
- Enum_Option.Quick_Start_Response: QuickStartResponse,
924
- Enum_Option.User_Timeout_Option: UserTimeout,
925
- Enum_Option.TCP_Authentication_Option: Authentication,
926
- Enum_Option.Multipath_TCP: _MPTCP,
927
- Enum_Option.TCP_Fast_Open_Cookie: FastOpenCookie,
928
- }),
929
911
  )
930
912
  #: Padding.
931
913
  padding: 'bytes' = PaddingField(length=lambda pkt: pkt.get('__option_padding__', 0)) # key generated by OptionField
@@ -936,16 +918,3 @@ class TCP(Schema):
936
918
  def __init__(self, srcport: 'Enum_AppType | int', dstport: 'Enum_AppType | int', seq: 'int', ack: 'int',
937
919
  offset: 'OffsetFlag', flags: 'Flags', window: 'int', checksum: 'bytes',
938
920
  urgent: 'int', options: 'list[Option | bytes] | bytes', payload: 'bytes | Protocol | Schema') -> 'None': ...
939
-
940
-
941
- #: DefaultDict[Enum_MPTCPOption, Type[MPTCP]]: Mapping of MPTCP type numbers to schemas.
942
- MAP_MPTCP_DATA = collections.defaultdict(lambda: MPTCPUnknown, {
943
- Enum_MPTCPOption.MP_CAPABLE: MPTCPCapable,
944
- #Enum_MPTCPOption.MP_JOIN: MPTCPJoin,
945
- Enum_MPTCPOption.DSS: MPTCPDSS,
946
- Enum_MPTCPOption.ADD_ADDR: MPTCPAddAddress,
947
- Enum_MPTCPOption.REMOVE_ADDR: MPTCPRemoveAddress,
948
- Enum_MPTCPOption.MP_PRIO: MPTCPPriority,
949
- Enum_MPTCPOption.MP_FAIL: MPTCPFallback,
950
- Enum_MPTCPOption.MP_FASTCLOSE: MPTCPFastclose,
951
- }) # type: DefaultDict[Enum_MPTCPOption | int, Type[MPTCP]]
@@ -82,11 +82,11 @@ from pcapkit.protocols.data.transport.tcp import NoOperation as Data_NoOperation
82
82
  from pcapkit.protocols.data.transport.tcp import \
83
83
  PartialOrderConnectionPermitted as Data_PartialOrderConnectionPermitted
84
84
  from pcapkit.protocols.data.transport.tcp import \
85
- PartialOrderConnectionProfile as Data_PartialOrderConnectionProfile
85
+ PartialOrderServiceProfile as Data_PartialOrderServiceProfile
86
86
  from pcapkit.protocols.data.transport.tcp import QuickStartResponse as Data_QuickStartResponse
87
87
  from pcapkit.protocols.data.transport.tcp import SACKBlock as Data_SACKBlock
88
88
  from pcapkit.protocols.data.transport.tcp import SACKPermitted as Data_SACKPermitted
89
- from pcapkit.protocols.data.transport.tcp import Timestamp as Data_Timestamp
89
+ from pcapkit.protocols.data.transport.tcp import Timestamps as Data_Timestamps
90
90
  from pcapkit.protocols.data.transport.tcp import UnassignedOption as Data_UnassignedOption
91
91
  from pcapkit.protocols.data.transport.tcp import UserTimeout as Data_UserTimeout
92
92
  from pcapkit.protocols.data.transport.tcp import WindowScale as Data_WindowScale
@@ -121,11 +121,11 @@ from pcapkit.protocols.schema.transport.tcp import NoOperation as Schema_NoOpera
121
121
  from pcapkit.protocols.schema.transport.tcp import \
122
122
  PartialOrderConnectionPermitted as Schema_PartialOrderConnectionPermitted
123
123
  from pcapkit.protocols.schema.transport.tcp import \
124
- PartialOrderConnectionProfile as Schema_PartialOrderConnectionProfile
124
+ PartialOrderServiceProfile as Schema_PartialOrderServiceProfile
125
125
  from pcapkit.protocols.schema.transport.tcp import QuickStartResponse as Schema_QuickStartResponse
126
126
  from pcapkit.protocols.schema.transport.tcp import SACKBlock as Schema_SACKBlock
127
127
  from pcapkit.protocols.schema.transport.tcp import SACKPermitted as Schema_SACKPermitted
128
- from pcapkit.protocols.schema.transport.tcp import Timestamp as Schema_Timestamp
128
+ from pcapkit.protocols.schema.transport.tcp import Timestamps as Schema_Timestamps
129
129
  from pcapkit.protocols.schema.transport.tcp import UnassignedOption as Schema_UnassignedOption
130
130
  from pcapkit.protocols.schema.transport.tcp import UserTimeout as Schema_UserTimeout
131
131
  from pcapkit.protocols.schema.transport.tcp import WindowScale as Schema_WindowScale
@@ -960,7 +960,7 @@ class TCP(Transport[Data_TCP, Schema_TCP],
960
960
  )
961
961
  return data
962
962
 
963
- def _read_mode_ts(self, schema: 'Schema_Timestamp', *, options: 'Option') -> 'Data_Timestamp': # pylint: disable=unused-argument
963
+ def _read_mode_ts(self, schema: 'Schema_Timestamps', *, options: 'Option') -> 'Data_Timestamps': # pylint: disable=unused-argument
964
964
  """Read TCP timestamps option.
965
965
 
966
966
  Structure of TCP timestamp option [:rfc:`7323`]:
@@ -986,7 +986,7 @@ class TCP(Transport[Data_TCP, Schema_TCP],
986
986
  if schema.length != 10:
987
987
  raise ProtocolError(f'{self.alias}: [OptNo {schema.kind}] invalid format')
988
988
 
989
- data = Data_Timestamp(
989
+ data = Data_Timestamps(
990
990
  kind=schema.kind,
991
991
  length=schema.length,
992
992
  timestamp=schema.value,
@@ -1024,7 +1024,7 @@ class TCP(Transport[Data_TCP, Schema_TCP],
1024
1024
  length=schema.length,
1025
1025
  )
1026
1026
 
1027
- def _read_mode_pocsp(self, schema: 'Schema_PartialOrderConnectionProfile', *, options: 'Option') -> 'Data_PartialOrderConnectionProfile': # pylint: disable=unused-argument
1027
+ def _read_mode_pocsp(self, schema: 'Schema_PartialOrderServiceProfile', *, options: 'Option') -> 'Data_PartialOrderServiceProfile': # pylint: disable=unused-argument
1028
1028
  """Read TCP partial order connection service profile option.
1029
1029
 
1030
1030
  Structure of TCP ``POC-SP`` option [:rfc:`1693`][:rfc:`6247`]:
@@ -1050,7 +1050,7 @@ class TCP(Transport[Data_TCP, Schema_TCP],
1050
1050
  if schema.length != 3:
1051
1051
  raise ProtocolError(f'{self.alias}: [OptNo {schema.kind}] invalid format')
1052
1052
 
1053
- data = Data_PartialOrderConnectionProfile(
1053
+ data = Data_PartialOrderServiceProfile(
1054
1054
  kind=schema.kind,
1055
1055
  length=schema.length,
1056
1056
  start=bool(schema.profile['start']),
@@ -2206,10 +2206,10 @@ class TCP(Transport[Data_TCP, Schema_TCP],
2206
2206
  data=data,
2207
2207
  )
2208
2208
 
2209
- def _make_mode_ts(self, code: 'Enum_Option', opt: 'Optional[Data_Timestamp]' = None, *,
2209
+ def _make_mode_ts(self, code: 'Enum_Option', opt: 'Optional[Data_Timestamps]' = None, *,
2210
2210
  tsval: 'int' = 0,
2211
2211
  tsecr: 'int' = 0,
2212
- **kwargs: 'Any') -> 'Schema_Timestamp':
2212
+ **kwargs: 'Any') -> 'Schema_Timestamps':
2213
2213
  """Make TCP timestamps option.
2214
2214
 
2215
2215
  Args:
@@ -2227,7 +2227,7 @@ class TCP(Transport[Data_TCP, Schema_TCP],
2227
2227
  tsval = opt.timestamp
2228
2228
  tsecr = opt.echo
2229
2229
 
2230
- return Schema_Timestamp(
2230
+ return Schema_Timestamps(
2231
2231
  kind=code,
2232
2232
  length=10,
2233
2233
  value=tsval,
@@ -2252,10 +2252,10 @@ class TCP(Transport[Data_TCP, Schema_TCP],
2252
2252
  length=2,
2253
2253
  )
2254
2254
 
2255
- def _make_mode_pocsp(self, code: 'Enum_Option', opt: 'Optional[Data_PartialOrderConnectionProfile]' = None, *,
2255
+ def _make_mode_pocsp(self, code: 'Enum_Option', opt: 'Optional[Data_PartialOrderServiceProfile]' = None, *,
2256
2256
  start: 'bool' = False,
2257
2257
  end: 'bool' = False,
2258
- **kwargs: 'Any') -> 'Schema_PartialOrderConnectionProfile':
2258
+ **kwargs: 'Any') -> 'Schema_PartialOrderServiceProfile':
2259
2259
  """Make TCP partial order connection service profile option.
2260
2260
 
2261
2261
  Args:
@@ -2273,7 +2273,7 @@ class TCP(Transport[Data_TCP, Schema_TCP],
2273
2273
  start = opt.start
2274
2274
  end = opt.end
2275
2275
 
2276
- return Schema_PartialOrderConnectionProfile(
2276
+ return Schema_PartialOrderServiceProfile(
2277
2277
  kind=code,
2278
2278
  length=3,
2279
2279
  profile={
@@ -46,7 +46,7 @@ from aenum import StrEnum, extend_enum
46
46
  __all__ = ['{NAME}']
47
47
 
48
48
  if TYPE_CHECKING:
49
- from typing import DefaultDict, Optional, Type
49
+ from typing import Any, DefaultDict, Optional, Type
50
50
 
51
51
 
52
52
  class {NAME}(StrEnum):
@@ -81,6 +81,30 @@ class {NAME}(StrEnum):
81
81
  def __str__(self) -> 'str':
82
82
  return '%s [%d]' % (self.opt_name, self.opt_value)
83
83
 
84
+ def __int__(self) -> 'int':
85
+ return self.opt_value
86
+
87
+ def __lt__(self, other: '{NAME}') -> 'bool':
88
+ return self.opt_value < other
89
+
90
+ def __gt__(self, other: '{NAME}') -> 'bool':
91
+ return self.opt_value > other
92
+
93
+ def __le__(self, other: '{NAME}') -> 'bool':
94
+ return self.opt_value <= other
95
+
96
+ def __ge__(self, other: '{NAME}') -> 'bool':
97
+ return self.opt_value >= other
98
+
99
+ def __eq__(self, other: 'Any') -> 'bool':
100
+ return self.opt_value == other
101
+
102
+ def __ne__(self, other: 'Any') -> 'bool':
103
+ return self.opt_value != other
104
+
105
+ def __hash__(self) -> 'int':
106
+ return hash(self.opt_value)
107
+
84
108
  {ENUM}
85
109
 
86
110
  @staticmethod
@@ -47,7 +47,7 @@ from pcapkit.utilities.compat import show_flag_values
47
47
  __all__ = ['{NAME}']
48
48
 
49
49
  if TYPE_CHECKING:
50
- from typing import DefaultDict, Type
50
+ from typing import Any, DefaultDict, Type
51
51
 
52
52
 
53
53
  class TransportProtocol(IntFlag):
@@ -119,6 +119,30 @@ class {NAME}(StrEnum):
119
119
  def __str__(self) -> 'str':
120
120
  return '%s [%d - %s]' % (self.svc, self.port, self.proto.name)
121
121
 
122
+ def __int__(self) -> 'int':
123
+ return self.opt_value
124
+
125
+ def __lt__(self, other: '{NAME}') -> 'bool':
126
+ return self.opt_value < other
127
+
128
+ def __gt__(self, other: '{NAME}') -> 'bool':
129
+ return self.opt_value > other
130
+
131
+ def __le__(self, other: '{NAME}') -> 'bool':
132
+ return self.opt_value <= other
133
+
134
+ def __ge__(self, other: '{NAME}') -> 'bool':
135
+ return self.opt_value >= other
136
+
137
+ def __eq__(self, other: 'Any') -> 'bool':
138
+ return self.opt_value == other
139
+
140
+ def __ne__(self, other: 'Any') -> 'bool':
141
+ return self.opt_value != other
142
+
143
+ def __hash__(self) -> 'int':
144
+ return hash(self.opt_value)
145
+
122
146
  {ENUM}
123
147
 
124
148
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pypcapkit
3
- Version: 1.0.3.post3
3
+ Version: 1.1.0.post1
4
4
  Summary: PyPCAPKit: comprehensive network packet analysis library
5
5
  Author-email: Jarry Shaw <jarryshaw@icloud.com>
6
6
  Maintainer: Jarry Shaw