diff mbox series

[v5,3/3] helper: chksum: verify odph_ipv4_chksum_*() functions

Message ID 1503576008-15890-4-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v5,1/3] helper: chksum: calculate checksum in network byte order | expand

Commit Message

Github ODP bot Aug. 24, 2017, noon UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


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

---
/** Email created from pull request 132 (lumag:fix-checksum)
 ** https://github.com/Linaro/odp/pull/132
 ** Patch: https://github.com/Linaro/odp/pull/132.patch
 ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380
 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff
 **/
 helper/test/chksum.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/helper/test/chksum.c b/helper/test/chksum.c
index 1beae47f..4a957c32 100644
--- a/helper/test/chksum.c
+++ b/helper/test/chksum.c
@@ -108,9 +108,17 @@  int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED)
 				       ODPH_IPV4HDR_LEN);
 	ip->proto = ODPH_IPPROTO_UDP;
 	ip->id = odp_cpu_to_be_16(1);
-	ip->chksum = 0;
 	odp_packet_has_ipv4_set(test_packet, 1);
-	odph_ipv4_csum_update(test_packet);
+	if (odph_ipv4_csum_update(test_packet) < 0)
+		status = -1;
+
+	if (!odph_ipv4_csum_valid(test_packet))
+		status = -1;
+
+	printf("IP chksum = 0x%x\n", odp_be_to_cpu_16(ip->chksum));
+
+	if (odp_be_to_cpu_16(ip->chksum) != 0x3965)
+		status = -1;
 
 	/* udp */
 	odp_packet_l4_offset_set(test_packet, ODPH_ETHHDR_LEN