mirror of
https://github.com/apache/nuttx.git
synced 2025-12-10 04:04:18 +08:00
libc/crc: Add crc8rohcincr for incremental CRC8 ROHC calculation
Add crc8rohcincr() function to support byte-by-byte CRC8 calculation using the ROHC polynomial (0x07) without XOR inversions. This is useful for protocols that require incremental CRC accumulation, such as GSM 07.10 (CMUX), where the CRC must be computed as frames are parsed from circular buffers. Changes include: - New crc8rohcincr() function for single-byte incremental CRC - Function takes current CRC value and returns updated CRC - Uses same g_crc8_tab table as other ROHC functions - No XOR inversions applied for proper accumulation This allows protocols like CMUX to replace local CRC table implementations with standard libc CRC functions while maintaining correct incremental calculation behavior. Signed-off-by: Halysson <halysson1007@gmail.com>
This commit is contained in:
@@ -118,6 +118,12 @@ uint8_t crc8rohcpart(FAR const uint8_t *src, size_t len, uint8_t crc8val);
|
||||
|
||||
uint8_t crc8rohc(FAR const uint8_t *src, size_t len);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: crc8rohcincr
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t crc8rohcincr(uint8_t data_byte, uint8_t crc8val);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -88,3 +88,12 @@ uint8_t crc8rohc(FAR const uint8_t *src, size_t len)
|
||||
{
|
||||
return crc8rohcpart(src, len, 0xff);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: crc8rohcincr
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t crc8rohcincr(uint8_t data_byte, uint8_t crc8val)
|
||||
{
|
||||
return g_crc8_tab[crc8val ^ data_byte];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user