⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 olsr.c

📁 OLSR Implementation for XORP
💻 C
📖 第 1 页 / 共 5 页
字号:
		*/		olsr_calculate_routing_table(); 		changes_topology=DOWN;		//CRC HNA add		/*-------------------------*/		changes_net=DOWN;		/*-------------------------*/				if (debug_level ==1 || debug_level ==2)		{			printf ("\n\n.........time (%02d:%02d:%02d.%06lu),changes in topology! .........\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec);			printf (" now, the routing table is\n");			olsr_print_routing_table(routingtable);						fprintf (y_file,"\n\n.........time (%02d:%02d:%02d.%06lu),changes in topology! .........\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec);			fprintf (y_file," now, the routing table is\n");			olsr_print_trace_routing_table(routingtable);		}				if (debug_level ==2)		{			printf ("\n the topology table is\n");			olsr_print_topology_table();			printf ("\n the mid table is:\n");			olsr_print_main_address_table();			olsr_print_interface_address_table();									fprintf (y_file,"\n the topology table is\n");			olsr_print_trace_topology_table();			fprintf (y_file,"\n the mid table is:\n");			olsr_print_trace_main_address_table();			olsr_print_trace_interface_address_table();		}		return 0;	}	//CRC HNA add	/*------------------------------*/	if(changes_net)	{		/*		copy the routing table from mirror table 		and modify it to reflect the hna changes		*/		//olsr_modify_routing_table_from_hna();		olsr_calculate_routing_table();		changes_net=DOWN; 				if (debug_level ==1 || debug_level ==2)		{			printf (".........changes in network! .........\n");			printf (" now, the routing table is\n");			olsr_print_routing_table(routingtable);						fprintf (y_file,".........changes in network! .........\n");			fprintf (y_file," now, the routing table is\n");			olsr_print_trace_routing_table(routingtable);		}		return 0;	}}/*------------------------------------------------------------------------*//********************** added by Y.Ge *****************//* qos OLSR */intolsr_process_changes_with_qos(){	/*------------------*/	if(debug_level > 8)	{		if(changes_neighborhood)		printf("CHANGES IN NEIGHBORHOOD\n");		if(changes_topology)		printf("CHANGES IN TOPOLOGY\n");	}	/*------------------*/  	if(changes_neighborhood)	{		/*		Calculate new mprs and routing table		*/		olsr_calculate_mpr();		olsr_calculate_routing_table_with_qos(); 		changes_neighborhood=DOWN;		changes_topology=DOWN;		//CRC HNA add		/*-------------------------*/		changes_net=DOWN;		/*-------------------------*/		if (debug_level ==1 || debug_level ==2)		{			printf ("\n\n.........time (%02d:%02d:%02d.%06lu), changes in neighborhood! .........\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec);			printf (" now, the routing table is\n");			olsr_print_routing_table(routingtable);						fprintf (y_file,"\n\n\n\n.........time (%02d:%02d:%02d.%06lu), changes in neighborhood! .........\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec);			fprintf (y_file," now, the routing table is\n");			olsr_print_trace_routing_table(routingtable);		}				if (debug_level ==2)		{			printf ("\n the neighbor table is\n");			olsr_print_neighbor_table();			printf ("\n the two hop neighbor table is\n");			olsr_print_two_hop_neighbor_table();			printf ("\n the main address routing table is\n");			olsr_print_main_addr_neigh_table();						fprintf (y_file,"\n the neighbor table is\n");			olsr_print_trace_neighbor_table();			fprintf (y_file,"\n the two hop neighbor table is\n");			olsr_print_trace_two_hop_neighbor_table();			fprintf (y_file,"\n the main address routing table is\n");			olsr_print_trace_main_addr_neigh_table();					}		return 0;	}	if(changes_topology)	{		/*		calculate the routing table		*/		olsr_calculate_routing_table_with_qos(); 		changes_topology=DOWN;		//CRC HNA add		/*-------------------------*/		changes_net=DOWN;		/*-------------------------*/				if (debug_level ==1 || debug_level ==2)		{			printf ("\n\n.........time (%02d:%02d:%02d.%06lu),changes in topology! .........\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec);			printf (" now, the routing table is\n");			olsr_print_routing_table(routingtable);						fprintf (y_file,"\n\n.........time (%02d:%02d:%02d.%06lu),changes in topology! .........\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec);			fprintf (y_file," now, the routing table is\n");			olsr_print_trace_routing_table(routingtable);		}				if (debug_level ==2)		{			printf ("\n the topology table is\n");			olsr_print_topology_table();			printf ("\n the mid table is:\n");			olsr_print_main_address_table();			olsr_print_interface_address_table();									fprintf (y_file,"\n the topology table is\n");			olsr_print_trace_topology_table();			fprintf (y_file,"\n the mid table is:\n");			olsr_print_trace_main_address_table();			olsr_print_trace_interface_address_table();		}		return 0;	}	//CRC HNA add	/*------------------------------*/	if(changes_net)	{		/*		copy the routing table from mirror table 		and modify it to reflect the hna changes		*/		//olsr_modify_routing_table_from_hna();		olsr_calculate_routing_table_with_qos();		changes_net=DOWN; 				if (debug_level ==1 || debug_level ==2)		{			printf (".........changes in network! .........\n");			printf (" now, the routing table is\n");			olsr_print_routing_table(routingtable);						fprintf (y_file,".........changes in network! .........\n");			fprintf (y_file," now, the routing table is\n");			olsr_print_trace_routing_table(routingtable);		}		return 0;	}}/*------------------------------------------------------------------------*/intolsr_process_received_hello(struct hello_message *message, int index){	if (use_hyst)		olsr_process_received_hello_with_hyst(message, index);	else		olsr_process_received_hello_no_hyst(message, index);	}/*------------------------------------------------------------------------*//*------ This function WITH hysteresis----*/intolsr_process_received_hello_with_hyst(struct hello_message *message, int iface_index) //"iface_index" added by Y.Ge{	olsr_u8_t                   	link=0;	olsr_u8_t               	link_type=0, neigh_type = 0;	struct neighbor_entry       	*neighbor;	struct neighbor_2_entry      	*two_hop_neighbor;	struct main_addr_neigh_entry	*main_addr_neighbor;  //added by Y.Ge	struct iface_addr_list_entry	*neighbor_iface_link; //added by Y.Ge	float                   	rcvd_vtime;  //added by Y.Ge 	float                       	rcvd_htime;	//added by Y.Ge  	olsr_u8_t               	change_hold_time = 0; //added by Y.Ge 	struct timeval 	        	hold_time_tmp;	//added by Y.Ge	struct timeval              	next_hello_time; //added by Y.Ge 		int                          	changed = 0;  //IF (changed), the main address neighbor status should be updated	struct timeval            	tmp_timeval; //added by Y.Ge		if(message==NULL)		return 1;    	//link=olsr_lookup_link_status(message); //commented by Y.Ge		if (debug_level > 4)	{		printf ("\n\nbefore process received HELLO WITH HYST, the tables are:\n");		olsr_print_neighbor_table();		olsr_print_main_addr_neigh_table(); 		olsr_print_two_hop_neighbor_table();		olsr_print_mpr_selector_table();		olsr_print_topology_table();		olsr_print_main_address_table();		olsr_print_interface_address_table();		if (use_qos)			qos_olsr_print_routing_table(routingtable);		else			olsr_print_routing_table(routingtable);				fprintf (y_file,"\n\nbefore process received HELLO WITH HYST, the tables are:\n");		olsr_print_trace_neighbor_table();		olsr_print_trace_main_addr_neigh_table(); 		olsr_print_trace_two_hop_neighbor_table();		olsr_print_trace_mpr_selector_table();		olsr_print_trace_topology_table();		olsr_print_trace_main_address_table();		olsr_print_trace_interface_address_table();		if (use_qos)			qos_olsr_print_trace_routing_table(routingtable);		else			olsr_print_trace_routing_table(routingtable);	}	/********************** added by Y.Ge ********************/	/*	 * decompose link - link = neighbor type + link type 	 */	/********************** added by Y.Ge ******************/	link_type = olsr_lookup_link_status(message, iface_index);	neigh_type = olsr_lookup_neighbor_status(message, iface_index);	rcvd_vtime = olsr_compute_time_from_vtime(message->v_time);	rcvd_htime = olsr_compute_time_from_vtime(message->rcvd_h_time) * 1.25; //Y.Ge: consider Hello jitter	/* a message that announce link type == link_sym && neighbor type == not_neigh is invalid */	if (link_type == SYM_LINK && neigh_type == NOT_NEIGH)	{		printf ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n");		printf ("XATTENTION: the link and neigghbor code in HELLO  does't match!X\n");		printf ("XXXXXXX   link type is: %d, neighbor type is: %d  XXXXXXXXXXXXXX\n", link_type, neigh_type);		printf ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n");		olsr_destroy_hello_message(message);		exit  (1);	}	olsr_init_timer(rcvd_vtime*1000,&hold_time_tmp);  //the v_time value in HELLO	olsr_init_timer(rcvd_htime*1000, &next_hello_time); //the h_time value in HELLO	/******************** end of revision *******************/	//if(link==NBS_MPR) //commented by Y.Ge	if (neigh_type == MPR_NEIGH) //added by Y.Ge		olsr_update_mpr_selector_table(message);  	//if(NULL== (neighbor=olsr_lookup_neighbor_table(&message->source_addr))) //commented by Y.Ge	if(NULL== (neighbor=olsr_lookup_neighbor_table(&message->source_addr, &addr_manet[iface_index]))) //added by Y.Ge	{		//The neighbor entry doesn't exist in neighbtable				/********************** added by Y.Ge ******************/		/*** debug ***/		if (debug_level >3)		{			printf ("\n+++ new neighbor detected ! +++\n"); //added by Y.Ge			fprintf (y_file,"\n+++ new neighbor detected ! +++\n"); //added by Y.Ge		}		/********************* end of revision *****************/		neighbor=(struct neighbor_entry *)malloc(sizeof(struct neighbor_entry));   		memcpy(&neighbor->my_iface_addr, &message->my_addr, sizeof(struct olsr_ip_addr)); //added by  Y.Ge 		memcpy(&neighbor->neighbor_addr, &message->source_addr, sizeof(struct olsr_ip_addr)); //added by Y.Ge		neighbor->my_iface_index = iface_index; //added by Y.Ge, iface_index that connects to that neighbor		//memcpy(&neighbor->neighbor_addr,&message->originator_addr,sizeof(struct olsr_ip_addr));	//commented by Y.Ge				/*********** added by Y.Ge ***********/		/* qos OLSR */		if (use_qos)		{			neighbor->neighbor_hello_seq = message->packet_seq_number;			neighbor->neighbor_busy_time = default_busy_time;		}		/********** end of revision *********/				/* timers */						timerminus(&neighbor->neighbor_link_sym_timer); //added by Y.Ge, expire the L_SYM_TIME		timeradd(&now, &hold_time_tmp, &neighbor->neighbor_link_asym_timer); //added by Y.Ge		timeradd(&now, &hold_time_tmp, &neighbor->neighbor_timer); //added  by Y.Ge		//timeradd(&now,&hold_time_neighbor,&neighbor->neighbor_timer); //commented by Y.Ge		neighbor->neighbor_ifp=NULL;		neighbor->neighbor_2_list=NULL;		neighbor->neighbor_2_nocov=0;		neighbor->neighbor_main_info=NULL;				/* added by Y.Ge, dealing with hysteresis */  		//added by L. Qin, 		neighbor->neighbor_hysavg = HYST_SCALING;		printf("in olsr.c the neighbor_hysavg is %f\n",neighbor->neighbor_hysavg);		neighbor->link_pending = 0;		neighbor->h_time_value = rcvd_htime;		timerminus(&neighbor->neighbor_link_lost_timer);		timeradd(&now, &next_hello_time, &neighbor->next_hello_timer);		olsr_insert_neighbor_table(neighbor);				/* update the link status */		//neighbor->neighbor_status=NBS_ASYM; //commented by Y.Ge 		neighbor->neighbor_status = ASYM_LINK; //added by Y.Ge				/* L_time = max (L_time, L_ASYM_time), added by Y.Ge */		if (compare_timer(&neighbor->neighbor_timer, &neighbor->neighbor_link_asym_timer) ==0)			olsr_assign_timer(&neighbor->neighbor_link_asym_timer, &neighbor->neighbor_timer);  				/******************** added by Y.Ge **************/		/*		 update main_addr_neighbor_table		*/		/* a new neighbor */		if (NULL == (main_addr_neighbor = olsr_lookup_main_addr_neigh_table(&message->originator_addr)))		{			main_addr_neighbor = (struct main_addr_neigh_entry *)malloc(sizeof(struct main_addr_neigh_entry));			memcpy(&main_addr_neighbor->main_addr_neigh_addr, &message->originator_addr, sizeof(struct olsr_ip_addr));			main_addr_neighbor->main_addr_neigh_willingness = message->willingness;			main_addr_neighbor->main_addr_neigh_status = NOT_NEIGH; 			main_addr_neighbor->neigh_iface_list=NULL;			main_addr_neighbor->interface_pointer=0;			olsr_insert_main_addr_neigh_table(main_addr_neighbor);			/* LINK neighbor to main_neighbor ENTRIES */			olsr_linking_neighbor_main_neighbor(neighbor, main_addr_neighbor);		}		else		{			/* LINK neighbor to main_neighbor ENTRIES */			olsr_linking_neighbor_main_neighbor(neighbor, main_addr_neighbor);		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -