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

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

?? arp.c

?? 用于以太網開發
?? C
?? 第 1 頁 / 共 2 頁
字號:
	/* 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;
				}
				
				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 = 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一区二区三区免费野_久草精品视频
欧美精品一区二区久久婷婷| 国产成人自拍网| 91蜜桃传媒精品久久久一区二区| 中文字幕不卡三区| 国产成人鲁色资源国产91色综| 亚洲精品一区二区三区福利| 美女www一区二区| 日韩精品一区二区三区在线| 久久99精品久久久久久| 久久综合色之久久综合| 国产伦精品一区二区三区免费| 久久日一线二线三线suv| 国产激情一区二区三区桃花岛亚洲| 久久免费看少妇高潮| 成人avav在线| 亚洲最新视频在线播放| 欧美精品日日鲁夜夜添| 久久精品国产第一区二区三区| 久久综合五月天婷婷伊人| 成人中文字幕合集| 亚洲精品国产成人久久av盗摄| 欧美三级日韩在线| 国内成人自拍视频| 亚洲精品乱码久久久久| 欧美精品色综合| 国产精品亚洲第一区在线暖暖韩国| 国产精品乱码一区二区三区软件 | 一本一道久久a久久精品| 亚洲黄色性网站| 日韩欧美在线影院| av午夜一区麻豆| 日本午夜一区二区| 日韩码欧中文字| 日韩欧美中文字幕公布| 91免费观看视频在线| 看片的网站亚洲| 亚洲女子a中天字幕| 日韩精品一区二| 91国产精品成人| 国产九色sp调教91| 亚洲a一区二区| 国产午夜亚洲精品午夜鲁丝片| 欧美在线色视频| 国产精品一卡二卡| 日韩精品乱码免费| 亚洲视频在线一区观看| 精品理论电影在线| 欧美性受xxxx黑人xyx| 国产成人免费高清| 美女任你摸久久| 亚洲国产精品嫩草影院| 国产精品久久毛片av大全日韩| 3atv在线一区二区三区| 91片黄在线观看| 成人手机电影网| 精一区二区三区| 五月激情综合婷婷| 亚洲欧美另类小说| 国产精品久久夜| 亚洲国产精品二十页| 精品欧美久久久| 欧美肥妇毛茸茸| 在线国产亚洲欧美| 99精品在线观看视频| 高清国产一区二区| 国产一区二区91| 久久国产精品第一页| 午夜国产精品一区| 亚洲一区二区免费视频| 亚洲人吸女人奶水| 亚洲欧洲av在线| 国产精品无圣光一区二区| 精品国产亚洲在线| 欧美mv日韩mv亚洲| 日韩一区二区在线观看视频播放| 在线精品亚洲一区二区不卡| 色哟哟在线观看一区二区三区| av网站免费线看精品| av一二三不卡影片| 一本到三区不卡视频| 9久草视频在线视频精品| 成人精品一区二区三区中文字幕| 国产精品综合网| 国产精品一区二区久久精品爱涩 | 911精品国产一区二区在线| 欧美在线视频不卡| 91麻豆精品久久久久蜜臀 | 日韩久久免费av| 日韩精品自拍偷拍| 26uuu国产日韩综合| 久久嫩草精品久久久久| 国产午夜精品在线观看| 国产欧美中文在线| 成人欧美一区二区三区小说| 一区二区三区不卡视频在线观看| 洋洋成人永久网站入口| 全部av―极品视觉盛宴亚洲| 久久成人av少妇免费| 国产精品中文字幕日韩精品 | 国产乱理伦片在线观看夜一区| 粉嫩久久99精品久久久久久夜| eeuss鲁片一区二区三区在线看| 91偷拍与自偷拍精品| 欧美性色黄大片| 日韩一级免费一区| 欧美高清一级片在线观看| 亚洲人成在线播放网站岛国 | 麻豆极品一区二区三区| 韩国av一区二区三区在线观看| 成人丝袜高跟foot| 欧美视频中文字幕| 亚洲精品一区二区精华| 亚洲素人一区二区| 人人精品人人爱| 国产91在线看| 在线亚洲一区观看| 精品久久久久久最新网址| 国产精品视频yy9299一区| 亚洲图片欧美色图| 国产乱淫av一区二区三区| 色综合久久久久网| 久久青草欧美一区二区三区| 亚洲欧洲美洲综合色网| 日本亚洲视频在线| 972aa.com艺术欧美| 欧美一三区三区四区免费在线看| 国产亚洲午夜高清国产拍精品| 亚洲人123区| 极品销魂美女一区二区三区| 91美女片黄在线观看| 精品国内二区三区| 亚洲午夜精品在线| 成人网在线免费视频| 欧美大片一区二区三区| 自拍偷自拍亚洲精品播放| 美女免费视频一区二区| 91黄色免费版| 国产欧美日韩在线观看| 日本少妇一区二区| 色哟哟在线观看一区二区三区| 2022国产精品视频| 日韩精品色哟哟| 色呦呦国产精品| 欧美嫩在线观看| 亚洲美女免费视频| 懂色中文一区二区在线播放| 欧美一区二区三区免费观看视频 | 欧美在线观看18| 国产精品嫩草久久久久| 久久99精品国产麻豆不卡| 欧美日韩的一区二区| 最新日韩在线视频| 成熟亚洲日本毛茸茸凸凹| 精品少妇一区二区三区日产乱码| 午夜亚洲国产au精品一区二区| 色综合久久综合| 国产精品女主播在线观看| 狠狠狠色丁香婷婷综合激情| 欧美一区二区三区婷婷月色| 亚洲一级在线观看| 色噜噜狠狠色综合欧洲selulu| 国产精品久久久久久妇女6080| 国产专区欧美精品| 日韩欧美二区三区| 日本一区中文字幕| 制服丝袜在线91| 亚洲444eee在线观看| 91黄色免费版| 亚洲午夜久久久久久久久电影网 | 亚洲少妇屁股交4| 波多野结衣91| 日韩美女视频19| 色视频欧美一区二区三区| 日韩一区在线看| 色综合久久久久久久久久久| 亚洲人午夜精品天堂一二香蕉| 一本久道中文字幕精品亚洲嫩| 亚洲精品免费一二三区| 欧美三级日韩三级| 午夜视频一区在线观看| 欧美一区欧美二区| 精品在线一区二区三区| 精品日韩成人av| 粉嫩嫩av羞羞动漫久久久| 国产精品青草久久| 日本久久一区二区| 亚洲高清视频的网址| 制服丝袜一区二区三区| 国产一区二区三区日韩 | 亚洲乱码日产精品bd| 色综合久久久网| 日韩高清不卡一区| 精品国产乱码久久久久久蜜臀| 国产精品中文有码| 中文字幕一区二区三区不卡 | 色综合色综合色综合 | 亚洲精品高清在线| 91精品国产欧美一区二区成人| 国产精品一区二区你懂的| 亚洲欧美综合另类在线卡通|