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

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

?? tcp.lst

?? 用c8051f340基于51單片機(jī)上網(wǎng)
?? LST
?? 第 1 頁 / 共 3 頁
字號:
C51 COMPILER V8.08   TCP                                                                   11/04/2008 18:45:34 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE TCP
OBJECT MODULE PLACED IN Tcp.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.exe Tcp.c DB OE

line level    source

   1          //-----------------------------------------------------------------------------
   2          // Copyright (c) 2002 Jim Brady
   3          // Do not use commercially without author's permission
   4          // Last revised August 2002
   5          // Net TCP.C
   6          //
   7          // This module handles TCP segments
   8          // Refer to RFC 793, 896, 1122, 1323, 2018, 2581
   9          //
  10          // A "connection" is a unique combination of 4 items:  His IP address,
  11          // his port number, my IP address, and my port number.
  12          //
  13          // Note that a SYN and a FIN count as a byte of data, but a RST does
  14          // not count. Neither do any of the other flags.
  15          // See "TCP/IP Illustrated, Volume 1" Sect 17.3 for info on flags
  16          //-----------------------------------------------------------------------------
  17          #include <string.h>
  18          //#include <stdlib.h>
  19          #include <ctype.h>              // toupper
  20          #include "C8051f340.h"
  21          #include "global.h"
  22          ///#include "net.h"
  23          #include "cksum.h"
  24          #include "ip.h"
  25          #include "http.h"
  26          #include "tcp.h"
  27          extern char xdata outbuf1[];
  28          
  29          // These structures keep track of connection information
  30          CONNECTION xdata conxn[5];
  31          
  32          ULONG idata initial_sequence_nr;
  33          UINT xdata sender_tcpport;
  34          static ULONG xdata sender_ipaddr;
  35          UCHAR idata just_closed; // Keeps track of when a conxn closed
  36          
  37          extern ULONG code my_ipaddr;
  38          extern UCHAR idata debug;
  39          extern char xdata text[];
  40          
  41          // Options: MSS (4 bytes), NOPS (2 bytes), Selective ACK (2 bytes) 
  42          UCHAR code opt[10] = {
  43          0x02, 0x04, 0x05, 0xB4,
  44          0x01, 0x01,
  45          0x04, 0x02};
  46          
  47          
  48          
  49          //------------------------------------------------------------------------
  50          //  Initialize variables declared in this module
  51          //
  52          //------------------------------------------------------------------------
  53          void init_tcp(void)
  54          {
  55   1         memset(conxn, 0, sizeof(conxn));
C51 COMPILER V8.08   TCP                                                                   11/04/2008 18:45:34 PAGE 2   

  56   1         just_closed = FALSE;
  57   1         initial_sequence_nr = 1;
  58   1      }
  59          
  60          
  61          
  62          //------------------------------------------------------------------------
  63          // This sends a TCP segments that do not include any data.
  64          // http_send() in the HTTP module is used to send data.
  65          // See "TCP/IP Illustrated, Volume 1" Sect 17.3
  66          //------------------------------------------------------------------------
  67          void tcp_send(UINT flags, UINT hdr_len, UCHAR nr)
  68          {
  69   1         ULONG idata sum, dest;
  70   1              UINT idata result;
  71   1         UCHAR xdata * outbuf;
  72   1         TCP_HEADER xdata * tcp;
  73   1         IP_HEADER xdata * ip;
  74   1                
  75   1         
  76   1         // Allocate memory for entire outgoing message including
  77   1         // eth & IP headers 
  78   1        // outbuf = (UCHAR xdata *)malloc(34 + hdr_len);
  79   1        // if (outbuf == NULL)
  80   1         //{
  81   1          //  return;
  82   1         //}
  83   1         outbuf = outbuf1;
  84   1                 
  85   1         tcp = (TCP_HEADER xdata *)(outbuf + 34);
  86   1         ip = (IP_HEADER xdata *)(outbuf + 14);
  87   1      
  88   1         // If no connection, then message is probably a reset
  89   1         // message which goes back to the sender
  90   1         // Otherwise, use information from the connection.
  91   1         if (nr == NO_CONNECTION)
  92   1         {
  93   2            tcp->source_port = HTTP_PORT;
  94   2            tcp->dest_port = sender_tcpport;
  95   2            tcp->sequence = 0;
  96   2            tcp->ack_number = 0;
  97   2            dest = sender_ipaddr;
  98   2         }
  99   1         else if (nr < 5)
 100   1         {
 101   2            // This message is to connected port
 102   2            tcp->source_port = HTTP_PORT;
 103   2            tcp->dest_port = conxn[nr].port;
 104   2            tcp->sequence = conxn[nr].my_sequence;
 105   2            tcp->ack_number = conxn[nr].his_sequence;
 106   2            dest = conxn[nr].ipaddr;
 107   2         }
 108   1         else
 109   1         {
 110   2      //              free(outbuf);
 111   2                      return;
 112   2              }
 113   1      
 114   1         // Total segment length = header length
 115   1            
 116   1         // Insert header len
 117   1         tcp->flags = (hdr_len << 10) | flags;
C51 COMPILER V8.08   TCP                                                                   11/04/2008 18:45:34 PAGE 3   

 118   1         tcp->window = 1024;
 119   1         tcp->checksum = 0;
 120   1         tcp->urgent_ptr = 0;
 121   1         
 122   1         // Sending SYN with header options
 123   1         if (hdr_len == 28)
 124   1         {
 125   2            memcpy(&tcp->options, opt, 8);
 126   2         }   
 127   1         
 128   1         // Compute checksum including 12 bytes of pseudoheader
 129   1              // Must pre-fill 2 items in ip header to do this
 130   1              ip->dest_ipaddr = dest;
 131   1              ip->source_ipaddr = my_ipaddr;
 132   1                      
 133   1              // Sum source_ipaddr, dest_ipaddr, and entire TCP message 
 134   1              sum = (ULONG)cksum(outbuf + 26, 8 + hdr_len);
 135   1                                      
 136   1              // Add in the rest of pseudoheader which is
 137   1              // protocol id and TCP segment length
 138   1              sum += (ULONG)0x0006;
 139   1              sum += (ULONG)hdr_len;
 140   1      
 141   1              // In case there was a carry, add it back around
 142   1              result = (UINT)(sum + (sum >> 16));
 143   1              tcp->checksum = ~result;
 144   1         
 145   1              ip_send(outbuf, dest, TCP_TYPE, hdr_len);
 146   1      
 147   1         // (Re)start TCP retransmit timer
 148   1         conxn[nr].timer = TCP_TIMEOUT;
 149   1      }
 150          
 151          
 152          
 153          
 154          //------------------------------------------------------------------------
 155          // This runs every 0.5 seconds.  If the other end has not ACK'd
 156          // everyting we have sent, it re-sends it.  To save RAM space, we 
 157          // regenerate a segment rather than keeping a bunch of segments 
 158          // hanging around eating up RAM.  A connection should not be in an
 159          // opening or closing state when this timer expires, so we simply
 160          // send a reset.
 161          //
 162          //      If a connection is in the ESTABLISHED state when the timer expires
 163          // then we have just sent a web page so re-send the page
 164          //------------------------------------------------------------------------
 165          void tcp_retransmit(void)
 166          {
 167   1         static UCHAR idata retries = 0;
 168   1         UCHAR idata nr;
 169   1      
 170   1         // Scan through all active connections 
 171   1         for (nr = 0; nr < 5; nr++)
 172   1         {
 173   2            if ((conxn[nr].ipaddr != 0) && (conxn[nr].timer))
 174   2            {
 175   3               // Decrement the timer and see if it hit 0
 176   3               conxn[nr].timer--;
 177   3               if (conxn[nr].timer == 0)
 178   3               {
 179   4                  // Socket just timed out. If we are not in ESTABLISHED state
C51 COMPILER V8.08   TCP                                                                   11/04/2008 18:45:34 PAGE 4   

 180   4                  // something is amiss so send reset and close connection
 181   4                  if (conxn[nr].state != STATE_ESTABLISHED)
 182   4                  {
 183   5                     // Send reset and close connection
 184   5                     tcp_send(FLG_RST, 20, nr);
 185   5                     conxn[nr].ipaddr = 0;
 186   5                     return;
 187   5                  }
 188   4                  else
 189   4                  {
 190   5                     // Socket is in ESTABLISHED state. First make sure his
 191   5                     // ack number is not bogus.
 192   5                     if (conxn[nr].his_ack > conxn[nr].my_sequence)
 193   5                     {
 194   6                        // Send reset and close connection
 195   6                        tcp_send(FLG_RST, 20, nr);
 196   6                        conxn[nr].ipaddr = 0;
 197   6                        return;
 198   6                     }
 199   5                     
 200   5                     // We always increment our sequence number immediately
 201   5                                              // after sending, so the ack number from the other end
 202   5                                              // should be equal to our sequence number.  If it is less,
 203   5                                              // it means he lost some of our data.
 204   5                     if (conxn[nr].his_ack < conxn[nr].my_sequence)
 205   5                                              {
 206   6                        retries++;
 207   6                                                      if (retries <= 2)
 208   6                                                      {
 209   7                              // The only thing we send is a web page, and it looks

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩中文字幕91| 国产午夜三级一区二区三| 亚洲婷婷在线视频| eeuss影院一区二区三区| 国产精品午夜电影| 成人avav在线| 亚洲小说欧美激情另类| 91精品欧美久久久久久动漫| 日韩电影在线看| 精品国产乱码久久久久久图片| 精品一区二区在线播放| 国产欧美一区二区精品婷婷 | 一区二区三区在线观看欧美| 97精品国产露脸对白| 亚洲一区二区高清| 日韩美女视频在线| 国产盗摄女厕一区二区三区| 亚洲三级电影网站| 9191久久久久久久久久久| 久久激五月天综合精品| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 调教+趴+乳夹+国产+精品| 欧美成人一区二区| www.一区二区| 三级一区在线视频先锋| 国产欧美一区二区三区在线看蜜臀 | 老司机精品视频在线| 国产日韩精品一区二区三区| 色欧美片视频在线观看在线视频| 日韩和的一区二区| 亚洲国产精品高清| 欧美精品一卡两卡| 国产成人免费视频网站高清观看视频 | 经典一区二区三区| 亚洲欧美另类小说| 日韩一级二级三级精品视频| 成人精品一区二区三区四区| 亚洲一二三四区不卡| 精品av综合导航| 欧美色网一区二区| 粉嫩高潮美女一区二区三区 | 欧美日韩国产综合一区二区| 韩国精品主播一区二区在线观看 | 不卡的看片网站| 六月丁香婷婷色狠狠久久| 亚洲欧美一区二区三区国产精品 | 国产精品三级av在线播放| 欧美日韩视频专区在线播放| 成人免费视频app| 日韩电影免费在线观看网站| 亚洲日本成人在线观看| 久久这里只精品最新地址| 在线免费观看一区| 国产成人日日夜夜| 欧美a一区二区| 一区二区三区在线视频观看58| 久久亚洲一级片| 欧美一二区视频| 欧美日韩情趣电影| 99久久精品免费看国产免费软件| 国产一区在线不卡| 日本v片在线高清不卡在线观看| 亚洲免费观看高清在线观看| 国产精品乱码一区二三区小蝌蚪| 欧美成人乱码一区二区三区| 日韩欧美精品在线| 精品视频在线看| 91高清视频在线| 91麻豆视频网站| caoporn国产精品| 国产99精品视频| 国产成人精品影院| 国产一区二区不卡在线 | 欧美电影免费提供在线观看| 欧美群妇大交群中文字幕| 欧美视频日韩视频在线观看| 日本韩国一区二区三区视频| 色婷婷精品久久二区二区蜜臀av| 99久久伊人网影院| 成人一区二区三区视频在线观看 | 亚洲精品ww久久久久久p站| 综合在线观看色| 中文一区在线播放| 国产精品毛片高清在线完整版| 久久久另类综合| 欧美激情在线一区二区三区| 国产精品国产自产拍高清av | 欧美性大战久久久久久久蜜臀| 91影院在线免费观看| 色综合婷婷久久| 欧美日韩一区高清| 欧美高清视频不卡网| 欧美一级一区二区| 久久综合久久99| 久久精品日产第一区二区三区高清版 | 成人高清伦理免费影院在线观看| 成人午夜视频在线观看| 99在线精品视频| 欧美无乱码久久久免费午夜一区| 欧美日韩国产精选| 精品国产99国产精品| 中文幕一区二区三区久久蜜桃| 亚洲麻豆国产自偷在线| 亚洲成人一二三| 精品一区二区三区免费播放| 国产不卡在线播放| 欧美最新大片在线看| 欧美一区2区视频在线观看| 久久网站最新地址| 亚洲人成精品久久久久久| 亚洲国产成人高清精品| 久久精品国产99国产| www.欧美亚洲| 欧美肥妇毛茸茸| 国产丝袜欧美中文另类| 亚洲制服丝袜一区| 国精产品一区一区三区mba桃花| 成人免费视频免费观看| 911精品产国品一二三产区| 久久精品欧美日韩精品| 亚洲精选视频在线| 久久99国内精品| 色94色欧美sute亚洲线路一ni| 欧美一区二区视频免费观看| 国产精品丝袜黑色高跟| 午夜精品久久久久久久99樱桃| 国产另类ts人妖一区二区| 一本色道久久综合亚洲aⅴ蜜桃 | 一区二区三区在线免费播放| 狠狠狠色丁香婷婷综合久久五月| 91麻豆免费看| 久久香蕉国产线看观看99| 亚洲高清一区二区三区| 成人涩涩免费视频| 26uuuu精品一区二区| 亚洲线精品一区二区三区八戒| 国产精品一区二区久久精品爱涩| 欧美精品日韩一区| 亚洲欧美国产高清| 国产黄色精品视频| 日韩欧美色综合网站| 一区二区在线观看免费| 不卡高清视频专区| 久久伊人中文字幕| 蜜芽一区二区三区| 色88888久久久久久影院野外| 久久久国产精华| 精品系列免费在线观看| 欧美日韩精品一二三区| 亚洲日本在线天堂| 不卡av在线网| 久久久久久久久久久黄色| 久久99国产精品久久99果冻传媒| 精品视频资源站| 亚洲国产综合色| 91国产视频在线观看| 亚洲婷婷在线视频| 99热精品一区二区| 国产精品不卡一区二区三区| 国产精品资源网| 久久精品免视看| 国产精品综合一区二区三区| 日韩欧美激情四射| 精品一区二区三区av| 欧美电视剧在线观看完整版| 日韩国产精品91| 欧美一级日韩一级| 麻豆免费精品视频| 日韩午夜av一区| 久久se精品一区精品二区| 日韩精品一区在线| 国产综合久久久久久鬼色 | 日韩成人av影视| 制服丝袜一区二区三区| 日韩高清不卡一区二区| 日韩午夜在线观看| 国产一区二区三区免费看| 久久日韩粉嫩一区二区三区| 国产裸体歌舞团一区二区| 中文字幕精品一区二区精品绿巨人 | 国产精品久久看| 色久综合一二码| 亚洲日本护士毛茸茸| 欧美日韩精品一区二区三区| 亚州成人在线电影| 日韩欧美国产一区二区三区| 精品无人码麻豆乱码1区2区 | 91精品国产综合久久香蕉麻豆| 天堂久久一区二区三区| 日韩欧美色电影| 成人av在线资源网站| 伊人开心综合网| 日韩一卡二卡三卡国产欧美| 国产一区二三区| 久久精品男人天堂av| 在线一区二区三区做爰视频网站| 日韩中文字幕91| 中文字幕免费在线观看视频一区| www.激情成人| 日本成人在线不卡视频|