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

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

?? arp.c

?? 在freescale 的ne64上開發(fā)的源代碼
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
#include "debug.h"
#include "ethernet.h"
#include "arp.h"
#include "timers.h"
#include "ip.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;

  j=0;
  qstruct=0;

	/* 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		*/
	
	(void)RECEIVE_NETWORK_B();
	(void)RECEIVE_NETWORK_B();
	(void)RECEIVE_NETWORK_B();
	(void)RECEIVE_NETWORK_B();
	(void)RECEIVE_NETWORK_B();
	(void)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;
	
	#if 1 /*zhengch*/
	send_frame.sendFrameType = UNICAST_FRAME;
	//send_frame.tagFlag =received_frame.tagFlag;
	#endif
	
#pragma MESSAGE DISABLE C1825		//Warning: indirection
	NETWORK_ADD_DATALINK(&send_frame);
#pragma MESSAGE DEFAULT C1825		//Warning: indirection       
	
	/* 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(0x001C);		/* Send the packet	*/
	
	//ARP_DEBUGOUT("ARP Reply Sent..\n\r");
	
	/* Add the Sender's info to cache because we can	*/
	
	(void)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;

	#if 1 /*zhengch*/
	send_frame.sendFrameType = UNICAST_FRAME;
	//send_frame.tagFlag =received_frame.tagFlag;
	#endif
	
#pragma MESSAGE DISABLE C1825		//Warning: indirection
	NETWORK_ADD_DATALINK(&send_frame);
#pragma MESSAGE WARNING C1825		//Warning: indirection       
	
	/* 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(0x001C);						/* 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;
			
	}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
热久久一区二区| 欧美婷婷六月丁香综合色| 成人国产精品视频| 一本大道av伊人久久综合| 色天天综合久久久久综合片| 欧美三级乱人伦电影| 亚洲综合成人在线视频| 亚洲成av人在线观看| 日韩av电影一区| 国产成人欧美日韩在线电影| 99久久综合国产精品| 成人av在线影院| 欧美揉bbbbb揉bbbbb| 欧美刺激脚交jootjob| 日韩欧美电影在线| 欧美高清在线视频| 一区二区三区四区五区视频在线观看| 视频一区国产视频| 国产精品亚洲第一区在线暖暖韩国| 成人一级视频在线观看| 欧美日韩中文另类| 成人免费在线播放视频| 国产精品国产三级国产a| 一区二区三区日韩欧美精品| 日本成人在线网站| 成人黄色av网站在线| 91精品免费在线| 国产欧美视频一区二区三区| 天堂资源在线中文精品| 国产成人午夜高潮毛片| 色婷婷激情久久| 久久丝袜美腿综合| 亚洲一区二区视频在线| 国产在线播精品第三| 欧美日韩国产首页在线观看| 国产欧美一区在线| 亚洲h精品动漫在线观看| 国产成人免费av在线| 欧美日韩高清影院| 亚洲精品在线一区二区| 亚洲香肠在线观看| 粉嫩aⅴ一区二区三区四区| 欧美精品一二三区| 国产精品电影一区二区| 久久99这里只有精品| 欧美久久一区二区| 成人免费在线播放视频| 精品亚洲成a人在线观看| 欧美色网一区二区| 国产精品久久久久久久久久免费看 | 91在线云播放| 国产日韩av一区| 热久久免费视频| 成人性生交大片免费看中文网站| 欧美xxxxxxxxx| 亚洲国产精品久久艾草纯爱| 色婷婷综合久色| 国产精品久久久久aaaa樱花| 美女国产一区二区| 91精品婷婷国产综合久久性色| 亚洲人成网站影音先锋播放| 国模无码大尺度一区二区三区| 91精品国产入口在线| 亚洲综合免费观看高清完整版| 91女神在线视频| 国产亚洲成av人在线观看导航| 美洲天堂一区二卡三卡四卡视频| 欧美日本一区二区在线观看| 一区二区三区免费观看| 国产成人小视频| 久久久九九九九| 狠狠色综合色综合网络| 精品久久久久av影院| 蜜臀99久久精品久久久久久软件| 91福利视频久久久久| 综合久久综合久久| 成人午夜精品在线| 国产精品国产自产拍高清av| 大陆成人av片| 国产精品水嫩水嫩| 欧美三级欧美一级| 亚洲国产成人av网| 欧美高清视频一二三区 | 日韩一区二区不卡| 天堂成人国产精品一区| 欧美午夜在线一二页| 亚洲精品久久久蜜桃| 色婷婷综合久久久中文一区二区| 亚洲精品国产精品乱码不99| 色综合中文字幕国产 | 亚洲成人午夜电影| 欧美伊人久久久久久久久影院| 亚洲一区在线观看视频| 色综合久久久久久久| 亚洲mv在线观看| 91精品国产91久久久久久一区二区| 亚洲精品中文字幕乱码三区| 91麻豆产精品久久久久久| 亚洲另类在线一区| 欧美精品亚洲一区二区在线播放| 日本欧美韩国一区三区| 欧美精品第一页| 国产米奇在线777精品观看| 久久久777精品电影网影网| 99久久精品国产一区| 有码一区二区三区| 欧美精品在线观看一区二区| 韩国av一区二区三区四区| 国产免费成人在线视频| 在线视频一区二区三| 丝瓜av网站精品一区二区| 在线91免费看| 国产美女精品人人做人人爽| 中文字幕在线一区二区三区| 欧美日韩一二区| 国内精品久久久久影院一蜜桃| 精品国产一区久久| 91原创在线视频| 午夜精品免费在线观看| 久久久五月婷婷| 91亚洲精品乱码久久久久久蜜桃 | 白白色 亚洲乱淫| 亚洲视频在线一区| 日韩欧美的一区| av电影天堂一区二区在线观看| 亚洲国产毛片aaaaa无费看| 日韩视频在线永久播放| 欧美aaaaaa午夜精品| 最新热久久免费视频| 欧美欧美欧美欧美| 成人免费va视频| 亚洲国产日韩一级| 中文字幕成人av| 欧美性猛片xxxx免费看久爱| 精品一区精品二区高清| 一区二区三区四区在线免费观看| 日韩一区二区三区在线观看| 国产成人啪免费观看软件| 亚洲精品欧美专区| 久久亚洲二区三区| 色伊人久久综合中文字幕| 国产麻豆91精品| 亚洲成人7777| 亚洲色图制服诱惑 | 亚洲三级在线免费| 欧美一级午夜免费电影| 色综合久久九月婷婷色综合| 麻豆精品国产91久久久久久| 国产亚洲精品aa午夜观看| 欧美精品第1页| 99久久精品国产观看| 国产综合久久久久久鬼色| 亚洲一区在线视频观看| www国产精品av| 91精品国产色综合久久ai换脸| 99视频热这里只有精品免费| 国产一区二区三区不卡在线观看| 亚洲国产乱码最新视频| 国产精品超碰97尤物18| 精品国产区一区| 欧美男人的天堂一二区| aaa欧美日韩| 国产精品一级在线| 麻豆国产精品官网| 香蕉乱码成人久久天堂爱免费| 中文字幕一区二区三| 制服丝袜亚洲网站| 欧美无砖专区一中文字| 99久久精品国产导航| 成人h动漫精品| 加勒比av一区二区| 麻豆免费看一区二区三区| 五月激情六月综合| 亚洲乱码日产精品bd | 韩国毛片一区二区三区| 麻豆成人综合网| 日韩影院免费视频| 亚洲精品亚洲人成人网在线播放| 中文字幕一区二区三区精华液| 久久久久久久精| 久久久久青草大香线综合精品| 日韩网站在线看片你懂的| 欧美性生交片4| 色88888久久久久久影院按摩| 91亚洲大成网污www| 99视频在线精品| 99久久亚洲一区二区三区青草| 91在线视频网址| eeuss影院一区二区三区| 97se亚洲国产综合自在线不卡| 成人黄色av网站在线| 亚洲午夜一区二区三区| 亚洲h精品动漫在线观看| 亚洲在线成人精品| 午夜精品久久久久久久久久| 亚洲18色成人| 麻豆国产精品视频| 狠狠色狠狠色合久久伊人| 日本不卡1234视频| 美女在线一区二区|