pypcapkit 1.0.3.post3__cp38-none-any.whl → 1.1.0__cp38-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 (39) hide show
  1. pcapkit/__init__.py +1 -1
  2. pcapkit/corekit/fields/collections.py +4 -5
  3. pcapkit/corekit/fields/field.py +33 -8
  4. pcapkit/corekit/fields/ipaddress.py +0 -1
  5. pcapkit/corekit/fields/misc.py +14 -19
  6. pcapkit/corekit/fields/numbers.py +2 -3
  7. pcapkit/corekit/fields/strings.py +2 -3
  8. pcapkit/corekit/infoclass.py +59 -6
  9. pcapkit/corekit/protochain.py +8 -1
  10. pcapkit/foundation/registry/protocols.py +30 -51
  11. pcapkit/protocols/data/__init__.py +4 -4
  12. pcapkit/protocols/data/internet/__init__.py +4 -4
  13. pcapkit/protocols/data/internet/mh.py +4 -4
  14. pcapkit/protocols/data/transport/__init__.py +4 -4
  15. pcapkit/protocols/data/transport/tcp.py +4 -4
  16. pcapkit/protocols/internet/mh.py +20 -20
  17. pcapkit/protocols/protocol.py +3 -2
  18. pcapkit/protocols/schema/__init__.py +4 -4
  19. pcapkit/protocols/schema/application/httpv2.py +16 -29
  20. pcapkit/protocols/schema/internet/__init__.py +4 -4
  21. pcapkit/protocols/schema/internet/hip.py +62 -111
  22. pcapkit/protocols/schema/internet/hopopt.py +46 -48
  23. pcapkit/protocols/schema/internet/ipv4.py +36 -41
  24. pcapkit/protocols/schema/internet/ipv6_opts.py +48 -52
  25. pcapkit/protocols/schema/internet/ipv6_route.py +9 -20
  26. pcapkit/protocols/schema/internet/mh.py +49 -84
  27. pcapkit/protocols/schema/misc/pcapng.py +178 -195
  28. pcapkit/protocols/schema/schema.py +252 -53
  29. pcapkit/protocols/schema/transport/__init__.py +4 -4
  30. pcapkit/protocols/schema/transport/tcp.py +52 -83
  31. pcapkit/protocols/transport/tcp.py +14 -14
  32. pcapkit/vendor/pcapng/option_type.py +25 -1
  33. pcapkit/vendor/reg/apptype.py +25 -1
  34. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.dist-info}/METADATA +1 -1
  35. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.dist-info}/RECORD +39 -39
  36. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.dist-info}/LICENSE +0 -0
  37. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.dist-info}/WHEEL +0 -0
  38. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.dist-info}/entry_points.txt +0 -0
  39. {pypcapkit-1.0.3.post3.dist-info → pypcapkit-1.1.0.dist-info}/top_level.txt +0 -0
pcapkit/__init__.py CHANGED
@@ -123,4 +123,4 @@ __all__ = [
123
123
  ]
124
124
 
125
125
  #: version number
126
- __version__ = '1.0.3.post3'
126
+ __version__ = '1.1.0'
@@ -56,7 +56,7 @@ class ListField(_Field[List[_TL]], Generic[_TL]):
56
56
  def __init__(self, length: 'int | Callable[[dict[str, Any]], int]' = lambda _: -1,
57
57
  item_type: 'Optional[_Field]' = None,
58
58
  callback: 'Callable[[Self, dict[str, Any]], None]' = lambda *_: None) -> 'None':
59
- self._name = '<list>'
59
+ #self._name = '<list>'
60
60
  self._callback = callback
61
61
  self._item_type = item_type
62
62
 
@@ -75,9 +75,8 @@ class ListField(_Field[List[_TL]], Generic[_TL]):
75
75
  Returns:
76
76
  Updated field instance.
77
77
 
78
- Notes:
79
- This method will return a new instance of :class:`ListField`
80
- instead of updating the current instance.
78
+ This method will return a new instance of :class:`ListField`
79
+ instead of updating the current instance.
81
80
 
82
81
  """
83
82
  new_self = copy.copy(self)
@@ -213,7 +212,7 @@ class OptionField(ListField, Generic[_TS]):
213
212
  eool: 'Optional[int | StdlibEnum | AenumEnum]' = None,
214
213
  callback: 'Callable[[Self, dict[str, Any]], None]' = lambda *_: None) -> 'None':
215
214
  super().__init__(length, None, callback)
216
- self._name = '<option>'
215
+ #self._name = '<option>'
217
216
  self._eool = eool
218
217
  self._option_padding = 0
219
218
 
@@ -16,6 +16,8 @@ if TYPE_CHECKING:
16
16
 
17
17
  from typing_extensions import Literal, Self
18
18
 
19
+ from pcapkit.protocols.schema.schema import Schema
20
+
19
21
  _T = TypeVar('_T')
20
22
 
21
23
 
@@ -41,6 +43,10 @@ class _Field(Generic[_T], metaclass=abc.ABCMeta):
41
43
  :meth:`~_Field.pack` should be considerate of the template format
42
44
  and the actual value provided for packing.
43
45
 
46
+ Args:
47
+ *args: Arbitrary positional arguments.
48
+ **kwargs: Arbitrary keyword arguments.
49
+
44
50
  """
45
51
 
46
52
  if TYPE_CHECKING:
@@ -98,9 +104,8 @@ class _Field(Generic[_T], metaclass=abc.ABCMeta):
98
104
  Returns:
99
105
  Updated field instance.
100
106
 
101
- Notes:
102
- This method will return a new instance of :class:`_Field` instead of
103
- updating the current instance.
107
+ This method will return a new instance of :class:`_Field` instead of
108
+ updating the current instance.
104
109
 
105
110
  """
106
111
  new_self = copy.copy(self)
@@ -109,7 +114,9 @@ class _Field(Generic[_T], metaclass=abc.ABCMeta):
109
114
 
110
115
  # NOTE: This method is created as a placeholder for the necessary attributes.
111
116
  def __init__(self, *args: 'Any', **kwargs: 'Any') -> 'None':
112
- self._name = f'<{type(self).__name__[:-5].lower()}>'
117
+ if not hasattr(self, '_name'):
118
+ self._name = f'<{type(self).__name__[:-5].lower()}>'
119
+
113
120
  self._default = NoValue
114
121
  self._template = '0s'
115
122
  self._callback = lambda *_: None
@@ -119,6 +126,22 @@ class _Field(Generic[_T], metaclass=abc.ABCMeta):
119
126
  return f'<{self.__class__.__name__}>'
120
127
  return f'<{self.__class__.__name__} {self.name}>'
121
128
 
129
+ def __set_name__(self, owner: 'Schema', name: 'str') -> 'None':
130
+ """Set field name and update field list (if applicable).
131
+
132
+ This method is to be called by the metaclass during class creation.
133
+ It is used to set the field name and update the field list, i.e.,
134
+ :attr:`Schema.__fields__ <pcapkit.protocols.schema.schema.Schema.__fields__>`
135
+ mapping dictionary.
136
+
137
+ """
138
+ # Update field list (if applicable)
139
+ if hasattr(owner, '__fields__'):
140
+ owner.__fields__[name] = self
141
+
142
+ # Set field name
143
+ self.name = name
144
+
122
145
  def pre_process(self, value: '_T', packet: 'dict[str, Any]') -> 'Any': # pylint: disable=unused-argument
123
146
  """Process field value before construction (packing).
124
147
 
@@ -204,7 +227,10 @@ class Field(_Field[_T], Generic[_T]):
204
227
  def __init__(self, length: 'int | Callable[[dict[str, Any]], int]',
205
228
  default: '_T | NoValueType' = NoValue,
206
229
  callback: 'Callable[[Self, dict[str, Any]], None]' = lambda *_: None) -> 'None':
207
- self._name = '<unknown>'
230
+ #self._name = '<unknown>'
231
+ if not hasattr(self, '_name'):
232
+ self._name = f'<{type(self).__name__[:-5].lower()}>'
233
+
208
234
  self._default = default
209
235
  self._callback = callback
210
236
 
@@ -222,9 +248,8 @@ class Field(_Field[_T], Generic[_T]):
222
248
  Returns:
223
249
  New instance of :class:`Field`.
224
250
 
225
- Notes:
226
- This method will return a new instance of :class:`Field` instead of
227
- updating the current instance.
251
+ This method will return a new instance of :class:`Field` instead of
252
+ updating the current instance.
228
253
 
229
254
  """
230
255
  new_self = copy.copy(self)
@@ -3,7 +3,6 @@
3
3
 
4
4
  import abc
5
5
  import ipaddress
6
- from sys import prefix
7
6
  from typing import TYPE_CHECKING, Generic, TypeVar, cast
8
7
 
9
8
  from pcapkit.corekit.fields.field import _T, Field, NoValue
@@ -141,9 +141,8 @@ class ConditionalField(_Field[_TC]):
141
141
  Returns:
142
142
  Updated field instance.
143
143
 
144
- Notes:
145
- This method will return a new instance of :class:`ConditionalField`
146
- instead of updating the current instance.
144
+ This method will return a new instance of :class:`ConditionalField`
145
+ instead of updating the current instance.
147
146
 
148
147
  """
149
148
  new_self = copy.copy(self)
@@ -273,7 +272,7 @@ class PayloadField(_Field[_TP]):
273
272
  default: '_TP | NoValueType | bytes' = NoValue,
274
273
  protocol: 'Optional[Type[_TP]]' = None,
275
274
  callback: 'Callable[[Self, dict[str, Any]], None]' = lambda *_: None) -> 'None':
276
- self._name = '<payload>'
275
+ #self._name = '<payload>'
277
276
  self._default = default # type: ignore[assignment]
278
277
  self._protocol = protocol # type: ignore[assignment]
279
278
  self._callback = callback
@@ -293,9 +292,8 @@ class PayloadField(_Field[_TP]):
293
292
  Returns:
294
293
  Updated field instance.
295
294
 
296
- Notes:
297
- This method will return a new instance of :class:`PayloadField`
298
- instead of updating the current instance.
295
+ This method will return a new instance of :class:`PayloadField`
296
+ instead of updating the current instance.
299
297
 
300
298
  """
301
299
  new_self = copy.copy(self)
@@ -409,7 +407,7 @@ class SwitchField(_Field[_TC]):
409
407
  return self._field
410
408
 
411
409
  def __init__(self, selector: 'Callable[[dict[str, Any]], _Field[_TC]]' = lambda _: NoValueField()) -> 'None': # type: ignore[assignment,return-value]
412
- self._name = '<switch>'
410
+ #self._name = '<switch>'
413
411
  self._field = cast('_Field[_TC]', NoValueField())
414
412
  self._selector = selector
415
413
 
@@ -422,9 +420,8 @@ class SwitchField(_Field[_TC]):
422
420
  Returns:
423
421
  New field instance.
424
422
 
425
- Notes:
426
- This method will return a new instance of :class:`SwitchField`
427
- instead of updating the current instance.
423
+ This method will return a new instance of :class:`SwitchField`
424
+ instead of updating the current instance.
428
425
 
429
426
  """
430
427
  new_self = copy.copy(self)
@@ -527,7 +524,7 @@ class SchemaField(_Field[_TS]):
527
524
  default: '_TS | NoValueType | bytes' = NoValue,
528
525
  packet: 'Optional[dict[str, Any]]' = None,
529
526
  callback: 'Callable[[Self, dict[str, Any]], None]' = lambda *_: None) -> 'None':
530
- self._name = '<schema>'
527
+ #self._name = '<schema>'
531
528
  self._callback = callback
532
529
 
533
530
  if packet is None:
@@ -557,9 +554,8 @@ class SchemaField(_Field[_TS]):
557
554
  Returns:
558
555
  New field instance.
559
556
 
560
- Notes:
561
- This method will return a new instance of :class:`SchemaField`
562
- instead of updating the current instance.
557
+ This method will return a new instance of :class:`SchemaField`
558
+ instead of updating the current instance.
563
559
 
564
560
  """
565
561
  new_self = copy.copy(self)
@@ -679,7 +675,7 @@ class ForwardMatchField(_Field[_TC]):
679
675
  return self._field
680
676
 
681
677
  def __init__(self, field: '_Field[_TC]') -> 'None':
682
- self._name = '<forward_match>'
678
+ #self._name = '<forward_match>'
683
679
  self._field = field
684
680
 
685
681
  def __call__(self, packet: 'dict[str, Any]') -> 'Self':
@@ -691,9 +687,8 @@ class ForwardMatchField(_Field[_TC]):
691
687
  Returns:
692
688
  Updated field instance.
693
689
 
694
- Notes:
695
- This method will return a new instance of :class:`ConditionalField`
696
- instead of updating the current instance.
690
+ This method will return a new instance of :class:`ConditionalField`
691
+ instead of updating the current instance.
697
692
 
698
693
  """
699
694
  new_self = copy.copy(self)
@@ -92,9 +92,8 @@ class NumberField(Field[int], Generic[_T]):
92
92
  Returns:
93
93
  New instance of :class:`NumberField`.
94
94
 
95
- Notes:
96
- This method will return a new instance of :class:`NumberField` instead of
97
- updating the current instance.
95
+ This method will return a new instance of :class:`NumberField` instead of
96
+ updating the current instance.
98
97
 
99
98
  """
100
99
  new_self = super().__call__(packet)
@@ -56,9 +56,8 @@ class _TextField(Field[_T], Generic[_T]):
56
56
  Returns:
57
57
  New instance of :class:`_TextField`.
58
58
 
59
- Notes:
60
- This method will return a new instance of :class:`_TextField` instead of
61
- updating the current instance.
59
+ This method will return a new instance of :class:`_TextField` instead of
60
+ updating the current instance.
62
61
 
63
62
  """
64
63
  new_self = super().__call__(packet)
@@ -10,6 +10,7 @@ designed to work alike :func:`dataclasses.dataclass` as introduced
10
10
  in :pep:`557`.
11
11
 
12
12
  """
13
+ import abc
13
14
  import collections.abc
14
15
  import enum
15
16
  import itertools
@@ -49,6 +50,11 @@ def info_final(cls: 'ST', *, _finalised: 'bool' = True) -> 'ST':
49
50
  class. It can be useful to reduce runtime generation
50
51
  time as well as caching already generated attributes.
51
52
 
53
+ Notes:
54
+ The decorator should only be used on the *final*
55
+ class, otherwise, any subclasses derived from a
56
+ finalised info class will not be re-finalised.
57
+
52
58
  Args:
53
59
  cls: Info class.
54
60
  _finalised: Whether to make the info class as finalised.
@@ -56,11 +62,6 @@ def info_final(cls: 'ST', *, _finalised: 'bool' = True) -> 'ST':
56
62
  Returns:
57
63
  Finalised info class.
58
64
 
59
- Notes:
60
- The decorator should only be used on the *final*
61
- class, otherwise, any subclasses derived from a
62
- finalised info class will not be re-finalised.
63
-
64
65
  :meta decorator:
65
66
  """
66
67
  if cls.__finalised__ == FinalisedState.FINAL:
@@ -140,7 +141,59 @@ def info_final(cls: 'ST', *, _finalised: 'bool' = True) -> 'ST':
140
141
  return final(cls)
141
142
 
142
143
 
143
- class Info(Mapping[str, VT], Generic[VT]):
144
+ class InfoMeta(abc.ABCMeta):
145
+ """Meta class to add dynamic support to :class:`Info`.
146
+
147
+ This meta class is used to generate necessary attributes for the
148
+ :class:`Info` class. It can be useful to reduce runtime generation
149
+ cost as well as caching already generated attributes.
150
+
151
+ * :attr:`Info.__additional__` and :attr:`Info.__excluded__` are
152
+ lists of additional and excluded field names, which are used to
153
+ determine certain names to be included or excluded from the field
154
+ dictionary. They will be automatically populated from the class
155
+ attributes of the :class:`Info` class and its base classes.
156
+
157
+ .. note::
158
+
159
+ This is implemented thru the :meth:`__new__` method, which will
160
+ inherit the additional and excluded field names from the base
161
+ classes, as well as populating the additional and excluded field
162
+ from the subclass attributes.
163
+
164
+ .. code-block:: python
165
+
166
+ class A(Info):
167
+ __additional__ = ['a', 'b']
168
+
169
+ class B(A):
170
+ __additional__ = ['c', 'd']
171
+
172
+ class C(B):
173
+ __additional__ = ['e', 'f']
174
+
175
+ print(A.__additional__) # ['a', 'b']
176
+ print(B.__additional__) # ['a', 'b', 'c', 'd']
177
+ print(C.__additional__) # ['a', 'b', 'c', 'd', 'e', 'f']
178
+
179
+ """
180
+
181
+ def __new__(cls, name: 'str', bases: 'tuple[type, ...]', attrs: 'dict[str, Any]', **kwargs: 'Any') -> 'Type[Info]':
182
+ if '__additional__' not in attrs:
183
+ attrs['__additional__'] = []
184
+ if '__excluded__' not in attrs:
185
+ attrs['__excluded__'] = []
186
+
187
+ for base in bases:
188
+ if hasattr(base, '__additional__'):
189
+ attrs['__additional__'].extend(
190
+ name for name in base.__additional__ if name not in attrs['__additional__'])
191
+ if hasattr(base, '__excluded__'):
192
+ attrs['__excluded__'].extend(name for name in base.__excluded__ if name not in attrs['__excluded__'])
193
+ return super().__new__(cls, name, bases, attrs, **kwargs) # type: ignore[return-value]
194
+
195
+
196
+ class Info(Mapping[str, VT], Generic[VT], metaclass=InfoMeta):
144
197
  """Turn dictionaries into :obj:`object` like instances.
145
198
 
146
199
  * :class:`Info` objects inherit from :obj:`dict` type
@@ -26,7 +26,14 @@ __all__ = ['ProtoChain']
26
26
 
27
27
 
28
28
  class ProtoChain(collections.abc.Sequence):
29
- """Protocols chain."""
29
+ """Protocols chain.
30
+
31
+ Args:
32
+ proto: New protocol class on the top stack.
33
+ alias: New protocol alias on the top stack.
34
+ basis: Original protocol chain as base stacks.
35
+
36
+ """
30
37
 
31
38
  #: Internal data storage for protocol chain.
32
39
  __data__: 'tuple[tuple[str, Type[Protocol]], ...]'
@@ -8,7 +8,7 @@ This module provides the protocol registries for :mod:`pcapkit`.
8
8
 
9
9
  """
10
10
  import importlib
11
- from typing import TYPE_CHECKING, cast
11
+ from typing import TYPE_CHECKING
12
12
 
13
13
  from pcapkit.protocols import __proto__ as protocol_registry
14
14
  from pcapkit.protocols.application.httpv2 import HTTP as HTTPv2
@@ -23,21 +23,23 @@ 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 MAP_HTTP_FRAME
27
- from pcapkit.protocols.schema.internet.hip import HIP as Schema_HIP
28
- from pcapkit.protocols.schema.internet.hopopt import HOPOPT as Schema_HOPOPT
29
- from pcapkit.protocols.schema.internet.ipv4 import IPv4 as Schema_IPv4
30
- from pcapkit.protocols.schema.internet.ipv6_opts import IPv6_Opts as Schema_IPv6_Opts
31
- from pcapkit.protocols.schema.internet.ipv6_route import MAP_IPV6_ROUTE_DATA
32
- from pcapkit.protocols.schema.internet.mh import MAP_MH_DATA
33
- from pcapkit.protocols.schema.internet.mh import CGAParameter as Schema_MH_CGAParameter
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
34
35
  from pcapkit.protocols.schema.internet.mh import Packet as Schema_MH_Packet
35
- from pcapkit.protocols.schema.misc.pcapng import MAP_DSB_SECRETS, MAP_PCAPNG_BLOCK
36
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
37
38
  from pcapkit.protocols.schema.misc.pcapng import \
38
- NameResolutionBlock as Schema_PCAPNG_NameResolutionBlock
39
- from pcapkit.protocols.schema.transport.tcp import MAP_MPTCP_DATA
40
- from pcapkit.protocols.schema.transport.tcp import TCP as Schema_TCP
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
41
43
  from pcapkit.protocols.transport.tcp import TCP
42
44
  from pcapkit.protocols.transport.udp import UDP
43
45
  from pcapkit.utilities.exceptions import RegistryError
@@ -65,7 +67,6 @@ if TYPE_CHECKING:
65
67
  from pcapkit.const.reg.transtype import TransType
66
68
  from pcapkit.const.tcp.mp_tcp_option import MPTCPOption as TCP_MPTCPOption
67
69
  from pcapkit.const.tcp.option import Option as TCP_Option
68
- from pcapkit.corekit.fields.collections import OptionField
69
70
  from pcapkit.protocols.application.httpv2 import FrameConstructor as HTTP_FrameConstructor
70
71
  from pcapkit.protocols.application.httpv2 import FrameParser as HTTP_FrameParser
71
72
  from pcapkit.protocols.internet.hip import ParameterConstructor as HIP_ParameterConstructor
@@ -93,22 +94,6 @@ if TYPE_CHECKING:
93
94
  from pcapkit.protocols.misc.pcapng import RecordParser as PCAPNG_RecordParser
94
95
  from pcapkit.protocols.misc.pcapng import SecretsConstructor as PCAPNG_SecretsConstructor
95
96
  from pcapkit.protocols.misc.pcapng import SecretsParser as PCAPNG_SecretsParser
96
- from pcapkit.protocols.schema.application.httpv2 import FrameType as Schema_HTTP_FrameType
97
- from pcapkit.protocols.schema.internet.hip import Parameter as Schema_HIP_Parameter
98
- from pcapkit.protocols.schema.internet.hopopt import Option as Schema_HOPOPT_Option
99
- from pcapkit.protocols.schema.internet.ipv4 import Option as Schema_IPv4_Option
100
- from pcapkit.protocols.schema.internet.ipv6_opts import Option as Schema_IPv6_Opts_Option
101
- from pcapkit.protocols.schema.internet.ipv6_route import \
102
- RoutingType as Schema_IPv6_Route_RoutingType
103
- from pcapkit.protocols.schema.internet.mh import CGAExtension as Schema_MH_CGAExtension
104
- from pcapkit.protocols.schema.internet.mh import Option as Schema_MH_Option
105
- from pcapkit.protocols.schema.internet.mh import Packet as Schema_MH_Packet
106
- from pcapkit.protocols.schema.misc.pcapng import DSBSecrets as Schema_PCAPNG_DSBSecrets
107
- from pcapkit.protocols.schema.misc.pcapng import \
108
- NameResolutionRecord as Schema_PCAPNG_NameResolutionRecord
109
- from pcapkit.protocols.schema.misc.pcapng import Option as Schema_PCAPNG_Option
110
- from pcapkit.protocols.schema.transport.tcp import MPTCP as Schema_TCP_MPTCP
111
- from pcapkit.protocols.schema.transport.tcp import Option as Schema_TCP_Option
112
97
  from pcapkit.protocols.transport.tcp import MPOptionConstructor as TCP_MPOptionConstructor
113
98
  from pcapkit.protocols.transport.tcp import MPOptionParser as TCP_MPOptionParser
114
99
  from pcapkit.protocols.transport.tcp import OptionConstructor as TCP_OptionConstructor
@@ -340,7 +325,7 @@ def register_ipv4_option(code: 'IPv4_OptionNumber', meth: 'str | tuple[IPv4_Opti
340
325
 
341
326
  IPv4.register_option(code, meth)
342
327
  if schema is not None:
343
- cast('OptionField[Schema_IPv4_Option]', Schema_IPv4.options).registry[code] = schema
328
+ Schema_IPv4_Option.register(code, schema)
344
329
  logger.info('registered IPv4 option parser: %s', code.name)
345
330
 
346
331
 
@@ -365,7 +350,7 @@ def register_hip_parameter(code: 'HIP_Parameter', meth: 'str | tuple[HIP_Paramet
365
350
 
366
351
  HIP.register_parameter(code, meth)
367
352
  if schema is not None:
368
- cast('OptionField[Schema_HIP_Parameter]', Schema_HIP.param).registry[code] = schema
353
+ Schema_HIP_Parameter.register(code, schema)
369
354
  logger.info('registered HIP parameter parser: %s', code.name)
370
355
 
371
356
 
@@ -390,7 +375,7 @@ def register_hopopt_option(code: 'IPv6_Option', meth: 'str | tuple[HOPOPT_Option
390
375
 
391
376
  HOPOPT.register_option(code, meth)
392
377
  if schema is not None:
393
- cast('OptionField[Schema_HOPOPT_Option]', Schema_HOPOPT.options).registry[code] = schema
378
+ Schema_HOPOPT_Option.register(code, schema)
394
379
  logger.info('registered HOPOPT option parser: %s', code.name)
395
380
 
396
381
 
@@ -415,7 +400,7 @@ def register_ipv6_opts_option(code: 'IPv6_Option', meth: 'str | tuple[IPv6_Opts_
415
400
 
416
401
  IPv6_Opts.register_option(code, meth)
417
402
  if schema is not None:
418
- cast('OptionField[Schema_IPv6_Opts_Option]', Schema_IPv6_Opts.options).registry[code] = schema
403
+ Schema_IPv6_Opts_Option.register(code, schema)
419
404
  logger.info('registered IPv6-Opts option parser: %s', code.name)
420
405
 
421
406
 
@@ -440,7 +425,7 @@ def register_ipv6_route_routing(code: 'IPv6_Routing', meth: 'str | tuple[IPv6_Ro
440
425
 
441
426
  IPv6_Route.register_routing(code, meth)
442
427
  if schema is not None:
443
- MAP_IPV6_ROUTE_DATA[code] = schema
428
+ Schema_IPv6_Route_RoutingType.register(code, schema)
444
429
  logger.info('registered IPv6-Route routing data parser: %s', code.name)
445
430
 
446
431
 
@@ -465,7 +450,7 @@ def register_mh_message(code: 'MH_Packet', meth: 'str | tuple[MH_PacketParser, M
465
450
 
466
451
  MH.register_message(code, meth)
467
452
  if schema is not None:
468
- MAP_MH_DATA[code] = schema
453
+ Schema_MH_Packet.register(code, schema)
469
454
  logger.info('registered MH message type parser: %s', code.name)
470
455
 
471
456
 
@@ -490,10 +475,7 @@ def register_mh_option(code: 'MH_Option', meth: 'str | tuple[MH_OptionParser, MH
490
475
 
491
476
  MH.register_option(code, meth)
492
477
  if schema is not None:
493
- for subclass in Schema_MH_Packet.__subclasses__():
494
- if not hasattr(subclass, 'options'):
495
- continue
496
- cast('OptionField[Schema_MH_Option]', subclass.options).registry[code] = schema
478
+ Schema_MH_Option.register(code, schema)
497
479
  logger.info('registered MH option parser: %s', code.name)
498
480
 
499
481
 
@@ -518,7 +500,7 @@ def register_mh_extension(code: 'MH_CGAExtension', meth: 'str | tuple[MH_Extensi
518
500
 
519
501
  MH.register_extension(code, meth)
520
502
  if schema is not None:
521
- cast('OptionField[Schema_MH_CGAExtension]', Schema_MH_CGAParameter.extensions).registry[code] = schema
503
+ Schema_MH_CGAExtension.register(code, schema)
522
504
  logger.info('registered MH CGA extension: %s', code.name)
523
505
 
524
506
 
@@ -616,7 +598,7 @@ def register_tcp_option(code: 'TCP_Option', meth: 'str | tuple[TCP_OptionParser,
616
598
 
617
599
  TCP.register_option(code, meth)
618
600
  if schema is not None:
619
- cast('OptionField[Schema_TCP_Option]', Schema_TCP.options).registry[code] = schema
601
+ Schema_TCP_Option.register(code, schema)
620
602
  logger.info('registered TCP option parser: %s', code.name)
621
603
 
622
604
 
@@ -641,7 +623,7 @@ def register_tcp_mp_option(code: 'TCP_MPTCPOption', meth: 'str | tuple[TCP_MPOpt
641
623
 
642
624
  TCP.register_mp_option(code, meth)
643
625
  if schema is not None:
644
- MAP_MPTCP_DATA[code] = schema
626
+ Schema_TCP_MPTCP.register(code, schema)
645
627
  logger.info('registered MPTCP option parser: %s', code.name)
646
628
 
647
629
 
@@ -699,7 +681,7 @@ def register_http_frame(code: 'HTTP_Frame', meth: 'str | tuple[HTTP_FrameParser,
699
681
 
700
682
  HTTPv2.register_frame(code, meth)
701
683
  if schema is not None:
702
- MAP_HTTP_FRAME[code] = schema
684
+ Schema_HTTP_FrameType.register(code, schema)
703
685
  logger.info('registered HTTP/2 frame parser: %s', code.name)
704
686
 
705
687
 
@@ -729,7 +711,7 @@ def register_pcapng_block(code: 'PCAPNG_BlockType', meth: 'str | tuple[PCAPNG_Bl
729
711
 
730
712
  PCAPNG.register_block(code, meth)
731
713
  if schema is not None:
732
- MAP_PCAPNG_BLOCK[code] = schema
714
+ Schema_PCAPNG_BlockType.register(code, schema)
733
715
  logger.info('registered PCAP-NG block parser: %s', code.name)
734
716
 
735
717
 
@@ -754,10 +736,7 @@ def register_pcapng_option(code: 'PCAPNG_OptionType', meth: 'str | tuple[PCAPNG_
754
736
 
755
737
  PCAPNG.register_option(code, meth)
756
738
  if schema is not None:
757
- for subclass in Schema_PCAPNG_BlockType.__subclasses__():
758
- if not hasattr(subclass, 'options'):
759
- continue
760
- cast('OptionField[Schema_PCAPNG_Option]', subclass.options).registry[code] = schema
739
+ Schema_PCAPNG_Option.register(code, schema)
761
740
  logger.info('registered PCAP-NG option parser: %s', code.name)
762
741
 
763
742
 
@@ -783,7 +762,7 @@ def register_pcapng_record(code: 'PCAPNG_RecordType', meth: 'str | tuple[PCAPNG_
783
762
 
784
763
  PCAPNG.register_record(code, meth)
785
764
  if schema is not None:
786
- cast('OptionField[Schema_PCAPNG_NameResolutionRecord]', Schema_PCAPNG_NameResolutionBlock.records).registry[code] = schema
765
+ Schema_PCAPNG_NameResolutionRecord.register(code, schema)
787
766
  logger.info('registered PCAP-NG name resolution record parser: %s', code.name)
788
767
 
789
768
 
@@ -808,5 +787,5 @@ def register_pcapng_secrets(code: 'PCAPNG_SecretsType', meth: 'str | tuple[PCAPN
808
787
 
809
788
  PCAPNG.register_secrets(code, meth)
810
789
  if schema is not None:
811
- MAP_DSB_SECRETS[code] = schema
790
+ Schema_PCAPNG_DSBSecrets.register(code, schema)
812
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', 'MH_BindRefreshAdviceOption', 'MH_AlternateCareofAddressOption',
142
- 'MH_NonceIndicesOption', 'MH_BindingAuthorizationDataOption', 'MH_MobileNetworkPrefixOption',
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', 'TCP_Timestamp', 'TCP_PartialOrderConnectionPermitted', # pylint: disable=line-too-long
156
- 'TCP_PartialOrderConnectionProfile', 'TCP_CC', 'TCP_CCNew', 'TCP_CCEcho', 'TCP_AlternateChecksumRequest',
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
- BindingAuthorizationDataOption as MH_BindingAuthorizationDataOption
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 BindRefreshAdviceOption as MH_BindRefreshAdviceOption
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', 'MH_BindRefreshAdviceOption', 'MH_AlternateCareofAddressOption',
291
- 'MH_NonceIndicesOption', 'MH_BindingAuthorizationDataOption', 'MH_MobileNetworkPrefixOption',
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', 'BindRefreshAdviceOption', 'AlternateCareofAddressOption',
74
- 'NonceIndicesOption', 'BindingAuthorizationDataOption', 'MobileNetworkPrefixOption',
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',
@@ -281,7 +281,7 @@ class PadOption(Option):
281
281
 
282
282
 
283
283
  @info_final
284
- class BindRefreshAdviceOption(Option):
284
+ class BindingRefreshAdviceOption(Option):
285
285
  """Data model for Binding Refresh Advice option."""
286
286
 
287
287
  #: Refresh interval.
@@ -316,7 +316,7 @@ class NonceIndicesOption(Option):
316
316
 
317
317
 
318
318
  @info_final
319
- class BindingAuthorizationDataOption(Option):
319
+ class AuthorizationDataOption(Option):
320
320
  """Data model for Binding Authorization Data option."""
321
321
 
322
322
  #: Authenticator.