(layer)
return struct
Returns a ResponseStruct of the request layer.
Returns a ResponseStruct of the request layer.
Returns a ResponseStruct of the request layer .
def parse_layer(layer):
    """Returns a ResponseStruct of the request layer.
    """
    struct = ResponseStruct()
    # packet length
    struct.pkt_length = endian_int(layer[0:3])
    layer = layer[3:]
    # packet number
    struct.num = int(layer[0], 16)
    layer = layer[1:]
    # catalog
    ltmp = int(layer[0], 16)
    struct.catalog = ''.join(layer[1:ltmp + 1]).decode('hex')
    layer = layer[ltmp + 1:]
    # database
    ltmp = int(layer[0], 16)
    if ltmp > 0:
        struct.database = ''.join(layer[1:ltmp + 1]).decode('hex')
        layer = layer[ltmp + 1:]
    else:
        layer = layer[1:]
    # table
    ltmp = int(layer[0], 16)
    if ltmp > 0:
        struct.table = ''.join(layer[1:ltmp + 1]).decode('hex')
        layer = layer[ltmp + 1:]
    else:
        layer = layer[1:]
    # original table
    ltmp = int(layer[0], 16)
    if ltmp > 0:
        struct.orig_table = ''.join(layer[1:ltmp + 1]).decode('hex')
        layer = layer[ltmp + 1:]
    else:
        layer = layer[1:]
    # name
    ltmp = int(layer[0], 16)
    if ltmp > 0:
        struct.name = ''.join(layer[1:ltmp + 1]).decode('hex')
        layer = layer[ltmp + 1:]
    else:
        layer = layer[1:]
    # original name
    ltmp = int(layer[0], 16)
    if ltmp > 0:
        struct.orig_name = ''.join(layer[1:ltmp + 1]).decode('hex')
        layer = layer[ltmp + 1:]
    else:
        layer = layer[1:]
    # charset number
    struct.char_num = endian_int(layer[1:3])
    layer = layer[3:]
    # length
    struct.length = endian_int(layer[0:4])
    layer = layer[4:]
    # type
    struct.type = int(layer[0], 16)
    layer = layer[1:]
    # flags
    struct.flags = layer[0:2]
    layer = layer[2:]
    # decimals
    struct.decimals = int(layer[0], 16)
    return struct
def parse_layer ( layer ) : struct = ResponseStruct ( ) # packet length struct . pkt_length = endian_int ( layer [ 0 : 3 ] ) layer = layer [ 3 : ] # packet number struct . num = int ( layer [ 0 ] , 16 ) layer = layer [ 1 : ] # catalog ltmp = int ( layer [ 0 ] , 16 ) struct . catalog = '' . join ( layer [ 1 : ltmp + 1 ] ) . decode ( 'hex' ) layer = layer [ ltmp + 1 : ] # database ltmp = int ( layer [ 0 ] , 16 ) if ltmp > 0 : struct . database = '' . join ( layer [ 1 : ltmp + 1 ] ) . decode ( 'hex' ) layer = layer [ ltmp + 1 : ] else : layer = layer [ 1 : ] # table ltmp = int ( layer [ 0 ] , 16 ) if ltmp > 0 : struct . table = '' . join ( layer [ 1 : ltmp + 1 ] ) . decode ( 'hex' ) layer = layer [ ltmp + 1 : ] else : layer = layer [ 1 : ] # original table ltmp = int ( layer [ 0 ] , 16 ) if ltmp > 0 : struct . orig_table = '' . join ( layer [ 1 : ltmp + 1 ] ) . decode ( 'hex' ) layer = layer [ ltmp + 1 : ] else : layer = layer [ 1 : ] # name ltmp = int ( layer [ 0 ] , 16 ) if ltmp > 0 : struct . name = '' . join ( layer [ 1 : ltmp + 1 ] ) . decode ( 'hex' ) layer = layer [ ltmp + 1 : ] else : layer = layer [ 1 : ] # original name ltmp = int ( layer [ 0 ] , 16 ) if ltmp > 0 : struct . orig_name = '' . join ( layer [ 1 : ltmp + 1 ] ) . decode ( 'hex' ) layer = layer [ ltmp + 1 : ] else : layer = layer [ 1 : ] # charset number struct . char_num = endian_int ( layer [ 1 : 3 ] ) layer = layer [ 3 : ] # length struct . length = endian_int ( layer [ 0 : 4 ] ) layer = layer [ 4 : ] # type struct . type = int ( layer [ 0 ] , 16 ) layer = layer [ 1 : ] # flags struct . flags = layer [ 0 : 2 ] layer = layer [ 2 : ] # decimals struct . decimals = int ( layer [ 0 ] , 16 ) return struct