<commit_before>"""
    This is the OpenFlow 1.0 dictionary/dissector
    Here messages, types and codes are converted to names.
"""


def get_ofp_type(of_type):
    of_types = {0: 'Hello',
                1: 'Error',
                2: 'EchoReq',
                3: 'EchoRes',
                4: 'Vendor',
                5: 'FeatureReq',
                6: 'FeatureRes',
                7: 'GetConfigReq',
                8: 'GetConfigRes',
                9: 'SetConfig',
                10: 'PacketIn',
                11: 'FlowRemoved',
                12: 'PortStatus',
                13: 'PacketOut',
                14: 'FlowMod',
                15: 'PortMod',
                16: 'StatsReq',
                17: 'StatsRes',
                18: 'BarrierReq',
                19: 'BarrierRes',
                20: 'QueueGetConfigReq',
                21: 'QueueGetConfigRes'}
    try:
        return of_types[of_type]
    except KeyError:
        return 'UnknownType(%s)' % of_type


def get_ofp_error(error_type, code):
    errors_types = dict()
    error_codes = dict()

    # Starts with an Error - exception
    errors_types[error_type] = 'UnknownType(%s)' % error_type
    error_codes[code] = 'UnknownCode(%s)' % code

    # Error Types
    if error_type in range(0, 6):
        errors_types = {0: 'HelloFailed(0)',
                        1: 'BadRequest(1)',
                        2: 'BadAction(2)',
                        3: 'FlowMod Failed(3)',
                        4: 'PortMod Failed(4)',
                        5: 'QueueOpFailed(5)'}

    # Error Codes per Error Type
    if error_type == 0:
        if error_codes in range(0, 2):
            error_codes = {0: 'Incompatible(0)',
                           1: 'EPerm(1)'}

    elif error_type == 1:
        if error_codes in range(0, 9):
            error_codes = {0: 'BadVersion(0)',
                           1: 'BadType(1)',
                           2: 'BadStat(2)',
                           3: 'BadVendor(3)',
                           4: 'BadSubtype(4)',
                           5: 'EPerm(5)',
                           6: 'BadLength(6)',
                           7: 'BufferEmpty(7)',
                           8: 'BufferUnknown(8)'}

    elif error_type == 2:
        if error_codes in range(0, 9):
            error_codes = {0: 'BadType',
                           1: 'BadLength',
                           2: 'BadVendor',
                           3: 'BadVendorType',
                           4: 'BadOutPort',
                           5: 'BadArgument',
                           6: 'EPerm',
                           7: 'TooMany',
                           8: 'BadQueue'}

    elif error_type == 3:
        if error_codes == 0 or error_codes in range(2, 7):
            error_codes = {0: 'AllTablesFull(0)',
                           2: 'Overlap(2)',
                           3: 'EPerm(3)',
                           4: 'BadEmergTimeout(4)',
                           5: 'BadCommand(5)',
                           6: 'Unsupported(6)'}

    elif error_type == 4:
        if error_codes in range(0, 2):
            error_codes = {0: 'BadPort(0)',
                           1: 'BadHwAddr(1)'}

    elif error_type == 5:
        if error_codes in range(0, 3):
            error_codes = {0: 'BadPort(0)',
                           1: 'BadQueue(1)',
                           2: 'EPerm(2)'}

    return errors_types[error_type], error_codes[code]

<commit_msg>Errors were not being shown. error_code replaced by code<commit_after>"""
    This is the OpenFlow 1.0 dictionary/dissector
    Here messages, types and codes are converted to names.
"""


def get_ofp_type(of_type):
    of_types = {0: 'Hello',
                1: 'Error',
                2: 'EchoReq',
                3: 'EchoRes',
                4: 'Vendor',
                5: 'FeatureReq',
                6: 'FeatureRes',
                7: 'GetConfigReq',
                8: 'GetConfigRes',
                9: 'SetConfig',
                10: 'PacketIn',
                11: 'FlowRemoved',
                12: 'PortStatus',
                13: 'PacketOut',
                14: 'FlowMod',
                15: 'PortMod',
                16: 'StatsReq',
                17: 'StatsRes',
                18: 'BarrierReq',
                19: 'BarrierRes',
                20: 'QueueGetConfigReq',
                21: 'QueueGetConfigRes'}
    try:
        return of_types[of_type]
    except KeyError:
        return 'UnknownType(%s)' % of_type


def get_ofp_error(error_type, code):
    errors_types = dict()
    error_codes = dict()

    # Starts with an Error - exception
    errors_types[error_type] = 'UnknownType(%s)' % error_type
    error_codes[code] = 'UnknownCode(%s)' % code

    # Error Types
    if error_type in range(0, 6):
        errors_types = {0: 'HelloFailed(0)',
                        1: 'BadRequest(1)',
                        2: 'BadAction(2)',
                        3: 'FlowMod Failed(3)',
                        4: 'PortMod Failed(4)',
                        5: 'QueueOpFailed(5)'}

    # Error Codes per Error Type
    if error_type == 0:
        if code in range(0, 2):
            error_codes = {0: 'Incompatible(0)',
                           1: 'EPerm(1)'}

    elif error_type == 1:
        if code in range(0, 9):
            error_codes = {0: 'BadVersion(0)',
                           1: 'BadType(1)',
                           2: 'BadStat(2)',
                           3: 'BadVendor(3)',
                           4: 'BadSubtype(4)',
                           5: 'EPerm(5)',
                           6: 'BadLength(6)',
                           7: 'BufferEmpty(7)',
                           8: 'BufferUnknown(8)'}

    elif error_type == 2:
        if code in range(0, 9):
            error_codes = {0: 'BadType',
                           1: 'BadLength',
                           2: 'BadVendor',
                           3: 'BadVendorType',
                           4: 'BadOutPort',
                           5: 'BadArgument',
                           6: 'EPerm',
                           7: 'TooMany',
                           8: 'BadQueue'}

    elif error_type == 3:
        if code == 0 or code in range(2, 7):
            error_codes = {0: 'AllTablesFull(0)',
                           2: 'Overlap(2)',
                           3: 'EPerm(3)',
                           4: 'BadEmergTimeout(4)',
                           5: 'BadCommand(5)',
                           6: 'Unsupported(6)'}

    elif error_type == 4:
        if code in range(0, 2):
            error_codes = {0: 'BadPort(0)',
                           1: 'BadHwAddr(1)'}

    elif error_type == 5:
        if code in range(0, 3):
            error_codes = {0: 'BadPort(0)',
                           1: 'BadQueue(1)',
                           2: 'EPerm(2)'}

    return errors_types[error_type], error_codes[code]


{'fraction_non_alphanumeric': 0.12103289094056549, 'fraction_numerical': 0.03519907674552799, 'mean_word_length': 1.1098600121728546, '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': '3553084', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1942, 'n_words': 484}