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:
Halysson
2025-09-30 12:50:14 -03:00
committed by Alan C. Assis
parent 68fdbef524
commit 9014af9ae7
2 changed files with 15 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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];
}