<commit_before>from common.basic_types import UBInt8, UBInt16, UBInt32
from common.base import GenericStruct

class OFPHeader(GenericStruct):
    version = UBInt8()
    ofp_type = UBInt8()
    length = UBInt16()
    xid = UBInt32()


<commit_msg>Added header class and its requirements<commit_after>"""Defines Header classes and related items"""

# System imports
import enum

# Third-party imports

# Local source tree imports
from common import base
from common import basic_types


class OFPType(enum.Enum):
    """
    Message Type
    """
    # Symetric/Immutable messages
    OFPT_HELLO = 0
    OFPT_ERROR = 1
    OFPT_ECHO_REQUEST = 2
    OFPT_ECHO_REPLY = 3
    OFPT_VENDOR = 4

    # Switch configuration messages
    # Controller/Switch messages
    OFPT_FEATURES_REQUEST = 5
    OFPT_FEATURES_REPLY = 6
    OFPT_GET_CONFIG_REQUEST = 7
    OFPT_GET_CONFIG_REPLY = 8
    OFPT_SET_CONFIG = 9

    # Async messages
    OFPT_PACKET_IN = 10
    OFPT_FLOW_REMOVED = 11
    OFPT_PORT_STATUS = 12

    # Controller command messages
    # Controller/switch message
    OFPT_PACKET_OUT = 13
    OFPT_FLOW_MOD = 14
    OFPT_PORT_MOD = 15

    # Statistics messages
    # Controller/Switch message
    OFPT_STATS_REQUEST = 16
    OFPT_STATS_REPLY = 17

    # Barrier messages
    # Controller/Switch message
    OFPT_BARRIER_REQUEST = 18
    OFPT_BARRIER_REPLY = 19

    # Queue Configuration messages
    # Controller/Switch message
    OFPT_QUEUE_GET_CONFIG_REQUEST = 20
    OFPT_QUEUE_GET_CONFIG_REPLY = 21


class OFPHeader(base.GenericStruct):
    """Representation of an OpenFlow message Header

    :param version: version of the Protocol
    :param ofp_type: Type of  the message
    :param length: Length of the message, including the header itself
    :param xid: id of the message
    """
    version = basic_types.UBInt8()
    ofp_type = basic_types.UBInt8()
    length = basic_types.UBInt16()
    xid = basic_types.UBInt32()

    def __init__(self,
                 version=base.OFP_VERSION,
                 ofp_type=OFPType.OFPT_HELLO,
                 length=0,
                 xid=None):
        self.version = version
        self.ofp_type = ofp_type
        self.length = length
        self.xid = xid

{'fraction_non_alphanumeric': 0.06351351351351352, 'fraction_numerical': 0.023423423423423424, 'mean_word_length': 2.8096054888507718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7573127', 'n_tokens_mistral': 768, 'n_tokens_neox': 722, 'n_words': 182}