|
@@ -465,7 +465,7 @@ int tcp_connectto ( struct tcp_connection *conn,
|
465
|
465
|
conn->timer.expired = tcp_expired;
|
466
|
466
|
|
467
|
467
|
/* Send a SYN packet and transition to TCP_SYN_SENT */
|
468
|
|
- conn->snd_una = ( ( ( uint32_t ) random() ) << 16 ) & random();
|
|
468
|
+ conn->snd_una = random();
|
469
|
469
|
tcp_trans ( conn, TCP_SYN_SENT );
|
470
|
470
|
/* Allocate space for the packet */
|
471
|
471
|
free_pkb ( conn->tx_pkb );
|
|
@@ -598,7 +598,7 @@ int tcp_senddata ( struct tcp_connection *conn ) {
|
598
|
598
|
switch ( conn->tcp_state ) {
|
599
|
599
|
case TCP_LISTEN:
|
600
|
600
|
tcp_trans ( conn, TCP_SYN_SENT );
|
601
|
|
- conn->snd_una = ( ( ( uint32_t ) random() ) << 16 ) & random();
|
|
601
|
+ conn->snd_una = random();
|
602
|
602
|
break;
|
603
|
603
|
case TCP_ESTABLISHED:
|
604
|
604
|
case TCP_CLOSE_WAIT:
|
|
@@ -738,7 +738,6 @@ static int tcp_rx ( struct pk_buff *pkb,
|
738
|
738
|
conn->snd_win = tcphdr->win;
|
739
|
739
|
|
740
|
740
|
/* TCP State Machine */
|
741
|
|
- uint8_t out_flags = 0;
|
742
|
741
|
conn->tcp_lstate = conn->tcp_state;
|
743
|
742
|
switch ( conn->tcp_state ) {
|
744
|
743
|
case TCP_CLOSED:
|
|
@@ -750,12 +749,11 @@ static int tcp_rx ( struct pk_buff *pkb,
|
750
|
749
|
tcp_trans ( conn, TCP_SYN_RCVD );
|
751
|
750
|
/* Synchronize the sequence numbers */
|
752
|
751
|
conn->rcv_nxt = ntohl ( tcphdr->seq ) + 1;
|
753
|
|
- out_flags |= TCP_ACK;
|
|
752
|
+ conn->tcp_flags |= TCP_ACK;
|
754
|
753
|
|
755
|
754
|
/* Set the sequence number for the snd stream */
|
756
|
|
- conn->snd_una = ( ( ( uint32_t ) random() ) << 16 );
|
757
|
|
- conn->snd_una &= random();
|
758
|
|
- out_flags |= TCP_SYN;
|
|
755
|
+ conn->snd_una = random();
|
|
756
|
+ conn->tcp_flags |= TCP_SYN;
|
759
|
757
|
|
760
|
758
|
/* Send a SYN,ACK packet */
|
761
|
759
|
goto send_tcp_nomsg;
|
|
@@ -766,7 +764,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
766
|
764
|
if ( tcphdr->flags & TCP_SYN ) {
|
767
|
765
|
/* Synchronize the sequence number in rcv stream */
|
768
|
766
|
conn->rcv_nxt = ntohl ( tcphdr->seq ) + 1;
|
769
|
|
- out_flags |= TCP_ACK;
|
|
767
|
+ conn->tcp_flags |= TCP_ACK;
|
770
|
768
|
|
771
|
769
|
if ( tcphdr->flags & TCP_ACK ) {
|
772
|
770
|
tcp_trans ( conn, TCP_ESTABLISHED );
|
|
@@ -776,12 +774,12 @@ static int tcp_rx ( struct pk_buff *pkb,
|
776
|
774
|
*/
|
777
|
775
|
conn->snd_una = ntohl ( tcphdr->ack );
|
778
|
776
|
conn->tcp_op->connected ( conn );
|
779
|
|
- out_flags |= TCP_ACK;
|
|
777
|
+ conn->tcp_flags |= TCP_ACK;
|
780
|
778
|
tcp_senddata ( conn );
|
781
|
779
|
return;
|
782
|
780
|
} else {
|
783
|
781
|
tcp_trans ( conn, TCP_SYN_RCVD );
|
784
|
|
- out_flags |= TCP_SYN;
|
|
782
|
+ conn->tcp_flags |= TCP_SYN;
|
785
|
783
|
goto send_tcp_nomsg;
|
786
|
784
|
}
|
787
|
785
|
}
|
|
@@ -811,7 +809,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
811
|
809
|
tcp_trans ( conn, TCP_CLOSE_WAIT );
|
812
|
810
|
/* FIN consumes one byte */
|
813
|
811
|
conn->rcv_nxt++;
|
814
|
|
- out_flags |= TCP_ACK;
|
|
812
|
+ conn->tcp_flags |= TCP_ACK;
|
815
|
813
|
/* Send an acknowledgement */
|
816
|
814
|
goto send_tcp_nomsg;
|
817
|
815
|
}
|
|
@@ -821,7 +819,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
821
|
819
|
case TCP_FIN_WAIT_1:
|
822
|
820
|
if ( tcphdr->flags & TCP_FIN ) {
|
823
|
821
|
conn->rcv_nxt++;
|
824
|
|
- out_flags |= TCP_ACK;
|
|
822
|
+ conn->tcp_flags |= TCP_ACK;
|
825
|
823
|
conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
826
|
824
|
|
827
|
825
|
if ( tcphdr->flags & TCP_ACK ) {
|
|
@@ -842,7 +840,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
842
|
840
|
tcp_trans ( conn, TCP_TIME_WAIT );
|
843
|
841
|
/* FIN consumes one byte */
|
844
|
842
|
conn->rcv_nxt++;
|
845
|
|
- out_flags |= TCP_ACK;
|
|
843
|
+ conn->tcp_flags |= TCP_ACK;
|
846
|
844
|
goto send_tcp_nomsg;
|
847
|
845
|
}
|
848
|
846
|
/* Packet might contain data */
|
|
@@ -886,12 +884,12 @@ static int tcp_rx ( struct pk_buff *pkb,
|
886
|
884
|
conn->tcp_op->newdata ( conn, pkb->data + hlen,
|
887
|
885
|
toack );
|
888
|
886
|
} else {
|
889
|
|
- DBG ( "Unexpected sequence number %ld (wanted %ld)\n",
|
|
887
|
+ DBG ( "Unexpected sequence number %lx (wanted %lx)\n",
|
890
|
888
|
ntohl ( tcphdr->seq ), conn->rcv_nxt );
|
891
|
889
|
}
|
892
|
890
|
|
893
|
891
|
/* Acknowledge new data */
|
894
|
|
- out_flags |= TCP_ACK;
|
|
892
|
+ conn->tcp_flags |= TCP_ACK;
|
895
|
893
|
if ( !( tcphdr->flags & TCP_ACK ) ) {
|
896
|
894
|
goto send_tcp_nomsg;
|
897
|
895
|
}
|
|
@@ -918,7 +916,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
918
|
916
|
conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
919
|
917
|
conn->rcv_nxt++;
|
920
|
918
|
if ( ! ( tcphdr->flags & TCP_ACK ) ) {
|
921
|
|
- out_flags |= TCP_ACK;
|
|
919
|
+ conn->tcp_flags |= TCP_ACK;
|
922
|
920
|
/* Send an acknowledgement */
|
923
|
921
|
goto send_tcp_nomsg;
|
924
|
922
|
}
|