Unpack SRS report TLV not expecting padding to be present
Add a function pullx32 to pull x amount of bytes into uint32_t Change the unpacking to pull only the needed bytes, and skip over the padding, when not Aerial Change SRS.indication dumping function to also print the report TLV contents Change SRS.indication unitary test to fill the last 4 byte block of the report TLV according to the length, with padding
This commit is contained in:
@@ -259,6 +259,31 @@ uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t pullx32(uint8_t length, uint8_t **in, uint32_t *out, uint8_t *end)
|
||||
{
|
||||
uint8_t *pIn = *in;
|
||||
if (length > 4) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s Can't pull more than 4 bytes (%d) into a uint32_t\n", __FUNCTION__, length);
|
||||
on_error();
|
||||
return 0;
|
||||
}
|
||||
if ((end - pIn) >= length) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
|
||||
*out |= ((uint32_t)pIn[i] << (8 * i));
|
||||
#else
|
||||
*out = ((uint32_t)pIn[i] << (8 * (length - 1 - i)));
|
||||
#endif
|
||||
}
|
||||
(*in) += length;
|
||||
return length;
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
|
||||
on_error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end)
|
||||
{
|
||||
uint8_t *pIn = *in;
|
||||
|
||||
Reference in New Issue
Block a user