diff mbox series

[API-NEXT,v3,4/14] linux-gen: packet: implement L3/L4 type setters

Message ID 1518008409-31750-5-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v3,1/14] linux-gen: packet: implement packet l3/l4 proto types | expand

Commit Message

Github ODP bot Feb. 7, 2018, 12:59 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 457 (lumag:packet-types)
 ** https://github.com/Linaro/odp/pull/457
 ** Patch: https://github.com/Linaro/odp/pull/457.patch
 ** Base sha: e1175d5a69c65bb465022c9f1381c40fdb5c4069
 ** Merge commit sha: 86fcf3650d33f5dd82712dda131fb8ca66a3bdf8
 **/
 platform/linux-generic/odp_packet.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index f5151d293..4b90e9f07 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2557,9 +2557,31 @@  odp_proto_l3_type_t odp_packet_l3_type(odp_packet_t pkt)
 	return pkt_hdr->p.input_flags.l3_type;
 }
 
+void odp_packet_l3_type_set(odp_packet_t pkt, odp_proto_l3_type_t val)
+{
+	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+	pkt_hdr->p.input_flags.l3_type = val;
+	pkt_hdr->p.input_flags.arp = (val == ODP_PROTO_L3_TYPE_ARP);
+	pkt_hdr->p.input_flags.ipv4 = (val == ODP_PROTO_L3_TYPE_IPV4);
+	pkt_hdr->p.input_flags.ipv6 = (val == ODP_PROTO_L3_TYPE_IPV6);
+}
+
 odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt)
 {
 	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
 
 	return pkt_hdr->p.input_flags.l4_type;
 }
+
+void odp_packet_l4_type_set(odp_packet_t pkt, odp_proto_l4_type_t val)
+{
+	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+	pkt_hdr->p.input_flags.l4_type = val;
+	pkt_hdr->p.input_flags.tcp = (val == ODP_PROTO_L4_TYPE_TCP);
+	pkt_hdr->p.input_flags.udp = (val == ODP_PROTO_L4_TYPE_UDP);
+	pkt_hdr->p.input_flags.sctp = (val == ODP_PROTO_L4_TYPE_SCTP);
+	pkt_hdr->p.input_flags.icmp = (val == ODP_PROTO_L4_TYPE_ICMPV4) ||
+				      (val == ODP_PROTO_L4_TYPE_ICMPV6);
+}