[v5,2/3] net: add IPv6 extension header definitions
diff mbox series

Message ID 20181031021758.66752-3-doucette@bu.edu
State New
Delegated to: Thomas Monjalon
Headers show
Series
  • Extend rte_ipv6_frag_get_ipv6_fragment_header()
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Cody Doucette Oct. 31, 2018, 2:17 a.m. UTC
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 <doucette@bu.edu>
---
 lib/librte_net/rte_ip.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Thomas Monjalon Oct. 31, 2018, 5:03 p.m. UTC | #1
31/10/2018 03:17, Cody Doucette:
> 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 <doucette@bu.edu>

Olivier, is this patch OK?
Olivier Matz Nov. 5, 2018, 8:45 a.m. UTC | #2
On Wed, Oct 31, 2018 at 06:03:37PM +0100, Thomas Monjalon wrote:
> 31/10/2018 03:17, Cody Doucette:
> > 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 <doucette@bu.edu>
> 
> Olivier, is this patch OK?

Yes, thanks

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Patch
diff mbox series

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