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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? arp.c

?? 用于以太網(wǎng)開(kāi)發(fā)
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
#include <datatypes.h>
#include <debug.h>
#include <ethernet.h>
#include <arp.h>
#include <timers.h>
#include <system.h>
#include <globalvariables.h>

/** \brief ARP cache table holding ARP_TSIZE cache values 
 *
 *	ARP cache table is an array of arp_entry structures holding
 *	all of the necessary information about the state, timeouts and
 *	hardware/IP addresses of individual entries. By modifying the
 *	#ARP_TSIZE, cache size can be changed and thus RAM memory occupied
 *	by the ARP cache significantly reduced or increased. See arp_entry
 *	definition for more information about struct fields.
 */
struct arp_entry	arp_table[ARP_TSIZE]; 

/** \brief ARP timer handle used for measuring timeouts, doing retransmissions,..
 *	
 *	ARP module uses this timer handle to detect that a certain period of
 *	time has expired (defined by the value of #ARP_MANG_TOUT) and that
 *	cache entries should be examined to see what to do with them.
 */
UINT8 arp_timer; 

/** \brief Process and analyze the received ARP packet
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	
 *	\date 10.07.2002
 *	\param frame Pointer to ethernet_frame structure containing information
 *		about the received frame
 *	\return Return #TRUE if Ethernet frame processed held ARP packet,
 *		otherwise #FALSE.
 *
 *	Invoke process_arp function whenever ARP packet is received 
 *	(see main_demo.c for an example loop). This function will process the
 *	received packet, analyze it'c content briefly and perform on of the
 *	two possible actions:
 *		\li If the received packet is ARP request it will invoke
 *		arp_send_reply in order to send ARP reply back
 *		\li If the received packet is ARP response it will iterate through
 *		the cache table and try to find ARP entry that is beeing resolved
 *		or refreshed
 */
UINT8 process_arp (struct ethernet_frame* frame) 
{
	
	UINT8 temp;		
	
	/* Check if ARP packet*/
	
	if( frame->protocol == ARP_ETHCODE ) 
	{
		/* Yep, ARP */
		
		NETWORK_RECEIVE_INITIALIZE(frame->buf_index);
		
		/* Is it long enough?	*/
		
		if( frame->frame_size < (2*MAXHWALEN + 2*MAXPRALEN + 2 + 6) ) 
		{
			/* Somehow corrupted ARP packet	*/
			ARP_DEBUGOUT("Corrupted ARP packet\n\r");
			return(TRUE);
		}
			 
		
		/* Ignore next 6 bytes: <HW type>, <Protocol type> */
		/* <HW address len> and <Protocol address len> 	   */
		
		for(temp=0; temp<6; temp++)
			RECEIVE_NETWORK_B();
		
		ARP_DEBUGOUT("Incoming ARP..\n\r");
		
		/* Check if request or response */
		
		if( RECEIVE_NETWORK_B() == 0x00) 
		{
		
			temp = RECEIVE_NETWORK_B();	/* get opcode */
		
			if( temp == ARP_REQUEST ) {
				ARP_DEBUGOUT(" ARP REQUEST Received..\n\r");
				arp_send_response();
			} else if( temp == ARP_REPLY ) {
				ARP_DEBUGOUT("ARP Response Received..\n\r");
				arp_get_response();	
			}
			
		/* Wasn't request or response or all done, dump it */
		
		}
		
		/*NETWORK_RECEIVE_END();*/
		return(TRUE);
		
	}
	
	/* Wasn't ARP, don't touch the packet */
	
	return(FALSE);								
}

/** \brief Send response to an ARP request
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 10.07.2002
 *	\warning
 *		\li This function starts reading data from Ethernet controller
 *		without initializing it for reading it first, so NIC must already
 *		be initialized for reading from correct address (it expects ar$sha
 *		field from ARP packet immediately)
 *
 *	This function is invoked from process_arp() function in order to send
 *	a reply to an ARP request. First, incoming packet is checked to see
 *	if it is intended for us or not. If not, function does not do anything.
 *	Otherwise, ARP reply packet is formed and sent.
 */
void arp_send_response(void)
{
	struct arp_entry *qstruct;
	UINT8 rem_hwadr[MAXHWALEN];
	UINT32 rem_ip;
	UINT32 ltemp;
	INT8 i;
	BYTE j;

	/* Record Sender's HW address		*/
	
	for( i=0; i<MAXHWALEN; i++) 
		rem_hwadr[i] = RECEIVE_NETWORK_B();		
	
	/* Read Sender's IP Address	*/
	
	for( i=0; i<MAXPRALEN; i++) {
		rem_ip <<= 8;
		rem_ip |= RECEIVE_NETWORK_B();
	} 
	
	
	/* Skip Target HW address		*/
	
	RECEIVE_NETWORK_B();
	RECEIVE_NETWORK_B();
	RECEIVE_NETWORK_B();
	RECEIVE_NETWORK_B();
	RECEIVE_NETWORK_B();
	RECEIVE_NETWORK_B();	
	
	/* Is The Packet For Us?	*/
	
	for( i=0; i<MAXPRALEN; i++) {
		ltemp <<= 8;
		ltemp |= RECEIVE_NETWORK_B();
	}
		
	
	if( ltemp != localmachine.localip ) 
		return;								/* No	*/

	ARP_DEBUGOUT("Preparing for ARP Reply\n\r");
	
	/* OK. Now send reply		*/
	
	NETWORK_SEND_INITIALIZE(ARP_BUFFER);
	
	/* Add datalink (Ethernet addresses) information	*/
	
	for( i=0; i<MAXHWALEN; i++)	{
		send_frame.destination[i] = rem_hwadr[i];
		send_frame.source[i] = localmachine.localHW[i];
	}
	
	send_frame.protocol = PROTOCOL_ARP;
	
	NETWORK_ADD_DATALINK(&send_frame);
	
	/* PUT ARP Data	*/
	
	SEND_NETWORK_B( (BYTE)(AR_HARDWARE>>8) );				/* Hardware Type	*/
	SEND_NETWORK_B( (BYTE)AR_HARDWARE );
	SEND_NETWORK_B(0x08);									/* Protocol Type	*/
	SEND_NETWORK_B(0x00);
	SEND_NETWORK_B(MAXHWALEN);								/* HW Adr Len		*/
	SEND_NETWORK_B(MAXPRALEN);								/* Protocol Adr. Len*/
	SEND_NETWORK_B( 0x00 );									/* ARP Opcode		*/	
	SEND_NETWORK_B( 0x02 );					
	SEND_NETWORK_B((UINT8)(localmachine.localHW[0]));		/* Address fields	*/
	SEND_NETWORK_B((UINT8)(localmachine.localHW[1]));
	SEND_NETWORK_B((UINT8)(localmachine.localHW[2]));
	SEND_NETWORK_B((UINT8)(localmachine.localHW[3]));
	SEND_NETWORK_B((UINT8)(localmachine.localHW[4]));
	SEND_NETWORK_B((UINT8)(localmachine.localHW[5]));

	SEND_NETWORK_B((UINT8)(localmachine.localip>>24));
	SEND_NETWORK_B((UINT8)(localmachine.localip>>16));
	SEND_NETWORK_B((UINT8)(localmachine.localip>>8));
	SEND_NETWORK_B((UINT8)(localmachine.localip));
	SEND_NETWORK_B((UINT8)rem_hwadr[0]);
	SEND_NETWORK_B((UINT8)rem_hwadr[1]);
	SEND_NETWORK_B((UINT8)rem_hwadr[2]);
	SEND_NETWORK_B((UINT8)rem_hwadr[3]);
	SEND_NETWORK_B((UINT8)rem_hwadr[4]);
	SEND_NETWORK_B((UINT8)rem_hwadr[5]);						
	SEND_NETWORK_B((UINT8)(rem_ip>>24));
	SEND_NETWORK_B((UINT8)(rem_ip>>16));
	SEND_NETWORK_B((UINT8)(rem_ip>>8));
	SEND_NETWORK_B((UINT8)rem_ip);
	
	NETWORK_COMPLETE_SEND(0x0040);		/* Send the packet	*/
	
	ARP_DEBUGOUT("ARP Reply Sent..\n\r");
	
	/* Add the Sender's info to cache because we can	*/
	
	arp_add(rem_ip, &send_frame.destination[0], ARP_TEMP_IP);
	
	return;
		
}


/** \brief Extract data from the received ARP packet
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 10.07.2002
 *	\warning
 *		\li This function starts reading data from Ethernet controller
 *		without initializing it for reading it first, so NIC must already
 *		be initialized for reading from correct address (it expects ar$sha
 *		field from ARP packet immediately)
 *
 *	This function is invoked from process_arp() function when ARP reply
 *	packet is detected. Basic checking is performed to see if the packet
 *	is intended for us, and if it is, ARP cache table is checked and 
 *	corresponding entry is refreshed (resolved).
 *
 */
void arp_get_response(void)
{
	struct arp_entry *qstruct;
	UINT8   rem_hwadr[MAXHWALEN];
	UINT32 	rem_ip = 0;
	UINT32 	ltemp  = 0;
	INT8    i;
	UINT8   j;
	
	/* Read Sender's HW address	*/
	
	for( i=0; i<MAXHWALEN; i++) 
		rem_hwadr[i] = RECEIVE_NETWORK_B();
		
	/* Read Sender's IP Address	*/
	
	for( i=0; i<MAXPRALEN; i++) 
	{
		rem_ip <<= 8;
		rem_ip |= RECEIVE_NETWORK_B();
	}
	
	
	/* Skip our HW Address	*/
	
	for(i=0; i<MAXHWALEN; i++)
		RECEIVE_NETWORK_B();
	
	
	/* Is The Packet For Us?	*/
	
	for( i=0; i<MAXPRALEN; i++)	
	{
		ltemp <<= 8;
		ltemp |= RECEIVE_NETWORK_B();
	}
		
	
	if( ltemp != localmachine.localip ) 
		return;								/* No	*/

	ARP_DEBUGOUT("Now entering to process ARP Reply..\n\r");
	
	/* Are we waiting for that reply?	*/
	
	for( i=1; i<ARP_TSIZE; i++ ) 
	{
		qstruct = &arp_table[i];
		
		if( qstruct->state == ARP_FREE )
			continue;
		
		if( qstruct->state == ARP_RESERVED )
			continue;				
		
		if( rem_ip == qstruct->pradr ) 
		{
			/* We are caching that IP, refresh it	*/
			
			ARP_DEBUGOUT("Refreshing ARP cache from Reply..\n\r");
			
			for( j=0; j<MAXHWALEN; j++ )		
				qstruct->hwadr[j] = rem_hwadr[j];
				
			qstruct->ttl = ARP_TIMEOUT;
			qstruct->retries = ARP_MAXRETRY;				/* No need for Retry	*/
			qstruct->state = ARP_RESOLVED;
		
			/* Done	*/
			
			break;
		}	
	
	}

}

/** \brief Send ARP request based on information in an ARP cache table
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 1.11.2001
 *	\param entry Index of ARP cache entry that is beeing resolved
 * 
 *	Invoked from arp_find() and arp_manage() functions, arp_send_request
 *	creates ARP request packet based on data stored in the ARP cache entry
 *	who's index is given as a parameter.
 */
void arp_send_req (UINT8 entry)
{

	struct arp_entry *qstruct;
	UINT8 i;
	
	qstruct = &arp_table[entry];
	
	NETWORK_SEND_INITIALIZE(ARP_BUFFER);
	
	/* Add datalink (Ethernet addresses) information	*/
	
	for( i=0; i<MAXHWALEN; i++) {
		send_frame.destination[i] = 0xFF;
		send_frame.source[i] = localmachine.localHW[i];
		
	}
	
	
	
	send_frame.protocol = PROTOCOL_ARP;
	
	NETWORK_ADD_DATALINK(&send_frame);
	
	/* PUT ARP Data	*/

	SEND_NETWORK_B( (BYTE) (AR_HARDWARE>>8) );			/* Hardware Type	*/
	SEND_NETWORK_B( (BYTE) AR_HARDWARE );
	SEND_NETWORK_B(0x08);								/* Protocol Type	*/
	SEND_NETWORK_B(0x00);
	SEND_NETWORK_B(MAXHWALEN);							/* HW Adr Len		*/
	SEND_NETWORK_B(MAXPRALEN);							/* Protocol Adr. Len*/
	SEND_NETWORK_B( (BYTE)(ARP_REQUEST>>8));			/* ARP Opcode		*/
	SEND_NETWORK_B( (BYTE) ARP_REQUEST );
	
	SEND_NETWORK_B((UINT8)localmachine.localHW[0]);		
	SEND_NETWORK_B((UINT8)localmachine.localHW[1]);
	SEND_NETWORK_B((UINT8)localmachine.localHW[2]);
	SEND_NETWORK_B((UINT8)localmachine.localHW[3]);
	SEND_NETWORK_B((UINT8)localmachine.localHW[4]);
	SEND_NETWORK_B((UINT8)localmachine.localHW[5]);	
	
	SEND_NETWORK_B((UINT8)(localmachine.localip>>24));
	SEND_NETWORK_B((UINT8)(localmachine.localip>>16));
	SEND_NETWORK_B((UINT8)(localmachine.localip>>8));
	SEND_NETWORK_B((UINT8)localmachine.localip);
	SEND_NETWORK_B((UINT8)0xFF);
	SEND_NETWORK_B((UINT8)0xFF);
	SEND_NETWORK_B((UINT8)0xFF);
	SEND_NETWORK_B((UINT8)0xFF);
	SEND_NETWORK_B((UINT8)0xFF);
	SEND_NETWORK_B((UINT8)0xFF);						
	SEND_NETWORK_B((UINT8)(qstruct->pradr>>24));
	SEND_NETWORK_B((UINT8)(qstruct->pradr>>16));
	SEND_NETWORK_B((UINT8)(qstruct->pradr>>8));
	SEND_NETWORK_B((UINT8)qstruct->pradr);
	
	
	/* Packet assembled now, just send it ... */
	
	NETWORK_COMPLETE_SEND(0x0040);						/* Min packet size	*/
 
 	ARP_DEBUGOUT("ARP Request Sent\n\r");
	
}


/** \brief Allocate ARP entry in ARP cache table
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 1.11.2001
 *	\param type Type of ARP cache entry beeing allocated. Can be one of the
 *		following:
 *		\li #ARP_FIXED_IP
 *		\li #ARP_TEMP_IP 
 *	\return >=0 - pointer to allocated ARP entry (actaully index in the 
 *		ARP cache table)
 * 
 *	Allocate arp entry for given type. Chooses the unused entry if 
 *	one exists. Otherwice deletes entries in round-robin fashion.
 */
INT8 arp_alloc (UINT8 type)
{
	struct arp_entry *qstruct;
	INT8 i;
	static BYTE aenext = 1;		/* Cache Manager	*/
	INT16 found;
	
	/* try to find free entry */
	found=-1;

	for( i=0; i<ARP_TSIZE; i++ ) {
	
		if( arp_table[i].state == ARP_FREE ) {
			found=i;
			break;
		}
	}
	
	if(found != (-1) ) {
		qstruct = &arp_table[found];
		qstruct->state = ARP_RESERVED;
		qstruct->type = type;	
		return( (UINT8)found );
	}


	/* if no success, try ro find first temporary entry	*/
	/* on round-robin fashion							*/
	

	for( i=0; i<ARP_TSIZE; i++ ) {	
		if( arp_table[aenext].type == ARP_TEMP_IP) {
			found = aenext;			
			break;
		}
			
		/* Move to next entry */
	
		aenext = (aenext + 1);
		if( aenext >= ARP_TSIZE )
			aenext = 1;
			
	}
	
	
	/* Was there free or temporary entries?	*/
	
	if( found == (-1) )
		return(-1);
		

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产亚洲一区二区三区| 国产一区二区影院| 喷水一区二区三区| 国产精品一区二区91| 99久久综合99久久综合网站| 在线观看中文字幕不卡| 欧美一级在线观看| 日韩一区在线免费观看| 舔着乳尖日韩一区| 国产精品一区二区久激情瑜伽| 91欧美一区二区| 日韩免费在线观看| 综合久久久久久久| 蜜臀国产一区二区三区在线播放| 丁香五精品蜜臀久久久久99网站| 欧美在线影院一区二区| 久久久久国产精品厨房| 夜夜嗨av一区二区三区网页 | av影院午夜一区| 欧美男生操女生| 国产精品私人影院| 日本成人在线电影网| av一二三不卡影片| 日韩精品一区二区三区视频播放| 国产精品超碰97尤物18| 热久久国产精品| 91美女片黄在线| 精品国产电影一区二区| 亚洲一区在线视频| 高清不卡一区二区| 日韩精品一区二区三区中文精品| 成人免费小视频| 精品中文av资源站在线观看| 欧美自拍偷拍午夜视频| 欧美激情一区二区三区| 蜜臀av国产精品久久久久 | 1024国产精品| 精品一区二区影视| 欧美日韩免费高清一区色橹橹| 国产精品色在线观看| 免费日本视频一区| 一本大道久久精品懂色aⅴ| 欧美激情综合五月色丁香 | 精品日韩99亚洲| 一区二区三区日本| 97精品国产露脸对白| 亚洲精品在线免费播放| 午夜精品爽啪视频| 欧美色男人天堂| ...xxx性欧美| 国产精品亚洲成人| 欧美精品一区男女天堂| 日本一区中文字幕| 欧美日韩成人在线一区| 亚洲图片欧美视频| 色婷婷久久综合| 亚洲视频一区在线观看| 成人性生交大合| 国产午夜精品一区二区三区四区| 麻豆精品一区二区av白丝在线| 欧美日韩一区不卡| 亚洲综合一区二区| 色综合中文字幕国产 | 国产成人午夜精品影院观看视频| 精品免费国产一区二区三区四区| 日韩中文字幕91| 欧美人体做爰大胆视频| 亚洲成av人片观看| 欧美三级电影在线观看| 一区二区三区在线观看视频| 色综合久久久久久久久| 一区二区三区四区视频精品免费 | 午夜精品久久久久久久| 欧美高清视频一二三区| 视频在线观看91| 欧美一区二区在线看| 日本视频免费一区| 亚洲精品一区二区三区在线观看| 久久成人免费网站| 久久久www成人免费无遮挡大片| 国产激情视频一区二区在线观看 | 色综合中文字幕国产 | 欧美一区二区三区小说| 天使萌一区二区三区免费观看| 欧美色窝79yyyycom| 亚洲第一福利视频在线| 6080午夜不卡| 久久狠狠亚洲综合| 久久精品免费在线观看| 成人毛片在线观看| 亚洲色图制服丝袜| 欧美无人高清视频在线观看| 天天综合日日夜夜精品| 日韩欧美三级在线| 成人亚洲一区二区一| 亚洲精品成人在线| 欧美日韩第一区日日骚| 精品一区二区三区免费视频| 久久精品在线观看| 99久久精品久久久久久清纯| 亚洲激情图片一区| 欧美一区二区性放荡片| 国产一区二区0| 亚洲天堂av一区| 欧美日韩高清一区| 国产风韵犹存在线视精品| 综合网在线视频| 538prom精品视频线放| 国精产品一区一区三区mba桃花| 国产精品女同互慰在线看| 在线一区二区视频| 久久99精品久久久| 一色屋精品亚洲香蕉网站| 欧美日韩一级二级三级| 精品在线一区二区三区| 一区在线观看免费| 日韩三级中文字幕| 成人理论电影网| 五月婷婷综合在线| 久久久久成人黄色影片| 欧美性猛交xxxx黑人交 | 国产精品久久久久影视| 欧美熟乱第一页| 国产不卡在线视频| 午夜欧美视频在线观看| 国产亚洲婷婷免费| 精品视频免费在线| 国产成+人+日韩+欧美+亚洲| 婷婷夜色潮精品综合在线| 久久精品一区二区三区不卡牛牛 | 青青草视频一区| 中文字幕日韩一区| 欧美变态口味重另类| 色噜噜狠狠色综合中国| 国产专区综合网| 亚洲电影中文字幕在线观看| 欧美国产一区在线| 欧美一区二区三区在线观看视频 | 午夜国产精品影院在线观看| 国产欧美一区视频| 欧美一级日韩不卡播放免费| 99re这里只有精品视频首页| 激情久久久久久久久久久久久久久久| 亚洲日本在线观看| 久久久久久久久久久久久夜| 91精品国产一区二区三区| 91美女在线观看| 成人午夜视频在线观看| 久久精品二区亚洲w码| 亚洲国产你懂的| 综合分类小说区另类春色亚洲小说欧美| 日韩一区二区不卡| 欧美视频三区在线播放| 色综合色综合色综合| 国产99精品在线观看| 久久99久久久久| 日韩黄色在线观看| 亚洲一区二区三区四区中文字幕| 国产精品久久久一区麻豆最新章节| 欧美白人最猛性xxxxx69交| 欧美日韩久久久| 色88888久久久久久影院按摩 | 亚洲精品日韩一| 国产精品美日韩| 国产精品天美传媒沈樵| 久久久夜色精品亚洲| 欧美xxx久久| 日韩一区二区不卡| 日韩亚洲电影在线| 91精品国产欧美一区二区| 欧美日韩中文字幕精品| 欧美三级蜜桃2在线观看| 欧美中文字幕久久 | 青青草国产成人av片免费| 天堂蜜桃一区二区三区| 日韩国产精品大片| 石原莉奈一区二区三区在线观看| 亚洲一二三四区| 亚洲一区二区av在线| 一区二区国产视频| 亚洲一区在线看| 午夜精品久久久久久久99水蜜桃| 性做久久久久久免费观看 | 欧美va亚洲va香蕉在线| 91精品国产欧美一区二区18 | 国产高清不卡二三区| 国产成人一区在线| 国产suv一区二区三区88区| 国产成人av福利| 成人性生交大片免费| 99免费精品在线观看| 在线视频国产一区| 欧美日韩一区二区三区不卡| 91精品国产乱| 欧美成人三级电影在线| 久久免费午夜影院| 国产精品五月天| 亚洲免费观看高清完整版在线观看熊 | 日韩精品一区第一页| 免费的成人av|