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

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

?? ip.c

?? udp,tcp/ip在智能家居芯片上的代碼實(shí)現(xiàn).包括芯片NE64的網(wǎng)絡(luò)驅(qū)動(dòng)源代碼
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):

/** \file ip.c
 *	\brief OpenTCP IP protocol implementation
 *	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *		\li Vladan Jovanovic (vladan.jovanovic@violasystems.com)
 *	\version 1.0
 *	\date 11.6.2002
 *	\bug
 *	\warning
 *	\todo 
 *		\li Implement stub handler for supporting fragmented datagrams (
 *		may be usefull on MCUs with lots of available RAM)
 *  
 *	OpenTCP IP protocol implementation functions. For declaration,
 *	constants and data structures refer to ip.h.
 */

/*
 *Copyright (c) 2000-2002 Viola Systems Ltd.
 *All rights reserved.
 *
 *Redistribution and use in source and binary forms, with or without 
 *modification, are permitted provided that the following conditions 
 *are met:
 *
 *1. Redistributions of source code must retain the above copyright 
 *notice, this list of conditions and the following disclaimer.
 *
 *2. Redistributions in binary form must reproduce the above copyright 
 *notice, this list of conditions and the following disclaimer in the 
 *documentation and/or other materials provided with the distribution.
 *
 *3. The end-user documentation included with the redistribution, if 
 *any, must include the following acknowledgment:
 *	"This product includes software developed by Viola 
 *	Systems (http://www.violasystems.com/)."
 *
 *Alternately, this acknowledgment may appear in the software itself, 
 *if and wherever such third-party acknowledgments normally appear.
 *
 *4. The names "OpenTCP" and "Viola Systems" must not be used to 
 *endorse or promote products derived from this software without prior 
 *written permission. For written permission, please contact 
 *opentcp@opentcp.org.
 *
 *5. Products derived from this software may not be called "OpenTCP", 
 *nor may "OpenTCP" appear in their name, without prior written 
 *permission of the Viola Systems Ltd.
 *
 *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 
 *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE 
 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *====================================================================
 *
 *OpenTCP is the unified open source TCP/IP stack available on a series 
 *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
 *
 *For more information on how to network-enable your devices, or how to 
 *obtain commercial technical support for OpenTCP, please see 
 *<http://www.violasystems.com/>.
 */


#include <debug.h>
#include <datatypes.h>
#include <ethernet.h>
#include <arp.h>
#include <ip.h>
#include <system.h>


/**	\brief Used for storing various information about the incoming IP packet
 *	
 *	Various fields from the IP packet are stored in this structure. These
 *	values are later used from other upper layer protocols (ICMP, UDP, TCP
 *	and possibly others) to extract needed information about the received
 *	packet. See ip_frame definition for struct information.
 */
struct ip_frame received_ip_packet;

/**	\brief Used for storing various information about the outgoing IP packet
 *	
 *	Various fields from the IP packet are stored in this structure. These
 *	values are filled based on the information supplied by the upper 
 * 	layer protocols (ICMP, UDP, TCP and possibly others) and used to form
 *	a correct IP packet (correct filed values, checksum,..). See ip_frame
 *	definition for struct information.
 */
struct ip_frame send_ip_packet;

UINT16 ip_id;	/**< ID field in the next IP packet that will be sent */

/** \brief Process received IP frame
 *	\ingroup periodic_functions
 * 	\author 
 *		\li Jari Lahti
 *	\date 11.06.2002
 *	\param frame pointer to ethernet_frame structure holding information
 *		about the received frame that carries IP datagram.
 *	\return
 *		\li -1 - IP packet not OK
 *		\li >0 - Length of next layer data (IP packet OK)
 *
 *	Process received IP packet by checking necessary header information
 *	and storing it accordingly to received_ip_packet variable. If everything
 *	checks out, return length of the data carried in the IP datagram (for
 *	higher-level protocols), otherwise return -1.
 */
INT16 process_ip_in (struct ethernet_frame* frame)
{

	UINT8 olen;
	UINT8 i;
	
	/* Check for Protocol								*/
	
	IP_DEBUGOUT("Checking if IP Protocol\n\r");
	
	if( frame->protocol != PROTOCOL_IP )
		return(-1);
		
	IP_DEBUGOUT("It's IP\n\r");
	
	if( frame->frame_size < ETH_HEADER_LEN )
		return(-1);
		
	if( (frame->frame_size - ETH_HEADER_LEN) < IP_HLEN )
		return(-1); 
				
	/* Get IP Header Information						*/
		
	NETWORK_RECEIVE_INITIALIZE(frame->buf_index);
		
	received_ip_packet.vihl = RECEIVE_NETWORK_B();
		
	/* Is it IPv4?	*/
		
	if( (received_ip_packet.vihl & 0xF0) != 0x40 ) {
		IP_DEBUGOUT("ERROR: IP is not version 4!\n\r");
		return(-1);
	}
		
	IP_DEBUGOUT("IP Version 4 OK!\n\r");	
		
	received_ip_packet.tos      = RECEIVE_NETWORK_B();						
	received_ip_packet.tlen     = RECEIVE_NETWORK_W();		
	received_ip_packet.id       = RECEIVE_NETWORK_W();		
	received_ip_packet.frags    = RECEIVE_NETWORK_W();
	received_ip_packet.ttl      = RECEIVE_NETWORK_B();	
	received_ip_packet.protocol = RECEIVE_NETWORK_B();		
	received_ip_packet.checksum = RECEIVE_NETWORK_W();

	received_ip_packet.sip = (((UINT32)RECEIVE_NETWORK_B()) << 24);
	received_ip_packet.sip |= (((UINT32)RECEIVE_NETWORK_B()) << 16);
	received_ip_packet.sip |= (((UINT32)RECEIVE_NETWORK_B()) << 8);
	received_ip_packet.sip |= RECEIVE_NETWORK_B();
		
	received_ip_packet.dip = (((UINT32)RECEIVE_NETWORK_B()) << 24);
	received_ip_packet.dip |= (((UINT32)RECEIVE_NETWORK_B()) << 16);
	received_ip_packet.dip |= (((UINT32)RECEIVE_NETWORK_B()) << 8);
	received_ip_packet.dip |= RECEIVE_NETWORK_B();

	/* Is that packet for us?			*/
	if((received_ip_packet.dip != localmachine.localip )&&
		(received_ip_packet.dip != IP_BROADCAST_ADDRESS)) 
		{

		/* It's not for us. Check still if ICMP with rigth physical	*/
		/* address that migth be used to set temporary IP			*/
		
		IP_DEBUGOUT("IP address does not match!\n\r");
		
		if( received_ip_packet.protocol != IP_ICMP) 
			return(-1);
			
		/* Check physical address			*/
		
		for(i=0; i<PHY_ADR_LEN; i++)
		{
			if(frame->destination[i] != localmachine.localHW[i])
				return(-1);
		}	

	}
	
	
	/* Is there options to copy?		*/
		
	olen = ((received_ip_packet.vihl & 0x0F) << 2) - IP_MIN_HLEN;
	
	/* Somebody bluffing with too long option field?	*/
	
	if(olen > MAX_IP_OPTLEN) {
		IP_DEBUGOUT("ERROR:Size of maximum allowed IP option lengt exceeded!\n\r");
		return(-1);
	}
	
	if( olen > (frame->frame_size - ETH_HEADER_LEN - IP_HLEN) )	{
		IP_DEBUGOUT("ERROR:IP option field too long!\n\r");
		return(-1);
	}
		
	for( i=0; i < olen; i++ ) {
		received_ip_packet.opt[i] = RECEIVE_NETWORK_B();	
		IP_DEBUGOUT("IP Options..\n\r");
	}
	
	if(received_ip_packet.tlen >  (frame->frame_size - ETH_HEADER_LEN) ) {
		IP_DEBUGOUT("ERROR: Total len too long\r\n");
		return(-1);
	}
	
	/* Is the checksum OK?	*/
	
	IP_DEBUGOUT("Validating the IP checksum..\n\r");
	
	if ( ip_check_cs(&received_ip_packet) != TRUE )	{
		IP_DEBUGOUT("IP Checksum Corrupted..\n\r");
		return(-1);
	}	
	
	IP_DEBUGOUT("..Checksum OK!\n\r");	
	
	/* Add the address to ARP cache	*/	
	if( received_ip_packet.sip != IP_BROADCAST_ADDRESS)
		arp_add( received_ip_packet.sip, &frame->source[0], ARP_TEMP_IP);
	
	/* Calculate the start of next layer data	*/	
	received_ip_packet.buf_index = frame->buf_index + IP_HLEN + olen;
	
	/* Is this packet fragmented?						*/
	/* We don't deal with those							*/
	/* TODO: Implement Stub handler for more mem. uP's	*/	
	if( received_ip_packet.frags & (IP_MOREFRAGS | IP_FRAGOFF) ) 
	{
		IP_DEBUGOUT("Fragmented IP packet\r\n");
		return(-1);
	}
	/* checking moved upwards!
	if( received_ip_packet.frags & IP_FRAGOFF )	{
		IP_DEBUGOUT("Fragmented IP packet\r\n");
		return(-1);
	}
	*/
	
	IP_DEBUGOUT("Leaving IP succesfully..\n\r");
	
	return(received_ip_packet.tlen - IP_HLEN - olen);
	
}

/** \brief Try to send out IP frame
 * 	\author 
 *		\li Jari Lahti
 *	\date 11.06.2002
 *	\param ipadr remote IP address
 *	\param pcol protocol over IP used. Can be one of the
 *		following:
 *		\li #IP_ICMP
 *		\li #IP_UDP
 *		\li #IP_TCP
 *	\param tos type of service required
 *	\param ttl time to live header field of IP packet
 *	\param dat pointer to data buffer
 *	\param len length of data to be sent in IP datagram
 *	\return
 *		\li -1 - general error
 *		\li -2 - ARP cache not ready
 *		\li >0 - number of data bytes sent (packet OK)
 *
 *	Invoke this function to perform all of the necessary preparation in
 *	order to send out an IP packet. These include:
 *		\li Consulting ARP cache for HW address to send the packet to
 *		\li Filling send_ip_packet variable with correct values
 *		\li Calculating checksum for the IP packet
 *		\li Adding datalink header information
 *		\li	Sending IP header and data
 *		\li Instructing NIC to send the data
 */
INT16 process_ip_out (UINT32 ipadr, UINT8 pcol, UINT8 tos, UINT8 ttl, UINT8* dat, UINT16 len)
{
	struct arp_entry *qstruct;
	UINT16 i;
	
	/* Try to get MAC address from ARP cache	*/
	

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本色道**综合亚洲精品蜜桃冫| 欧美一区二区大片| 免费的国产精品| 亚洲日本在线天堂| 精品国产一区二区三区不卡| 欧美日韩一级大片网址| 成人天堂资源www在线| 琪琪一区二区三区| 午夜视频一区二区三区| 国产精品久久久久久久久免费桃花 | 99精品国产99久久久久久白柏| 日本欧美一区二区三区乱码| 亚洲理论在线观看| 国产日韩一级二级三级| 日韩视频在线永久播放| 欧美视频在线观看一区| 99久久伊人精品| 国产成都精品91一区二区三| 久久国产欧美日韩精品| 亚洲观看高清完整版在线观看| 国产精品久久三区| 久久九九久久九九| 精品久久人人做人人爱| 欧美一级理论性理论a| 欧美日韩成人高清| 欧美亚洲图片小说| 欧美最猛黑人xxxxx猛交| 99r精品视频| 91在线你懂得| caoporen国产精品视频| 成人黄色片在线观看| 国产精品影视在线| 精品亚洲国内自在自线福利| 日韩高清不卡一区二区三区| 日韩一区欧美二区| 免费观看在线综合| 男人的天堂亚洲一区| 老司机午夜精品| 九色综合狠狠综合久久| 激情欧美一区二区三区在线观看| 玖玖九九国产精品| 经典三级视频一区| 成人自拍视频在线观看| 成人网在线播放| 色综合久久中文综合久久97| 972aa.com艺术欧美| 色综合久久中文字幕综合网| 欧美午夜视频网站| 91麻豆精品国产91久久久久久久久| 在线电影国产精品| 久久亚洲影视婷婷| 国产精品女同一区二区三区| 亚洲欧洲日产国产综合网| 亚洲免费高清视频在线| 亚洲123区在线观看| 免费高清在线视频一区·| 国产在线视视频有精品| 成人国产精品免费网站| 欧美亚一区二区| 欧美一区二区三区免费| 久久久久久一二三区| 国产精品美女视频| 亚洲国产视频一区二区| 蜜臀av性久久久久蜜臀aⅴ四虎| 国产在线播放一区二区三区| 成人国产视频在线观看| 欧美日本一区二区三区四区| 精品国产乱码91久久久久久网站| 欧美激情一区二区三区四区| 亚洲精品一二三| 日韩av一级片| 成人黄色小视频| 欧美肥妇bbw| 国产精品视频九色porn| 视频在线观看91| 国产精品一级片| 色婷婷一区二区| 精品国产乱码久久久久久久| 中文字幕字幕中文在线中不卡视频| 亚洲高清久久久| 国产成人在线视频免费播放| 91麻豆.com| 精品动漫一区二区三区在线观看| 中文字幕亚洲一区二区av在线| 三级成人在线视频| 成人黄色小视频在线观看| 欧美一区二区日韩| **网站欧美大片在线观看| 免费成人在线视频观看| 色综合一个色综合亚洲| 久久这里只有精品首页| 亚洲一区av在线| 不卡视频免费播放| 精品日韩一区二区| 亚洲图片欧美一区| 97久久精品人人澡人人爽| 精品久久久久久亚洲综合网| 亚洲自拍偷拍综合| 粉嫩av一区二区三区| 日韩你懂的在线播放| 亚洲国产裸拍裸体视频在线观看乱了| 国产剧情一区在线| 日韩美女一区二区三区| 亚洲一区二区三区四区在线| 丰满白嫩尤物一区二区| 日韩美女在线视频| 天堂一区二区在线免费观看| 91视频免费看| 国产欧美精品区一区二区三区 | 欧美日韩日日摸| 亚洲天堂a在线| 国产成人免费网站| 日韩限制级电影在线观看| 亚洲第一av色| 在线观看av一区| 亚洲欧美激情视频在线观看一区二区三区 | 日韩激情一二三区| 91日韩一区二区三区| 国产精品视频在线看| 国产精品白丝jk黑袜喷水| 欧美va亚洲va| 精品一区二区在线观看| 日韩免费看的电影| 蜜桃精品视频在线| 91精品国产手机| 性做久久久久久久久| 欧美婷婷六月丁香综合色| 亚洲欧美国产高清| 欧美在线影院一区二区| 亚洲一区在线观看视频| 在线观看精品一区| 午夜在线成人av| 欧美日韩第一区日日骚| 日韩精品电影在线| 日韩美女主播在线视频一区二区三区| 首页国产丝袜综合| 日韩一区二区三区高清免费看看 | 日韩专区一卡二卡| 日韩一二三区不卡| 激情六月婷婷综合| 久久精品夜色噜噜亚洲a∨| 国产精品91xxx| 国产精品美女www爽爽爽| 成人视屏免费看| 亚洲精品视频观看| 欧美视频精品在线| 日韩经典中文字幕一区| 亚洲精品在线观看网站| 国产盗摄女厕一区二区三区| 国产日韩欧美一区二区三区综合| 高清视频一区二区| 亚洲欧美电影院| 欧美夫妻性生活| 国产精品一区在线| 亚洲精品亚洲人成人网在线播放| 欧美日韩小视频| 美女www一区二区| 国产欧美日韩麻豆91| 色呦呦一区二区三区| 日韩一区精品视频| 久久久久国产精品免费免费搜索 | 欧美mv和日韩mv国产网站| 国产一区二区0| 一区二区三区中文字幕精品精品| 欧美片网站yy| 成人午夜av影视| 亚洲va欧美va人人爽| 2021中文字幕一区亚洲| 99精品视频在线观看| 秋霞影院一区二区| 国产精品无人区| 337p亚洲精品色噜噜噜| 国产成人精品综合在线观看| 一区二区久久久| 欧美va在线播放| 欧美这里有精品| 国产不卡视频一区| 亚洲第一av色| 中文字幕中文字幕在线一区 | 国产精品久久久久婷婷二区次| 日本韩国一区二区| 国产一区二区三区在线观看免费 | 日韩精品三区四区| 亚洲欧美在线aaa| 精品国产91亚洲一区二区三区婷婷| 北条麻妃一区二区三区| 老司机免费视频一区二区三区| 中文字幕一区日韩精品欧美| 欧美一区二区美女| 91视频观看视频| 国产一区二区在线免费观看| 亚洲成av人片在www色猫咪| 久久久久国产精品麻豆ai换脸 | 久久久久久久精| 制服丝袜亚洲精品中文字幕| 色综合天天综合网国产成人综合天| 美国三级日本三级久久99| 亚洲女人****多毛耸耸8| 久久嫩草精品久久久久| 日韩欧美在线综合网|