Message ID | 1417838383-3215-1-git-send-email-bala.manoharan@linaro.org |
---|---|
State | New |
Headers | show |
On Fri, Dec 5, 2014 at 9:59 PM, Balasubramanian Manoharan < bala.manoharan@linaro.org> wrote: > Adds TCP header description struct odph_tcphdr_t in helper directory. > This structure is used for accessing TCP header information from the packet > > Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> > --- > helper/include/odph_tcp.h | 81 > ++++++++++++++++++++++ > platform/linux-generic/include/api/odp_byteorder.h | 7 ++ > 2 files changed, 88 insertions(+) > create mode 100644 helper/include/odph_tcp.h > > diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h > new file mode 100644 > index 0000000..7dbc0df > --- /dev/null > +++ b/helper/include/odph_tcp.h > @@ -0,0 +1,81 @@ > +/* 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> > + > +/** TCP header */ > +typedef struct ODP_PACKED { > + uint16be_t src_port; /**< Source port */ > + uint16be_t dst_port; /**< Destinatino port */ > Typo: s/Destinatino/Destination/ > + uint32be_t seq_no; /**< Sequence number */ > + uint32be_t ack_no; /**< Acknowledgment number */ > + union { > + uint16be_t doffset_flags; > +#if defined(ODP_BIG_ENDIAN_BITFIELD) > + struct { > + uint16be_t rsvd1:8; > + uint16be_t flags:8; /**< TCP flags as a byte */ > + }; > + struct { > + uint16be_t hl:4; /**< Hdr len, in words */ > + uint16be_t rsvd3:4; /**< Reserved */ > + uint16be_t cwr:1; > + uint16be_t ece:1; > + uint16be_t urg:1; > + uint16be_t ack:1; > + uint16be_t psh:1; > + uint16be_t rst:1; > + uint16be_t syn:1; > + uint16be_t fin:1; > + }; > +#elif defined(ODP_LITTLE_ENDIAN_BITFIELD) > + struct { > + uint16be_t flags:8; > + uint16be_t rsvd1:8; /**< TCP flags as a byte */ > + }; > + struct { > + uint16be_t rsvd3:4; /**< Reserved */ > + uint16be_t hl:4; /**< Hdr len, in words */ > + uint16be_t fin:1; > + uint16be_t syn:1; > + uint16be_t rst:1; > + uint16be_t psh:1; > + uint16be_t ack:1; > + uint16be_t urg:1; > + uint16be_t ece:1; > + uint16be_t cwr:1; > + }; > + > +#else > +#error "Endian BitField order not defined!" > +#endif > + }; > + uint16be_t window; /**< Window size */ > + uint16be_t cksm; /**< Checksum */ > + uint16be_t urgptr; /**< Urgent pointer */ > +} odph_tcphdr_t; > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif > diff --git a/platform/linux-generic/include/api/odp_byteorder.h > b/platform/linux-generic/include/api/odp_byteorder.h > index 79ddd75..5d7cceb 100644 > --- a/platform/linux-generic/include/api/odp_byteorder.h > +++ b/platform/linux-generic/include/api/odp_byteorder.h > @@ -19,6 +19,7 @@ extern "C" { > #endif > > #include <endian.h> > +#include <asm/byteorder.h> > #include <odp_std_types.h> > #include <odp_compiler.h> > > @@ -45,6 +46,12 @@ extern "C" { > /** Little endian byte order */ > #define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN > > +/** Big endian bit field */ > +#define ODP_BIG_ENDIAN_BITFIELD __BIG_ENDIAN_BITFIELD > + > +/** Little endian bit field */ > +#define ODP_LITTLE_ENDIAN_BITFIELD __LITTLE_ENDIAN_BITFIELD > + > /** Selected byte order */ > #if __BYTE_ORDER == __LITTLE_ENDIAN > #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN > -- > 2.0.1.472.g6f92e5f > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h new file mode 100644 index 0000000..7dbc0df --- /dev/null +++ b/helper/include/odph_tcp.h @@ -0,0 +1,81 @@ +/* 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> + +/** 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 */ + union { + uint16be_t doffset_flags; +#if defined(ODP_BIG_ENDIAN_BITFIELD) + struct { + uint16be_t rsvd1:8; + uint16be_t flags:8; /**< TCP flags as a byte */ + }; + struct { + uint16be_t hl:4; /**< Hdr len, in words */ + uint16be_t rsvd3:4; /**< Reserved */ + uint16be_t cwr:1; + uint16be_t ece:1; + uint16be_t urg:1; + uint16be_t ack:1; + uint16be_t psh:1; + uint16be_t rst:1; + uint16be_t syn:1; + uint16be_t fin:1; + }; +#elif defined(ODP_LITTLE_ENDIAN_BITFIELD) + struct { + uint16be_t flags:8; + uint16be_t rsvd1:8; /**< TCP flags as a byte */ + }; + struct { + uint16be_t rsvd3:4; /**< Reserved */ + uint16be_t hl:4; /**< Hdr len, in words */ + uint16be_t fin:1; + uint16be_t syn:1; + uint16be_t rst:1; + uint16be_t psh:1; + uint16be_t ack:1; + uint16be_t urg:1; + uint16be_t ece:1; + uint16be_t cwr:1; + }; + +#else +#error "Endian BitField order not defined!" +#endif + }; + uint16be_t window; /**< Window size */ + uint16be_t cksm; /**< Checksum */ + uint16be_t urgptr; /**< Urgent pointer */ +} odph_tcphdr_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/api/odp_byteorder.h b/platform/linux-generic/include/api/odp_byteorder.h index 79ddd75..5d7cceb 100644 --- a/platform/linux-generic/include/api/odp_byteorder.h +++ b/platform/linux-generic/include/api/odp_byteorder.h @@ -19,6 +19,7 @@ extern "C" { #endif #include <endian.h> +#include <asm/byteorder.h> #include <odp_std_types.h> #include <odp_compiler.h> @@ -45,6 +46,12 @@ extern "C" { /** Little endian byte order */ #define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN +/** Big endian bit field */ +#define ODP_BIG_ENDIAN_BITFIELD __BIG_ENDIAN_BITFIELD + +/** Little endian bit field */ +#define ODP_LITTLE_ENDIAN_BITFIELD __LITTLE_ENDIAN_BITFIELD + /** Selected byte order */ #if __BYTE_ORDER == __LITTLE_ENDIAN #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN
Adds TCP header description struct odph_tcphdr_t in helper directory. This structure is used for accessing TCP header information from the packet Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> --- helper/include/odph_tcp.h | 81 ++++++++++++++++++++++ platform/linux-generic/include/api/odp_byteorder.h | 7 ++ 2 files changed, 88 insertions(+) create mode 100644 helper/include/odph_tcp.h