Commit da9fe96e authored by Rúben Soares Silva's avatar Rúben Soares Silva

Move general FAPI P5 message pack procedure from fapi_vnf_p5 into FAPI P5 library.

Implement FAPI P5 message unpack, as well as message length check function procedure in FAPI P5 library.
Update check_nr_unpack_length in nfapi_p5.c to reference FAPI P5 message length check function.
parent 350746f4
......@@ -622,61 +622,6 @@ int aerial_nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t *config)
return 0;
}
int fapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t *config){
nfapi_p4_p5_message_header_t *pMessageHeader = pMessageBuf;
uint8_t *pWritePackedMessage = pPackedBuf;
uint32_t packedMsgLen;
//uint16_t packedMsgLen16;
if (pMessageBuf == NULL || pPackedBuf == NULL) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 Pack supplied pointers are null\n");
return -1;
}
uint8_t *pPackMessageEnd = pPackedBuf + packedBufLen;
uint8_t *pPackedLengthField = &pWritePackedMessage[4];
uint8_t *pPacketBodyField = &pWritePackedMessage[8];
uint8_t *pPacketBodyFieldStart = &pWritePackedMessage[8];
pack_nr_p5_message_body(pMessageHeader, &pPacketBodyField, pPackMessageEnd, config);
// PHY API message header
push8(1, &pWritePackedMessage, pPackMessageEnd); // Number of messages
push8(0, &pWritePackedMessage, pPackMessageEnd); // Opaque handle
// PHY API Message structure
push16(pMessageHeader->message_id, &pWritePackedMessage, pPackMessageEnd); // Message type ID
if(1==1) {
// check for a valid message length
packedMsgLen = get_packed_msg_len((uintptr_t)pPacketBodyFieldStart, (uintptr_t)pPacketBodyField);
packedMsgLen-=1;
if(pMessageHeader->message_id == NFAPI_NR_PHY_MSG_TYPE_START_REQUEST){
//START.request doesn't have a body, length is 0
packedMsgLen = 0;
}else if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message 0x%02x length error %d, buffer supplied %d\n",pMessageHeader->message_id, packedMsgLen, packedBufLen);
return -1;
} else {
}
// Update the message length in the header
if(!push32(packedMsgLen, &pPackedLengthField, pPackMessageEnd))
return -1;
// return the packed length
return (packedMsgLen);
} else {
// Failed to pack the meassage
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 Failed to pack message\n");
return -1;
}
}
int oai_fapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req)
{
nfapi_vnf_p7_config_t *p7_config = aerial_vnf.p7_vnfs[0].config;
......
......@@ -65,7 +65,6 @@ uint8_t aerial_unpack_nr_param_response(uint8_t **ppReadPackedMsg, uint8_t *end,
uint8_t aerial_unpack_nr_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
int aerial_pnf_nr_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx);
int aerial_nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t *config);
int fapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
int oai_fapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req);
int oai_fapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req);
......
......@@ -40,8 +40,6 @@
#include "nfapi.h"
#include "assertions.h"
#define DEBUG_FAPI_NFAPI_MSGS 0
typedef struct {
uint8_t num_msg;
uint8_t opaque_handle;
......@@ -49,4 +47,23 @@ typedef struct {
uint32_t message_length;
} fapi_message_header_t;
int fapi_nr_p5_message_header_unpack(uint8_t **pMessageBuf,
uint32_t messageBufLen,
void *pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p4_p5_codec_config_t *config);
int fapi_nr_p5_message_pack(void *pMessageBuf,
uint32_t messageBufLen,
void *pPackedBuf,
uint32_t packedBufLen,
nfapi_p4_p5_codec_config_t *config);
int fapi_nr_p5_message_unpack(void *pMessageBuf,
uint32_t messageBufLen,
void *pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p4_p5_codec_config_t *config);
int check_nr_fapi_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpackedBufLen);
#endif // OPENAIRINTERFACE_NR_FAPI_H
This diff is collapsed.
......@@ -38,6 +38,7 @@
#include "nfapi/oai_integration/vendor_ext.h"
#include <debug.h>
#include "nr_fapi_p5.h"
#include "nr_fapi.h"
// Pack routines
//TODO: Add pacl/unpack fns for uint32 and uint64
......@@ -3378,47 +3379,16 @@ static int check_nr_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpack
retLen = sizeof(nfapi_nr_pnf_stop_response_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_param_request_scf_t))
retLen = sizeof(nfapi_nr_param_request_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_param_response_scf_t))
retLen = sizeof(nfapi_nr_param_response_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_config_request_scf_t))
retLen = sizeof(nfapi_nr_config_request_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_config_response_scf_t))
retLen = sizeof(nfapi_nr_config_response_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
if (unpackedBufLen >= sizeof( nfapi_nr_start_request_scf_t))
retLen = sizeof( nfapi_nr_start_request_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_start_response_scf_t))
retLen = sizeof(nfapi_nr_start_response_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_stop_request_t))
retLen = sizeof(nfapi_stop_request_t);
case NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION:
case NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION:
retLen = check_nr_fapi_unpack_length(msgId, unpackedBufLen);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE:
......
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