# -*- coding: utf-8 -*-# pylint: disable=line-too-long,consider-using-f-string"""TCP Checksum==================.. module:: pcapkit.const.tcp.checksumThis module contains the constant enumeration for **TCP Checksum**,which is automatically generated from :class:`pcapkit.vendor.tcp.checksum.Checksum`."""fromaenumimportIntEnum,extend_enum__all__=['Checksum']
[docs]classChecksum(IntEnum):"""[Checksum] TCP Checksum [:rfc:`1146`]"""TCP_checksum=0Checksum_8_bit_Fletcher_s_algorithm=1Checksum_16_bit_Fletcher_s_algorithm=2Redundant_Checksum_Avoidance=3@staticmethoddefget(key:'int | str',default:'int'=-1)->'Checksum':"""Backport support for original codes. Args: key: Key to get enum item. default: Default value if not found. :meta private: """ifisinstance(key,int):returnChecksum(key)ifkeynotinChecksum._member_map_:# pylint: disable=no-memberreturnextend_enum(Checksum,key,default)returnChecksum[key]# type: ignore[misc]
[docs]@classmethoddef_missing_(cls,value:'int')->'Checksum':"""Lookup function used when value is not found. Args: value: Value to get enum item. """ifnot(isinstance(value,int)and0<=value<=255):raiseValueError('%r is not a valid %s'%(value,cls.__name__))returnextend_enum(cls,'Unassigned_%d'%value,value)