diff options
author | Dan Williams <dcbw@redhat.com> | 2011-09-27 13:13:40 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2011-09-27 13:13:40 -0500 |
commit | 18fc92ef7304d01c5ec11ced22ff82c4ab6dbbe1 (patch) | |
tree | ee936fbb66ed56b1d2545d3f25550c16fcf1efcc /libwmc/src/utils.c | |
parent | 8250dee13177a164d61e31fe8d60900f9d5c6797 (diff) |
libwmc: add more test code and start of com tests
Diffstat (limited to 'libwmc/src/utils.c')
-rw-r--r-- | libwmc/src/utils.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libwmc/src/utils.c b/libwmc/src/utils.c index 99c13db7..3c470330 100644 --- a/libwmc/src/utils.c +++ b/libwmc/src/utils.c @@ -274,9 +274,11 @@ uml290_wmc_encapsulate (char *inbuf, * hdlc_decapsulate_buffer: * @inbuf: buffer in which to look for an HDLC frame * @inbuf_len: length of valid data in @inbuf - * @check_known_crc: if %TRUE, validate the CRC using @known_crc + * @check_known_crc: if %TRUE, validate the CRC using @known_crc if the normal + * CRC check fails * @known_crc: if @check_known_crc is %TRUE, compare the frame's CRC against - * @known_crc. @known_crc must be in Little Endian (LE) byte order. + * @known_crc if the normal CRC check fails. @known_crc must be in Little + * Endian (LE) byte order. * @outbuf: buffer in which to put decapsulated data from the HDLC frame * @outbuf_len: max size of @outbuf * @out_decap_len: on success, size of the decapsulated data @@ -365,12 +367,14 @@ hdlc_decapsulate_buffer (const char *inbuf, } /* Check the CRC of the packet's data */ - crc = check_known_crc ? known_crc : crc16 (outbuf, unesc_len - 2, 0); + crc = crc16 (outbuf, unesc_len - 2, 0); pkt_crc = outbuf[unesc_len - 2] & 0xFF; pkt_crc |= (outbuf[unesc_len - 1] & 0xFF) << 8; if (crc != pkt_crc) { - *out_used = pkt_len + 1; /* packet + CRC + 0x7E */ - return FALSE; + if (!check_known_crc || (pkt_crc != known_crc)) { + *out_used = pkt_len + 1; /* packet + CRC + 0x7E */ + return FALSE; + } } *out_used = pkt_len + 1; /* packet + CRC + 0x7E */ |