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

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

?? tcp.c

?? C8051F系列的TCP/IP源程序C8051F系列的TCP/IP源程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
   // a temporary conection  to it for processing
   if (i == 5)
   {
      if (tcp->flags & FLG_SYN)
      {
         // Find first unused connection (one with IP = 0) 
         for (j=0; j < 5; j++)
         {
            if (conxn[j].ipaddr == 0)
            {
               nr = j;
               // Initialize new connection
               conxn[nr].state = STATE_LISTEN;
               break;
            }
         }
      
         // If all connections are used then drop msg
         if (j == 5) return;
         
         if (debug)
         {
            serial_send("TCP: New connection ");
            memset(text, 0, 10);
            itoa((UINT)nr, text, 10);
            serial_send(text);
			   serial_send("\r");
         }
      }
   }


   // By now we should have a connection number in range of 0-4
   // Do a check to avoid any chance of exceeding size of struct
   if (nr > 4)
   {
      if (debug) serial_send("TCP: Error in assigning conxn number\r");
      return;
   }

   // Eventually put in protection against wrapping sequence
   // numbers, for now make the client start over if his
   // sequence number is close to wrapping
   if (tcp->sequence > 0xFFFFFF00L) 
   {
      if (debug) serial_send("TCP: Rcvd a high sequence number\r");
		conxn[nr].ipaddr = 0;			
		tcp_send(FLG_RST, 20, NO_CONNECTION);
		return;		
   }
           
   // Handle messages whose action is mostly independent of state
   // such as RST, SYN, and segment with no ACK.  That way the
	// state machine below does not need to worry about it.
   if (tcp->flags & FLG_RST)
   {
      // An RST does not depend on state at all.  And it does
      // not count as data so do not send an ACK here.  Close
      // connection
 		if (debug) serial_send("TCP: Rcvd a reset\r");
      conxn[nr].ipaddr = 0;
      return;
   }
	
	else if (tcp->flags & FLG_SYN)
	{
	   // A SYN segment only makes sense if connection is in LISTEN 
	   if ((conxn[nr].state != STATE_LISTEN) &&
          (conxn[nr].state != STATE_CLOSED))
		{
			if (debug) serial_send("TCP: Error, rcvd bogus SYN\r");
			conxn[nr].ipaddr = 0;			
		  	tcp_send(FLG_RST, 20, NO_CONNECTION);
		  	return;		
		}
	}
	
	else if ((tcp->flags & FLG_ACK) == 0)
	{
		// Incoming segments except SYN or RST must have ACK bit set
	 	// See TCP/IP Illustrated, Vol 2, Page 965
      // Drop segment but do not send a reset
		if (debug) serial_send("TCP: Error, rcvd segment has no ACK\r");
		return;
	}
	   
   // Compute length of header including options, and from that
   // compute length of actual data
   header_len =  (tcp->flags & 0xF000) >> 10;
   data_len = len - header_len;


         
   // Handle TCP state machine for this connection
   switch (conxn[nr].state)
   {
      case STATE_CLOSED:
      case STATE_LISTEN:
            
      // If incoming segment contains SYN and no ACK, then handle 
      if ((tcp->flags & FLG_SYN) && ((tcp->flags & FLG_ACK) == 0))
      {
         // Capture his starting sequence number and generate
         // my starting sequence number
         // Fill in connection information
         conxn[nr].ipaddr = ip->source_ipaddr;
         conxn[nr].port = tcp->source_port;
         conxn[nr].state = STATE_LISTEN;
         conxn[nr].his_sequence = 1 + tcp->sequence;
         conxn[nr].his_ack = tcp->ack_number;
         
         // Use system clock for initial sequence number
         EA = 0;
         conxn[nr].my_sequence = initial_sequence_nr;
         initial_sequence_nr += 64000L;
         EA = 1;                  
                  
         // Send header options with the next message
         // Since timestamps are optional and we do not use
         // them, do not have to send them 
         // After sending the SYN ACK the client browser will
         // blast me with 2 messages, an ACK, and a HTTP GET
         tcp_send(FLG_SYN | FLG_ACK, 28, nr);
         
         // My SYN flag increments my sequence number
         // My sequence number is always updated to point to 
         // the next byte to be sent.  So the incoming ack
         // number should equal my sequence number  
         conxn[nr].my_sequence++;
      
         conxn[nr].state = STATE_SYN_RCVD;
         if (debug) serial_send("TCP: Entered SYN RCVD state\r");
      }
		else 
      {
         // Sender is out of sync so send reset
         conxn[nr].ipaddr = 0;
         tcp_send(FLG_RST, 20, NO_CONNECTION);   
      } 
		break;


      case STATE_SYN_RCVD:
      // He may already be sending me data - should process it
		conxn[nr].his_sequence += data_len;
      conxn[nr].his_ack = tcp->ack_number;
            
      if (tcp->flags & FLG_FIN)
		{
		   // His FIN counts as a byte of data
         conxn[nr].his_sequence++;
         tcp_send(FLG_ACK, 20, nr);
         conxn[nr].state = STATE_CLOSE_WAIT;
         if (debug) serial_send("TCP: Entered CLOSE_WAIT state\r");
               
        	// At this point we would normally wait for the	application
         // to close.  For now, send FIN right away.
         tcp_send(FLG_FIN | FLG_ACK, 20, nr);
         conxn[nr].my_sequence++;   // For my FIN
         conxn[nr].state = STATE_LAST_ACK;
         if (debug) serial_send("TCP: Entered LAST ACK state\r");
      }

		// Make sure he is ACKing my SYN
		else if (tcp->ack_number == conxn[nr].my_sequence)
      {
         conxn[nr].state = STATE_ESTABLISHED;
         if (debug) serial_send("TCP: Entered ESTABLISHED state\r");
         // If sender sent data ignore it and he will resend
         // Do not send response because we received no
         // data... wait for client to send something to me 
      }
      break;


      case STATE_ESTABLISHED:
      conxn[nr].his_ack = tcp->ack_number;
           
      if (tcp->flags & FLG_FIN)
		{
		   // His FIN counts as a byte of data
         conxn[nr].his_sequence++;
         tcp_send(FLG_ACK, 20, nr);
         conxn[nr].state = STATE_CLOSE_WAIT;
         if (debug) serial_send("TCP: Entered CLOSE_WAIT state\r");
               
        	// At this point we would normally wait for the	application
         // to close.  For now, send FIN immediately.
         tcp_send(FLG_FIN | FLG_ACK, 20, nr);
         conxn[nr].my_sequence++;   // For my FIN
         conxn[nr].state = STATE_LAST_ACK;
         if (debug) serial_send("TCP: Entered LAST ACK state\r");
      }
		else if (data_len != 0)
      {
			// Received normal TCP segment from sender with data
      	// Send an ACK immediately and pass the data on to
			// the application
			conxn[nr].his_sequence += data_len;
         tcp_send(FLG_ACK, 20, nr); 		// Send ACK
      	  
      	      	      	 									
			// Send pointer to start of TCP payload
			// http_server increments my sequence number when 
         // sending so don't worry about it here
         result = http_server(inbuf, header_len, nr, 0);
								
			// Start timer to close conxn if no activity
			conxn[nr].inactivity = INACTIVITY_TIME;
		}
	   break;


      case STATE_CLOSE_WAIT:
      // With this code, should not get here
      if (debug) serial_send("TCP: Oops! Rcvd unexpected message\r");
      
      break;

      
      case STATE_LAST_ACK:
      conxn[nr].his_ack = tcp->ack_number;
            
      // If he ACK's my FIN then close
      if (tcp->ack_number == conxn[nr].my_sequence)
      {
         conxn[nr].state = STATE_CLOSED;
         conxn[nr].ipaddr = 0;  // Free up struct area
         just_closed = TRUE;
      }
      break;

      
      case STATE_FIN_WAIT_1:
      // He may still be sending me data - should process it
		conxn[nr].his_sequence += data_len;
      conxn[nr].his_ack = tcp->ack_number;
                  
      if (tcp->flags & FLG_FIN)
      {
         // His FIN counts as a byte of data
         conxn[nr].his_sequence++;
         tcp_send(FLG_ACK, 20, nr);
         
         // If he has ACK'd my FIN then we can close connection
         if (tcp->ack_number == conxn[nr].my_sequence)
			{
         	conxn[nr].state = STATE_TIME_WAIT;
         	if (debug) serial_send("TCP: Entered TIME_WAIT state\r");
               
         	conxn[nr].state = STATE_CLOSED;
         	conxn[nr].ipaddr = 0;  // Free up connection
         	just_closed = TRUE;
      	}
			else
			{
				// He has not ACK'd my FIN.  This happens when there is a simultaneous
				// close - I got his FIN but he has not yet ACK'd my FIN
				conxn[nr].state = STATE_CLOSING;
				if (debug) serial_send("TCP: Entered CLOSING state\r");
			}
		}
      else if (tcp->ack_number == conxn[nr].my_sequence)
      {
         // He has ACK'd my FIN but has not sent a FIN yet himself
         conxn[nr].state = STATE_FIN_WAIT_2;
         if (debug) serial_send("TCP: Entered FIN_WAIT_2 state\r");
      }
      break;

      
      case STATE_FIN_WAIT_2:
      // He may still be sending me data - should process it
		conxn[nr].his_sequence += data_len;
      conxn[nr].his_ack = tcp->ack_number;
      
      if (tcp->flags & FLG_FIN)
      {
         conxn[nr].his_sequence++; // For his FIN flag
         tcp_send(FLG_ACK, 20, nr);
         conxn[nr].state = STATE_TIME_WAIT;
         if (debug) serial_send("TCP: Entered TIME_WAIT state\r");
         conxn[nr].state = STATE_CLOSED;
         conxn[nr].ipaddr = 0;  // Free up struct area
         just_closed = TRUE;
      }
      break;
            
            
      case STATE_TIME_WAIT:
      // With this code, should not get here
      if (debug) serial_send("TCP: Oops! In TIME_WAIT state\r");
      break;

      
      case STATE_CLOSING:
      // Simultaneous close has happened. I have received his FIN
      // but he has not yet ACK'd my FIN.  Waiting for ACK.
		// Will not receive data in this state
		conxn[nr].his_ack = tcp->ack_number;
      		
		if (tcp->ack_number == conxn[nr].my_sequence)
      {
		   conxn[nr].state = STATE_TIME_WAIT;
         if (debug) serial_send("TCP: Entered TIME_WAIT state\r");
         
         // Do not send any response to his ACK
         conxn[nr].state = STATE_CLOSED;
         conxn[nr].ipaddr = 0;  // Free up struct area
         just_closed = TRUE;
      }
      break;

      
      default:
      if (debug) serial_send("TCP: Error, no handler\r");
      break;
   }
   
   // This is for debug, to see when conxn closes
   if (just_closed)
   {
      just_closed = FALSE;
      if (debug)
      {
         serial_send("TCP: Closed connection ");
         memset(text, 0, 10);
         itoa((UINT)nr, text, 10);
		   serial_send(text);
		   serial_send("\r");
      }
   }
}



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91成人国产精品| 国产又黄又大久久| 欧美在线观看一区| 一区二区三区四区中文字幕| av中文字幕不卡| 综合久久久久久久| 欧美色男人天堂| 天天免费综合色| 精品蜜桃在线看| 成人av电影在线| 亚洲精品乱码久久久久久日本蜜臀| 91在线视频播放地址| 亚洲一区在线视频观看| 7777精品伊人久久久大香线蕉经典版下载 | 日韩欧美色电影| 国产一区二区在线视频| 中文字幕 久热精品 视频在线| 91偷拍与自偷拍精品| 亚洲午夜在线观看视频在线| 欧美人与z0zoxxxx视频| 久久69国产一区二区蜜臀| 国产婷婷色一区二区三区| 99re成人在线| 图片区日韩欧美亚洲| 久久久久久夜精品精品免费| 一本一道波多野结衣一区二区| 亚洲chinese男男1069| 国产网站一区二区| 欧美性淫爽ww久久久久无| 日本怡春院一区二区| 欧美高清在线精品一区| 欧美日韩成人综合| 狠狠色狠狠色综合系列| 综合中文字幕亚洲| 日韩欧美国产综合一区 | 欧美日韩大陆在线| 国产成人精品免费一区二区| 亚洲精品中文在线| 久久综合久久鬼色| 欧美色综合久久| 懂色一区二区三区免费观看 | 欧美三级日韩三级国产三级| 国产精品一区二区不卡| 亚洲国产aⅴ成人精品无吗| 亚洲国产电影在线观看| 欧美精品乱码久久久久久按摩| 成人涩涩免费视频| 蜜桃av噜噜一区二区三区小说| 国产精品麻豆视频| 久久综合色综合88| 91精品国产91热久久久做人人| 国产91丝袜在线播放0| 免费观看成人av| 亚洲一区二区三区中文字幕在线| 国产欧美一区视频| 久久综合狠狠综合久久激情| 欧美日韩一级视频| 日本高清成人免费播放| 国产精品亚洲成人| 国内精品久久久久影院薰衣草| 亚洲成av人片在线| 亚洲国产一区二区a毛片| 国产精品久久久久毛片软件| 欧美大片日本大片免费观看| 欧美在线视频你懂得| 暴力调教一区二区三区| 成人综合激情网| 国产美女精品在线| 久久超碰97中文字幕| 免费看精品久久片| 日本怡春院一区二区| 舔着乳尖日韩一区| 午夜影视日本亚洲欧洲精品| 亚洲激情自拍视频| 亚洲免费观看高清完整版在线观看| 久久久久久一二三区| 久久综合九色综合久久久精品综合| 日韩免费在线观看| 日韩亚洲欧美成人一区| 欧美一区二区三区在线看| 欧美视频一区二区三区在线观看 | 一级日本不卡的影视| 亚洲免费在线电影| 亚洲精品免费一二三区| 综合色天天鬼久久鬼色| 亚洲三级久久久| 亚洲激情六月丁香| 亚洲一区二区三区美女| 天堂成人免费av电影一区| 日本不卡一二三区黄网| 久草热8精品视频在线观看| 久久99国产乱子伦精品免费| 国内偷窥港台综合视频在线播放| 国产乱码一区二区三区| 国产成人欧美日韩在线电影| 国产**成人网毛片九色 | 国产女主播视频一区二区| 国产精品嫩草影院com| 亚洲人xxxx| 性做久久久久久免费观看欧美| 日本不卡123| 国产伦精品一区二区三区免费 | 日本欧美韩国一区三区| 久久66热re国产| 波多野洁衣一区| 欧美日韩一区三区四区| 日韩欧美国产一二三区| 久久久久亚洲蜜桃| 亚洲日本成人在线观看| 日韩国产欧美在线观看| 久久电影网站中文字幕| 成人av网站在线| 欧美日韩一区在线观看| 久久综合久久综合久久| 亚洲激情综合网| 激情成人午夜视频| 一本久久a久久精品亚洲| 日韩一级黄色大片| 中文字幕欧美一| 日本在线观看不卡视频| 丁香婷婷综合网| 欧美日韩aaaaa| 亚洲国产精品成人综合 | 亚洲人快播电影网| 久久se精品一区二区| 97se亚洲国产综合自在线| 欧美一区2区视频在线观看| 国产欧美一区二区精品秋霞影院| 亚洲午夜免费视频| 国产成人av电影在线播放| 在线观看日韩毛片| 国产婷婷色一区二区三区在线| 亚洲妇熟xx妇色黄| 成人高清免费在线播放| 欧美福利视频一区| 自拍偷自拍亚洲精品播放| 久久精品国产澳门| 欧美丝袜自拍制服另类| 国产精品美女久久久久aⅴ国产馆| 日韩电影免费一区| 欧洲另类一二三四区| 国产精品乱码人人做人人爱| 美女网站视频久久| 欧美日韩在线亚洲一区蜜芽| 国产精品久久福利| 高清国产一区二区三区| 精品99久久久久久| 日本在线不卡一区| 欧美日韩免费一区二区三区视频 | 亚洲黄色小说网站| 成人免费三级在线| 日韩欧美中文一区二区| 亚洲午夜成aⅴ人片| 成人av网站免费| 国产婷婷一区二区| 国产一级精品在线| 精品国产91乱码一区二区三区 | 国产福利一区在线观看| 日韩欧美亚洲国产另类 | 日韩欧美一级二级三级| 午夜国产不卡在线观看视频| 91视频在线看| 亚洲人成网站色在线观看| www.66久久| 亚洲欧美影音先锋| 91免费国产视频网站| 亚洲欧洲av另类| 91免费精品国自产拍在线不卡| 中文字幕中文乱码欧美一区二区 | 一区二区三区精品视频在线| 99综合电影在线视频| 欧美激情一区二区三区不卡| 福利一区福利二区| 国产欧美精品一区| 成人免费观看av| 一色屋精品亚洲香蕉网站| 91在线视频观看| 亚洲一区视频在线观看视频| 欧美综合一区二区三区| 亚洲一卡二卡三卡四卡无卡久久| 欧美体内she精高潮| 日韩av电影天堂| 精品久久久久一区| 成人久久18免费网站麻豆| 中文字幕亚洲一区二区va在线| 色呦呦国产精品| 日韩福利电影在线| 久久蜜桃av一区精品变态类天堂| 丁香五精品蜜臀久久久久99网站| 综合激情网...| 欧美色涩在线第一页| 蓝色福利精品导航| 久久久久9999亚洲精品| 成人美女视频在线观看18| 亚洲视频一二三区| 欧美一级理论性理论a| 国内精品写真在线观看| 成人欧美一区二区三区1314| 欧美性生活大片视频| 韩日av一区二区|