Check if the current settings conform to the LISP specifications and
        fix them where possible.

def sanitize(self):
        '''
        Check if the current settings conform to the LISP specifications and
        fix them where possible.
        '''
        super(MapNotifyMessage, self).sanitize()

        # The first bit after the Type field in a Map-Notify message is
        # allocated as the "I" bit.  I bit indicates that a 128 bit xTR-ID and
        # 64 bit site-ID field is present at the end of the Map-Notify message,
        # following the final Record in the Map-Notify.
        if not isinstance(self.xtr_id, numbers.Integral) \
        or self.xtr_id < 0 or self.xtr_id >= 2 ** 128:
            raise ValueError('Invalid xTR-ID')

        # site-ID is a 64 bit field at the end of the Map-Register message,
        # following the xTR-ID.
        if not isinstance(self.site_id, numbers.Integral) \
        or self.site_id < 0 or self.site_id >= 2 ** 64:
            raise ValueError('Invalid site-ID')

        # Nonce:  This 8-octet Nonce field is set to 0 in Map-Register
        # messages.  Since the Map-Register message is authenticated, the
        # nonce field is not currently used for any security function but
        # may be in the future as part of an anti-replay solution.
        if len(bytes(self.nonce)) != 8:
            raise ValueError('Invalid nonce')

        # Key ID:  A configured ID to find the configured Message
        # Authentication Code (MAC) algorithm and key value used for the
        # authentication function.  See Section 14.4 for codepoint
        # assignments.
        if self.key_id not in (KEY_ID_NONE, KEY_ID_HMAC_SHA_1_96,
                               KEY_ID_HMAC_SHA_256_128):
            raise ValueError('Invalid Key ID')

        # Authentication Data:  The message digest used from the output of the
        # Message Authentication Code (MAC) algorithm.  The entire Map-
        # Register payload is authenticated with this field preset to 0.
        # After the MAC is computed, it is placed in this field.
        # Implementations of this specification MUST include support for
        # HMAC-SHA-1-96 [RFC2404] and support for HMAC-SHA-256-128 [RFC6234]
        # is RECOMMENDED.
        if not isinstance(self.authentication_data, bytes):
            raise ValueError('Invalid authentication data')

        # Map-Reply Record:  When the M bit is set, this field is the size of a
        # single "Record" in the Map-Reply format.  This Map-Reply record
        # contains the EID-to-RLOC mapping entry associated with the Source
        # EID.  This allows the ETR which will receive this Map-Request to
        # cache the data if it chooses to do so.
        for record in self.records:
            if not isinstance(record, MapRegisterRecord):
                raise ValueError('Invalid record')

            record.sanitize()