📄 uip.s
字号:
;
; /* We also send a reset packet to the remote host. */
; BUF->flags = TCP_RST | TCP_ACK;
ldi R24,20
sts _uip_buf+14+33,R24
.dbline 529
; goto tcp_send_nodata;
xjmp L91
L85:
.dbline 533
; }
;
; /* Exponential backoff. */
; uip_connr->timer = UIP_RTO << (uip_connr->nrtx > 4?
ldi R24,4
ldd R30,y+0
ldd R31,y+1
ldd R2,z+27
cp R24,R2
brsh L92
clr R25
movw R10,R24
xjmp L93
L92:
ldd R30,y+0
ldd R31,y+1
ldd R10,z+27
clr R11
L93:
ldi R16,3
ldi R17,0
movw R18,R10
xcall lsl16
mov R2,R16
ldd R30,y+0
ldd R31,y+1
std z+26,R2
.dbline 536
; 4:
; uip_connr->nrtx);
; ++(uip_connr->nrtx);
ldd R24,y+0
ldd R25,y+1
adiw R24,27
movw R30,R24
ldd R24,z+0
subi R24,255 ; addi 1
std z+0,R24
.dbline 544
;
; /* Ok, so we need to retransmit. We do this differently
; depending on which state we are in. In ESTABLISHED, we
; call upon the application so that it may prepare the
; data for the retransmit. In SYN_RCVD, we resend the
; SYNACK that we sent earlier and in LAST_ACK we have to
; retransmit our FINACK. */
; UIP_STAT(++uip_stat.tcp.rexmit);
lds R24,_uip_stat+26+12
lds R25,_uip_stat+26+12+1
adiw R24,1
sts _uip_stat+26+12+1,R25
sts _uip_stat+26+12,R24
.dbline 545
ldd R30,y+0
ldd R31,y+1
ldd R24,z+25
clr R25
andi R24,15
andi R25,0
movw R10,R24
cpi R24,1
ldi R30,0
cpc R25,R30
brne X36
xjmp L100
X36:
cpi R24,2
ldi R30,0
cpc R25,R30
breq L101
cpi R24,3
ldi R30,0
cpc R25,R30
breq L105
cpi R24,4
ldi R30,0
cpc R25,R30
brne X37
xjmp L108
X37:
cpi R24,6
ldi R30,0
cpc R25,R30
brne X38
xjmp L108
X38:
cpi R24,8
ldi R30,0
cpc R25,R30
brne X39
xjmp L108
X39:
xjmp L112
X5:
.dbline 545
; switch(uip_connr->tcpstateflags & TS_MASK) {
.dbline 549
; case SYN_RCVD:
; /* In the SYN_RCVD state, we should retransmit our
; SYNACK. */
; goto tcp_send_synack;
L101:
.dbline 554
;
; #if UIP_ACTIVE_OPEN
; case SYN_SENT:
; /* In the SYN_SENT state, we retransmit out SYN. */
; BUF->flags = 0;
clr R2
sts _uip_buf+14+33,R2
.dbline 555
; goto tcp_send_syn;
xjmp L104
L105:
.dbline 563
; #endif /* UIP_ACTIVE_OPEN */
;
; case ESTABLISHED:
; /* In the ESTABLISHED state, we call upon the application
; to do the actual retransmit after which we jump into
; the code for sending out the packet (the apprexmit
; label). */
; uip_len = 0;
clr R2
clr R3
sts _uip_len+1,R3
sts _uip_len,R2
.dbline 564
; uip_slen = 0;
sts _uip_slen+1,R3
sts _uip_slen,R2
.dbline 565
; uip_flags = UIP_REXMIT;
ldi R24,4
sts _uip_flags,R24
.dbline 566
; UIP_APPCALL();
xcall _httpd_appcall
.dbline 567
; goto apprexmit;
xjmp L106
X6:
.dbline 573
;
; case FIN_WAIT_1:
; case CLOSING:
; case LAST_ACK:
; /* In all these states we should retransmit a FINACK. */
; goto tcp_send_finack;
.dbline 576
;
; }
; }
.dbline 577
L81:
.dbline 577
; } else if((uip_connr->tcpstateflags & TS_MASK) == ESTABLISHED) {
ldd R30,y+0
ldd R31,y+1
ldd R24,z+25
andi R24,15
cpi R24,3
breq X40
xjmp L112
X40:
.dbline 577
.dbline 580
; /* If there was no need for a retransmission, we poll the
; application for new data. */
; uip_len = 0;
clr R2
clr R3
sts _uip_len+1,R3
sts _uip_len,R2
.dbline 581
; uip_slen = 0;
sts _uip_slen+1,R3
sts _uip_slen,R2
.dbline 582
; uip_flags = UIP_POLL;
ldi R24,8
sts _uip_flags,R24
.dbline 583
; UIP_APPCALL();
xcall _httpd_appcall
.dbline 584
; goto appsend;
xjmp L111
X7:
.dbline 586
; }
; }
.dbline 587
; goto drop;
L63:
.dbline 604
; }
; #if UIP_UDP
; if(flag == UIP_UDP_TIMER) {
; if(uip_udp_conn->lport != 0) {
; uip_appdata = &uip_buf[UIP_LLH_LEN + 28];
; uip_len = uip_slen = 0;
; uip_flags = UIP_POLL;
; UIP_UDP_APPCALL();
; goto udp_send;
; } else {
; goto drop;
; }
; }
; #endif
;
; /* This is where the input processing starts. */
; UIP_STAT(++uip_stat.ip.recv);
lds R24,_uip_stat+2
lds R25,_uip_stat+2+1
adiw R24,1
sts _uip_stat+2+1,R25
sts _uip_stat+2,R24
.dbline 610
;
;
; /* Start of IPv4 input header processing code. */
;
; /* Check validity of the IP header. */
; if(BUF->vhl != 0x45) { /* IP version and header length. */
ldi R30,<_uip_buf+14
ldi R31,>_uip_buf+14
ldd R24,z+0
cpi R24,69
breq L114
.dbline 610
.dbline 611
; UIP_STAT(++uip_stat.ip.drop);
lds R24,_uip_stat
lds R25,_uip_stat+1
adiw R24,1
sts _uip_stat+1,R25
sts _uip_stat,R24
.dbline 612
; UIP_STAT(++uip_stat.ip.vhlerr);
lds R24,_uip_stat+6
lds R25,_uip_stat+6+1
adiw R24,1
sts _uip_stat+6+1,R25
sts _uip_stat+6,R24
.dbline 613
; UIP_LOG("ip: invalid version or header length.");
.dbline 614
; goto drop;
xjmp L112
L114:
.dbline 621
; }
;
; /* Check the size of the packet. If the size reported to us in
; uip_len doesn't match the size reported in the IP header, there
; has been a transmission error and we drop the packet. */
;
; if(BUF->len[0] != (uip_len >> 8)) { /* IP length, high byte. */
lds R2,_uip_len
lds R3,_uip_len+1
mov R2,R3
clr R3
lds R4,_uip_buf+14+2
clr R5
cp R4,R2
cpc R5,R3
breq L118
.dbline 621
.dbline 622
; uip_len = (uip_len & 0xff) | (BUF->len[0] << 8);
mov R2,R4
clr R3
mov R3,R2
clr R2
lds R24,_uip_len
lds R25,_uip_len+1
andi R25,0
or R24,R2
or R25,R3
sts _uip_len+1,R25
sts _uip_len,R24
.dbline 623
; }
L118:
.dbline 624
; if(BUF->len[1] != (uip_len & 0xff)) { /* IP length, low byte. */
lds R24,_uip_len
lds R25,_uip_len+1
andi R25,0
lds R2,_uip_buf+14+2+1
clr R3
cp R2,R24
cpc R3,R25
breq L124
.dbline 624
.dbline 625
; uip_len = (uip_len & 0xff00) | BUF->len[1];
clr R3
lds R24,_uip_len
lds R25,_uip_len+1
andi R24,0
or R24,R2
or R25,R3
sts _uip_len+1,R25
sts _uip_len,R24
.dbline 626
; }
L124:
.dbline 629
;
; /* Check the fragment flag. */
; if((BUF->ipoffset[0] & 0x3f) != 0 ||
lds R24,_uip_buf+14+6
andi R24,63
brne L139
lds R2,_uip_buf+14+6+1
tst R2
breq L132
L139:
.dbline 630
; BUF->ipoffset[1] != 0) {
.dbline 637
; #if UIP_REASSEMBLY
; uip_len = uip_reass();
; if(uip_len == 0) {
; goto drop;
; }
; #else
; UIP_STAT(++uip_stat.ip.drop);
lds R24,_uip_stat
lds R25,_uip_stat+1
adiw R24,1
sts _uip_stat+1,R25
sts _uip_stat,R24
.dbline 638
; UIP_STAT(++uip_stat.ip.fragerr);
lds R24,_uip_stat+12
lds R25,_uip_stat+12+1
adiw R24,1
sts _uip_stat+12+1,R25
sts _uip_stat+12,R24
.dbline 639
; UIP_LOG("ip: fragment dropped.");
.dbline 640
; goto drop;
xjmp L112
L132:
.dbline 660
; #endif /* UIP_REASSEMBLY */
; }
;
; /* If we are configured to use ping IP address configuration and
; hasn't been assigned an IP address yet, we accept all ICMP
; packets. */
; #if UIP_PINGADDRCONF
; if((uip_hostaddr[0] | uip_hostaddr[1]) == 0) {
; if(BUF->proto == UIP_PROTO_ICMP) {
; UIP_LOG("ip: possible ping config packet received.");
; goto icmp_input;
; } else {
; UIP_LOG("ip: packet dropped since no address assigned.");
; goto drop;
; }
; }
; #endif /* UIP_PINGADDRCONF */
;
; /* Check if the packet is destined for our IP address. */
; if(BUF->destipaddr[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+14+16
lds R3,_uip_buf+14+16+1
cp R2,R30
cpc R3,R31
breq L141
.dbline 660
.dbline 661
; UIP_STAT(++uip_stat.ip.drop);
lds R24,_uip_stat
lds R25,_uip_stat+1
adiw R24,1
sts _uip_stat+1,R25
sts _uip_stat,R24
.dbline 662
; UIP_LOG("ip: packet not for us.");
.dbline 663
; goto drop;
xjmp L112
L141:
.dbline 665
; }
; if(BUF->destipaddr[1] != uip_hostaddr[1]) {
ldi R30,<_uip_hostaddr+2
ldi R31,>_uip_hostaddr+2
lpm R0,Z+
lpm R1,Z
movw R30,R0
lds R2,_uip_buf+14+16+2
lds R3,_uip_buf+14+16+2+1
cp R2,R30
cpc R3,R31
breq L145
.dbline 665
.dbline 666
; UIP_STAT(++uip_stat.ip.drop);
lds R24,_uip_stat
lds R25,_uip_stat+1
adiw R24,1
sts _uip_stat+1,R25
sts _uip_stat,R24
.dbline 667
; UIP_LOG("ip: packet not for us.");
.dbline 668
; goto drop;
xjmp L112
L145:
.dbline 671
; }
;
; if(uip_ipchksum() != 0xffff) { /* Compute and check the IP header
xcall _uip_ipchksum
cpi R16,255
ldi R30,255
cpc R17,R30
breq L151
.dbline 671
.dbline 673
; checksum. */
; UIP_STAT(++uip_stat.ip.drop);
lds R24,_uip_stat
lds R25,_uip_stat+1
adiw R24,1
sts _uip_stat+1,R25
sts _uip_stat,R24
.dbline 674
; UIP_STAT(++uip_stat.ip.chkerr);
lds R24,_uip_stat+14
lds R25,_uip_stat+14+1
adiw R24,1
sts _uip_stat+14+1,R25
sts _uip_stat+14,R24
.dbline 675
; UIP_LOG("ip: bad checksum.");
.dbline 676
; goto drop;
xjmp L112
L151:
.dbline 679
; }
;
; if(BUF->proto == UIP_PROTO_TCP) /* Check for TCP packet. If so, jump
lds R24,_uip_buf+14+9
cpi R24,6
brne L154
.dbline 681
; to the tcp_input label. */
; goto tcp_input;
xjmp L158
L154:
.dbline 688
;
; #if UIP_UDP
; if(BUF->proto == UIP_PROTO_UDP)
; goto udp_input;
; #endif /* UIP_UDP */
;
; if(BUF->proto != UIP_PROTO_ICMP) { /* We only allow ICMP packets from
lds R24,_uip_buf+14+9
cpi R24,1
breq L159
.dbline 688
.dbline 690
; here. */
; UIP_STAT(++uip_stat.ip.drop);
lds R24,_uip_stat
lds R25,_uip_stat+1
adiw R24,1
sts _uip_stat+1,R25
sts _uip_stat,R24
.dbline 691
; UIP_STAT(++uip_stat.ip.protoerr);
lds R24,_uip_stat+16
lds R25,_uip_stat+16+1
adiw R24,1
sts _uip_stat+16+1,R25
sts _uip_stat+16,R24
.dbline 692
; UIP_LOG("ip: neither tcp nor icmp.");
.dbline 693
; goto drop;
xjmp L112
L159:
L164:
.dbline 697
; }
;
; icmp_input:
; UIP_STAT(++uip_stat.icmp.recv);
lds R24,_uip_stat+18+2
lds R25,_uip_stat+18+2+1
adiw R24,1
sts _uip_stat+18+2+1,R25
sts _uip_stat+18+2,R24
.dbline 702
;
; /* ICMP echo (i.e., ping) processing. This is simple, we only change
; the ICMP type from ECHO to ECHO_REPLY and adjust the ICMP
; checksum before we return the packet. */
; if(ICMPBUF->type != ICMP_ECHO) {
lds R24,_uip_buf+14+20
cpi R24,8
breq L167
.dbline 702
.dbline 703
; UIP_STAT(++uip_stat.icmp.drop);
lds R24,_uip_stat+18
lds R25,_uip_stat+18+1
adiw R24,1
sts _uip_stat+18+1,R25
sts _uip_stat+18,R24
.dbline 704
; UIP_STAT(++uip_stat.icmp.typeerr);
lds R24,_uip_stat+18+6
lds R25,_uip_stat+18+6+1
adiw R24,1
sts _uip_stat+18+6+1,R25
sts _uip_stat+18+6,R24
.dbline 705
; UIP_LOG("icmp: not icmp echo.");
.dbline 706
; goto drop;
xjmp L112
L167:
.dbline 719
; }
;
; /* If we are configured to use ping IP address assignment, we use
; the destination IP address of this ping packet and assign it to
; ourself. */
; #if UIP_PINGADDRCONF
; if((uip_hostaddr[0] | uip_hostaddr[1]) == 0) {
; uip_hostaddr[0] = BUF->destipaddr[0];
; uip_hostaddr[1] = BUF->destipaddr[1];
; }
; #endif /* UIP_PINGADDRCONF */
;
; ICMPBUF->type = ICMP_ECHO_REPLY;
clr R2
sts _uip_buf+14+20,R2
.dbline 721
;
; if(ICMPBUF->icmpchksum >= HTONS(0xffff - (ICMP_ECHO << 8))) {
lds R24,_uip_buf+14+22
lds R25,_uip_buf+14+22+1
cpi R24,247
ldi R30,255
cpc R25,R30
brlo L176
.dbline 721
.dbline 722
; ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8) + 1;
adiw R24,9
sts _uip_buf+14+22+1,R25
sts _uip_buf+14+22,R24
.dbline 723
xjmp L177
L176:
.dbline 723
; } else {
.dbline 724
; ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8);
lds R24,_uip_buf+14+22
lds R25,_uip_buf+14+22+1
adiw R24,8
sts _uip_buf+14+22+1,R25
sts _uip_buf+14+22,R24
.dbline 725
; }
L177:
.dbline 728
;
; /* Swap IP addresses. */
; tmp16 = BUF->destipaddr[0];
lds R2,_uip_buf+14+16
lds R3,_uip_buf+14+16+1
sts _tmp16+1,R3
sts _tmp16,R2
.dbline 729
; BUF->destipaddr[0] = BUF->srcipaddr[0];
lds R2,_uip_buf+14+12
lds R3,_uip_buf+14+12+1
sts _uip_buf+14+16+1,R3
sts _uip_buf+14+16,R2
.dbline 730
; BUF->srcipaddr[0] = tmp16;
lds R2,_tmp16
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -