From patchwork Wed Feb 1 13:14:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 93025 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2313150obz; Wed, 1 Feb 2017 05:16:21 -0800 (PST) X-Received: by 10.55.135.1 with SMTP id j1mr2784112qkd.107.1485954981446; Wed, 01 Feb 2017 05:16:21 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p102si14396358qkp.108.2017.02.01.05.16.21; Wed, 01 Feb 2017 05:16:21 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 18F1F607C6; Wed, 1 Feb 2017 13:16:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 04BBB62D30; Wed, 1 Feb 2017 13:14:40 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A1E4162D18; Wed, 1 Feb 2017 13:14:20 +0000 (UTC) Received: from mail-qt0-f169.google.com (mail-qt0-f169.google.com [209.85.216.169]) by lists.linaro.org (Postfix) with ESMTPS id 3723762CDE for ; Wed, 1 Feb 2017 13:14:15 +0000 (UTC) Received: by mail-qt0-f169.google.com with SMTP id x49so262214043qtc.2 for ; Wed, 01 Feb 2017 05:14:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fhrSz/f6xo7TPgX5aPE28Fxy91blYIylNw1khuLU258=; b=BKSv4AbncbVuNZ4mAwBTeOFcuBgHgCBRcZHb9cLWdI96ztRMYtECxQ+SSw8pmXFC7x ffSiQqqlTLW+OnreN1bQZhdxaas35dWWDC/MH8cl/BfIn8cSWHw7RVbWuJP2YtiqVm38 dqn+8+cJOF7s+BZ9NTUsQr8eldYR2iMhvTHA5eYK0B3E48FUORD7zjKiErtm9pBIRPNz JkK77LsjQXxwYK31eIQynRew3cPvcR0TpDkM+TDnqC5WHalTJfwyVpqpU09Lvknck/tK qjo/O9gG9BWN2CpLRc2rF2zysGXM0vx/NUorryhilTH6ubE5u8X0htDj9KkfuZhb+uyh gUeQ== X-Gm-Message-State: AIkVDXLjSGpNqMyQ1SC6wCrn8epv74tI928jRwUShIbXpqxrtpCk1XEqExTwmdJtn3sY1Fo98xs= X-Received: by 10.200.32.146 with SMTP id 18mr2509296qtd.149.1485954854534; Wed, 01 Feb 2017 05:14:14 -0800 (PST) Received: from localhost (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by smtp.gmail.com with ESMTPSA id k18sm18498682qtc.12.2017.02.01.05.14.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Feb 2017 05:14:13 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 1 Feb 2017 08:14:05 -0500 Message-Id: <20170201131409.26631-2-mike.holmes@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201131409.26631-1-mike.holmes@linaro.org> References: <20170201131409.26631-1-mike.holmes@linaro.org> Subject: [lng-odp] [PATCH 1/5] helper: split out types X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Mike Holmes --- helper/Makefile.am | 5 +- helper/include/odp/helper/chksum.h | 13 +-- helper/include/odp/helper/chksum_types.h | 45 +++++++++ helper/include/odp/helper/ip.h | 136 +------------------------ helper/include/odp/helper/ip_types.h | 168 +++++++++++++++++++++++++++++++ helper/include/odp/helper/udp.h | 17 +--- helper/include/odp/helper/udp_types.h | 50 +++++++++ 7 files changed, 270 insertions(+), 164 deletions(-) create mode 100644 helper/include/odp/helper/chksum_types.h create mode 100644 helper/include/odp/helper/ip_types.h create mode 100644 helper/include/odp/helper/udp_types.h -- 2.9.3 diff --git a/helper/Makefile.am b/helper/Makefile.am index d484679..b77a928 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -15,9 +15,11 @@ AM_LDFLAGS += -version-number '$(ODPHELPER_LIBSO_VERSION)' helperincludedir = $(includedir)/odp/helper/ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/chksum.h\ + $(srcdir)/include/odp/helper/chksum_types.h\ $(srcdir)/include/odp/helper/eth.h\ $(srcdir)/include/odp/helper/icmp.h\ $(srcdir)/include/odp/helper/ip.h\ + $(srcdir)/include/odp/helper/ip_types.h\ $(srcdir)/include/odp/helper/ipsec.h\ $(srcdir)/include/odp/helper/odph_api.h\ $(srcdir)/include/odp/helper/odph_cuckootable.h\ @@ -28,7 +30,8 @@ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/tcp.h\ $(srcdir)/include/odp/helper/table.h\ $(srcdir)/include/odp/helper/threads.h \ - $(srcdir)/include/odp/helper/udp.h + $(srcdir)/include/odp/helper/udp.h \ + $(srcdir)/include/odp/helper/udp_types.h if helper_extn helperinclude_HEADERS += \ diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 520e927..94c9305 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -17,24 +17,13 @@ extern "C" { #endif #include +#include /** @addtogroup odph_chksum ODPH CHECK SUM * @{ */ /** - * Chksum Operation Code - * - * This enumeration type is used to tell odph_udp_tcp_chksum what to do once - * it has calculated the TCP/UDP check sum. - */ -typedef enum { - ODPH_CHKSUM_GENERATE, /**< Set TCP/UDP header chksum field */ - ODPH_CHKSUM_VERIFY, /**< See if TCP/UDP header chksum is correct */ - ODPH_CHKSUM_RETURN /**< Don't generate or verify chksum */ -} odph_chksum_op_t; - -/** * Checksum * * @param buffer calculate chksum for buffer diff --git a/helper/include/odp/helper/chksum_types.h b/helper/include/odp/helper/chksum_types.h new file mode 100644 index 0000000..b01d9cc --- /dev/null +++ b/helper/include/odp/helper/chksum_types.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP checksum helper + */ +#ifndef ODPH_CHKSUM_TYPES_H_ +#define ODPH_CHKSUM_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @addtogroup odph_chksum ODPH CHECK SUM + * @{ + */ + +/** + * Chksum Operation Code + * + * This enumeration type is used to tell odph_udp_tcp_chksum what to do once + * it has calculated the TCP/UDP check sum. + */ +typedef enum { + ODPH_CHKSUM_GENERATE, /**< Set TCP/UDP header chksum field */ + ODPH_CHKSUM_VERIFY, /**< See if TCP/UDP header chksum is correct */ + ODPH_CHKSUM_RETURN /**< Don't generate or verify chksum */ +} odph_chksum_op_t; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index ba6e675..08af794 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -18,6 +18,7 @@ extern "C" { #endif #include +#include #include #include @@ -26,72 +27,6 @@ extern "C" { * @{ */ -#define ODPH_IPV4 4 /**< IP version 4 */ -#define ODPH_IPV4HDR_LEN 20 /**< Min length of IP header (no options) */ -#define ODPH_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ -#define ODPH_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ - -/** The one byte IPv4 tos or IPv6 tc field is composed of the following two - * subfields - a six bit Differentiated Service Code Point (DSCP) and a two - * bit Explicit Congestion Notification (ECN) subfield. The following - * constants can be used to extract or modify these fields. Despite the - * name prefix being ODPH_IP_TOS_* these constants apply equally well for - * the IPv6 Traffic Class (tc) field. - */ -#define ODPH_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value 63 */ -#define ODPH_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ -#define ODPH_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by 2 */ -#define ODPH_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value 3 */ -#define ODPH_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ -#define ODPH_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ - -/** The following constants give names to the four possible ECN values, - * as described in RFC 3168. - */ -#define ODPH_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN */ -#define ODPH_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ -#define ODPH_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ -#define ODPH_IP_ECN_CE 3 /**< Used to signal Congestion Experienced */ - -/** @internal Returns IPv4 version */ -#define ODPH_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) - -/** @internal Returns IPv4 header length */ -#define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) - -/** @internal Returns IPv4 DSCP */ -#define ODPH_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) - -/** @internal Returns IPv4 Don't fragment */ -#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & 0x4000) - -/** @internal Returns IPv4 more fragments */ -#define ODPH_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & 0x2000) - -/** @internal Returns IPv4 fragment offset */ -#define ODPH_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) - -/** @internal Returns true if IPv4 packet is a fragment */ -#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) - -/** IPv4 header */ -typedef struct ODP_PACKED { - uint8_t ver_ihl; /**< Version / Header length */ - uint8_t tos; /**< Type of service */ - odp_u16be_t tot_len; /**< Total length */ - odp_u16be_t id; /**< ID */ - odp_u16be_t frag_offset;/**< Fragmentation offset */ - uint8_t ttl; /**< Time to live */ - uint8_t proto; /**< Protocol */ - odp_u16sum_t chksum; /**< Checksum */ - odp_u32be_t src_addr; /**< Source address */ - odp_u32be_t dst_addr; /**< Destination address */ -} odph_ipv4hdr_t; - -/** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, - "ODPH_IPV4HDR_T__SIZE_ERROR"); - /** * Check if IPv4 checksum is valid * @@ -147,75 +82,6 @@ static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) return ip->chksum; } -/** IPv6 version */ -#define ODPH_IPV6 6 - -/** IPv6 header length */ -#define ODPH_IPV6HDR_LEN 40 - -/** IPv6 address length in bytes */ -#define ODPH_IPV6ADDR_LEN 16 - -/** The following constants can be used to access the three subfields - * of the 4 byte ver_tc_flow field - namely the four bit Version subfield, - * the eight bit Traffic Class subfield (TC) and the twenty bit Flow Label - * subfield. Note that the IPv6 TC field is analogous to the IPv4 TOS - * field and is composed of the DSCP and ECN subfields. Use the ODPH_IP_TOS_* - * constants above to access these subfields. - */ -#define ODPH_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit mask */ -#define ODPH_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift */ -#define ODPH_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ -#define ODPH_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ -#define ODPH_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask */ -#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ - -/** @internal Returns IPv6 DSCP */ -#define ODPH_IPV6HDR_DSCP(ver_tc_flow) \ - (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) - -/** - * IPv6 header - */ -typedef struct ODP_PACKED { - odp_u32be_t ver_tc_flow; /**< Version / Traffic class / Flow label */ - odp_u16be_t payload_len; /**< Payload length */ - uint8_t next_hdr; /**< Next header */ - uint8_t hop_limit; /**< Hop limit */ - uint8_t src_addr[16]; /**< Source address */ - uint8_t dst_addr[16]; /**< Destination address */ -} odph_ipv6hdr_t; - -/** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, - "ODPH_IPV6HDR_T__SIZE_ERROR"); - -/** - * IPv6 Header extensions - */ -typedef struct ODP_PACKED { - uint8_t next_hdr; /**< Protocol of next header */ - uint8_t ext_len; /**< Length of this extension in 8 byte units, - not counting first 8 bytes, so 0 = 8 bytes - 1 = 16 bytes, etc. */ - uint8_t filler[6]; /**< Fill out first 8 byte segment */ -} odph_ipv6hdr_ext_t; - -/** @name - * IP protocol values (IPv4:'proto' or IPv6:'next_hdr') - * @{*/ -#define ODPH_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */ -#define ODPH_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol (1) */ -#define ODPH_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */ -#define ODPH_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */ -#define ODPH_IPPROTO_ROUTE 0x2B /**< IPv6 Routing header (43) */ -#define ODPH_IPPROTO_FRAG 0x2C /**< IPv6 Fragment (44) */ -#define ODPH_IPPROTO_AH 0x33 /**< Authentication Header (51) */ -#define ODPH_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */ -#define ODPH_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */ - -/**@}*/ - /** * Parse IPv4 address from a string * diff --git a/helper/include/odp/helper/ip_types.h b/helper/include/odp/helper/ip_types.h new file mode 100644 index 0000000..39c50c0 --- /dev/null +++ b/helper/include/odp/helper/ip_types.h @@ -0,0 +1,168 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP IP header + */ + +#ifndef ODPH_IP_TYPES_H_ +#define ODPH_IP_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @addtogroup odph_header ODPH HEADER + * @{ + */ + +#define ODPH_IPV4 4 /**< IP version 4 */ +#define ODPH_IPV4HDR_LEN 20 /**< Min length of IP header (no options) */ +#define ODPH_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ +#define ODPH_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ + +/** The one byte IPv4 tos or IPv6 tc field is composed of the following two + * subfields - a six bit Differentiated Service Code Point (DSCP) and a two + * bit Explicit Congestion Notification (ECN) subfield. The following + * constants can be used to extract or modify these fields. Despite the + * name prefix being ODPH_IP_TOS_* these constants apply equally well for + * the IPv6 Traffic Class (tc) field. + */ +#define ODPH_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value 63 */ +#define ODPH_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ +#define ODPH_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by 2 */ +#define ODPH_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value 3 */ +#define ODPH_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ +#define ODPH_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ + +/** The following constants give names to the four possible ECN values, + * as described in RFC 3168. + */ +#define ODPH_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN */ +#define ODPH_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ +#define ODPH_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ +#define ODPH_IP_ECN_CE 3 /**< Used to signal Congestion Experienced */ + +/** @internal Returns IPv4 version */ +#define ODPH_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) + +/** @internal Returns IPv4 header length */ +#define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) + +/** @internal Returns IPv4 DSCP */ +#define ODPH_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) + +/** @internal Returns IPv4 Don't fragment */ +#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & 0x4000) + +/** @internal Returns IPv4 more fragments */ +#define ODPH_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & 0x2000) + +/** @internal Returns IPv4 fragment offset */ +#define ODPH_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) + +/** @internal Returns true if IPv4 packet is a fragment */ +#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) + +/** IPv4 header */ +typedef struct ODP_PACKED { + uint8_t ver_ihl; /**< Version / Header length */ + uint8_t tos; /**< Type of service */ + odp_u16be_t tot_len; /**< Total length */ + odp_u16be_t id; /**< ID */ + odp_u16be_t frag_offset;/**< Fragmentation offset */ + uint8_t ttl; /**< Time to live */ + uint8_t proto; /**< Protocol */ + odp_u16sum_t chksum; /**< Checksum */ + odp_u32be_t src_addr; /**< Source address */ + odp_u32be_t dst_addr; /**< Destination address */ +} odph_ipv4hdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, + "ODPH_IPV4HDR_T__SIZE_ERROR"); + +/** IPv6 version */ +#define ODPH_IPV6 6 + +/** IPv6 header length */ +#define ODPH_IPV6HDR_LEN 40 + +/** IPv6 address length in bytes */ +#define ODPH_IPV6ADDR_LEN 16 + +/** The following constants can be used to access the three subfields + * of the 4 byte ver_tc_flow field - namely the four bit Version subfield, + * the eight bit Traffic Class subfield (TC) and the twenty bit Flow Label + * subfield. Note that the IPv6 TC field is analogous to the IPv4 TOS + * field and is composed of the DSCP and ECN subfields. Use the ODPH_IP_TOS_* + * constants above to access these subfields. + */ +#define ODPH_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit mask */ +#define ODPH_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift */ +#define ODPH_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ +#define ODPH_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ +#define ODPH_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask */ +#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ + +/** @internal Returns IPv6 DSCP */ +#define ODPH_IPV6HDR_DSCP(ver_tc_flow) \ + (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) + +/** + * IPv6 header + */ +typedef struct ODP_PACKED { + odp_u32be_t ver_tc_flow; /**< Version / Traffic class / Flow label */ + odp_u16be_t payload_len; /**< Payload length */ + uint8_t next_hdr; /**< Next header */ + uint8_t hop_limit; /**< Hop limit */ + uint8_t src_addr[16]; /**< Source address */ + uint8_t dst_addr[16]; /**< Destination address */ +} odph_ipv6hdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, + "ODPH_IPV6HDR_T__SIZE_ERROR"); + +/** + * IPv6 Header extensions + */ +typedef struct ODP_PACKED { + uint8_t next_hdr; /**< Protocol of next header */ + uint8_t ext_len; /**< Length of this extension in 8 byte units, + not counting first 8 bytes, so 0 = 8 bytes + 1 = 16 bytes, etc. */ + uint8_t filler[6]; /**< Fill out first 8 byte segment */ +} odph_ipv6hdr_ext_t; + +/** @name + * IP protocol values (IPv4:'proto' or IPv6:'next_hdr') + * @{*/ +#define ODPH_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */ +#define ODPH_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol (1) */ +#define ODPH_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */ +#define ODPH_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */ +#define ODPH_IPPROTO_ROUTE 0x2B /**< IPv6 Routing header (43) */ +#define ODPH_IPPROTO_FRAG 0x2C /**< IPv6 Fragment (44) */ +#define ODPH_IPPROTO_AH 0x33 /**< Authentication Header (51) */ +#define ODPH_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */ +#define ODPH_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */ + +/**@}*/ + +/** + * @} + */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/include/odp/helper/udp.h b/helper/include/odp/helper/udp.h index 1ba2dff..e1661de 100644 --- a/helper/include/odp/helper/udp.h +++ b/helper/include/odp/helper/udp.h @@ -18,23 +18,12 @@ extern "C" { #endif #include -#include +#include /** @addtogroup odph_header ODPH HEADER * @{ */ -/** UDP header length */ -#define ODPH_UDPHDR_LEN 8 - -/** UDP header */ -typedef struct ODP_PACKED { - odp_u16be_t src_port; /**< Source port */ - odp_u16be_t dst_port; /**< Destination port */ - odp_u16be_t length; /**< UDP datagram length in bytes (header+data) */ - odp_u16be_t chksum; /**< UDP header and data checksum (0 if not used)*/ -} odph_udphdr_t; - /** * UDP checksum * @@ -52,10 +41,6 @@ static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt) return (rc == 0) ? chksum : 0; } -/** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN, - "ODPH_UDPHDR_T__SIZE_ERROR"); - /** * @} */ diff --git a/helper/include/odp/helper/udp_types.h b/helper/include/odp/helper/udp_types.h new file mode 100644 index 0000000..aa6703a --- /dev/null +++ b/helper/include/odp/helper/udp_types.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP UDP header + */ + +#ifndef ODPH_UDP_TYPES_H_ +#define ODPH_UDP_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** @addtogroup odph_header ODPH HEADER + * @{ + */ + +/** UDP header length */ +#define ODPH_UDPHDR_LEN 8 + +/** UDP header */ +typedef struct ODP_PACKED { + odp_u16be_t src_port; /**< Source port */ + odp_u16be_t dst_port; /**< Destination port */ + odp_u16be_t length; /**< UDP datagram length in bytes (header+data) */ + odp_u16be_t chksum; /**< UDP header and data checksum (0 if not used)*/ +} odph_udphdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN, + "ODPH_UDPHDR_T__SIZE_ERROR"); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif