|
@@ -497,7 +497,8 @@ int tcp_close ( struct tcp_connection *conn ) {
|
497
|
497
|
case TCP_SYN_RCVD:
|
498
|
498
|
case TCP_ESTABLISHED:
|
499
|
499
|
tcp_trans ( conn, TCP_FIN_WAIT_1 );
|
500
|
|
- conn->tcp_op->closed ( conn, CONN_SNDCLOSE ); /* TODO: Check! */
|
|
500
|
+ if ( conn->tcp_op->closed )
|
|
501
|
+ conn->tcp_op->closed ( conn, CONN_SNDCLOSE ); /* TODO: Check! */
|
501
|
502
|
/* FIN consumes one byte on the snd stream */
|
502
|
503
|
// conn->snd_una++;
|
503
|
504
|
goto send_tcp_nomsg;
|
|
@@ -510,11 +511,13 @@ int tcp_close ( struct tcp_connection *conn ) {
|
510
|
511
|
*/
|
511
|
512
|
list_del ( &conn->list );
|
512
|
513
|
tcp_trans ( conn, TCP_CLOSED );
|
513
|
|
- conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
|
514
|
+ if ( conn->tcp_op->closed )
|
|
515
|
+ conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
514
|
516
|
return 0;
|
515
|
517
|
case TCP_CLOSE_WAIT:
|
516
|
518
|
tcp_trans ( conn, TCP_LAST_ACK );
|
517
|
|
- conn->tcp_op->closed ( conn, CONN_SNDCLOSE ); /* TODO: Check! */
|
|
519
|
+ if ( conn->tcp_op->closed )
|
|
520
|
+ conn->tcp_op->closed ( conn, CONN_SNDCLOSE ); /* TODO: Check! */
|
518
|
521
|
/* FIN consumes one byte on the snd stream */
|
519
|
522
|
// conn->snd_una++;
|
520
|
523
|
goto send_tcp_nomsg;
|
|
@@ -630,8 +633,9 @@ int tcp_senddata ( struct tcp_connection *conn ) {
|
630
|
633
|
/* Set the advertised window */
|
631
|
634
|
conn->rcv_win = pkb_available ( conn->tx_pkb );
|
632
|
635
|
/* Call the senddata() call back function */
|
633
|
|
- conn->tcp_op->senddata ( conn, conn->tx_pkb->data,
|
634
|
|
- pkb_available ( conn->tx_pkb ) );
|
|
636
|
+ if ( conn->tcp_op->senddata )
|
|
637
|
+ conn->tcp_op->senddata ( conn, conn->tx_pkb->data,
|
|
638
|
+ pkb_available ( conn->tx_pkb ) );
|
635
|
639
|
/* Send pure ACK if senddata() didn't call tcp_send() */
|
636
|
640
|
if ( conn->tx_pkb ) {
|
637
|
641
|
tcp_send ( conn, TCP_NOMSG, TCP_NOMSG_LEN );
|
|
@@ -796,7 +800,8 @@ static int tcp_rx ( struct pk_buff *pkb,
|
796
|
800
|
* acked() callback function.
|
797
|
801
|
*/
|
798
|
802
|
conn->snd_una = ntohl ( tcphdr->ack );
|
799
|
|
- conn->tcp_op->connected ( conn );
|
|
803
|
+ if ( conn->tcp_op->connected )
|
|
804
|
+ conn->tcp_op->connected ( conn );
|
800
|
805
|
conn->tcp_flags |= TCP_ACK;
|
801
|
806
|
tcp_senddata ( conn );
|
802
|
807
|
rc = 0;
|
|
@@ -812,7 +817,8 @@ static int tcp_rx ( struct pk_buff *pkb,
|
812
|
817
|
case TCP_SYN_RCVD:
|
813
|
818
|
if ( tcphdr->flags & TCP_RST ) {
|
814
|
819
|
tcp_trans ( conn, TCP_LISTEN );
|
815
|
|
- conn->tcp_op->closed ( conn, CONN_RESTART );
|
|
820
|
+ if ( conn->tcp_op->closed )
|
|
821
|
+ conn->tcp_op->closed ( conn, CONN_RESTART );
|
816
|
822
|
rc = 0;
|
817
|
823
|
goto done;
|
818
|
824
|
}
|
|
@@ -823,7 +829,8 @@ static int tcp_rx ( struct pk_buff *pkb,
|
823
|
829
|
* function nor does it send an ACK.
|
824
|
830
|
*/
|
825
|
831
|
conn->snd_una = tcphdr->ack - 1;
|
826
|
|
- conn->tcp_op->connected ( conn );
|
|
832
|
+ if ( conn->tcp_op->connected )
|
|
833
|
+ conn->tcp_op->connected ( conn );
|
827
|
834
|
rc = 0;
|
828
|
835
|
goto done;
|
829
|
836
|
}
|
|
@@ -849,7 +856,8 @@ static int tcp_rx ( struct pk_buff *pkb,
|
849
|
856
|
if ( tcphdr->flags & TCP_FIN ) {
|
850
|
857
|
conn->rcv_nxt++;
|
851
|
858
|
conn->tcp_flags |= TCP_ACK;
|
852
|
|
- conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
|
859
|
+ if ( conn->tcp_op->closed )
|
|
860
|
+ conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
853
|
861
|
|
854
|
862
|
if ( tcphdr->flags & TCP_ACK ) {
|
855
|
863
|
tcp_trans ( conn, TCP_TIME_WAIT );
|
|
@@ -920,7 +928,8 @@ static int tcp_rx ( struct pk_buff *pkb,
|
920
|
928
|
}
|
921
|
929
|
/* Invoke the acked() callback */
|
922
|
930
|
conn->snd_una += acked;
|
923
|
|
- conn->tcp_op->acked ( conn, acked );
|
|
931
|
+ if ( conn->tcp_op->acked )
|
|
932
|
+ conn->tcp_op->acked ( conn, acked );
|
924
|
933
|
}
|
925
|
934
|
|
926
|
935
|
/**
|
|
@@ -931,8 +940,9 @@ static int tcp_rx ( struct pk_buff *pkb,
|
931
|
940
|
/* Check the sequence number */
|
932
|
941
|
if ( conn->rcv_nxt == ntohl ( tcphdr->seq ) ) {
|
933
|
942
|
conn->rcv_nxt += toack;
|
934
|
|
- conn->tcp_op->newdata ( conn,
|
935
|
|
- pkb->data + hlen, toack );
|
|
943
|
+ if ( conn->tcp_op->newdata )
|
|
944
|
+ conn->tcp_op->newdata ( conn, pkb->data + hlen,
|
|
945
|
+ toack );
|
936
|
946
|
} else {
|
937
|
947
|
DBG ( "Unexpected sequence number %lx (wanted %lx)\n",
|
938
|
948
|
ntohl ( tcphdr->ack ), conn->rcv_nxt );
|