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

📄 uip_arp.lis

📁 uIP是免费的TCP/IP协议栈,我们将它移植到我们的AVR以太网开发板中
💻 LIS
📖 第 1 页 / 共 4 页
字号:
                        .module uip_arp.c
                        .area data(ram, con, rel)
 0000           _uip_ethaddr::
 0000                   .blkb 2
                        .area idata
 0000 4F46              .byte 'O,'F
                        .area data(ram, con, rel)
 0002                   .blkb 2
                        .area idata
 0002 4649              .byte 'F,'I
                        .area data(ram, con, rel)
 0004                   .blkb 2
                        .area idata
 0004 4345              .byte 'C,'E
                        .area data(ram, con, rel)
 0006                   .dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\uip_arp.c
 0006                   .dbstruct 0 6 uip_eth_addr
 0006                   .dbfield 0 addr A[6:6]c
 0006                   .dbend
 0006                   .dbsym e uip_ethaddr _uip_ethaddr S[uip_eth_addr]
                        .area text(rom, con, rel)
 0000                   .dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\uip_arp.c
 0000                   .dbfunc e uip_arp_init _uip_arp_init fV
                        .even
 0000           _uip_arp_init::
 0000 2297              sbiw R28,2
 0002                   .dbline -1
 0002                   .dbline 129
 0002           ; /**
 0002           ;  * \addtogroup uip
 0002           ;  * @{
 0002           ;  */
 0002           ; 
 0002           ; /**
 0002           ;  * \defgroup uiparp uIP Address Resolution Protocol
 0002           ;  * @{
 0002           ;  * 
 0002           ;  * The Address Resolution Protocol ARP is used for mapping between IP
 0002           ;  * addresses and link level addresses such as the Ethernet MAC
 0002           ;  * addresses. ARP uses broadcast queries to ask for the link level
 0002           ;  * address of a known IP address and the host which is configured with
 0002           ;  * the IP address for which the query was meant, will respond with its
 0002           ;  * link level address.
 0002           ;  *
 0002           ;  * \note This ARP implementation only supports Ethernet.
 0002           ;  */
 0002           ;  
 0002           ; /**
 0002           ;  * \file
 0002           ;  * Implementation of the ARP Address Resolution Protocol.
 0002           ;  * \author Adam Dunkels <adam@dunkels.com>
 0002           ;  *
 0002           ;  */
 0002           ; 
 0002           ; /*
 0002           ;  * Copyright (c) 2001-2003, Adam Dunkels.
 0002           ;  * All rights reserved. 
 0002           ;  *
 0002           ;  * Redistribution and use in source and binary forms, with or without 
 0002           ;  * modification, are permitted provided that the following conditions 
 0002           ;  * are met: 
 0002           ;  * 1. Redistributions of source code must retain the above copyright 
 0002           ;  *    notice, this list of conditions and the following disclaimer. 
 0002           ;  * 2. Redistributions in binary form must reproduce the above copyright 
 0002           ;  *    notice, this list of conditions and the following disclaimer in the 
 0002           ;  *    documentation and/or other materials provided with the distribution. 
 0002           ;  * 3. The name of the author may not be used to endorse or promote
 0002           ;  *    products derived from this software without specific prior
 0002           ;  *    written permission.  
 0002           ;  *
 0002           ;  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
 0002           ;  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 0002           ;  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 0002           ;  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 0002           ;  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 0002           ;  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 0002           ;  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 0002           ;  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 0002           ;  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 0002           ;  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 0002           ;  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
 0002           ;  *
 0002           ;  * This file is part of the uIP TCP/IP stack.
 0002           ;  *
 0002           ;  * $Id: uip_arp.c,v 1.1 2004/05/09 00:24:48 Louis Exp $
 0002           ;  *
 0002           ;  */
 0002           ; 
 0002           ; 
 0002           ; #include "uip_arp.h"
 0002           ; 
 0002           ; #include <string.h>
 0002           ; 
 0002           ; struct arp_hdr {
 0002           ;   struct uip_eth_hdr ethhdr;
 0002           ;   u16_t hwtype;
 0002           ;   u16_t protocol;
 0002           ;   u8_t hwlen;
 0002           ;   u8_t protolen;
 0002           ;   u16_t opcode;
 0002           ;   struct uip_eth_addr shwaddr;
 0002           ;   u16_t sipaddr[2];
 0002           ;   struct uip_eth_addr dhwaddr;
 0002           ;   u16_t dipaddr[2]; 
 0002           ; };
 0002           ; 
 0002           ; struct ethip_hdr {
 0002           ;   struct uip_eth_hdr ethhdr;
 0002           ;   /* IP header. */
 0002           ;   u8_t vhl,
 0002           ;     tos,          
 0002           ;     len[2],       
 0002           ;     ipid[2],        
 0002           ;     ipoffset[2],  
 0002           ;     ttl,          
 0002           ;     proto;     
 0002           ;   u16_t ipchksum;
 0002           ;   u16_t srcipaddr[2], 
 0002           ;     destipaddr[2];
 0002           ; };
 0002           ; 
 0002           ; #define ARP_REQUEST 1
 0002           ; #define ARP_REPLY   2
 0002           ; 
 0002           ; #define ARP_HWTYPE_ETH 1
 0002           ; 
 0002           ; struct arp_entry {
 0002           ;   u16_t ipaddr[2];
 0002           ;   struct uip_eth_addr ethaddr;
 0002           ;   u8_t time;
 0002           ; };
 0002           ; 
 0002           ; struct uip_eth_addr uip_ethaddr = {{UIP_ETHADDR0,
 0002           ;                                   UIP_ETHADDR1,
 0002           ;                                   UIP_ETHADDR2,
 0002           ;                                   UIP_ETHADDR3,
 0002           ;                                   UIP_ETHADDR4,
 0002           ;                                   UIP_ETHADDR5}};
 0002           ; 
 0002           ; static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
 0002           ; static u16_t ipaddr[2];
 0002           ; static u8_t i, c;
 0002           ; 
 0002           ; static u8_t arptime;
 0002           ; static u8_t tmpage;
 0002           ; 
 0002           ; #define BUF   ((struct arp_hdr *)&uip_buf[0])
 0002           ; #define IPBUF ((struct ethip_hdr *)&uip_buf[0])
 0002           ; /*-----------------------------------------------------------------------------------*/
 0002           ; /**
 0002           ;  * Initialize the ARP module.
 0002           ;  *
 0002           ;  */
 0002           ; /*-----------------------------------------------------------------------------------*/
 0002           ; void
 0002           ; uip_arp_init(void)
 0002           ; {
 0002                   .dbline 130
 0002 2224              clr R2
 0004 20920300          sts _i,R2
 0008 16C0              xjmp L11
 000A           L8:
 000A                   .dbline 130
 000A                   .dbline 131
 000A 84E0              ldi R24,4
 000C 90E0              ldi R25,0
 000E 9983              std y+1,R25
 0010 8883              std y+0,R24
 0012 2227              clr R18
 0014 3327              clr R19
 0016 20900300          lds R2,_i
 001A 8BE0              ldi R24,11
 001C 829D              mul R24,R2
 001E 8001              movw R16,R0
 0020 80E0              ldi R24,<_arp_table
 0022 90E0              ldi R25,>_arp_table
 0024 080F              add R16,R24
 0026 191F              adc R17,R25
 0028 0E940000          xcall _memset
 002C                   .dbline 132
 002C           L9:
 002C                   .dbline 130
 002C 80910300          lds R24,_i
 0030 8F5F              subi R24,255    ; addi 1
 0032 80930300          sts _i,R24
 0036           L11:
 0036                   .dbline 130
 0036           ;   for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
 0036 80910300          lds R24,_i
 003A 8830              cpi R24,8
 003C 30F3              brlo L8
 003E                   .dbline -2
 003E           L7:
 003E 2296              adiw R28,2
 0040                   .dbline 0 ; func end
 0040 0895              ret
 0042                   .dbend
 0042                   .dbfunc e uip_arp_timer _uip_arp_timer fV
 0042                   .dbstruct 0 11 arp_entry
 0042                   .dbfield 0 ipaddr A[4:2]s
 0042                   .dbfield 4 ethaddr S[uip_eth_addr]
 0042                   .dbfield 10 time c
 0042                   .dbend
 0042           ;         tabptr -> R10,R11
                        .even
 0042           _uip_arp_timer::
 0042 0E940000          xcall push_gset3x
 0046 2297              sbiw R28,2
 0048                   .dbline -1
 0048                   .dbline 146
 0048           ;     memset(arp_table[i].ipaddr, 0, 4);
 0048           ;   }
 0048           ; }
 0048           ; /*-----------------------------------------------------------------------------------*/
 0048           ; /**
 0048           ;  * Periodic ARP processing function.
 0048           ;  *
 0048           ;  * This function performs periodic timer processing in the ARP module
 0048           ;  * and should be called at regular intervals. The recommended interval
 0048           ;  * is 10 seconds between the calls.
 0048           ;  *
 0048           ;  */
 0048           ; /*-----------------------------------------------------------------------------------*/
 0048           ; void
 0048           ; uip_arp_timer(void)
 0048           ; {
 0048                   .dbline 149
 0048           ;   struct arp_entry *tabptr;
 0048           ;   
 0048           ;   ++arptime;
 0048 80910100          lds R24,_arptime
 004C 8F5F              subi R24,255    ; addi 1
 004E 80930100          sts _arptime,R24
 0052                   .dbline 150
 0052 2224              clr R2
 0054 20920300          sts _i,R2
 0058 2AC0              xjmp L16
 005A           L13:
 005A                   .dbline 150
 005A           ;   for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
 005A                   .dbline 151
 005A           ;     tabptr = &arp_table[i];
 005A 20900300          lds R2,_i
 005E 8BE0              ldi R24,11
 0060 829D              mul R24,R2
 0062 5001              movw R10,R0
 0064 80E0              ldi R24,<_arp_table
 0066 90E0              ldi R25,>_arp_table
 0068 A80E              add R10,R24
 006A B91E              adc R11,R25
 006C                   .dbline 152
 006C           ;     if((tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 &&
 006C F501              movw R30,R10
 006E 2280              ldd R2,z+2
 0070 3380              ldd R3,z+3
 0072 F501              movw R30,R10
 0074 4080              ldd R4,z+0
 0076 5180              ldd R5,z+1
 0078 4228              or R4,R2
 007A 5328              or R5,R3
 007C 4420              tst R4
 007E 11F4              brne X0
 0080 5520              tst R5
 0082 81F0              breq L17
 0084           X0:
 0084 F501              movw R30,R10
 0086 2284              ldd R2,z+10
 0088 80910100          lds R24,_arptime
 008C 8219              sub R24,R2
 008E 8837              cpi R24,120
 0090 48F0              brlo L17
 0092                   .dbline 153
 0092           ;        arptime - tabptr->time >= UIP_ARP_MAXAGE) {
 0092                   .dbline 154
 0092           ;       memset(tabptr->ipaddr, 0, 4);
 0092 84E0              ldi R24,4
 0094 90E0              ldi R25,0
 0096 9983              std y+1,R25
 0098 8883              std y+0,R24
 009A 2227              clr R18
 009C 3327              clr R19
 009E 8501              movw R16,R10
 00A0 0E940000          xcall _memset
 00A4                   .dbline 155
 00A4           ;     }
 00A4           L17:
 00A4                   .dbline 156
 00A4           L14:
 00A4                   .dbline 150
 00A4 80910300          lds R24,_i
 00A8 8F5F              subi R24,255    ; addi 1
 00AA 80930300          sts _i,R24
 00AE           L16:
 00AE                   .dbline 150
 00AE 80910300          lds R24,_i
 00B2 8830              cpi R24,8
 00B4 90F2              brlo L13
 00B6                   .dbline -2
 00B6           L12:
 00B6 2296              adiw R28,2
 00B8 0E940000          xcall pop_gset3x
 00BC                   .dbline 0 ; func end
 00BC 0895              ret
 00BE                   .dbsym r tabptr 10 pS[arp_entry]
 00BE                   .dbend
 00BE                   .dbfunc s uip_arp_update _uip_arp_update fV
 00BE           ;         tabptr -> R10,R11
 00BE           ;        ethaddr -> R12,R13
 00BE           ;         ipaddr -> R14,R15
                        .even
 00BE           _uip_arp_update:
 00BE 0E940000          xcall push_gset5x
 00C2 6901              movw R12,R18
 00C4 7801              movw R14,R16
 00C6 2297              sbiw R28,2
 00C8                   .dbline -1
 00C8                   .dbline 162
 00C8           ;   }
 00C8           ; 
 00C8           ; }
 00C8           ; /*-----------------------------------------------------------------------------------*/
 00C8           ; static void
 00C8           ; uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
 00C8           ; {
 00C8                   .dbline 167
 00C8 2224              clr R2
 00CA 20920300          sts _i,R2
 00CE 3EC0              xjmp L23
 00D0           L20:
 00D0                   .dbline 167
 00D0           ;   register struct arp_entry *tabptr;
 00D0           ;   /* Walk through the ARP mapping table and try to find an entry to
 00D0           ;      update. If none is found, the IP -> MAC address mapping is
 00D0           ;      inserted in the ARP table. */
 00D0           ;   for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
 00D0                   .dbline 169
 00D0           ; 
 00D0           ;     tabptr = &arp_table[i];
 00D0 20900300          lds R2,_i
 00D4 8BE0              ldi R24,11
 00D6 829D              mul R24,R2
 00D8 5001              movw R10,R0
 00DA 80E0              ldi R24,<_arp_table
 00DC 90E0              ldi R25,>_arp_table
 00DE A80E              add R10,R24
 00E0 B91E              adc R11,R25
 00E2                   .dbline 171
 00E2           ;     /* Only check those entries that are actually in use. */
 00E2           ;     if(tabptr->ipaddr[0] != 0 &&
 00E2 F501              movw R30,R10
 00E4 2080              ldd R2,z+0
 00E6 3180              ldd R3,z+1
 00E8 2220              tst R2
 00EA 19F4              brne X1

⌨️ 快捷键说明

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