⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uip.lst

📁 STC51系列的源码
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V8.02   UIP                                                                   10/28/2008 15:31:45 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE UIP
OBJECT MODULE PLACED IN .\out\uip.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE uip.c LARGE OPTIMIZE(SIZE) BROWSE DEBUG OBJECTEXTEND PRINT(.\out\uip.lst) O
                    -BJECT(.\out\uip.obj)

line level    source

   1          #include "../CPU/CPU.h"
   2          #include "../CFG/CFG.h"
   3          #include "../UART/UART.h"
   4          #include "uip.h"
   5          #include "uipopt.h"
   6          #include "uip_arch.h"
   7          
   8          /*-----------------------------------------------------------------------------------*/
   9          /* Variable definitions. */
  10          
  11          
  12          /* The IP address of this host. If it is defined to be fixed (by setting UIP_FIXEDADDR to 1 in uipopt.h), 
             -the address is set here. Otherwise, the address */
  13          #if UIP_FIXEDADDR > 0
  14          const u16_t code uip_hostaddr[2] =
  15            {HTONS((UIP_IPADDR0 << 8) | UIP_IPADDR1),
  16             HTONS((UIP_IPADDR2 << 8) | UIP_IPADDR3)};
  17          const u16_t code uip_arp_draddr[2] =
  18            {HTONS((UIP_DRIPADDR0 << 8) | UIP_DRIPADDR1),
  19             HTONS((UIP_DRIPADDR2 << 8) | UIP_DRIPADDR3)};
  20          const u16_t code uip_arp_netmask[2] =
  21            {HTONS((UIP_NETMASK0 << 8) | UIP_NETMASK1),
  22             HTONS((UIP_NETMASK2 << 8) | UIP_NETMASK3)};
  23          #else
              u16_t   uip_hostaddr[2];       
              u16_t   uip_arp_draddr[2], uip_arp_netmask[2];
              #endif /* UIP_FIXEDADDR */
  27          
  28          u8_t   uip_buf[UIP_BUFSIZE+2];   /* The packet buffer that contains
  29                                          incoming packets. */
  30          volatile u8_t *uip_appdata;  /* The uip_appdata pointer points to
  31                                          application data. */
  32          volatile u8_t *uip_sappdata;  /* The uip_appdata pointer points to the
  33                                           application data which is to be sent. */
  34          #if UIP_URGDATA > 0
  35          volatile u8_t *uip_urgdata;  /* The uip_urgdata pointer points to
  36                                          urgent data (out-of-band data), if
  37                                          present. */
  38          volatile u8_t   uip_urglen, uip_surglen;
  39          #endif /* UIP_URGDATA > 0 */
  40          
  41          volatile u16_t   uip_len, uip_slen;
  42                                       /* The uip_len is either 8 or 16 bits,
  43                                          depending on the maximum packet
  44                                          size. */
  45          
  46          volatile u8_t   uip_flags;     /* The uip_flags variable is used for
  47                                          communication between the TCP/IP stack
  48                                          and the application program. */
  49          struct uip_conn   *uip_conn;   /* uip_conn always points to the current
  50                                          connection. */
  51          
  52          struct uip_conn   uip_conns[UIP_CONNS];
  53                                       /* The uip_conns array holds all TCP
C51 COMPILER V8.02   UIP                                                                   10/28/2008 15:31:45 PAGE 2   

  54                                          connections. */
  55          u16_t   uip_listenports[UIP_LISTENPORTS];
  56                                       /* The uip_listenports list all currently
  57                                          listning ports. */
  58          #if UIP_UDP
              struct uip_udp_conn   *uip_udp_conn;
              struct uip_udp_conn   uip_udp_conns[UIP_UDP_CONNS];
              #endif /* UIP_UDP */
  62          
  63          
  64          static u16_t   ipid;           /* Ths ipid variable is an increasing
  65                                          number that is used for the IP ID
  66                                          field. */
  67          
  68          static u8_t   iss[4];          /* The iss variable is used for the TCP
  69                                          initial sequence number. */
  70          
  71          #if UIP_ACTIVE_OPEN
              static u16_t   lastport;       /* Keeps track of the last port used for
                                              a new connection. */
              #endif /* UIP_ACTIVE_OPEN */
  75          
  76          /* Temporary variables. */
  77          volatile u8_t uip_acc32[4];
  78          static u8_t   c, opt;
  79          static u16_t   tmp16;
  80          
  81          /* Structures and definitions. */
  82          #define TCP_FIN 0x01
  83          #define TCP_SYN 0x02
  84          #define TCP_RST 0x04
  85          #define TCP_PSH 0x08
  86          #define TCP_ACK 0x10
  87          #define TCP_URG 0x20
  88          #define TCP_CTL 0x3f
  89          
  90          #define ICMP_ECHO_REPLY 0
  91          #define ICMP_ECHO       8     
  92          
  93          /* Macros. */
  94          #define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
  95          #define FBUF ((uip_tcpip_hdr *)&uip_reassbuf[0])
  96          #define ICMPBUF ((uip_icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
  97          #define UDPBUF ((uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
  98          
  99          #if UIP_STATISTICS == 1
 100          struct uip_stats uip_stat;
 101          #define UIP_STAT(s) s
 102          #else
              #define UIP_STAT(s)
              #endif /* UIP_STATISTICS == 1 */
 105          
 106          #if UIP_LOGGING == 1
              #include <stdio.h>
              void uip_log(char *msg);
              #define UIP_LOG(m) uip_log(m)
              #else
 111          #define UIP_LOG(m)
 112          #endif /* UIP_LOGGING == 1 */
 113          
 114          /*-----------------------------------------------------------------------------------*/
 115          void
C51 COMPILER V8.02   UIP                                                                   10/28/2008 15:31:45 PAGE 3   

 116          uip_init(void)
 117          {
 118   1        for(c = 0; c < UIP_LISTENPORTS; ++c) {
 119   2          uip_listenports[c] = 0;
 120   2        }
 121   1        for(c = 0; c < UIP_CONNS; ++c) {
 122   2          uip_conns[c].tcpstateflags = CLOSED;
 123   2        }
 124   1      #if UIP_ACTIVE_OPEN
                lastport = 1024;
              #endif /* UIP_ACTIVE_OPEN */
 127   1      
 128   1      #if UIP_UDP
                for(c = 0; c < UIP_UDP_CONNS; ++c) {
                  uip_udp_conns[c].lport = 0;
                }
              #endif /* UIP_UDP */
 133   1        
 134   1      
 135   1        /* IPv4 initialization. */
 136   1      #if UIP_FIXEDADDR == 0
                uip_hostaddr[0] = uip_hostaddr[1] = 0;
              #endif /* UIP_FIXEDADDR */
 139   1      
 140   1      }
 141          /*-----------------------------------------------------------------------------------*/
 142          #if UIP_ACTIVE_OPEN
              struct uip_conn *
              uip_connect(u16_t *ripaddr, u16_t rport)
              {
                register struct uip_conn *conn, *cconn;
                
                /* Find an unused local port. */
               again:
                ++lastport;
              
                if(lastport >= 32000) {
                  lastport = 4096;
                }
              
                /* Check if this port is already in use, and if so try to find
                   another one. */
                for(c = 0; c < UIP_CONNS; ++c) {
                  conn = &uip_conns[c];
                  if(conn->tcpstateflags != CLOSED &&
                     conn->lport == htons(lastport)) {
                    goto again;
                  }
                }
              
              
                conn = 0;
                for(c = 0; c < UIP_CONNS; ++c) {
                  cconn = &uip_conns[c]; 
                  if(cconn->tcpstateflags == CLOSED) {
                    conn = cconn;
                    break;
                  }
                  if(cconn->tcpstateflags == TIME_WAIT) {
                    if(conn == 0 ||
                       cconn->timer > uip_conn->timer) {
                      conn = cconn;
C51 COMPILER V8.02   UIP                                                                   10/28/2008 15:31:45 PAGE 4   

                    }
                  }
                }
              
                if(conn == 0) {
                  return 0;
                }
                
                conn->tcpstateflags = SYN_SENT;
              
                conn->snd_nxt[0] = iss[0];
                conn->snd_nxt[1] = iss[1];
                conn->snd_nxt[2] = iss[2];
                conn->snd_nxt[3] = iss[3];
              
                conn->initialmss = conn->mss = UIP_TCP_MSS;
                
                conn->len = 1;   /* TCP length of the SYN is one. */
                conn->nrtx = 0;
                conn->timer = 1; /* Send the SYN next time around. */
                conn->rto = UIP_RTO;
                conn->sa = 0;
                conn->sv = 16;
                conn->lport = htons(lastport);
                conn->rport = rport;
                conn->ripaddr[0] = ripaddr[0];
                conn->ripaddr[1] = ripaddr[1];
                
                return conn;
              }
              #endif /* UIP_ACTIVE_OPEN */
 209          /*-----------------------------------------------------------------------------------*/
 210          #if UIP_UDP
              struct uip_udp_conn *
              uip_udp_new(u16_t *ripaddr, u16_t rport)
              {
                register struct uip_udp_conn *conn;
                
                /* Find an unused local port. */
               again:
                ++lastport;
              
                if(lastport >= 32000) {
                  lastport = 4096;
                }
                
                for(c = 0; c < UIP_UDP_CONNS; ++c) {
                  if(uip_udp_conns[c].lport == lastport) {
                    goto again;
                  }
                }
              
              
                conn = 0;
                for(c = 0; c < UIP_UDP_CONNS; ++c) {
                  if(uip_udp_conns[c].lport == 0) {
                    conn = &uip_udp_conns[c]; 
                    break;
                  }
                }
              
                if(conn == 0) {
C51 COMPILER V8.02   UIP                                                                   10/28/2008 15:31:45 PAGE 5   

                  return 0;
                }
                
                conn->lport = HTONS(lastport);
                conn->rport = HTONS(rport);
                conn->ripaddr[0] = ripaddr[0];
                conn->ripaddr[1] = ripaddr[1];
                
                return conn;
              }
              #endif /* UIP_UDP */
 251          /*-----------------------------------------------------------------------------------*/
 252          void
 253          uip_unlisten(u16_t port)
 254          {
 255   1        for(c = 0; c < UIP_LISTENPORTS; ++c) {
 256   2          if(uip_listenports[c] == port) {
 257   3            uip_listenports[c] = 0;
 258   3            return;
 259   3          }
 260   2        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -