conn->timer.expired = tcp_expired;
/* Send a SYN packet and transition to TCP_SYN_SENT */
- conn->snd_una = ( ( ( uint32_t ) random() ) << 16 ) & random();
+ conn->snd_una = random();
tcp_trans ( conn, TCP_SYN_SENT );
/* Allocate space for the packet */
free_pkb ( conn->tx_pkb );
switch ( conn->tcp_state ) {
case TCP_LISTEN:
tcp_trans ( conn, TCP_SYN_SENT );
- conn->snd_una = ( ( ( uint32_t ) random() ) << 16 ) & random();
+ conn->snd_una = random();
break;
case TCP_ESTABLISHED:
case TCP_CLOSE_WAIT:
conn->snd_win = tcphdr->win;
/* TCP State Machine */
- uint8_t out_flags = 0;
conn->tcp_lstate = conn->tcp_state;
switch ( conn->tcp_state ) {
case TCP_CLOSED:
tcp_trans ( conn, TCP_SYN_RCVD );
/* Synchronize the sequence numbers */
conn->rcv_nxt = ntohl ( tcphdr->seq ) + 1;
- out_flags |= TCP_ACK;
+ conn->tcp_flags |= TCP_ACK;
/* Set the sequence number for the snd stream */
- conn->snd_una = ( ( ( uint32_t ) random() ) << 16 );
- conn->snd_una &= random();
- out_flags |= TCP_SYN;
+ conn->snd_una = random();
+ conn->tcp_flags |= TCP_SYN;
/* Send a SYN,ACK packet */
goto send_tcp_nomsg;
if ( tcphdr->flags & TCP_SYN ) {
/* Synchronize the sequence number in rcv stream */
conn->rcv_nxt = ntohl ( tcphdr->seq ) + 1;
- out_flags |= TCP_ACK;
+ conn->tcp_flags |= TCP_ACK;
if ( tcphdr->flags & TCP_ACK ) {
tcp_trans ( conn, TCP_ESTABLISHED );
*/
conn->snd_una = ntohl ( tcphdr->ack );
conn->tcp_op->connected ( conn );
- out_flags |= TCP_ACK;
+ conn->tcp_flags |= TCP_ACK;
tcp_senddata ( conn );
return;
} else {
tcp_trans ( conn, TCP_SYN_RCVD );
- out_flags |= TCP_SYN;
+ conn->tcp_flags |= TCP_SYN;
goto send_tcp_nomsg;
}
}
tcp_trans ( conn, TCP_CLOSE_WAIT );
/* FIN consumes one byte */
conn->rcv_nxt++;
- out_flags |= TCP_ACK;
+ conn->tcp_flags |= TCP_ACK;
/* Send an acknowledgement */
goto send_tcp_nomsg;
}
case TCP_FIN_WAIT_1:
if ( tcphdr->flags & TCP_FIN ) {
conn->rcv_nxt++;
- out_flags |= TCP_ACK;
+ conn->tcp_flags |= TCP_ACK;
conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
if ( tcphdr->flags & TCP_ACK ) {
tcp_trans ( conn, TCP_TIME_WAIT );
/* FIN consumes one byte */
conn->rcv_nxt++;
- out_flags |= TCP_ACK;
+ conn->tcp_flags |= TCP_ACK;
goto send_tcp_nomsg;
}
/* Packet might contain data */
conn->tcp_op->newdata ( conn, pkb->data + hlen,
toack );
} else {
- DBG ( "Unexpected sequence number %ld (wanted %ld)\n",
+ DBG ( "Unexpected sequence number %lx (wanted %lx)\n",
ntohl ( tcphdr->seq ), conn->rcv_nxt );
}
/* Acknowledge new data */
- out_flags |= TCP_ACK;
+ conn->tcp_flags |= TCP_ACK;
if ( !( tcphdr->flags & TCP_ACK ) ) {
goto send_tcp_nomsg;
}
conn->tcp_op->closed ( conn, CONN_SNDCLOSE );
conn->rcv_nxt++;
if ( ! ( tcphdr->flags & TCP_ACK ) ) {
- out_flags |= TCP_ACK;
+ conn->tcp_flags |= TCP_ACK;
/* Send an acknowledgement */
goto send_tcp_nomsg;
}