コード例 #1
0
ファイル: etr_node.py プロジェクト: SeleneLI/LIG_measurement
class InfoRequest(object):
    def __init__(self, eid_prefix, etrr, control_plane_sockets):
        # Store input
        self.eid_prefix = eid_prefix
        self.etrr = etrr
        self.control_plane_sockets = control_plane_sockets

        # Create the InfoRequest
        self.info_request = InfoMessage(nonce=os.urandom(8),
                                        key_id=self.etrr.key_id,
                                        ttl=1440,
                                        eid_prefix=self.eid_prefix)
        self.info_request.insert_authentication_data(self.etrr.key)

        # Remember source and destination of the outgoing request
        self.sent_from = None
        self.sent_to = None

        # Here the reply will be stored
        self.info_reply = None

        # This event will be triggered when the reply is received
        self.reply_received = threading.Event()

    def send(self):
        self.sent_from, self.sent_to = send_message(message=self.info_request,
                                                    my_sockets=self.control_plane_sockets,
                                                    destinations=[self.etrr.map_server],
                                                    port=4342)

    def set_reply_if_matches(self, source, info_message):
        if source != self.etrr.map_server \
        or info_message.nonce != self.info_request.nonce:
            # Not for us
            return False

        logger.debug(u"Received a reply to InfoRequest from {0}".format(source))
        self.info_reply = info_message
        self.info_reply.reply.private_etr_rloc = self.sent_from[0]
        self.reply_received.set()
        return True
コード例 #2
0
ファイル: etr_node.py プロジェクト: SeleneLI/LIG_measurement
    def __init__(self, eid_prefix, etrr, control_plane_sockets):
        # Store input
        self.eid_prefix = eid_prefix
        self.etrr = etrr
        self.control_plane_sockets = control_plane_sockets

        # Create the InfoRequest
        self.info_request = InfoMessage(nonce=os.urandom(8),
                                        key_id=self.etrr.key_id,
                                        ttl=1440,
                                        eid_prefix=self.eid_prefix)
        self.info_request.insert_authentication_data(self.etrr.key)

        # Remember source and destination of the outgoing request
        self.sent_from = None
        self.sent_to = None

        # Here the reply will be stored
        self.info_reply = None

        # This event will be triggered when the reply is received
        self.reply_received = threading.Event()