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

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

?? tcp.c

?? C51的tcpip源程序 包含了TCP,IP,ARP,ICMP等協議的接口
?? 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小视频免费看| 欧美日韩电影在线播放| 欧美韩国日本一区| 男人的天堂久久精品| 99re视频这里只有精品| 欧美一级久久久| 亚洲欧美一区二区三区国产精品 | 一区二区在线观看av| 久久成人av少妇免费| 91久久国产最好的精华液| 欧美国产亚洲另类动漫| 另类的小说在线视频另类成人小视频在线 | 看电视剧不卡顿的网站| 欧美午夜精品久久久| 国产精品久久久久久久久久久免费看 | 99久久免费精品高清特色大片| 欧美精品一区二区三区蜜臀 | 国产精品久久久久精k8| 麻豆成人久久精品二区三区红| 在线观看日韩电影| 亚洲激情综合网| 色伊人久久综合中文字幕| 国产精品久久久久久久久免费桃花 | 高清不卡在线观看av| 欧美电影精品一区二区| 麻豆精品国产91久久久久久| 91精品午夜视频| 亚洲成a人v欧美综合天堂下载| 色婷婷亚洲综合| 亚洲精品自拍动漫在线| 91久久精品一区二区| 一级特黄大欧美久久久| 色屁屁一区二区| 亚洲最大的成人av| 91福利精品视频| 夜夜揉揉日日人人青青一国产精品| aaa欧美大片| 亚洲色欲色欲www| 91麻豆精品视频| 亚洲国产人成综合网站| 欧美男生操女生| 日本欧美在线观看| 精品精品国产高清一毛片一天堂| 精品影视av免费| 国产人久久人人人人爽| 成人永久看片免费视频天堂| 中文字幕永久在线不卡| 在线观看中文字幕不卡| 首页国产欧美日韩丝袜| 日韩一级大片在线观看| 激情欧美一区二区三区在线观看| 久久综合久久综合亚洲| 成人做爰69片免费看网站| 亚洲欧美国产77777| 欧美日韩一区在线| 久久99久国产精品黄毛片色诱| 久久精品一区八戒影视| 色婷婷综合久色| 麻豆国产精品官网| 国产精品家庭影院| 欧美色图12p| 狠狠色2019综合网| 亚洲欧洲日产国码二区| 欧美伦理电影网| 国产成人啪免费观看软件| 亚洲你懂的在线视频| 日韩精品一区国产麻豆| 9人人澡人人爽人人精品| 亚洲午夜电影在线| xfplay精品久久| 欧洲av一区二区嗯嗯嗯啊| 麻豆精品久久久| 亚洲美女偷拍久久| 欧美精品一区二区三区视频| 日本韩国一区二区三区视频| 国产在线日韩欧美| 一区二区三区四区蜜桃| 久久综合国产精品| 欧美日韩国产在线观看| 成人一区二区三区视频| 日韩av高清在线观看| 亚洲人成网站在线| 精品对白一区国产伦| 欧美性受xxxx黑人xyx性爽| 国产精品123区| 免费在线一区观看| 亚洲欧美色综合| 久久久综合激的五月天| 欧美色男人天堂| av在线播放成人| 国产精品一区二区不卡| 欧美bbbbb| 亚洲电影一区二区三区| 国产精品久久久久aaaa| 国产无遮挡一区二区三区毛片日本| 欧美在线视频全部完| 成人美女在线观看| 国内精品伊人久久久久av一坑| 亚洲一区二区三区四区中文字幕| 中文字幕一区二区视频| 国产欧美日本一区二区三区| 精品成人a区在线观看| 91精品国产高清一区二区三区| 欧洲视频一区二区| 91香蕉国产在线观看软件| 国产成人精品亚洲777人妖| 国产一区二区三区日韩| 国内外精品视频| 精品一区二区三区av| 麻豆91精品视频| 美女www一区二区| 精品在线视频一区| 另类成人小视频在线| 六月丁香婷婷久久| 麻豆成人91精品二区三区| 久久精品国产免费| 韩国三级电影一区二区| 国产精品一区二区视频| 国产成人av影院| 懂色av中文字幕一区二区三区| 丁香网亚洲国际| www.视频一区| 91麻豆产精品久久久久久| 色视频成人在线观看免| 欧美在线免费视屏| 欧美日韩和欧美的一区二区| 91精品国产综合久久精品麻豆| 欧美一区二区三区人| 欧美zozo另类异族| 国产欧美精品区一区二区三区| 国产亚洲成aⅴ人片在线观看| 中文字幕免费不卡| 亚洲三级免费观看| 亚洲高清免费观看 | 欧美精品粉嫩高潮一区二区| 日韩一区二区电影在线| 国产日韩欧美精品电影三级在线| 亚洲婷婷国产精品电影人久久| 亚洲一区二区精品久久av| 青青草国产精品97视觉盛宴 | 国产精品自拍网站| av一区二区久久| 欧美精品久久一区| 国产人妖乱国产精品人妖| 亚洲尤物在线视频观看| 久久国产综合精品| av在线免费不卡| 91精品国产综合久久久久久| 欧美国产日韩在线观看| 午夜久久电影网| 国产成人自拍网| 欧美日韩亚洲高清一区二区| 国产午夜亚洲精品不卡| 亚洲一区二区精品视频| 国产精品一区二区免费不卡 | 粉嫩嫩av羞羞动漫久久久| 色偷偷一区二区三区| 精品国产乱码久久久久久免费| 亚洲品质自拍视频| 国产一区二区三区美女| 欧美影视一区在线| 中文在线免费一区三区高中清不卡| 一区二区三区中文免费| 国产剧情一区二区| 欧美理论片在线| 日韩毛片一二三区| 国产一区二区三区久久久| 欧美日韩一区不卡| 一区精品在线播放| 国产精品一区二区在线观看不卡| 欧美日韩国产一区二区三区地区| 日本一区二区三区在线观看| 日韩不卡在线观看日韩不卡视频| 91在线观看高清| 国产欧美日韩在线| 九色porny丨国产精品| 欧美乱熟臀69xxxxxx| 亚洲女女做受ⅹxx高潮| 国产aⅴ精品一区二区三区色成熟| 日韩一区二区三区精品视频| 午夜精品久久久久久不卡8050| av资源网一区| 欧美国产综合色视频| 韩日av一区二区| 欧美大片一区二区三区| 天堂影院一区二区| 欧美色综合久久| 一区二区不卡在线播放 | 欧美优质美女网站| 亚洲欧美激情插| 91网站最新地址| 18成人在线观看| 成人av在线看| 国产精品久久久久三级|