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

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

?? tcp.c

?? 一個(gè)8位單片機(jī)的TCPIP處理程序
?? 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");
      }
   }
}



?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产综合久久福利| 精品国产乱码久久久久久1区2区| 懂色av一区二区三区免费看| 国内久久精品视频| 国产精品1区2区3区在线观看| 韩国女主播成人在线| 国产成人午夜视频| 国产一区二区三区高清播放| 豆国产96在线|亚洲| 色噜噜狠狠色综合中国| 色综合久久88色综合天天| 欧美少妇bbb| 日韩欧美一级在线播放| 久久久久久久久久电影| 国产精品乱码久久久久久| 一区二区三区在线观看动漫| 日韩国产精品91| 毛片av一区二区| 国产成人av自拍| 在线观看欧美黄色| 日韩欧美美女一区二区三区| 国产精品美女视频| 五月综合激情日本mⅴ| 国内精品第一页| 色综合久久天天| 欧美日韩综合在线免费观看| 精品少妇一区二区三区| 亚洲私人黄色宅男| 美女诱惑一区二区| 99久久精品免费| 日韩一区二区精品| 亚洲三级在线播放| 久久99精品国产麻豆不卡| 97久久精品人人爽人人爽蜜臀| 在线观看区一区二| 日韩午夜激情av| 日韩美女啊v在线免费观看| 青青草一区二区三区| 国产精品一区二区你懂的| 日本电影欧美片| 日韩午夜激情视频| 亚洲精品视频观看| 丁香一区二区三区| 337p粉嫩大胆色噜噜噜噜亚洲| 午夜精品久久一牛影视| 色综合婷婷久久| 中国av一区二区三区| 久久99国内精品| 欧美一区二区三区在线观看视频| 亚洲美女少妇撒尿| eeuss影院一区二区三区| 久久66热偷产精品| 成人网在线免费视频| 欧美一区二视频| 亚洲一二三四区| 91蜜桃在线免费视频| 久久久久久久久免费| 另类欧美日韩国产在线| 精品视频色一区| 亚洲欧美另类小说| caoporm超碰国产精品| 欧美国产丝袜视频| 丰满少妇在线播放bd日韩电影| 久久久久久综合| 国产综合久久久久影院| 欧美电影免费观看高清完整版| 日韩av在线免费观看不卡| 欧美丰满高潮xxxx喷水动漫| 亚洲成av人片一区二区梦乃| 欧美性生活久久| 亚洲综合视频在线| 日本丶国产丶欧美色综合| 亚洲激情六月丁香| 欧美视频在线观看一区| 一区二区三区高清在线| 欧美性色黄大片手机版| 亚洲国产精品久久久久秋霞影院| 欧美性极品少妇| 天天操天天色综合| 91麻豆精品国产91久久久久| 美日韩黄色大片| 久久婷婷久久一区二区三区| 福利一区二区在线| 亚洲色图色小说| 欧美最猛性xxxxx直播| 亚洲二区视频在线| 日韩亚洲欧美成人一区| 精品一区二区免费在线观看| 久久嫩草精品久久久精品一| 国产91精品精华液一区二区三区| 国产精品成人免费精品自在线观看| 91亚洲精华国产精华精华液| 亚洲综合成人在线| 7777精品久久久大香线蕉 | av一区二区久久| 亚洲人123区| 在线不卡欧美精品一区二区三区| 奇米四色…亚洲| 久久欧美中文字幕| 99在线热播精品免费| 亚洲高清免费在线| 69p69国产精品| 国产精品资源站在线| 亚洲欧美日韩小说| 3atv在线一区二区三区| 国产麻豆9l精品三级站| 亚洲欧美视频在线观看| 欧美高清视频一二三区 | 日韩网站在线看片你懂的| 国产乱码精品一区二区三区五月婷 | 国产精品动漫网站| 91国产免费看| 免费成人结看片| 国产精品美女久久久久aⅴ| 欧美性欧美巨大黑白大战| 日本视频一区二区| 国产精品美女久久久久久久久 | 亚洲另类一区二区| 欧美一级淫片007| 国产suv一区二区三区88区| 亚洲乱码一区二区三区在线观看| 日韩一级片在线播放| 高清av一区二区| 日日夜夜一区二区| 欧美国产精品劲爆| 777亚洲妇女| 99久久婷婷国产综合精品| 男男视频亚洲欧美| 18涩涩午夜精品.www| 日韩亚洲欧美一区二区三区| 91丨九色丨国产丨porny| 蜜臀av亚洲一区中文字幕| 中文字幕亚洲一区二区va在线| 欧美一区二区高清| 蜜桃精品在线观看| 99视频在线精品| 欧美日韩一区 二区 三区 久久精品| 色综合色狠狠天天综合色| 欧美美女一区二区在线观看| 中文幕一区二区三区久久蜜桃| 国产精品美女久久久久av爽李琼| 久久国产麻豆精品| 日韩精品国产欧美| 国产亚洲一本大道中文在线| 欧美日韩情趣电影| 男人操女人的视频在线观看欧美| 91福利国产精品| 国产精品久久三| 精品亚洲国内自在自线福利| 欧美日韩精品专区| 奇米色777欧美一区二区| 国产色91在线| 色婷婷亚洲一区二区三区| 亚洲成av人片在线| 日本道免费精品一区二区三区| 精品欧美乱码久久久久久1区2区| 亚洲精品国产一区二区精华液| 日本午夜精品视频在线观看| 91精品国产一区二区三区蜜臀 | 高清久久久久久| 国产精品久久久久久久久晋中| 精品一区二区三区免费观看 | 精品久久国产字幕高潮| 久久精品人人做人人综合| 极品瑜伽女神91| 日韩欧美国产电影| 国产做a爰片久久毛片| 欧美人狂配大交3d怪物一区| 亚洲人成亚洲人成在线观看图片| 国产成人一区在线| 国产欧美一区二区精品性色| 亚洲一区二区欧美日韩| 一本色道久久综合亚洲aⅴ蜜桃| 国产精品午夜在线| 国产精品一区二区免费不卡 | 中文字幕欧美国产| 老司机精品视频在线| 欧美日韩视频在线第一区| **欧美大码日韩| thepron国产精品| 欧美一区二区三区视频| 五月婷婷色综合| 久久久亚洲国产美女国产盗摄 | 久久婷婷国产综合国色天香| 免费在线观看一区| 欧美理论电影在线| 亚洲国产日日夜夜| 欧美日韩一级视频| 亚洲综合在线视频| 欧美一区二区三区在线电影| 亚洲最新视频在线观看| 日韩一区二区视频在线观看| 亚洲精品一二三四区| 制服丝袜av成人在线看| 国产露脸91国语对白| 精品乱码亚洲一区二区不卡| 风流少妇一区二区| 毛片av一区二区三区| 亚洲人成在线观看一区二区| 精品国产乱码久久久久久免费|