def handle_message(received_message, control_plane_sockets, data_plane_sockets):
    """
    Handle a LISP message. The default handle method determines the type
    of message and delegates it to the more specific method
    """
    logger.debug(u"Handling message #{0} ({1}) from {2}".format(received_message.message_nr,
                                                                received_message.message.__class__.__name__,
                                                                received_message.source[0]))

    try:
        if isinstance(received_message.message, MapRequestMessage):
            # A map-request message
            handle_map_request(received_message, control_plane_sockets, data_plane_sockets)

        elif isinstance(received_message.message, MapReplyMessage):
            # A map-reply message
            handle_map_reply(received_message, control_plane_sockets, data_plane_sockets)

        elif isinstance(received_message.message, MapNotifyMessage):
            # A map-notify message (subclass of MapRegisterMessage, so put above it!)
            handle_map_notify(received_message, control_plane_sockets, data_plane_sockets)

        elif isinstance(received_message.message, MapRegisterMessage):
            # A map-register message
            handle_map_register(received_message, control_plane_sockets, data_plane_sockets)

        elif isinstance(received_message.message, MapReferralMessage):
            # A map-referral message
            handle_map_referral(received_message, control_plane_sockets, data_plane_sockets)

        elif isinstance(received_message.message, EncapsulatedControlMessage):
            # Determine the type of ECM
            if isinstance(received_message.inner_message, MapRequestMessage):
                if received_message.message.ddt_originated:
                    # A DDT map-request message
                    handle_ddt_map_request(received_message, control_plane_sockets, data_plane_sockets)
                else:
                    # An encapsulated map-request message
                    handle_enc_map_request(received_message, control_plane_sockets, data_plane_sockets)
            else:
                logger.warning("ECM does not contain a map-request in message %d", received_message.message_nr)
        elif isinstance(received_message.message, InfoMessage):
            handle_info_message(received_message, control_plane_sockets, data_plane_sockets)
        else:
            logger.warning("Unknown content in message %d", received_message.message_nr)
    except:
        logger.exception("Unexpected exception while handling message %d", received_message.message_nr)
def handle_message ( received_message , control_plane_sockets , data_plane_sockets ) : logger . debug ( u"Handling message #{0} ({1}) from {2}" . format ( received_message . message_nr , received_message . message . __class__ . __name__ , received_message . source [ 0 ] ) ) try : if isinstance ( received_message . message , MapRequestMessage ) : handle_map_request ( received_message , control_plane_sockets , data_plane_sockets ) elif isinstance ( received_message . message , MapReplyMessage ) : handle_map_reply ( received_message , control_plane_sockets , data_plane_sockets ) elif isinstance ( received_message . message , MapNotifyMessage ) : handle_map_notify ( received_message , control_plane_sockets , data_plane_sockets ) elif isinstance ( received_message . message , MapRegisterMessage ) : handle_map_register ( received_message , control_plane_sockets , data_plane_sockets ) elif isinstance ( received_message . message , MapReferralMessage ) : handle_map_referral ( received_message , control_plane_sockets , data_plane_sockets ) elif isinstance ( received_message . message , EncapsulatedControlMessage ) : if isinstance ( received_message . inner_message , MapRequestMessage ) : if received_message . message . ddt_originated : handle_ddt_map_request ( received_message , control_plane_sockets , data_plane_sockets ) else : handle_enc_map_request ( received_message , control_plane_sockets , data_plane_sockets ) else : logger . warning ( "ECM does not contain a map-request in message %d" , received_message . message_nr ) elif isinstance ( received_message . message , InfoMessage ) : handle_info_message ( received_message , control_plane_sockets , data_plane_sockets ) else : logger . warning ( "Unknown content in message %d" , received_message . message_nr ) except : logger . exception ( "Unexpected exception while handling message %d" , received_message . message_nr )
Handle a LISP message. The default handle method determines the type
    of message and delegates it to the more specific method