Skip to content

Commit 6d1853b

Browse files
committed
added MH Binding Error Status Code vendor/const
1 parent c30c8f0 commit 6d1853b

File tree

8 files changed

+172
-4
lines changed

8 files changed

+172
-4
lines changed

docs/source/pcapkit/const/mh.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ enumerations include:
9292
- CGA Extension Type Values [*]_
9393
* - :class:`MH_CGASec <pcapkit.const.mh.cga_sec.CGASec>`
9494
- CGA SEC [*]_
95+
* - :class:`MH_BindingError <pcapkit.const.mh.binding_error.BindingError>`
96+
- Bingding Error Status Code [*]_
9597

9698
Access Technology Type Option Type Values
9799
=========================================
@@ -626,6 +628,19 @@ which is automatically generated from :class:`pcapkit.vendor.mh.cga_sec.CGASec`.
626628
:undoc-members:
627629
:show-inheritance:
628630

631+
Binding Error Status Code
632+
=========================
633+
634+
.. module:: pcapkit.const.mh.binding_error
635+
636+
This module contains the constant enumeration for **Binding Error Status Code**,
637+
which is automatically generated from :class:`pcapkit.vendor.mh.binding_error.BindingError`.
638+
639+
.. autoclass:: pcapkit.const.mh.binding_error.BindingError
640+
:members:
641+
:undoc-members:
642+
:show-inheritance:
643+
629644
.. raw:: html
630645

631646
<hr />
@@ -671,3 +686,4 @@ which is automatically generated from :class:`pcapkit.vendor.mh.cga_sec.CGASec`.
671686
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-1
672687
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-2
673688
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-3
689+
.. [*] :rfc:`6275#section-6.1.9`

docs/source/pcapkit/vendor/mh.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ vendor crawlers include:
9292
- CGA Extension Type Values [*]_
9393
* - :class:`MH_CGASec <pcapkit.vendor.mh.cga_sec.CGASec>`
9494
- CGA SEC [*]_
95+
* - :class:`MH_BindingError <pcapkit.vendor.mh.binding_error.BindingError>`
96+
- Bingding Error Status Code [*]_
9597

9698
Access Technology Type Option Type Values
9799
=========================================
@@ -585,6 +587,18 @@ which is automatically generating :class:`pcapkit.const.mh.cga_sec.CGASec`.
585587
:members: FLAG, LINK
586588
:show-inheritance:
587589

590+
Binding Error Status Code
591+
=========================
592+
593+
.. module:: pcapkit.vendor.mh.binding_error
594+
595+
This module contains the vendor crawler for **Binding Error Status Code**,
596+
which is automatically generating :class:`pcapkit.const.mh.binding_error.BindingError`.
597+
598+
.. autoclass:: pcapkit.vendor.mh.binding_error.BindingError
599+
:members: FLAG, LINK
600+
:show-inheritance:
601+
588602
.. raw:: html
589603

590604
<hr />
@@ -630,3 +644,4 @@ which is automatically generating :class:`pcapkit.const.mh.cga_sec.CGASec`.
630644
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-1
631645
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-2
632646
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-3
647+
.. [*] :rfc:`6275#section-6.1.9`

pcapkit/const/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
'MH_FlowBindingType', 'MH_FlowBindingIndicationTrigger',
6868
'MH_FlowBindingACKStatus', 'MH_FlowBindingAction', 'MH_QoSAttribute',
6969
'MH_LMAControlledMAGSuboption', 'MH_LLACode', 'MH_CGAType',
70-
'MH_CGAExtension', 'MH_CGASec',
70+
'MH_CGAExtension', 'MH_CGASec', 'MH_BindingError',
7171
# OSPF
7272
'OSPF_Authentication', 'OSPF_Packet',
7373
# TCP

pcapkit/const/mh/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
- CGA Extension Type Values [*]_
9494
* - :class:`MH_CGASec <pcapkit.const.mh.cga_sec.CGASec>`
9595
- CGA SEC [*]_
96+
* - :class:`MH_BindingError <pcapkit.const.mh.binding_error.BindingError>`
97+
- Bingding Error Status Code [*]_
9698
9799
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1
98100
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-2
@@ -135,6 +137,7 @@
135137
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-1
136138
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-2
137139
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-3
140+
.. [*] :rfc:`6275#section-6.1.9`
138141
139142
"""
140143

@@ -181,6 +184,7 @@
181184
from pcapkit.const.mh.upa_status import \
182185
UpdateNotificationACKStatus as MH_UpdateNotificationACKStatus
183186
from pcapkit.const.mh.upn_reason import UpdateNotificationReason as MH_UpdateNotificationReason
187+
from pcapkit.const.mh.binding_error import BindingError as MH_BindingError
184188

185189
__all__ = [
186190
'MH_Packet', 'MH_Option', 'MH_DNSStatusCode', 'MH_ACKStatusCode',
@@ -196,5 +200,5 @@
196200
'MH_FlowBindingType', 'MH_FlowBindingIndicationTrigger',
197201
'MH_FlowBindingACKStatus', 'MH_FlowBindingAction', 'MH_QoSAttribute',
198202
'MH_LMAControlledMAGSuboption', 'MH_LLACode', 'MH_CGAType',
199-
'MH_CGAExtension', 'MH_CGASec',
203+
'MH_CGAExtension', 'MH_CGASec', 'MH_BindingError',
200204
]

pcapkit/const/mh/binding_error.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- coding: utf-8 -*-
2+
# pylint: disable=line-too-long,consider-using-f-string
3+
"""Binding Error Status Code
4+
===============================
5+
6+
.. module:: pcapkit.const.mh.binding_error
7+
8+
This module contains the constant enumeration for **Binding Error Status Code**,
9+
which is automatically generated from :class:`pcapkit.vendor.mh.binding_error.BindingError`.
10+
11+
"""
12+
13+
from aenum import IntEnum, extend_enum
14+
15+
__all__ = ['BindingError']
16+
17+
18+
class BindingError(IntEnum):
19+
"""[BindingError] Binding Error Status Code"""
20+
21+
Unknown_binding_for_Home_Address_destination_option = 1
22+
23+
Unrecognized_MH_Type_value = 2
24+
25+
@staticmethod
26+
def get(key: 'int | str', default: 'int' = -1) -> 'BindingError':
27+
"""Backport support for original codes.
28+
29+
Args:
30+
key: Key to get enum item.
31+
default: Default value if not found.
32+
33+
:meta private:
34+
"""
35+
if isinstance(key, int):
36+
return BindingError(key)
37+
if key not in BindingError._member_map_: # pylint: disable=no-member
38+
return extend_enum(BindingError, key, default)
39+
return BindingError[key] # type: ignore[misc]
40+
41+
@classmethod
42+
def _missing_(cls, value: 'int') -> 'BindingError':
43+
"""Lookup function used when value is not found.
44+
45+
Args:
46+
value: Value to get enum item.
47+
48+
"""
49+
if not (isinstance(value, int) and 0 <= value <= 255):
50+
raise ValueError('%r is not a valid %s' % (value, cls.__name__))
51+
return extend_enum(cls, 'Unassigned_%d' % value, value)

pcapkit/vendor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
'MH_FlowBindingType', 'MH_FlowBindingIndicationTrigger',
9292
'MH_FlowBindingACKStatus', 'MH_FlowBindingAction', 'MH_QoSAttribute',
9393
'MH_LMAControlledMAGSuboption', 'MH_LLACode', 'MH_CGAType',
94-
'MH_CGAExtension', 'MH_CGASec',
94+
'MH_CGAExtension', 'MH_CGASec', 'MH_BindingError',
9595
# OSPF
9696
'OSPF_Authentication', 'OSPF_Packet',
9797
# TCP

pcapkit/vendor/mh/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
- CGA Extension Type Values [*]_
9494
* - :class:`MH_CGASec <pcapkit.vendor.mh.cga_sec.CGASec>`
9595
- CGA SEC [*]_
96+
* - :class:`MH_BindingError <pcapkit.vendor.mh.binding_error.BindingError>`
97+
- Bingding Error Status Code [*]_
9698
9799
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1
98100
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-2
@@ -135,6 +137,7 @@
135137
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-1
136138
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-2
137139
.. [*] https://www.iana.org/assignments/cga-message-types/cga-message-types.xhtml#cga-message-types-3
140+
.. [*] :rfc:`6275#section-6.1.9`
138141
139142
"""
140143

@@ -181,6 +184,7 @@
181184
from pcapkit.vendor.mh.upa_status import \
182185
UpdateNotificationACKStatus as MH_UpdateNotificationACKStatus
183186
from pcapkit.vendor.mh.upn_reason import UpdateNotificationReason as MH_UpdateNotificationReason
187+
from pcapkit.vendor.mh.binding_error import BindingError as MH_BindingError
184188

185189
__all__ = [
186190
'MH_Packet', 'MH_Option', 'MH_DNSStatusCode', 'MH_ACKStatusCode',
@@ -196,5 +200,5 @@
196200
'MH_FlowBindingType', 'MH_FlowBindingIndicationTrigger',
197201
'MH_FlowBindingACKStatus', 'MH_FlowBindingAction', 'MH_QoSAttribute',
198202
'MH_LMAControlledMAGSuboption', 'MH_LLACode', 'MH_CGAType',
199-
'MH_CGAExtension', 'MH_CGASec',
203+
'MH_CGAExtension', 'MH_CGASec', 'MH_BindingError',
200204
]

pcapkit/vendor/mh/binding_error.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# -*- coding: utf-8 -*-
2+
"""Binding Error Status Code
3+
===============================
4+
5+
.. module:: pcapkit.vendor.mh.binding_error
6+
7+
This module contains the vendor crawler for **Binding Error Status Code**,
8+
which is automatically generating :class:`pcapkit.const.mh.binding_error.BindingError`.
9+
10+
"""
11+
12+
import collections
13+
import sys
14+
from typing import TYPE_CHECKING
15+
16+
from pcapkit.vendor.default import Vendor
17+
18+
if TYPE_CHECKING:
19+
from collections import Counter
20+
21+
__all__ = ['BindingError']
22+
23+
#: Binding error codes.
24+
DATA = {
25+
1: 'Unknown binding for Home Address destination option',
26+
2: 'Unrecognized MH Type value',
27+
} # type: dict[int, str]
28+
29+
30+
class BindingError(Vendor):
31+
"""Binding Error Status Code"""
32+
33+
#: Value limit checker.
34+
FLAG = 'isinstance(value, int) and 0 <= value <= 255'
35+
36+
def request(self) -> 'dict[int, str]': # type: ignore[override] # pylint: disable=arguments-differ
37+
"""Fetch registry data.
38+
39+
Returns:
40+
Registry data (:data:`~pcapkit.vendor.ipv4.qs_function.DATA`).
41+
42+
"""
43+
return DATA
44+
45+
def count(self, data: 'dict[int, str]') -> 'Counter[str]': # type: ignore[override]
46+
"""Count field records.
47+
48+
Args:
49+
data: Registry data.
50+
51+
Returns:
52+
Field recordings.
53+
54+
"""
55+
return collections.Counter(map(self.safe_name, data.values()))
56+
57+
def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # type: ignore[override]
58+
"""Process registry data.
59+
60+
Args:
61+
data: Registry data.
62+
63+
Returns:
64+
Enumeration fields and missing fields.
65+
66+
"""
67+
enum = [] # type: list[str]
68+
miss = [
69+
"return extend_enum(cls, 'Unassigned_%d' % value, value)",
70+
]
71+
for code, name in DATA.items():
72+
renm = self.rename(name, code) # type: ignore[arg-type]
73+
enum.append(f"{renm} = {code}".ljust(76))
74+
return enum, miss
75+
76+
77+
if __name__ == '__main__':
78+
sys.exit(BindingError()) # type: ignore[arg-type]

0 commit comments

Comments
 (0)