diff mbox series

[API-NEXT,v5,1/7] api: packet: add protocol type enumeration

Message ID 1517410819-24732-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v5,1/7] api: packet: add protocol type enumeration | expand

Commit Message

Github ODP bot Jan. 31, 2018, 3 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Add enumerations for L3 and L4 protocol types, and functions
to request those.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 403 (psavol:next-ipsec-tfc)
 ** https://github.com/Linaro/odp/pull/403
 ** Patch: https://github.com/Linaro/odp/pull/403.patch
 ** Base sha: 5718327018debbb02aacb464493504c95fbe57a3
 ** Merge commit sha: a8d85f63d9e1de7ba709e84b37a06e3482bdea1d
 **/
 include/odp/api/abi-default/packet.h               | 28 +++++++
 include/odp/api/spec/packet.h                      | 95 ++++++++++++++++++++++
 .../linux-generic/include-abi/odp/api/abi/packet.h | 28 +++++++
 3 files changed, 151 insertions(+)
diff mbox series

Patch

diff --git a/include/odp/api/abi-default/packet.h b/include/odp/api/abi-default/packet.h
index 3d6876731..b83288d4c 100644
--- a/include/odp/api/abi-default/packet.h
+++ b/include/odp/api/abi-default/packet.h
@@ -30,6 +30,34 @@  typedef _odp_abi_packet_seg_t *odp_packet_seg_t;
 #define ODP_PACKET_SEG_INVALID    ((odp_packet_seg_t)0xffffffff)
 #define ODP_PACKET_OFFSET_INVALID 0xffff
 
+typedef uint8_t odp_proto_l3_type_t;
+
+#define ODP_PROTO_L3_TYPE_NONE   0
+#define ODP_PROTO_L3_TYPE_ARP    1
+#define ODP_PROTO_L3_TYPE_RARP   2
+#define ODP_PROTO_L3_TYPE_MPLS   3
+#define ODP_PROTO_L3_TYPE_IPV4   4
+#define ODP_PROTO_L3_TYPE_IPV6   6
+
+typedef uint8_t odp_proto_l4_type_t;
+
+/* Numbers from IANA Assigned Internet Protocol Numbers list */
+#define ODP_PROTO_L4_TYPE_NONE      0
+#define ODP_PROTO_L4_TYPE_ICMPV4    1
+#define ODP_PROTO_L4_TYPE_IGMP      2
+#define ODP_PROTO_L4_TYPE_IPV4      4
+#define ODP_PROTO_L4_TYPE_TCP       6
+#define ODP_PROTO_L4_TYPE_UDP       17
+#define ODP_PROTO_L4_TYPE_IPV6      41
+#define ODP_PROTO_L4_TYPE_GRE       47
+#define ODP_PROTO_L4_TYPE_ESP       50
+#define ODP_PROTO_L4_TYPE_AH        51
+#define ODP_PROTO_L4_TYPE_ICMPV6    58
+#define ODP_PROTO_L4_TYPE_NO_NEXT   59
+#define ODP_PROTO_L4_TYPE_IPCOMP    108
+#define ODP_PROTO_L4_TYPE_SCTP      132
+#define ODP_PROTO_L4_TYPE_ROHC      142
+
 typedef enum {
 	ODP_PACKET_GREEN = 0,
 	ODP_PACKET_YELLOW = 1,
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 3222ff5c2..4be515c7b 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -71,6 +71,79 @@  extern "C" {
   * Packet is red
   */
 
+/**
+ * @typedef odp_proto_l3_type_t
+ * Layer 3 protocol type
+ */
+
+/**
+ * @def ODP_PROTO_L3_TYPE_NONE
+ * Layer 3 protocol type not defined
+ *
+ * @def ODP_PROTO_L3_TYPE_ARP
+ * Layer 3 protocol is ARP
+ *
+ * @def ODP_PROTO_L3_TYPE_RARP
+ * Layer 3 protocol is RARP
+ *
+ * @def ODP_PROTO_L3_TYPE_MPLS
+ * Layer 3 protocol is MPLS
+ *
+ * @def ODP_PROTO_L3_TYPE_IPV4
+ * Layer 3 protocol type is IPv4
+ *
+ * @def ODP_PROTO_L3_TYPE_IPV6
+ * Layer 3 protocol type is IPv6
+ */
+
+/**
+ * @def ODP_PROTO_L4_TYPE_NONE
+ * Layer 4 protocol type not defined
+ *
+ * @def ODP_PROTO_L4_TYPE_ICMPV4
+ * Layer 4 protocol type is ICMPv4
+ *
+ * @def ODP_PROTO_L4_TYPE_IGMP
+ * Layer 4 protocol type is IGMP
+ *
+ * @def ODP_PROTO_L4_TYPE_IPV4
+ * Layer 4 protocol type is IPv4
+ *
+ * @def ODP_PROTO_L4_TYPE_TCP
+ * Layer 4 protocol type is TCP
+ *
+ * @def ODP_PROTO_L4_TYPE_UDP
+ * Layer 4 protocol type is UDP
+ *
+ * @def ODP_PROTO_L4_TYPE_IPV6
+ * Layer 4 protocol type is IPv6
+ *
+ * @def ODP_PROTO_L4_TYPE_GRE
+ * Layer 4 protocol type is GRE
+ *
+ * @def ODP_PROTO_L4_TYPE_ESP
+ * Layer 4 protocol type is IPSEC ESP
+ *
+ * @def ODP_PROTO_L4_TYPE_AH
+ * Layer 4 protocol type is IPSEC AH
+ *
+ * @def ODP_PROTO_L4_TYPE_ICMPV6
+ * Layer 4 protocol type is ICMPv6
+ *
+ * @def ODP_PROTO_L4_TYPE_NO_NEXT
+ * Layer 4 protocol type is "No Next Header".
+ * Protocol / next header number is 59.
+ *
+ * @def ODP_PROTO_L4_TYPE_IPCOMP
+ * Layer 4 protocol type is IP Payload Compression Protocol
+ *
+ * @def ODP_PROTO_L4_TYPE_SCTP
+ * Layer 4 protocol type is SCTP
+ *
+ * @def ODP_PROTO_L4_TYPE_ROHC
+ * Layer 4 protocol type is ROHC
+ */
+
 /**
  * Protocol
  */
@@ -1542,6 +1615,28 @@  uint32_t odp_packet_l4_offset(odp_packet_t pkt);
  */
 int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset);
 
+/**
+ * Layer 3 protocol type
+ *
+ * Returns layer 3 protocol type. Initial type value is ODP_PROTO_L3_TYPE_NONE.
+ *
+ * @param      pkt      Packet handle
+ *
+ * @return Layer 3 protocol type
+ */
+odp_proto_l3_type_t odp_packet_l3_type(odp_packet_t pkt);
+
+/**
+ * Layer 4 protocol type
+ *
+ * Returns layer 4 protocol type. Initial type value is ODP_PROTO_L4_TYPE_NONE.
+ *
+ * @param      pkt      Packet handle
+ *
+ * @return Layer 4 protocol type
+ */
+odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt);
+
 /**
  * Layer 3 checksum check status
  *
diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet.h b/platform/linux-generic/include-abi/odp/api/abi/packet.h
index 1aa7cbd58..137cd3ec4 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/packet.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/packet.h
@@ -47,6 +47,34 @@  static inline odp_packet_seg_t _odp_packet_seg_from_ndx(uint8_t ndx)
 
 #define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)-1)
 
+typedef uint8_t odp_proto_l3_type_t;
+
+#define ODP_PROTO_L3_TYPE_NONE   0
+#define ODP_PROTO_L3_TYPE_ARP    1
+#define ODP_PROTO_L3_TYPE_RARP   2
+#define ODP_PROTO_L3_TYPE_MPLS   3
+#define ODP_PROTO_L3_TYPE_IPV4   4
+#define ODP_PROTO_L3_TYPE_IPV6   6
+
+typedef uint8_t odp_proto_l4_type_t;
+
+/* Numbers from IANA Assigned Internet Protocol Numbers list */
+#define ODP_PROTO_L4_TYPE_NONE      0
+#define ODP_PROTO_L4_TYPE_ICMPV4    1
+#define ODP_PROTO_L4_TYPE_IGMP      2
+#define ODP_PROTO_L4_TYPE_IPV4      4
+#define ODP_PROTO_L4_TYPE_TCP       6
+#define ODP_PROTO_L4_TYPE_UDP       17
+#define ODP_PROTO_L4_TYPE_IPV6      41
+#define ODP_PROTO_L4_TYPE_GRE       47
+#define ODP_PROTO_L4_TYPE_ESP       50
+#define ODP_PROTO_L4_TYPE_AH        51
+#define ODP_PROTO_L4_TYPE_ICMPV6    58
+#define ODP_PROTO_L4_TYPE_NO_NEXT   59
+#define ODP_PROTO_L4_TYPE_IPCOMP    108
+#define ODP_PROTO_L4_TYPE_SCTP      132
+#define ODP_PROTO_L4_TYPE_ROHC      142
+
 typedef enum {
 	ODP_PACKET_GREEN = 0,
 	ODP_PACKET_YELLOW = 1,