Commit f336cbc6 authored by Melissa Elkadi's avatar Melissa Elkadi

Fixing pull/push array 32 and cleaning nFAPI code

Several of these changes were made previously and
lost in the merge.
parent a1dee602
......@@ -44,13 +44,21 @@ uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end);
uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pullarray32(uint8_t **in, uint32_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pullarray32(uint8_t **values_to_pull,
uint32_t out[],
uint32_t max_num_values_to_pull,
uint32_t num_values_to_pull,
uint8_t *out_end);
uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
uint32_t pusharray32(uint32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
uint32_t pusharray32(const uint32_t *values_to_push,
uint32_t max_num_values_to_push,
uint32_t num_values_to_push,
uint8_t **out,
uint8_t *out_end);
uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
typedef uint8_t (*pack_array_elem_fn)(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end);
......
......@@ -307,7 +307,8 @@ uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **ou
uint32_t idx;
for(idx = 0; idx < len; ++idx) {
pushs16(in[idx], out, end);
if (!pushs16(in[idx], out, end))
return 0;
}
return sizeof(uint16_t) * len;
......@@ -316,24 +317,28 @@ uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **ou
return 0;
}
}
uint32_t pullarray32(uint8_t **in, uint32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) {
if(len == 0)
uint32_t pullarray32(uint8_t **values_to_pull,
uint32_t out[],
uint32_t max_num_values_to_pull,
uint32_t num_values_to_pull,
uint8_t *out_end) {
if(num_values_to_pull == 0)
return 1;
if(len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
if(num_values_to_pull > max_num_values_to_pull) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, num_values_to_pull, max_num_values_to_pull);
return 0;
}
if((end - (*in)) >= sizeof(uint32_t) * len) {
if((out_end - (*values_to_pull)) >= sizeof(uint32_t) * num_values_to_pull) {
uint32_t idx;
for(idx = 0; idx < len; ++idx) {
if(!pull32(in, &out[idx], end))
for(idx = 0; idx < num_values_to_pull; ++idx) {
if(!pull32(values_to_pull, &out[idx], out_end))
return 0;
}
return sizeof(uint32_t) * len;
return sizeof(uint32_t) * num_values_to_pull;
} else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
return 0;
......@@ -363,24 +368,28 @@ uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t le
return 0;
}
}
uint32_t pusharray32(uint32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) {
if(len == 0)
uint32_t pusharray32(const uint32_t *values_to_push,
uint32_t max_num_values_to_push,
uint32_t num_values_to_push,
uint8_t **out,
uint8_t *out_end) {
if(num_values_to_push == 0)
return 1;
if(len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
if(num_values_to_push > max_num_values_to_push) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, num_values_to_push, max_num_values_to_push);
return 0;
}
if((end - (*out)) >= sizeof(uint32_t) * len) {
if((out_end - (*out)) >= sizeof(uint32_t) * num_values_to_push) {
uint32_t idx;
for(idx = 0; idx < len; ++idx) {
if(!push32(in[idx], out, end))
for(idx = 0; idx < num_values_to_push; ++idx) {
if(!push32(values_to_push[idx], out, out_end))
return 0;
}
return sizeof(uint32_t) * len;
return sizeof(uint32_t) * num_values_to_push;
} else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
return 0;
......@@ -399,7 +408,8 @@ uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **ou
uint32_t idx;
for(idx = 0; idx < len; ++idx) {
pushs32(in[idx], out, end);
if (!pushs32(in[idx], out, end))
return 0;
}
return sizeof(uint32_t) * len;
......
......@@ -1893,15 +1893,23 @@ static uint8_t pack_tx_data_pdu_list_value(void *tlv, uint8_t **ppWritePackedMsg
switch(value->TLVs[i].tag) {
case 0: {
if(!pusharray32(value->TLVs[i].value.direct, 16384, value->TLVs[i].length, ppWritePackedMsg, end))
if (!pusharray32(value->TLVs[i].value.direct, sizeof(value->TLVs[i].value.direct) / sizeof(uint32_t),
value->TLVs[i].length / sizeof(uint32_t), ppWritePackedMsg, end)) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s():%d. value->TLVs[i].length %d \n",
__FUNCTION__, __LINE__, value->TLVs[i].length);
return 0;
}
break;
}
case 1: {
if(!pusharray32(value->TLVs[i].value.ptr, value->TLVs[i].length, value->TLVs[i].length, ppWritePackedMsg, end))
if (!pusharray32(value->TLVs[i].value.ptr, value->TLVs[i].length / sizeof(uint32_t),
value->TLVs[i].length / sizeof(uint32_t), ppWritePackedMsg, end)) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s():%d. value->TLVs[i].length %d \n",
__FUNCTION__, __LINE__, value->TLVs[i].length);
return 0;
}
break;
}
......@@ -3181,32 +3189,36 @@ return 1;
static uint8_t pack_nr_uci_pucch_0_1(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_nr_uci_pucch_pdu_format_0_1_t* value = (nfapi_nr_uci_pucch_pdu_format_0_1_t*)tlv;
if(!(push8(value->pduBitmap, ppWritePackedMsg, end) &&
push32(value->handle, ppWritePackedMsg, end) &&
push16(value->rnti, ppWritePackedMsg, end) &&
push8(value->pucch_format, ppWritePackedMsg, end) &&
push8(value->ul_cqi, ppWritePackedMsg, end) &&
push16(value->timing_advance, ppWritePackedMsg, end) &&
push16(value->rssi, ppWritePackedMsg, end)
))
return 0;
if (!push8(value->pduBitmap, ppWritePackedMsg, end))
return 0;
if (!push32(value->handle, ppWritePackedMsg, end))
return 0;
if (!push16(value->rnti, ppWritePackedMsg, end))
return 0;
if (!push8(value->pucch_format, ppWritePackedMsg, end))
return 0;
if (!push8(value->ul_cqi, ppWritePackedMsg, end))
return 0;
if (!push16(value->timing_advance, ppWritePackedMsg, end))
return 0;
if (!push16(value->rssi, ppWritePackedMsg, end))
return 0;
if (value->pduBitmap & 0x01) { //SR
if (!(push8(value->sr->sr_indication, ppWritePackedMsg, end) &&
push8(value->sr->sr_confidence_level, ppWritePackedMsg, end)
))
return 0;
if (!push8(value->sr->sr_indication, ppWritePackedMsg, end))
return 0;
if (!push8(value->sr->sr_confidence_level, ppWritePackedMsg, end))
return 0;
}
if (((value->pduBitmap >> 1) & 0x01)) { //HARQ
if (!(push8(value->harq->num_harq, ppWritePackedMsg, end) &&
push8(value->harq->harq_confidence_level, ppWritePackedMsg, end)
))
if (!push8(value->harq->num_harq, ppWritePackedMsg, end))
return 0;
if (!push8(value->harq->harq_confidence_level, ppWritePackedMsg, end))
return 0;
for (int i = 0; i < value->harq->num_harq; i++)
{
if (!(push8(value->harq->harq_list[i].harq_value, ppWritePackedMsg, end)
))
return 0;
if (!push8(value->harq->harq_list[i].harq_value, ppWritePackedMsg, end))
return 0;
}
}
......@@ -3216,60 +3228,83 @@ static uint8_t pack_nr_uci_pucch_0_1(void* tlv, uint8_t **ppWritePackedMsg, uint
static uint8_t pack_nr_uci_pucch_2_3_4(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_nr_uci_pucch_pdu_format_2_3_4_t* value = (nfapi_nr_uci_pucch_pdu_format_2_3_4_t*) tlv;
if(!(push8(value->pduBitmap, ppWritePackedMsg, end) &&
push32(value->handle, ppWritePackedMsg, end) &&
push16(value->rnti, ppWritePackedMsg, end) &&
push8(value->pucch_format, ppWritePackedMsg, end) &&
push8(value->ul_cqi, ppWritePackedMsg, end) &&
push16(value->timing_advance, ppWritePackedMsg, end) &&
push16(value->rssi, ppWritePackedMsg, end)
))
return 0;
if (!push8(value->pduBitmap, ppWritePackedMsg, end))
return 0;
if (!push32(value->handle, ppWritePackedMsg, end))
return 0;
if (!push16(value->rnti, ppWritePackedMsg, end))
return 0;
if (!push8(value->pucch_format, ppWritePackedMsg, end))
return 0;
if (!push8(value->ul_cqi, ppWritePackedMsg, end))
return 0;
if (!push16(value->timing_advance, ppWritePackedMsg, end))
return 0;
if (!push16(value->rssi, ppWritePackedMsg, end))
return 0;
if (value->pduBitmap & 0x01) { //SR
if(!(push8(value->sr.sr_bit_len, ppWritePackedMsg, end) &&
pusharray8(value->sr.sr_payload, (int)(value->sr.sr_bit_len / 8) + 1, (int)(value->sr.sr_bit_len / 8) + 1, ppWritePackedMsg, end)
))
return 0;
if (!push16(value->sr.sr_bit_len, ppWritePackedMsg, end))
return 0;
if (!pusharray8(value->sr.sr_payload,
(int)((value->sr.sr_bit_len / 8) + 1),
(int)((value->sr.sr_bit_len / 8) + 1),
ppWritePackedMsg,
end))
return 0;
}
if (((value->pduBitmap >> 1) & 0x01)) { //HARQ
if(!(push8(value->harq.harq_crc, ppWritePackedMsg, end) &&
push8(value->harq.harq_bit_len, ppWritePackedMsg, end) &&
pusharray8(value->harq.harq_payload, (int)(value->harq.harq_bit_len / 8) + 1, (int)(value->harq.harq_bit_len / 8) + 1, ppWritePackedMsg, end)
))
if ((value->pduBitmap >> 1) & 0x01) { //HARQ
if (!push8(value->harq.harq_crc, ppWritePackedMsg, end))
return 0;
if (!push16(value->harq.harq_bit_len, ppWritePackedMsg, end))
return 0;
if (!pusharray8(value->harq.harq_payload,
(int)((value->harq.harq_bit_len / 8) + 1),
(int)((value->harq.harq_bit_len / 8) + 1),
ppWritePackedMsg,
end))
return 0;
}
if (((value->pduBitmap >> 2) & 0x01)) { //CSI-1
if(!(push8(value->csi_part1.csi_part1_crc, ppWritePackedMsg, end) &&
push8(value->csi_part1.csi_part1_bit_len, ppWritePackedMsg, end) &&
pusharray8(value->csi_part1.csi_part1_payload, (int)(value->csi_part1.csi_part1_bit_len / 8) + 1, (int)(value->csi_part1.csi_part1_bit_len / 8) + 1, ppWritePackedMsg, end)
))
if ((value->pduBitmap >> 2) & 0x01) { //CSI-1
if (!push8(value->csi_part1.csi_part1_crc, ppWritePackedMsg, end))
return 0;
if (!push16(value->csi_part1.csi_part1_bit_len, ppWritePackedMsg, end))
return 0;
if (!pusharray8(value->csi_part1.csi_part1_payload,
(int)((value->csi_part1.csi_part1_bit_len / 8) + 1),
(int)((value->csi_part1.csi_part1_bit_len / 8) + 1),
ppWritePackedMsg,
end))
return 0;
}
if (((value->pduBitmap >> 3) & 0x01)) { //CSI-2
if(!(push8(value->csi_part2.csi_part2_crc, ppWritePackedMsg, end) &&
push8(value->csi_part2.csi_part2_bit_len, ppWritePackedMsg, end) &&
pusharray8(value->csi_part2.csi_part2_payload, (int)(value->csi_part2.csi_part2_bit_len / 8) + 1, (int)(value->csi_part2.csi_part2_bit_len / 8) + 1, ppWritePackedMsg, end)
))
if ((value->pduBitmap >> 3) & 0x01) { //CSI-2
if (!push8(value->csi_part2.csi_part2_crc, ppWritePackedMsg, end))
return 0;
if (!push16(value->csi_part2.csi_part2_bit_len, ppWritePackedMsg, end))
return 0;
if (!pusharray8(value->csi_part2.csi_part2_payload,
(int)((value->csi_part2.csi_part2_bit_len / 8) + 1),
(int)((value->csi_part2.csi_part2_bit_len / 8) + 1),
ppWritePackedMsg,
end))
return 0;
}
return 1;
}
static uint8_t pack_nr_uci_indication_body(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
static uint8_t pack_nr_uci_indication_body(nfapi_nr_uci_t* value, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_nr_uci_t* value = (nfapi_nr_uci_t*)tlv;
if(!(push16(value->pdu_type, ppWritePackedMsg, end) &&
push16(value->pdu_size, ppWritePackedMsg, end)
))
if (!push16(value->pdu_type, ppWritePackedMsg, end))
return 0;
if (!push16(value->pdu_size, ppWritePackedMsg, end))
return 0;
switch (value->pdu_type) {
NFAPI_TRACE(NFAPI_TRACE_INFO, " NFAPI_NR_UCI_PUSCH_PDU_TYPE = %d \n", value->pdu_type);
case NFAPI_NR_UCI_PUSCH_PDU_TYPE:
NFAPI_TRACE(NFAPI_TRACE_WARN, "Unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE \n");
break;
......@@ -3290,13 +3325,14 @@ static uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uin
{
nfapi_nr_uci_indication_t *pNfapiMsg = (nfapi_nr_uci_indication_t*)msg;
if (!(push16(pNfapiMsg->sfn , ppWritePackedMsg, end) &&
push16(pNfapiMsg->slot , ppWritePackedMsg, end) &&
push16(pNfapiMsg->num_ucis, ppWritePackedMsg, end)
))
if (!push16(pNfapiMsg->sfn , ppWritePackedMsg, end))
return 0;
if (!push16(pNfapiMsg->slot , ppWritePackedMsg, end))
return 0;
if (!push16(pNfapiMsg->num_ucis, ppWritePackedMsg, end))
return 0;
for(int i=0; i<pNfapiMsg->num_ucis;i++)
for (int i = 0; i < pNfapiMsg->num_ucis; i++)
{
if (!pack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppWritePackedMsg, end))
return 0;
......@@ -5510,14 +5546,18 @@ static uint8_t unpack_tx_data_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t
switch(pNfapiMsg->TLVs[i].tag) {
case 0: {
if(!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.direct, 16384, pNfapiMsg->TLVs[i].length, end))
if (!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.direct,
sizeof(pNfapiMsg->TLVs[i].value.direct) / sizeof(uint32_t),
pNfapiMsg->TLVs[i].length / sizeof(uint32_t), end))
return 0;
break;
}
case 1: {
if(!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.ptr, pNfapiMsg->TLVs[i].length, pNfapiMsg->TLVs[i].length, end))
if (!pullarray32(ppReadPackedMsg,pNfapiMsg->TLVs[i].value.ptr,
pNfapiMsg->TLVs[i].length / sizeof(uint32_t),
pNfapiMsg->TLVs[i].length / sizeof(uint32_t), end))
return 0;
break;
......@@ -5907,58 +5947,111 @@ static uint8_t unpack_nr_uci_pucch_0_1(nfapi_nr_uci_pucch_pdu_format_0_1_t *valu
}
static uint8_t unpack_nr_uci_pucch_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_nr_uci_pucch_pdu_format_2_3_4_t* value = (nfapi_nr_uci_pucch_pdu_format_2_3_4_t*) tlv;
static uint8_t unpack_nr_uci_pucch_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t* value,
uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_p7_codec_config_t *config) {
if (!pull8(ppReadPackedMsg, &value->pduBitmap, end))
return 0;
if (!pull32(ppReadPackedMsg, &value->handle, end))
return 0;
if (!pull16(ppReadPackedMsg, &value->rnti, end))
return 0;
if (!pull8(ppReadPackedMsg, &value->pucch_format, end))
return 0;
if (!pull8(ppReadPackedMsg, &value->ul_cqi, end))
return 0;
if (!pull16(ppReadPackedMsg, &value->timing_advance, end))
return 0;
if (!pull16(ppReadPackedMsg, &value->rssi, end))
return 0;
if(!(pull8(ppReadPackedMsg, &value->pduBitmap, end) &&
pull32(ppReadPackedMsg, &value->handle, end) &&
pull16(ppReadPackedMsg, &value->rnti, end) &&
pull8(ppReadPackedMsg, &value->pucch_format, end) &&
pull8(ppReadPackedMsg, &value->ul_cqi, end) &&
pull16(ppReadPackedMsg, &value->timing_advance, end) &&
pull16(ppReadPackedMsg, &value->rssi, end)
))
return 0;
if (value->pduBitmap & 0x01) { //SR
if(!(pull16(ppReadPackedMsg, &value->sr.sr_bit_len, end)))
if (!pull16(ppReadPackedMsg, &value->sr.sr_bit_len, end))
return 0;
value->sr.sr_payload = (uint8_t*) malloc(sizeof(uint8_t) * ((value->sr.sr_bit_len/8)));
value->sr.sr_payload = nfapi_p7_allocate(sizeof(*value->sr.sr_payload) *
(int)((value->sr.sr_bit_len / 8) + 1),
config);
if (value->sr.sr_payload == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate value->sr.sr_payload\n", __FUNCTION__);
return 0;
}
if(!(pullarray8(ppReadPackedMsg, &value->sr.sr_payload[0], (int)(value->sr.sr_bit_len / 8), (int)(value->sr.sr_bit_len / 8), end)))
return 0;
if (!pullarray8(ppReadPackedMsg, value->sr.sr_payload,
(int)((value->sr.sr_bit_len / 8) + 1),
(int)((value->sr.sr_bit_len / 8) + 1),
end))
return 0;
}
if (((value->pduBitmap >> 1) & 0x01)) { //HARQ
if(!(pull8(ppReadPackedMsg, &value->harq.harq_crc, end)) &&
(pull16(ppReadPackedMsg, &value->harq.harq_bit_len, end)))
if ((value->pduBitmap >> 1) & 0x01) { //HARQ
if (!pull8(ppReadPackedMsg, &value->harq.harq_crc, end))
return 0;
if (!pull16(ppReadPackedMsg, &value->harq.harq_bit_len, end))
return 0;
value->harq.harq_payload = (uint8_t*) malloc(sizeof(uint8_t) * ((value->harq.harq_bit_len/8 )));
value->harq.harq_payload = nfapi_p7_allocate(sizeof(*value->harq.harq_payload) *
(int)((value->harq.harq_bit_len / 8) + 1),
config);
if (value->harq.harq_payload == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate value->harq.harq_payload\n", __FUNCTION__);
return 0;
}
if(!(pullarray8(ppReadPackedMsg, value->harq.harq_payload, (int)(value->harq.harq_bit_len / 8), (int)(value->harq.harq_bit_len / 8), end)))
if (!pullarray8(ppReadPackedMsg, value->harq.harq_payload,
(int)((value->harq.harq_bit_len / 8) + 1),
(int)((value->harq.harq_bit_len / 8) + 1),
end))
return 0;
}
if (((value->pduBitmap >> 2) & 0x01)) { //CSI-1
if(!(pull8(ppReadPackedMsg, &value->csi_part1.csi_part1_crc, end)) &&
(pull16(ppReadPackedMsg, &value->csi_part1.csi_part1_bit_len, end)))
if ((value->pduBitmap >> 2) & 0x01) { //CSI-1
if (!pull8(ppReadPackedMsg, &value->csi_part1.csi_part1_crc, end))
return 0;
if (!pull16(ppReadPackedMsg, &value->csi_part1.csi_part1_bit_len, end))
return 0;
value->csi_part1.csi_part1_payload = (uint8_t*) malloc(sizeof(uint8_t) * ((value->csi_part1.csi_part1_bit_len/8)));
value->csi_part1.csi_part1_payload = nfapi_p7_allocate(sizeof(*value->csi_part1.csi_part1_payload) *
(int)((value->csi_part1.csi_part1_bit_len / 8) + 1),
config);
if (value->csi_part1.csi_part1_payload == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate value->csi_part1.csi_part1_payload\n",
__FUNCTION__);
return 0;
}
// if(!(pullarray8(ppReadPackedMsg, value->csi_part1.csi_part1_payload, (int)(value->csi_part1.csi_part1_bit_len / 8), (int)(value->csi_part1.csi_part1_bit_len / 8), end)))
// return 0;
if (!pullarray8(ppReadPackedMsg, value->csi_part1.csi_part1_payload,
(int)((value->csi_part1.csi_part1_bit_len / 8) + 1),
(int)((value->csi_part1.csi_part1_bit_len / 8) + 1),
end))
return 0;
}
if (((value->pduBitmap >> 3) & 0x01)) { //CSI-2
if(!(pull8(ppReadPackedMsg, &value->csi_part2.csi_part2_crc, end)) &&
(pull16(ppReadPackedMsg, &value->csi_part2.csi_part2_bit_len, end)))
if ((value->pduBitmap >> 3) & 0x01) { //CSI-2
if (!pull8(ppReadPackedMsg, &value->csi_part2.csi_part2_crc, end))
return 0;
if (!pull16(ppReadPackedMsg, &value->csi_part2.csi_part2_bit_len, end))
return 0;
value->csi_part2.csi_part2_payload = (uint8_t*) malloc(sizeof(uint8_t) * ((value->csi_part2.csi_part2_bit_len/8 )));
value->csi_part2.csi_part2_payload = nfapi_p7_allocate(sizeof(*value->csi_part2.csi_part2_payload) *
(int)((value->csi_part2.csi_part2_bit_len / 8) + 1),
config);
if (value->csi_part2.csi_part2_payload == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate value->csi_part2.csi_part2_payload\n",
__FUNCTION__);
return 0;
}
if(!(pullarray8(ppReadPackedMsg, value->csi_part2.csi_part2_payload, (int)(value->csi_part2.csi_part2_bit_len / 8) , (int)(value->csi_part2.csi_part2_bit_len / 8) , end)))
if (!pullarray8(ppReadPackedMsg, value->csi_part2.csi_part2_payload,
(int)((value->csi_part2.csi_part2_bit_len / 8) + 1),
(int)((value->csi_part2.csi_part2_bit_len / 8) + 1),
end))
return 0;
}
......@@ -5970,9 +6063,9 @@ static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t *value,
uint8_t *end,
nfapi_p7_codec_config_t *config)
{
if(!(pull16(ppReadPackedMsg, &value->pdu_type, end) &&
pull16(ppReadPackedMsg, &value->pdu_size, end)
))
if (!pull16(ppReadPackedMsg, &value->pdu_type, end))
return 0;
if (!pull16(ppReadPackedMsg, &value->pdu_size, end))
return 0;
switch (value->pdu_type) {
......@@ -5988,7 +6081,7 @@ static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t *value,
}
case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: {
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu = &value->pucch_pdu_format_2_3_4;
if (!unpack_nr_uci_pucch_2_3_4(uci_pdu, ppReadPackedMsg, end))
if (!unpack_nr_uci_pucch_2_3_4(uci_pdu, ppReadPackedMsg, end, config))
return 0;
break;
}
......@@ -6004,17 +6097,18 @@ static uint8_t unpack_nr_uci_indication(uint8_t **ppReadPackedMsg, uint8_t *end,
{
nfapi_nr_uci_indication_t *pNfapiMsg = (nfapi_nr_uci_indication_t*)msg;
if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn , end) &&
pull16(ppReadPackedMsg, &pNfapiMsg->slot , end) &&
pull16(ppReadPackedMsg, &pNfapiMsg->num_ucis, end)
))
return 0;
if (!pull16(ppReadPackedMsg, &pNfapiMsg->sfn , end))
return 0;
if (!pull16(ppReadPackedMsg, &pNfapiMsg->slot , end))
return 0;
if (!pull16(ppReadPackedMsg, &pNfapiMsg->num_ucis, end))
return 0;
pNfapiMsg->uci_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->uci_list) * pNfapiMsg->num_ucis, config);
for (int i = 0; i < pNfapiMsg->num_ucis; i++)
{
if(!unpack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppReadPackedMsg, end, config))
return 0;
if (!unpack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppReadPackedMsg, end, config))
return 0;
}
return 1;
......
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