Avoid calling NULL methods!
This commit is contained in:
parent
89bcb57201
commit
3fbfbad0f7
|
@ -497,6 +497,7 @@ int tcp_close ( struct tcp_connection *conn ) {
|
||||||
case TCP_SYN_RCVD:
|
case TCP_SYN_RCVD:
|
||||||
case TCP_ESTABLISHED:
|
case TCP_ESTABLISHED:
|
||||||
tcp_trans ( conn, TCP_FIN_WAIT_1 );
|
tcp_trans ( conn, TCP_FIN_WAIT_1 );
|
||||||
|
if ( conn->tcp_op->closed )
|
||||||
conn->tcp_op->closed ( conn, CONN_SNDCLOSE ); /* TODO: Check! */
|
conn->tcp_op->closed ( conn, CONN_SNDCLOSE ); /* TODO: Check! */
|
||||||
/* FIN consumes one byte on the snd stream */
|
/* FIN consumes one byte on the snd stream */
|
||||||
// conn->snd_una++;
|
// conn->snd_una++;
|
||||||
|
@ -510,10 +511,12 @@ int tcp_close ( struct tcp_connection *conn ) {
|
||||||
*/
|
*/
|
||||||
list_del ( &conn->list );
|
list_del ( &conn->list );
|
||||||
tcp_trans ( conn, TCP_CLOSED );
|
tcp_trans ( conn, TCP_CLOSED );
|
||||||
|
if ( conn->tcp_op->closed )
|
||||||
conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
||||||
return 0;
|
return 0;
|
||||||
case TCP_CLOSE_WAIT:
|
case TCP_CLOSE_WAIT:
|
||||||
tcp_trans ( conn, TCP_LAST_ACK );
|
tcp_trans ( conn, TCP_LAST_ACK );
|
||||||
|
if ( conn->tcp_op->closed )
|
||||||
conn->tcp_op->closed ( conn, CONN_SNDCLOSE ); /* TODO: Check! */
|
conn->tcp_op->closed ( conn, CONN_SNDCLOSE ); /* TODO: Check! */
|
||||||
/* FIN consumes one byte on the snd stream */
|
/* FIN consumes one byte on the snd stream */
|
||||||
// conn->snd_una++;
|
// conn->snd_una++;
|
||||||
|
@ -630,6 +633,7 @@ int tcp_senddata ( struct tcp_connection *conn ) {
|
||||||
/* Set the advertised window */
|
/* Set the advertised window */
|
||||||
conn->rcv_win = pkb_available ( conn->tx_pkb );
|
conn->rcv_win = pkb_available ( conn->tx_pkb );
|
||||||
/* Call the senddata() call back function */
|
/* Call the senddata() call back function */
|
||||||
|
if ( conn->tcp_op->senddata )
|
||||||
conn->tcp_op->senddata ( conn, conn->tx_pkb->data,
|
conn->tcp_op->senddata ( conn, conn->tx_pkb->data,
|
||||||
pkb_available ( conn->tx_pkb ) );
|
pkb_available ( conn->tx_pkb ) );
|
||||||
/* Send pure ACK if senddata() didn't call tcp_send() */
|
/* Send pure ACK if senddata() didn't call tcp_send() */
|
||||||
|
@ -796,6 +800,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
||||||
* acked() callback function.
|
* acked() callback function.
|
||||||
*/
|
*/
|
||||||
conn->snd_una = ntohl ( tcphdr->ack );
|
conn->snd_una = ntohl ( tcphdr->ack );
|
||||||
|
if ( conn->tcp_op->connected )
|
||||||
conn->tcp_op->connected ( conn );
|
conn->tcp_op->connected ( conn );
|
||||||
conn->tcp_flags |= TCP_ACK;
|
conn->tcp_flags |= TCP_ACK;
|
||||||
tcp_senddata ( conn );
|
tcp_senddata ( conn );
|
||||||
|
@ -812,6 +817,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
||||||
case TCP_SYN_RCVD:
|
case TCP_SYN_RCVD:
|
||||||
if ( tcphdr->flags & TCP_RST ) {
|
if ( tcphdr->flags & TCP_RST ) {
|
||||||
tcp_trans ( conn, TCP_LISTEN );
|
tcp_trans ( conn, TCP_LISTEN );
|
||||||
|
if ( conn->tcp_op->closed )
|
||||||
conn->tcp_op->closed ( conn, CONN_RESTART );
|
conn->tcp_op->closed ( conn, CONN_RESTART );
|
||||||
rc = 0;
|
rc = 0;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -823,6 +829,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
||||||
* function nor does it send an ACK.
|
* function nor does it send an ACK.
|
||||||
*/
|
*/
|
||||||
conn->snd_una = tcphdr->ack - 1;
|
conn->snd_una = tcphdr->ack - 1;
|
||||||
|
if ( conn->tcp_op->connected )
|
||||||
conn->tcp_op->connected ( conn );
|
conn->tcp_op->connected ( conn );
|
||||||
rc = 0;
|
rc = 0;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -849,6 +856,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
||||||
if ( tcphdr->flags & TCP_FIN ) {
|
if ( tcphdr->flags & TCP_FIN ) {
|
||||||
conn->rcv_nxt++;
|
conn->rcv_nxt++;
|
||||||
conn->tcp_flags |= TCP_ACK;
|
conn->tcp_flags |= TCP_ACK;
|
||||||
|
if ( conn->tcp_op->closed )
|
||||||
conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
|
||||||
|
|
||||||
if ( tcphdr->flags & TCP_ACK ) {
|
if ( tcphdr->flags & TCP_ACK ) {
|
||||||
|
@ -920,6 +928,7 @@ static int tcp_rx ( struct pk_buff *pkb,
|
||||||
}
|
}
|
||||||
/* Invoke the acked() callback */
|
/* Invoke the acked() callback */
|
||||||
conn->snd_una += acked;
|
conn->snd_una += acked;
|
||||||
|
if ( conn->tcp_op->acked )
|
||||||
conn->tcp_op->acked ( conn, acked );
|
conn->tcp_op->acked ( conn, acked );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,8 +940,9 @@ static int tcp_rx ( struct pk_buff *pkb,
|
||||||
/* Check the sequence number */
|
/* Check the sequence number */
|
||||||
if ( conn->rcv_nxt == ntohl ( tcphdr->seq ) ) {
|
if ( conn->rcv_nxt == ntohl ( tcphdr->seq ) ) {
|
||||||
conn->rcv_nxt += toack;
|
conn->rcv_nxt += toack;
|
||||||
conn->tcp_op->newdata ( conn,
|
if ( conn->tcp_op->newdata )
|
||||||
pkb->data + hlen, toack );
|
conn->tcp_op->newdata ( conn, pkb->data + hlen,
|
||||||
|
toack );
|
||||||
} else {
|
} else {
|
||||||
DBG ( "Unexpected sequence number %lx (wanted %lx)\n",
|
DBG ( "Unexpected sequence number %lx (wanted %lx)\n",
|
||||||
ntohl ( tcphdr->ack ), conn->rcv_nxt );
|
ntohl ( tcphdr->ack ), conn->rcv_nxt );
|
||||||
|
|
Reference in New Issue