daemon/core/broker.py
def handlemsg(self, msg):
        ''' Handle an API message. Determine whether this needs to be handled
            by the local server or forwarded on to another one. 
            Returns True when message does not need to be handled locally,
            and performs forwarding if required.
            Returning False indicates this message should be handled locally.
        '''
        serverlist = []
        handle_locally = False
        # Do not forward messages when in definition state 
        # (for e.g. configuring services)
        if self.session.getstate() == coreapi.CORE_EVENT_DEFINITION_STATE:
            handle_locally = True
            return not handle_locally
        # Decide whether message should be handled locally or forwarded, or both
        if msg.msgtype == coreapi.CORE_API_NODE_MSG:
            (handle_locally, serverlist) = self.handlenodemsg(msg)
        elif msg.msgtype == coreapi.CORE_API_EVENT_MSG:
            # broadcast events everywhere
            serverlist = self.getserverlist()
        elif msg.msgtype == coreapi.CORE_API_CONF_MSG:
            # broadcast location and services configuration everywhere
            confobj = msg.gettlv(coreapi.CORE_TLV_CONF_OBJ)
            if confobj == "location" or confobj == "services" or \
               confobj == "session" or confobj == "all":
                serverlist = self.getserverlist()
        elif msg.msgtype == coreapi.CORE_API_FILE_MSG:
            # broadcast hook scripts and custom service files everywhere
            filetype = msg.gettlv(coreapi.CORE_TLV_FILE_TYPE)
            if filetype is not None and \
                (filetype[:5] == "hook:" or filetype[:8] == "service:"):
                serverlist = self.getserverlist()

        if msg.msgtype == coreapi.CORE_API_LINK_MSG:
            # prepare a serverlist from two node numbers in link message
            (handle_locally, serverlist, msg) = self.handlelinkmsg(msg)
        elif len(serverlist) == 0:
            # check for servers based on node numbers in all messages but link
            nn = msg.nodenumbers()
            if len(nn) == 0:
                return False
            serverlist = self.getserversbynode(nn[0])

        if len(serverlist) == 0: 
            handle_locally = True

        # allow other handlers to process this message
        # (this is used by e.g. EMANE to use the link add message to keep counts
        # of interfaces on other servers)
        for handler in self.handlers:
            handler(msg)

        # Perform any message forwarding
        handle_locally = self.forwardmsg(msg, serverlist, handle_locally)
        return not handle_locally
 Handle an API message. Determine whether this needs to be handled
            by the local server or forwarded on to another one. 
            Returns True when message does not need to be handled locally,
            and performs forwarding if required.
            Returning False indicates this message should be handled locally.
        
Handle an API message. Determine whether this needs to be handled
by the local server or forwarded on to another one.
Returns True when message does not need to be handled locally,
and performs forwarding if required.
Returning False indicates this message should be handled locally.
Handle an API message . Determine whether this needs to be handled by the local server or forwarded on to another one . Returns True when message does not need to be handled locally and performs forwarding if required . Returning False indicates this message should be handled locally .
def handlemsg(self, msg):
        serverlist = []
        handle_locally = False
        if self.session.getstate() == coreapi.CORE_EVENT_DEFINITION_STATE:
            handle_locally = True
            return not handle_locally
        if msg.msgtype == coreapi.CORE_API_NODE_MSG:
            (handle_locally, serverlist) = self.handlenodemsg(msg)
        elif msg.msgtype == coreapi.CORE_API_EVENT_MSG:
            serverlist = self.getserverlist()
        elif msg.msgtype == coreapi.CORE_API_CONF_MSG:
            confobj = msg.gettlv(coreapi.CORE_TLV_CONF_OBJ)
            if confobj == "location" or confobj == "services" or \
               confobj == "session" or confobj == "all":
                serverlist = self.getserverlist()
        elif msg.msgtype == coreapi.CORE_API_FILE_MSG:
            filetype = msg.gettlv(coreapi.CORE_TLV_FILE_TYPE)
            if filetype is not None and \
                (filetype[:5] == "hook:" or filetype[:8] == "service:"):
                serverlist = self.getserverlist()
        if msg.msgtype == coreapi.CORE_API_LINK_MSG:
            (handle_locally, serverlist, msg) = self.handlelinkmsg(msg)
        elif len(serverlist) == 0:
            nn = msg.nodenumbers()
            if len(nn) == 0:
                return False
            serverlist = self.getserversbynode(nn[0])
        if len(serverlist) == 0: 
            handle_locally = True
        for handler in self.handlers:
            handler(msg)
        handle_locally = self.forwardmsg(msg, serverlist, handle_locally)
        return not handle_locally
def handlemsg ( self , msg ) : serverlist = [ ] handle_locally = False if self . session . getstate ( ) == coreapi . CORE_EVENT_DEFINITION_STATE : handle_locally = True return not handle_locally if msg . msgtype == coreapi . CORE_API_NODE_MSG : ( handle_locally , serverlist ) = self . handlenodemsg ( msg ) elif msg . msgtype == coreapi . CORE_API_EVENT_MSG : serverlist = self . getserverlist ( ) elif msg . msgtype == coreapi . CORE_API_CONF_MSG : confobj = msg . gettlv ( coreapi . CORE_TLV_CONF_OBJ ) if confobj == "location" or confobj == "services" or confobj == "session" or confobj == "all" : serverlist = self . getserverlist ( ) elif msg . msgtype == coreapi . CORE_API_FILE_MSG : filetype = msg . gettlv ( coreapi . CORE_TLV_FILE_TYPE ) if filetype is not None and ( filetype [ : 5 ] == "hook:" or filetype [ : 8 ] == "service:" ) : serverlist = self . getserverlist ( ) if msg . msgtype == coreapi . CORE_API_LINK_MSG : ( handle_locally , serverlist , msg ) = self . handlelinkmsg ( msg ) elif len ( serverlist ) == 0 : nn = msg . nodenumbers ( ) if len ( nn ) == 0 : return False serverlist = self . getserversbynode ( nn [ 0 ] ) if len ( serverlist ) == 0 : handle_locally = True for handler in self . handlers : handler ( msg ) handle_locally = self . forwardmsg ( msg , serverlist , handle_locally ) return not handle_locally
Handle an API message.
Handle an API message .
''' Handle an API message. Determine whether this needs to be handled
            by the local server or forwarded on to another one. 
            Returns True when message does not need to be handled locally,
            and performs forwarding if required.
            Returning False indicates this message should be handled locally.
        ''' # Do not forward messages when in definition state  # (for e.g. configuring services) # Decide whether message should be handled locally or forwarded, or both # broadcast events everywhere # broadcast location and services configuration everywhere # broadcast hook scripts and custom service files everywhere # prepare a serverlist from two node numbers in link message # check for servers based on node numbers in all messages but link # allow other handlers to process this message # (this is used by e.g. EMANE to use the link add message to keep counts # of interfaces on other servers) # Perform any message forwarding
self
msg