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

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

?? tcp.c

?? c8051f020源代碼39個 使用Silicon Labs IDE 調試器
?? C
?? 第 1 頁 / 共 2 頁
字號:
   
   // If i = 5, we are not connected. If it is a SYN then assign
   // 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| 成人激情午夜影院| 在线成人免费观看| 亚洲女厕所小便bbb| 国产一区二区三区香蕉| 欧美人xxxx| 成人欧美一区二区三区在线播放| 日本欧美肥老太交大片| 色先锋aa成人| 国产精品久久网站| 国产精品一区二区果冻传媒| 欧美日韩不卡视频| 亚洲综合视频在线| 色婷婷亚洲精品| 国产精品狼人久久影院观看方式| 国产自产2019最新不卡| 日韩亚洲欧美中文三级| 亚洲午夜久久久| 在线观看免费一区| 亚洲精品国产视频| av激情综合网| 中文字幕日韩精品一区| www.亚洲在线| 亚洲人成小说网站色在线| 成人精品一区二区三区四区| 久久这里只有精品6| 国产精品综合一区二区三区| www国产成人免费观看视频 深夜成人网 | 国产福利视频一区二区三区| 日韩免费观看高清完整版在线观看| 亚洲成人免费观看| 欧美三级日本三级少妇99| 亚洲激情欧美激情| 欧美日韩免费观看一区三区| 亚洲高清在线视频| 欧美一区二区视频网站| 免费欧美高清视频| 欧美mv日韩mv亚洲| 国产 日韩 欧美大片| 国产精品日日摸夜夜摸av| 99久久夜色精品国产网站| 一区二区三区丝袜| 欧美妇女性影城| 九一九一国产精品| 久久精品夜夜夜夜久久| 99国产精品国产精品久久| 亚洲激情在线激情| 日韩一区二区免费高清| 韩国女主播成人在线观看| 欧美极品少妇xxxxⅹ高跟鞋| 99riav一区二区三区| 亚洲高清视频中文字幕| 精品国产乱码久久久久久免费| 国产盗摄女厕一区二区三区| 中文字幕五月欧美| 欧美一区二区三区视频在线| 国产成人亚洲综合色影视| 夜夜嗨av一区二区三区四季av| 欧美日韩成人激情| 国产精品亚洲成人| 亚洲黄色录像片| 精品噜噜噜噜久久久久久久久试看| 国产高清久久久| 性感美女极品91精品| 久久精品一区二区| 欧美在线视频日韩| 国产精品综合av一区二区国产馆| 亚洲男人的天堂在线aⅴ视频| 欧美一卡在线观看| av亚洲精华国产精华精华| 蜜臀精品久久久久久蜜臀| 国产精品久久久久久久浪潮网站| 欧美男女性生活在线直播观看| 高清不卡一二三区| 奇米综合一区二区三区精品视频| 中文字幕不卡在线观看| 日韩欧美一级片| 欧美色图激情小说| 成人久久视频在线观看| 免费国产亚洲视频| 亚洲成年人网站在线观看| 国产精品女主播在线观看| 欧美一级二级三级蜜桃| 91搞黄在线观看| 成人午夜伦理影院| 国产原创一区二区三区| 亚洲二区在线视频| 亚洲男帅同性gay1069| 国产午夜精品在线观看| 日韩三级视频中文字幕| 欧美日韩精品免费| 91理论电影在线观看| 成人夜色视频网站在线观看| 麻豆91免费观看| 日日欢夜夜爽一区| 亚洲视频在线观看一区| 中文字幕va一区二区三区| 久久精品欧美日韩精品| 精品免费国产二区三区| 日韩一级二级三级精品视频| 欧美精品一二三区| 欧美日韩国产综合一区二区| 日本电影亚洲天堂一区| 91麻豆视频网站| jlzzjlzz亚洲日本少妇| 成人av午夜影院| 丰满白嫩尤物一区二区| 国产超碰在线一区| 国产一区 二区 三区一级| 激情综合色综合久久综合| 麻豆国产一区二区| 久久91精品国产91久久小草| 久久66热re国产| 国产一区二区视频在线| 激情综合一区二区三区| 国产精品夜夜爽| www.欧美色图| 色系网站成人免费| 欧美日韩亚洲综合在线| 欧美一区二区三区在线观看| 欧美不卡一区二区三区| 久久久青草青青国产亚洲免观| 2021国产精品久久精品| 国产欧美一区二区在线观看| 欧美激情在线一区二区| 亚洲视频1区2区| 亚洲不卡av一区二区三区| 青青草精品视频| 国产精品一二三四区| 91小视频在线免费看| 欧美日韩精品欧美日韩精品一 | 美日韩一区二区| 久久 天天综合| 成人性色生活片| 在线看国产日韩| 欧美大肚乱孕交hd孕妇| 亚洲国产成人在线| 亚洲一区二区三区激情| 久久99精品久久久久| 成人免费视频播放| 欧美做爰猛烈大尺度电影无法无天| 欧美一二三在线| 中文字幕色av一区二区三区| 日韩精品视频网| 丰满放荡岳乱妇91ww| 欧美人妇做爰xxxⅹ性高电影| 26uuu久久综合| 亚洲国产日韩在线一区模特| 黄页网站大全一区二区| 色综合久久久久| 欧美精品一区二区三区很污很色的 | 国产精品久久午夜夜伦鲁鲁| 亚洲v中文字幕| 成人丝袜18视频在线观看| 欧美日韩一区二区三区四区五区 | 国产成人久久精品77777最新版本| 一本一道久久a久久精品 | 欧美日韩在线精品一区二区三区激情| 日韩一区二区三区在线观看| 国产精品污www在线观看| 日韩成人午夜电影| 一本高清dvd不卡在线观看 | 欧美一区二区黄色| 一区二区三区精品视频| 夫妻av一区二区| 日韩欧美你懂的| 香蕉久久一区二区不卡无毒影院 | 午夜av一区二区| av综合在线播放| 久久久不卡网国产精品二区| 日韩精品欧美成人高清一区二区| 99视频国产精品| 久久久精品影视| 久久99精品一区二区三区三区| 在线精品视频一区二区| 亚洲国产精品国自产拍av| 麻豆精品一区二区| 91精品视频网| 午夜av电影一区| 欧美色涩在线第一页| 洋洋av久久久久久久一区| 91色在线porny| 国产精品区一区二区三区| 久久国内精品视频| 欧美一级一级性生活免费录像| 亚洲午夜三级在线| 欧美伊人久久久久久午夜久久久久| 国产精品久久久久久亚洲伦| 国产91精品一区二区麻豆网站 | 欧美成人伊人久久综合网| 亚洲1区2区3区视频| 欧美午夜视频网站| 亚洲午夜在线视频| 欧美精选午夜久久久乱码6080| 亚洲一本大道在线| 欧美日韩国产中文| 日韩电影免费在线观看网站| 777a∨成人精品桃花网| 美女免费视频一区二区|