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:
Rúben Soares Silva
2025-03-31 10:15:08 +01:00
parent 1d479b2aa9
commit d9e3725a21
7 changed files with 83 additions and 13 deletions
+1
View File
@@ -50,6 +50,7 @@ uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *e
uint8_t unpack_nr_uci_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_srs_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config);
uint8_t unpack_nr_srs_report_tlv_value(nfapi_srs_report_tlv_t *report_tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_nr_rach_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t unpack_nr_rach_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config);
#endif // OPENAIRINTERFACE_NR_FAPI_P7_H
+24 -4
View File
@@ -2300,6 +2300,28 @@ uint8_t pack_nr_srs_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *e
return 1;
}
uint8_t unpack_nr_srs_report_tlv_value(nfapi_srs_report_tlv_t *report_tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
#ifndef ENABLE_AERIAL
for (int i = 0; i < (report_tlv->length + 3) / 4; i++) {
if (!pull32(ppReadPackedMsg, &report_tlv->value[i], end)) {
return 0;
}
}
#else
const uint16_t last_idx = ((report_tlv->length + 3) / 4) - 1;
for (int i = 0; i < last_idx; i++) {
if (!pull32(ppReadPackedMsg, &report_tlv->value[i], end)) {
return 0;
}
}
// Pull last bytes according to how much padding it would need to be 32-bit aligned
const uint8_t padding = get_tlv_padding(report_tlv->length);
pullx32(4 - padding, ppReadPackedMsg, &report_tlv->value[last_idx], end);
#endif
return 1;
}
static uint8_t unpack_nr_srs_report_tlv(nfapi_srs_report_tlv_t *report_tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
if(!(pull16(ppReadPackedMsg, &report_tlv->tag, end) &&
@@ -2307,10 +2329,8 @@ static uint8_t unpack_nr_srs_report_tlv(nfapi_srs_report_tlv_t *report_tlv, uint
return 0;
}
#ifndef ENABLE_AERIAL
for (int i = 0; i < (report_tlv->length + 3) / 4; i++) {
if (!pull32(ppReadPackedMsg, &report_tlv->value[i], end)) {
return 0;
}
if (!unpack_nr_srs_report_tlv_value(report_tlv, ppReadPackedMsg, end)) {
return 0;
}
#endif
return 1;
+13 -1
View File
@@ -2684,6 +2684,18 @@ void dump_uci_indication(const nfapi_nr_uci_indication_t *msg)
}
}
static void dump_srs_report_tlv(const nfapi_srs_report_tlv_t* tlv, int depth)
{
depth++;
INDENTED_PRINTF("TAG = 0x%02x\n", tlv->tag);
INDENTED_PRINTF("LENGTH = 0x%02x\n", tlv->length);
INDENTED_PRINTF("VALUE = ");
for (int i = 0; i < ((tlv->length + 3) / 4); ++i) {
printf("0x%04x ", tlv->value[i]);
}
printf("\n");
}
void dump_srs_indication(const nfapi_nr_srs_indication_t *msg)
{
int depth = 0;
@@ -2704,7 +2716,7 @@ void dump_srs_indication(const nfapi_nr_srs_indication_t *msg)
INDENTED_PRINTF("Timing advance offset in nanoseconds = 0x%02x\n", pdu->timing_advance_offset_nsec);
INDENTED_PRINTF("SRS usage = 0x%02x\n", pdu->srs_usage);
INDENTED_PRINTF("Report Type = 0x%02x\n", pdu->report_type);
/* call to dump_srs_report_tlv */
dump_srs_report_tlv(&pdu->report_tlv, depth);
depth--;
}
}