Change PNF to use functions pointers to pack/unpack messages.
Adds 3 new function pointers to the P5 and P7 PNF 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. Changes the header unpack and message unpack functions to return true on success and false on failure, instead of an int
This commit is contained in:
@@ -319,7 +319,47 @@ typedef struct nfapi_pnf_config
|
||||
*/
|
||||
void (*deallocate_p4_p5_vendor_ext)(void* header);
|
||||
|
||||
/*! \brief Encodes an (n)FAPI P5 message to a buffer
|
||||
* \param pMessageBuf A pointer to a nfapi 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 a (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);
|
||||
|
||||
} nfapi_pnf_config_t;
|
||||
|
||||
@@ -726,7 +766,42 @@ typedef struct nfapi_pnf_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 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 a 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_pnf_p7_config_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user