diff mbox series

[API-NEXT,v3,11/14] validation: switch to using odp_packet_l4_type_set()

Message ID 1518008409-31750-12-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, 1 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Use odp_packet_l4_type_set() instead of calling odp_packet_has_*_set().

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
 **/
 .../api/classification/odp_classification_common.c |  4 +-
 test/validation/api/packet/packet.c                | 60 ++++++++++++++++++++--
 test/validation/api/traffic_mngr/traffic_mngr.c    |  4 +-
 3 files changed, 60 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/api/classification/odp_classification_common.c b/test/validation/api/classification/odp_classification_common.c
index 191489126..7d6d24162 100644
--- a/test/validation/api/classification/odp_classification_common.c
+++ b/test/validation/api/classification/odp_classification_common.c
@@ -350,7 +350,7 @@  odp_packet_t create_packet(cls_packet_info_t pkt_info)
 		udp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
 		udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);
 		udp->chksum = 0;
-		odp_packet_has_udp_set(pkt, 1);
+		odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_UDP);
 		if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0) {
 			LOG_ERR("odph_udp_tcp_chksum failed\n");
 			return ODP_PACKET_INVALID;
@@ -360,7 +360,7 @@  odp_packet_t create_packet(cls_packet_info_t pkt_info)
 		tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
 		tcp->hl = ODPH_TCPHDR_LEN / 4;
 		tcp->cksm = 0;
-		odp_packet_has_tcp_set(pkt, 1);
+		odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_TCP);
 		if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0) {
 			LOG_ERR("odph_udp_tcp_chksum failed\n");
 			return ODP_PACKET_INVALID;
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index 00228b240..b3174b824 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -1052,10 +1052,6 @@  void packet_test_in_flags(void)
 	TEST_INFLAG(pkt, ipfrag);
 	TEST_INFLAG(pkt, ipopt);
 	TEST_INFLAG(pkt, ipsec);
-	TEST_INFLAG(pkt, udp);
-	TEST_INFLAG(pkt, tcp);
-	TEST_INFLAG(pkt, sctp);
-	TEST_INFLAG(pkt, icmp);
 
 	odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_NONE);
 	CU_ASSERT_EQUAL(odp_packet_l3_type(pkt), ODP_PROTO_L3_TYPE_NONE);
@@ -1069,17 +1065,73 @@  void packet_test_in_flags(void)
 	CU_ASSERT(!odp_packet_has_ipv4(pkt));
 	CU_ASSERT(!odp_packet_has_ipv6(pkt));
 
+	odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_NONE);
+	CU_ASSERT_EQUAL(odp_packet_l4_type(pkt), ODP_PROTO_L4_TYPE_NONE);
+	CU_ASSERT(!odp_packet_has_tcp(pkt));
+	CU_ASSERT(!odp_packet_has_udp(pkt));
+	CU_ASSERT(!odp_packet_has_sctp(pkt));
+	CU_ASSERT(!odp_packet_has_icmp(pkt));
+
 	odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV4);
 	CU_ASSERT_EQUAL(odp_packet_l3_type(pkt), ODP_PROTO_L3_TYPE_IPV4);
 	CU_ASSERT(!odp_packet_has_arp(pkt));
 	CU_ASSERT(odp_packet_has_ipv4(pkt));
 	CU_ASSERT(!odp_packet_has_ipv6(pkt));
 
+	odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_ICMPV4);
+	CU_ASSERT_EQUAL(odp_packet_l4_type(pkt), ODP_PROTO_L4_TYPE_ICMPV4);
+	CU_ASSERT(!odp_packet_has_tcp(pkt));
+	CU_ASSERT(!odp_packet_has_udp(pkt));
+	CU_ASSERT(!odp_packet_has_sctp(pkt));
+	CU_ASSERT(odp_packet_has_icmp(pkt));
+
+	odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_TCP);
+	CU_ASSERT_EQUAL(odp_packet_l4_type(pkt), ODP_PROTO_L4_TYPE_TCP);
+	CU_ASSERT(odp_packet_has_tcp(pkt));
+	CU_ASSERT(!odp_packet_has_udp(pkt));
+	CU_ASSERT(!odp_packet_has_sctp(pkt));
+	CU_ASSERT(!odp_packet_has_icmp(pkt));
+
+	odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_UDP);
+	CU_ASSERT_EQUAL(odp_packet_l4_type(pkt), ODP_PROTO_L4_TYPE_UDP);
+	CU_ASSERT(!odp_packet_has_tcp(pkt));
+	CU_ASSERT(odp_packet_has_udp(pkt));
+	CU_ASSERT(!odp_packet_has_sctp(pkt));
+	CU_ASSERT(!odp_packet_has_icmp(pkt));
+
+	odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_SCTP);
+	CU_ASSERT_EQUAL(odp_packet_l4_type(pkt), ODP_PROTO_L4_TYPE_SCTP);
+	CU_ASSERT(!odp_packet_has_tcp(pkt));
+	CU_ASSERT(!odp_packet_has_udp(pkt));
+	CU_ASSERT(odp_packet_has_sctp(pkt));
+	CU_ASSERT(!odp_packet_has_icmp(pkt));
+
+	odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_AH);
+	CU_ASSERT_EQUAL(odp_packet_l4_type(pkt), ODP_PROTO_L4_TYPE_AH);
+	CU_ASSERT(!odp_packet_has_tcp(pkt));
+	CU_ASSERT(!odp_packet_has_udp(pkt));
+	CU_ASSERT(!odp_packet_has_sctp(pkt));
+	CU_ASSERT(!odp_packet_has_icmp(pkt));
+
+	odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_ESP);
+	CU_ASSERT_EQUAL(odp_packet_l4_type(pkt), ODP_PROTO_L4_TYPE_ESP);
+	CU_ASSERT(!odp_packet_has_tcp(pkt));
+	CU_ASSERT(!odp_packet_has_udp(pkt));
+	CU_ASSERT(!odp_packet_has_sctp(pkt));
+	CU_ASSERT(!odp_packet_has_icmp(pkt));
+
 	odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV6);
 	CU_ASSERT_EQUAL(odp_packet_l3_type(pkt), ODP_PROTO_L3_TYPE_IPV6);
 	CU_ASSERT(!odp_packet_has_arp(pkt));
 	CU_ASSERT(!odp_packet_has_ipv4(pkt));
 	CU_ASSERT(odp_packet_has_ipv6(pkt));
+
+	odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_ICMPV6);
+	CU_ASSERT_EQUAL(odp_packet_l4_type(pkt), ODP_PROTO_L4_TYPE_ICMPV6);
+	CU_ASSERT(!odp_packet_has_tcp(pkt));
+	CU_ASSERT(!odp_packet_has_udp(pkt));
+	CU_ASSERT(!odp_packet_has_sctp(pkt));
+	CU_ASSERT(odp_packet_has_icmp(pkt));
 }
 
 void packet_test_error_flags(void)
diff --git a/test/validation/api/traffic_mngr/traffic_mngr.c b/test/validation/api/traffic_mngr/traffic_mngr.c
index 4b70282b1..c597cffcf 100644
--- a/test/validation/api/traffic_mngr/traffic_mngr.c
+++ b/test/validation/api/traffic_mngr/traffic_mngr.c
@@ -775,7 +775,7 @@  static odp_packet_t make_pkt(odp_pool_t  pkt_pool,
 
 	if (pkt_info->use_tcp) {
 		/* TCP Header */
-		odp_packet_has_tcp_set(odp_pkt, 1);
+		odp_packet_l4_type_set(odp_pkt, ODP_PROTO_L4_TYPE_TCP);
 		tcp_hdr->src_port = odp_cpu_to_be_16(DEFAULT_TCP_SRC_PORT);
 		tcp_hdr->dst_port = odp_cpu_to_be_16(DEFAULT_TCP_DST_PORT);
 		tcp_hdr->seq_no   = odp_cpu_to_be_32(cpu_tcp_seq_num);
@@ -790,7 +790,7 @@  static odp_packet_t make_pkt(odp_pool_t  pkt_pool,
 		cpu_tcp_seq_num       += payload_len;
 	} else {
 		/* UDP Header */
-		odp_packet_has_udp_set(odp_pkt, 1);
+		odp_packet_l4_type_set(odp_pkt, ODP_PROTO_L4_TYPE_UDP);
 		udp_hdr->src_port = odp_cpu_to_be_16(DEFAULT_UDP_SRC_PORT);
 		udp_hdr->dst_port = odp_cpu_to_be_16(DEFAULT_UDP_DST_PORT);
 		udp_hdr->length   = odp_cpu_to_be_16(l4_len);