📄 uip_arp.s
字号:
breq L46
.dbline 247
; (uip_hostaddr[1] & uip_arp_netmask[1])) {
.dbline 248
; return;
xjmp L42
L46:
.dbline 250
; }
; uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src));
ldi R18,<_uip_buf+6
ldi R19,>_uip_buf+6
ldi R16,<_uip_buf+26
ldi R17,>_uip_buf+26
xcall _uip_arp_update
.dbline 252
;
; return;
.dbline -2
L42:
.dbline 0 ; func end
ret
.dbend
.dbfunc e uip_arp_arpin _uip_arp_arpin fV
.even
_uip_arp_arpin::
sbiw R28,2
.dbline -1
.dbline 279
; }
; /*-----------------------------------------------------------------------------------*/
; /**
; * ARP processing for incoming ARP packets.
; *
; * This function should be called by the device driver when an ARP
; * packet has been received. The function will act differently
; * depending on the ARP packet type: if it is a reply for a request
; * that we previously sent out, the ARP cache will be filled in with
; * the values from the ARP reply. If the incoming ARP packet is an ARP
; * request for our IP address, an ARP reply packet is created and put
; * into the uip_buf[] buffer.
; *
; * When the function returns, the value of the global variable uip_len
; * indicates whether the device driver should send out a packet or
; * not. If uip_len is zero, no packet should be sent. If uip_len is
; * non-zero, it contains the length of the outbound packet that is
; * present in the uip_buf[] buffer.
; *
; * This function expects an ARP packet with a prepended Ethernet
; * header in the uip_buf[] buffer, and the length of the packet in the
; * global variable uip_len.
; */
; /*-----------------------------------------------------------------------------------*/
; void
; uip_arp_arpin(void)
; {
.dbline 281
;
; if(uip_len < sizeof(struct arp_hdr)) {
lds R24,_uip_len
lds R25,_uip_len+1
cpi R24,42
ldi R30,0
cpc R25,R30
brsh L56
.dbline 281
.dbline 282
; uip_len = 0;
clr R2
clr R3
sts _uip_len+1,R3
sts _uip_len,R2
.dbline 283
; return;
xjmp L55
L56:
.dbline 286
; }
;
; uip_len = 0;
clr R2
clr R3
sts _uip_len+1,R3
sts _uip_len,R2
.dbline 288
;
; switch(BUF->opcode) {
lds R24,_uip_buf+20
lds R25,_uip_buf+20+1
cpi R24,0
ldi R30,1
cpc R25,R30
breq L61
cpi R24,0
ldi R30,1
cpc R25,R30
brge X8
xjmp L55
X8:
L94:
lds R24,_uip_buf+20
lds R25,_uip_buf+20+1
cpi R24,0
ldi R30,2
cpc R25,R30
brne X9
xjmp L85
X9:
xjmp L55
X7:
.dbline 288
L61:
.dbline 292
; case HTONS(ARP_REQUEST):
; /* ARP request. If it asked for our address, we send out a
; reply. */
; if(BUF->dipaddr[0] == uip_hostaddr[0] &&
ldi R30,<_uip_hostaddr
ldi R31,>_uip_hostaddr
lpm R0,Z+
lpm R1,Z
movw R30,R0
lds R2,_uip_buf+38
lds R3,_uip_buf+38+1
cp R2,R30
cpc R3,R31
breq X10
xjmp L55
X10:
ldi R30,<_uip_hostaddr+2
ldi R31,>_uip_hostaddr+2
lpm R0,Z+
lpm R1,Z
movw R30,R0
lds R2,_uip_buf+38+2
lds R3,_uip_buf+38+2+1
cp R2,R30
cpc R3,R31
breq X11
xjmp L55
X11:
.dbline 293
; BUF->dipaddr[1] == uip_hostaddr[1]) {
.dbline 295
; /* The reply opcode is 2. */
; BUF->opcode = HTONS(2);
ldi R24,512
ldi R25,2
sts _uip_buf+20+1,R25
sts _uip_buf+20,R24
.dbline 297
;
; memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_uip_buf+22
ldi R19,>_uip_buf+22
ldi R16,<_uip_buf+32
ldi R17,>_uip_buf+32
xcall _memcpy
.dbline 298
; memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_uip_ethaddr
ldi R19,>_uip_ethaddr
ldi R16,<_uip_buf+22
ldi R17,>_uip_buf+22
xcall _memcpy
.dbline 299
; memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_uip_ethaddr
ldi R19,>_uip_ethaddr
ldi R16,<_uip_buf+6
ldi R17,>_uip_buf+6
xcall _memcpy
.dbline 300
; memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_uip_buf+32
ldi R19,>_uip_buf+32
ldi R16,<_uip_buf
ldi R17,>_uip_buf
xcall _memcpy
.dbline 302
;
; BUF->dipaddr[0] = BUF->sipaddr[0];
lds R2,_uip_buf+28
lds R3,_uip_buf+28+1
sts _uip_buf+38+1,R3
sts _uip_buf+38,R2
.dbline 303
; BUF->dipaddr[1] = BUF->sipaddr[1];
lds R2,_uip_buf+28+2
lds R3,_uip_buf+28+2+1
sts _uip_buf+38+2+1,R3
sts _uip_buf+38+2,R2
.dbline 304
; BUF->sipaddr[0] = uip_hostaddr[0];
ldi R30,<_uip_hostaddr
ldi R31,>_uip_hostaddr
lpm R0,Z+
lpm R1,Z
movw R30,R0
sts _uip_buf+28+1,R31
sts _uip_buf+28,R30
.dbline 305
; BUF->sipaddr[1] = uip_hostaddr[1];
ldi R30,<_uip_hostaddr+2
ldi R31,>_uip_hostaddr+2
lpm R0,Z+
lpm R1,Z
movw R30,R0
sts _uip_buf+28+2+1,R31
sts _uip_buf+28+2,R30
.dbline 307
;
; BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
ldi R24,1544
ldi R25,6
sts _uip_buf+12+1,R25
sts _uip_buf+12,R24
.dbline 308
; uip_len = sizeof(struct arp_hdr);
ldi R24,42
ldi R25,0
sts _uip_len+1,R25
sts _uip_len,R24
.dbline 309
; }
.dbline 310
; break;
xjmp L55
L85:
.dbline 314
; case HTONS(ARP_REPLY):
; /* ARP reply. We insert or update the ARP table if it was meant
; for us. */
; if(BUF->dipaddr[0] == uip_hostaddr[0] &&
ldi R30,<_uip_hostaddr
ldi R31,>_uip_hostaddr
lpm R0,Z+
lpm R1,Z
movw R30,R0
lds R2,_uip_buf+38
lds R3,_uip_buf+38+1
cp R2,R30
cpc R3,R31
brne L55
ldi R30,<_uip_hostaddr+2
ldi R31,>_uip_hostaddr+2
lpm R0,Z+
lpm R1,Z
movw R30,R0
lds R2,_uip_buf+38+2
lds R3,_uip_buf+38+2+1
cp R2,R30
cpc R3,R31
brne L55
.dbline 315
; BUF->dipaddr[1] == uip_hostaddr[1]) {
.dbline 317
;
; uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
ldi R18,<_uip_buf+22
ldi R19,>_uip_buf+22
ldi R16,<_uip_buf+28
ldi R17,>_uip_buf+28
xcall _uip_arp_update
.dbline 318
; }
.dbline 319
; break;
.dbline 322
; }
;
; return;
.dbline -2
L55:
adiw R28,2
.dbline 0 ; func end
ret
.dbend
.dbfunc e uip_arp_out _uip_arp_out fV
; tabptr -> R10,R11
.even
_uip_arp_out::
xcall push_gset3x
sbiw R28,2
.dbline -1
.dbline 354
; }
; /*-----------------------------------------------------------------------------------*/
; /**
; * Prepend Ethernet header to an outbound IP packet and see if we need
; * to send out an ARP request.
; *
; * This function should be called before sending out an IP packet. The
; * function checks the destination IP address of the IP packet to see
; * what Ethernet MAC address that should be used as a destination MAC
; * address on the Ethernet.
; *
; * If the destination IP address is in the local network (determined
; * by logical ANDing of netmask and our IP address), the function
; * checks the ARP cache to see if an entry for the destination IP
; * address is found. If so, an Ethernet header is prepended and the
; * function returns. If no ARP cache entry is found for the
; * destination IP address, the packet in the uip_buf[] is replaced by
; * an ARP request packet for the IP address. The IP packet is dropped
; * and it is assumed that they higher level protocols (e.g., TCP)
; * eventually will retransmit the dropped packet.
; *
; * If the destination IP address is not on the local network, the IP
; * address of the default router is used instead.
; *
; * When the function returns, a packet is present in the uip_buf[]
; * buffer, and the length of the packet is in the global variable
; * uip_len.
; */
; /*-----------------------------------------------------------------------------------*/
; void
; uip_arp_out(void)
; {
.dbline 364
; struct arp_entry *tabptr;
; /* Find the destination IP address in the ARP table and construct
; the Ethernet header. If the destination IP addres isn't on the
; local network, we use the default router's IP address instead.
;
; If not ARP table entry is found, we overwrite the original IP
; packet with an ARP request for the IP address. */
;
; /* Check if the destination address is on the local network. */
; if((IPBUF->destipaddr[0] & uip_arp_netmask[0]) !=
ldi R30,<_uip_arp_netmask
ldi R31,>_uip_arp_netmask
lpm R0,Z+
lpm R1,Z
movw R30,R0
ldi R26,<_uip_hostaddr
ldi R27,>_uip_hostaddr
st -y,R31
st -y,R30
movw R30,R26
lpm R26,Z+
lpm R27,Z
ld R30,y+
ld R31,y+
and R26,R30
and R27,R31
ldi R30,<_uip_arp_netmask
ldi R31,>_uip_arp_netmask
lpm R0,Z+
lpm R1,Z
movw R30,R0
lds R2,_uip_buf+30
lds R3,_uip_buf+30+1
and R2,R30
and R3,R31
cp R2,R26
cpc R3,R27
brne L104
ldi R30,<_uip_arp_netmask+2
ldi R31,>_uip_arp_netmask+2
lpm R0,Z+
lpm R1,Z
movw R30,R0
ldi R26,<_uip_hostaddr+2
ldi R27,>_uip_hostaddr+2
st -y,R31
st -y,R30
movw R30,R26
lpm R26,Z+
lpm R27,Z
ld R30,y+
ld R31,y+
and R26,R30
and R27,R31
ldi R30,<_uip_arp_netmask+2
ldi R31,>_uip_arp_netmask+2
lpm R0,Z+
lpm R1,Z
movw R30,R0
lds R2,_uip_buf+30+2
lds R3,_uip_buf+30+2+1
and R2,R30
and R3,R31
cp R2,R26
cpc R3,R27
breq L96
L104:
.dbline 367
; (uip_hostaddr[0] & uip_arp_netmask[0]) ||
; (IPBUF->destipaddr[1] & uip_arp_netmask[1]) !=
; (uip_hostaddr[1] & uip_arp_netmask[1])) {
.dbline 371
; /* Destination address was not on the local network, so we need to
; use the default router's IP address instead of the destination
; address when determining the MAC address. */
; ipaddr[0] = uip_arp_draddr[0];
ldi R30,<_uip_arp_draddr
ldi R31,>_uip_arp_draddr
lpm R0,Z+
lpm R1,Z
movw R30,R0
sts _ipaddr+1,R31
sts _ipaddr,R30
.dbline 372
; ipaddr[1] = uip_arp_draddr[1];
ldi R30,<_uip_arp_draddr+2
ldi R31,>_uip_arp_draddr+2
lpm R0,Z+
lpm R1,Z
movw R30,R0
sts _ipaddr+2+1,R31
sts _ipaddr+2,R30
.dbline 373
xjmp L97
L96:
.dbline 373
; } else {
.dbline 375
; /* Else, we use the destination IP address. */
; ipaddr[0] = IPBUF->destipaddr[0];
lds R2,_uip_buf+30
lds R3,_uip_buf+30+1
sts _ipaddr+1,R3
sts _ipaddr,R2
.dbline 376
; ipaddr[1] = IPBUF->destipaddr[1];
lds R2,_uip_buf+30+2
lds R3,_uip_buf+30+2+1
sts _ipaddr+2+1,R3
sts _ipaddr+2,R2
.dbline 377
; }
L97:
.dbline 379
clr R2
sts _i,R2
xjmp L114
L111:
.dbline 379
;
; for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
.dbline 380
; tabptr = &arp_table[i];
lds R2,_i
ldi R24,11
mul R24,R2
movw R10,R0
ldi R24,<_arp_table
ldi R25,>_arp_table
add R10,R24
adc R11,R25
.dbline 381
; if(ipaddr[0] == tabptr->ipaddr[0] &&
movw R30,R10
ldd R2,z+0
ldd R3,z+1
lds R4,_ipaddr
lds R5,_ipaddr+1
cp R4,R2
cpc R5,R3
brne L115
ldd R2,z+2
ldd R3,z+3
lds R4,_ipaddr+2
lds R5,_ipaddr+2+1
cp R4,R2
cpc R5,R3
brne L115
.dbline 383
; ipaddr[1] == tabptr->ipaddr[1])
; break;
xjmp L113
L115:
.dbline 384
L112:
.dbline 379
lds R24,_i
subi R24,255 ; addi 1
sts _i,R24
L114:
.dbline 379
lds R24,_i
cpi R24,8
brlo L111
L113:
.dbline 386
; }
;
; if(i == UIP_ARPTAB_SIZE) {
lds R24,_i
cpi R24,8
breq X12
xjmp L118
X12:
.dbline 386
.dbline 390
; /* The destination address was not in our ARP table, so we
; overwrite the IP packet with an ARP request. */
;
; memset(BUF->ethhdr.dest.addr, 0xff, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,255
ldi R19,0
ldi R16,<_uip_buf
ldi R17,>_uip_buf
xcall _memset
.dbline 391
; memset(BUF->dhwaddr.addr, 0x00, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
clr R18
clr R19
ldi R16,<_uip_buf+32
ldi R17,>_uip_buf+32
xcall _memset
.dbline 392
; memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_uip_ethaddr
ldi R19,>_uip_ethaddr
ldi R16,<_uip_buf+6
ldi R17,>_uip_buf+6
xcall _memcpy
.dbline 393
; memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_uip_ethaddr
ldi R19,>_uip_ethaddr
ldi R16,<_uip_buf+22
ldi R17,>_uip_buf+22
xcall _memcpy
.dbline 395
;
; BUF->dipaddr[0] = ipaddr[0];
lds R2,_ipaddr
lds R3,_ipaddr+1
sts _uip_buf+38+1,R3
sts _uip_buf+38,R2
.dbline 396
; BUF->dipaddr[1] = ipaddr[1];
lds R2,_ipaddr+2
lds R3,_ipaddr+2+1
sts _uip_buf+38+2+1,R3
sts _uip_buf+38+2,R2
.dbline 397
; BUF->sipaddr[0] = uip_hostaddr[0];
ldi R30,<_uip_hostaddr
ldi R31,>_uip_hostaddr
lpm R0,Z+
lpm R1,Z
movw R30,R0
sts _uip_buf+28+1,R31
sts _uip_buf+28,R30
.dbline 398
; BUF->sipaddr[1] = uip_hostaddr[1];
ldi R30,<_uip_hostaddr+2
ldi R31,>_uip_hostaddr+2
lpm R0,Z+
lpm R1,Z
movw R30,R0
sts _uip_buf+28+2+1,R31
sts _uip_buf+28+2,R30
.dbline 399
; BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
ldi R24,256
ldi R25,1
sts _uip_buf+20+1,R25
sts _uip_buf+20,R24
.dbline 400
; BUF->hwtype = HTONS(ARP_HWTYPE_ETH);
sts _uip_buf+14+1,R25
sts _uip_buf+14,R24
.dbline 401
; BUF->protocol = HTONS(UIP_ETHTYPE_IP);
ldi R24,8
ldi R25,0
sts _uip_buf+16+1,R25
sts _uip_buf+16,R24
.dbline 402
; BUF->hwlen = 6;
ldi R24,6
sts _uip_buf+18,R24
.dbline 403
; BUF->protolen = 4;
ldi R24,4
sts _uip_buf+19,R24
.dbline 404
; BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
ldi R24,1544
ldi R25,6
sts _uip_buf+12+1,R25
sts _uip_buf+12,R24
.dbline 406
;
; uip_appdata = &uip_buf[40 + UIP_LLH_LEN];
ldi R24,<_uip_buf+54
ldi R25,>_uip_buf+54
sts _uip_appdata+1,R25
sts _uip_appdata,R24
.dbline 408
;
; uip_len = sizeof(struct arp_hdr);
ldi R24,42
ldi R25,0
sts _uip_len+1,R25
sts _uip_len,R24
.dbline 409
; return;
xjmp L95
L118:
.dbline 413
; }
;
; /* Build an ethernet header. */
; memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
movw R18,R10
subi R18,252 ; offset = 4
sbci R19,255
ldi R16,<_uip_buf
ldi R17,>_uip_buf
xcall _memcpy
.dbline 414
; memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_uip_ethaddr
ldi R19,>_uip_ethaddr
ldi R16,<_uip_buf+6
ldi R17,>_uip_buf+6
xcall _memcpy
.dbline 416
;
; IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
ldi R24,8
ldi R25,0
sts _uip_buf+12+1,R25
sts _uip_buf+12,R24
.dbline 418
;
; uip_len += sizeof(struct uip_eth_hdr);
lds R24,_uip_len
lds R25,_uip_len+1
adiw R24,14
sts _uip_len+1,R25
sts _uip_len,R24
.dbline -2
L95:
adiw R28,2
xcall pop_gset3x
.dbline 0 ; func end
ret
.dbsym r tabptr 10 pS[arp_entry]
.dbend
.area bss(ram, con, rel)
.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\uip_arp.c
_tmpage:
.blkb 1
.dbsym s tmpage _tmpage c
_arptime:
.blkb 1
.dbsym s arptime _arptime c
_c:
.blkb 1
.dbsym s c _c c
_i:
.blkb 1
.dbsym s i _i c
_ipaddr:
.blkb 4
.dbsym s ipaddr _ipaddr A[4:2]s
_arp_table:
.blkb 88
.dbsym s arp_table _arp_table A[88:8]S[arp_entry]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -