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

📄 uip.s

📁 uIP是免费的TCP/IP协议栈,我们将它移植到我们的AVR以太网开发板中
💻 S
📖 第 1 页 / 共 5 页
字号:
	lds R3,_tmp16+1
	sts _uip_buf+14+12+1,R3
	sts _uip_buf+14+12,R2
	.dbline 731
;   tmp16 = BUF->destipaddr[1];
	lds R2,_uip_buf+14+16+2
	lds R3,_uip_buf+14+16+2+1
	sts _tmp16+1,R3
	sts _tmp16,R2
	.dbline 732
;   BUF->destipaddr[1] = BUF->srcipaddr[1];
	lds R2,_uip_buf+14+12+2
	lds R3,_uip_buf+14+12+2+1
	sts _uip_buf+14+16+2+1,R3
	sts _uip_buf+14+16+2,R2
	.dbline 733
;   BUF->srcipaddr[1] = tmp16;
	lds R2,_tmp16
	lds R3,_tmp16+1
	sts _uip_buf+14+12+2+1,R3
	sts _uip_buf+14+12+2,R2
	.dbline 735
; 
;   UIP_STAT(++uip_stat.icmp.sent);
	lds R24,_uip_stat+18+4
	lds R25,_uip_stat+18+4+1
	adiw R24,1
	sts _uip_stat+18+4+1,R25
	sts _uip_stat+18+4,R24
	.dbline 736
;   goto send;
	xjmp L206
L158:
	.dbline 813
; 
;   /* End of IPv4 input header processing code. */
;   
; 
; #if UIP_UDP
;   /* UDP input processing. */
;  udp_input:
;   /* UDP processing is really just a hack. We don't do anything to the
;      UDP/IP headers, but let the UDP application do all the hard
;      work. If the application sets uip_slen, it has a packet to
;      send. */
; #if UIP_UDP_CHECKSUMS
;   if(uip_udpchksum() != 0xffff) { 
;     UIP_STAT(++uip_stat.udp.drop);
;     UIP_STAT(++uip_stat.udp.chkerr);
;     UIP_LOG("udp: bad checksum.");    
;     goto drop;
;   }  
; #endif /* UIP_UDP_CHECKSUMS */
; 
;   /* Demultiplex this UDP packet between the UDP "connections". */
;   for(uip_udp_conn = &uip_udp_conns[0];
;       uip_udp_conn < &uip_udp_conns[UIP_UDP_CONNS];
;       ++uip_udp_conn) {
;     if(uip_udp_conn->lport != 0 &&
;        UDPBUF->destport == uip_udp_conn->lport &&
;        (uip_udp_conn->rport == 0 ||
;         UDPBUF->srcport == uip_udp_conn->rport) &&
;        BUF->srcipaddr[0] == uip_udp_conn->ripaddr[0] &&
;        BUF->srcipaddr[1] == uip_udp_conn->ripaddr[1]) {
;       goto udp_found; 
;     }
;   }
;   goto drop;
;   
;  udp_found:
;   uip_len = uip_len - 28;
;   uip_appdata = &uip_buf[UIP_LLH_LEN + 28];
;   uip_flags = UIP_NEWDATA;
;   uip_slen = 0;
;   UIP_UDP_APPCALL();
;  udp_send:
;   if(uip_slen == 0) {
;     goto drop;      
;   }
;   uip_len = uip_slen + 28;
; 
;   BUF->len[0] = (uip_len >> 8);
;   BUF->len[1] = (uip_len & 0xff);
;   
;   BUF->proto = UIP_PROTO_UDP;
; 
;   UDPBUF->udplen = HTONS(uip_slen + 8);
;   UDPBUF->udpchksum = 0;
; #if UIP_UDP_CHECKSUMS 
;   /* Calculate UDP checksum. */
;   UDPBUF->udpchksum = ~(uip_udpchksum());
;   if(UDPBUF->udpchksum == 0) {
;     UDPBUF->udpchksum = 0xffff;
;   }
; #endif /* UIP_UDP_CHECKSUMS */
; 
;   BUF->srcport  = uip_udp_conn->lport;
;   BUF->destport = uip_udp_conn->rport;
; 
;   BUF->srcipaddr[0] = uip_hostaddr[0];
;   BUF->srcipaddr[1] = uip_hostaddr[1];
;   BUF->destipaddr[0] = uip_udp_conn->ripaddr[0];
;   BUF->destipaddr[1] = uip_udp_conn->ripaddr[1];
;  
;   uip_appdata = &uip_buf[UIP_LLH_LEN + 40];
;   goto ip_send_nolen;
; #endif /* UIP_UDP */
;   
;   /* TCP input processing. */  
;  tcp_input:
;   UIP_STAT(++uip_stat.tcp.recv);
	lds R24,_uip_stat+26+2
	lds R25,_uip_stat+26+2+1
	adiw R24,1
	sts _uip_stat+26+2+1,R25
	sts _uip_stat+26+2,R24
	.dbline 817
; 
;   /* Start of TCP input header processing code. */
;   
;   if(uip_tcpchksum() != 0xffff) {   /* Compute and check the TCP
	xcall _uip_tcpchksum
	cpi R16,255
	ldi R30,255
	cpc R17,R30
	breq L209
	.dbline 817
	.dbline 819
; 				       checksum. */
;     UIP_STAT(++uip_stat.tcp.drop);
	lds R24,_uip_stat+26
	lds R25,_uip_stat+26+1
	adiw R24,1
	sts _uip_stat+26+1,R25
	sts _uip_stat+26,R24
	.dbline 820
;     UIP_STAT(++uip_stat.tcp.chkerr);
	lds R24,_uip_stat+26+6
	lds R25,_uip_stat+26+6+1
	adiw R24,1
	sts _uip_stat+26+6+1,R25
	sts _uip_stat+26+6,R24
	.dbline 821
;     UIP_LOG("tcp: bad checksum.");    
	.dbline 822
;     goto drop;
	xjmp L112
L209:
	.dbline 827
	ldi R24,<_uip_conns
	ldi R25,>_uip_conns
	std y+1,R25
	std y+0,R24
	xjmp L217
L214:
	.dbline 827
;   }
;   
;   /* Demultiplex this segment. */
;   /* First check any active connections. */
;   for(uip_connr = &uip_conns[0]; uip_connr < &uip_conns[UIP_CONNS]; ++uip_connr) {
	.dbline 828
;     if(uip_connr->tcpstateflags != CLOSED &&
	ldd R30,y+0
	ldd R31,y+1
	ldd R2,z+25
	tst R2
	breq L219
	ldd R30,y+0
	ldd R31,y+1
	ldd R2,z+4
	ldd R3,z+5
	lds R4,_uip_buf+14+22
	lds R5,_uip_buf+14+22+1
	cp R4,R2
	cpc R5,R3
	brne L219
	ldd R30,y+0
	ldd R31,y+1
	ldd R2,z+6
	ldd R3,z+7
	lds R4,_uip_buf+14+20
	lds R5,_uip_buf+14+20+1
	cp R4,R2
	cpc R5,R3
	brne L219
	ldd R30,y+0
	ldd R31,y+1
	ldd R2,z+0
	ldd R3,z+1
	lds R4,_uip_buf+14+12
	lds R5,_uip_buf+14+12+1
	cp R4,R2
	cpc R5,R3
	brne L219
	ldd R2,z+2
	ldd R3,z+3
	lds R4,_uip_buf+14+12+2
	lds R5,_uip_buf+14+12+2+1
	cp R4,R2
	cpc R5,R3
	brne L219
	.dbline 832
;        BUF->destport == uip_connr->lport &&
;        BUF->srcport == uip_connr->rport &&
;        BUF->srcipaddr[0] == uip_connr->ripaddr[0] &&
;        BUF->srcipaddr[1] == uip_connr->ripaddr[1]) {
	.dbline 833
;       goto found;    
	xjmp L230
L219:
	.dbline 835
L215:
	.dbline 827
	ldd R24,y+0
	ldd R25,y+1
	adiw R24,35
	std y+1,R25
	std y+0,R24
L217:
	.dbline 827
	ldi R24,<_uip_conns+350
	ldi R25,>_uip_conns+350
	ldd R0,y+0
	ldd R1,y+1
	cp R0,R24
	cpc R1,R25
	brsh X41
	xjmp L214
X41:
	.dbline 841
;     }
;   }
; 
;   /* If we didn't find and active connection that expected the packet,
;      either this packet is an old duplicate, or this is a SYN packet
;      destined for a connection in LISTEN. If the SYN flag isn't set,
;      it is an old packet and we send a RST. */
;   if((BUF->flags & TCP_CTL) != TCP_SYN)
	lds R24,_uip_buf+14+33
	andi R24,63
	cpi R24,2
	breq L231
	.dbline 842
;     goto reset;
	xjmp L235
L231:
	.dbline 844
;   
;   tmp16 = BUF->destport;
	lds R2,_uip_buf+14+22
	lds R3,_uip_buf+14+22+1
	sts _tmp16+1,R3
	sts _tmp16,R2
	.dbline 846
	clr R2
	sts _c,R2
	xjmp L241
L238:
	.dbline 846
;   /* Next, check listening connections. */  
;   for(c = 0; c < UIP_LISTENPORTS; ++c) {
	.dbline 847
;     if(tmp16 == uip_listenports[c])
	lds R2,_c
	ldi R24,2
	mul R24,R2
	movw R30,R0
	ldi R24,<_uip_listenports
	ldi R25,>_uip_listenports
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	lds R4,_tmp16
	lds R5,_tmp16+1
	cp R4,R2
	cpc R5,R3
	brne L242
	.dbline 848
;       goto found_listen;
	xjmp L244
L242:
	.dbline 849
L239:
	.dbline 846
	lds R24,_c
	subi R24,255    ; addi 1
	sts _c,R24
L241:
	.dbline 846
	lds R24,_c
	cpi R24,10
	brlo L238
	.dbline 852
;   }
;   
;   /* No matching connection found, so we send a RST packet. */
;   UIP_STAT(++uip_stat.tcp.synrst);
	lds R24,_uip_stat+26+16
	lds R25,_uip_stat+26+16+1
	adiw R24,1
	sts _uip_stat+26+16+1,R25
	sts _uip_stat+26+16,R24
L235:
	.dbline 856
;  reset:
; 
;   /* We do not send resets in response to resets. */
;   if(BUF->flags & TCP_RST) 
	lds R2,_uip_buf+14+33
	sbrs R2,2
	rjmp L247
	.dbline 857
;     goto drop;
	xjmp L112
L247:
	.dbline 859
; 
;   UIP_STAT(++uip_stat.tcp.rst);
	lds R24,_uip_stat+26+10
	lds R25,_uip_stat+26+10+1
	adiw R24,1
	sts _uip_stat+26+10+1,R25
	sts _uip_stat+26+10,R24
	.dbline 861
;   
;   BUF->flags = TCP_RST | TCP_ACK;
	ldi R24,20
	sts _uip_buf+14+33,R24
	.dbline 862
;   uip_len = 40;
	ldi R24,40
	ldi R25,0
	sts _uip_len+1,R25
	sts _uip_len,R24
	.dbline 863
;   BUF->tcpoffset = 5 << 4;
	ldi R24,80
	sts _uip_buf+14+32,R24
	.dbline 866
; 
;   /* Flip the seqno and ackno fields in the TCP header. */
;   c = BUF->seqno[3];
	lds R2,_uip_buf+14+24+3
	sts _c,R2
	.dbline 867
;   BUF->seqno[3] = BUF->ackno[3];  
	lds R2,_uip_buf+14+28+3
	sts _uip_buf+14+24+3,R2
	.dbline 868
;   BUF->ackno[3] = c;
	lds R2,_c
	sts _uip_buf+14+28+3,R2
	.dbline 870
;   
;   c = BUF->seqno[2];
	lds R2,_uip_buf+14+24+2
	sts _c,R2
	.dbline 871
;   BUF->seqno[2] = BUF->ackno[2];  
	lds R2,_uip_buf+14+28+2
	sts _uip_buf+14+24+2,R2
	.dbline 872
;   BUF->ackno[2] = c;
	lds R2,_c
	sts _uip_buf+14+28+2,R2
	.dbline 874
;   
;   c = BUF->seqno[1];
	lds R2,_uip_buf+14+24+1
	sts _c,R2
	.dbline 875
;   BUF->seqno[1] = BUF->ackno[1];
	lds R2,_uip_buf+14+28+1
	sts _uip_buf+14+24+1,R2
	.dbline 876
;   BUF->ackno[1] = c;
	lds R2,_c
	sts _uip_buf+14+28+1,R2
	.dbline 878
;   
;   c = BUF->seqno[0];
	lds R2,_uip_buf+14+24
	sts _c,R2
	.dbline 879
;   BUF->seqno[0] = BUF->ackno[0];  
	lds R2,_uip_buf+14+28
	sts _uip_buf+14+24,R2
	.dbline 880
;   BUF->ackno[0] = c;
	lds R2,_c
	sts _uip_buf+14+28,R2
	.dbline 885
; 
;   /* We also have to increase the sequence number we are
;      acknowledging. If the least significant byte overflowed, we need
;      to propagate the carry to the other bytes as well. */
;   if(++BUF->ackno[3] == 0) {
	lds R24,_uip_buf+14+28+3
	subi R24,255    ; addi 1
	mov R2,R24
	sts _uip_buf+14+28+3,R2
	tst R24
	brne L301
	.dbline 885
	.dbline 886
;     if(++BUF->ackno[2] == 0) {
	lds R24,_uip_buf+14+28+2
	subi R24,255    ; addi 1
	mov R2,R24
	sts _uip_buf+14+28+2,R2
	tst R24
	brne L306
	.dbline 886
	.dbline 887
;       if(++BUF->ackno[1] == 0) {
	lds R24,_uip_buf+14+28+1
	subi R24,255    ; addi 1
	mov R2,R24
	sts _uip_buf+14+28+1,R2
	tst R24
	brne L311
	.dbline 887
	.dbline 888
; 	++BUF->ackno[0];
	lds R24,_uip_buf+14+28
	subi R24,255    ; addi 1
	sts _uip_buf+14+28,R24
	.dbline 889
;       }
L311:
	.dbline 890
;     }
L306:
	.dbline 891
;   }
L301:
	.dbline 894
;  
;   /* Swap port numbers. */
;   tmp16 = BUF->srcport;
	lds R2,_uip_buf+14+20
	lds R3,_uip_buf+14+20+1
	sts _tmp16+1,R3
	sts _tmp16,R2
	.dbline 895
;   BUF->srcport = BUF->destport;
	lds R2,_uip_buf+14+22
	lds R3,_uip_buf+14+22+1
	sts _uip_buf+14+20+1,R3
	sts _uip_buf+14+20,R2
	.dbline 896
;   BUF->destport = tmp16;
	lds R2,_tmp16
	lds R3,_tmp16+1
	sts _uip_buf+14+22+1,R3
	sts _uip_buf+14+22,R2
	.dbline 899
;   
;   /* 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 900
;   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 901
;   BUF->srcipaddr[0] = tmp16;
	lds R2,_tmp16
	lds R3,_tmp16+1
	sts _uip_buf+14+12+1,R3
	sts _uip_buf+14+12,R2
	.dbline 902
;   tmp16 = BUF->destipaddr[1];
	lds R2,_uip_buf+14+16+2
	lds R3,_uip_buf+14+16+2+1
	sts _tmp16+1,R3
	sts _tmp16,R2
	.dbline 903
;   BUF->destipaddr[1] = BUF->srcipaddr[1];
	lds R2,_uip_buf+14+12+2
	lds R3,_uip_buf+14+12+2+1
	sts _uip_buf+14+16+2+1,R3
	sts _uip_buf+14+16+2,R2
	.dbline 904
;   BUF->srcipaddr[1] = tmp16;
	lds R2,_tmp16
	lds R3,_tmp16+1
	sts _uip_buf+14+12+2+1,R3
	sts _uip_buf+14+12+2,R2
	.dbline 908
; 
;   
;   /* And send out the RST packet! */
;   goto tcp_send_noconn;
	xjmp L346
L244:
	.dbline 920
; 
;   /* This label will be jumped to if we matched the incoming packet
;      with a connection in LISTEN. In that case, we should create a new
;      connection and send a SYNACK in return. */
;  found_listen:
;   /* First we check if there are any connections avaliable. Unused
;      connections are kept in the same table as used connections, but
;      unused ones have the tcpstate set to CLOSED. Also, connections in
;      TIME_WAIT are kept track of and we'll use the oldest one if no
;      CLOSED connections are found. Thanks to Eddie C. Dost for a very
;      nice algorithm for the TIME_WAIT search. */
;   uip_connr = 0;
	clr R0
	clr R1
	std y+1,R1
	std y+0,R0
	.dbline 921
	clr R2
	sts _c,R2
	xjmp L350
L347:
	.dbline 921
;   for(c = 0; c < UIP_CONNS; ++c) {
	.dbline 922
;     if(uip_conns[c].tcpstateflags == CLOSED) {
	lds R2,_c
	ldi R24,35
	mul R24,R2
	movw R30,R0
	ldi R24,<_uip_conns+25
	ldi R25,>_uip_conns+25
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	tst R2
	brne L351
	.dbline 922
	.dbline 923
;       uip_connr = &uip_conns[c];
	lds R2,_c
	ldi R24,35
	mul R24,R2
	movw R2,R0
	ldi R24,<_uip_conns
	ldi R25,>_uip_conns
	add R2,R24
	adc R3,R25
	std y+1,R3
	std y+0,R2
	.dbline 924
;       break;
	xjmp L349
L351:
	.dbline 926
;     }
;     if(uip_conns[c].tcpstateflags == TIME_WAIT) {
	lds R2,_c
	ldi R24,35
	mul R24,R2
	movw R30,R0
	ldi R24,<_uip_conns+25
	ldi R25,>_uip_conns+25
	add R30,R24
	adc R31,R25
	ldd R24,z+0
	cpi R24,7
	brne L354
	.dbline 926
	.dbline 927
;       if(uip_connr == 0 ||
	ldd R0,y+0
	ldd R1,y+1
	tst R0
	brne X8
	tst R1
	breq L360
X8:
	lds R2,_c
	ldi R24,35
	mul R24,R2
	movw R30,R0
	ldi R24,<_uip_conns+26
	ldi R25,>_uip_conns+26
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R30,y+0
	ldd R31,y+1
	ldd R3,z+26
	cp R3,R2
	brsh L357
L360:
	.dbline 928
; 	 uip_conns[c].timer > uip_connr->timer) {
	.dbline 929
; 	uip_connr = &uip_conns[c];
	lds R2,_c
	ldi R24,35
	mul R24,R2
	movw R2,R0
	ldi R24,<_uip_conns
	ldi R25,>_uip_conns
	add R2,R24
	adc R3,R25
	std y+1,R3
	std y+0,R2

⌨️ 快捷键说明

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