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

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

?? tcp.c

?? 基于GPRS網絡的遠程監控系統
?? 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一区二区三区免费野_久草精品视频
欧美国产禁国产网站cc| 波多野结衣欧美| 色综合天天综合色综合av| 久久色视频免费观看| 午夜视频久久久久久| 在线免费观看视频一区| 亚洲一级二级三级| 欧美三级电影网站| 婷婷丁香激情综合| 这里只有精品99re| 一区二区欧美精品| 欧美综合亚洲图片综合区| 亚洲高清一区二区三区| 欧美午夜在线一二页| 亚洲电影一区二区| 久久综合狠狠综合久久激情| 久久精品72免费观看| 精品日韩在线一区| 大胆欧美人体老妇| 亚洲精品老司机| 欧美一区二区三区四区高清| 五月天久久比比资源色| 2024国产精品| 成人教育av在线| 亚洲精品老司机| 色哟哟国产精品免费观看| 午夜精品福利一区二区三区蜜桃| 欧美网站大全在线观看| 蜜臀精品一区二区三区在线观看| 国产亚洲美州欧州综合国| 91香蕉视频mp4| 亚洲成人av电影在线| 精品久久久久久久久久久院品网 | www.99精品| 日韩国产成人精品| 久久久久国产成人精品亚洲午夜 | 久久精品欧美一区二区三区不卡| 国产成人精品综合在线观看| 悠悠色在线精品| 精品国产一区二区三区四区四| 国产九九视频一区二区三区| 日韩欧美的一区| 91久久精品网| 国产一区二区三区精品视频| 亚洲欧洲色图综合| 精品国产一区二区精华| 91视频.com| 久久丁香综合五月国产三级网站| 2021国产精品久久精品 | 欧洲在线/亚洲| 久久精品av麻豆的观看方式| 一区二区三区日韩精品视频| 日韩一区二区三| 91麻豆视频网站| 视频一区中文字幕| 亚洲一区二区三区爽爽爽爽爽| 日韩欧美www| 日本精品视频一区二区三区| 丰满亚洲少妇av| 日本aⅴ精品一区二区三区| 中文欧美字幕免费| 欧美一区二区网站| 91亚洲精华国产精华精华液| 国精产品一区一区三区mba视频| 国产欧美一区二区三区鸳鸯浴 | 国产精品女主播av| 欧美三电影在线| 欧美性大战久久久久久久| 国产精品系列在线观看| 视频一区国产视频| 亚洲h在线观看| 亚洲美女视频一区| 国产免费观看久久| 欧美一区二区三区视频免费| 欧美性感一类影片在线播放| eeuss鲁片一区二区三区在线观看| 蜜桃视频免费观看一区| 日本午夜一本久久久综合| 一区二区三区在线高清| 国产精品素人一区二区| 26uuu亚洲综合色| 国产亚洲自拍一区| 久久久久久一二三区| 精品国产亚洲在线| 26uuu色噜噜精品一区二区| 3d动漫精品啪啪| 制服丝袜日韩国产| 在线观看国产91| 欧美挠脚心视频网站| 欧美日韩国产另类一区| 欧美熟乱第一页| 欧美日本在线看| 欧美电影在线免费观看| 制服丝袜日韩国产| 久久午夜色播影院免费高清| 精品国产凹凸成av人导航| 日韩免费看的电影| 欧美大片国产精品| 国产校园另类小说区| 国产亚洲一区字幕| 久久久国产午夜精品| 日韩一区二区三免费高清| 欧美成人精精品一区二区频| 2022国产精品视频| 国产日产欧产精品推荐色| 依依成人精品视频| 亚洲午夜影视影院在线观看| 亚洲第一成年网| 日本欧美大码aⅴ在线播放| 国产成人av电影| 91女神在线视频| 这里只有精品视频在线观看| 精品少妇一区二区三区日产乱码| 欧美久久久久久久久久| 亚洲精品一区二区三区四区高清| 久久青草欧美一区二区三区| 国产免费观看久久| 一卡二卡三卡日韩欧美| 久久精品免费看| 国产电影一区二区三区| 色综合久久久久综合体桃花网| 欧美蜜桃一区二区三区| 久久综合色鬼综合色| 中文字幕中文字幕一区二区 | 成人午夜激情在线| 一本久久a久久精品亚洲| 欧美v亚洲v综合ⅴ国产v| 亚洲国产精品成人久久综合一区| 亚洲精品网站在线观看| 亚洲第一福利一区| 成人av免费在线观看| 欧美三日本三级三级在线播放| 日韩欧美国产精品| 亚洲线精品一区二区三区| 视频一区二区国产| 丁香亚洲综合激情啪啪综合| 欧美天天综合网| 久久精品一区八戒影视| 亚洲一区二区欧美| 国产成人在线视频免费播放| 精品视频在线视频| 国产精品―色哟哟| 日韩国产欧美在线观看| 日本午夜精品一区二区三区电影| 成人久久18免费网站麻豆| 欧美午夜精品一区二区蜜桃| 精品国产一区久久| 亚洲一区二区三区在线| 国产91高潮流白浆在线麻豆| 97se亚洲国产综合在线| 欧美国产日韩在线观看| 日韩vs国产vs欧美| 色美美综合视频| 欧美主播一区二区三区美女| 久久久亚洲国产美女国产盗摄| 免费在线观看精品| 欧美一级精品大片| 日韩专区欧美专区| 欧美人与禽zozo性伦| 亚洲一线二线三线久久久| 91麻豆精东视频| 国产精品久线观看视频| 成人污视频在线观看| 亚洲国产精品成人综合| 成人免费视频免费观看| 中文在线免费一区三区高中清不卡| 激情国产一区二区| 久久综合精品国产一区二区三区| 精品亚洲国内自在自线福利| 欧美本精品男人aⅴ天堂| 男人的天堂亚洲一区| 日韩欧美在线网站| 久久精品国产免费看久久精品| 欧美一区二区三区人| 日本成人在线网站| 久久日韩粉嫩一区二区三区| 国产精品一二三四| 国产精品乱码久久久久久| 成人免费高清在线| 一区二区三区中文免费| 欧美性受极品xxxx喷水| 亚洲mv在线观看| 日韩欧美色综合| 国产精品白丝jk白祙喷水网站| 久久久久久97三级| 色综合中文综合网| 国产精品的网站| 97精品电影院| 亚洲成人午夜影院| 欧美肥胖老妇做爰| 国产乱码精品一品二品| 国产精品理伦片| 欧美主播一区二区三区美女| 丝袜国产日韩另类美女| 国产日韩成人精品| 色婷婷av一区| 精品一区二区免费在线观看| 国产精品水嫩水嫩| 欧美日韩国产首页在线观看| 精品一区二区三区久久|