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

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

?? ip.c

?? 44B0+8019系統(tǒng)
?? C
字號:
//-----------------------------------------------------------------------------
// Net IP.C
// This module is the IP layer
// Refer to RFC 791, 1122, and RFC 815 (fragmentation)
//-----------------------------------------------------------------------------
#include <string.h>

#include "rtl8019.h"
#include "net.h"
#include "cksum.h"
#include "arp.h"
#include "icmp.h"
#include "udp.h"
#include "tcp.h"
#include "ip.h"

extern unsigned int my_ipaddr;
WAIT wait;

//========================================================================
void ip_getHader(void *inbuf,void *h)
{
   unsigned char *pinbuf = (unsigned char*)inbuf;
   unsigned char *pBuf;
   IP_HEADER *ph = (IP_HEADER*)h;

   //=========================================
   ph->ver_len = pinbuf[14];
   ph->type_of_service = pinbuf[15];

   //=========================================
   //pBuf = (unsigned char *)&ph->total_length;
   //pBuf[1] = pinbuf[16];
   //pBuf[0] = pinbuf[17];
   ph->total_length = get__int16(pinbuf+16);
   
   //=========================================
   //pBuf = (unsigned char *)&ph->identifier;
   //pBuf[1] = pinbuf[18];
   //pBuf[0] = pinbuf[19];
   ph->identifier = get__int16(pinbuf+18);
   //=========================================
   //pBuf = (unsigned char *)&ph->fragment_info;
   //pBuf[1] = pinbuf[20];
   //pBuf[0] = pinbuf[21];
   ph->fragment_info = get__int16(pinbuf+20);
   //=========================================
   ph->time_to_live = pinbuf[22];
   ph->protocol_id = pinbuf[23];

   //=========================================
   //pBuf = (unsigned char *)&ph->header_cksum;
   //pBuf[1] = pinbuf[24];
   //pBuf[0] = pinbuf[25];
   ph->header_cksum = get__int16(pinbuf+24);
   //=========================================
   //memcpy((unsigned char*)&ph->source_ipaddr,pinbuf+26,4);
   ph->source_ipaddr = get__int32(pinbuf+26);
   //=========================================
   //memcpy((unsigned char*)&ph->dest_ipaddr,pinbuf+30,4);
   ph->dest_ipaddr = get__int32(pinbuf+30);
}

void ip_setHader(void *inbuf,void *h)
{
   unsigned char *pinbuf = (unsigned char*)inbuf;
   unsigned char *pBuf;
   IP_HEADER *ph = (IP_HEADER*)h;

   //=========================================
   pinbuf[14] = ph->ver_len;
   pinbuf[15] = ph->type_of_service;

   //=========================================
   //pBuf = (unsigned char *)&ph->total_length;
   //pinbuf[16] = pBuf[1];
   //pinbuf[17] = pBuf[0];
   set__int16(pinbuf+16,ph->total_length);
   //=========================================
   //pBuf = (unsigned char *)&ph->identifier;
   //pinbuf[18] = pBuf[1];
   //pinbuf[19] = pBuf[0];
   set__int16(pinbuf+18,ph->identifier);
   //=========================================
   //pBuf = (unsigned char *)&ph->fragment_info;
   //pinbuf[20] = pBuf[1];
   //pinbuf[21] = pBuf[0];
   set__int16(pinbuf+20,ph->fragment_info);
   //=========================================
   pinbuf[22] = ph->time_to_live;
   pinbuf[23] = ph->protocol_id;

   //=========================================
   //pBuf = (unsigned char *)&ph->header_cksum;
   //pinbuf[24] = pBuf[1];
   //pinbuf[25] = pBuf[0];
   set__int16(pinbuf+24,ph->header_cksum);
   //=========================================
   //memcpy(pinbuf+26,(unsigned char*)&ph->source_ipaddr,4);
   set__int32(pinbuf+26,ph->source_ipaddr);
   //=========================================
   //memcpy(pinbuf+30,(unsigned char*)&ph->dest_ipaddr,4);
   set__int32(pinbuf+30,ph->dest_ipaddr);
}

//------------------------------------------------------------------------
// This handles outgoing IP datagrams.  It adds the 20 byte IP header
// and checksum then forwards the IP datagram to the Ethernet layer
// for sending. See "TCP/IP Illustrated, Volume 1" Sect 3.2
//------------------------------------------------------------------------
void ip_send(unsigned char *outbuf, unsigned int ipaddr, unsigned char proto_id, unsigned short len)
{

   //unsigned char dto_hwaddr[6] = {0x00,0xe0,0x4c,0xe0,0xc1,0xc7};
   IP_HEADER *ip,iph;
   unsigned char *hwaddr;
   static unsigned short int ip_ident = 0;
   
   ip = &iph;
   ip->ver_len = 0x45;              // IPv4 with 20 byte header
   ip->type_of_service = 0;
   ip->total_length = 20 + len;
   ip->identifier = ip_ident++;     // sequential identifier
   ip->fragment_info = 0;           // not fragmented
   ip->time_to_live = 32;           // max hops
   ip->protocol_id = proto_id;      // type of payload
   ip->header_cksum = 0;
   ip->source_ipaddr = my_ipaddr;
   
   // Outgoing IP address
   ip->dest_ipaddr = ipaddr;

   // Compute and insert complement of checksum of ip header
   // Outgoing ip header length is always 20 bytes
   ip_setHader(outbuf,ip);		//將ip報封裝成太幀
   ip->header_cksum = ~cksum(outbuf + 14, 20);
   
   // Use ARP to get hardware address to send this to
   hwaddr = arp_resolve(ip->dest_ipaddr);//找到于目標(biāo)ip對應(yīng)的物理地址
	
	// Null means that the ARP resolver did not find the IP address
	// in its cache so had to send an ARP request
	if (hwaddr == NULL)
	{
		// Fill in the destination information so ehrn the ARP response
		 //arrives we can identify it and know what to do when we get it
      memcpy(wait.buf , outbuf, 20 + len + 14);
		wait.ipaddr = ip->dest_ipaddr;
		wait.proto_id = proto_id;
		wait.len = len;
		wait.timer = ARP_TIMEOUT; 
        return;
	}	
   
    //hwaddr = (unsigned char *)dto_hwaddr;	
	ip_setHader(outbuf,ip);
   while( !ETH_Send(outbuf, hwaddr, IP_PACKET, 20 + len) );
}



//------------------------------------------------------------------------
// This handles incoming IP datagrams from the Ethernet layer
// See "TCP/IP Illustrated, Volume 1" Sect 3.2
//------------------------------------------------------------------------
void ip_rcve(unsigned char *inbuf)
{
	IP_HEADER *ip,iph;
	unsigned short int header_len, payload_len;
   unsigned int i;

   //ip = (IP_HEADER *)(inbuf + 14);
   ip = &iph;

   ip_getHader( inbuf , ip);
            
   // Make sure it is addressed to my IP address
   if (ip->dest_ipaddr != my_ipaddr) return;

   // Validate checksum of ip header
	header_len = 4 * (0x0F & ip->ver_len);
	payload_len = ip->total_length - header_len;
   if (cksum(inbuf + 14, header_len) != 0xFFFF)
	{
	   return; 
   }
	
	// Make sure incoming message is IP version 4
	if ((ip->ver_len >> 4) != 0x04)
	{
   	return;
	}

	// Make sure incoming message is not fragmented because
   // we cannot handle fragmented messages
   if ((ip->fragment_info & 0x3FFF) != 0)
   {
 	   return; 
   }

   // At this point we have received a valid IP datagram addressed
   // to me.  We do not use header options, and do not forward
   // messages, so in the unlikely event there are header options,
   // delete them and shift the data down. The advantage is that
   // layers such as UDP and TCP know where their data starts
	if (header_len > 20)
	{
     // Use memmove because of overlap
      memmove(inbuf + 34, inbuf + 14 + header_len, payload_len);

		// Adjust info to reflect the move
		header_len = 20;
		ip->ver_len = 0x45;
		ip->total_length = 20 + payload_len;
	}
	
	
	// Look at protocol ID byte and call the appropriate
   // function to handle the received message.  See 
   // "TCP/IP Illustrated, Volume 1" Sect 1.7 and RFC 791
   // for values for various protocols
   switch (ip->protocol_id)
	{
      case ICMP_TYPE:
      {
         icmp_rcve(inbuf, payload_len);
         break;
      }

      case IGMP_TYPE:
      {
		   // We cannot handle IGMP messages
		   //if (debug) serial_send("IP:  Error, IGMP pkt rcvd\r");
         break;
      }
		  
      case UDP_TYPE:
      {
         udp_rcve(inbuf, payload_len);
         break;
      }

      case TCP_TYPE:   
      {
         tcp_rcve(inbuf, payload_len);
         break;
      }

      default:
      {
         //if (debug) serial_send("IP:  Unknown IP proto id rcvd\r");
         break;
      }
   }
}


//void mytt_ip()
//{
//   mytt();
//}


?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲黄色片在线观看| 欧美丝袜自拍制服另类| 9色porny自拍视频一区二区| 99久久er热在这里只有精品15| 在线日韩一区二区| 精品成a人在线观看| 亚洲欧美一区二区视频| 性做久久久久久免费观看欧美| 激情综合亚洲精品| 色综合久久久久| 欧美精品一区二| 亚洲黄色av一区| 激情综合色播激情啊| 91福利区一区二区三区| 精品国产亚洲在线| 亚洲国产一区二区a毛片| 激情文学综合插| 欧美丝袜丝nylons| 欧美国产1区2区| 日本女人一区二区三区| 91无套直看片红桃| 精品国产亚洲一区二区三区在线观看| 亚洲精品亚洲人成人网| 韩日精品视频一区| 欧美日韩成人在线一区| 国产精品美女久久久久久| 日本不卡视频一二三区| 色综合久久久久网| 中国av一区二区三区| 久久电影网电视剧免费观看| 在线观看成人免费视频| 国产精品久久久爽爽爽麻豆色哟哟 | 国产精品午夜在线| 免费av成人在线| 在线观看欧美黄色| 国产精品日日摸夜夜摸av| 老司机午夜精品99久久| 欧美性大战xxxxx久久久| 中文字幕av一区二区三区高| 另类专区欧美蜜桃臀第一页| 欧美伊人久久大香线蕉综合69| 中文字幕国产一区二区| 精品无码三级在线观看视频| 欧美精品色一区二区三区| 亚洲美腿欧美偷拍| 成人精品一区二区三区中文字幕 | 国产风韵犹存在线视精品| 日韩一区二区三区四区五区六区| 亚洲精品视频在线观看免费| 国产91高潮流白浆在线麻豆| 精品久久久三级丝袜| 日韩国产高清影视| 欧美揉bbbbb揉bbbbb| 亚洲精品视频在线观看免费| 99在线精品一区二区三区| 久久久天堂av| 国产一区二区三区蝌蚪| 精品成人佐山爱一区二区| 久久99精品网久久| 欧美成人精品1314www| 人人超碰91尤物精品国产| 欧美日韩国产综合久久| 婷婷国产v国产偷v亚洲高清| 欧美美女黄视频| 日日嗨av一区二区三区四区| 欧美日韩一区二区三区不卡 | 337p亚洲精品色噜噜| 亚洲国产日日夜夜| 精品视频免费在线| 亚洲va天堂va国产va久| 欧美怡红院视频| 亚洲成人精品一区| 欧美精品久久久久久久多人混战 | 欧美一区二区私人影院日本| 午夜电影久久久| 日韩三级视频中文字幕| 另类中文字幕网| 久久精品一区八戒影视| 本田岬高潮一区二区三区| 成人免费在线播放视频| 91欧美一区二区| 亚洲夂夂婷婷色拍ww47| 在线不卡免费欧美| 毛片不卡一区二区| 久久久久久久久一| 成人高清免费观看| 亚洲精品你懂的| 777欧美精品| 韩国v欧美v日本v亚洲v| 中文字幕av一区二区三区免费看 | 视频一区在线视频| 日韩情涩欧美日韩视频| 国内成+人亚洲+欧美+综合在线| 久久综合99re88久久爱| 成人av动漫网站| 一区二区三区**美女毛片| 69堂成人精品免费视频| 国模一区二区三区白浆| 日韩毛片视频在线看| 7878成人国产在线观看| 国产黄色精品网站| 亚洲理论在线观看| 日韩精品一区在线| 高潮精品一区videoshd| 亚洲一区二区黄色| 精品电影一区二区三区| 99久久国产综合精品麻豆| 日韩精品五月天| 欧美高清在线视频| 欧美日韩国产一区二区三区地区| 国产一区高清在线| 伊人色综合久久天天人手人婷| 日韩免费观看高清完整版| 成人激情午夜影院| 日韩精品国产精品| 1000部国产精品成人观看| 欧美三级视频在线| 懂色av中文字幕一区二区三区| 亚洲另类中文字| 久久美女高清视频| 欧美午夜精品一区| 国产成人精品一区二区三区网站观看| 一区二区三区中文字幕电影| 2023国产精品| 欧美日韩国产一区| 成人精品国产一区二区4080| 日本不卡在线视频| 综合色天天鬼久久鬼色| 精品国产污污免费网站入口| 欧美天堂亚洲电影院在线播放| 国产福利精品一区二区| 日韩中文字幕av电影| 日韩理论片网站| 久久综合九色欧美综合狠狠| 欧美人与z0zoxxxx视频| 99视频热这里只有精品免费| 久久国产精品露脸对白| 一区二区三区美女| 国产精品久久久久久久久搜平片| 欧美一区二区三区影视| 色综合中文字幕国产| 国产寡妇亲子伦一区二区| 日韩国产高清影视| 亚洲一级在线观看| 自拍偷拍亚洲欧美日韩| 国产欧美日韩精品a在线观看| 欧美一区二区三区影视| 欧美三级欧美一级| 色猫猫国产区一区二在线视频| 国产成人一级电影| 久久99精品一区二区三区| 日韩激情一二三区| 亚洲成人在线免费| 一区二区三区四区中文字幕| 中文字幕乱码久久午夜不卡| 欧美精品一区二区三区蜜桃视频| 欧美日韩视频专区在线播放| 色狠狠av一区二区三区| www.66久久| 国产suv一区二区三区88区| 精品中文字幕一区二区| 日韩电影免费在线观看网站| 亚洲妇女屁股眼交7| 一区2区3区在线看| 亚洲欧美一区二区三区极速播放| 国产精品久久久久久久久免费樱桃| 久久久.com| 国产亚洲欧美日韩俺去了| 欧美精品一区二区精品网| 精品国产污污免费网站入口| 日韩免费高清av| 日韩欧美中文字幕精品| 欧美一区二区私人影院日本| 在线播放一区二区三区| 欧美日韩国产高清一区二区三区| 欧洲精品一区二区| 欧美主播一区二区三区| 欧美视频一二三区| 欧美精品丝袜中出| 91精品国产综合久久久久久久久久| 欧美挠脚心视频网站| 91精品国产高清一区二区三区 | 狠狠色综合播放一区二区| 蜜桃久久精品一区二区| 免费高清视频精品| 久久精品99国产精品| 久久99精品国产91久久来源| 精品一区二区三区视频在线观看 | 国产无人区一区二区三区| 国产亚洲短视频| 国产精品国产成人国产三级| 日韩久久一区二区| 亚洲第一狼人社区| 奇米精品一区二区三区在线观看| 日本不卡中文字幕| 国产精品影音先锋| av男人天堂一区| 欧美亚洲高清一区二区三区不卡| 欧美人与禽zozo性伦| 亚洲精品一区二区三区精华液|