Browse Source

[tcp] Merge boolean flags into a single "flags" field

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
75505942ac
1 changed files with 15 additions and 8 deletions
  1. 15
    8
      src/net/tcp.c

+ 15
- 8
src/net/tcp.c View File

30
 	/** List of TCP connections */
30
 	/** List of TCP connections */
31
 	struct list_head list;
31
 	struct list_head list;
32
 
32
 
33
+	/** Flags */
34
+	unsigned int flags;
35
+
33
 	/** Data transfer interface */
36
 	/** Data transfer interface */
34
 	struct interface xfer;
37
 	struct interface xfer;
35
-	/** Data transfer interface closed flag */
36
-	int xfer_closed;
37
 
38
 
38
 	/** Remote socket address */
39
 	/** Remote socket address */
39
 	struct sockaddr_tcpip peer;
40
 	struct sockaddr_tcpip peer;
77
 	 * Equivalent to TS.Recent in RFC 1323 terminology.
78
 	 * Equivalent to TS.Recent in RFC 1323 terminology.
78
 	 */
79
 	 */
79
 	uint32_t ts_recent;
80
 	uint32_t ts_recent;
80
-	/** Timestamps enabled */
81
-	int timestamps;
82
 
81
 
83
 	/** Transmit queue */
82
 	/** Transmit queue */
84
 	struct list_head queue;
83
 	struct list_head queue;
88
 	struct retry_timer wait;
87
 	struct retry_timer wait;
89
 };
88
 };
90
 
89
 
90
+/** TCP flags */
91
+enum tcp_flags {
92
+	/** TCP data transfer interface has been closed */
93
+	TCP_XFER_CLOSED = 0x0001,
94
+	/** TCP timestamps are enabled */
95
+	TCP_TS_ENABLED = 0x0002,
96
+};
97
+
91
 /**
98
 /**
92
  * List of registered TCP connections
99
  * List of registered TCP connections
93
  */
100
  */
275
 
282
 
276
 	/* Close data transfer interface */
283
 	/* Close data transfer interface */
277
 	intf_shutdown ( &tcp->xfer, rc );
284
 	intf_shutdown ( &tcp->xfer, rc );
278
-	tcp->xfer_closed = 1;
285
+	tcp->flags |= TCP_XFER_CLOSED;
279
 
286
 
280
 	/* If we are in CLOSED, or have otherwise not yet received a
287
 	/* If we are in CLOSED, or have otherwise not yet received a
281
 	 * SYN (i.e. we are in LISTEN or SYN_SENT), just delete the
288
 	 * SYN (i.e. we are in LISTEN or SYN_SENT), just delete the
474
 		mssopt->length = sizeof ( *mssopt );
481
 		mssopt->length = sizeof ( *mssopt );
475
 		mssopt->mss = htons ( TCP_MSS );
482
 		mssopt->mss = htons ( TCP_MSS );
476
 	}
483
 	}
477
-	if ( ( flags & TCP_SYN ) || tcp->timestamps ) {
484
+	if ( ( flags & TCP_SYN ) || ( tcp->flags & TCP_TS_ENABLED ) ) {
478
 		tsopt = iob_push ( iobuf, sizeof ( *tsopt ) );
485
 		tsopt = iob_push ( iobuf, sizeof ( *tsopt ) );
479
 		memset ( tsopt->nop, TCP_OPTION_NOP, sizeof ( tsopt->nop ) );
486
 		memset ( tsopt->nop, TCP_OPTION_NOP, sizeof ( tsopt->nop ) );
480
 		tsopt->tsopt.kind = TCP_OPTION_TS;
487
 		tsopt->tsopt.kind = TCP_OPTION_TS;
719
 	if ( ! ( tcp->tcp_state & TCP_STATE_RCVD ( TCP_SYN ) ) ) {
726
 	if ( ! ( tcp->tcp_state & TCP_STATE_RCVD ( TCP_SYN ) ) ) {
720
 		tcp->rcv_ack = seq;
727
 		tcp->rcv_ack = seq;
721
 		if ( options->tsopt )
728
 		if ( options->tsopt )
722
-			tcp->timestamps = 1;
729
+			tcp->flags |= TCP_TS_ENABLED;
723
 	}
730
 	}
724
 
731
 
725
 	/* Ignore duplicate SYN */
732
 	/* Ignore duplicate SYN */
801
 		tcp->tcp_state |= TCP_STATE_ACKED ( acked_flags );
808
 		tcp->tcp_state |= TCP_STATE_ACKED ( acked_flags );
802
 
809
 
803
 	/* Start sending FIN if we've had all possible data ACKed */
810
 	/* Start sending FIN if we've had all possible data ACKed */
804
-	if ( list_empty ( &tcp->queue ) && tcp->xfer_closed )
811
+	if ( list_empty ( &tcp->queue ) && ( tcp->flags & TCP_XFER_CLOSED ) )
805
 		tcp->tcp_state |= TCP_STATE_SENT ( TCP_FIN );
812
 		tcp->tcp_state |= TCP_STATE_SENT ( TCP_FIN );
806
 
813
 
807
 	return 0;
814
 	return 0;

Loading…
Cancel
Save