/** * Unlink, delete and free a nbr2_list entry. */ static void olsr_del_nbr2_list(struct neighbor_2_list_entry *nbr2_list) { struct neighbor_2_entry *nbr2; nbr2 = nbr2_list->neighbor_2; if (nbr2->neighbor_2_pointer < 1) { DEQUEUE_ELEM(nbr2); free(nbr2); } /* * Kill running timers. */ olsr_stop_timer(nbr2_list->nbr2_list_timer); nbr2_list->nbr2_list_timer = NULL; /* Dequeue */ DEQUEUE_ELEM(nbr2_list); free(nbr2_list); /* Set flags to recalculate the MPR set and the routing table */ changes_neighborhood = true; changes_topology = true; }
int delete_plc_peer_neighbor(const union olsr_ip_addr *peer_addr) { uint32_t hash; struct plc_peer_entry *entry; //olsr_printf(3, "inserting neighbor\n"); hash = olsr_ip_hashing(peer_addr); entry = plc_peer_neighbors[hash].next; /* * Find neighbor entry */ while (entry != &plc_peer_neighbors[hash]) { if (ipequal(&entry->plc_peer_main_addr, peer_addr)) break; entry = entry->next; } if (entry == &plc_peer_neighbors[hash]) return 0; /* Dequeue */ DEQUEUE_ELEM(entry); free(entry); table_size--; return 1; }
static bool olsr_delete_hna_net_entry(struct hna_net *net_to_delete) { #ifdef DEBUG struct ipaddr_str buf1, buf2; #endif /* DEBUG */ struct hna_entry *hna_gw; bool removed_entry = false; #ifdef __linux__ if (is_prefix_inetgw(&net_to_delete->hna_prefix)) { /* modify smart gateway entry if necessary */ olsr_delete_gateway_entry(&net_to_delete->hna_gw->A_gateway_addr, net_to_delete->hna_prefix.prefix_len, false); } #endif /* __linux__ */ olsr_stop_timer(net_to_delete->hna_net_timer); net_to_delete->hna_net_timer = NULL; /* be pedandic */ hna_gw = net_to_delete->hna_gw; #ifdef DEBUG OLSR_PRINTF(5, "HNA: timeout %s via hna-gw %s\n", olsr_ip_prefix_to_string(&net_to_delete->hna_prefix), olsr_ip_to_string(&buf2, &hna_gw->A_gateway_addr)); #endif /* DEBUG */ /* * Delete the rt_path for the entry. */ olsr_delete_routing_table(&net_to_delete->hna_prefix.prefix, net_to_delete->hna_prefix.prefix_len, &hna_gw->A_gateway_addr); DEQUEUE_ELEM(net_to_delete); /* Delete hna_gw if empty */ if (hna_gw->networks.next == &hna_gw->networks) { DEQUEUE_ELEM(hna_gw); olsr_cookie_free(hna_entry_mem_cookie, hna_gw); removed_entry = true; } olsr_cookie_free(hna_net_mem_cookie, net_to_delete); return removed_entry; }
void olsr_update_neighbor_main_addr(struct neighbor_entry *entry, const union olsr_ip_addr *new_main_addr) { /*remove from old pos*/ DEQUEUE_ELEM(entry); /*update main addr*/ entry->neighbor_main_addr = *new_main_addr; /*insert it again*/ QUEUE_ELEM(neighbortable[olsr_ip_hashing(new_main_addr)], entry); }
int olsr_delete_neighbor_table(const union olsr_ip_addr *neighbor_addr) { struct neighbor_2_list_entry *two_hop_list, *two_hop_to_delete; olsr_u32_t hash; struct neighbor_entry *entry; //printf("inserting neighbor\n"); hash = olsr_ip_hashing(neighbor_addr); entry = neighbortable[hash].next; /* * Find neighbor entry */ while(entry != &neighbortable[hash]) { if(ipequal(&entry->neighbor_main_addr, neighbor_addr)) break; entry = entry->next; } if(entry == &neighbortable[hash]) return 0; two_hop_list = entry->neighbor_2_list.next; while (two_hop_list != &entry->neighbor_2_list) { two_hop_to_delete = two_hop_list; two_hop_list = two_hop_list->next; two_hop_to_delete->neighbor_2->neighbor_2_pointer--; olsr_delete_neighbor_pointer(two_hop_to_delete->neighbor_2, &entry->neighbor_main_addr); olsr_del_nbr2_list(two_hop_to_delete); } /* Dequeue */ DEQUEUE_ELEM(entry); free(entry); changes_neighborhood = OLSR_TRUE; return 1; }
/** * Wrapper for the timer callback. */ static void olsr_expire_mpr_sel_entry(void *context) { #ifdef DEBUG struct ipaddr_str buf; #endif /* DEBUG */ struct mpr_selector *mpr_sel; mpr_sel = (struct mpr_selector *)context; mpr_sel->MS_timer = NULL; #ifdef DEBUG OLSR_PRINTF(1, "MPRS: Timing out %st\n", olsr_ip_to_string(&buf, &mpr_sel->MS_main_addr)); #endif /* DEBUG */ DEQUEUE_ELEM(mpr_sel); /* Delete entry */ free(mpr_sel); signal_link_changes(true); }