📄 uip.s
字号:
.dbline 930
; }
L357:
.dbline 931
; }
L354:
.dbline 932
L348:
.dbline 921
lds R24,_c
subi R24,255 ; addi 1
sts _c,R24
L350:
.dbline 921
lds R24,_c
cpi R24,10
brsh X42
xjmp L347
X42:
L349:
.dbline 934
; }
;
; if(uip_connr == 0) {
ldd R0,y+0
ldd R1,y+1
tst R0
brne L361
tst R1
brne L361
X9:
.dbline 934
.dbline 938
; /* All connections are used already, we drop packet and hope that
; the remote end will retransmit the packet at a time when we
; have more spare connections. */
; UIP_STAT(++uip_stat.tcp.syndrop);
lds R24,_uip_stat+26+14
lds R25,_uip_stat+26+14+1
adiw R24,1
sts _uip_stat+26+14+1,R25
sts _uip_stat+26+14,R24
.dbline 939
; UIP_LOG("tcp: found no unused connections.");
.dbline 940
; goto drop;
xjmp L112
L361:
.dbline 942
; }
; uip_conn = uip_connr;
ldd R0,y+0
ldd R1,y+1
sts _uip_conn+1,R1
sts _uip_conn,R0
.dbline 945
;
; /* Fill in the necessary fields for the new connection. */
; uip_connr->rto = uip_connr->timer = UIP_RTO;
ldi R24,3
movw R30,R0
std z+26,R24
movw R30,R0
std z+24,R24
.dbline 946
; uip_connr->sa = 0;
clr R2
movw R30,R0
std z+22,R2
.dbline 947
; uip_connr->sv = 4;
ldi R24,4
movw R30,R0
std z+23,R24
.dbline 948
; uip_connr->nrtx = 0;
movw R30,R0
std z+27,R2
.dbline 949
; uip_connr->lport = BUF->destport;
lds R2,_uip_buf+14+22
lds R3,_uip_buf+14+22+1
movw R30,R0
std z+5,R3
std z+4,R2
.dbline 950
; uip_connr->rport = BUF->srcport;
lds R2,_uip_buf+14+20
lds R3,_uip_buf+14+20+1
movw R30,R0
std z+7,R3
std z+6,R2
.dbline 951
; uip_connr->ripaddr[0] = BUF->srcipaddr[0];
lds R2,_uip_buf+14+12
lds R3,_uip_buf+14+12+1
movw R30,R0
std z+1,R3
std z+0,R2
.dbline 952
; uip_connr->ripaddr[1] = BUF->srcipaddr[1];
lds R2,_uip_buf+14+12+2
lds R3,_uip_buf+14+12+2+1
std z+3,R3
std z+2,R2
.dbline 953
; uip_connr->tcpstateflags = SYN_RCVD;
ldi R24,1
movw R30,R0
std z+25,R24
.dbline 955
;
; uip_connr->snd_nxt[0] = iss[0];
lds R2,_iss
movw R30,R0
std z+12,R2
.dbline 956
; uip_connr->snd_nxt[1] = iss[1];
lds R2,_iss+1
movw R30,R0
std z+13,R2
.dbline 957
; uip_connr->snd_nxt[2] = iss[2];
lds R2,_iss+2
movw R30,R0
std z+14,R2
.dbline 958
; uip_connr->snd_nxt[3] = iss[3];
lds R2,_iss+3
movw R30,R0
std z+15,R2
.dbline 959
; uip_connr->len = 1;
clr R25
movw R30,R0
std z+17,R25
std z+16,R24
.dbline 962
;
; /* rcv_nxt should be the seqno from the incoming packet + 1. */
; uip_connr->rcv_nxt[3] = BUF->seqno[3];
lds R2,_uip_buf+14+24+3
movw R30,R0
std z+11,R2
.dbline 963
; uip_connr->rcv_nxt[2] = BUF->seqno[2];
lds R2,_uip_buf+14+24+2
movw R30,R0
std z+10,R2
.dbline 964
; uip_connr->rcv_nxt[1] = BUF->seqno[1];
lds R2,_uip_buf+14+24+1
movw R30,R0
std z+9,R2
.dbline 965
; uip_connr->rcv_nxt[0] = BUF->seqno[0];
lds R2,_uip_buf+14+24
movw R30,R0
std z+8,R2
.dbline 966
; uip_add_rcv_nxt(1);
ldi R16,1
ldi R17,0
xcall _uip_add_rcv_nxt
.dbline 969
;
; /* Parse the TCP MSS option, if present. */
; if((BUF->tcpoffset & 0xf0) > 0x50) {
ldi R24,80
lds R25,_uip_buf+14+32
andi R25,240
cp R24,R25
brlo X43
xjmp L388
X43:
.dbline 969
.dbline 970
clr R2
sts _c,R2
xjmp L395
L392:
.dbline 970
; for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) {
.dbline 971
; opt = uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + c];
ldi R24,<_uip_buf+54
ldi R25,>_uip_buf+54
lds R30,_c
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
sts _opt,R2
.dbline 972
; if(opt == 0x00) {
tst R2
brne L399
.dbline 972
.dbline 974
; /* End of options. */
; break;
xjmp L394
L399:
.dbline 975
; } else if(opt == 0x01) {
lds R24,_opt
cpi R24,1
brne L401
.dbline 975
.dbline 976
; ++c;
lds R24,_c
subi R24,255 ; addi 1
sts _c,R24
.dbline 978
xjmp L402
L401:
.dbline 978
; /* NOP option. */
; } else if(opt == 0x02 &&
lds R24,_opt
cpi R24,2
breq X44
xjmp L403
X44:
ldi R24,<_uip_buf+55
ldi R25,>_uip_buf+55
lds R30,_c
clr R31
add R30,R24
adc R31,R25
ldd R24,z+0
cpi R24,4
brne L403
.dbline 979
; uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0x04) {
.dbline 981
; /* An MSS option with the right option length. */
; tmp16 = ((u16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) |
ldi R24,<_uip_buf+57
ldi R25,>_uip_buf+57
lds R30,_c
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldi R24,<_uip_buf+56
ldi R25,>_uip_buf+56
lds R30,_c
clr R31
add R30,R24
adc R31,R25
ldd R3,z+0
sts _tmp16+1,R3
sts _tmp16,R2
.dbline 983
; (u16_t)uip_buf[40 + UIP_LLH_LEN + 3 + c];
; uip_connr->initialmss = uip_connr->mss =
ldi R24,1446
ldi R25,5
cp R24,R2
cpc R25,R3
brsh L408
movw R10,R24
xjmp L409
L408:
lds R10,_tmp16
lds R11,_tmp16+1
L409:
ldd R30,y+0
ldd R31,y+1
std z+19,R11
std z+18,R10
ldd R30,y+0
ldd R31,y+1
std z+21,R11
std z+20,R10
.dbline 987
; tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
;
; /* And we are done processing options. */
; break;
xjmp L394
L403:
.dbline 988
; } else {
.dbline 991
; /* All other options have a length field, so that we easily
; can skip past them. */
; if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) {
ldi R24,<_uip_buf+55
ldi R25,>_uip_buf+55
lds R30,_c
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
tst R2
brne L410
.dbline 991
.dbline 994
; /* If the length field is zero, the options are malformed
; and we don't process them further. */
; break;
xjmp L394
L410:
.dbline 996
; }
; c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c];
ldi R24,<_uip_buf+55
ldi R25,>_uip_buf+55
lds R30,_c
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
lds R3,_c
add R3,R2
sts _c,R3
.dbline 997
; }
L402:
.dbline 998
L393:
.dbline 970
L395:
.dbline 970
lds R24,_uip_buf+14+32
swap R24
andi R24,#0x0F
subi R24,5
lsl R24
lsl R24
lds R2,_c
cp R2,R24
brsh X45
xjmp L392
X45:
L394:
.dbline 999
; }
; }
L388:
L100:
.dbline 1004
;
; /* Our response will be a SYNACK. */
; #if UIP_ACTIVE_OPEN
; tcp_send_synack:
; BUF->flags = TCP_ACK;
ldi R24,16
sts _uip_buf+14+33,R24
L104:
.dbline 1007
;
; tcp_send_syn:
; BUF->flags |= TCP_SYN;
lds R24,_uip_buf+14+33
ori R24,2
sts _uip_buf+14+33,R24
.dbline 1015
; #else /* UIP_ACTIVE_OPEN */
; tcp_send_synack:
; BUF->flags = TCP_SYN | TCP_ACK;
; #endif /* UIP_ACTIVE_OPEN */
;
; /* We send out the TCP Maximum Segment Size option with our
; SYNACK. */
; BUF->optdata[0] = 2;
ldi R24,2
sts _uip_buf+14+40,R24
.dbline 1016
; BUF->optdata[1] = 4;
ldi R24,4
sts _uip_buf+14+40+1,R24
.dbline 1017
; BUF->optdata[2] = (UIP_TCP_MSS) / 256;
ldi R24,5
sts _uip_buf+14+40+2,R24
.dbline 1018
; BUF->optdata[3] = (UIP_TCP_MSS) & 255;
ldi R24,166
sts _uip_buf+14+40+3,R24
.dbline 1019
; uip_len = 44;
ldi R24,44
ldi R25,0
sts _uip_len+1,R25
sts _uip_len,R24
.dbline 1020
; BUF->tcpoffset = 6 << 4;
ldi R24,96
sts _uip_buf+14+32,R24
.dbline 1021
; goto tcp_send;
xjmp L431
L230:
.dbline 1025
;
; /* This label will be jumped to if we found an active connection. */
; found:
; uip_conn = uip_connr;
ldd R0,y+0
ldd R1,y+1
sts _uip_conn+1,R1
sts _uip_conn,R0
.dbline 1026
; uip_flags = 0;
clr R2
sts _uip_flags,R2
.dbline 1032
;
; /* We do a very naive form of TCP reset processing; we just accept
; any RST and kill our connection. We should in fact check if the
; sequence number of this reset is wihtin our advertised window
; before we accept the reset. */
; if(BUF->flags & TCP_RST) {
lds R2,_uip_buf+14+33
sbrs R2,2
rjmp L432
.dbline 1032
.dbline 1033
; uip_connr->tcpstateflags = CLOSED;
clr R2
movw R30,R0
std z+25,R2
.dbline 1034
; UIP_LOG("tcp: got reset, aborting connection.");
.dbline 1035
; uip_flags = UIP_ABORT;
ldi R24,32
sts _uip_flags,R24
.dbline 1036
; UIP_APPCALL();
xcall _httpd_appcall
.dbline 1037
; goto drop;
xjmp L112
L432:
.dbline 1041
; }
; /* Calculated the length of the data, if the application has sent
; any data to us. */
; c = (BUF->tcpoffset >> 4) << 2;
lds R24,_uip_buf+14+32
swap R24
andi R24,#0x0F
lsl R24
lsl R24
sts _c,R24
.dbline 1045
; /* uip_len will contain the length of the actual TCP data. This is
; calculated by subtracing the length of the TCP header (in
; c) and the length of the IP header (20 bytes). */
; uip_len = uip_len - c - 20;
mov R2,R24
clr R3
lds R24,_uip_len
lds R25,_uip_len+1
sub R24,R2
sbc R25,R3
sbiw R24,20
sts _uip_len+1,R25
sts _uip_len,R24
.dbline 1050
;
; /* First, check if the sequence number of the incoming packet is
; what we're expecting next. If not, we send out an ACK with the
; correct numbers in. */
; if(uip_len > 0 &&
lds R2,_uip_len
lds R3,_uip_len+1
tst R2
brne X10
tst R3
breq L438
X10:
ldd R30,y+0
ldd R31,y+1
ldd R2,z+8
lds R3,_uip_buf+14+24
cp R3,R2
brne L453
ldd R30,y+0
ldd R31,y+1
ldd R2,z+9
lds R3,_uip_buf+14+24+1
cp R3,R2
brne L453
ldd R30,y+0
ldd R31,y+1
ldd R2,z+10
lds R3,_uip_buf+14+24+2
cp R3,R2
brne L453
ldd R30,y+0
ldd R31,y+1
ldd R2,z+11
lds R3,_uip_buf+14+24+3
cp R3,R2
breq L438
L453:
.dbline 1054
; (BUF->seqno[0] != uip_connr->rcv_nxt[0] ||
; BUF->seqno[1] != uip_connr->rcv_nxt[1] ||
; BUF->seqno[2] != uip_connr->rcv_nxt[2] ||
; BUF->seqno[3] != uip_connr->rcv_nxt[3])) {
.dbline 1055
; goto tcp_send_ack;
xjmp L454
L438:
.dbline 1062
; }
;
; /* Next, check if the incoming segment acknowledges any outstanding
; data. If so, we update the sequence number, reset the length of
; the outstanding data, calculate RTT estimations, and reset the
; retransmission timer. */
; if((BUF->flags & TCP_ACK) && uip_outstanding(uip_connr)) {
lds R2,_uip_buf+14+33
sbrs R2,4
rjmp L455
ldd R30,y+0
ldd R31,y+1
ldd R2,z+16
ldd R3,z+17
tst R2
brne X11
tst R3
brne X46
xjmp L455
X46:
X11:
.dbline 1062
.dbline 1063
; uip_add32(uip_connr->snd_nxt, uip_connr->len);
ldd R30,y+0
ldd R31,y+1
ldd R18,z+16
ldd R19,z+17
ldd R16,y+0
ldd R17,y+1
subi R16,244 ; offset = 12
sbci R17,255
xcall _uip_add32
.dbline 1064
; if(BUF->ackno[0] == uip_acc32[0] &&
lds R2,_uip_acc32
lds R3,_uip_buf+14+28
cp R3,R2
breq X47
xjmp L459
X47:
lds R2,_uip_acc32+1
lds R3,_uip_buf+14+28+1
cp R3,R2
breq X48
xjmp L459
X48:
lds R2,_uip_acc32+2
lds R3,_uip_buf+14+28+2
cp R3,R2
breq X49
xjmp L459
X49:
lds R2,_uip_acc32+3
lds R3,_uip_buf+14+28+3
cp R3,R2
breq X50
xjmp L459
X50:
.dbline 1067
; BUF->ackno[1] == uip_acc32[1] &&
; BUF->ackno[2] == uip_acc32[2] &&
; BUF->ackno[3] == uip_acc32[3]) {
.dbline 1069
; /* Update sequence number. */
; uip_connr->snd_nxt[0] = uip_acc32[0];
lds R2,_uip_acc32
ldd R30,y+0
ldd R31,y+1
std z+12,R2
.dbline 1070
; uip_connr->snd_nxt[1] = uip_acc32[1];
lds R2,_uip_acc32+1
ldd R30,y+0
ldd R31,y+1
std z+13,R2
.dbline 1071
; uip_connr->snd_nxt[2] = uip_acc32[2];
lds R2,_uip_acc32+2
ldd R30,y+0
ldd R31,y+1
std z+14,R2
.dbline 1072
; uip_connr->snd_nxt[3] = uip_acc32[3];
lds R2,_uip_acc32+3
ldd R30,y+0
ldd R31,y+1
std z+15,R2
.dbline 1076
;
;
; /* Do RTT estimation, unless we have done retransmissions. */
; if(uip_connr->nrtx == 0) {
ldd R30,y+0
ldd R31,y+1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -