olsr_bool sort_mpr_set_handler(void* olsr, void* arg_a, void* arg_b) { OLSR_MPR_TUPLE* data = NULL, *insert = NULL; data = (OLSR_MPR_TUPLE* )arg_a; insert = (OLSR_MPR_TUPLE* )arg_b; if (cmp_ip_addr((struct olsrv2* )olsr, &data->MPR_if_addr, &insert->MPR_if_addr) > 0) { return OLSR_TRUE; } return OLSR_FALSE; }
static olsr_bool process_hello(struct olsrv2 *olsr, struct hello_message *hello, union olsr_ip_addr *in_if, union olsr_ip_addr *from_addr) { struct hello_neighbor *hello_neigh = NULL; OLSR_LIST* retList = NULL; OLSR_LIST_ENTRY *entry = NULL; OLSR_LOCAL_INTERFACE_BLOCK_ENTRY *local_entry = NULL; OLSR_SYMMETRIC_NEIGHBOR_TUPLE *sym_data = NULL; olsr_time_t time; olsr_bool change_assn = OLSR_FALSE, selected_mpr = OLSR_FALSE; //codexxx // before processing hello message add the queue length of the corresponding originator to the OLSR_LIST "queue_set" olsr_bool IPfound = OLSR_FALSE; struct queue_info *queueInf = NULL, *tempo= NULL ; OLSR_LIST_ENTRY *queueEntry = NULL; queueInf = (queue_info *)olsr_malloc(sizeof(queue_info), __FUNCTION__); queueInf->orig_IP = hello->orig_addr ; queueInf->Qlength = hello->queuelength; if(olsr->queue_set.numEntry == 0) { // insert to the list directly OLSR_InsertList(&olsr->queue_set,queueInf,sizeof(queue_info)); }else{ // liste deja contient des element ...donc trouver si deja existe queueEntry = olsr->queue_set.head ; while(queueEntry != NULL) ///// { tempo = (queue_info *)queueEntry->data ; if(!cmp_ip_addr(olsr,&tempo->orig_IP,&queueInf->orig_IP)) //// { // on a trouver cet originator IP ds la liste alors update le queue et sortir de la boucle tempo->Qlength = queueInf->Qlength; IPfound = OLSR_TRUE; break; } queueEntry = queueEntry->next ; } if(IPfound == OLSR_FALSE) { // cet IP n'existe pas deja dans la liste => l'introduire OLSR_InsertList(&olsr->queue_set,queueInf,sizeof(queue_info)); } } //end codexxx if (own_ip_addr(olsr, &hello->source_addr)) { // wiss: ma3neta el source address byetaba2 ma3 wa7ed men el intrface address taba3 node if(DEBUG_OLSRV2){ char* paddr = olsr_niigata_ip_to_string(olsr, &olsr->main_addr); olsr_printf("Received Hello, but this Hello is sent from ME!!\n[%s]",paddr); free(paddr); } return OLSR_FALSE; // wiss: betla3 men process_hello } if(search_link_set_local_for_exist(olsr, in_if, &hello->source_addr) == OLSR_FALSE){ // wiss:ma la2a bel olsr linkset entry 3enda local_if= "in_if" w neigbor_if=&hello->source_addr // wiss: ma la2a jar 3endou ip hello->source_addr ma3neta el link da3 proc_link_set(olsr, in_if, &hello->source_addr, LOST, hello->willingness, hello->vtime, hello->htime); } // neighbor address hello_neigh = hello->neighbors; while (hello_neigh){ if(equal_ip_addr(olsr, &hello_neigh->address, in_if )) { // wiss: hello_neigh->address, byetaba2 ma3 in_if proc_link_set(olsr, in_if, &hello->source_addr, hello_neigh->status, hello->willingness, hello->vtime, hello->htime); //update symmetric neighbor set proc_symmetric_neighbor_set(olsr, in_if, hello_neigh->status, hello); break; // wiss : so iza fet hon ya3ni la2a el neighbor so break... so iza ma la2an byente2el 3al neigh->next } hello_neigh = hello_neigh->next; } //update neighbor address association set proc_association_set(olsr, &hello->local_iface_list, hello->vtime); hello_neigh = hello->neighbors; while (hello_neigh){ //process 2hop Neighbor set proc_2neigh_set(olsr, in_if, &hello->source_addr, &hello_neigh->address, hello_neigh->status, hello_neigh->other_neigh, hello->vtime); //check: own interfaces is selected MPR by source nodes. if(selected_mpr == OLSR_FALSE && own_ip_addr(olsr, &hello_neigh->address) == OLSR_TRUE && hello_neigh->is_mpr == OLSR_TRUE) { selected_mpr = OLSR_TRUE; } //next pointer hello_neigh = hello_neigh->next; } //update mpr selector set , relay set, advertise neighbor set if(selected_mpr == OLSR_TRUE) { entry = hello->local_iface_list.head; while(entry) { local_entry = (OLSR_LOCAL_INTERFACE_BLOCK_ENTRY *)entry->data; retList = search_symmetric_neighbor_set(olsr, in_if, &local_entry->iface_addr); if(retList) { if(retList->numEntry != 1) { olsr_error("process_hello():5"); } get_current_time(olsr, &time); sym_data = (OLSR_SYMMETRIC_NEIGHBOR_TUPLE *)retList->head->data; OLSR_DeleteList_Search(retList); if(get_neighbor_status(&time, &sym_data->N_time) == SYMMETRIC) { proc_mpr_selector_set(olsr, &local_entry->iface_addr); if(olsr->change_mpr_selector_set) { if(proc_adv_neigh_set(olsr, &local_entry->iface_addr)){ proc_relay_set(olsr, &local_entry->iface_addr); change_assn = OLSR_TRUE; } } }//if(get_neigh...) } //next entry entry = entry->next; }//while } else{ // wiss: ici selected_mpr==false entry = hello->local_iface_list.head; while(entry) { local_entry = (OLSR_LOCAL_INTERFACE_BLOCK_ENTRY *)entry->data; delete_mpr_selector_set(olsr, &local_entry->iface_addr); if(olsr->change_mpr_selector_set) { delete_adv_neigh_set(olsr, &local_entry->iface_addr); if(olsr->change_adv_neigh_set) { change_assn = OLSR_TRUE; delete_relay_set(olsr, &local_entry->iface_addr); } } //next entry entry = entry->next; }//while } /* if I am selecetd as MPR by someone, I_am_MPR_flag turns ON and send TC message every TC_INTERVAL */ if (olsr->I_am_MPR_flag == OLSR_FALSE && olsr->adv_neigh_set.head != NULL){ olsr->I_am_MPR_flag = OLSR_TRUE; } if(DEBUG_OLSRV2) { olsr_printf("\tassn[%d]\n", get_local_assn(olsr)); } if (change_assn == OLSR_TRUE) increment_local_assn(olsr); return OLSR_TRUE; }