Merge branch 'episys/master' into episys/david/episys-merge-2nd-x2c

This commit is contained in:
David Kim
2021-03-15 11:05:35 -07:00
35 changed files with 1132 additions and 487 deletions
+6 -4
View File
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Cisco Systems, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,7 +37,7 @@ void nfapi_trace_dbg(nfapi_trace_level_t level, const char *format, ...);
// initialize the trace function to 0
void (*nfapi_trace_g)(nfapi_trace_level_t level, const char* format, ...) = &nfapi_trace_dbg;
nfapi_trace_level_t nfapi_trace_level_g = NFAPI_TRACE_INFO;
nfapi_trace_level_t nfapi_trace_level_g = NFAPI_TRACE_ERROR;
//nfapi_trace_level_t nfapi_trace_level_g = NFAPI_TRACE_WARN;
void nfapi_set_trace_level(nfapi_trace_level_t new_level)
@@ -47,6 +47,8 @@ void nfapi_set_trace_level(nfapi_trace_level_t new_level)
void nfapi_trace_dbg(nfapi_trace_level_t level, const char *format, ...)
{
if (level < nfapi_trace_level_g)
return;
char trace_buff[MAX_MSG_LENGTH + TRACE_HEADER_LENGTH];
va_list p_args;
struct timeval tv;
+31 -8
View File
@@ -2484,6 +2484,7 @@ static uint8_t pack_harq_indication_body_value(void *tlv, uint8_t **ppWritePacke
uint16_t i = 0;
uint16_t total_number_of_pdus = value->number_of_harqs;
assert(total_number_of_pdus <= NFAPI_HARQ_IND_MAX_PDU);
for(; i < total_number_of_pdus; ++i)
{
nfapi_harq_indication_pdu_t* pdu = &(value->harq_pdu_list[i]);
@@ -2536,6 +2537,7 @@ static uint8_t pack_crc_indication_body_value(void* tlv, uint8_t **ppWritePacked
uint16_t i = 0;
uint16_t total_number_of_pdus = value->number_of_crcs;
assert(total_number_of_pdus <= NFAPI_CRC_IND_MAX_PDU);
for(; i < total_number_of_pdus; ++i)
{
nfapi_crc_indication_pdu_t* pdu = &(value->crc_pdu_list[i]);
@@ -2596,6 +2598,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP
uint16_t total_number_of_pdus = value->number_of_pdus;
//printf("ULSCH:pdus:%d\n", total_number_of_pdus);
assert(total_number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
for(i = 0; i < total_number_of_pdus; ++i)
{
nfapi_rx_indication_pdu_t* pdu = &(value->rx_pdu_list[i]);
@@ -2619,6 +2622,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP
}
// Now update the structure to include the offset
assert(total_number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
for(i =0; i < total_number_of_pdus; ++i)
{
nfapi_rx_indication_pdu_t* pdu = &(value->rx_pdu_list[i]);
@@ -2634,6 +2638,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP
}
// Write out the pdu
assert(total_number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
for(i = 0; i < total_number_of_pdus; ++i)
{
nfapi_rx_indication_pdu_t* pdu = &(value->rx_pdu_list[i]);
@@ -2644,6 +2649,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP
}
// Write out the pdu data
assert(total_number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
for(i = 0; i < total_number_of_pdus; ++i)
{
uint16_t length = 0;
@@ -2837,6 +2843,7 @@ static uint8_t pack_sr_indication_body_value(void *tlv, uint8_t **ppWritePackedM
uint16_t i = 0;
uint16_t total_number_of_pdus = value->number_of_srs;
assert(total_number_of_pdus <= NFAPI_SR_IND_MAX_PDU);
for(; i < total_number_of_pdus; ++i)
{
nfapi_sr_indication_pdu_t* pdu = &(value->sr_pdu_list[i]);
@@ -2904,6 +2911,7 @@ static uint8_t pack_cqi_indication_body_value(void *tlv, uint8_t **ppWritePacked
uint16_t i = 0;
uint16_t offset = 2; // taking into account the number_of_cqis
uint16_t total_number_of_pdus = value->number_of_cqis;
assert(total_number_of_pdus <= NFAPI_CQI_IND_MAX_PDU);
for(i = 0; i < total_number_of_pdus; ++i)
{
nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]);
@@ -2932,6 +2940,7 @@ static uint8_t pack_cqi_indication_body_value(void *tlv, uint8_t **ppWritePacked
}
// Now update the structure to include the offset
assert(total_number_of_pdus <= NFAPI_CQI_IND_MAX_PDU);
for(i =0; i < total_number_of_pdus; ++i)
{
nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]);
@@ -2957,6 +2966,7 @@ static uint8_t pack_cqi_indication_body_value(void *tlv, uint8_t **ppWritePacked
}
// Write out the cqi information
assert(total_number_of_pdus <= NFAPI_CQI_IND_MAX_PDU);
for(i = 0; i < total_number_of_pdus; ++i)
{
nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]);
@@ -2979,6 +2989,7 @@ static uint8_t pack_cqi_indication_body_value(void *tlv, uint8_t **ppWritePacked
}
// Write out the cqi raw data
assert(total_number_of_pdus <= NFAPI_CQI_IND_MAX_PDU);
for(i = 0; i < total_number_of_pdus; ++i)
{
uint16_t length = 0;
@@ -6334,15 +6345,16 @@ static uint8_t unpack_harq_indication_body_value(void* tlv, uint8_t **ppReadPack
return 0;
}
value->harq_pdu_list = (nfapi_harq_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_harq_indication_pdu_t) * value->number_of_harqs, config);
assert(value->number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU);
value->harq_pdu_list = (nfapi_harq_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_harq_indication_pdu_t) * NFAPI_HARQ_IND_MAX_PDU, config);
if(value->harq_pdu_list == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate harq ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_harqs);
return 0;
}
uint8_t i = 0;
for(i = 0; i < value->number_of_harqs; ++i)
assert(value->number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU);
for (size_t i = 0; i < value->number_of_harqs; ++i)
{
nfapi_harq_indication_pdu_t* pdu = &(value->harq_pdu_list[i]);
if(pull16(ppReadPackedMsg, &pdu->instance_length, end) == 0)
@@ -6408,7 +6420,8 @@ static uint8_t unpack_crc_indication_body_value(void *tlv, uint8_t **ppReadPacke
if(value->number_of_crcs > 0)
{
value->crc_pdu_list = (nfapi_crc_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_crc_indication_pdu_t) * value->number_of_crcs, config);
assert(value->number_of_crcs <= NFAPI_CRC_IND_MAX_PDU);
value->crc_pdu_list = (nfapi_crc_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_crc_indication_pdu_t) * NFAPI_CRC_IND_MAX_PDU, config);
if(value->crc_pdu_list == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate crc ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_crcs);
@@ -6422,6 +6435,7 @@ static uint8_t unpack_crc_indication_body_value(void *tlv, uint8_t **ppReadPacke
uint8_t i = 0;
assert(value->number_of_crcs <= NFAPI_CRC_IND_MAX_PDU);
for(i = 0; i < value->number_of_crcs; ++i)
{
nfapi_crc_indication_pdu_t* pdu = &(value->crc_pdu_list[i]);
@@ -6500,7 +6514,8 @@ static uint8_t unpack_rx_indication_body_value(void *tlv, uint8_t **ppReadPacked
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);
assert(value->number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
value->rx_pdu_list = (nfapi_rx_indication_pdu_t *)nfapi_p7_allocate(sizeof(nfapi_rx_indication_pdu_t) * NFAPI_RX_IND_MAX_PDU, 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);
@@ -6533,6 +6548,7 @@ static uint8_t unpack_rx_indication_body_value(void *tlv, uint8_t **ppReadPacked
return 0;
}
assert(i <= NFAPI_RX_IND_MAX_PDU);
nfapi_rx_indication_pdu_t *pdu = &value->rx_pdu_list[i];
pdu->rx_ue_information.tl = generic_tl;
@@ -6588,6 +6604,7 @@ static uint8_t unpack_rx_indication_body_value(void *tlv, uint8_t **ppReadPacked
}
}
assert(value->number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
for (int i = 0; i < value->number_of_pdus; ++i)
{
nfapi_rx_indication_pdu_t *pdu = &value->rx_pdu_list[i];
@@ -6869,7 +6886,8 @@ static uint8_t unpack_sr_indication_body_value(void *tlv, uint8_t **ppReadPacked
if(value->number_of_srs > 0)
{
value->sr_pdu_list = (nfapi_sr_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_sr_indication_pdu_t) * value->number_of_srs, config);
assert(value->number_of_srs <= NFAPI_SR_IND_MAX_PDU);
value->sr_pdu_list = (nfapi_sr_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_sr_indication_pdu_t) * NFAPI_SR_IND_MAX_PDU, config);
if(value->sr_pdu_list == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate sr ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_srs);
@@ -6882,6 +6900,7 @@ static uint8_t unpack_sr_indication_body_value(void *tlv, uint8_t **ppReadPacked
}
uint8_t i = 0;
assert(value->number_of_srs <= NFAPI_SR_IND_MAX_PDU);
for(i = 0; i < value->number_of_srs; ++i)
{
nfapi_sr_indication_pdu_t* pdu = &(value->sr_pdu_list[i]);
@@ -6978,7 +6997,8 @@ static uint8_t unpack_cqi_indication_body_value(void* tlv, uint8_t **ppReadPack
if(value->number_of_cqis > 0)
{
value->cqi_pdu_list = (nfapi_cqi_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_cqi_indication_pdu_t) * value->number_of_cqis, config);
assert(value->number_of_cqis <= NFAPI_SR_IND_MAX_PDU);
value->cqi_pdu_list = (nfapi_cqi_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_cqi_indication_pdu_t) * NFAPI_SR_IND_MAX_PDU, config);
if(value->cqi_pdu_list == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate cqi ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_cqis);
@@ -6992,7 +7012,8 @@ static uint8_t unpack_cqi_indication_body_value(void* tlv, uint8_t **ppReadPack
if(value->number_of_cqis > 0)
{
value->cqi_raw_pdu_list = (nfapi_cqi_indication_raw_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_cqi_indication_raw_pdu_t) * value->number_of_cqis, config);
assert(value->number_of_cqis <= NFAPI_SR_IND_MAX_PDU);
value->cqi_raw_pdu_list = (nfapi_cqi_indication_raw_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_cqi_indication_raw_pdu_t) * NFAPI_SR_IND_MAX_PDU, config);
if(value->cqi_raw_pdu_list == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate raw cqi ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_cqis);
@@ -7005,6 +7026,7 @@ static uint8_t unpack_cqi_indication_body_value(void* tlv, uint8_t **ppReadPack
}
uint8_t i = 0;
assert(value->number_of_cqis <= NFAPI_CQI_IND_MAX_PDU);
for(i = 0; i < value->number_of_cqis; ++i)
{
nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]);
@@ -7057,6 +7079,7 @@ static uint8_t unpack_cqi_indication_body_value(void* tlv, uint8_t **ppReadPack
}
uint8_t idx = 0;
assert(value->number_of_cqis <= NFAPI_CQI_IND_MAX_PDU);
for(idx = 0; idx < value->number_of_cqis; ++idx)
{
if(value->cqi_pdu_list[idx].cqi_indication_rel8.tl.tag == NFAPI_CQI_INDICATION_REL8_TAG)
+1 -2
View File
@@ -18,9 +18,8 @@
#ifndef _PNF_H_
#define _PNF_H_
#include "nfapi_pnf_interface.h"
#include "nfapi/open-nFAPI/pnf/inc/pnf_p7.h"
#define NFAPI_MAX_PACKED_MESSAGE_SIZE 8192
typedef struct {
+117 -112
View File
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Cisco Systems, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -93,9 +93,9 @@ void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_nr_pnf_param_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_PARAM.request received\n");
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(nfapi_nr_pnf_param_request_t), &pnf->_public.codec_config) >= 0)
{
@@ -109,7 +109,7 @@ void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in IDLE state\n", __FUNCTION__);
nfapi_nr_pnf_param_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_RESPONSE;
@@ -121,7 +121,7 @@ void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -137,9 +137,9 @@ void pnf_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_pnf_param_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_PARAM.request received\n");
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(nfapi_pnf_param_request_t), &pnf->_public.codec_config) >= 0)
{
@@ -153,7 +153,7 @@ void pnf_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in IDLE state\n", __FUNCTION__);
nfapi_pnf_param_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_PARAM_RESPONSE;
@@ -165,7 +165,7 @@ void pnf_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -185,7 +185,7 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
nfapi_pnf_config_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_CONFIG.request received\n");
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0)
{
@@ -194,7 +194,7 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// delete the phy records
nfapi_pnf_phy_config_delete_all(&pnf->_public);
// create the phy records
if (req.pnf_phy_rf_config.tl.tag == NFAPI_PNF_PHY_RF_TAG)
{
@@ -203,14 +203,14 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
nfapi_pnf_phy_config_t* phy = (nfapi_pnf_phy_config_t*)malloc(sizeof(nfapi_pnf_phy_config_t));
memset(phy, 0, sizeof(nfapi_pnf_phy_config_t));
phy->state = NFAPI_PNF_PHY_IDLE;
phy->phy_id = req.pnf_phy_rf_config.phy_rf_config[i].phy_id;
nfapi_pnf_phy_config_add(&(pnf->_public), phy);
}
}
if(pnf->_public.pnf_config_req)
{
(pnf->_public.pnf_config_req)(&(pnf->_public), &req);
@@ -219,7 +219,7 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in correct state: %d\n", __FUNCTION__, pnf->_public.state);
nfapi_pnf_config_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE;
@@ -251,7 +251,7 @@ void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen
nfapi_nr_pnf_config_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_CONFIG.request received\n");
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0)
{
@@ -260,7 +260,7 @@ void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen
{
// delete the phy records
nfapi_pnf_phy_config_delete_all(&pnf->_public);
// create the phy records
if (req.pnf_phy_rf_config.tl.tag == NFAPI_PNF_PHY_RF_TAG)
{
@@ -269,14 +269,14 @@ void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen
{
nfapi_pnf_phy_config_t* phy = (nfapi_pnf_phy_config_t*)malloc(sizeof(nfapi_pnf_phy_config_t));
memset(phy, 0, sizeof(nfapi_pnf_phy_config_t));
phy->state = NFAPI_PNF_PHY_IDLE;
phy->phy_id = req.pnf_phy_rf_config.phy_rf_config[i].phy_id;
nfapi_pnf_phy_config_add(&(pnf->_public), phy);
}
}
if(pnf->_public.pnf_nr_config_req)
{
(pnf->_public.pnf_nr_config_req)(&(pnf->_public), &req);
@@ -285,7 +285,7 @@ void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in correct state: %d\n", __FUNCTION__, pnf->_public.state);
nfapi_nr_pnf_config_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE;
@@ -315,7 +315,7 @@ void pnf_handle_pnf_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
nfapi_pnf_start_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_START.request Received\n");
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0)
{
@@ -357,7 +357,7 @@ void pnf_nr_handle_pnf_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
nfapi_nr_pnf_start_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_START.request Received\n");
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0)
{
@@ -397,9 +397,9 @@ void pnf_handle_pnf_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_pnf_stop_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_STOP.request Received\n");
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0)
{
@@ -423,7 +423,7 @@ void pnf_handle_pnf_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
@@ -440,11 +440,11 @@ void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_param_request_t req;
nfapi_pnf_config_t* config = &(pnf->_public);
NFAPI_TRACE(NFAPI_TRACE_INFO, "PARAM.request received\n");
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -479,7 +479,7 @@ void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
resp.error_code = NFAPI_MSG_INVALID_CONFIG;
nfapi_pnf_param_resp(config, &resp);
}
}
else
{
@@ -495,7 +495,7 @@ void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
@@ -512,11 +512,11 @@ void pnf_nr_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_nr_param_request_scf_t req;
nfapi_pnf_config_t* config = &(pnf->_public);
NFAPI_TRACE(NFAPI_TRACE_INFO, "PARAM.request received\n");
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -551,7 +551,7 @@ void pnf_nr_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
resp.error_code = NFAPI_MSG_INVALID_CONFIG;
nfapi_nr_pnf_param_resp(config, &resp);
}
}
else
{
@@ -567,7 +567,7 @@ void pnf_nr_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
@@ -587,9 +587,9 @@ void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
nfapi_config_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "CONFIG.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -639,7 +639,7 @@ void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -659,9 +659,9 @@ void pnf_nr_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
nfapi_nr_config_request_scf_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "CONFIG.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -681,7 +681,7 @@ void pnf_nr_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
(config->nr_config_req)(config, phy, &req);
}
}
else
@@ -718,7 +718,7 @@ void pnf_nr_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -734,11 +734,11 @@ void pnf_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_start_request_t req;
nfapi_pnf_config_t* config = &(pnf->_public);
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() START.request received state:%d\n", __FUNCTION__, config->state);
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -788,7 +788,7 @@ void pnf_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
@@ -805,11 +805,11 @@ void pnf_nr_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_nr_start_request_scf_t req;
nfapi_pnf_config_t* config = &(pnf->_public);
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() START.request received state:%d\n", __FUNCTION__, config->state);
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -859,7 +859,7 @@ void pnf_nr_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
@@ -878,9 +878,9 @@ void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
nfapi_stop_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "STOP.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -930,10 +930,10 @@ void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
@@ -949,9 +949,9 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
nfapi_nr_stop_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "STOP.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -1001,10 +1001,10 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
@@ -1020,9 +1020,9 @@ void pnf_handle_measurement_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
nfapi_measurement_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "MEASUREMENT.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -1072,7 +1072,7 @@ void pnf_handle_measurement_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -1087,13 +1087,13 @@ void pnf_handle_rssi_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
{
nfapi_rssi_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "RSSI.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message
if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
@@ -1143,10 +1143,10 @@ void pnf_handle_rssi_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
@@ -1159,11 +1159,11 @@ void pnf_handle_cell_search_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_cell_search_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "CELL_SEARCH.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
@@ -1212,7 +1212,7 @@ void pnf_handle_cell_search_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -1231,9 +1231,9 @@ void pnf_handle_broadcast_detect_request(pnf_t* pnf, void *pRecvMsg, int recvMsg
nfapi_broadcast_detect_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "BROADCAST_DETECT.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
@@ -1282,7 +1282,7 @@ void pnf_handle_broadcast_detect_request(pnf_t* pnf, void *pRecvMsg, int recvMsg
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
@@ -1298,11 +1298,11 @@ void pnf_handle_system_information_schedule_request(pnf_t* pnf, void *pRecvMsg,
else
{
nfapi_system_information_schedule_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "SYSTEM_INFORMATION_SCHEDULE.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
@@ -1351,7 +1351,7 @@ void pnf_handle_system_information_schedule_request(pnf_t* pnf, void *pRecvMsg,
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -1368,9 +1368,9 @@ void pnf_handle_system_information_request(pnf_t* pnf, void *pRecvMsg, int recvM
nfapi_system_information_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "SYSTEM_INFORMATION.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
@@ -1419,7 +1419,7 @@ void pnf_handle_system_information_request(pnf_t* pnf, void *pRecvMsg, int recvM
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -1435,11 +1435,11 @@ void pnf_handle_nmm_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
else
{
nfapi_nmm_stop_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "NMM_STOP.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
@@ -1488,7 +1488,7 @@ void pnf_handle_nmm_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
@@ -1504,21 +1504,21 @@ void pnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_t* pnf, uin
else
{
nfapi_pnf_config_t* config = &(pnf->_public);
if(config->allocate_p4_p5_vendor_ext)
{
uint16_t msg_size;
nfapi_p4_p5_message_header_t* msg = config->allocate_p4_p5_vendor_ext(message_id, &msg_size);
if(msg == 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n");
return;
}
int unpack_result = nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, msg, msg_size, &config->codec_config);
if(unpack_result == 0)
{
if(config->vendor_ext)
@@ -1528,10 +1528,10 @@ void pnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_t* pnf, uin
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(config->deallocate_p4_p5_vendor_ext)
config->deallocate_p4_p5_vendor_ext(msg);
}
}
}
@@ -1732,8 +1732,8 @@ void pnf_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len)
{
int packed_len = nfapi_nr_p5_message_pack(msg, msg_len,
pnf->tx_message_buffer,
sizeof(pnf->tx_message_buffer),
pnf->tx_message_buffer,
sizeof(pnf->tx_message_buffer),
&pnf->_public.codec_config);
if (packed_len < 0)
@@ -1749,8 +1749,8 @@ int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* ms
int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len)
{
int packed_len = nfapi_p5_message_pack(msg, msg_len,
pnf->tx_message_buffer,
sizeof(pnf->tx_message_buffer),
pnf->tx_message_buffer,
sizeof(pnf->tx_message_buffer),
&pnf->_public.codec_config);
if (packed_len < 0)
@@ -1765,8 +1765,8 @@ int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg,
int pnf_pack_and_send_p4_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len)
{
int packed_len = nfapi_p4_message_pack(msg, msg_len,
pnf->tx_message_buffer,
sizeof(pnf->tx_message_buffer),
pnf->tx_message_buffer,
sizeof(pnf->tx_message_buffer),
&pnf->_public.codec_config);
if (packed_len < 0)
@@ -1797,14 +1797,14 @@ int pnf_connect(pnf_t* pnf)
NFAPI_TRACE(NFAPI_TRACE_INFO, "Starting P5 PNF connection to VNF at %s:%u\n", pnf->_public.vnf_ip_addr, pnf->_public.vnf_p5_port);
// todo split the vnf address list. currently only supporting 1
struct addrinfo hints, *servinfo;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM; // For SCTP we are only interested in SOCK_STREAM
// todo : allow the client to restrict IPV4 or IPV6
// todo : randomize which address to connect to?
char port_str[8];
snprintf(port_str, sizeof(port_str), "%d", pnf->_public.vnf_p5_port);
if(getaddrinfo(pnf->_public.vnf_ip_addr, port_str, &hints, &servinfo) != 0)
@@ -1822,7 +1822,7 @@ int pnf_connect(pnf_t* pnf)
char* family = "Unknown";
char* address = "Unknown";
char _addr[128];
if(p->ai_family == AF_INET6)
{
family = "IPV6";
@@ -1886,7 +1886,7 @@ int pnf_connect(pnf_t* pnf)
}
else
{
// Create an IP socket point
// Create an IP socket point
if ((pnf->p5_sock = socket(p->ai_family, SOCK_STREAM, IPPROTO_IP)) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P5 socket errno: %d\n", errno);
@@ -1894,12 +1894,12 @@ int pnf_connect(pnf_t* pnf)
return -1;
}
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "P5 socket created...\n");
if (connect(pnf->p5_sock, p->ai_addr, p->ai_addrlen ) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After connect (address:%s port:%d) errno: %d\n",
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After connect (address:%s port:%d) errno: %d\n",
pnf->_public.vnf_ip_addr, pnf->_public.vnf_p5_port, errno);
if(errno == EINVAL)
@@ -1970,14 +1970,16 @@ int pnf_connect(pnf_t* pnf)
int pnf_send_message(pnf_t* pnf, uint8_t *msg, uint32_t len, uint16_t stream)
{
if (pnf->sctp)
{
#if 0
printf("\nPNF SENDS: \n");
for(int i=0; i<len; i++){
printf("%d", msg[i]);
}
printf("\n");
#endif
if (sctp_sendmsg(pnf->p5_sock, msg, len, NULL, 0, 42/*config->sctp_stream_number*/, 0, stream/*P5_STREAM_ID*/, 0, 0) < 0)
{
@@ -2069,12 +2071,14 @@ int pnf_read_dispatch_message(pnf_t* pnf)
}
else
{
#if 0
// print the received message
printf("\n MESSAGE RECEIVED: \n");
for(int i=0; i<message_size; i++){
printf("%d", read_buffer[i]);
}
printf("\n");
#endif
if (flags & MSG_NOTIFICATION)
{
@@ -2198,12 +2202,14 @@ int pnf_nr_read_dispatch_message(pnf_t* pnf)
}
else
{
#if 0
// print the received message
printf("\n MESSAGE RECEIVED: \n");
for(int i=0; i<message_size; i++){
printf("%d", read_buffer[i]);
}
printf("\n");
#endif
if (flags & MSG_NOTIFICATION)
{
@@ -2275,7 +2281,7 @@ int pnf_message_pump(pnf_t* pnf)
selectRetval = select(pnf->p5_sock+1, &rfds, NULL, NULL, &timeout);
if(selectRetval == 0)
{
{
// timeout
continue;
}
@@ -2336,7 +2342,7 @@ int pnf_nr_message_pump(pnf_t* pnf)
selectRetval = select(pnf->p5_sock+1, &rfds, NULL, NULL, &timeout);
if(selectRetval == 0)
{
{
// timeout
continue;
}
@@ -2376,4 +2382,3 @@ int pnf_nr_message_pump(pnf_t* pnf)
return 0;
}
+8 -9
View File
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Cisco Systems, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,11 +32,11 @@ nfapi_pnf_config_t* nfapi_pnf_config_create()
memset(_this, 0, sizeof(pnf_t));
_this->sctp = 1; // enable sctp
_this->_public.vnf_p5_port = NFAPI_P5_SCTP_PORT;
_this->_public.malloc = &malloc;
_this->_public.free = &free;
_this->_public.free = &free;
_this->_public.codec_config.allocate = &malloc;
_this->_public.codec_config.deallocate = &free;
@@ -265,7 +265,7 @@ int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_param_response_t* res
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
return -1;
}
pnf_t* _this = (pnf_t*)(config);
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_param_response_t));
@@ -279,7 +279,7 @@ int nfapi_nr_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
return -1;
}
pnf_t* _this = (pnf_t*)(config);
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_param_response_scf_t));
@@ -591,4 +591,3 @@ int nfapi_pnf_vendor_extension(nfapi_pnf_config_t* config, nfapi_p4_p5_message_h
return pnf_pack_and_send_p5_message(_this, msg, msg_len);
}
+8 -1
View File
@@ -2947,12 +2947,19 @@ void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time)
}
// read the segment
recvfrom_result = recvfrom(pnf_p7->p7_sock, pnf_p7->rx_message_buffer, header.message_length, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size);
recvfrom_result = recvfrom(pnf_p7->p7_sock, pnf_p7->rx_message_buffer, pnf_p7->rx_message_buffer_size,
MSG_DONTWAIT | MSG_TRUNC, (struct sockaddr*)&remote_addr, &remote_addr_size);
now_hr_time = pnf_get_current_time_hr(); //DJP - moved to here - get closer timestamp???
if(recvfrom_result > 0)
{
if (recvfrom_result != header.message_length)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(%d). Received unexpected number of bytes. %d != %d",
__FUNCTION__, __LINE__, recvfrom_result, header.message_length);
break;
}
pnf_handle_p7_message(pnf_p7->rx_message_buffer, recvfrom_result, pnf_p7, now_hr_time);
//printf("\npnf_handle_p7_message sfn=%d,slot=%d\n",pnf_p7->sfn,pnf_p7->slot);
}
+1
View File
@@ -18,6 +18,7 @@
#ifndef _VNF_H_
#define _VNF_H_
#include "pnf_p7.h"
#include "nfapi_vnf_interface.h"
typedef struct
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Cisco Systems, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,14 +22,12 @@
#include "nfapi_nr_interface.h"
#include "debug.h"
#include "netinet/in.h"
#if defined(__cplusplus)
extern "C" {
#endif
#define NFAPI_MAX_PACKED_MESSAGE_SIZE 8192
/*! The nfapi VNF phy configuration information
*/
@@ -108,79 +106,79 @@ typedef struct nfapi_vnf_config
/*! Configuration options for the p4 p5 pack unpack functions */
nfapi_p4_p5_codec_config_t codec_config;
/*! Optional user defined data that will be avaliable in the callbacks*/
void* user_data;
/*! \brief Callback indicating that a pnf has established connection
/*! \brief Callback indicating that a pnf has established connection
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 used to indicate this pnf p5 connection
*
* The client is expected to send the PNF_PARAM.request in response to
*
* The client is expected to send the PNF_PARAM.request in response to
* the connection indication
*
*
* \todo Do we need to send the address information of the PNF?
*/
int (*pnf_nr_connection_indication)(nfapi_vnf_config_t* config, int p5_idx);
int (*pnf_connection_indication)(nfapi_vnf_config_t* config, int p5_idx);
/*! \brief Callback indicating that a pnf has lost connection
/*! \brief Callback indicating that a pnf has lost connection
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 used to indicate this pnf p5 connection
*
* The p5_idx may be used for future new p5 connections
*
* The client is responsiable for communicating to the p7 instance(s) that
* may be associated with this p5 that they should be deleted using the
* may be associated with this p5 that they should be deleted using the
* nfapi_vnf_p7_del_pnf functon
*
*
*/
int (*pnf_disconnect_indication)(nfapi_vnf_config_t* config, int p5_idx);
// p5 interface functions
/*! \brief A callback to handle the PNF_PARAM.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded PNF_PARAM.response. This will
* have been allocated on the stack.
* \param resp A data structure for the decoded PNF_PARAM.response. This will
* have been allocated on the stack.
* \return not currently used.
*
*
* The PNF_PARAM.resp contains the capability of the PNF identified by the
* p5_idx.
*
* p5_idx.
*
* The client is expected to send the PNF_CONFIG.request after receiving the
* PNF_PARAM.resp. This can be done in the call back.
* PNF_PARAM.resp. This can be done in the call back.
*
* It is expected that the client when building the PNF_CONFIG.request will
* used the nfapi_vnf_allocate_phy() to allocate unique phy id for each FAPI
* instance the client wishes to create.
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
int (*pnf_nr_param_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_param_response_t* resp);
int (*pnf_param_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_response_t* resp);
/*! A callback for the PNF_CONFIG.resp
/*! A callback for the PNF_CONFIG.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded PNF_CONFIG.response. This will
* have been allocated on the stack.
* \param resp A data structure for the decoded PNF_CONFIG.response. This will
* have been allocated on the stack.
* \return not currently used.
*
* The PNF_CONFIG.resp contains the result of the PNF_CONFIG.request for the
* PNF identified by the p5_idx.
*
*
* The PNF_CONFIG.resp contains the result of the PNF_CONFIG.request for the
* PNF identified by the p5_idx.
*
* The client is expected to send the PNF_START.request after receiving the
* PNF_PARAM.resp. This can be done in the call back.
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* PNF_PARAM.resp. This can be done in the call back.
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
@@ -190,19 +188,19 @@ typedef struct nfapi_vnf_config
/*! A callback for the PNF_START.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded PNF_START.response. This will
* have been allocated on the stack.
* \param resp A data structure for the decoded PNF_START.response. This will
* have been allocated on the stack.
* \return not currently used.
*
* The PNF_START.resp contains the result of the PNF_START.request for the
* PNF identified by the p5_idx.
*
* The client is expected to send the PARAM.request for each FAPI instance
* that has been created in the PNF.
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The PNF_START.resp contains the result of the PNF_START.request for the
* PNF identified by the p5_idx.
*
* The client is expected to send the PARAM.request for each FAPI instance
* that has been created in the PNF.
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
@@ -212,63 +210,63 @@ typedef struct nfapi_vnf_config
/*! A callback for the PNF_STOP.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded PNF_STOP.response. This will
* have been allocated on the stack.
* \param resp A data structure for the decoded PNF_STOP.response. This will
* have been allocated on the stack.
* \return not currently used.
*
* The PNF_STOP.response contains the result of the PNF_STOP.request for the
* PNF identified by the p5_idx.
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The PNF_STOP.response contains the result of the PNF_STOP.request for the
* PNF identified by the p5_idx.
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
int (*pnf_stop_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_stop_response_t* resp);
/*! A callback for the PARAM.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded PARAM.resposne. This will
* have been allocated on the stack.
* \param resp A data structure for the decoded PARAM.resposne. This will
* have been allocated on the stack.
* \return not currently used.
*
*
* The PARAM.request contains the capabilities of the FAPI instance identified
* by the phy_id
*
* The client is expected to send the CONFIG.request after receiving the
* PARAM.response. This can be done in the call back. The PARAM.response
* contains the PNF P7 address (ipv4 or ipv6) and port. This information
* PARAM.response. This can be done in the call back. The PARAM.response
* contains the PNF P7 address (ipv4 or ipv6) and port. This information
* is used when calling the nfapi_vnf_p7_add_pnf()
*
* The client is responsible for identifing the VNF P7 ip address
*
* The client is responsible for identifing the VNF P7 ip address
* (ipv4 or ipv6) and port for the VNF P7 entity which will be sent to the
* PNF P7 entity. That endpoint should be valid before send the
* PNF P7 entity. That endpoint should be valid before send the
* CONFIG.request.
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
int (*param_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t* resp);
int (*nr_param_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_param_response_scf_t* resp);
/*! A callback for the CONFIG.response
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded CONFIG.response This will
* have been allocated on the stack.
* \param resp A data structure for the decoded CONFIG.response This will
* have been allocated on the stack.
* \return not currently used.
*
*
* The CONFIG.response contains the result of the CONFIG.request
*
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
@@ -278,173 +276,173 @@ typedef struct nfapi_vnf_config
/*! A callback for the START.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded START.response This will
* have been allocated on the stack.
* \param resp A data structure for the decoded START.response This will
* have been allocated on the stack.
* \return not currently used.
*
*
* The START.response contains the result of the START.request
*
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
int (*start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp);
int (*nr_start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_start_response_scf_t* resp);
/*! A callback for the STOP.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded STOP.response This will
* have been allocated on the stack.
* \param resp A data structure for the decoded STOP.response This will
* have been allocated on the stack.
* \return not currently used.
*
*
* The STOP.response contains the result of the STOP.request
*
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*stop_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_stop_response_t* resp);
/*! A callback for the MEASUREMENT.resp
/*! A callback for the MEASUREMENT.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded MEASUREMENT.response This will
* have been allocated on the stack.
* \param resp A data structure for the decoded MEASUREMENT.response This will
* have been allocated on the stack.
* \return not currently used.
*
*
* The MEASUREMENT.response contains the result of the MEASUREMENT.request
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The resp may contain pointers to dyanmically allocated sub structures
* such as the vendor_extention. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*measurement_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_measurement_response_t* resp);
// p4 interface functions
/*! A callback for the RSSI.resp
/*! A callback for the RSSI.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded RSSI.response This will
* have been allocated on the stack.
* \param resp A data structure for the decoded RSSI.response This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*rssi_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_rssi_response_t* resp);
/*! A callback for the RSSI.indication
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded RSSI.indication This will
* have been allocated on the stack.
* \param resp A data structure for the decoded RSSI.indication This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*rssi_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_rssi_indication_t* ind);
/*! A callback for the CELL_SEARCH.response
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded CELL_SEARCH.response This will
* have been allocated on the stack.
* \param resp A data structure for the decoded CELL_SEARCH.response This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*cell_search_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_cell_search_response_t* resp);
/*! A callback for the CELL_SEARCH.indication
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded CELL_SEARCH.indication This will
* have been allocated on the stack.
* \param resp A data structure for the decoded CELL_SEARCH.indication This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*cell_search_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_cell_search_indication_t* ind);
/*! A callback for the BROADCAST_DETECT.response
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded BROADCAST_DETECT.response This will
* have been allocated on the stack.
* \param resp A data structure for the decoded BROADCAST_DETECT.response This will
* have been allocated on the stack.
* \return not currently used. */
int (*broadcast_detect_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_broadcast_detect_response_t* resp);
/*! A callback for the BROADCAST_DETECT.indication
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded BROADCAST_DETECT.indication This will
* have been allocated on the stack.
* \return not currently used.
* \param resp A data structure for the decoded BROADCAST_DETECT.indication This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*broadcast_detect_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_broadcast_detect_indication_t* ind);
/*! A callback for the SYSTEM_INFORMATION_SCHEUDLE.response
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded SYSTEM_INFORMATION_SCHEUDLE.response This will
* have been allocated on the stack.
* \return not currently used.
* \param resp A data structure for the decoded SYSTEM_INFORMATION_SCHEUDLE.response This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*system_information_schedule_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_schedule_response_t* resp);
/*! A callback for the SYSTEM_INFORMATION_SCHEUDLE.indication
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded SYSTEM_INFORMATION_SCHEUDLE.indication This will
* have been allocated on the stack.
* \return not currently used.
* \param resp A data structure for the decoded SYSTEM_INFORMATION_SCHEUDLE.indication This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*system_information_schedule_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_schedule_indication_t* ind);
/*! A callback for the SYSTEM_INFORMATION.response
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded SYSTEM_INFORMATION.response This will
* have been allocated on the stack.
* \return not currently used.
* \param resp A data structure for the decoded SYSTEM_INFORMATION.response This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*system_information_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_response_t* resp);
/*! A callback for the SYSTEM_INFORMATION.indication
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded SYSTEM_INFORMATION.indication This will
* have been allocated on the stack.
* \return not currently used.
* \param resp A data structure for the decoded SYSTEM_INFORMATION.indication This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*system_information_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_indication_t* ind);
/*! A callback for the NMM_STOP.response
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded NMM_STOP.response This will
* have been allocated on the stack.
* \return not currently used.
* \param resp A data structure for the decoded NMM_STOP.response This will
* have been allocated on the stack.
* \return not currently used.
*/
int (*nmm_stop_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nmm_stop_response_t* resp);
/*! A callback for any vendor extension message received
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
* \param resp A data structure for the decoded vendor extention message
* \return not currently used.
* \param resp A data structure for the decoded vendor extention message
* \return not currently used.
*/
int (*vendor_ext)(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg);
/*! A callback to allocate vendor extension messages
* \param message_id The message is taken from the message header
* \param msg_size The is the vendor extention message that has been allocated.
* \param msg_size The is the vendor extention message that has been allocated.
* The callee must set this value
* \return A pointer to an allocated vendor extention message
*/
nfapi_p4_p5_message_header_t* (*allocate_p4_p5_vendor_ext)(uint16_t message_id, uint16_t* msg_size);
/*! A callback to deallocate vendor extension messages
* \param header A pointer to an allocated vendor extention message
*/
@@ -453,8 +451,8 @@ typedef struct nfapi_vnf_config
} nfapi_vnf_config_t;
/*! Creates and initialise the vnf config structure before use
@@ -467,24 +465,24 @@ nfapi_vnf_config_t* nfapi_vnf_config_create(void);
void nfapi_vnf_config_destory(nfapi_vnf_config_t* config);
/*! Start the VNF library.
/*! Start the VNF library.
* \param config A pointer to a vnf config
* \return 0 means success, -1 failure
*
* The config should be initailize with port the vnf should listen on and
* the callback set to functions that will be called when a nFAPI message is
* the callback set to functions that will be called when a nFAPI message is
* recevied before calling nfapi_vnf_start.
*
*
* This function will not return untill nfapi_vnf_stop is called
*/
int nfapi_nr_vnf_start(nfapi_vnf_config_t* config);
int nfapi_vnf_start(nfapi_vnf_config_t* config);
/*! Stop the VNF library.
/*! Stop the VNF library.
* \param config A pointer to a vnf config
* \return 0 means success, -1 failure
*
*
* This function will cause the nfapi_vnf_start function to return
*/
int nfapi_vnf_stop(nfapi_vnf_config_t* config);
@@ -494,7 +492,7 @@ int nfapi_vnf_stop(nfapi_vnf_config_t* config);
* \param p5_idx The P5 index return by the callbacks
* \param phy_id A pointer to a phy_id that will be set by this function
* \return 0 means success, -1 failure
*
*
* Called before nfapi_vnf_config_req to allocate a vnf phy instance. This
* function will return unqiue phy_id to be used for this identify the phy
*
@@ -655,16 +653,16 @@ typedef struct nfapi_vnf_p7_config
* If not set the vnf p7 library will use malloc
*/
void* (*malloc)(size_t size);
/*! A user define callback to override the default memory deallocation
* \param ptr Pointer to a memory block to deallocate
*
* If not set the vnf p7 library will use free
*/
void (*free)(void*);
/*! A user define callback to handle trace from the pnf
* \param level The trace level
* \param level The trace level
* \param message The trace string
*/
void (*trace)(nfapi_trace_level_t level, const char* message, ...);
@@ -706,172 +704,172 @@ typedef struct nfapi_vnf_p7_config
*
* \todo Need some way the tell the VNF how long it has
*/
int (*subframe_indication)(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf);
int (*slot_indication)(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn, uint16_t slot);
/*! A callback for the HARQ.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded HARQ.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded HARQ.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*harq_indication)(struct nfapi_vnf_p7_config* config, nfapi_harq_indication_t* ind);
/*! A callback for the CRC.ind
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded CRC.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded CRC.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*crc_indication)(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_t* ind);
/*! A callback for the RX_ULSCH.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded RX_ULSCH.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded RX_ULSCH.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*
* Note that the rx_indication may hold one or many uplink pdus in the
* Note that the rx_indication may hold one or many uplink pdus in the
* ind.rx_indication_body.rx_pdu_list
*/
*/
int (*rx_indication)(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ind);
/*! A callback for the RACH.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded RACH.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded RACH.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*rach_indication)(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind);
/*! A callback for the SRS.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded SRS.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded SRS.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*srs_indication)(struct nfapi_vnf_p7_config* config, nfapi_srs_indication_t* ind);
/*! A callback for the RX_SR.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded RX_SR.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded RX_SR.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*sr_indication)(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* ind);
/*! A callback for the RX_CQI.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded RX_CQI.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded RX_CQI.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*cqi_indication)(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_t* ind);
/*! A callback for the LBT_DL.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded LBT_DL.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded LBT_DL.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
*/
int (*lbt_dl_indication)(struct nfapi_vnf_p7_config* config, nfapi_lbt_dl_indication_t* ind);
/*! A callback for the NB_HARQ.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded LBT_DL.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded LBT_DL.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
int (*nb_harq_indication)(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind);
*/
int (*nb_harq_indication)(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind);
/*! A callback for the NRACH.indication
* \param config A pointer to the vnf p7 configuration
* \param ind A data structure for the decoded LBT_DL.indication This will
* have been allocated on the stack.
* \param ind A data structure for the decoded LBT_DL.indication This will
* have been allocated on the stack.
* \return not currently used.
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
*
* The ind may contain pointers to dyanmically allocated sub structures
* such as the pdu. The dyanmically allocated structure will
* be deallocated on return. If the client wishes to 'keep' the structures
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
int (*nrach_indication)(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind);
*/
int (*nrach_indication)(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind);
/*! A callback for any vendor extension messages
* \param config A pointer to the vnf p7 configuration
* \param msg A data structure for the decoded vendor extention message allocated
* using the allocate_p7_vendor_ext callback
* \return not currently used.
*/
*/
int (*vendor_ext)(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg);
/*! Optional userdata that will be passed back in the callbacks*/
void* user_data;
/*! A callback to allocate a memory for a vendor extension message
* \param message_id The message is taken from the p7 message header
* \param msg_size The is the vendor extention message that has been allocated.
* \param msg_size The is the vendor extention message that has been allocated.
* The callee must set this value
* \return A pointer to an allocated vendor extention message
*/
nfapi_p7_message_header_t* (*allocate_p7_vendor_ext)(uint16_t message_id, uint16_t* msg_size);
/*! A callback to deallocate a vendor extension message
* \param header A pointer to an allocated vendor extention message
*/
@@ -890,7 +888,7 @@ nfapi_vnf_p7_config_t* nfapi_vnf_p7_config_create(void);
*
* The pointer to the config will not long be valid after this call
*/
void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config);
/*! Start the VNF P7 library.
@@ -898,17 +896,17 @@ void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config);
* \return A status value. 0 equal success, -1 indicates failure
*
* This function is blocking and will not return until the nfapi_vnf_p7_stop
* function is called.
* function is called.
*/
int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config);
int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config);
/*! Stop the VNF P7 library.
/*! Stop the VNF P7 library.
* \param config A pointer to an vnf p7 configuration structure
* \return A status value. 0 equal success, -1 indicates failure
*
*
* This function will cause the nfapi_vnf_p7_start function to return
*/
int nfapi_vnf_p7_stop(nfapi_vnf_p7_config_t* config);
@@ -929,7 +927,7 @@ int nfapi_vnf_p7_release_pdu(nfapi_vnf_p7_config_t* config, void*);
/*! Add a vnf p7 instance to the vnf p7 module
* \param config A pointer to the vnf p7 configuration
* \param pnf_p7_addr The udp address the pnf p7 entity has chosen
* \param pnf_p7_addr The udp address the pnf p7 entity has chosen
* \param pnf_p7_port The udp port the pnf p7 entity has chosen
* \param phy_id The unique phy id for the pnf p7 entity
* \return A status value. 0 equal success, -1 indicates failure
@@ -953,7 +951,7 @@ int nfapi_vnf_p7_del_pnf(nfapi_vnf_p7_config_t* config, int phy_id);
* \param config A pointer to the vnf p7 configuration
* \param req A data structure for the decoded DL_CONFIG.request.
* \return A status value. 0 equal success, -1 indicates failure
*
*
* The caller is responsiable for memory management of any pointers set in the req, which
* may be released after this function call has returned or at a later pointer
*/
@@ -964,7 +962,7 @@ int nfapi_vnf_p7_nr_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_nr_dl_tti
* \param config A pointer to the vnf p7 configuration
* \param req A data structure for the decoded UL_CONFIG.request.
* \return A status value. 0 equal success, -1 indicates failure
*
*
* The caller is responsiable for memory management of any pointers set in the req, which
* may be released after this function call has returned or at a later pointer
*/
@@ -974,7 +972,7 @@ int nfapi_vnf_p7_ul_tti_req(nfapi_vnf_p7_config_t* config, nfapi_nr_ul_tti_reque
* \param config A pointer to the vnf p7 configuration
* \param req A data structure for the decoded HI_DCI0.request.
* \return A status value. 0 equal success, -1 indicates failure
*
*
* The caller is responsiable for memory management of any pointers set in the req, which
* may be released after this function call has returned or at a later pointer
*/
@@ -984,7 +982,7 @@ int nfapi_vnf_p7_ul_dci_req(nfapi_vnf_p7_config_t* config, nfapi_nr_ul_dci_reque
* \param config A pointer to the vnf p7 configuration
* \param req A data structure for the decoded HI_DCI0.request.
* \return A status value. 0 equal success, -1 indicates failure
*
*
* The caller is responsiable for memory management of any pointers set in the req, which
* may be released after this function call has returned or at a later pointer
*/
@@ -994,7 +992,7 @@ int nfapi_vnf_p7_tx_data_req(nfapi_vnf_p7_config_t* config, nfapi_nr_tx_data_req
* \param config A pointer to the vnf p7 configuration
* \param req A data structure for the decoded LBT_DL_CONFIG.request.
* \return A status value. 0 equal success, -1 indicates failure
*
*
* The caller is responsiable for memory management of any pointers set in the req, which
* may be released after this function call has returned or at a later pointer
*/
@@ -1004,7 +1002,7 @@ int nfapi_vnf_p7_lbt_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_lbt_dl_c
* \param config A pointer to the vnf p7 configuration
* \param msg A data structure for the decoded vendor extention message
* \return A status value. 0 equal success, -1 indicates failure
*
*
* The caller is responsiable for memory management of any pointers set in the req, which
* may be released after this function call has returned or at a later pointer
*/
+11 -4
View File
@@ -23,9 +23,14 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include "vnf_p7.h"
#ifdef NDEBUG
# warning assert is disabled
#endif
#define SYNC_CYCLE_COUNT 2
void* vnf_p7_malloc(vnf_p7_t* vnf_p7, size_t size)
@@ -818,6 +823,7 @@ void vnf_handle_rx_ulsch_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vn
}
}
assert(ind.rx_indication_body.number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
uint16_t i = 0;
for(i = 0; i < ind.rx_indication_body.number_of_pdus; ++i)
{
@@ -2446,9 +2452,9 @@ int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom returned 0\n");
}
else if(recvfrom_result != header.message_length)
else if(recvfrom_result != -1 && recvfrom_result != header.message_length)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "did not receive the entire message %d %d\n", 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);
@@ -2500,8 +2506,9 @@ void vnf_p7_release_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header)
case NFAPI_RX_ULSCH_INDICATION:
{
nfapi_rx_indication_t* rx_ind = (nfapi_rx_indication_t*)(header);
uint16_t i = 0;
for(i = 0; i < rx_ind->rx_indication_body.number_of_pdus; ++i)
size_t number_of_pdus = rx_ind->rx_indication_body.number_of_pdus;
assert(number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
for(size_t i = 0; i < number_of_pdus; ++i)
{
vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list[i].data);
}