Selaa lähdekoodia

Remove some of the confusion surrounding the amount to strip off from

a TCP packet before passing to newdata().
tags/v0.9.3
Michael Brown 18 vuotta sitten
vanhempi
commit
de0c36a98a
1 muutettua tiedostoa jossa 5 lisäystä ja 6 poistoa
  1. 5
    6
      src/net/tcp.c

+ 5
- 6
src/net/tcp.c Näytä tiedosto

341
  * @v tcphdr	TCP header
341
  * @v tcphdr	TCP header
342
  */
342
  */
343
 void tcp_dump ( struct tcp_header *tcphdr ) {
343
 void tcp_dump ( struct tcp_header *tcphdr ) {
344
-	DBG ( "TCP %p src:%d dest:%d seq:%lld ack:%lld hlen:%hd flags:%#hx\n",
344
+	DBG ( "TCP %p src:%d dest:%d seq:%lx ack:%lx hlen:%hd flags:%#hx\n",
345
 		tcphdr, ntohs ( tcphdr->src ), ntohs ( tcphdr->dest ), ntohl ( tcphdr->seq ),
345
 		tcphdr, ntohs ( tcphdr->src ), ntohs ( tcphdr->dest ), ntohl ( tcphdr->seq ),
346
 		ntohl ( tcphdr->ack ), ( ( tcphdr->hlen & TCP_MASK_HLEN ) / 16 ), ( tcphdr->flags & TCP_MASK_FLAGS ) );
346
 		ntohl ( tcphdr->ack ), ( ( tcphdr->hlen & TCP_MASK_HLEN ) / 16 ), ( tcphdr->flags & TCP_MASK_FLAGS ) );
347
 }
347
 }
670
 	struct tcp_header *tcphdr;
670
 	struct tcp_header *tcphdr;
671
 	uint32_t acked, toack;
671
 	uint32_t acked, toack;
672
 	int hlen;
672
 	int hlen;
673
-	int add = 4;
674
 
673
 
675
 	/* Sanity check */
674
 	/* Sanity check */
676
 	if ( pkb_len ( pkb ) < sizeof ( *tcphdr ) ) {
675
 	if ( pkb_len ( pkb ) < sizeof ( *tcphdr ) ) {
688
 	if ( hlen != sizeof ( *tcphdr ) ) {
687
 	if ( hlen != sizeof ( *tcphdr ) ) {
689
 		if ( hlen == sizeof ( *tcphdr ) + 4 ) {
688
 		if ( hlen == sizeof ( *tcphdr ) + 4 ) {
690
 			DBG ( "TCP options sent\n" );
689
 			DBG ( "TCP options sent\n" );
691
-			add = 4;
692
 		} else {
690
 		} else {
693
 			DBG ( "Bad header length (%d bytes)\n", hlen );
691
 			DBG ( "Bad header length (%d bytes)\n", hlen );
694
 			return -EINVAL;
692
 			return -EINVAL;
861
 		/* Check if expected sequence number */
859
 		/* Check if expected sequence number */
862
 		if ( conn->rcv_nxt == ntohl ( tcphdr->seq ) ) {
860
 		if ( conn->rcv_nxt == ntohl ( tcphdr->seq ) ) {
863
 			conn->rcv_nxt += toack;
861
 			conn->rcv_nxt += toack;
864
-			conn->tcp_op->newdata ( conn, pkb->data + sizeof ( *tcphdr ) + add, toack );
862
+			conn->tcp_op->newdata ( conn, pkb->data + hlen,
863
+						toack );
865
 		} else {
864
 		} else {
866
-			printf ( "Unexpected sequence number %ld\n", 
865
+			DBG ( "Unexpected sequence number %ld (wanted %ld)\n", 
867
-				ntohl ( tcphdr->seq ) );
866
+			      ntohl ( tcphdr->seq ), conn->rcv_nxt );
868
 		}
867
 		}
869
 
868
 
870
 		/* Acknowledge new data */
869
 		/* Acknowledge new data */

Loading…
Peruuta
Tallenna