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

📄 timer.c

📁 OLSR Implementation for XORP
💻 C
📖 第 1 页 / 共 2 页
字号:
				}			}			else			{				send_tc_seperately = 1;								if (debug_level > 3)				{					printf ("----- send TC out first!\n");					fprintf (y_file,"----- send TC out first!\n");				}								if (hna_relay_size + mid_relay_size >  MAXPACKETSIZE)				{					send_mid_seperately = 1;										if (debug_level > 3)					{						printf ("----- send MID out after TC!\n");						fprintf (y_file,"----- send MID out after TC!\n");					}				}			}		}		else 		{			if (debug_level > 3 && (timetorelay_mid || timetorelay_hna))			{				printf ("********* there are relayed TC || (MID || HNA) together ************\n");				printf ("tc relay size: %d, mid relay size: %d, hna relay size: %d\n", tc_relay_size, mid_relay_size, hna_relay_size);								fprintf (y_file,"********* there are relayed TC || (MID || HNA) together ************\n");				fprintf (y_file,"tc relay size: %d, mid relay size: %d, hna relay size: %d\n", tc_relay_size, mid_relay_size, hna_relay_size);			}						if ((timetorelay_mid && (tc_relay_size + mid_relay_size >  MAXPACKETSIZE)) || (timetorelay_hna && (tc_relay_size + hna_relay_size >  MAXPACKETSIZE)))			{				send_tc_seperately = 1;								if (debug_level > 3)				{					printf ("^^^^^^^^^^^^^^ can not send TC and MID/HNA together ^^^^^^^^^^^^^^^^\n");					fprintf (y_file,"^^^^^^^^^^^^^^ can not send TC and MID/HNA together ^^^^^^^^^^^^^^^^\n");				}			}		}			}	else	{		if (timetorelay_mid && timetorelay_hna)		{			if (debug_level > 3)			{				printf ("********* there are relayed MID, HNA together ************\n");				printf ("mid relay size: %d, hna relay size: %d\n", mid_relay_size, hna_relay_size);								fprintf (y_file,"********* there are relayed MID, HNA together ************\n");				fprintf (y_file,"mid relay size: %d, hna relay size: %d\n", mid_relay_size, hna_relay_size);			}						if (mid_relay_size + hna_relay_size>MAXPACKETSIZE)			{				send_mid_seperately = 1;								if (debug_level > 3)				{					printf ("^^^^^^^^^^^^^^ can not send MID  and HNA together ^^^^^^^^^^^^^^^^\n");					fprintf (y_file,"^^^^^^^^^^^^^^ can not send MID  and HNA together ^^^^^^^^^^^^^^^^\n");				}				}		}	}	/******************* end of revision ***************/	/* Advance time on differents tables entry */	olsr_delete_time_out_entries();	//timetobroadcast_hello = 1;	//timetobroadcast_mid = 0;	if ((timetoreset_hello)&&(hello_start==1))	{		sincelast_hello_poll = 0;		hello_jit_result = (float) random()/RAND_MAX - 0.5;		hello_jit_result *= hello_jitter;		hello_int_wjit = hello_int + hello_jit_result;				if (debug_level == -1)			printf("hello int with jitter value = %f\n",hello_int_wjit);  	}	/*************** following "for" loop is added by Y.Ge to add interface index info *********/	for (ifp = ifnet; ifp; ifp = ifp->int_next) 	{		/******************** added by Y.Ge ****************/		/*** first of all, check if there is packets to be relayed ***/		if(timetorelay_tc)		{			printf ("XXXXXXXXXXXXXXXXXXXX time  (%02d:%02d:%02d.%06lu) TC sent from interface %d!XXXXXXXXXXXXXXXXXX\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec, ifp->my_index);			fprintf (y_file, "XXXXXXXXXXXXXXXXXXXX time  (%02d:%02d:%02d.%06lu) TC sent from interface %d!XXXXXXXXXXXXXXXXXX\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec, ifp->my_index);						/* qos OLSR */			if (qostcpacket_relay.multipoint_relay_selector_busy_time !=NULL)				qostc_build((struct sockaddr *)NULL, &qostcpacket_relay, &tcpacket_relay,0, ifp, 1);			else				tc_build((struct sockaddr *)NULL,(struct hello_message *)NULL, &tcpacket_relay, (struct mid_message *)NULL, (struct hna_message *)NULL, 0, ifp, 1);			tc_to_relay = 0;			qostc_to_relay = 0;			tc_relay_interval = 0;						if (send_tc_seperately)			{				/******** should send tc out first *********/				if (debug_level > 3)				{					printf ("=========== the relayed TC is sent out! ===========\n");					fprintf (y_file,"=========== the relayed TC is sent out! ===========\n");				}								tointerface (sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL, ifp->my_index);			}			}				if (timetorelay_mid)		{			printf ("XXXXXXXXXXXXXXXXXXXX time  (%02d:%02d:%02d.%06lu) MID sent from interface %d!XXXXXXXXXXXXXXXXXX\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec, ifp->my_index);			fprintf (y_file, "XXXXXXXXXXXXXXXXXXXX time  (%02d:%02d:%02d.%06lu) MID sent from interface %d!XXXXXXXXXXXXXXXXXX\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec, ifp->my_index);						mid_build((struct sockaddr *)NULL,(struct hello_message *)NULL, (struct tc_message *)NULL, &midpacket_relay, (struct hna_message *)NULL, 0, ifp, 1);			mid_to_relay = 0;			mid_relay_interval = 0;							if (send_mid_seperately)			{				/******** should send mid out first *********/				if (debug_level > 3)				{					printf ("=========== the relayed MID is sent out! ===========\n");					fprintf (y_file,"=========== the relayed MID is sent out! ===========\n");				}								tointerface (sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL, ifp->my_index);			}						}		if (timetorelay_hna)		{			printf ("XXXXXXXXXXXXXXXXXXXX time  (%02d:%02d:%02d.%06lu) HNA sent from interface %d!XXXXXXXXXXXXXXXXXX\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec, ifp->my_index);			fprintf (y_file, "XXXXXXXXXXXXXXXXXXXX time  (%02d:%02d:%02d.%06lu) HNA sent from interface %d!XXXXXXXXXXXXXXXXXX\n", nowtm->tm_hour, nowtm->tm_min,nowtm->tm_sec,now.tv_usec, ifp->my_index);						hna_build((struct sockaddr *)NULL,(struct hello_message *)NULL, (struct tc_message *)NULL,(struct mid_message *)NULL, &hnapacket_relay,  0, ifp, 1);			hna_to_relay = 0;			hna_relay_interval = 0;						}		/******************* end of revision ***************///		printf("timer.c: outside the if: index: %d timetobroadcast_hello %d hello_start //%d\n",ifp->my_index,timetobroadcast_hello,hello_start);		if ((timetobroadcast_hello)&&(hello_start==1)) 		{			olsr_build_hello_packet(&hellopacket, ifp->my_index);			hello_build((struct sockaddr *)NULL, &hellopacket, (struct tc_message *)NULL,(struct mid_message *)NULL,(struct hna_message *)NULL, 0, ifp);						/******** added by Y.Ge *********/			/* qos OLSR */			if (use_qos)			{				qoshello_build((struct sockaddr *)NULL, 0, ifp);			}			/******** end of revision *******/			sincelast_hello = 0;			if(debug_level > 6) 			{				olsr_print_neighbor_table();				if(debug_level > 7) 					olsr_print_topology_table();			}								}        		if (timetobroadcast_tc && mprstable.mssn!=0) //"mprstable.mssn!=0" added by Y.Ge, mpr selector table has been changed		{			/************ added by Y.Ge **************/			if (tc_built_finished == 0)			{				if (use_qos)				{					olsr_build_qos_tc_packet(&qostcpacket, ifp->my_index);				}				olsr_build_tc_packet(&tcpacket, ifp->my_index);				tc_built_finished = 1;			}						/*toall(tc_build, (struct hello_message *)NULL, &tcpacket,(struct hna_message *)NULL, (struct interface *)NULL);*/ //commented by Y.Ge						if (use_qos)				qostc_build ((struct sockaddr *)NULL, &qostcpacket, &tcpacket, 0, ifp, 0);			else 				tc_build ((struct sockaddr  *)NULL,(struct hello_message *)NULL, &tcpacket,(struct mid_message *)NULL,(struct hna_message *)NULL, 0, ifp, 0);			/*********** end of revision ***********/									sincelast_tc = 0;			tc_jit_result = (float) random()/RAND_MAX - 0.5;			tc_jit_result *= tc_jitter;			if (debug_level > 6)				printf("tc jitter value = %f\n",tc_jit_result);			sincelast_tc += tc_jit_result;			//changes = 0;	//commented by Y.Ge, reset changes later		}		//CRC HNA modify		if (timetobroadcast_hna && hnainfo.hna_net_addrs != NULL) // revised by Y.Ge		{			/*toall(hna_build, (struct hello_message *)NULL,(struct tc_message *)NULL,(struct mid_message *)NULL, &hnainfo,(struct interface *)NULL);			sincelast_hna = 0;*/ //commented by  Y.Ge						/************** added by Y.Ge **********/			hna_build ((struct sockaddr *)NULL, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL, &hnainfo, 0, ifp, 0);			sincelast_hna = 0;			hna_jit_result = (float) random()/RAND_MAX -0.5;			hna_jit_result *= hna_jitter;			sincelast_hna += hna_jit_result;			hna_sent = 1;			/************** end of revision *********/		}		/*************** added by Y.Ge ***************/		if (timetobroadcast_mid && num_of_interface>1)		{			if (mid_built_finished == 0) //only need to build MID once			{				olsr_build_mid_packet (&midpacket, ifp->my_index);				mid_built_finished = 1;			}			mid_build((struct sockaddr *)NULL, (struct hello_message *)NULL,(struct tc_message *)NULL, &midpacket, (struct hna_message *)NULL, 0, ifp, 0);			sincelast_mid = 0;			mid_jit_result = (float) random()/RAND_MAX - 0.5;			mid_jit_result *= mid_jitter;			sincelast_mid += mid_jit_result;		}		/****************** end of revision **************/		if (outputsize)		{			//toall(sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL ); //commented by Y.Ge			tointerface (sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL, ifp->my_index); //added by Y.Ge			//printf ("\n\nXXXXXXXXXXXXXXXXXXXXXXXXXX sending message finished!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n");			//getchar();		}					}	/************** added by Y.Ge ************/	/*	 * reset the changes	 * which is used in timetobroadcast_tc	 */	if (timetobroadcast_tc)	{		if (changes)			changes = 0;	}		/* 	 * update message seq number	 * delete the addresses in various messages  	 */	if (midpacket.mid_interface_address != NULL)	{		if (check_chunk_count(mid_chunk) ==0)		{			printf ("XXXXXXXXXXX something wrong with mid truck! XXXXXXXXXXXXXXX\n");			exit (1);		}				msg_seqnum.mid_seqnum += mid_chunk[0];		reset_chunk_count (mid_chunk);				mid_addresses = midpacket.mid_interface_address;		while (mid_addresses)		{			prev_mid_addresses = mid_addresses;			mid_addresses = mid_addresses->next;			free(prev_mid_addresses);		}	}	if (tcpacket.multipoint_relay_selector_address != NULL)	{		if (check_chunk_count(tc_chunk) ==0)		{			printf ("XXXXXXXXXXX something wrong with tc truck! XXXXXXXXXXXXXXX\n");			exit (1);		}				msg_seqnum.tc_seqnum += tc_chunk[0];				/*printf (" ++++++++ now tc seq is: %d\n", msg_seqnum.tc_seqnum);		fprintf (y_file," ++++++++ now tc seq is: %d\n", msg_seqnum.tc_seqnum);*/				reset_chunk_count (tc_chunk);		mprs = tcpacket.multipoint_relay_selector_address;		while (mprs)		{			prev_mprs = mprs;			mprs = mprs->next;			free(prev_mprs);		}	}	if (hna_sent && hnainfo.hna_net_addrs != NULL)	{		if (check_chunk_count(hna_chunk) ==0)		{			printf ("XXXXXXXXXXX something wrong with hna truck! XXXXXXXXXXXXXXX\n");			exit (1);		}		/*printf ("&&&&&&&&&&&&&& hnachunk is: %d\n", hna_chunk[0]);		printf (" originally hna sequence is: %d\n", msg_seqnum.hna_seqnum);*/				msg_seqnum.hna_seqnum += hna_chunk[0];		hnainfo.packet_seq_number = msg_seqnum.hna_seqnum;		/*printf (" now hna sequence is: %d\n", msg_seqnum.hna_seqnum);*/		reset_chunk_count (hna_chunk);	}		/*	 * free the memroy of the relayed TC and MID packets	 */	if (tc_to_relay == 0 && tcpacket_relay.multipoint_relay_selector_address!=NULL)	{		olsr_destroy_tc_message(&tcpacket_relay);		tcpacket_relay.multipoint_relay_selector_address = NULL;		tc_relay_size = 0;	}	if (qostc_to_relay == 0 && qostcpacket_relay.multipoint_relay_selector_busy_time!=NULL)	{		olsr_destroy_qos_tc_message(&qostcpacket_relay);		qostcpacket_relay.multipoint_relay_selector_busy_time = NULL;		qostc_relay_size = 0;	}	if (mid_to_relay ==0 && midpacket_relay.mid_interface_address!=NULL)	{		//printf ("XXXXXXXXXX should destroy the midpacket_relay! XXXXXXXXXXX\n");		olsr_destroy_mid_message(&midpacket_relay);		midpacket_relay.mid_interface_address=NULL;		mid_relay_size = 0;	}	if (hna_to_relay == 0 && hnapacket_relay.hna_net_addrs != NULL)	{		olsr_destroy_hna_message(&hnapacket_relay);		hnapacket_relay.hna_net_addrs = NULL;		hna_relay_size = 0;	}	/*************** end of revision ***************/	}

⌨️ 快捷键说明

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