summaryrefslogtreecommitdiffstats
path: root/src/net/tcp.c
diff options
context:
space:
mode:
authorMichael Brown2010-07-15 20:15:36 +0200
committerMichael Brown2010-07-15 20:59:57 +0200
commit75505942acf44c5f130d1a047ad5a701a43d94a1 (patch)
tree7399a8c7d9398cd2b1fdec51cf9de0160dde8bb0 /src/net/tcp.c
parent[tcp] Use a dedicated timer for the TIME_WAIT state (diff)
downloadipxe-75505942acf44c5f130d1a047ad5a701a43d94a1.tar.gz
ipxe-75505942acf44c5f130d1a047ad5a701a43d94a1.tar.xz
ipxe-75505942acf44c5f130d1a047ad5a701a43d94a1.zip
[tcp] Merge boolean flags into a single "flags" field
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/tcp.c')
-rw-r--r--src/net/tcp.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/net/tcp.c b/src/net/tcp.c
index 67deac90..234e39a6 100644
--- a/src/net/tcp.c
+++ b/src/net/tcp.c
@@ -30,10 +30,11 @@ struct tcp_connection {
/** List of TCP connections */
struct list_head list;
+ /** Flags */
+ unsigned int flags;
+
/** Data transfer interface */
struct interface xfer;
- /** Data transfer interface closed flag */
- int xfer_closed;
/** Remote socket address */
struct sockaddr_tcpip peer;
@@ -77,8 +78,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;
@@ -88,6 +87,14 @@ struct tcp_connection {
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,
+};
+
/**
* List of registered TCP connections
*/
@@ -275,7 +282,7 @@ static void tcp_close ( struct tcp_connection *tcp, int rc ) {
/* Close data transfer interface */
intf_shutdown ( &tcp->xfer, rc );
- tcp->xfer_closed = 1;
+ tcp->flags |= TCP_XFER_CLOSED;
/* If we are in CLOSED, or have otherwise not yet received a
* SYN (i.e. we are in LISTEN or SYN_SENT), just delete the
@@ -474,7 +481,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;
@@ -719,7 +726,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 */
@@ -801,7 +808,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;