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

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

?? tcp.c

?? 8051 Web Server project See Makefile for build notes Written for Keil C51 V5.1 compiler, notes:
?? 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一区二区三区免费野_久草精品视频
欧美欧美午夜aⅴ在线观看| 国产亚洲制服色| 精品国产伦一区二区三区免费| 国产精品视频看| 视频一区二区不卡| 99精品视频免费在线观看| 欧美视频第二页| 国产精品欧美一区喷水| 看片网站欧美日韩| 91福利国产精品| 亚洲欧洲av另类| 国产很黄免费观看久久| 欧美一区欧美二区| 亚洲一二三级电影| 91丨九色丨尤物| 欧美国产激情一区二区三区蜜月| 奇米影视一区二区三区| 欧美日韩三级一区二区| 国产精品美女久久福利网站 | 久久aⅴ国产欧美74aaa| 在线免费不卡视频| 亚洲同性gay激情无套| 国产大陆亚洲精品国产| 日韩精品在线一区| 视频在线观看91| 欧美人与z0zoxxxx视频| 曰韩精品一区二区| 91在线看国产| 中文字幕一区二区不卡 | 不卡视频在线看| 国产亚洲一本大道中文在线| 精品一区二区三区香蕉蜜桃 | 久久精品视频一区二区| 韩国一区二区视频| 久久综合九色综合欧美亚洲| 日韩二区三区在线观看| 欧美一区二区三区电影| 日韩高清一区在线| 欧美一区二视频| 日本欧美肥老太交大片| 91精品国产综合久久小美女| 日本中文字幕一区二区视频| 欧美日产国产精品| 日韩av在线发布| 欧美tickling网站挠脚心| 极品瑜伽女神91| 国产日产欧美一区二区三区| 成人深夜在线观看| 一区二区在线观看av| 在线观看成人小视频| 天堂久久一区二区三区| 精品奇米国产一区二区三区| 国产美女一区二区| 国产精品对白交换视频| 91福利在线观看| 欧美aaaaaa午夜精品| 久久久久久久久蜜桃| 不卡视频在线观看| 亚洲一区二区影院| 日韩一区二区三区四区 | 久久99久久精品| 国产欧美日韩久久| 色一情一伦一子一伦一区| 五月天欧美精品| 久久久蜜桃精品| 色综合久久综合| 首页国产欧美久久| 国产欧美一区二区精品秋霞影院| av男人天堂一区| 免费看欧美美女黄的网站| 中文一区二区在线观看| 欧美日韩免费高清一区色橹橹| 日本午夜精品一区二区三区电影| 国产日韩欧美一区二区三区综合| 91免费视频网| 久久se精品一区二区| 亚洲乱码日产精品bd| 日韩欧美国产精品| 色综合天天做天天爱| 蜜桃久久精品一区二区| 亚洲特黄一级片| 久久伊人中文字幕| 欧美日韩三级视频| 9l国产精品久久久久麻豆| 日韩精品成人一区二区三区 | 欧美精品一区二区高清在线观看| 99在线精品观看| 美女视频黄免费的久久| 亚洲精品乱码久久久久| 久久久久久久av麻豆果冻| 欧美日韩国产一区| k8久久久一区二区三区 | 欧美一区二区三区影视| 91免费观看视频| 国产成人午夜片在线观看高清观看| 亚洲成人一区二区| 国产精品久久久久精k8| 精品国产乱码久久久久久久久| 在线一区二区三区四区| 成人的网站免费观看| 国产一区二区三区精品视频| 日韩经典一区二区| 性欧美大战久久久久久久久| 亚洲人成人一区二区在线观看| 国产午夜亚洲精品理论片色戒| 日韩欧美色综合网站| 欧美精品在线视频| 91极品视觉盛宴| 91色|porny| 91视频免费看| 99久久久无码国产精品| 国产成人免费xxxxxxxx| 国产精品99久久久| 国产美女一区二区三区| 裸体一区二区三区| 蜜臀99久久精品久久久久久软件| 亚洲国产精品久久人人爱| 一区二区三区四区激情| 亚洲人成人一区二区在线观看| 中文字幕在线观看不卡| 中文字幕亚洲一区二区av在线| 久久精品一区四区| 欧美国产一区在线| 中文字幕日韩精品一区| 18涩涩午夜精品.www| 亚洲精品免费在线观看| 亚洲一区二区四区蜜桃| 亚洲www啪成人一区二区麻豆| 午夜精品久久久久久久久久| 日韩在线卡一卡二| 久久99精品国产麻豆不卡| 国产最新精品免费| 国产91丝袜在线播放0| 99免费精品在线观看| 色噜噜狠狠成人中文综合| 欧美视频第二页| 日韩一二三区视频| 中文字幕欧美日韩一区| 亚洲三级电影网站| 天堂成人国产精品一区| 黄色日韩网站视频| 9人人澡人人爽人人精品| 欧美在线一区二区三区| 日韩午夜小视频| 国产免费成人在线视频| 亚洲麻豆国产自偷在线| 日韩精品国产欧美| 国产91清纯白嫩初高中在线观看 | 久久精品99久久久| 粉嫩aⅴ一区二区三区四区| 色婷婷精品久久二区二区蜜臀av| 555夜色666亚洲国产免| 久久久久国色av免费看影院| 亚洲黄色尤物视频| 激情欧美日韩一区二区| 色伊人久久综合中文字幕| 日韩网站在线看片你懂的| 国产精品色呦呦| 日韩和欧美一区二区三区| 国产99久久久国产精品免费看| 色婷婷综合久久| 日韩丝袜情趣美女图片| 亚洲欧美成人一区二区三区| 青娱乐精品在线视频| jizzjizzjizz欧美| 欧美一区二区三区视频在线观看| 日本一区二区高清| 日韩激情一区二区| 色一区在线观看| 久久久精品黄色| 视频一区在线视频| 一本到一区二区三区| 国产日韩高清在线| 另类综合日韩欧美亚洲| 在线观看一区日韩| 日本一二三四高清不卡| 久久99九九99精品| 91精品免费观看| 亚洲一区二区偷拍精品| 99久久精品99国产精品| 精品国产一区二区三区久久影院 | 亚洲天堂2014| 粉嫩av一区二区三区粉嫩| 日韩欧美一区电影| 亚欧色一区w666天堂| av不卡在线播放| 国产欧美一区在线| 国产美女精品一区二区三区| 制服视频三区第一页精品| 亚洲欧美日韩中文播放 | 天使萌一区二区三区免费观看| 91网站最新地址| 国产精品成人免费在线| 成人三级伦理片| 亚洲国产精品国自产拍av| 国产麻豆视频一区二区| 久久久欧美精品sm网站 | 免费欧美高清视频| 宅男在线国产精品| 三级精品在线观看|