From 0b39cc91817ebf29f11553368aea343bdd2f33bf Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 9 Nov 2015 20:08:28 +0100 Subject: hapc_test: don't print checksum if it matches --- hapc_test.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'hapc_test.c') diff --git a/hapc_test.c b/hapc_test.c index a240c14..377c22d 100644 --- a/hapc_test.c +++ b/hapc_test.c @@ -28,12 +28,18 @@ static uint8_t compute_checksum(const uint8_t *data, unsigned int len) void dump_frame(const struct hapc_msg_hdr *hdr) { unsigned int len = hapc_payload_len(hdr); + uint8_t csum_frame, csum_computed; printf("len=%4u, flow_id=%s: ", len, get_value_string(hapc_flow_names, hdr->flow_id)); - printf("checksum=0x%02x, computed=0x%02x\n", - hapc_frame_csum(hdr), compute_checksum((const uint8_t *) hdr, sizeof(*hdr)+len)); + csum_frame = hapc_frame_csum(hdr); + csum_computed = compute_checksum((const uint8_t *) hdr, sizeof(*hdr)+len); + + if (csum_frame != csum_computed) { + printf("CSUM ERROR (%02x != %02x)\n", csum_frame, csum_computed); + return; + } switch (hdr->flow_id) { case HAPC_FLOW_OBJECT: -- cgit v1.2.3