(pkt)
return (columns, response)
Parse a Response packet.  Given a raw query response
       packet, this will parse out the columns and text.
       Returned is a tuple of (columns, data)
Parse a Response packet.  Given a raw query response
       packet, this will parse out the columns and text.
       Returned is a tuple of (columns, data)
Parse a Response packet . Given a raw query response packet this will parse out the columns and text . Returned is a tuple of ( columns data )
def get_response(pkt):
    """Parse a Response packet.  Given a raw query response
       packet, this will parse out the columns and text.
       Returned is a tuple of (columns, data)
    """
    header = True
    num = num_fields(pkt)

    # not all mysql responses have headers...
    if verify_header(pkt):
        pkt = pkt[5:]
    else:
        header = False

    columns = []
    response = []

    # check if packet is an error packet
    if is_error(pkt):
        return (None, None)

    # parse columns
    tmp = 0
    while True:
        try:
            column = get_layer(tmp, pkt)
            if column is None or is_eof_layer(column):
                break
            struct = parse_layer(column)
            columns.append(struct)
            tmp += 1
        except Exception, e:
            util.debug('Error parsing mysql: %s' % e)
            return (None, None)

    # parse returned data
    if header and is_eof_layer(get_layer(num, pkt)):
        layers = 1
        while True:
            try:
                layer = get_layer(num + layers, pkt)
                if is_eof_layer(layer):
                    break
                response.append(parse_response_data(layer, num))
                layers += 1
            except Exception, e:
                util.debug('Error parsing mysql: %s' % e)
                break
    return (columns, response)
def get_response ( pkt ) : header = True num = num_fields ( pkt ) # not all mysql responses have headers... if verify_header ( pkt ) : pkt = pkt [ 5 : ] else : header = False columns = [ ] response = [ ] # check if packet is an error packet if is_error ( pkt ) : return ( None , None ) # parse columns tmp = 0 while True : try : column = get_layer ( tmp , pkt ) if column is None or is_eof_layer ( column ) : break struct = parse_layer ( column ) columns . append ( struct ) tmp += 1 except Exception , e : util . debug ( 'Error parsing mysql: %s' % e ) return ( None , None ) # parse returned data if header and is_eof_layer ( get_layer ( num , pkt ) ) : layers = 1 while True : try : layer = get_layer ( num + layers , pkt ) if is_eof_layer ( layer ) : break response . append ( parse_response_data ( layer , num ) ) layers += 1 except Exception , e : util . debug ( 'Error parsing mysql: %s' % e ) break return ( columns , response )