Change VNF to use functions pointers to pack/unpack messages.

Adds 3 new function pointers to the P5 and P7 VNF structures, allowing to configure which function to use to pack/unpack the messages, as well as unpack the message header, being then used seamlessly regardless of using the FAPI or nFAPI functions.
This commit is contained in:
Rúben Soares Silva
2025-06-26 16:57:08 +01:00
parent 00b5eba192
commit 2089655a97
4 changed files with 122 additions and 31 deletions
@@ -449,7 +449,47 @@ typedef struct nfapi_vnf_config
*/
void (*deallocate_p4_p5_vendor_ext)(void* header);
/*! \brief Encodes a (n)FAPI P5 message to a buffer
* \param pMessageBuf A pointer to a (n)fapi p5 message structure
* \param messageBufLen The size of the p5 message structure
* \param pPackedBuf A pointer to the buffer that the p5 message will be packed into
* \param packedBufLen The size of the buffer
* \param config A pointer to the nfapi configuration structure
* \return != 0 means success, -1 means failure.
*/
int (*pack_func)(void* pMessageBuf,
uint32_t messageBufLen,
void* pPackedBuf,
uint32_t packedBufLen,
nfapi_p4_p5_codec_config_t* config);
/*! \brief Decodes an (n)FAPI P5 message
* \param pMessageBuf A pointer to an encoded P5 message
* \param messageBufLen The size of the encoded P5 message
* \param pUnpackedBuf A pointer to the nfapi_message_header
* \param unpackedBufLen The size of nfapi_message_header structure.
* \param config A pointer to the nfapi configuration structure
* \return true on success, false on failure
*/
bool (*unpack_func)(void* pMessageBuf,
uint32_t messageBufLen,
void* pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p4_p5_codec_config_t* config);
/*! \brief Decodes an (n)FAPI P5 message header
* \param pMessageBuf A pointer to an encoded P5 message header
* \param messageBufLen The size of the encoded P5 message header
* \param pUnpackedBuf A pointer to the nfapi_message_header
* \param unpackedBufLen The size of nfapi_message_header structure.
* \param config A pointer to the nfapi configuration structure
* \return true on success, false on failure
*/
bool (*hdr_unpack_func)(void* pMessageBuf,
uint32_t messageBufLen,
void* pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p4_p5_codec_config_t* config);
@@ -878,7 +918,42 @@ typedef struct nfapi_vnf_p7_config
*/
void (*deallocate_p7_vendor_ext)(void* header);
/*! A callback to pack a P7 message
* \param pMessageBuf A pointer to a nfapi p7 message structure
* \param pPackedBuf A pointer to the buffer that the p7 message will be packed into
* \param packedBufLen The size of the buffer
* \param config A pointer to the nfapi configuration structure
* \return != -1 means success, -1 means failure.
*/
int (*pack_func)(void* pMessageBuf, void* pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config);
/*! A callback to unpack a P7 message
* \param pMessageBuf A pointer to an encoded P7 message header
* \param messageBufLen The size of the encoded P7 message header
* \param pUnpackedBuf A pointer to the nfapi_message_header
* \param unpackedBufLen The size of nfapi_message_header structure.
* \param config A pointer to the nfapi configuration structure
* \return true on success, false on failure
*/
bool (*unpack_func)(void* pMessageBuf,
uint32_t messageBufLen,
void* pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p7_codec_config_t* config);
/*! \brief Decodes an NFAPI P7 message header
* \param pMessageBuf A pointer to an encoded P5 message header
* \param messageBufLen The size of the encoded P5 message header
* \param pUnpackedBuf A pointer to the nfapi_message_header
* \param unpackedBufLen The size of nfapi_message_header structure.
* \param config A pointer to the nfapi configuration structure
* \return true on success, false on failure
*/
bool (*hdr_unpack_func)(void* pMessageBuf,
uint32_t messageBufLen,
void* pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p7_codec_config_t* config);
} nfapi_vnf_p7_config_t;
/*! Creates and initializes the nfapi_vnf_p7_config structure before use