import struct


def verify_response_header(response, tcode, tl=16):
    """Verifies response header, and returns remainder of response"""
    # First we unpack the the header data, and verify there were no errors and
    # the TL code is correct.
    r_tl, r_tcode, r_rcode = struct.unpack('>2x2B2xBx', response[:8])
    if(r_tl >> 2 != tl) or (r_tcode >> 4 != tcode) or (r_rcode != 0):
        raise IOError
    else:
        return response[8:]