Commit 6ed8610a authored by Andrew Burger's avatar Andrew Burger

Fix for rx_ind

parent 2d657b5e
......@@ -4956,37 +4956,39 @@ static uint8_t unpack_rx_indication_rel9_value(void *tlv, uint8_t **ppReadPacked
return (pull16(ppReadPackedMsg, &value->timing_advance_r9, end));
}
static uint8_t unpack_rx_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
static uint8_t unpack_rx_indication_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{
nfapi_rx_indication_body_t* value = (nfapi_rx_indication_body_t*)tlv;
// the rxBodyEnd points to the end of the cqi PDU's
uint8_t* rxBodyEnd = *ppReadPackedMsg + value->tl.length;
uint8_t* rxPduEnd = rxBodyEnd;
nfapi_rx_indication_body_t *value = (nfapi_rx_indication_body_t *)tlv;
uint8_t* numberOfPdusAddress = *ppReadPackedMsg;
// the rxBodyEnd points to the end of the cqi PDU's Is this a problem? -Andrew
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s value->tl.length in unpack: %u \n", __FUNCTION__,
value->tl.length);
uint8_t *rxBodyEnd = *ppReadPackedMsg + value->tl.length;
if(rxBodyEnd > end)
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s rxBodyEnd: %p end: %p\n", __FUNCTION__,
rxBodyEnd, end);
if (rxBodyEnd > end)
{
// pdu end is past buffer end
return 0;
}
char foo[1024];
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
__LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if(pull16(ppReadPackedMsg, &value->number_of_pdus, end) == 0)
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if (pull16(ppReadPackedMsg, &value->number_of_pdus, end) == 0)
return 0;
if(value->number_of_pdus > NFAPI_RX_IND_MAX_PDU)
if (value->number_of_pdus > NFAPI_RX_IND_MAX_PDU)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of rx ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_pdus, NFAPI_RX_IND_MAX_PDU);
return 0;
return 0;
}
if(value->number_of_pdus > 0)
if (value->number_of_pdus > 0)
{
value->rx_pdu_list = (nfapi_rx_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_rx_indication_pdu_t) * value->number_of_pdus, config);
if(value->rx_pdu_list == NULL)
value->rx_pdu_list = (nfapi_rx_indication_pdu_t *)nfapi_p7_allocate(sizeof(nfapi_rx_indication_pdu_t) * value->number_of_pdus, config);
if (value->rx_pdu_list == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate rx ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_pdus);
return 0;
......@@ -4996,102 +4998,112 @@ static uint8_t unpack_rx_indication_body_value(void* tlv, uint8_t **ppReadPacked
{
value->rx_pdu_list = 0;
}
uint8_t i = 0;
nfapi_rx_indication_pdu_t* pdu = 0;
while((uint8_t*)(*ppReadPackedMsg) < rxBodyEnd && (uint8_t*)(*ppReadPackedMsg) < rxPduEnd)
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number_of_pdus = %u\n", __FUNCTION__, value->number_of_pdus);
for (int i = 0; i < value->number_of_pdus; i++)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
__LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s i = %u\n", __FUNCTION__, i);
nfapi_tl_t generic_tl;
if( unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
// NFAPI_RX_UE_INFORMATION_TAG
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_tl failed\n", __FUNCTION__);
return 0;
}
switch(generic_tl.tag)
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag = 0x%x length = %u\n", __FUNCTION__, generic_tl.tag, generic_tl.length);
if (generic_tl.tag != NFAPI_RX_UE_INFORMATION_TAG)
{
case NFAPI_RX_UE_INFORMATION_TAG:
{
pdu = &(value->rx_pdu_list[i++]);
pdu->rx_ue_information.tl = generic_tl;
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
__LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if(unpack_rx_ue_information_value(&pdu->rx_ue_information, ppReadPackedMsg, end) == 0)
return 0;
}
break;
case NFAPI_RX_INDICATION_REL8_TAG:
{
if(pdu != 0)
{
pdu->rx_indication_rel8.tl = generic_tl;
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
__LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if(unpack_rx_indication_rel8_value(&pdu->rx_indication_rel8, ppReadPackedMsg, end) == 0)
return 0;
if(pdu->rx_indication_rel8.offset > 0)
{
// Need to check that the data is within the tlv
if(numberOfPdusAddress + pdu->rx_indication_rel8.offset + pdu->rx_indication_rel8.length <= rxBodyEnd)
{
// If this the first pdu set the rxPduEnd
if(numberOfPdusAddress + pdu->rx_indication_rel8.offset < rxPduEnd)
{
rxPduEnd = numberOfPdusAddress + pdu->rx_indication_rel8.offset;
if(rxPduEnd > end)
{
// pdu end is past buffer end
return 0;
}
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME: the rx data is outside of the tlv\n");
}
}
}
}
break;
case NFAPI_RX_INDICATION_REL9_TAG:
{
if(pdu != 0)
{
pdu->rx_indication_rel9.tl = generic_tl;
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
__LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if(unpack_rx_indication_rel9_value(&pdu->rx_indication_rel9, ppReadPackedMsg, end) == 0)
return 0;
}
}
break;
default:
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "RX_ULSCH.indication Invalid pdu type %d \n", generic_tl.tag );
}
break;
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag wrong\n", __FUNCTION__);
return 0;
}
nfapi_rx_indication_pdu_t *pdu = &value->rx_pdu_list[i];
pdu->rx_ue_information.tl = generic_tl;
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if (unpack_rx_ue_information_value(&pdu->rx_ue_information, ppReadPackedMsg, end) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_rx_ue_info failure\n", __FUNCTION__);
return 0;
}
// NFAPI_RX_INDICATION_REL8_TAG
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_tl failed\n", __FUNCTION__);
return 0;
}
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag = 0x%x length = %u\n", __FUNCTION__, generic_tl.tag, generic_tl.length);
if (generic_tl.tag != NFAPI_RX_INDICATION_REL8_TAG)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag wrong\n", __FUNCTION__);
return 0;
}
pdu->rx_indication_rel8.tl = generic_tl;
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if (unpack_rx_indication_rel8_value(&pdu->rx_indication_rel8, ppReadPackedMsg, end) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_rx_indication_rel8 failure\n", __FUNCTION__);
return 0;
}
//What is offset not stripping 10 bytes
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s pdu->rx_indication_rel8.offset = %u", __FUNCTION__,
pdu->rx_indication_rel8.offset);
// NFAPI_RX_INDICATION_REL9_TAG
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_tl failed\n", __FUNCTION__);
return 0;
}
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag = 0x%x length = %u\n", __FUNCTION__, generic_tl.tag, generic_tl.length);
if (generic_tl.tag != NFAPI_RX_INDICATION_REL9_TAG)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag wrong\n", __FUNCTION__);
return 0;
}
pdu->rx_indication_rel9.tl = generic_tl;
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if (unpack_rx_indication_rel9_value(&pdu->rx_indication_rel9, ppReadPackedMsg, end) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_rx_indication_rel9 failure\n", __FUNCTION__);
return 0;
}
}
uint8_t idx = 0;
for(idx = 0; idx < value->number_of_pdus; ++idx)
for (int i = 0; i < value->number_of_pdus; ++i)
{
if(value->rx_pdu_list[idx].rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG)
nfapi_rx_indication_pdu_t *pdu = &value->rx_pdu_list[i];
if (pdu->rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG)
{
uint32_t length = value->rx_pdu_list[idx].rx_indication_rel8.length;
value->rx_pdu_list[idx].data = nfapi_p7_allocate(length, config);
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
__LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if(pullarray8(ppReadPackedMsg, value->rx_pdu_list[idx].data, length, length, end) == 0)
uint32_t length = pdu->rx_indication_rel8.length;
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
if (pullarray8(ppReadPackedMsg, pdu->data, length, length, end) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pullarray8 failure\n", __FUNCTION__);
return 0;
}
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
__LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s:%d: %s\n", __FUNCTION__,
// __LINE__, hexdump(*ppReadPackedMsg, end - *ppReadPackedMsg, foo, sizeof(foo)));
}
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s Success!\n", __FUNCTION__);
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