Commit d1cd5b77 authored by Melissa Elkadi's avatar Melissa Elkadi

Clean up to nFAPI and error checking UL_TTI_REQ n_pdus

We seprarated out the large if block in the push/pull
of the UL_TTI_REQ fields to make it easier to read
and debug. Furthermore, we add in AsserFatals before
indexing in UL_TTI_REQ PDU list to ensure we are not
indexing past the end of the array.
parent b66d1874
......@@ -1583,14 +1583,21 @@ static uint8_t pack_ul_config_request_body_value(void *tlv, uint8_t **ppWritePac
static uint8_t pack_ul_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
nfapi_nr_ul_tti_request_t *pNfapiMsg = (nfapi_nr_ul_tti_request_t *)msg;
if (!(push16(pNfapiMsg->SFN, ppWritePackedMsg, end) &&
push16(pNfapiMsg->Slot, ppWritePackedMsg, end) &&
push8(pNfapiMsg->n_pdus, ppWritePackedMsg, end) &&
push8(pNfapiMsg->rach_present, ppWritePackedMsg, end) &&
push8(pNfapiMsg->n_ulsch, ppWritePackedMsg, end) &&
push8(pNfapiMsg->n_ulcch, ppWritePackedMsg, end) &&
push8(pNfapiMsg->n_group, ppWritePackedMsg, end) ))
if (!push16(pNfapiMsg->SFN, ppWritePackedMsg, end))
return 0;
if (!push16(pNfapiMsg->Slot, ppWritePackedMsg, end))
return 0;
if (!push8(pNfapiMsg->n_pdus, ppWritePackedMsg, end))
return 0;
if (!push8(pNfapiMsg->n_group, ppWritePackedMsg, end))
return 0;
if (!push8(pNfapiMsg->rach_present, ppWritePackedMsg, end))
return 0;
if (!push8(pNfapiMsg->n_ulsch, ppWritePackedMsg, end))
return 0;
if (!push8(pNfapiMsg->n_ulcch, ppWritePackedMsg, end))
return 0;
for(int i=0; i<pNfapiMsg->n_pdus; i++) {
if(!pack_ul_tti_pdu_list_value(&pNfapiMsg->pdus_list[i], ppWritePackedMsg, end))
......@@ -4655,14 +4662,19 @@ static uint8_t unpack_ul_tti_groups_list_value(uint8_t **ppReadPackedMsg, uint8_
static uint8_t unpack_ul_tti_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) {
nfapi_nr_ul_tti_request_t *pNfapiMsg = (nfapi_nr_ul_tti_request_t *)msg;
if (!(
pull16(ppReadPackedMsg, &pNfapiMsg->SFN, end) &&
pull16(ppReadPackedMsg, &pNfapiMsg->Slot, end) &&
pull8(ppReadPackedMsg, &pNfapiMsg->n_pdus, end) &&
pull8(ppReadPackedMsg, &pNfapiMsg->n_group, end) &&
pull8(ppReadPackedMsg, &pNfapiMsg->rach_present, end) &&
pull8(ppReadPackedMsg, &pNfapiMsg->n_ulcch, end) &&
pull8(ppReadPackedMsg, &pNfapiMsg->n_ulsch, end) ))
if (!pull16(ppReadPackedMsg, &pNfapiMsg->SFN, end))
return 0;
if (!pull16(ppReadPackedMsg, &pNfapiMsg->Slot, end))
return 0;
if (!pull8(ppReadPackedMsg, &pNfapiMsg->n_pdus, end))
return 0;
if (!pull8(ppReadPackedMsg, &pNfapiMsg->n_group, end))
return 0;
if (!pull8(ppReadPackedMsg, &pNfapiMsg->rach_present, end))
return 0;
if (!pull8(ppReadPackedMsg, &pNfapiMsg->n_ulcch, end))
return 0;
if (!pull8(ppReadPackedMsg, &pNfapiMsg->n_ulsch, end))
return 0;
for(int i=0; i< pNfapiMsg->n_pdus; i++) {
......
......@@ -300,6 +300,8 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP
(RA_sfn_index + slot_index) * N_t_slot * fdm + td_index * fdm + fdm_index;
if((prach_occasion_id < cc->total_prach_occasions) && (td_index == 0)){
AssertFatal(UL_tti_req->n_pdus < sizeof(UL_tti_req->pdus_list) / sizeof(UL_tti_req->pdus_list[0]),
"Invalid UL_tti_req->n_pdus %d\n", UL_tti_req->n_pdus);
UL_tti_req->pdus_list[UL_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PRACH_PDU_TYPE;
UL_tti_req->pdus_list[UL_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_prach_pdu_t);
......@@ -801,6 +803,9 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t
future_ul_tti_req->Slot,
sched_frame,
sched_slot);
AssertFatal(future_ul_tti_req->n_pdus <
sizeof(future_ul_tti_req->pdus_list) / sizeof(future_ul_tti_req->pdus_list[0]),
"Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus);
future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE;
future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
nfapi_nr_pusch_pdu_t *pusch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pusch_pdu;
......
......@@ -85,7 +85,9 @@ void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id, int
void nr_fill_nfapi_srs(int module_id, int CC_id, int UE_id, sub_frame_t slot, NR_SRS_Resource_t *srs_resource) {
nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_id]->UL_tti_req_ahead[0][slot];
AssertFatal(future_ul_tti_req->n_pdus <
sizeof(future_ul_tti_req->pdus_list) / sizeof(future_ul_tti_req->pdus_list[0]),
"Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus);
future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE;
future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_srs_pdu_t);
nfapi_nr_srs_pdu_t *srs_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].srs_pdu;
......
......@@ -55,6 +55,9 @@ void nr_fill_nfapi_pucch(module_id_t mod_id,
future_ul_tti_req->Slot,
pucch->frame,
pucch->ul_slot);
AssertFatal(future_ul_tti_req->n_pdus <
sizeof(future_ul_tti_req->pdus_list) / sizeof(future_ul_tti_req->pdus_list[0]),
"Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus);
future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE;
future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pucch_pdu_t);
nfapi_nr_pucch_pdu_t *pucch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pucch_pdu;
......
......@@ -1704,6 +1704,9 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot)
future_ul_tti_req->Slot,
sched_pusch->frame,
sched_pusch->slot);
AssertFatal(future_ul_tti_req->n_pdus <
sizeof(future_ul_tti_req->pdus_list) / sizeof(future_ul_tti_req->pdus_list[0]),
"Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus);
future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE;
future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
nfapi_nr_pusch_pdu_t *pusch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pusch_pdu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment