Source code for pcapkit.const.mh.packet
# -*- coding: utf-8 -*-
# pylint: disable=line-too-long,consider-using-f-string
"""Mobility Header Types - for the MH Type field in the Mobility Header
==========================================================================
.. module:: pcapkit.const.mh.packet
This module contains the constant enumeration for **Mobility Header Types - for the MH Type field in the Mobility Header**,
which is automatically generated from :class:`pcapkit.vendor.mh.packet.Packet`.
"""
from typing import TYPE_CHECKING
from aenum import IntEnum
from pcapkit.corekit.enum import EnumRegistry
from pcapkit.utilities.exceptions import EnumValueError
if TYPE_CHECKING:
from typing import Any
__all__ = ['Packet']
[docs]
class Packet(EnumRegistry, IntEnum):
"""[Packet] Mobility Header Types - for the MH Type field in the Mobility Header"""
#: Binding Refresh Request [:rfc:`6275`]
Binding_Refresh_Request = 0
#: Home Test Init [:rfc:`6275`]
Home_Test_Init = 1
#: Care-of Test Init [:rfc:`6275`]
Care_of_Test_Init = 2
#: Home Test [:rfc:`6275`]
Home_Test = 3
#: Care-of Test [:rfc:`6275`]
Care_of_Test = 4
#: Binding Update [:rfc:`6275`]
Binding_Update = 5
#: Binding Acknowledgement [:rfc:`6275`]
Binding_Acknowledgement = 6
#: Binding Error [:rfc:`6275`]
Binding_Error = 7
#: Fast Binding Update [:rfc:`5568`]
Fast_Binding_Update = 8
#: Fast Binding Acknowledgment [:rfc:`5568`]
Fast_Binding_Acknowledgment = 9
#: Fast Neighbor Advertisement (Deprecated) [:rfc:`5568`]
Fast_Neighbor_Advertisement = 10
#: Experimental Mobility Header [:rfc:`5096`]
Experimental_Mobility_Header = 11
#: Home Agent Switch Message [:rfc:`5142`]
Home_Agent_Switch_Message = 12
#: Heartbeat Message [:rfc:`5847`]
Heartbeat_Message = 13
#: Handover Initiate Message [:rfc:`5568`]
Handover_Initiate_Message = 14
#: Handover Acknowledge Message [:rfc:`5568`]
Handover_Acknowledge_Message = 15
#: Binding Revocation Message [:rfc:`5846`]
Binding_Revocation_Message = 16
#: Localized Routing Initiation [:rfc:`6705`]
Localized_Routing_Initiation = 17
#: Localized Routing Acknowledgment [:rfc:`6705`]
Localized_Routing_Acknowledgment = 18
#: Update Notification [:rfc:`7077`]
Update_Notification = 19
#: Update Notification Acknowledgement [:rfc:`7077`]
Update_Notification_Acknowledgement = 20
#: Flow Binding Message [:rfc:`7109`]
Flow_Binding_Message = 21
#: Subscription Query [:rfc:`7161`]
Subscription_Query = 22
#: Subscription Response [:rfc:`7161`]
Subscription_Response = 23
[docs]
@classmethod
def _validate_value(cls, value: 'Any') -> 'None':
"""Reject ``value`` unless it passes the range check :meth:`_missing_` makes.
Overrides :meth:`~pcapkit.corekit.enum.EnumLookup._validate_value`
with that check and the message it raises, so
:meth:`~pcapkit.corekit.enum.EnumRegistry.register` refuses exactly the
values :meth:`~pcapkit.corekit.enum.EnumLookup.get` refuses, in the
same words (:issue:`1816`).
Args:
value: Value about to be looked up or minted.
Raises:
EnumValueError: If ``value`` fails that check. A
:exc:`ValueError`, so an ``except ValueError`` caller is
unaffected.
"""
if not (isinstance(value, int) and 0 <= value <= 255):
raise EnumValueError('%r is not a valid %s' % (value, cls.__name__))
[docs]
@classmethod
def _missing_(cls, value: 'int') -> 'Packet':
"""Lookup function used when value is not found.
Args:
value: Value to get enum item.
"""
if not (isinstance(value, int) and 0 <= value <= 255):
raise ValueError('%r is not a valid %s' % (value, cls.__name__))
return cls._unregistered_member(value, 'Unassigned')