def handle_map_register(received_message, control_plane_sockets, data_plane_sockets): map_register = received_message.message assert isinstance(map_register, MapRegisterMessage) processed_records = [] saved_key = "" for record in map_register.records: assert isinstance(record, MapRegisterRecord) # Look up the address in the tree instance_id, afi, prefix = determine_instance_id_and_afi(record.eid_prefix) tree_node = resolve(instance_id, afi, prefix) if isinstance(tree_node, MapServerNode): try: tree_node.handle_map_register_record( received_message, record, control_plane_sockets, data_plane_sockets ) # Record processed: store the record, and keep the authentication key in case we want to send back a notify processed_records.append(record) saved_key = tree_node.key except MapServerException, e: logger.error("MapServerNode could not process record {0}: {1}".format(record, e.message)) else: logger.warn( u"Received a Map-Register message for {0}" ", but we are not a MapServer for that EID space".format(prefix) )
def handle_map_notify(received_message, control_plane_sockets, data_plane_sockets): map_notify = received_message.message assert isinstance(map_notify, MapNotifyMessage) for record in map_notify.records: assert isinstance(record, MapRegisterRecord) # Look up the address in the tree instance_id, afi, prefix = determine_instance_id_and_afi(record.eid_prefix) tree_node = resolve(instance_id, afi, prefix) if isinstance(tree_node, ETRNode): tree_node.handle_map_notify_record(received_message, record, control_plane_sockets, data_plane_sockets) else: logger.warn( u"Received a Map-Notify message for {0}" ", but we are not a MapServerClient for that EID space".format(prefix) )
def handle_info_message(received_message, control_plane_sockets, data_plane_sockets): info_message = received_message.message assert isinstance(info_message, InfoMessage) logger.debug("HANDLING {0!r}".format(received_message)) if not received_message.message.is_reply: logger.error(u"We are not an RTR, we can only handle InfoMessage replies") return eid_prefix = info_message.eid_prefix instance_id, afi, eid_prefix = determine_instance_id_and_afi(eid_prefix) node = resolve(instance_id, afi, eid_prefix) if not isinstance(node, ETRNode): # Not for us: drop logger.warn( u"Ignoring message {0}: Info-Message for prefix {1} in instance {2} " "for which we are not an ETR".format(received_message.message_nr, eid_prefix, instance_id) ) return node.handle_info_message_reply(received_message, control_plane_sockets, data_plane_sockets)