[gPXE-devel] [PATCHv3 6/7] [tcp] Port tcp sequence helper functions from Linux
cooldavid at cooldavid.org
cooldavid at cooldavid.org
Thu Jul 15 11:58:56 EDT 2010
From: Guo-Fu Tseng <cooldavid at cooldavid.org>
Signed-off-by: Guo-Fu Tseng <cooldavid at cooldavid.org>
---
src/include/gpxe/tcp.h | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/include/gpxe/tcp.h b/src/include/gpxe/tcp.h
index cb33713..94091b8 100644
--- a/src/include/gpxe/tcp.h
+++ b/src/include/gpxe/tcp.h
@@ -28,6 +28,26 @@ struct tcp_header {
uint16_t urg; /* Urgent pointer */
};
+/** @Sequence helper functions ported from Linux
+ * @{
+ */
+
+/*
+ * The next routines deal with comparing 32 bit unsigned ints
+ * and worry about wraparound (automatic with unsigned arithmetic).
+ */
+static inline int before ( uint32_t seq1, uint32_t seq2 ) {
+ return ( int32_t ) ( seq1 - seq2 ) < 0;
+}
+#define after(seq2,seq1) before(seq1,seq2)
+
+/* is s2<=s1<=s3 ? */
+static inline int between ( uint32_t seq1, uint32_t seq2, uint32_t seq3) {
+ return seq3 - seq2 >= seq1 - seq2;
+}
+
+/** @} */
+
/** @defgroup tcpopts TCP options
* @{
*/
--
1.7.1
More information about the gPXE-devel
mailing list