From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay64.bu.edu (relay64.bu.edu [128.197.228.104]) by dpdk.org (Postfix) with ESMTP id 3C4F691 for ; Wed, 31 Oct 2018 03:18:46 +0100 (CET) X-Envelope-From: doucette@bu.edu X-BU-AUTH: xia1.bu.edu [128.197.41.97] Received: from BU-AUTH (localhost.localdomain [127.0.0.1]) (authenticated bits=0) by relay64.bu.edu (8.14.3/8.14.3) with ESMTP id w9V2I3mQ032189 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Tue, 30 Oct 2018 22:18:14 -0400 From: Cody Doucette To: Olivier Matz Cc: dev@dpdk.org, Cody Doucette Date: Wed, 31 Oct 2018 02:17:57 +0000 Message-Id: <20181031021758.66752-3-doucette@bu.edu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031021758.66752-1-doucette@bu.edu> References: <20181031021758.66752-1-doucette@bu.edu> Subject: [dpdk-dev] [PATCH v5 2/3] net: add IPv6 extension header definitions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2018 02:18:46 -0000 Add a common IPv6 extension header and an inline function for determining whether a next header field represents an IPv6 extension header. Signed-off-by: Cody Doucette --- lib/librte_net/rte_ip.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index f2a8904a2..43dbb15e4 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -350,6 +350,14 @@ struct ipv6_hdr { #define IPV6_HDR_FL_MASK ((1u << IPV6_HDR_TC_SHIFT) - 1) #define IPV6_HDR_TC_MASK (0xf << IPV6_HDR_TC_SHIFT) +/** + * IPv6 extension header + */ +struct ipv6_opt_hdr { + uint8_t nexthdr; /**< Next header. */ + uint8_t hdrlen; /**< Length; presence & meaning varies by ext type. */ +} __attribute__((packed)); + /** * Process the pseudo-header checksum of an IPv6 header. * @@ -421,6 +429,25 @@ rte_ipv6_udptcp_cksum(const struct ipv6_hdr *ipv6_hdr, const void *l4_hdr) return (uint16_t)cksum; } +/** + * Check whether an IPv6 nexthdr value is for an IPv6 extension header. + * + * @param nexthdr + * The protocol/next header field from an IPv6 (extension) header. + * @return + * Whether the nexthdr field is for an IPv6 extension header. + */ +static inline int +ipv6_ext_hdr(uint8_t nexthdr) +{ + return (nexthdr == IPPROTO_HOPOPTS) || + (nexthdr == IPPROTO_ROUTING) || + (nexthdr == IPPROTO_FRAGMENT) || + (nexthdr == IPPROTO_AH) || + (nexthdr == IPPROTO_NONE) || + (nexthdr == IPPROTO_DSTOPTS); +} + #ifdef __cplusplus } #endif -- 2.17.1