import struct


def control_header_type(pkt):
    """Return the control header type of a capwap packet."""
    try:
        capwap_bytes = pkt[42:]
        capwap_hlen = (struct.unpack('!B', capwap_bytes[1:2])[
            0] & 0b11111000) >> 1
        ctrl_header_type = struct.unpack(
            '!B', capwap_bytes[capwap_hlen + 3:capwap_hlen + 4])[0]
        return ctrl_header_type
    except:
        return None