Source code for pcapkit.const.ipv4.option_number

# -*- coding: utf-8 -*-
# pylint: disable=line-too-long,consider-using-f-string
"""IP Option Numbers
=======================

.. module:: pcapkit.const.ipv4.option_number

This module contains the constant enumeration for **IP Option Numbers**,
which is automatically generated from :class:`pcapkit.vendor.ipv4.option_number.OptionNumber`.

"""

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__ = ['OptionNumber']


[docs] class OptionNumber(EnumRegistry, IntEnum): """[OptionNumber] IP Option Numbers""" #: ``EOOL``, End of Options List [:rfc:`791`][Jon Postel] EOOL = 0 #: ``NOP``, No Operation [:rfc:`791`][Jon Postel] NOP = 1 #: ``SEC``, Security [:rfc:`1108`] SEC = 130 #: ``LSR``, Loose Source Route [:rfc:`791`][Jon Postel] LSR = 131 #: ``TS``, Time Stamp [:rfc:`791`][Jon Postel] TS = 68 #: ``E-SEC``, Extended Security [:rfc:`1108`] E_SEC = 133 #: ``CIPSO``, Commercial Security [draft-ietf-cipso-ipsecurity-01] CIPSO = 134 #: ``RR``, Record Route [:rfc:`791`][Jon Postel] RR = 7 #: ``SID``, Stream ID [:rfc:`791`][Jon Postel][:rfc:`6814`] SID = 136 #: ``SSR``, Strict Source Route [:rfc:`791`][Jon Postel] SSR = 137 #: ``ZSU``, Experimental Measurement [ZSu] ZSU = 10 #: ``MTUP``, MTU Probe [:rfc:`1063`][:rfc:`1191`] MTUP = 11 #: ``MTUR``, MTU Reply [:rfc:`1063`][:rfc:`1191`] MTUR = 12 #: ``FINN``, Experimental Flow Control [Greg Finn] FINN = 205 #: ``VISA``, Experimental Access Control [Deborah Estrin][:rfc:`6814`] VISA = 142 #: ``ENCODE``, ??? [VerSteeg][:rfc:`6814`] ENCODE = 15 #: ``IMITD``, IMI Traffic Descriptor [Lee] IMITD = 144 #: ``EIP``, Extended Internet Protocol [:rfc:`1385`][:rfc:`6814`] EIP = 145 #: ``TR``, Traceroute [:rfc:`1393`][:rfc:`6814`] TR = 82 #: ``ADDEXT``, Address Extension [Ullmann IPv7][:rfc:`6814`] ADDEXT = 147 #: ``RTRALT``, Router Alert [:rfc:`2113`] RTRALT = 148 #: ``SDB``, Selective Directed Broadcast [Charles Bud Graff][:rfc:`6814`] SDB = 149 #: Unassigned (Released 18 October 2005) Unassigned_150 = 150 #: ``DPS``, Dynamic Packet State [Andy Malis][:rfc:`6814`] DPS = 151 #: ``UMP``, Upstream Multicast Pkt. [Dino Farinacci][:rfc:`6814`] UMP = 152 #: ``QS``, Quick-Start [:rfc:`4782`] QS = 25 #: ``EXP``, RFC3692-style Experiment [:rfc:`4727`] EXP_30 = 30 #: ``EXP``, RFC3692-style Experiment [:rfc:`4727`] EXP_94 = 94 #: ``EXP``, RFC3692-style Experiment [:rfc:`4727`] EXP_158 = 158 #: ``EXP``, RFC3692-style Experiment [:rfc:`4727`] EXP_222 = 222
[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') -> 'OptionNumber': """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')