'Extract and return the xid (and length) of an openflow message.'

def _extract_message_xid(self, message):

    xid = 0
    if (len(message) >= 8):
        (message_length, xid) = struct.unpack_from('!HL', message, 2)
    elif (len(message) >= 4):
        message_length = ((ord(message[2]) << 8) | ord(message[3]))
    else:
        message_length = len(message)
    return xid
