Parse the given packet and update properties accordingly

def from_bytes(cls, bitstream):
        '''
        Parse the given packet and update properties accordingly
        '''
        packet = cls()

        # Convert to ConstBitStream (if not already provided)
        if not isinstance(bitstream, ConstBitStream):
            if isinstance(bitstream, Bits):
                bitstream = ConstBitStream(auto=bitstream)
            else:
                bitstream = ConstBitStream(bytes=bitstream)

        # Read the type
        type_nr = bitstream.read('uint:4')
        if type_nr != packet.message_type:
            msg = 'Invalid bitstream for a {0} packet'
            class_name = packet.__class__.__name__
            raise ValueError(msg.format(class_name))

        # Read if this is a reply
        packet.is_reply = bitstream.read('bool')

        # Skip reserved bits
        packet._reserved1 = bitstream.read(27)

        # Read the nonce
        packet.nonce = bitstream.read('bytes:8')

        # Read the key id
        packet.key_id = bitstream.read('uint:16')

        # Read the authentication data
        data_length = bitstream.read('uint:16')
        packet.authentication_data = bitstream.read('bytes:%d' % data_length)

        # Read the TTL
        packet.ttl = bitstream.read('uint:32')

        # Skip reserved bits
        packet._reserved2 = bitstream.read(8)

        # Store the EID prefix mask length until we need it
        eid_prefix_len = bitstream.read('uint:8')

        # Read the EID prefix
        packet.eid_prefix = read_afi_address_from_bitstream(bitstream, eid_prefix_len)

        # Read the reply
        packet.reply = read_afi_address_from_bitstream(bitstream)

        # Verify that the properties make sense
        packet.sanitize()

        return packet