diff mbox series

[API-NEXT,v1,1/2] linux-gen: packet: implement packet l3/l4 proto types

Message ID 1518814825-27180-2-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v1,1/2] linux-gen: packet: implement packet l3/l4 proto types | expand

Commit Message

Github ODP bot Feb. 16, 2018, 9 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 463 (lumag:packet-types-3)
 ** https://github.com/Linaro/odp/pull/463
 ** Patch: https://github.com/Linaro/odp/pull/463.patch
 ** Base sha: af7be638ef9ac98bdb1f2e4917f152889eb1850f
 ** Merge commit sha: 35498cf7080f84be804702cc9c2d471808f5f3fb
 **/
 platform/linux-generic/odp_packet.c | 38 +++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index dc16e9be4..ad4fd3bb6 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2544,3 +2544,41 @@  int odp_packet_has_ref(odp_packet_t pkt)
 
 	return 0;
 }
+
+odp_proto_l3_type_t odp_packet_l3_type(odp_packet_t pkt)
+{
+	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+	if (pkt_hdr->p.input_flags.ipv4)
+		return ODP_PROTO_L3_TYPE_IPV4;
+	else if (pkt_hdr->p.input_flags.ipv6)
+		return ODP_PROTO_L3_TYPE_IPV6;
+	else if (pkt_hdr->p.input_flags.arp)
+		return ODP_PROTO_L3_TYPE_ARP;
+
+	return ODP_PROTO_L3_TYPE_NONE;
+}
+
+odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt)
+{
+	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+	if (pkt_hdr->p.input_flags.tcp)
+		return ODP_PROTO_L4_TYPE_TCP;
+	else if (pkt_hdr->p.input_flags.udp)
+		return ODP_PROTO_L4_TYPE_UDP;
+	else if (pkt_hdr->p.input_flags.sctp)
+		return ODP_PROTO_L4_TYPE_SCTP;
+	else if (pkt_hdr->p.input_flags.ipsec_ah)
+		return ODP_PROTO_L4_TYPE_AH;
+	else if (pkt_hdr->p.input_flags.ipsec_esp)
+		return ODP_PROTO_L4_TYPE_ESP;
+	else if (pkt_hdr->p.input_flags.icmp &&
+		 pkt_hdr->p.input_flags.ipv4)
+		return ODP_PROTO_L4_TYPE_ICMPV4;
+	else if (pkt_hdr->p.input_flags.icmp &&
+		 pkt_hdr->p.input_flags.ipv6)
+		return ODP_PROTO_L4_TYPE_ICMPV6;
+
+	return ODP_PROTO_L4_TYPE_NONE;
+}