diff mbox series

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

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

Commit Message

Github ODP bot Feb. 7, 2018, 10:59 a.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: 802ddfc5ea6f47a8935993bf6f8c1675a4c94930
 **/
 platform/linux-generic/odp_packet.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index f5151d293..fce5a730b 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2557,9 +2557,30 @@  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.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);
+}