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

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

?? tcp.c

?? 單片機控制RTL8019AS的程序,C語言編寫,仿真通過.
?? 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;
         
         
      }
   }


   // 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)
   {
      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) 
   {

		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
      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))
		{
			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
		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;
     
      }
		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;

               
        	// 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;

      }

		// Make sure he is ACKing my SYN
		else if (tcp->ack_number == conxn[nr].my_sequence)
      {
         conxn[nr].state = STATE_ESTABLISHED;
         // 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;

               
        	// 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;

      }
		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
      
      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
      }
      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;
               
         	conxn[nr].state = STATE_CLOSED;
         	conxn[nr].ipaddr = 0;  // Free up connection

      	}
			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;

			}
		}
      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;

      }
      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;
         conxn[nr].state = STATE_CLOSED;
         conxn[nr].ipaddr = 0;  // Free up struct area
      }
      break;
            
            
      case STATE_TIME_WAIT:
      // With this code, should not get here
      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;
         
         // Do not send any response to his ACK
         conxn[nr].state = STATE_CLOSED;
         conxn[nr].ipaddr = 0;  // Free up struct area

      }
      break;

      
      default:
      break;
   }
   
 
   
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一区二区不卡| 亚洲电影欧美电影有声小说| 日本视频免费一区| 91精品一区二区三区在线观看| 亚洲精品视频免费看| 在线影院国内精品| 亚洲国产你懂的| 欧美一区二区在线播放| 狠狠色丁香婷综合久久| 亚洲国产成人在线| 一本大道av伊人久久综合| 亚洲一区在线电影| 日韩欧美精品在线视频| 国产精品亚洲人在线观看| 中文字幕成人网| 欧美午夜精品理论片a级按摩| 亚洲午夜影视影院在线观看| 日韩一区二区三区四区五区六区| 激情小说欧美图片| 18欧美亚洲精品| 欧美另类变人与禽xxxxx| 国产在线精品一区二区不卡了| 中文在线一区二区| 91超碰这里只有精品国产| 激情五月婷婷综合| 亚洲欧美一区二区三区国产精品| 欧美精品日韩一区| 国产91在线|亚洲| 亚洲国产精品视频| 久久久99免费| 日本韩国欧美一区二区三区| 蜜桃传媒麻豆第一区在线观看| 国产精品国产精品国产专区不蜜| 欧美人妖巨大在线| 99精品偷自拍| 久久国产免费看| 亚洲精品五月天| 久久日韩精品一区二区五区| 91久久精品一区二区二区| 韩国成人福利片在线播放| 亚洲综合一区在线| 日本一区二区三区电影| 欧美日韩国产首页| av一区二区三区在线| 麻豆成人综合网| 一区二区三区四区国产精品| 26uuu久久天堂性欧美| 欧美精品一二三| 97精品久久久久中文字幕 | 免播放器亚洲一区| 中文字幕精品一区| 欧美不卡视频一区| 欧美日韩成人在线一区| 91网页版在线| 成人99免费视频| 国产一区二区精品久久91| 日韩有码一区二区三区| 一区二区三区四区蜜桃| 中文字幕一区av| 国产日韩一级二级三级| 欧美成人艳星乳罩| 欧美一三区三区四区免费在线看| 色菇凉天天综合网| 色哟哟国产精品免费观看| 成人动漫中文字幕| 国产传媒日韩欧美成人| 精品在线播放免费| 久久国产免费看| 麻豆免费看一区二区三区| 日韩高清中文字幕一区| 亚洲第四色夜色| 一区二区三区国产精品| 亚洲欧美日韩在线| 亚洲欧美一区二区不卡| 亚洲图片另类小说| 亚洲婷婷在线视频| 成人免费在线视频| 一区二区三区欧美| 亚洲精品成人少妇| 91麻豆文化传媒在线观看| 国产69精品久久久久777| 国内精品在线播放| 国产一区二区三区四区五区入口 | 午夜视频一区在线观看| 午夜私人影院久久久久| 无码av免费一区二区三区试看| 亚洲一区在线播放| 日本在线不卡一区| 日韩高清欧美激情| 九色|91porny| 懂色一区二区三区免费观看| 成人福利视频网站| 91久久精品一区二区二区| 欧美日韩在线三区| 91精品久久久久久蜜臀| 精品久久久久久久久久久久包黑料| 日韩欧美成人一区二区| 精品va天堂亚洲国产| 国产调教视频一区| 一区二区三区中文在线| 香蕉久久夜色精品国产使用方法| 男女性色大片免费观看一区二区 | 欧美三级日韩三级国产三级| 欧美片在线播放| 精品欧美一区二区久久| 中文一区一区三区高中清不卡| 一区二区三区欧美在线观看| 蜜桃视频在线观看一区| 高清成人免费视频| 欧美日韩综合在线免费观看| 日韩三区在线观看| 国产精品久久免费看| 亚洲v精品v日韩v欧美v专区| 国产综合久久久久久鬼色 | 日本高清免费不卡视频| 欧美日韩另类一区| 亚洲精品一线二线三线无人区| 中文字幕一区二区在线观看| 亚洲一区二区偷拍精品| 寂寞少妇一区二区三区| 99re这里只有精品视频首页| 5566中文字幕一区二区电影| 日本一区二区电影| 免费观看一级特黄欧美大片| 成人免费av资源| 欧美电影一区二区三区| 国产精品家庭影院| 奇米影视一区二区三区小说| 91丝袜高跟美女视频| 日韩免费看的电影| 一区二区视频免费在线观看| 国产精品一区二区在线观看不卡| 欧洲一区二区av| 中文幕一区二区三区久久蜜桃| 偷拍一区二区三区四区| 9久草视频在线视频精品| 欧美成人三级在线| 亚洲成人资源在线| 色综合久久久久久久久久久| 久久综合色天天久久综合图片| 一卡二卡三卡日韩欧美| 不卡一卡二卡三乱码免费网站| 日韩欧美一区在线| 亚洲成人综合视频| 91蜜桃免费观看视频| 久久久久国产精品厨房| 老司机精品视频导航| 欧美伊人精品成人久久综合97 | 狠狠色丁香婷综合久久| 在线精品亚洲一区二区不卡| 国产精品毛片a∨一区二区三区| 久久99久久久久| 欧美日韩中文字幕一区二区| 中文字幕av不卡| 国产成人一级电影| 久久久精品免费观看| 日本亚洲视频在线| 欧美巨大另类极品videosbest| 亚洲码国产岛国毛片在线| 国产精品88av| 26uuuu精品一区二区| 国产在线观看免费一区| 日韩欧美国产电影| 蜜桃精品视频在线| 91精品久久久久久久99蜜桃| 天天影视网天天综合色在线播放 | 不卡的av电影在线观看| 国产日韩精品一区二区三区在线| 国产一区二区看久久| 久久久精品欧美丰满| 国产精品主播直播| 国产欧美一区二区在线| 国产精品888| 日本一区二区成人| 91视频xxxx| 亚洲综合激情网| 欧美日韩午夜影院| 蜜臀av一级做a爰片久久| 欧美精品一区二区久久婷婷| 国产米奇在线777精品观看| 久久精品视频在线看| 成人永久免费视频| 成人欧美一区二区三区| 在线观看国产91| 免费观看在线综合| 欧美激情一区二区三区四区 | 一区二区日韩电影| 欧美日韩亚洲高清一区二区| 日本不卡在线视频| 欧美精品一区二区不卡| 波多野结衣精品在线| 亚洲欧美日韩国产一区二区三区 | 欧美成人艳星乳罩| 丁香啪啪综合成人亚洲小说| 有码一区二区三区| 欧美一区国产二区| 成人一区二区三区视频| 亚洲综合在线观看视频| 日韩天堂在线观看| 风流少妇一区二区|