From: Michael Brown <[email protected]>

Signed-off-by: Michael Brown <[email protected]>
Merged-by: Guo-Fu Tseng <[email protected]>
Signed-off-by: Guo-Fu Tseng <[email protected]>
---
 src/net/tcp.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/net/tcp.c b/src/net/tcp.c
index ddd7397..b5f48c4 100644
--- a/src/net/tcp.c
+++ b/src/net/tcp.c
@@ -31,10 +31,11 @@ struct tcp_connection {
        /** List of TCP connections */
        struct list_head list;
 
+       /** Flags */
+       unsigned int flags;
+
        /** Data transfer interface */
        struct xfer_interface xfer;
-       /** Data transfer interface closed flag */
-       int xfer_closed;
 
        /** Remote socket address */
        struct sockaddr_tcpip peer;
@@ -89,8 +90,6 @@ struct tcp_connection {
         * Equivalent to TS.Recent in RFC 1323 terminology.
         */
        uint32_t ts_recent;
-       /** Timestamps enabled */
-       int timestamps;
 
        /** Transmit queue */
        struct list_head queue;
@@ -98,9 +97,16 @@ struct tcp_connection {
        struct retry_timer timer;
        /** Shutdown (TIME_WAIT) timer */
        struct retry_timer wait;
+};
 
+/** TCP flags */
+enum tcp_flags {
+       /** TCP data transfer interface has been closed */
+       TCP_XFER_CLOSED = 0x0001,
+       /** TCP timestamps are enabled */
+       TCP_TS_ENABLED  = 0x0002,
        /** Activity started **/
-       int act_started;
+       TCP_ACT_STARTED = 0x0004,
 };
 
 /**
@@ -154,15 +160,15 @@ tcp_dump_state ( struct tcp_connection *tcp ) {
                       tcp_state ( tcp->tcp_state ) );
 
                if ( TCP_CLOSE_INPROGRESS ( tcp->tcp_state ) &&
-                    ! tcp->act_started ) {
+                    ! ( tcp->flags & TCP_TS_ENABLED ) ) {
                        activity_start();
-                       tcp->act_started = 1;
+                       tcp->flags |= TCP_TS_ENABLED;
                }
 
                if ( TCP_CLOSED_GRACEFULLY( tcp->tcp_state ) &&
-                    tcp->act_started ) {
+                    ( tcp->flags & TCP_TS_ENABLED ) ) {
                        activity_stop();
-                       tcp->act_started = 0;
+                       tcp->flags &= ~TCP_TS_ENABLED;
                }
        }
        tcp->prev_tcp_state = tcp->tcp_state;
@@ -351,7 +357,7 @@ static void tcp_xfer_shutdown ( struct tcp_connection *tcp, 
int rc ) {
        /* Close data transfer interface */
        xfer_nullify ( &tcp->xfer );
        xfer_close ( &tcp->xfer, rc );
-       tcp->xfer_closed = 1;
+       tcp->flags |= TCP_XFER_CLOSED;
 }
 
 /***************************************************************************
@@ -518,7 +524,7 @@ static int tcp_xmit ( struct tcp_connection *tcp, int 
force_send ) {
                mssopt->length = sizeof ( *mssopt );
                mssopt->mss = htons ( TCP_MSS );
        }
-       if ( ( flags & TCP_SYN ) || tcp->timestamps ) {
+       if ( ( flags & TCP_SYN ) || ( tcp->flags & TCP_TS_ENABLED ) ) {
                tsopt = iob_push ( iobuf, sizeof ( *tsopt ) );
                memset ( tsopt->nop, TCP_OPTION_NOP, sizeof ( tsopt->nop ) );
                tsopt->tsopt.kind = TCP_OPTION_TS;
@@ -771,7 +777,7 @@ static int tcp_rx_syn ( struct tcp_connection *tcp, 
uint32_t seq,
        if ( ! ( tcp->tcp_state & TCP_STATE_RCVD ( TCP_SYN ) ) ) {
                tcp->rcv_ack = seq;
                if ( options->tsopt )
-                       tcp->timestamps = 1;
+                       tcp->flags |= TCP_TS_ENABLED;
        }
 
        /* Ignore duplicate SYN */
@@ -857,7 +863,7 @@ static int tcp_rx_ack ( struct tcp_connection *tcp, 
uint32_t ack,
                tcp->tcp_state |= TCP_STATE_ACKED ( acked_flags );
 
        /* Start sending FIN if we've had all possible data ACKed */
-       if ( list_empty ( &tcp->queue ) && tcp->xfer_closed )
+       if ( list_empty ( &tcp->queue ) && ( tcp->flags & TCP_XFER_CLOSED ) )
                tcp->tcp_state |= TCP_STATE_SENT ( TCP_FIN );
 
        return 0;
-- 
1.7.1

_______________________________________________
gPXE-devel mailing list
[email protected]
http://etherboot.org/mailman/listinfo/gpxe-devel

Reply via email to