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

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

?? arp.c

?? 在freescale 的ne64上開發的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
#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;
			
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩在线卡一卡二| 1024国产精品| 免费人成黄页网站在线一区二区| 在线视频你懂得一区| 一区二区三区欧美视频| 欧美亚洲国产一区二区三区 | 欧美mv日韩mv亚洲| 经典一区二区三区| 中文字幕免费在线观看视频一区| 99视频一区二区| 欧美日韩极品在线观看一区| 日韩av一区二区三区四区| 日韩免费在线观看| 国产精品1024| 6080yy午夜一二三区久久| 蜜桃av噜噜一区| 中国av一区二区三区| 色噜噜狠狠成人中文综合| 婷婷国产v国产偷v亚洲高清| 欧美mv和日韩mv的网站| 成人高清在线视频| 亚洲va国产天堂va久久en| 久久婷婷成人综合色| eeuss国产一区二区三区| 亚洲成人综合在线| 国产欧美日韩亚州综合| 91最新地址在线播放| 图片区小说区区亚洲影院| 久久久亚洲国产美女国产盗摄| 99久久99久久精品国产片果冻 | 亚洲一区二区3| 日韩一级二级三级| 99久久99久久精品免费观看| 免费观看日韩电影| 亚洲三级小视频| 欧美va亚洲va香蕉在线| 91麻豆国产在线观看| 久久疯狂做爰流白浆xx| 亚洲精品美腿丝袜| 精品99一区二区| 日本韩国欧美一区| 国产一区二区三区四区五区美女| 亚洲免费观看高清完整| 精品国产伦一区二区三区观看方式| 97国产一区二区| 寂寞少妇一区二区三区| 午夜欧美视频在线观看| 国产精品毛片久久久久久久| 精品美女在线观看| 欧美日本国产一区| 色噜噜夜夜夜综合网| 懂色一区二区三区免费观看| 日本在线播放一区二区三区| 亚洲色图第一区| 久久精品一区八戒影视| 欧美日高清视频| 色婷婷亚洲精品| 成人av高清在线| 国产美女在线精品| 蜜桃一区二区三区四区| 婷婷一区二区三区| 伊人色综合久久天天人手人婷| 中文字幕免费不卡| 国产午夜一区二区三区| 久久综合久久综合九色| 日韩一区二区三| 欧美精品自拍偷拍动漫精品| 在线免费观看日韩欧美| 91在线观看一区二区| 成人精品免费视频| 国产成a人亚洲| 国产99久久久国产精品免费看| 国内外成人在线| 国模一区二区三区白浆| 蜜桃精品视频在线观看| 蜜臀av性久久久久蜜臀aⅴ流畅| 日韩综合小视频| 三级久久三级久久| 日本v片在线高清不卡在线观看| 亚洲成人激情自拍| 午夜精品福利在线| 免费久久99精品国产| 日韩电影在线一区| 蜜臂av日日欢夜夜爽一区| 久久青草国产手机看片福利盒子| 成人蜜臀av电影| 丰满白嫩尤物一区二区| 国产成人精品免费视频网站| 国产不卡免费视频| 成人黄页在线观看| 午夜视频久久久久久| 天堂一区二区在线| 久久国产精品免费| 国产福利91精品一区二区三区| 激情文学综合网| 丰满亚洲少妇av| 91麻豆国产福利精品| 欧美亚洲动漫制服丝袜| 在线电影欧美成精品| 欧美成人精品福利| 欧美韩日一区二区三区| 亚洲视频电影在线| 日韩电影在线一区二区三区| 久久国产夜色精品鲁鲁99| 国产高清不卡一区二区| 91丨porny丨中文| 欧美亚洲日本国产| 欧美成人三级电影在线| 色婷婷精品久久二区二区蜜臂av| 欧美日本一道本| 久久久精品天堂| 亚洲一区二区三区在线播放| 日韩国产高清影视| 国产成人精品免费看| 欧美综合亚洲图片综合区| 欧美大片在线观看一区| 亚洲欧洲在线观看av| 热久久国产精品| jlzzjlzz亚洲女人18| 91精品国产入口| 欧美色图第一页| 国产亚洲精品资源在线26u| 亚洲综合色噜噜狠狠| 加勒比av一区二区| 欧美在线观看一区| 精品粉嫩aⅴ一区二区三区四区| 亚洲色图制服诱惑 | 26uuu亚洲综合色| 亚洲另类色综合网站| 久久精品国产精品亚洲红杏| 午夜精品久久久久久久99水蜜桃 | 精品久久久久久久久久久院品网| 亚洲欧美经典视频| 精品制服美女丁香| 欧美性大战久久| 国产欧美日韩另类一区| 视频一区欧美精品| 91精品福利视频| 91视视频在线直接观看在线看网页在线看| 欧美日韩国产影片| 综合亚洲深深色噜噜狠狠网站| 久久精品国产亚洲一区二区三区| 91性感美女视频| 久久久久高清精品| 美女视频黄a大片欧美| 欧洲国产伦久久久久久久| 国产精品久久一级| 国产精品中文欧美| 精品久久五月天| 美女久久久精品| 91精品国产色综合久久不卡蜜臀 | 国产aⅴ综合色| 精品久久久久久综合日本欧美 | 亚洲欧洲av在线| 国产乱码精品1区2区3区| 欧美高清视频在线高清观看mv色露露十八| 国产精品白丝在线| 国产aⅴ精品一区二区三区色成熟| 国产成人在线电影| 欧美精品一区男女天堂| 久久精品国产亚洲高清剧情介绍| 欧美欧美欧美欧美首页| 亚洲国产视频在线| 色噜噜偷拍精品综合在线| 亚洲精品免费视频| 91福利精品第一导航| 亚洲嫩草精品久久| 91免费观看视频在线| 亚洲欧洲制服丝袜| 色偷偷成人一区二区三区91 | 蜜桃一区二区三区在线观看| 欧美色爱综合网| 依依成人精品视频| 欧美日韩亚洲不卡| 香蕉久久夜色精品国产使用方法| 欧美色图一区二区三区| 视频一区在线播放| 欧美变态tickle挠乳网站| 国产一区二三区好的| 久久久91精品国产一区二区三区| 国产成人午夜电影网| 国产精品久久久爽爽爽麻豆色哟哟 | 91丨九色丨蝌蚪丨老版| 亚洲毛片av在线| 欧美日韩一本到| 精品一区二区三区免费观看| 日韩欧美国产系列| 国产传媒久久文化传媒| 自拍偷拍国产亚洲| 欧美精品v国产精品v日韩精品| 精品一区二区三区在线观看| 亚洲国产精品传媒在线观看| av一本久道久久综合久久鬼色| 亚洲激情综合网| 制服丝袜亚洲网站| 国产精品一区二区久激情瑜伽| 中文成人av在线| 欧美日韩国产高清一区| 国产一区二区免费看| 国产精品每日更新|