Skip to content

Commit 55cde1b

Browse files
committed
added MH LLA Option Code const/vendor
1 parent 0438f26 commit 55cde1b

File tree

9 files changed

+207
-6
lines changed

9 files changed

+207
-6
lines changed

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"dtgram",
7272
"dtlr",
7373
"dtls",
74+
"DUID",
7475
"EAPOL",
7576
"ECDSA",
7677
"echore",
@@ -116,6 +117,7 @@
116117
"ghdr",
117118
"gpid",
118119
"gprof",
120+
"GUTI",
119121
"hdrs",
120122
"hend",
121123
"hexbuf",
@@ -139,6 +141,7 @@
139141
"ifrecv",
140142
"ilen",
141143
"ilnp",
144+
"IMSI",
142145
"inarp",
143146
"INET",
144147
"inte",
@@ -337,6 +340,7 @@
337340
"tidt",
338341
"tlen",
339342
"TLVs",
343+
"TMSI",
340344
"tnnl",
341345
"toctree",
342346
"todos",

docs/source/pcapkit/const/mh.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ enumerations include:
8484
- Quality-of-Service Attribute Registry [*]_
8585
* - :class:`MH_LMAControlledMAGSuboption <pcapkit.const.mh.lma_mag_suboption.LMAControlledMAGSuboption>`
8686
- LMA-Controlled MAG Parameters Sub-Option Type Values [*]_
87+
* - :class:`MH_LLACode <pcapkit.const.mh.lla_code.LLACode>`
88+
- Link-Layer Address (LLA) Option Code [*]_
8789

8890
Access Technology Type Option Type Values
8991
=========================================
@@ -566,11 +568,23 @@ which is automatically generated from :class:`pcapkit.vendor.mh.upn_reason.Updat
566568
:undoc-members:
567569
:show-inheritance:
568570

571+
Link-Layer Address (LLA) Option Code
572+
====================================
573+
574+
.. module:: pcapkit.const.mh.lla_code
575+
576+
This module contains the constant enumeration for **Link-Layer Address (LLA) Option Code**,
577+
which is automatically generated from :class:`pcapkit.vendor.mh.lla_code.LLACode`.
578+
579+
.. autoclass:: pcapkit.const.mh.lla_code.LLACode
580+
:members:
581+
:undoc-members:
582+
:show-inheritance:
583+
569584
.. raw:: html
570585

571586
<hr />
572587

573-
574588
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1
575589
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-2
576590
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-3
@@ -608,3 +622,4 @@ which is automatically generated from :class:`pcapkit.vendor.mh.upn_reason.Updat
608622
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#flow-binding-action
609623
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#qos-attribute
610624
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#lma-controlled-mag-parameters-sub-option-type
625+
.. [*] :rfc:`5568#section-6.4.3`

docs/source/pcapkit/vendor/mh.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ vendor crawlers include:
8484
- Quality-of-Service Attribute Registry [*]_
8585
* - :class:`MH_LMAControlledMAGSuboption <pcapkit.vendor.mh.lma_mag_suboption.LMAControlledMAGSuboption>`
8686
- LMA-Controlled MAG Parameters Sub-Option Type Values [*]_
87+
* - :class:`MH_LLACode <pcapkit.vendor.mh.lla_code.LLACode>`
88+
- Link-Layer Address (LLA) Option Code [*]_
8789

8890
Access Technology Type Option Type Values
8991
=========================================
@@ -529,11 +531,22 @@ which is automatically generating :class:`pcapkit.const.mh.upn_reason.UpdateNoti
529531
:members: FLAG, LINK
530532
:show-inheritance:
531533

534+
Link-Layer Address (LLA) Option Code
535+
====================================
536+
537+
.. module:: pcapkit.vendor.mh.lla_code
538+
539+
This module contains the vendor crawler for **Link-Layer Address (LLA) Option Code**,
540+
which is automatically generating :class:`pcapkit.const.mh.lla_code.LLACode`.
541+
542+
.. autoclass:: pcapkit.vendor.mh.lla_code.LLACode
543+
:members: FLAG, LINK
544+
:show-inheritance:
545+
532546
.. raw:: html
533547

534548
<hr />
535549

536-
537550
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1
538551
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-2
539552
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-3
@@ -571,3 +584,4 @@ which is automatically generating :class:`pcapkit.const.mh.upn_reason.UpdateNoti
571584
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#flow-binding-action
572585
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#qos-attribute
573586
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#lma-controlled-mag-parameters-sub-option-type
587+
.. [*] :rfc:`5568#section-6.4.3`

pcapkit/const/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
'MH_UpdateNotificationReason', 'MH_UpdateNotificationACKStatus',
6767
'MH_FlowBindingType', 'MH_FlowBindingIndicationTrigger',
6868
'MH_FlowBindingACKStatus', 'MH_FlowBindingAction', 'MH_QoSAttribute',
69-
'MH_LMAControlledMAGSuboption',
69+
'MH_LMAControlledMAGSuboption', 'MH_LLACode',
7070
# OSPF
7171
'OSPF_Authentication', 'OSPF_Packet',
7272
# TCP

pcapkit/const/mh/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
- Quality-of-Service Attribute Registry [*]_
8686
* - :class:`MH_LMAControlledMAGSuboption <pcapkit.const.mh.lma_mag_suboption.LMAControlledMAGSuboption>`
8787
- LMA-Controlled MAG Parameters Sub-Option Type Values [*]_
88+
* - :class:`MH_LLACode <pcapkit.const.mh.lla_code.LLACode>`
89+
- Link-Layer Address (LLA) Option Code [*]_
8890
8991
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1
9092
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-2
@@ -123,6 +125,7 @@
123125
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#flow-binding-action
124126
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#qos-attribute
125127
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#lma-controlled-mag-parameters-sub-option-type
128+
.. [*] :rfc:`5568#section-6.4.3`
126129
127130
"""
128131

@@ -165,6 +168,7 @@
165168
from pcapkit.const.mh.upa_status import \
166169
UpdateNotificationACKStatus as MH_UpdateNotificationACKStatus
167170
from pcapkit.const.mh.upn_reason import UpdateNotificationReason as MH_UpdateNotificationReason
171+
from pcapkit.const.mh.lla_code import LLACode as MH_LLACode
168172

169173
__all__ = [
170174
'MH_Packet', 'MH_Option', 'MH_DNSStatusCode', 'MH_ACKStatusCode',
@@ -179,5 +183,5 @@
179183
'MH_UpdateNotificationReason', 'MH_UpdateNotificationACKStatus',
180184
'MH_FlowBindingType', 'MH_FlowBindingIndicationTrigger',
181185
'MH_FlowBindingACKStatus', 'MH_FlowBindingAction', 'MH_QoSAttribute',
182-
'MH_LMAControlledMAGSuboption',
186+
'MH_LMAControlledMAGSuboption', 'MH_LLACode',
183187
]

pcapkit/const/mh/lla_code.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: utf-8 -*-
2+
# pylint: disable=line-too-long,consider-using-f-string
3+
"""Link-Layer Address (LLA) Option Code
4+
==========================================
5+
6+
.. module:: pcapkit.const.mh.lla_code
7+
8+
This module contains the constant enumeration for **Link-Layer Address (LLA) Option Code**,
9+
which is automatically generated from :class:`pcapkit.vendor.mh.lla_code.LLACode`.
10+
11+
"""
12+
13+
from aenum import IntEnum, extend_enum
14+
15+
__all__ = ['LLACode']
16+
17+
18+
class LLACode(IntEnum):
19+
"""[LLACode] Link-Layer Address (LLA) Option Code"""
20+
21+
Wilcard = 0
22+
23+
New_Access_Point = 1
24+
25+
MH = 2
26+
27+
NAR = 3
28+
29+
RtSolPr_or_PrRtAdv = 4
30+
31+
access_point = 5
32+
33+
no_prefix_information = 6
34+
35+
no_fast_handover_support = 7
36+
37+
@staticmethod
38+
def get(key: 'int | str', default: 'int' = -1) -> 'LLACode':
39+
"""Backport support for original codes.
40+
41+
Args:
42+
key: Key to get enum item.
43+
default: Default value if not found.
44+
45+
:meta private:
46+
"""
47+
if isinstance(key, int):
48+
return LLACode(key)
49+
if key not in LLACode._member_map_: # pylint: disable=no-member
50+
return extend_enum(LLACode, key, default)
51+
return LLACode[key] # type: ignore[misc]
52+
53+
@classmethod
54+
def _missing_(cls, value: 'int') -> 'LLACode':
55+
"""Lookup function used when value is not found.
56+
57+
Args:
58+
value: Value to get enum item.
59+
60+
"""
61+
if not (isinstance(value, int) and 0 <= value <= 255):
62+
raise ValueError('%r is not a valid %s' % (value, cls.__name__))
63+
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
@@ -90,7 +90,7 @@
9090
'MH_UpdateNotificationReason', 'MH_UpdateNotificationACKStatus',
9191
'MH_FlowBindingType', 'MH_FlowBindingIndicationTrigger',
9292
'MH_FlowBindingACKStatus', 'MH_FlowBindingAction', 'MH_QoSAttribute',
93-
'MH_LMAControlledMAGSuboption',
93+
'MH_LMAControlledMAGSuboption', 'MH_LLACode',
9494
# OSPF
9595
'OSPF_Authentication', 'OSPF_Packet',
9696
# TCP

pcapkit/vendor/mh/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
- Quality-of-Service Attribute Registry [*]_
8686
* - :class:`MH_LMAControlledMAGSuboption <pcapkit.vendor.mh.lma_mag_suboption.LMAControlledMAGSuboption>`
8787
- LMA-Controlled MAG Parameters Sub-Option Type Values [*]_
88+
* - :class:`MH_LLACode <pcapkit.vendor.mh.lla_code.LLACode>`
89+
- Link-Layer Address (LLA) Option Code [*]_
8890
8991
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1
9092
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-2
@@ -123,6 +125,7 @@
123125
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#flow-binding-action
124126
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#qos-attribute
125127
.. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#lma-controlled-mag-parameters-sub-option-type
128+
.. [*] :rfc:`5568#section-6.4.3`
126129
127130
"""
128131

@@ -165,6 +168,7 @@
165168
from pcapkit.vendor.mh.upa_status import \
166169
UpdateNotificationACKStatus as MH_UpdateNotificationACKStatus
167170
from pcapkit.vendor.mh.upn_reason import UpdateNotificationReason as MH_UpdateNotificationReason
171+
from pcapkit.vendor.mh.lla_code import LLACode as MH_LLACode
168172

169173
__all__ = [
170174
'MH_Packet', 'MH_Option', 'MH_DNSStatusCode', 'MH_ACKStatusCode',
@@ -179,5 +183,5 @@
179183
'MH_UpdateNotificationReason', 'MH_UpdateNotificationACKStatus',
180184
'MH_FlowBindingType', 'MH_FlowBindingIndicationTrigger',
181185
'MH_FlowBindingACKStatus', 'MH_FlowBindingAction', 'MH_QoSAttribute',
182-
'MH_LMAControlledMAGSuboption',
186+
'MH_LMAControlledMAGSuboption', 'MH_LLACode',
183187
]

pcapkit/vendor/mh/lla_code.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# -*- coding: utf-8 -*-
2+
"""Link-Layer Address (LLA) Option Code
3+
==========================================
4+
5+
.. module:: pcapkit.vendor.mh.lla_code
6+
7+
This module contains the vendor crawler for **Link-Layer Address (LLA) Option Code**,
8+
which is automatically generating :class:`pcapkit.const.mh.lla_code.LLACode`.
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__ = ['LLACode']
22+
23+
#: LLA option codes.
24+
DATA = {
25+
#: Wildcard requesting resolution for all nearby access points.
26+
0: 'Wilcard',
27+
#: Link-Layer Address of the New Access Point.
28+
1: 'New Access Point',
29+
#: Link-Layer Address of the MN.
30+
2: 'MH',
31+
#: Link-Layer Address of the NAR (i.e., Proxied Originator).
32+
3: 'NAR',
33+
#: Link-Layer Address of the source of RtSolPr or PrRtAdv.
34+
#: message.
35+
4: 'RtSolPr or PrRtAdv',
36+
#: The access point identified by the LLA belongs to the
37+
#: current interface of the router.
38+
5: 'access point',
39+
#: No prefix information available for the access point
40+
#: identified by the LLA.
41+
6: 'no prefix information',
42+
#: No fast handover support available for the access point
43+
#: identified by the LLA.
44+
7: 'no fast handover support',
45+
} # type: dict[int, str]
46+
47+
48+
49+
class LLACode(Vendor):
50+
"""Link-Layer Address (LLA) Option Code"""
51+
52+
#: Value limit checker.
53+
FLAG = 'isinstance(value, int) and 0 <= value <= 255'
54+
55+
def request(self) -> 'dict[int, str]': # type: ignore[override] # pylint: disable=arguments-differ
56+
"""Fetch registry data.
57+
58+
Returns:
59+
Registry data (:data:`~pcapkit.vendor.ipv4.qs_function.DATA`).
60+
61+
"""
62+
return DATA
63+
64+
def count(self, data: 'dict[int, str]') -> 'Counter[str]': # type: ignore[override]
65+
"""Count field records.
66+
67+
Args:
68+
data: Registry data.
69+
70+
Returns:
71+
Field recordings.
72+
73+
"""
74+
return collections.Counter(map(self.safe_name, data.values()))
75+
76+
def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # type: ignore[override]
77+
"""Process registry data.
78+
79+
Args:
80+
data: Registry data.
81+
82+
Returns:
83+
Enumeration fields and missing fields.
84+
85+
"""
86+
enum = [] # type: list[str]
87+
miss = [
88+
"return extend_enum(cls, 'Unassigned_%d' % value, value)",
89+
]
90+
for code, name in DATA.items():
91+
renm = self.rename(name, code) # type: ignore[arg-type]
92+
enum.append(f"{renm} = {code}".ljust(76))
93+
return enum, miss
94+
95+
96+
if __name__ == '__main__':
97+
sys.exit(LLACode()) # type: ignore[arg-type]

0 commit comments

Comments
 (0)