*/
#include <stdint.h>
+#include <sys/types.h>
#include <netinet/in.h>
+#include <netinet/ip.h>
#include <rte_byteorder.h>
#include <rte_mbuf.h>
*/
#define RTE_IPV4_IHL_MULTIPLIER (4)
+/* Type of Service fields */
+#define RTE_IPV4_HDR_DSCP_MASK (0xfc)
+#define RTE_IPV4_HDR_ECN_MASK (0x03)
+#define RTE_IPV4_HDR_ECN_CE RTE_IPV4_HDR_ECN_MASK
+
/* Fragment Offset * Flags. */
#define RTE_IPV4_HDR_DF_SHIFT 14
#define RTE_IPV4_HDR_MF_SHIFT 13
((x) >= RTE_IPV4_MIN_MCAST && (x) <= RTE_IPV4_MAX_MCAST)
/**< check if IPv4 address is multicast */
+/* IPv4 default fields values */
+#define RTE_IPV4_MIN_IHL (0x5)
+#define RTE_IPV4_VHL_DEF (IPVERSION | RTE_IPV4_MIN_IHL)
+
/**
* @internal Calculate a sum of all words in the buffer.
* Helper routine for the rte_raw_cksum().
/* IPv6 vtc_flow: IPv / TC / flow_label */
#define RTE_IPV6_HDR_FL_SHIFT 0
#define RTE_IPV6_HDR_TC_SHIFT 20
-#define RTE_IPV6_HDR_FL_MASK ((1u << RTE_IPV6_HDR_TC_SHIFT) - 1)
-#define RTE_IPV6_HDR_TC_MASK (0xff << RTE_IPV6_HDR_TC_SHIFT)
+#define RTE_IPV6_HDR_FL_MASK ((1u << RTE_IPV6_HDR_TC_SHIFT) - 1)
+#define RTE_IPV6_HDR_TC_MASK (0xff << RTE_IPV6_HDR_TC_SHIFT)
+#define RTE_IPV6_HDR_DSCP_MASK (0xfc << RTE_IPV6_HDR_TC_SHIFT)
+#define RTE_IPV6_HDR_ECN_MASK (0x03 << RTE_IPV6_HDR_TC_SHIFT)
+#define RTE_IPV6_HDR_ECN_CE RTE_IPV6_HDR_ECN_MASK
/**
* Process the pseudo-header checksum of an IPv6 header.
return (uint16_t)cksum;
}
+/* IPv6 fragmentation header size */
+#define RTE_IPV6_FRAG_HDR_SIZE 8
+
+/**
+ * Parse next IPv6 header extension
+ *
+ * This function checks if proto number is an IPv6 extensions and parses its
+ * data if so, providing information on next header and extension length.
+ *
+ * @param p
+ * Pointer to an extension raw data.
+ * @param proto
+ * Protocol number extracted from the "next header" field from
+ * the IPv6 header or the previous extension.
+ * @param ext_len
+ * Extension data length.
+ * @return
+ * next protocol number if proto is an IPv6 extension, -EINVAL otherwise
+ */
+__rte_experimental
+static inline int
+rte_ipv6_get_next_ext(uint8_t *p, int proto, size_t *ext_len)
+{
+ int next_proto;
+
+ switch (proto) {
+ case IPPROTO_AH:
+ next_proto = *p++;
+ *ext_len = (*p + 2) * sizeof(uint32_t);
+ break;
+
+ case IPPROTO_HOPOPTS:
+ case IPPROTO_ROUTING:
+ case IPPROTO_DSTOPTS:
+ next_proto = *p++;
+ *ext_len = (*p + 1) * sizeof(uint64_t);
+ break;
+
+ case IPPROTO_FRAGMENT:
+ next_proto = *p;
+ *ext_len = RTE_IPV6_FRAG_HDR_SIZE;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return next_proto;
+}
+
#ifdef __cplusplus
}
#endif