亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? arp.c

?? 在freescale 的ne64上開發的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
	
	
	/* Was there free or temporary entries?	*/
	
	if( found == (-1) )
		return(-1);
		
	/* Next time start from next entry	*/
	
	aenext = (aenext + 1);	
	if( aenext >= ARP_TSIZE )
		aenext = 1;		

	qstruct = &arp_table[found];
	
	/* Set ARP initial parameters	*/
	
	qstruct->state = ARP_RESERVED;
	qstruct->type = type;
	
	/* Was return(i)!!! <-wrong!!	*/
	
	return((UINT8)found);


}
/** \brief Add given IP address and MAC address to ARP cache
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 10.07.2002
 *	\param pra - protocol address (assumed IPv4)
 *	\param hwadr - pointer to Ethernet MAC address (6 bytes)
 *	\param type - type of address allocated if not found. Can be one of the
 *		following:
 *		\li #ARP_FIXED_IP
 *		\li #ARP_TEMP_IP
 *	\return
 *		\li 0 - Address already in cache. Refreshed.
 *		\li 1 - New entry in ARP cache created
 *
 *	New IP address is added to ARP cache based on the information
 *	supplied to function as parameters.
 */
INT8 arp_add (UINT32 pra, UINT8* hwadr, UINT8 type)
{
	struct arp_entry *qstruct;
	INT8 i;
	INT8 j;

	for( i=0; i<ARP_TSIZE; i++ ) {
		qstruct = &arp_table[i];
		
		if( qstruct->state == ARP_FREE )
			continue;
			
		if((qstruct->pradr == pra)&&(pra != IP_BROADCAST_ADDRESS)) {
			/* The address is in cache, refresh it	 */
			
			//ARP_DEBUGOUT(" Refreshing Existing ARP Entry..\n\r");
		
			for( j=0; j<MAXHWALEN; j++ )		
				qstruct->hwadr[j] = *hwadr++;
				
			qstruct->ttl = ARP_TIMEOUT;
			qstruct->retries = ARP_MAXRETRY;
			qstruct->state = ARP_RESOLVED;
	
			/* All OK	*/
		
			return (0);	
		}
	
	}
	
	if(is_subnet(pra,&localmachine) == FALSE){
		return (-1);
	}
	
	if( localmachine.defgw == pra )	{
		if(localmachine.defgw != 0) {
			type = ARP_FIXED_IP;
		}
	}

	
	/* Address was'nt on cache. Need to allocate new one	*/
	
	//ARP_DEBUGOUT("Allocating New ARP Entry..\n\r");
	
	i = arp_alloc(type);
	
	if( i < 0 )				/* No Entries Left?	*/
		return(-1);
			
	/* Fill the fields		*/
		
	qstruct = &arp_table[i];
		
	qstruct->pradr = pra;										/* Fill IP				*/
	
	for(i=0; i<MAXHWALEN; i++)
		qstruct->hwadr[i] = *hwadr++;							/* Fill HW address		*/

	qstruct->retries = ARP_MAXRETRY;
	qstruct->ttl = ARP_TIMEOUT;
	qstruct->state = ARP_RESOLVED;				
	
	//ARP_DEBUGOUT("ARP Entry Created!..\n\r");

	return(1);

}
 
/** \brief Find an ARP entry given a protocol address
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 01.11.2001
 *	\param pra - Protocol address (IPv4)
 *	\param machine - Pointer to configuration of network interface used
 *	\param type - Type of address allocated if not found. Can be one of the
 *		following:
 *		\li #ARP_FIXED_IP
 *		\li #ARP_TEMP_IP
 *	\return
 *		\li 0 - ARP entry not found or not ready yet (waiting for ARP response)
 *		\li struct arp_entry* - pointer to solved entry of ARP cache table
 *
 *	This function tries to resolve IPv4 address by checking the ARP cache
 *	table and sending ARP requested if needed. 
 */
struct arp_entry* arp_find (LWORD pra, struct netif *machine, UINT8 type)
{
	struct arp_entry *qstruct;
	INT8 i;
	
	//ARP_DEBUGOUT("Trying to find MAC address from ARP Cache\n\r");
	
	/* Is the address in the cache	*/
	
	for( i=0; i<ARP_TSIZE; i++ ) {
		qstruct = &arp_table[i];
		
		if( qstruct->state == ARP_FREE )
			continue;
		if( qstruct->pradr == pra) {
			/* The address is in cache, is it valid? */
			
			//ARP_DEBUGOUT("Address In Cache\n\r");
			
			if( qstruct->state < ARP_RESOLVED ) {
				//ARP_DEBUGOUT("Address in cache but unresolved :(\n\r");
				return(0);
			}
			/* All OK	*/
		
			return(qstruct);	
		}
	
	}
	
	/* The address wasn't on the cache. Is it in our Subnet?	*/
	
	if( is_subnet(pra, machine) ) {
		/* Yep, we need to send ARP REQUEST	*/
		
		//ARP_DEBUGOUT("Need to send ARP Request to local network..\n\r");
		
		if( machine->defgw == pra ) {
			if(machine->defgw != 0) {
				type = ARP_FIXED_IP;
			}
		}
		i = arp_alloc(type);
		
		if( i < 0 )				/* No Entries Left?	*/
			return(0);
			
		/* Send Request after filling the fields	*/
		
		qstruct = &arp_table[i];
		
		qstruct->pradr = pra;						/* Fill IP				*/
		qstruct->hwadr[0] = 0xFF;					/* Fill Broadcast IP	*/
		qstruct->hwadr[1] = 0xFF;
		qstruct->hwadr[2] = 0xFF;
		qstruct->hwadr[3] = 0xFF;
		qstruct->hwadr[4] = 0xFF;
		qstruct->hwadr[5] = 0xFF;
		qstruct->retries = ARP_MAXRETRY;
		qstruct->ttl = ARP_RESEND;
		arp_send_req( i );
		qstruct->state = ARP_PENDING;				/* Waiting for Reply	*/
		
		return(0);
	
	} 

	/* The Address belongst to the outern world, need to use MAC of			*/
	/* Default Gateway														*/
	
	//ARP_DEBUGOUT("Need to use MAC of Default GW\n\r");
	
	/* Check for Broadcast													*/
	
	if(machine->defgw == 0)				/* It's not specified	*/
		return(0);
	
	
	for( i=0; i<ARP_TSIZE; i++ ) {
		qstruct = &arp_table[i];
		
		if( qstruct->state == ARP_FREE )
			continue;
			
		if( qstruct->pradr == machine->defgw ) {
			/* The address is in cache, is it valid? */
		 
			
			if( qstruct->state < ARP_RESOLVED ) {
				//ARP_DEBUGOUT("The Address of Def. GW is not Solved!\n\r");
				return(0);
			}
		
			/* All OK	*/
			
			//ARP_DEBUGOUT(" >> Default Gateway MAC found!\n\r");
		
			return(qstruct);
				
		}
	
	}
	
	//ARP_DEBUGOUT("Need to send ARP Request to default gateway..\n\r");
		
	i = arp_alloc(ARP_FIXED_IP);
		
	if( i < 0 )				/* No Entries Left?	*/
		return(0);
			
	/* Send Request after filling the fields	*/
		
	qstruct = &arp_table[i];
		
	qstruct->pradr = machine->defgw;						/* Fill IP				*/
	qstruct->hwadr[0] = 0xFF;					/* Fill Broadcast IP	*/
	qstruct->hwadr[1] = 0xFF;
	qstruct->hwadr[2] = 0xFF;
	qstruct->hwadr[3] = 0xFF;
	qstruct->hwadr[4] = 0xFF;
	qstruct->hwadr[5] = 0xFF;
	qstruct->retries = ARP_MAXRETRY;
	qstruct->ttl = ARP_RESEND;
	arp_send_req( i );
	qstruct->state = ARP_PENDING;				/* Waiting for Reply	*/
	
	return(0);

	
}


/** \brief Manage ARP cache periodically
 *	\ingroup periodic_functions
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 04.11.2001
 *	\warning
 *		\li Invoke this function periodically to ensure proper ARP
 *		cache behaviour
 *
 *	Iterate through ARP cache aging entries. If timed-out entry is found,
 *	remove it (dynamic address) or update it (static address). This function
 *	must be called periodically by the system.
 *
 */
void arp_manage (void)
{
	struct arp_entry *qstruct;
	UINT8 i,j;
	static UINT8 aenext=0;
	
	/* Check Timer before entering	*/
	
	if( check_timer(arp_timer) )
		return;
		
	init_timer( arp_timer, ARP_MANG_TOUT*TIMERTIC);
	
	/* DEBUGOUT("Managing ARP Cache\n\r"); */
	
	for( i=0; i<ARP_TSIZE; i++ ) {
		/* DEBUGOUT("."); */
	
		qstruct = &arp_table[aenext];
		
		j = aenext;
		
		/* Take next entry next time	*/
				
		aenext++;
		if(aenext >= ARP_TSIZE)
			aenext = 0;	
	
		if( qstruct->state == ARP_FREE )
			continue;
			
		/* TODO: How about ARP_RESERVED?	*/
			
		if( qstruct->ttl > 0 )				/* Aging		*/
			qstruct->ttl --;
		
		if( qstruct->ttl == 0 )	{			/* Timed Out?	*/
			/* Do it for temporay entries	*/
			
			//ARP_DEBUGOUT("Found Timed out Entry..\n\r");
		
			if( qstruct->type == ARP_TEMP_IP ) {

				/* Release it?	*/
				if( qstruct->state == ARP_RESOLVED ) {	
					//ARP_DEBUGOUT("Releasing ARP Entry..\n\r");
					qstruct->state = ARP_FREE;
					continue;
				}
				
				/* Decrease retries left	*/
				
				if( qstruct->retries > 0 )	
					qstruct->retries--;
				
				if( qstruct->retries == 0 )	{
					//ARP_DEBUGOUT("ARP Replies Used up, releasing entry..\n\r");
					qstruct->state = ARP_FREE;
					continue;
				}
				
				/* So we need to resend ARP request	*/
				
				//ARP_DEBUGOUT("Trying to Resolve dynamic ARP Entry..\n\r");
			
				qstruct->ttl = ARP_RESEND;
				arp_send_req( j );
				qstruct->state = ARP_PENDING;				/* Waiting for Reply	*/			
				
				return;
			
			}
		
			/* Do it for Static Entries			*/
		
			if( qstruct->type == ARP_FIXED_IP ) {
				 	
				/* So we need to resend ARP request	*/
				
				/* Do not try to refresh broadcast	*/			
				if(qstruct->pradr == IP_BROADCAST_ADDRESS) 	{
					qstruct->ttl = ARP_TIMEOUT;
					continue;
				}
				if(qstruct->pradr!=localmachine.defgw)
				 {
					//ARP_DEBUGOUT("ARP Replies Used up, releasing entry..\n\r");
					qstruct->state = ARP_FREE;
					continue;
				}
				//ARP_DEBUGOUT("Refreshing Static ARP Entry..\n\r");
				
				if( qstruct->retries > 0 )	
					qstruct->retries--;
				
				if( qstruct->retries == 0 )
					qstruct->state = ARP_PENDING;
				else
					qstruct->state = ARP_REFRESHING;
			
				qstruct->ttl = (6*ARP_RESEND);
				
				arp_send_req( j );
				
				return;
			
			}
		
		}
	
	}


}



/** \brief Initialize data structures for ARP processing
 *	\ingroup core_initializer
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 01.11.2001
 *	\warning 
 *		\li Invoke this function at start-up to properly initialize
 *		ARP cache subsystem.
 *
 *	Call this function to properly initialize ARP cache table and so that
 *	ARP allocates and initializes a timer for it's use.
 */
void arp_init (void)
{
	struct arp_entry *qstruct;
	INT8 i;
	
	//ARP_DEBUGOUT("Initializing ARP");
	
	for( i=0; i<ARP_TSIZE; i++ ) {
		qstruct = &arp_table[i];
		
		qstruct->state = ARP_FREE;
		qstruct->type = ARP_TEMP_IP;
		
		//ARP_DEBUGOUT(".");
	}
	
	arp_timer = get_timer();
	init_timer(arp_timer, ARP_MANG_TOUT*TIMERTIC);

	/* set broadcast entry	*/
	
	qstruct = &arp_table[0];
	qstruct->pradr = IP_BROADCAST_ADDRESS;
	qstruct->state = ARP_RESOLVED;
	qstruct->type = ARP_FIXED_IP;
	qstruct->ttl = ARP_TIMEOUT;
	qstruct->retries = ARP_MAXRETRY;	
	
	for(i=0; i<MAXHWALEN; i++)
		qstruct->hwadr[i] = 0xFF;							
	
	//ARP_DEBUGOUT("\n\r");
	
}
/** \brief Checks if a given IP address belongs to the subnet of a
 		given machine
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 05.11.2001
 *	\param ipadr - IP address under check
 *	\param machine - pointer to configuration of network parameters used
 *	\return
 *		\li #TRUE - ipadr belongs to subnet of given machine
 *		\li #FALSE - ipadr is NOT a part of subnet of given machine 
 *
 *	Based on information supplied in ipadr and machine parameters this
 *	function performs basic check if IP address is on the same subnet as
 *	the one defined for the machine. 
 *
 */
BYTE is_subnet (LWORD ipadr, struct netif* machine)
{

	UINT32 ltemp;

	ltemp = ipadr & machine->netmask;						/* Get Subnet part	*/
	
	ltemp ^= (machine->localip & machine->netmask);			/* Compare to my IP	*/
	
	if( ltemp )
		return(FALSE);
	
	return(TRUE);

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美女精品自拍一二三四| 18欧美乱大交hd1984| 福利一区福利二区| 精品一区二区三区av| 五月天激情综合| 色哟哟精品一区| 精品视频色一区| 91精品国产综合久久精品麻豆| 欧美性猛交xxxxxx富婆| 91精品国产综合久久久蜜臀粉嫩| 日韩欧美一二三| 国产日韩影视精品| 亚洲激情五月婷婷| 亚洲精品乱码久久久久久久久| 日本女人一区二区三区| 午夜精品一区二区三区三上悠亚| 国产精品123| 欧美r级电影在线观看| 国产精品毛片久久久久久| 国产精品久久久久桃色tv| 国产91精品免费| 国产福利一区二区| 欧美日韩精品欧美日韩精品一综合| 日韩欧美国产麻豆| 国产片一区二区三区| 91免费国产在线| 亚洲午夜一区二区三区| 精品亚洲国内自在自线福利| 欧洲一区在线电影| 亚州成人在线电影| 欧美日韩一卡二卡三卡| 免费av网站大全久久| 日本黄色一区二区| 久久91精品久久久久久秒播| 91网站在线观看视频| 国产精品色在线观看| 日韩精品一区二区三区在线| 亚洲视频在线一区二区| 国产精一区二区三区| 亚洲成人精品在线观看| 久久精品亚洲国产奇米99| 爽好久久久欧美精品| 中文字幕精品三区| 欧美丝袜丝nylons| 日韩成人一级片| 亚洲天堂a在线| 欧美三区免费完整视频在线观看| 国模无码大尺度一区二区三区| 亚洲成人av在线电影| 欧美国产精品久久| 欧美一区二区网站| 成人av在线资源网站| 日韩欧美一区二区视频| 成人免费精品视频| 激情都市一区二区| 日本视频在线一区| 日本欧美一区二区三区| 久久久久高清精品| 91麻豆精品国产91久久久久久久久 | 岛国精品在线观看| 久久精品国产99国产精品| 中文字幕一区二区三区四区 | 亚洲一区免费观看| 这里只有精品免费| 91丨porny丨蝌蚪视频| 国产一区二区视频在线播放| 粉嫩一区二区三区在线看| 亚洲日本在线视频观看| 亚洲人妖av一区二区| 亚洲天天做日日做天天谢日日欢| 欧美日韩二区三区| 欧美日韩一区二区在线观看视频| 国产精品一卡二卡| a在线欧美一区| 欧美美女一区二区在线观看| 欧美精品欧美精品系列| 亚洲v日本v欧美v久久精品| 日韩精品亚洲一区| 久久99久久精品| 国产成人免费av在线| 国产美女娇喘av呻吟久久| 国产精品一区二区男女羞羞无遮挡 | 天涯成人国产亚洲精品一区av| 国产精品你懂的在线欣赏| 欧美国产日韩a欧美在线观看| 日韩免费观看2025年上映的电影| 久久在线免费观看| 久久福利视频一区二区| 性做久久久久久久久| 久久99国产精品麻豆| 国产白丝精品91爽爽久久| 久久久一区二区| 亚洲色欲色欲www在线观看| 亚洲欧美日韩一区二区 | 欧美区一区二区三区| 91麻豆精品一区二区三区| 91精品欧美综合在线观看最新| 欧美理论片在线| 欧美韩国日本不卡| 午夜国产不卡在线观看视频| 亚洲午夜一区二区三区| 日韩精品一区二区三区蜜臀 | 亚洲福利视频三区| 洋洋av久久久久久久一区| 六月丁香婷婷久久| 99re8在线精品视频免费播放| 专区另类欧美日韩| 91免费在线视频观看| 一区二区三区**美女毛片| 国产一区二区三区四区五区美女 | 99久久精品费精品国产一区二区| 精品精品国产高清一毛片一天堂| 亚洲最大的成人av| 欧美亚洲另类激情小说| 91精品欧美综合在线观看最新| 日韩高清国产一区在线| 欧美日本一道本在线视频| 亚洲图片激情小说| 在线电影国产精品| 成人福利视频在线看| 久久久九九九九| 国产精品一区二区91| 26uuu色噜噜精品一区二区| 亚洲福利一二三区| 91精品国产欧美一区二区成人| 精品在线播放午夜| 久久久久88色偷偷免费| 91精选在线观看| 色噜噜偷拍精品综合在线| 日本成人中文字幕| 中文久久乱码一区二区| 国产人成一区二区三区影院| 欧美精品tushy高清| 91国产丝袜在线播放| 国产成人精品一区二区三区四区 | 午夜不卡在线视频| 欧美日韩国产一区| 婷婷成人激情在线网| 亚洲精品一区二区三区精华液| 成人黄色综合网站| 亚洲国产一区二区在线播放| 亚洲国产精品精华液ab| 99久久精品免费观看| 男女男精品视频| 亚洲综合久久久久| 国产91色综合久久免费分享| 免费成人深夜小野草| 国产成人aaaa| 日本少妇一区二区| 午夜精品福利一区二区三区av| 欧美xxx久久| 欧美日本国产视频| 九色综合国产一区二区三区| 日韩av一级片| 精品一区二区三区久久| 天天色天天爱天天射综合| 国产精品久久久久永久免费观看| 色噜噜狠狠色综合欧洲selulu| 99国内精品久久| 欧美手机在线视频| 久久久精品国产免大香伊 | 久久99久久久欧美国产| 日韩专区一卡二卡| 久久精品国产精品亚洲综合| 国产在线观看免费一区| 丁香六月综合激情| 国产精品久久久久9999吃药| 日韩理论片网站| 免费成人结看片| 日韩中文字幕不卡| 国产精品一区二区无线| 欧美中文字幕不卡| 日韩码欧中文字| 国产日韩视频一区二区三区| 裸体一区二区三区| 国产精品乱码一区二三区小蝌蚪| 18涩涩午夜精品.www| 成人精品在线视频观看| 欧美日本在线播放| 日韩av在线播放中文字幕| 国产精品综合二区| 26uuu国产在线精品一区二区| 97精品国产露脸对白| 免费在线观看一区| 国产精品一级黄| 91香蕉视频黄| 成人国产一区二区三区精品| 欧美三级韩国三级日本三斤| 久久综合九色综合欧美98| 337p粉嫩大胆噜噜噜噜噜91av| 国产精品国产三级国产专播品爱网| 国产馆精品极品| 亚洲精品一区二区三区影院| 成人夜色视频网站在线观看| 欧美日韩国产美| 国产原创一区二区三区| 中文字幕中文乱码欧美一区二区| 欧美色视频在线观看| 日韩高清国产一区在线| 天堂影院一区二区|