aboutsummaryrefslogtreecommitdiff
path: root/helper/include/odp/helper/tcp.h
blob: 8a14efa15470c6fabe31c646e20b6a22f8b33283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright (c) 2014-2018 Linaro Limited
 */


/**
 * @file
 *
 * ODP TCP header
 */

#ifndef ODPH_TCP_H_
#define ODPH_TCP_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <odp_api.h>

/**
 * @addtogroup odph_protocols
 * @{
 */

#define ODPH_TCPHDR_LEN 20 /**< Min length of TCP header (no options) */

/** TCP header */
typedef struct ODP_PACKED {
	odp_u16be_t src_port; /**< Source port */
	odp_u16be_t dst_port; /**< Destination port */
	odp_u32be_t seq_no;   /**< Sequence number */
	odp_u32be_t ack_no;   /**< Acknowledgment number */
	/** Variant maps for TCP header fields */
	union {
		odp_u16be_t doffset_flags; /**< TCP Flags aggregate */
#if ODP_BIG_ENDIAN_BITFIELD
		struct {
			odp_u16be_t rsvd1:8;
			odp_u16be_t flags:8; /**< TCP flags as a byte */
		};
		struct {
			odp_u16be_t hl:4;    /**< Hdr len, in words */
			odp_u16be_t rsvd3:4; /**< Reserved */
			odp_u16be_t cwr:1;   /**< cwr bit */
			odp_u16be_t ece:1;   /**< ece bit */
			odp_u16be_t urg:1;   /**< urg bit */
			odp_u16be_t ack:1;   /**< ack bit */
			odp_u16be_t psh:1;   /**< psh bit */
			odp_u16be_t rst:1;   /**< rst bit */
			odp_u16be_t syn:1;   /**< syn bit */
			odp_u16be_t fin:1;   /**< fin bit */
		};
#elif ODP_LITTLE_ENDIAN_BITFIELD
		struct {
			odp_u16be_t flags:8;
			odp_u16be_t rsvd1:8; /**< TCP flags as a byte */
		};
		struct {
			odp_u16be_t rsvd3:4; /**< Reserved */
			odp_u16be_t hl:4;    /**< Hdr len, in words */
			odp_u16be_t fin:1;   /**< fin bit */
			odp_u16be_t syn:1;   /**< syn bit */
			odp_u16be_t rst:1;   /**< rst bit */
			odp_u16be_t psh:1;   /**< psh bit */
			odp_u16be_t ack:1;   /**< ack bit */
			odp_u16be_t urg:1;   /**< urg bit */
			odp_u16be_t ece:1;   /**< ece bit */
			odp_u16be_t cwr:1;   /**< cwr bit */
		};

#else
#error "Endian BitField order not defined!"
#endif
	};
	odp_u16be_t window; /**< Window size */
	odp_u16be_t cksm;   /**< Checksum */
	odp_u16be_t urgptr; /**< Urgent pointer */
} odph_tcphdr_t;

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif