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

📄 uip.lst

📁 移植uIP1.0到51单片机上的版本mcu_netV1.00 uIP ARP / ICMP / TCP协议的完全移植
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.06   UIP                                                                   05/02/2009 15:51:22 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE UIP
OBJECT MODULE PLACED IN .\uip.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\src\uip.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\uip.lst) OBJECT(.\uip.
                    -obj)

stmt level    source

   1          #define DEBUG_PRINTF/*(...) printf(__VA_ARGS__)   */
   2          
   3          /**
   4           * \defgroup uip The uIP TCP/IP stack
   5           * @{
   6           *
   7           * uIP is an implementation of the TCP/IP protocol stack intended for
   8           * small 8-bit and 16-bit microcontrollers.
   9           *
  10           * uIP provides the necessary protocols for Internet communication,
  11           * with a very small code footprint and RAM requirements - the uIP
  12           * code size is on the order of a few kilobytes and RAM usage is on
  13           * the order of a few hundred bytes.
  14           */
  15          
  16          /**
  17           * \file
  18           * The uIP TCP/IP stack code.
  19           * \author Adam Dunkels <adam@dunkels.com>
  20           */
  21          
  22          /*
  23           * Copyright (c) 2001-2003, Adam Dunkels.
  24           * All rights reserved.
  25           *
  26           * Redistribution and use in source and binary forms, with or without
  27           * modification, are permitted provided that the following conditions
  28           * are met:
  29           * 1. Redistributions of source code must retain the above copyright
  30           *    notice, this list of conditions and the following disclaimer.
  31           * 2. Redistributions in binary form must reproduce the above copyright
  32           *    notice, this list of conditions and the following disclaimer in the
  33           *    documentation and/or other materials provided with the distribution.
  34           * 3. The name of the author may not be used to endorse or promote
  35           *    products derived from this software without specific prior
  36           *    written permission.
  37           *
  38           * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  39           * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  40           * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  41           * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  42           * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  43           * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  44           * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  45           * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  46           * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  47           * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  48           * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49           *
  50           * This file is part of the uIP TCP/IP stack.
  51           *
  52           * $Id: uip.c,v 1.65 2006/06/11 21:46:39 adam Exp $
  53           *
  54           */
C51 COMPILER V7.06   UIP                                                                   05/02/2009 15:51:22 PAGE 2   

  55          
  56          /*
  57           * uIP is a small implementation of the IP, UDP and TCP protocols (as
  58           * well as some basic ICMP stuff). The implementation couples the IP,
  59           * UDP, TCP and the application layers very tightly. To keep the size
  60           * of the compiled code down, this code frequently uses the goto
  61           * statement. While it would be possible to break the uip_process()
  62           * function into many smaller functions, this would increase the code
  63           * size because of the overhead of parameter passing and the fact that
  64           * the optimier would not be as efficient.
  65           *
  66           * The principle is that we have a small buffer, called the uip_buf,
  67           * in which the device driver puts an incoming packet. The TCP/IP
  68           * stack parses the headers in the packet, and calls the
  69           * application. If the remote host has sent data to the application,
  70           * this data is present in the uip_buf and the application read the
  71           * data from there. It is up to the application to put this data into
  72           * a byte stream if needed. The application will not be fed with data
  73           * that is out of sequence.
  74           *
  75           * If the application whishes to send data to the peer, it should put
  76           * its data into the uip_buf. The uip_appdata pointer points to the
  77           * first available byte. The TCP/IP stack will calculate the
  78           * checksums, and fill in the necessary header fields and finally send
  79           * the packet back to the peer.
  80          */
  81          
  82          #include "uip.h"
  83          #include "uipopt.h"
  84          
  85          #if UIP_CONF_IPV6
              #include "uip-neighbor.h"
              #endif /* UIP_CONF_IPV6 */
  88          
  89          #include <string.h>
  90          
  91          /*---------------------------------------------------------------------------*/
  92          /* Variable definitions. */
  93          
  94          
  95          /* The IP address of this host. If it is defined to be fixed (by
  96             setting UIP_FIXEDADDR to 1 in uipopt.h), the address is set
  97             here. Otherwise, the address */
  98          #if UIP_FIXEDADDR > 0
              const uip_ipaddr_t uip_hostaddr =
                {HTONS((UIP_IPADDR0 << 8) | UIP_IPADDR1),
                 HTONS((UIP_IPADDR2 << 8) | UIP_IPADDR3)};
              const uip_ipaddr_t uip_draddr =
                {HTONS((UIP_DRIPADDR0 << 8) | UIP_DRIPADDR1),
                 HTONS((UIP_DRIPADDR2 << 8) | UIP_DRIPADDR3)};
              const uip_ipaddr_t uip_netmask =
                {HTONS((UIP_NETMASK0 << 8) | UIP_NETMASK1),
                 HTONS((UIP_NETMASK2 << 8) | UIP_NETMASK3)};
              #else
 109          uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask;
 110          #endif /* UIP_FIXEDADDR */
 111          
 112          static const uip_ipaddr_t all_ones_addr =
 113          #if UIP_CONF_IPV6
                {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
              #else /* UIP_CONF_IPV6 */
 116            {0xffff,0xffff};
C51 COMPILER V7.06   UIP                                                                   05/02/2009 15:51:22 PAGE 3   

 117          #endif /* UIP_CONF_IPV6 */
 118          static const uip_ipaddr_t all_zeroes_addr =
 119          #if UIP_CONF_IPV6
                {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};
              #else /* UIP_CONF_IPV6 */
 122            {0x0000,0x0000};
 123          #endif /* UIP_CONF_IPV6 */
 124          
 125          
 126          #if UIP_FIXEDETHADDR
 127          const struct uip_eth_addr uip_ethaddr = {{UIP_ETHADDR0,
 128                                                    UIP_ETHADDR1,
 129                                                    UIP_ETHADDR2,
 130                                                    UIP_ETHADDR3,
 131                                                    UIP_ETHADDR4,
 132                                                    UIP_ETHADDR5}};
 133          #else
              struct uip_eth_addr uip_ethaddr = {{0,0,0,0,0,0}};
              #endif
 136          
 137          #ifndef UIP_CONF_EXTERNAL_BUFFER
 138          u8_t xdata uip_buf[UIP_BUFSIZE + 2];   /* The packet buffer that contains
 139                                              incoming packets. */
 140          #endif /* UIP_CONF_EXTERNAL_BUFFER */
 141          
 142          /*gateway: void *---volatile u8_t*  */
 143          volatile u8_t *uip_appdata;               /* The uip_appdata pointer points to
 144                                              application data. */
 145          volatile u8_t *uip_sappdata;              /* The uip_appdata pointer points to
 146                                              the application data which is to
 147                                              be sent. */
 148          #if UIP_URGDATA > 0
 149          void *uip_urgdata;               /* The uip_urgdata pointer points to
 150                                              urgent data (out-of-band data), if
 151                                              present. */
 152          u16_t uip_urglen, uip_surglen;
 153          #endif /* UIP_URGDATA > 0 */
 154          
 155          u16_t idata uip_len, uip_slen;
 156                                       /* The uip_len is either 8 or 16 bits,
 157                                          depending on the maximum packet
 158                                          size. */
 159          
 160          u8_t idata uip_flags;     /* The uip_flags variable is used for
 161                                          communication between the TCP/IP stack
 162                                          and the application program. */
 163          struct uip_conn xdata *uip_conn;   /* uip_conn always points to the current
 164                                          connection. */
 165                              
 166          
 167          struct uip_conn xdata uip_conns[UIP_CONNS];
 168                                       /* The uip_conns array holds all TCP
 169                                          connections. */
 170          u16_t idata uip_listenports[UIP_LISTENPORTS];
 171                                       /* The uip_listenports list all currently
 172                                          listning ports. */
 173          #if UIP_UDP
              struct uip_udp_conn *uip_udp_conn;
              struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
              #endif /* UIP_UDP */
 177          
 178          static u16_t ipid;           /* Ths ipid variable is an increasing
C51 COMPILER V7.06   UIP                                                                   05/02/2009 15:51:22 PAGE 4   

 179                                          number that is used for the IP ID
 180                                          field. */
 181          
 182          void uip_setipid(u16_t id) { ipid = id; }
 183          
 184          static u8_t iss[4];          /* The iss variable is used for the TCP
 185                                          initial sequence number. */
 186          
 187          #if UIP_ACTIVE_OPEN
              static u16_t lastport;       /* Keeps track of the last port used for
                                              a new connection. */
              #endif /* UIP_ACTIVE_OPEN */
 191          
 192          /* Temporary variables. */
 193          u8_t uip_acc32[4];
 194          static u8_t c, opt;
 195          static u16_t tmp16;
 196          
 197          /* Structures and definitions. */
 198          #define TCP_FIN 0x01
 199          #define TCP_SYN 0x02
 200          #define TCP_RST 0x04
 201          #define TCP_PSH 0x08
 202          #define TCP_ACK 0x10
 203          #define TCP_URG 0x20
 204          #define TCP_CTL 0x3f
 205          
 206          #define TCP_OPT_END     0   /* End of TCP options list */
 207          #define TCP_OPT_NOOP    1   /* "No-operation" TCP option */
 208          #define TCP_OPT_MSS     2   /* Maximum segment size TCP option */
 209          
 210          #define TCP_OPT_MSS_LEN 4   /* Length of TCP MSS option. */
 211          
 212          #define ICMP_ECHO_REPLY 0
 213          #define ICMP_ECHO       8
 214          
 215          #define ICMP6_ECHO_REPLY             129
 216          #define ICMP6_ECHO                   128
 217          #define ICMP6_NEIGHBOR_SOLICITATION  135
 218          #define ICMP6_NEIGHBOR_ADVERTISEMENT 136
 219          
 220          #define ICMP6_FLAG_S (1 << 6)
 221          
 222          #define ICMP6_OPTION_SOURCE_LINK_ADDRESS 1
 223          #define ICMP6_OPTION_TARGET_LINK_ADDRESS 2
 224          
 225          
 226          /* Macros. */
 227          #define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
 228          #define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0])
 229          #define ICMPBUF ((struct uip_icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
 230          #define UDPBUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
 231          
 232          
 233          #if UIP_STATISTICS == 1
 234          struct uip_stats uip_stat;
 235          #define UIP_STAT(s) s
 236          #else
              #define UIP_STAT(s)
              #endif /* UIP_STATISTICS == 1 */
 239          
 240          #if UIP_LOGGING == 1
C51 COMPILER V7.06   UIP                                                                   05/02/2009 15:51:22 PAGE 5   

              /*#include <stdio.h>*/
              void uip_log(char *msg);
              #define UIP_LOG(m) uip_log(m)
              #else
 245          #define UIP_LOG(m)
 246          #endif /* UIP_LOGGING == 1 */
 247          
 248          #if ! UIP_ARCH_ADD32
 249          void 
 250          uip_add32(u8_t *op32, u16_t op16)
 251          {
 252   1        uip_acc32[3] = op32[3] + (op16 & 0xff);
 253   1        uip_acc32[2] = op32[2] + (op16 >> 8);
 254   1        uip_acc32[1] = op32[1];
 255   1        uip_acc32[0] = op32[0];
 256   1        
 257   1        if(uip_acc32[2] < (op16 >> 8)) {
 258   2          /* ++uip_acc32[1];*/   /*gateway*/
 259   2          uip_acc32[1] = uip_acc32[1] + 1;
 260   2          if(uip_acc32[1] == 0) {
 261   3            /* ++uip_acc32[0]; */
 262   3                uip_acc32[0] = uip_acc32[0] + 1;

⌨️ 快捷键说明

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