# Path: scapy/fields.py
# class BitEnumField(_BitField[Union[List[int], int]], _EnumField[int]):
#     __slots__ = EnumField.__slots__
# 
#     def __init__(self, name, default, size, enum, **kwargs):
#         # type: (str, Optional[int], int, Dict[int, str], **Any) -> None
#         _EnumField.__init__(self, name, default, enum)
#         _BitField.__init__(self, name, default, size, **kwargs)
# 
#     def any2i(self, pkt, x):
#         # type: (Optional[Packet], Any) -> Union[List[int], int]
#         return _EnumField.any2i(self, pkt, x)
# 
#     def i2repr(self,
#                pkt,  # type: Optional[Packet]
#                x,  # type: Union[List[int], int]
#                ):
#         # type: (...) -> Any
#         return _EnumField.i2repr(self, pkt, x)
# 
# class ByteEnumField(EnumField[int]):
#     def __init__(self, name, default, enum):
#         # type: (str, Optional[int], Dict[int, str]) -> None
#         EnumField.__init__(self, name, default, enum, "B")
# 
# class ByteField(Field[int, int]):
#     def __init__(self, name, default):
#         # type: (str, Optional[int]) -> None
#         Field.__init__(self, name, default, "B")
# 
# class ThreeBytesField(Field[int, int]):
#     def __init__(self, name, default):
#         # type: (str, int) -> None
#         Field.__init__(self, name, default, "!I")
# 
#     def addfield(self, pkt, s, val):
#         # type: (Packet, bytes, Optional[int]) -> bytes
#         return s + struct.pack(self.fmt, self.i2m(pkt, val))[1:4]
# 
#     def getfield(self, pkt, s):
#         # type: (Packet, bytes) -> Tuple[bytes, int]
#         return s[3:], self.m2i(pkt, struct.unpack(self.fmt, b"\x00" + s[:3])[0])  # noqa: E501
# 
# class BitField(_BitField[int]):
#     __doc__ = _BitField.__doc__
# 
# class LEShortField(Field[int, int]):
#     def __init__(self, name, default):
#         # type: (str, Optional[int]) -> None
#         Field.__init__(self, name, default, "<H")
# 
# class LESignedIntField(Field[int, int]):
#     def __init__(self, name, default):
#         # type: (str, int) -> None
#         Field.__init__(self, name, default, "<i")


from scapy.contrib.scada.iec104.iec104_fields import \
    IEC60870_5_4_NormalizedFixPoint, IEC104SignedSevenBitValue, \
    LESignedShortField, LEIEEEFloatField
from scapy.fields import BitEnumField, ByteEnumField, ByteField, \
    ThreeBytesField, \
    BitField, LEShortField, LESignedIntField
    }

    informantion_element_fields = [
        BitEnumField('iv', 0, 1, IEC104_IE_CommonQualityFlags.IV_FLAGS),
        # invalid
        BitEnumField('nt', 0, 1, IEC104_IE_CommonQualityFlags.NT_FLAGS),
        # live or cached old value
        BitEnumField('sb', 0, 1, IEC104_IE_CommonQualityFlags.SB_FLAGS),
        # value substituted
        BitEnumField('bl', 0, 1, IEC104_IE_CommonQualityFlags.BL_FLAGS),
        # blocked
        BitField('reserved', 0, 3),
        BitEnumField('ov', 0, 1, OV_FLAGS),  # overflow
    ]


class IEC104_IE_QDP(IEC104_IE_CommonQualityFlags):
    """
    QDP - quality descriptor protection equipment separate object

    EN 60870-5-101:2003, sec. 7.2.6.4 (p. 46)
    """

    informantion_element_fields = [
        BitEnumField('iv', 0, 1, IEC104_IE_CommonQualityFlags.IV_FLAGS),
        # invalid
        BitEnumField('nt', 0, 1, IEC104_IE_CommonQualityFlags.NT_FLAGS),
        # live or cached old value
        BitEnumField('sb', 0, 1, IEC104_IE_CommonQualityFlags.SB_FLAGS),
        # value substituted

# Path: scapy/fields.py
# class BitEnumField(_BitField[Union[List[int], int]], _EnumField[int]):
#     __slots__ = EnumField.__slots__
# 
#     def __init__(self, name, default, size, enum, **kwargs):
#         # type: (str, Optional[int], int, Dict[int, str], **Any) -> None
#         _EnumField.__init__(self, name, default, enum)
#         _BitField.__init__(self, name, default, size, **kwargs)
# 
#     def any2i(self, pkt, x):
#         # type: (Optional[Packet], Any) -> Union[List[int], int]
#         return _EnumField.any2i(self, pkt, x)
# 
#     def i2repr(self,
#                pkt,  # type: Optional[Packet]
#                x,  # type: Union[List[int], int]
#                ):
#         # type: (...) -> Any
#         return _EnumField.i2repr(self, pkt, x)
# 
# class ByteEnumField(EnumField[int]):
#     def __init__(self, name, default, enum):
#         # type: (str, Optional[int], Dict[int, str]) -> None
#         EnumField.__init__(self, name, default, enum, "B")
# 
# class ByteField(Field[int, int]):
#     def __init__(self, name, default):
#         # type: (str, Optional[int]) -> None
#         Field.__init__(self, name, default, "B")
# 
# class ThreeBytesField(Field[int, int]):
#     def __init__(self, name, default):
#         # type: (str, int) -> None
#         Field.__init__(self, name, default, "!I")
# 
#     def addfield(self, pkt, s, val):
#         # type: (Packet, bytes, Optional[int]) -> bytes
#         return s + struct.pack(self.fmt, self.i2m(pkt, val))[1:4]
# 
#     def getfield(self, pkt, s):
#         # type: (Packet, bytes) -> Tuple[bytes, int]
#         return s[3:], self.m2i(pkt, struct.unpack(self.fmt, b"\x00" + s[:3])[0])  # noqa: E501
# 
# class BitField(_BitField[int]):
#     __doc__ = _BitField.__doc__
# 
# class LEShortField(Field[int, int]):
#     def __init__(self, name, default):
#         # type: (str, Optional[int]) -> None
#         Field.__init__(self, name, default, "<H")
# 
# class LESignedIntField(Field[int, int]):
#     def __init__(self, name, default):
#         # type: (str, int) -> None
#         Field.__init__(self, name, default, "<i")


# Path: scapy/contrib/scada/iec104/iec104_information_elements.py
from scapy.contrib.scada.iec104.iec104_fields import \
    IEC60870_5_4_NormalizedFixPoint, IEC104SignedSevenBitValue, \
    LESignedShortField, LEIEEEFloatField
from scapy.fields import BitEnumField, ByteEnumField, ByteField, \
    ThreeBytesField, \
    BitField, LEShortField, LESignedIntField

    }

    informantion_element_fields = [
        BitEnumField('iv', 0, 1, IEC104_IE_CommonQualityFlags.IV_FLAGS),
        # invalid
        BitEnumField('nt', 0, 1, IEC104_IE_CommonQualityFlags.NT_FLAGS),
        # live or cached old value
        BitEnumField('sb', 0, 1, IEC104_IE_CommonQualityFlags.SB_FLAGS),
        # value substituted
        BitEnumField('bl', 0, 1, IEC104_IE_CommonQualityFlags.BL_FLAGS),
        # blocked
        BitField('reserved', 0, 3),
        BitEnumField('ov', 0, 1, OV_FLAGS),  # overflow
    ]


class IEC104_IE_QDP(IEC104_IE_CommonQualityFlags):
    """
    QDP - quality descriptor protection equipment separate object

    EN 60870-5-101:2003, sec. 7.2.6.4 (p. 46)
    """

    informantion_element_fields = [
        BitEnumField('iv', 0, 1, IEC104_IE_CommonQualityFlags.IV_FLAGS),
        # invalid
        BitEnumField('nt', 0, 1, IEC104_IE_CommonQualityFlags.NT_FLAGS),
        # live or cached old value
        BitEnumField('sb', 0, 1, IEC104_IE_CommonQualityFlags.SB_FLAGS),
        # value substituted

        BitEnumField('bl', 0, 1, IEC104_IE_CommonQualityFlags.BL_FLAGS),