diff options
-rw-r--r-- | hapc_test.c | 10 |
1 files changed, 8 insertions, 2 deletions
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: |