/** * This function should be called whenever the current linkcost * value changed in a relevant way. * * @param link pointer to current link * @param newcost new cost of this link */ void olsr_relevant_linkcost_change(void) { changes_neighborhood = true; changes_topology = true; /* XXX - we should check whether we actually announce this neighbour */ signal_link_changes(true); }
int update_neighbor_status(struct neighbor_entry *entry, int lnk) { /* * Update neighbor entry */ if(lnk == SYM_LINK) { /* N_status is set to SYM */ if(entry->status == NOT_SYM) { struct neighbor_2_entry *two_hop_neighbor; /* Delete posible 2 hop entry on this neighbor */ if((two_hop_neighbor = olsr_lookup_two_hop_neighbor_table(&entry->neighbor_main_addr))!=NULL) { olsr_delete_two_hop_neighbor_table(two_hop_neighbor); } changes_neighborhood = OLSR_TRUE; changes_topology = OLSR_TRUE; if(olsr_cnf->tc_redundancy > 1) signal_link_changes(OLSR_TRUE); } entry->status = SYM; } else { if(entry->status == SYM) { changes_neighborhood = OLSR_TRUE; changes_topology = OLSR_TRUE; if(olsr_cnf->tc_redundancy > 1) signal_link_changes(OLSR_TRUE); } /* else N_status is set to NOT_SYM */ entry->status = NOT_SYM; /* remove neighbor from routing list */ } return entry->status; }
int olsr_delete_neighbor_table(const union olsr_ip_addr *neighbor_addr) { struct neighbor_2_list_entry *two_hop_list, *two_hop_to_delete; uint32_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); olsr_del_nbr2_list(two_hop_to_delete); } /* Dequeue */ DEQUEUE_ELEM(entry); free(entry); changes_neighborhood = true; signal_link_changes(true); return 1; }
/** *Update a MPR selector entry or create an new *one if it does not exist * *@param addr the address of the MPR selector *@param vtime tha validity time of the entry * *@return 1 if a new entry was added 0 if not */ int olsr_update_mprs_set(const union olsr_ip_addr *addr, olsr_reltime vtime) { struct ipaddr_str buf; struct mpr_selector *mprs = olsr_lookup_mprs_set(addr); OLSR_PRINTF(5, "MPRS: Update %s\n", olsr_ip_to_string(&buf, addr)); if (mprs == NULL) { olsr_add_mpr_selector(addr, vtime); signal_link_changes(true); return 1; } olsr_set_mpr_sel_timer(mprs, vtime); return 0; }
/** * 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); }
/* * olsr_update_packet_loss_worker * * this function is called every times a hello package for a certain link_entry * is lost (timeout) or received. This way the lq-plugin can update the links link * quality value. * * @param pointer to link_entry * @param OLSR_TRUE if hello package was lost */ void olsr_update_packet_loss_worker(struct link_entry *entry, olsr_bool lost) { olsr_linkcost lq; lq = active_lq_handler->packet_loss_handler(entry, entry->linkquality, lost); if (olsr_is_relevant_costchange(lq, entry->linkcost)) { entry->linkcost = lq; if (olsr_cnf->lq_dlimit > 0) { changes_neighborhood = OLSR_TRUE; changes_topology = OLSR_TRUE; } else OLSR_PRINTF(3, "Skipping Dijkstra (1)\n"); /* XXX - we should check whether we actually announce this neighbour */ signal_link_changes(OLSR_TRUE); } }
/** *This function calculates the mpr neighbors *@return nada */ void olsr_calculate_mpr(void) { uint16_t two_hop_covered_count; uint16_t two_hop_count; int i; OLSR_PRINTF(3, "\n**RECALCULATING MPR**\n\n"); olsr_clear_mprs(); two_hop_count = olsr_calculate_two_hop_neighbors(); two_hop_covered_count = add_will_always_nodes(); // Calculate MPRs based on WILLINGNESS. // NOTE: Nodes with higher WILLINGNESS are chosen to be MPRs first. for (i = WILL_ALWAYS - 1; i > WILL_NEVER; i--) { struct neighbor_entry *mprs; struct neighbor_2_list_entry *two_hop_list = olsr_find_2_hop_neighbors_with_1_link(i); // NOTE: Iterate over two hop neighbor list. For each two hop neighbor get its neighbor list. // Mark next neighbor in list as MPR (initially ensures coverage). Optimize MPRs later. while (two_hop_list != NULL) { struct neighbor_2_list_entry *tmp; //printf("CHOSEN FROM 1 LINK\n"); if (!two_hop_list->neighbor_2->neighbor_2_nblist.next->neighbor->is_mpr) olsr_chosen_mpr(two_hop_list->neighbor_2->neighbor_2_nblist.next->neighbor, &two_hop_covered_count); tmp = two_hop_list; two_hop_list = two_hop_list->next;; free(tmp); } if (two_hop_covered_count >= two_hop_count) { i = WILL_NEVER; break; } //printf("two hop covered count: %d\n", two_hop_covered_count); while ((mprs = olsr_find_maximum_covered(i)) != NULL) { //printf("CHOSEN FROM MAXCOV\n"); olsr_chosen_mpr(mprs, &two_hop_covered_count); if (two_hop_covered_count >= two_hop_count) { i = WILL_NEVER; // NOTE: Break out of main loop. break; } } } /* increment the mpr sequence number */ //neighbortable.neighbor_mpr_seq++; /* Optimize selection */ olsr_optimize_mpr_set(); if (olsr_check_mpr_changes()) { OLSR_PRINTF(3, "CHANGES IN MPR SET\n"); if (olsr_cnf->tc_redundancy > 0) signal_link_changes(true); } }