/** * The main ip address has changed. * Do the needful. */ void olsr_change_myself_tc(void) { struct nbr_entry *entry, *iterator; bool main_ip_change = false; if (tc_myself) { /* * Check if there was a change. */ if (olsr_ipcmp(&tc_myself->addr, &olsr_cnf->router_id) == 0) { return; } /* flush local edges */ OLSR_FOR_ALL_NBR_ENTRIES(entry, iterator) { if (entry->tc_edge) { /* clean up local edges if necessary */ entry->tc_edge->neighbor = NULL; olsr_delete_tc_edge_entry(entry->tc_edge); entry->tc_edge = NULL; } } /* * Flush our own tc_entry. */ olsr_delete_tc_entry(tc_myself); /* * Clear the reference. */ tc_myself = NULL; main_ip_change = true; } /* * The old entry for ourselves is gone, generate a new one and trigger SPF. */ tc_myself = olsr_add_tc_entry(&olsr_cnf->router_id); if (main_ip_change) { OLSR_FOR_ALL_NBR_ENTRIES(entry, iterator) { /** * check if a main ip change destroyed our TC entries */ if (entry->tc_edge == NULL) { entry->tc_edge = olsr_add_tc_edge_entry(tc_myself, &entry->nbr_addr, 0); entry->tc_edge->neighbor = entry; } } } changes_topology = true; }
/** * Attempts to delete a tc entry. This will work unless there are virtual edges left * that cannot be removed * * @param entry the TC entry to delete * */ void olsr_delete_tc_entry(struct tc_entry *tc) { struct tc_edge_entry *tc_edge, *edge_iterator; struct rt_path *rtp, *rtp_iterator; #if !defined REMOVE_LOG_DEBUG struct ipaddr_str buf; #endif OLSR_DEBUG(LOG_TC, "TC: del entry %s\n", olsr_ip_to_string(&buf, &tc->addr)); /* The delete all non-virtual edges */ OLSR_FOR_ALL_TC_EDGE_ENTRIES(tc, tc_edge, edge_iterator) { olsr_delete_tc_edge_entry(tc_edge); }
/** * Delete a TC entry. * * @param tc the TC entry to delete */ void olsr_delete_tc_entry(struct tc_entry *tc) { struct tc_edge_entry *tc_edge; struct rt_path *rtp; /* delete gateway if available */ #ifdef __linux__ olsr_delete_gateway_entry(&tc->addr, FORCE_DELETE_GW_ENTRY, false); #endif /* __linux__ */ /* * Delete the rt_path for ourselves. */ olsr_delete_routing_table(&tc->addr, olsr_cnf->maxplen, &tc->addr); /* The edgetree and prefix tree must be empty before */ OLSR_FOR_ALL_TC_EDGE_ENTRIES(tc, tc_edge) { olsr_delete_tc_edge_entry(tc_edge); } OLSR_FOR_ALL_TC_EDGE_ENTRIES_END(tc, tc_edge);
/** * Delete a TC entry. * * @param entry the TC entry to delete * */ void olsr_delete_tc_entry(struct tc_entry *tc) { struct tc_edge_entry *tc_edge; struct rt_path *rtp; #if 0 struct ipaddr_str buf; OLSR_PRINTF(1, "TC: del entry %s\n", olsr_ip_to_string(&buf, &tc->addr)); #endif /* delete gateway if available */ #ifdef linux olsr_delete_gateway_entry(&tc->addr, FORCE_DELETE_GW_ENTRY); #endif /* * Delete the rt_path for ourselves. */ olsr_delete_routing_table(&tc->addr, olsr_cnf->maxplen, &tc->addr); /* The edgetree and prefix tree must be empty before */ OLSR_FOR_ALL_TC_EDGE_ENTRIES(tc, tc_edge) { olsr_delete_tc_edge_entry(tc_edge); } OLSR_FOR_ALL_TC_EDGE_ENTRIES_END(tc, tc_edge);