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

📄 uip.lis

📁 uIP是免费的TCP/IP协议栈,我们将它移植到我们的AVR以太网开发板中
💻 LIS
📖 第 1 页 / 共 5 页
字号:
                        .module uip.c
                        .area lit(rom, con, rel)
 0000           _uip_hostaddr::
 0000 C0A8              .word 43200
 0002 0063              .word 25344
 0004                   .dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\uip.c
 0004                   .dbsym e uip_hostaddr _uip_hostaddr A[4:2]ks
 0004           _uip_arp_draddr::
 0004 C0A8              .word 43200
 0006 0001              .word 256
 0008                   .dbsym e uip_arp_draddr _uip_arp_draddr A[4:2]ks
 0008           _uip_arp_netmask::
 0008 FFFF              .word 65535
 000A FF00              .word 255
 000C                   .dbsym e uip_arp_netmask _uip_arp_netmask A[4:2]ks
                        .area text(rom, con, rel)
 0000                   .dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\uip.c
 0000                   .dbfunc e uip_init _uip_init fV
                        .even
 0000           _uip_init::
 0000                   .dbline -1
 0000                   .dbline 179
 0000           ; /**
 0000           ;  * \addtogroup uip
 0000           ;  * @{
 0000           ;  */
 0000           ; 
 0000           ; /**
 0000           ;  * \file
 0000           ;  * The uIP TCP/IP stack code.
 0000           ;  * \author Adam Dunkels <adam@dunkels.com>
 0000           ;  */
 0000           ; 
 0000           ; /*
 0000           ;  * Copyright (c) 2001-2003, Adam Dunkels.
 0000           ;  * All rights reserved. 
 0000           ;  *
 0000           ;  * Redistribution and use in source and binary forms, with or without 
 0000           ;  * modification, are permitted provided that the following conditions 
 0000           ;  * are met: 
 0000           ;  * 1. Redistributions of source code must retain the above copyright 
 0000           ;  *    notice, this list of conditions and the following disclaimer. 
 0000           ;  * 2. Redistributions in binary form must reproduce the above copyright 
 0000           ;  *    notice, this list of conditions and the following disclaimer in the 
 0000           ;  *    documentation and/or other materials provided with the distribution. 
 0000           ;  * 3. The name of the author may not be used to endorse or promote
 0000           ;  *    products derived from this software without specific prior
 0000           ;  *    written permission.  
 0000           ;  *
 0000           ;  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
 0000           ;  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 0000           ;  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 0000           ;  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 0000           ;  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 0000           ;  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 0000           ;  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 0000           ;  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 0000           ;  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 0000           ;  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 0000           ;  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
 0000           ;  *
 0000           ;  * This file is part of the uIP TCP/IP stack.
 0000           ;  *
 0000           ;  * $Id: uip.c,v 1.1 2004/05/09 00:24:47 Louis Exp $
 0000           ;  *
 0000           ;  */
 0000           ; 
 0000           ; /*
 0000           ; This is a small implementation of the IP and TCP protocols (as well as
 0000           ; some basic ICMP stuff). The implementation couples the IP, TCP and the
 0000           ; application layers very tightly. To keep the size of the compiled code
 0000           ; down, this code also features heavy usage of the goto statement.
 0000           ; 
 0000           ; The principle is that we have a small buffer, called the uip_buf, in
 0000           ; which the device driver puts an incoming packet. The TCP/IP stack
 0000           ; parses the headers in the packet, and calls upon the application. If
 0000           ; the remote host has sent data to the application, this data is present
 0000           ; in the uip_buf and the application read the data from there. It is up
 0000           ; to the application to put this data into a byte stream if needed. The
 0000           ; application will not be fed with data that is out of sequence.
 0000           ; 
 0000           ; If the application whishes to send data to the peer, it should put its
 0000           ; data into the uip_buf, 40 bytes from the start of the buffer. The
 0000           ; TCP/IP stack will calculate the checksums, and fill in the necessary
 0000           ; header fields and finally send the packet back to the peer.
 0000           ; */
 0000           ; 
 0000           ; #include "uip.h"
 0000           ; #include "uipopt.h"
 0000           ; #include "uip_arch.h"
 0000           ; 
 0000           ; /*-----------------------------------------------------------------------------------*/
 0000           ; /* Variable definitions. */
 0000           ; 
 0000           ; 
 0000           ; /* 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 */
 0000           ; #if UIP_FIXEDADDR > 0
 0000           ; const u16_t uip_hostaddr[2] =
 0000           ;   {HTONS((UIP_IPADDR0 << 8) | UIP_IPADDR1),
 0000           ;    HTONS((UIP_IPADDR2 << 8) | UIP_IPADDR3)};
 0000           ; const u16_t uip_arp_draddr[2] =
 0000           ;   {HTONS((UIP_DRIPADDR0 << 8) | UIP_DRIPADDR1),
 0000           ;    HTONS((UIP_DRIPADDR2 << 8) | UIP_DRIPADDR3)};
 0000           ; const u16_t uip_arp_netmask[2] =
 0000           ;   {HTONS((UIP_NETMASK0 << 8) | UIP_NETMASK1),
 0000           ;    HTONS((UIP_NETMASK2 << 8) | UIP_NETMASK3)};
 0000           ; #else
 0000           ; u16_t uip_hostaddr[2];       
 0000           ; u16_t uip_arp_draddr[2], uip_arp_netmask[2];
 0000           ; #endif /* UIP_FIXEDADDR */
 0000           ; 
 0000           ; u8_t uip_buf[UIP_BUFSIZE+2];   /* The packet buffer that contains
 0000           ;                               incoming packets. */
 0000           ; volatile u8_t *uip_appdata;  /* The uip_appdata pointer points to
 0000           ;                               application data. */
 0000           ; volatile u8_t *uip_sappdata;  /* The uip_appdata pointer points to the
 0000           ;                                application data which is to be sent. */
 0000           ; #if UIP_URGDATA > 0
 0000           ; volatile u8_t *uip_urgdata;  /* The uip_urgdata pointer points to
 0000           ;                               urgent data (out-of-band data), if
 0000           ;                               present. */
 0000           ; volatile u8_t uip_urglen, uip_surglen;
 0000           ; #endif /* UIP_URGDATA > 0 */
 0000           ; 
 0000           ; volatile u16_t uip_len, uip_slen;
 0000           ;                              /* The uip_len is either 8 or 16 bits,
 0000           ;                               depending on the maximum packet
 0000           ;                               size. */
 0000           ; 
 0000           ; volatile u8_t uip_flags;     /* The uip_flags variable is used for
 0000           ;                               communication between the TCP/IP stack
 0000           ;                               and the application program. */
 0000           ; struct uip_conn *uip_conn;   /* uip_conn always points to the current
 0000           ;                               connection. */
 0000           ; 
 0000           ; struct uip_conn uip_conns[UIP_CONNS];
 0000           ;                              /* The uip_conns array holds all TCP
 0000           ;                               connections. */
 0000           ; u16_t uip_listenports[UIP_LISTENPORTS];
 0000           ;                              /* The uip_listenports list all currently
 0000           ;                               listning ports. */
 0000           ; #if UIP_UDP
 0000           ; struct uip_udp_conn *uip_udp_conn;
 0000           ; struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
 0000           ; #endif /* UIP_UDP */
 0000           ; 
 0000           ; 
 0000           ; static u16_t ipid;           /* Ths ipid variable is an increasing
 0000           ;                               number that is used for the IP ID
 0000           ;                               field. */
 0000           ; 
 0000           ; static u8_t iss[4];          /* The iss variable is used for the TCP
 0000           ;                               initial sequence number. */
 0000           ; 
 0000           ; #if UIP_ACTIVE_OPEN
 0000           ; static u16_t lastport;       /* Keeps track of the last port used for
 0000           ;                               a new connection. */
 0000           ; #endif /* UIP_ACTIVE_OPEN */
 0000           ; 
 0000           ; /* Temporary variables. */
 0000           ; volatile u8_t uip_acc32[4];
 0000           ; static u8_t c, opt;
 0000           ; static u16_t tmp16;
 0000           ; 
 0000           ; /* Structures and definitions. */
 0000           ; #define TCP_FIN 0x01
 0000           ; #define TCP_SYN 0x02
 0000           ; #define TCP_RST 0x04
 0000           ; #define TCP_PSH 0x08
 0000           ; #define TCP_ACK 0x10
 0000           ; #define TCP_URG 0x20
 0000           ; #define TCP_CTL 0x3f
 0000           ; 
 0000           ; #define ICMP_ECHO_REPLY 0
 0000           ; #define ICMP_ECHO       8     
 0000           ; 
 0000           ; /* Macros. */
 0000           ; #define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
 0000           ; #define FBUF ((uip_tcpip_hdr *)&uip_reassbuf[0])
 0000           ; #define ICMPBUF ((uip_icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
 0000           ; #define UDPBUF ((uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
 0000           ; 
 0000           ; #if UIP_STATISTICS == 1
 0000           ; struct uip_stats uip_stat;
 0000           ; #define UIP_STAT(s) s
 0000           ; #else
 0000           ; #define UIP_STAT(s)
 0000           ; #endif /* UIP_STATISTICS == 1 */
 0000           ; 
 0000           ; #if UIP_LOGGING == 1
 0000           ; #include <stdio.h>
 0000           ; void uip_log(char *msg);
 0000           ; #define UIP_LOG(m) uip_log(m)
 0000           ; #else
 0000           ; #define UIP_LOG(m)
 0000           ; #endif /* UIP_LOGGING == 1 */
 0000           ; 
 0000           ; /*-----------------------------------------------------------------------------------*/
 0000           ; void
 0000           ; uip_init(void)
 0000           ; {
 0000                   .dbline 180
 0000 2224              clr R2
 0002 20920300          sts _c,R2
 0006 12C0              xjmp L11
 0008           L8:
 0008                   .dbline 180
 0008                   .dbline 181
 0008 20900300          lds R2,_c
 000C 82E0              ldi R24,2
 000E 829D              mul R24,R2
 0010 F001              movw R30,R0
 0012 80E0              ldi R24,<_uip_listenports
 0014 90E0              ldi R25,>_uip_listenports
 0016 E80F              add R30,R24
 0018 F91F              adc R31,R25
 001A 2224              clr R2
 001C 3324              clr R3
 001E 3182              std z+1,R3
 0020 2082              std z+0,R2
 0022                   .dbline 182
 0022           L9:
 0022                   .dbline 180
 0022 80910300          lds R24,_c
 0026 8F5F              subi R24,255    ; addi 1
 0028 80930300          sts _c,R24
 002C           L11:
 002C                   .dbline 180
 002C           ;   for(c = 0; c < UIP_LISTENPORTS; ++c) {
 002C 80910300          lds R24,_c
 0030 8A30              cpi R24,10
 0032 50F3              brlo L8
 0034                   .dbline 183
 0034 2224              clr R2
 0036 20920300          sts _c,R2
 003A 10C0              xjmp L15
 003C           L12:
 003C                   .dbline 183
 003C                   .dbline 184
 003C 20900300          lds R2,_c
 0040 83E2              ldi R24,35
 0042 829D              mul R24,R2
 0044 F001              movw R30,R0
 0046 80E0              ldi R24,<_uip_conns+25
 0048 90E0              ldi R25,>_uip_conns+25
 004A E80F              add R30,R24
 004C F91F              adc R31,R25
 004E 2224              clr R2
 0050 2082              std z+0,R2
 0052                   .dbline 185
 0052           L13:
 0052                   .dbline 183
 0052 80910300          lds R24,_c
 0056 8F5F              subi R24,255    ; addi 1
 0058 80930300          sts _c,R24
 005C           L15:
 005C                   .dbline 183
 005C           ;     uip_listenports[c] = 0;
 005C           ;   }
 005C           ;   for(c = 0; c < UIP_CONNS; ++c) {
 005C 80910300          lds R24,_c
 0060 8A30              cpi R24,10
 0062 60F3              brlo L12
 0064                   .dbline 187
 0064           ;     uip_conns[c].tcpstateflags = CLOSED;
 0064           ;   }
 0064           ; #if UIP_ACTIVE_OPEN
 0064           ;   lastport = 1024;
 0064 80E0              ldi R24,1024
 0066 94E0              ldi R25,4
 0068 90930500          sts _lastport+1,R25
 006C 80930400          sts _lastport,R24
 0070                   .dbline -2
 0070           L7:
 0070                   .dbline 0 ; func end
 0070 0895              ret
 0072                   .dbend
 0072                   .dbstruct 0 35 uip_conn
 0072                   .dbfield 0 ripaddr A[4:2]s
 0072                   .dbfield 4 lport s
 0072                   .dbfield 6 rport s
 0072                   .dbfield 8 rcv_nxt A[4:4]c
 0072                   .dbfield 12 snd_nxt A[4:4]c
 0072                   .dbfield 16 len s
 0072                   .dbfield 18 mss s
 0072                   .dbfield 20 initialmss s
 0072                   .dbfield 22 sa c
 0072                   .dbfield 23 sv c
 0072                   .dbfield 24 rto c
 0072                   .dbfield 25 tcpstateflags c
 0072                   .dbfield 26 timer c
 0072                   .dbfield 27 nrtx c
 0072                   .dbfield 28 appstate A[7:7]c
 0072                   .dbend
 0072                   .dbfunc e uip_connect _uip_connect fpS[uip_conn]
 0072           ;          cconn -> R12,R13
 0072           ;           conn -> R10,R11
 0072           ;          rport -> R14,R15
 0072           ;        ripaddr -> y+6
                        .even
 0072           _uip_connect::
 0072 0E940000          xcall push_arg4
 0076 0E940000          xcall push_gset5x
 007A 7901              movw R14,R18
 007C                   .dbline -1
 007C                   .dbline 207
 007C           ; #endif /* UIP_ACTIVE_OPEN */
 007C           ; 
 007C           ; #if UIP_UDP
 007C           ;   for(c = 0; c < UIP_UDP_CONNS; ++c) {

⌨️ 快捷键说明

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