diff mbox

[v2] helper: odph_tcp header description

Message ID 1417070065-27696-1-git-send-email-bala.manoharan@linaro.org
State New
Headers show

Commit Message

Balasubramanian Manoharan Nov. 27, 2014, 6:34 a.m. UTC
This patch adds TCP header description struct odph_tcphdr_t
This structure is used for accessing TCP header information from the packet

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
V2: Removes Bit Fields from Header struct
 helper/include/odph_tcp.h | 90 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)
 create mode 100644 helper/include/odph_tcp.h
diff mbox

Patch

diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
new file mode 100644
index 0000000..f625ac7
--- /dev/null
+++ b/helper/include/odph_tcp.h
@@ -0,0 +1,90 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP TCP header
+ */
+
+#ifndef ODPH_TCP_H_
+#define ODPH_TCP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_align.h>
+#include <odp_debug.h>
+#include <odp_byteorder.h>
+
+/** @internal TCP header flag FIN offset */
+#define ODPH_TCPHDR_FIN_OFFSET	0
+
+/** @internal TCP header flag SYN offset */
+#define ODPH_TCPHDR_SYN_OFFSET	1
+
+/** @internal TCP header flag RST offset */
+#define ODPH_TCPHDR_RST_OFFSET	2
+
+/** @internal TCP header flag PSH offset */
+#define ODPH_TCPHDR_PSH_OFFSET	3
+
+/** @internal TCP header flag ACK offset */
+#define ODPH_TCPHDR_ACK_OFFSET	4
+
+/** @internal TCP header flag URG offset */
+#define ODPH_TCPHDR_URG_OFFSET	5
+
+/** @internal TCP header flag ECE offset */
+#define ODPH_TCPHDR_ECE_OFFSET	6
+
+/** @internal TCP header flag CWR offset */
+#define ODPH_TCPHDR_CWR_OFFSET	7
+
+/** @internal Returns TCP header FIN flag */
+#define ODPH_TCPHDR_FLAGS_FIN(flags) ((flags) & (1 << ODPH_TCPHDR_FIN_OFFSET))
+
+/** @internal Returns TCP header SYN flag */
+#define ODPH_TCPHDR_FLAGS_SYN(flags) ((flags) & (1 << ODPH_TCPHDR_SYN_OFFSET))
+
+/** @internal Returns TCP header RST flag */
+#define ODPH_TCPHDR_FLAGS_RST(flags) ((flags) & (1 << ODPH_TCPHDR_RST_OFFSET))
+
+/** @internal Returns TCP header PSH flag */
+#define ODPH_TCPHDR_FLAGS_PSH(flags) ((flags) & (1 << ODPH_TCPHDR_PSH_OFFSET))
+
+/** @internal Returns TCP header ACK flag */
+#define ODPH_TCPHDR_FLAGS_ACK(flags) ((flags) & (1 << ODPH_TCPHDR_ACK_OFFSET))
+
+/** @internal Returns TCP header URG flag */
+#define ODPH_TCPHDR_FLAGS_URG(flags) ((flags) & (1 << ODPH_TCPHDR_URG_OFFSET))
+
+/** @internal Returns TCP header ECE flag */
+#define ODPH_TCPHDR_FLAGS_ECE(flags) ((flags) & (1 << ODPH_TCPHDR_ECE_OFFSET))
+
+/** @internal Returns TCP header CWR flag */
+#define ODPH_TCPHDR_FLAGS_CWR(flags) ((flags) & (1 << ODPH_TCPHDR_CWR_OFFSET))
+
+/** TCP header */
+typedef struct ODP_PACKED {
+	uint16be_t src_port; /**< Source port */
+	uint16be_t dst_port; /**< Destinatino port */
+	uint32be_t seq_no;   /**< Sequence number */
+	uint32be_t ack_no;   /**< Acknowledgment number */
+	uint8_t data_offset; /**< Data offset and reserved */
+	uint8_t flags;       /**< TCP flags as a byte */
+	uint16be_t window;   /**< Window size */
+	uint16be_t cksm;     /**< Checksum */
+	uint16be_t urgptr;   /**< Urgent pointer */
+} odph_tcphdr_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif