Several nfapi bug fixes for RX ind and SR ind
The SR ind was not properly being packed and unpacked. The RX inidcation was not properly being allocated prior to unpacking. The freq_shift field was declared as a uint16_t but push/pulled as a uint8_t. Added MSG_TRUNC in the nfapi VNF recvfrom.
This commit is contained in:
@@ -1048,7 +1048,7 @@ static uint8_t pack_ul_tti_request_srs_pdu(nfapi_nr_srs_pdu_t *srs_pdu, uint8_t
|
||||
push8(srs_pdu->comb_offset, ppWritePackedMsg, end) &&
|
||||
push8(srs_pdu->cyclic_shift, ppWritePackedMsg, end) &&
|
||||
push8(srs_pdu->frequency_position, ppWritePackedMsg, end) &&
|
||||
push8(srs_pdu->frequency_shift, ppWritePackedMsg, end) &&
|
||||
push16(srs_pdu->frequency_shift, ppWritePackedMsg, end) &&
|
||||
push8(srs_pdu->frequency_hopping, ppWritePackedMsg, end) &&
|
||||
push8(srs_pdu->group_or_sequence_hopping, ppWritePackedMsg, end) &&
|
||||
push8(srs_pdu->resource_type, ppWritePackedMsg, end) &&
|
||||
@@ -1598,7 +1598,6 @@ static uint8_t pack_ul_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_
|
||||
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))
|
||||
return 0;
|
||||
@@ -3023,10 +3022,8 @@ return 1;
|
||||
|
||||
//RX DATA INDICATION
|
||||
|
||||
static uint8_t pack_nr_rx_data_indication_body(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
|
||||
static uint8_t pack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t *value, uint8_t **ppWritePackedMsg, uint8_t *end)
|
||||
{
|
||||
nfapi_nr_rx_data_pdu_t* value = (nfapi_nr_rx_data_pdu_t*)tlv;
|
||||
|
||||
if(!(push32(value->handle, ppWritePackedMsg, end) &&
|
||||
push16(value->rnti, ppWritePackedMsg, end) &&
|
||||
push8(value->harq_id, ppWritePackedMsg, end) &&
|
||||
@@ -3056,7 +3053,7 @@ static uint8_t pack_nr_rx_data_indication(void *msg, uint8_t **ppWritePackedMsg,
|
||||
|
||||
for (int i = 0; i < pNfapiMsg->number_of_pdus; i++)
|
||||
{
|
||||
if(!pack_nr_rx_data_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end))
|
||||
if(!pack_nr_rx_data_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end))
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3104,10 +3101,8 @@ return 1;
|
||||
|
||||
//SRS INDICATION
|
||||
|
||||
static uint8_t pack_nr_srs_indication_body(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
|
||||
static uint8_t pack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t *value, uint8_t **ppWritePackedMsg, uint8_t *end)
|
||||
{
|
||||
nfapi_nr_srs_indication_pdu_t* value = (nfapi_nr_srs_indication_pdu_t*)tlv;
|
||||
|
||||
if(!(push32(value->handle, ppWritePackedMsg, end) &&
|
||||
push16(value->rnti, ppWritePackedMsg, end) &&
|
||||
push16(value->timing_advance, ppWritePackedMsg, end) &&
|
||||
@@ -3119,8 +3114,7 @@ static uint8_t pack_nr_srs_indication_body(void* tlv, uint8_t **ppWritePackedMsg
|
||||
return 0;
|
||||
for(int i = 0; i < value->reported_symbol_list->num_rbs; i++)
|
||||
{
|
||||
if(!(push8(value->reported_symbol_list->rb_list->rb_snr, ppWritePackedMsg, end)
|
||||
))
|
||||
if (!push8(value->reported_symbol_list->rb_list[i].rb_snr, ppWritePackedMsg, end))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -5722,7 +5716,7 @@ static uint8_t unpack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t* value,
|
||||
return 0;
|
||||
|
||||
uint16_t length = value->pdu_length;
|
||||
value->pdu = nfapi_p7_allocate(length, config);
|
||||
value->pdu = nfapi_p7_allocate(sizeof(*value->pdu) * length, config);
|
||||
|
||||
if (pullarray8(ppReadPackedMsg, value->pdu, length, length, end) == 0)
|
||||
{
|
||||
@@ -5803,10 +5797,8 @@ return 1;
|
||||
|
||||
//SRS INDICATION
|
||||
|
||||
static uint8_t unpack_nr_srs_indication_body(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
|
||||
static uint8_t unpack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t* value, uint8_t **ppReadPackedMsg, uint8_t *end)
|
||||
{
|
||||
nfapi_nr_srs_indication_pdu_t* value = (nfapi_nr_srs_indication_pdu_t*)tlv;
|
||||
|
||||
if(!(pull32(ppReadPackedMsg, &value->handle, end) &&
|
||||
pull16(ppReadPackedMsg, &value->rnti, end) &&
|
||||
pull16(ppReadPackedMsg, &value->timing_advance, end) &&
|
||||
@@ -5818,17 +5810,14 @@ static uint8_t unpack_nr_srs_indication_body(void* tlv, uint8_t **ppReadPackedMs
|
||||
return 0;
|
||||
for(int i = 0; i < value->reported_symbol_list->num_rbs; i++)
|
||||
{
|
||||
if(!(pull8(ppReadPackedMsg, &value->reported_symbol_list->rb_list->rb_snr, end)
|
||||
))
|
||||
if (!pull8(ppReadPackedMsg, &value->reported_symbol_list->rb_list[i].rb_snr, end))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config)
|
||||
static uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_nr_srs_indication_t *pNfapiMsg, nfapi_p7_codec_config_t* config)
|
||||
{
|
||||
nfapi_nr_srs_indication_t *pNfapiMsg = (nfapi_nr_srs_indication_t*)msg;
|
||||
|
||||
if (!(pull16(ppReadPackedMsg,&pNfapiMsg->sfn , end) &&
|
||||
pull16(ppReadPackedMsg,&pNfapiMsg->slot , end) &&
|
||||
pull8(ppReadPackedMsg,&pNfapiMsg->number_of_pdus, end)
|
||||
@@ -5837,7 +5826,7 @@ static uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end,
|
||||
|
||||
for(int i=0; i<pNfapiMsg->number_of_pdus;i++)
|
||||
{
|
||||
if(!unpack_nr_srs_indication_body(&pNfapiMsg->pdu_list,ppReadPackedMsg,end))
|
||||
if (!unpack_nr_srs_indication_body(&pNfapiMsg->pdu_list[i], ppReadPackedMsg, end))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1473,7 +1473,7 @@ void vnf_handle_nr_slot_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling NR SLOT Indication\n", __FUNCTION__);
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "%s: Handling NR SLOT Indication\n", __FUNCTION__);
|
||||
if(vnf_p7->_public.nr_slot_indication)
|
||||
{
|
||||
(vnf_p7->_public.nr_slot_indication)(&ind);
|
||||
@@ -2574,32 +2574,28 @@ int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
|
||||
// resize the buffer if we have a large segment
|
||||
if(header.message_length > vnf_p7->rx_message_buffer_size)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length);
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length);
|
||||
vnf_p7->rx_message_buffer = realloc(vnf_p7->rx_message_buffer, header.message_length);
|
||||
vnf_p7->rx_message_buffer_size = header.message_length;
|
||||
}
|
||||
|
||||
// read the segment
|
||||
recvfrom_result = recvfrom(vnf_p7->socket, vnf_p7->rx_message_buffer, header.message_length, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size);
|
||||
recvfrom_result = recvfrom(vnf_p7->socket, vnf_p7->rx_message_buffer, header.message_length, MSG_WAITALL | MSG_TRUNC, (struct sockaddr*)&remote_addr, &remote_addr_size);
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "recvfrom_result = %d from %s():%d\n", recvfrom_result, __FUNCTION__, __LINE__);
|
||||
|
||||
// todo : how to handle incomplete readfroms, need some sort of buffer/select
|
||||
|
||||
if(recvfrom_result == 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom returned 0\n");
|
||||
}
|
||||
else if(recvfrom_result != -1 && recvfrom_result != header.message_length)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Received unexpected number of bytes %d %d\n", recvfrom_result, header.message_length);
|
||||
|
||||
recvfrom_result += recvfrom(vnf_p7->socket, &vnf_p7->rx_message_buffer[recvfrom_result], header.message_length - recvfrom_result, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(recvfrom_result > 0)
|
||||
if (recvfrom_result > 0)
|
||||
{
|
||||
if (recvfrom_result != header.message_length)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "(%d) Received unexpected number of bytes. %d != %d",
|
||||
__LINE__, recvfrom_result, header.message_length);
|
||||
break;
|
||||
}
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Calling vnf_nr_handle_p7_message from %d\n", __LINE__);
|
||||
vnf_handle_p7_message(vnf_p7->rx_message_buffer, recvfrom_result, vnf_p7);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user