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

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

?? tcp.c

?? 80c51 TCP/IP協(xié)議棧
?? 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一区二区三区免费野_久草精品视频
国产日韩精品一区二区三区| 日韩av一二三| 欧美日韩一级黄| 国产一区免费电影| 亚洲精品国产品国语在线app| 日本久久一区二区三区| 国内精品不卡在线| 一区二区三区精品视频在线| 精品国产一区二区三区久久影院 | 精品美女在线观看| 国产一区日韩二区欧美三区| 午夜激情综合网| 亚洲欧美日韩国产综合| 久久蜜桃香蕉精品一区二区三区| 欧美少妇性性性| 色婷婷av一区二区三区软件| 奇米影视一区二区三区小说| 亚洲自拍偷拍图区| 日韩欧美123| 欧洲另类一二三四区| 国产盗摄一区二区| 国产一区在线观看视频| 捆绑调教一区二区三区| 美女看a上一区| 丝袜诱惑制服诱惑色一区在线观看| 日韩不卡一二三区| 亚洲天堂福利av| 国产精品不卡在线| 国产精品久久久久影院亚瑟| 国产日韩精品一区二区三区在线| 久久一区二区三区四区| 久久精品网站免费观看| 综合精品久久久| 国产精品午夜在线| 国产视频一区二区三区在线观看| 久久综合九色综合久久久精品综合| 欧美日本在线播放| 精品免费国产一区二区三区四区| 日韩欧美专区在线| 精品福利av导航| 亚洲人123区| 91视频精品在这里| 一本色道久久综合亚洲91| 91久久精品国产91性色tv| 欧美日韩大陆一区二区| 日韩欧美色综合网站| 欧美国产日本韩| 性做久久久久久免费观看欧美| 免费黄网站欧美| 99久久亚洲一区二区三区青草| 色婷婷一区二区三区四区| 日韩欧美高清在线| 亚洲欧洲av一区二区三区久久| 亚洲国产精品久久不卡毛片| 精品一区二区三区影院在线午夜| 99视频精品在线| 精品少妇一区二区三区在线视频 | 成人综合日日夜夜| 9191成人精品久久| 1区2区3区精品视频| 日本成人在线看| 懂色一区二区三区免费观看| 欧美精品精品一区| 尤物视频一区二区| 成人午夜又粗又硬又大| 精品国产欧美一区二区| 国产精品资源网| 欧美日韩在线直播| 成人欧美一区二区三区白人 | 亚洲免费av观看| 福利电影一区二区三区| 欧美精品久久天天躁| 国产欧美精品国产国产专区| 蜜桃久久精品一区二区| 欧美日韩国产欧美日美国产精品| 中文一区二区在线观看| 国产高清久久久| 国产亚洲精久久久久久| 国产黄色91视频| 精品久久久久久无| 国产91丝袜在线观看| 国产精品护士白丝一区av| 91久久人澡人人添人人爽欧美| 亚洲欧美日韩国产另类专区| 欧美影院一区二区三区| 奇米在线7777在线精品 | 国产成人自拍在线| 亚洲精品大片www| 欧美精品一区二区在线播放| 波多野结衣亚洲| 偷拍日韩校园综合在线| 日日嗨av一区二区三区四区| 久久久99精品免费观看| 欧美性受xxxx黑人xyx| 国产一区二区在线看| 亚洲欧美日韩系列| 2022国产精品视频| 欧美日本不卡视频| 国产成人av电影在线播放| 一区二区三区91| 亚洲国产岛国毛片在线| 欧美一区二区三区日韩| av在线播放成人| 国产成a人亚洲| 韩国女主播一区二区三区| 亚洲一区视频在线| 亚洲成人免费看| xnxx国产精品| 日韩免费一区二区三区在线播放| 色婷婷久久一区二区三区麻豆| 国产精品123| 精品一区二区免费在线观看| 日韩国产在线观看| 一区二区三区日韩欧美| 丝袜亚洲精品中文字幕一区| 91丨porny丨户外露出| 亚洲精品成人悠悠色影视| 国产精品热久久久久夜色精品三区| 日韩欧美一二三| 亚洲精品在线电影| 337p粉嫩大胆色噜噜噜噜亚洲| 日韩三级伦理片妻子的秘密按摩| 91麻豆精品国产91久久久使用方法 | 91精品久久久久久久91蜜桃| 色婷婷激情综合| 欧美日韩另类国产亚洲欧美一级| 欧美性色黄大片手机版| 欧美久久一二三四区| 欧美久久一区二区| 精品精品国产高清a毛片牛牛 | 久久久久久久久久久黄色| 精品国产亚洲在线| 国产精品卡一卡二| 夜夜夜精品看看| 美女尤物国产一区| 国产精品一品二品| 欧美在线观看你懂的| 日韩欧美美女一区二区三区| 久久久精品国产免费观看同学| 亚洲成人先锋电影| 日本成人中文字幕| caoporn国产精品| 欧美人xxxx| 亚洲欧美综合网| 日本不卡视频在线观看| 不卡欧美aaaaa| 91精品国产综合久久久久久| 国产精品久久久久久久久久久免费看 | 久久人人97超碰com| 亚洲国产aⅴ天堂久久| 懂色av中文字幕一区二区三区| 91国偷自产一区二区开放时间 | 欧美一区二区三区免费在线看 | 欧美精品日日鲁夜夜添| 国产精品无码永久免费888| 日韩vs国产vs欧美| 欧美日韩综合一区| 中文字幕色av一区二区三区| 免费成人av在线播放| 欧美精品乱码久久久久久| 亚洲精品日韩综合观看成人91| 国产精品一区在线观看乱码| 欧美日本免费一区二区三区| 一区二区三区在线播| 色综合久久88色综合天天免费| 国产日产欧产精品推荐色| 激情图片小说一区| 欧美成人aa大片| 国产最新精品免费| 欧美精品色一区二区三区| 日韩欧美国产三级| 亚洲va中文字幕| 欧美日韩综合不卡| 偷拍与自拍一区| 日韩精品一区二区三区三区免费| 日韩高清中文字幕一区| 欧美一级黄色录像| 久久99国产精品尤物| 一区二区三区成人| 色综合久久88色综合天天 | 成人精品免费看| 国产精品你懂的在线| 91麻豆精品秘密| 爽好久久久欧美精品| 日韩欧美视频一区| 成人妖精视频yjsp地址| 一区二区欧美视频| 欧美一区二区女人| 国产一区二区不卡在线| 国产精品免费aⅴ片在线观看| 91免费精品国自产拍在线不卡| 国产欧美视频在线观看| 黄色资源网久久资源365| 国产欧美日韩久久| 欧美三区在线观看| 久久国产夜色精品鲁鲁99| 中文字幕在线一区免费| 欧美人牲a欧美精品| 成人免费观看视频| 天天色综合成人网|