diff options
Diffstat (limited to 'helper/test/chksum.c')
-rw-r--r-- | helper/test/chksum.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/helper/test/chksum.c b/helper/test/chksum.c index 1beae47f1..d7273284a 100644 --- a/helper/test/chksum.c +++ b/helper/test/chksum.c @@ -1,10 +1,7 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2015-2018 Linaro Limited */ -#include "odph_debug.h" #include <odp_api.h> #include <odp/helper/odph_api.h> @@ -19,7 +16,7 @@ struct udata_struct { }; /* Create additional dataplane threads */ -int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) +int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) { odp_instance_t instance; int status = 0; @@ -108,9 +105,20 @@ 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; + ip->tos = 0; + ip->frag_offset = 0; + ip->ttl = 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 |