Added CRC match function and simplify CRC check

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent 7846bfccb1
commit 22b1673b36

@ -47,7 +47,6 @@ SRSRAN_API uint32_t srsran_crc_attach_byte(srsran_crc_t* h, uint8_t* data, int l
static inline void srsran_crc_checksum_put_byte(srsran_crc_t* h, uint8_t byte) static inline void srsran_crc_checksum_put_byte(srsran_crc_t* h, uint8_t byte)
{ {
uint64_t crc = h->crcinit; uint64_t crc = h->crcinit;
uint32_t idx; uint32_t idx;
@ -74,6 +73,8 @@ SRSRAN_API uint32_t srsran_crc_checksum_byte(srsran_crc_t* h, const uint8_t* dat
SRSRAN_API uint32_t srsran_crc_checksum(srsran_crc_t* h, uint8_t* data, int len); SRSRAN_API uint32_t srsran_crc_checksum(srsran_crc_t* h, uint8_t* data, int len);
SRSRAN_API bool srsran_crc_match_byte(srsran_crc_t* h, uint8_t* data, int len);
SRSRAN_API bool srsran_crc_match(srsran_crc_t* h, uint8_t* data, int len); SRSRAN_API bool srsran_crc_match(srsran_crc_t* h, uint8_t* data, int len);
#endif // SRSRAN_CRC_H #endif // SRSRAN_CRC_H

@ -177,8 +177,10 @@ uint32_t srsran_crc_attach(srsran_crc_t* h, uint8_t* data, int len)
bool srsran_crc_match(srsran_crc_t* h, uint8_t* data, int len) bool srsran_crc_match(srsran_crc_t* h, uint8_t* data, int len)
{ {
uint8_t* ptr = &data[len]; return srsran_crc_checksum(h, data, len + h->order) == 0;
uint32_t checksum1 = srsran_crc_checksum(h, data, len); }
uint32_t checksum2 = srsran_bit_pack(&ptr, h->order);
return (checksum1 == checksum2); bool srsran_crc_match_byte(srsran_crc_t* h, uint8_t* data, int len)
{
return srsran_crc_checksum_byte(h, data, len + h->order) == 0;
} }

Loading…
Cancel
Save