Separate LTE and NR (n)FAPI headers
Update NR P5 and P7 nFAPI headers to have 32-bit message_length In the NR functions, this causes the header parameters following message_length to have their position shifted by 2 bytes, due to the increase in message_length size. Change needed to accommodate SCF222.10.02 Table 3-3 Separates nfapi_p4_p5_message_header_t and nfapi_nr_p4_p5_message_header_t Change the callbacks signature to accept/return void* intead of expecting a particular header type, being the NR/LTE distinction done inside the callback functions. Create NR related functions for nFAPI transmit timestamp and checksum calculation. Move nfapi_p7_codec_config_t and nfapi_p4_p5_codec_config_t to separate header to be shared between LTE and NR VNF/PNF Move nfapi_nr_timing_info_t into NR header. Move NR specific function declarations to NR header.
This commit is contained in:
committed by
Robert Schmidt
parent
434a6b5e84
commit
4e5b841a16
@@ -35,7 +35,7 @@ int fapi_nr_message_header_unpack(uint8_t **pMessageBuf,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
{
|
||||
uint8_t **pReadPackedMessage = pMessageBuf;
|
||||
nfapi_p4_p5_message_header_t *header = pUnpackedBuf;
|
||||
nfapi_nr_p4_p5_message_header_t *header = pUnpackedBuf;
|
||||
fapi_message_header_t fapi_msg = {0};
|
||||
|
||||
if (pMessageBuf == NULL || pUnpackedBuf == NULL || messageBufLen < NFAPI_HEADER_LENGTH
|
||||
@@ -46,7 +46,6 @@ int fapi_nr_message_header_unpack(uint8_t **pMessageBuf,
|
||||
// process the header
|
||||
int result =
|
||||
(pull8(pReadPackedMessage, &fapi_msg.num_msg, end) && pull8(pReadPackedMessage, &fapi_msg.opaque_handle, end)
|
||||
&& pull16(pReadPackedMessage, &header->message_id, end) && pull32(pReadPackedMessage, &fapi_msg.message_length, end));
|
||||
header->message_length = fapi_msg.message_length;
|
||||
&& pull16(pReadPackedMessage, &header->message_id, end) && pull32(pReadPackedMessage, &header->message_length, end));
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "nr_fapi_p5.h"
|
||||
#include "debug.h"
|
||||
|
||||
uint8_t fapi_nr_p5_message_body_pack(nfapi_p4_p5_message_header_t *header,
|
||||
uint8_t fapi_nr_p5_message_body_pack(nfapi_nr_p4_p5_message_header_t *header,
|
||||
uint8_t **ppWritePackedMsg,
|
||||
uint8_t *end,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
@@ -83,7 +83,7 @@ int fapi_nr_p5_message_pack(void *pMessageBuf,
|
||||
const uint32_t packedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
{
|
||||
nfapi_p4_p5_message_header_t *pMessageHeader = pMessageBuf;
|
||||
nfapi_nr_p4_p5_message_header_t *pMessageHeader = pMessageBuf;
|
||||
uint8_t *pWritePackedMessage = pPackedBuf;
|
||||
AssertFatal(isFAPIMessageIDValid(pMessageHeader->message_id),
|
||||
"FAPI message IDs are defined between 0x00 and 0xFF the message provided 0x%02x, which is not a FAPI message",
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#ifndef NFAPI_COMMON_INTERFACE_H
|
||||
#define NFAPI_COMMON_INTERFACE_H
|
||||
|
||||
typedef struct {
|
||||
uint16_t tag;
|
||||
uint16_t length;
|
||||
} nfapi_tl_t;
|
||||
|
||||
/*! Configuration options for the p7 pack unpack functions
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct nfapi_p7_codec_config {
|
||||
/*! Optional call back to allow the user to define the memory allocator.
|
||||
* \param size The size of the memory to allocate
|
||||
* \return a pointer to a valid memory block or 0 if it has failed.
|
||||
*
|
||||
* If not set the nfapi unpack functions will use malloc
|
||||
*/
|
||||
void* (*allocate)(size_t size);
|
||||
|
||||
/*! Optional call back to allow the user to define the memory deallocator.
|
||||
* \param ptr A poiner to a memory block allocated by the allocate callback
|
||||
*
|
||||
* If not set the client should use free
|
||||
*/
|
||||
void (*deallocate)(void* ptr);
|
||||
|
||||
/*! Optional call back function to handle unpacking vendor extension tlv.
|
||||
* \param tl A pointer to a decoded tag length structure
|
||||
* \param ppReadPackedMsg A handle to the read buffer.
|
||||
* \param end The end of the read buffer
|
||||
* \param ve A handle to a vendor extention structure that the call back should allocate if the structure can be decoded
|
||||
* \param config A pointer to the p7 codec configuration
|
||||
* \return return 0 if packed successfully, -1 if failed.
|
||||
*
|
||||
* If not set the tlv will be skipped
|
||||
*
|
||||
* Client should use the help methods in nfapi.h to decode the vendor extention.
|
||||
*
|
||||
* \todo Add code example
|
||||
*/
|
||||
int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl,
|
||||
uint8_t** ppReadPackedMsg,
|
||||
uint8_t* end,
|
||||
void** ve,
|
||||
struct nfapi_p7_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle packing vendor extension tlv.
|
||||
* \param ve A pointer to a vendor extention structure.
|
||||
* \param ppWritePackedMsg A handle to the write buffer
|
||||
* \param end The end of the write buffer. The callee should make sure not to write beyond the end
|
||||
* \param config A pointer to the p7 codec configuration
|
||||
* \return return 0 if packed successfully, -1 if failed.
|
||||
*
|
||||
* If not set the the tlv will be skipped
|
||||
*
|
||||
* Client should use the help methods in nfapi.h to encode the vendor extention
|
||||
*
|
||||
* \todo Add code example
|
||||
*/
|
||||
int (*pack_vendor_extension_tlv)(void* ve, uint8_t** ppWritePackedMsg, uint8_t* end, struct nfapi_p7_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle unpacking vendor extension messages.
|
||||
* \param header A pointer to a decode P7 message header for the vendor extention message
|
||||
* \param ppReadPackedMsg A handle to the encoded data buffer
|
||||
* \param end A pointer to the end of the encoded data buffer
|
||||
* \param config A pointer to the p7 codec configuration
|
||||
* \return 0 if unpacked successfully, -1 if failed
|
||||
*
|
||||
* If not set the message will be ignored
|
||||
*
|
||||
* If the message if is unknown the function should return -1
|
||||
*/
|
||||
int (*unpack_p7_vendor_extension)(void* header, uint8_t** ppReadPackedMsg, uint8_t* end, struct nfapi_p7_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle packing vendor extension messages.
|
||||
* \param header A poiner to a P7 message structure for the venfor extention message
|
||||
* \param ppWritePackedmsg A handle to the buffer to write the encoded message into
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param cofig A pointer to the p7 codec configuration
|
||||
* \return 0 if packed successfully, -1 if failed
|
||||
*
|
||||
* If not set the the message will be ingored
|
||||
*
|
||||
* If the message if is unknown the function should return -1
|
||||
*/
|
||||
int (*pack_p7_vendor_extension)(void* header, uint8_t** ppWritePackedmsg, uint8_t* end, struct nfapi_p7_codec_config* config);
|
||||
|
||||
/*! Optional user data that will be passed back with callbacks
|
||||
*/
|
||||
void* user_data;
|
||||
|
||||
} nfapi_p7_codec_config_t;
|
||||
|
||||
/*! Configuration options for the p4 & p5 pack unpack functions
|
||||
*
|
||||
*/
|
||||
typedef struct nfapi_p4_p5_codec_config {
|
||||
/*! Optional call back to allow the user to define the memory allocator.
|
||||
* \param size The size of the memory to allocate
|
||||
* \return a pointer to a valid memory block or 0 if it has failed.
|
||||
*
|
||||
* If not set the nfapi unpack functions will use malloc
|
||||
*/
|
||||
void* (*allocate)(size_t size);
|
||||
|
||||
/*! Optional call back to allow the user to define the memory deallocator.
|
||||
* \param ptr A poiner to a memory block allocated by the allocate callback
|
||||
*
|
||||
* If not set free will be used
|
||||
*/
|
||||
void (*deallocate)(void* ptr);
|
||||
|
||||
/*! Optional call back function to handle unpacking vendor extension tlv.
|
||||
* \param tl A pointer to a decoded tag length structure
|
||||
* \param ppReadPackedMsg A handle to the data buffer to decode
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param ve A handle to a vendor extention structure that will be allocated by this callback
|
||||
* \param config A pointer to the P4/P5 codec configuration
|
||||
* \return 0 if unpacked successfully, -1 if failed
|
||||
*
|
||||
* If not set the tlv will be skipped
|
||||
*/
|
||||
int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl,
|
||||
uint8_t** ppReadPackedMsg,
|
||||
uint8_t* end,
|
||||
void** ve,
|
||||
struct nfapi_p4_p5_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle packing vendor extension tlv.
|
||||
* \param ve
|
||||
* \param ppWritePackedMsg A handle to the data buffer pack the tlv into
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param config A pointer to the P4/P5 codec configuration
|
||||
* \return 0 if packed successfully, -1 if failed
|
||||
*
|
||||
* If not set the the tlv will be skipped
|
||||
*/
|
||||
int (*pack_vendor_extension_tlv)(void* ve, uint8_t** ppWritePackedMsg, uint8_t* end, struct nfapi_p4_p5_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle unpacking vendor extension messages.
|
||||
* \param header A pointer to a decode P4/P5 message header
|
||||
* \param ppReadPackgedMsg A handle to the data buffer to decode
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param config A pointer to the P4/P5 codec configuration
|
||||
* \return 0 if packed successfully, -1 if failed
|
||||
*
|
||||
* If not set the message will be ignored
|
||||
*/
|
||||
int (*unpack_p4_p5_vendor_extension)(void* header,
|
||||
uint8_t** ppReadPackedMsg,
|
||||
uint8_t* end,
|
||||
struct nfapi_p4_p5_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle packing vendor extension messages.
|
||||
* \param header A pointer to the P4/P5 message header to be encoded
|
||||
* \param ppWritePackedMsg A handle to the data buffer pack the message into
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param config A pointer to the P4/P5 codec configuration
|
||||
* \return 0 if packed successfully, -1 if failed
|
||||
*
|
||||
* If not set the the message will be ingored
|
||||
*/
|
||||
int (*pack_p4_p5_vendor_extension)(void* header,
|
||||
uint8_t** ppwritepackedmsg,
|
||||
uint8_t* end,
|
||||
struct nfapi_p4_p5_codec_config* config);
|
||||
|
||||
/*! Optional user data that will be passed back with callbacks
|
||||
*/
|
||||
void* user_data;
|
||||
|
||||
} nfapi_p4_p5_codec_config_t;
|
||||
|
||||
#endif // NFAPI_COMMON_INTERFACE_H
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "stddef.h"
|
||||
#include <stdint.h>
|
||||
#include "nfapi_common_interface.h"
|
||||
|
||||
// Constants - update based on implementation
|
||||
#define NFAPI_MAX_PHY_RF_INSTANCES 2
|
||||
@@ -116,10 +117,6 @@ typedef struct {
|
||||
#define NFAPI_P7_GET_SEQUENCE(_mss) ( (_mss) & 0x00FF )
|
||||
#define NFAPI_P7_SET_MSS(_more, _segm, _sequ) ( (((_more) & 0x1) << 7) | (((_segm) & 0x7) << 4) | ((_sequ) & 0xF) )
|
||||
|
||||
typedef struct {
|
||||
uint16_t tag;
|
||||
uint16_t length;
|
||||
} nfapi_tl_t;
|
||||
#define NFAPI_TAG_LENGTH_PACKED_LEN 4
|
||||
|
||||
// Convenience methods to convert between SFN/SLOT formats
|
||||
@@ -2537,29 +2534,6 @@ typedef struct {
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_timing_info_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p7_message_header_t header;
|
||||
|
||||
uint32_t last_sfn;
|
||||
uint32_t last_slot;
|
||||
uint32_t time_since_last_timing_info;
|
||||
|
||||
uint32_t dl_tti_jitter;
|
||||
uint32_t tx_data_request_jitter;
|
||||
uint32_t ul_tti_jitter;
|
||||
uint32_t ul_dci_jitter;
|
||||
|
||||
int32_t dl_tti_latest_delay;
|
||||
int32_t tx_data_request_latest_delay;
|
||||
int32_t ul_tti_latest_delay;
|
||||
int32_t ul_dci_latest_delay;
|
||||
|
||||
int32_t dl_tti_earliest_arrival;
|
||||
int32_t tx_data_request_earliest_arrival;
|
||||
int32_t ul_tti_earliest_arrival;
|
||||
int32_t ul_dci_earliest_arrival;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_timing_info_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_tl_t tl;
|
||||
@@ -3772,160 +3746,6 @@ typedef struct
|
||||
// Configuration options for the encode decode functions
|
||||
//
|
||||
|
||||
/*! Configuration options for the p7 pack unpack functions
|
||||
*
|
||||
*/
|
||||
typedef struct nfapi_p7_codec_config {
|
||||
|
||||
/*! Optional call back to allow the user to define the memory allocator.
|
||||
* \param size The size of the memory to allocate
|
||||
* \return a pointer to a valid memory block or 0 if it has failed.
|
||||
*
|
||||
* If not set the nfapi unpack functions will use malloc
|
||||
*/
|
||||
void* (*allocate)(size_t size);
|
||||
|
||||
/*! Optional call back to allow the user to define the memory deallocator.
|
||||
* \param ptr A poiner to a memory block allocated by the allocate callback
|
||||
*
|
||||
* If not set the client should use free
|
||||
*/
|
||||
void (*deallocate)(void* ptr);
|
||||
|
||||
/*! Optional call back function to handle unpacking vendor extension tlv.
|
||||
* \param tl A pointer to a decoded tag length structure
|
||||
* \param ppReadPackedMsg A handle to the read buffer.
|
||||
* \param end The end of the read buffer
|
||||
* \param ve A handle to a vendor extention structure that the call back should allocate if the structure can be decoded
|
||||
* \param config A pointer to the p7 codec configuration
|
||||
* \return return 0 if packed successfully, -1 if failed.
|
||||
*
|
||||
* If not set the tlv will be skipped
|
||||
*
|
||||
* Client should use the help methods in nfapi.h to decode the vendor extention.
|
||||
*
|
||||
* \todo Add code example
|
||||
*/
|
||||
int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nfapi_p7_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle packing vendor extension tlv.
|
||||
* \param ve A pointer to a vendor extention structure.
|
||||
* \param ppWritePackedMsg A handle to the write buffer
|
||||
* \param end The end of the write buffer. The callee should make sure not to write beyond the end
|
||||
* \param config A pointer to the p7 codec configuration
|
||||
* \return return 0 if packed successfully, -1 if failed.
|
||||
*
|
||||
* If not set the the tlv will be skipped
|
||||
*
|
||||
* Client should use the help methods in nfapi.h to encode the vendor extention
|
||||
*
|
||||
* \todo Add code example
|
||||
*/
|
||||
int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nfapi_p7_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle unpacking vendor extension messages.
|
||||
* \param header A pointer to a decode P7 message header for the vendor extention message
|
||||
* \param ppReadPackedMsg A handle to the encoded data buffer
|
||||
* \param end A pointer to the end of the encoded data buffer
|
||||
* \param config A pointer to the p7 codec configuration
|
||||
* \return 0 if unpacked successfully, -1 if failed
|
||||
*
|
||||
* If not set the message will be ignored
|
||||
*
|
||||
* If the message if is unknown the function should return -1
|
||||
*/
|
||||
int (*unpack_p7_vendor_extension)(nfapi_p7_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nfapi_p7_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle packing vendor extension messages.
|
||||
* \param header A poiner to a P7 message structure for the venfor extention message
|
||||
* \param ppWritePackedmsg A handle to the buffer to write the encoded message into
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param cofig A pointer to the p7 codec configuration
|
||||
* \return 0 if packed successfully, -1 if failed
|
||||
*
|
||||
* If not set the the message will be ingored
|
||||
*
|
||||
* If the message if is unknown the function should return -1
|
||||
*/
|
||||
int (*pack_p7_vendor_extension)(nfapi_p7_message_header_t* header, uint8_t **ppWritePackedmsg, uint8_t *end, struct nfapi_p7_codec_config* config);
|
||||
|
||||
/*! Optional user data that will be passed back with callbacks
|
||||
*/
|
||||
void* user_data;
|
||||
|
||||
} nfapi_p7_codec_config_t;
|
||||
|
||||
/*! Configuration options for the p4 & p5 pack unpack functions
|
||||
*
|
||||
*/
|
||||
typedef struct nfapi_p4_p5_codec_config {
|
||||
|
||||
/*! Optional call back to allow the user to define the memory allocator.
|
||||
* \param size The size of the memory to allocate
|
||||
* \return a pointer to a valid memory block or 0 if it has failed.
|
||||
*
|
||||
* If not set the nfapi unpack functions will use malloc
|
||||
*/
|
||||
void* (*allocate)(size_t size);
|
||||
|
||||
/*! Optional call back to allow the user to define the memory deallocator.
|
||||
* \param ptr A poiner to a memory block allocated by the allocate callback
|
||||
*
|
||||
* If not set free will be used
|
||||
*/
|
||||
void (*deallocate)(void* ptr);
|
||||
|
||||
/*! Optional call back function to handle unpacking vendor extension tlv.
|
||||
* \param tl A pointer to a decoded tag length structure
|
||||
* \param ppReadPackedMsg A handle to the data buffer to decode
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param ve A handle to a vendor extention structure that will be allocated by this callback
|
||||
* \param config A pointer to the P4/P5 codec configuration
|
||||
* \return 0 if unpacked successfully, -1 if failed
|
||||
*
|
||||
* If not set the tlv will be skipped
|
||||
*/
|
||||
int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nfapi_p4_p5_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle packing vendor extension tlv.
|
||||
* \param ve
|
||||
* \param ppWritePackedMsg A handle to the data buffer pack the tlv into
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param config A pointer to the P4/P5 codec configuration
|
||||
* \return 0 if packed successfully, -1 if failed
|
||||
*
|
||||
* If not set the the tlv will be skipped
|
||||
*/
|
||||
int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle unpacking vendor extension messages.
|
||||
* \param header A pointer to a decode P4/P5 message header
|
||||
* \param ppReadPackgedMsg A handle to the data buffer to decode
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param config A pointer to the P4/P5 codec configuration
|
||||
* \return 0 if packed successfully, -1 if failed
|
||||
*
|
||||
* If not set the message will be ignored
|
||||
*/
|
||||
int (*unpack_p4_p5_vendor_extension)(nfapi_p4_p5_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
|
||||
|
||||
/*! Optional call back function to handle packing vendor extension messages.
|
||||
* \param header A pointer to the P4/P5 message header to be encoded
|
||||
* \param ppWritePackedMsg A handle to the data buffer pack the message into
|
||||
* \param end A pointer to the end of the buffer
|
||||
* \param config A pointer to the P4/P5 codec configuration
|
||||
* \return 0 if packed successfully, -1 if failed
|
||||
*
|
||||
* If not set the the message will be ingored
|
||||
*/
|
||||
int (*pack_p4_p5_vendor_extension)(nfapi_p4_p5_message_header_t* header, uint8_t **ppwritepackedmsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
|
||||
|
||||
/*! Optional user data that will be passed back with callbacks
|
||||
*/
|
||||
void* user_data;
|
||||
|
||||
} nfapi_p4_p5_codec_config_t;
|
||||
|
||||
//
|
||||
// Functions
|
||||
//
|
||||
@@ -3979,21 +3799,7 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
*
|
||||
*/
|
||||
int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
|
||||
int nfapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
|
||||
|
||||
/*! \brief Packs a NFAPI P5 message body
|
||||
* \param header A pointer to the header of the P5 message
|
||||
* \param ppWritePackedMsg A pointer to the buffer where to pack the P5 message
|
||||
* \param end Pointer to the end of the packing buffer
|
||||
* \param config A pointer to the nfapi configuration structure
|
||||
* \return 0 means success, -1 means failure.
|
||||
*
|
||||
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf
|
||||
*/
|
||||
uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t* header,
|
||||
uint8_t** ppWritePackedMsg,
|
||||
uint8_t* end,
|
||||
nfapi_p4_p5_codec_config_t* config);
|
||||
|
||||
/*! \brief Decodes an NFAPI P5 message header
|
||||
* \param pMessageBuf A pointer to an encoded P5 message header
|
||||
@@ -4017,7 +3823,6 @@ int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, vo
|
||||
*
|
||||
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf
|
||||
*/
|
||||
int nfapi_nr_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
|
||||
int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
|
||||
|
||||
/*! \brief Encodes an NFAPI P7 message to a buffer
|
||||
@@ -4031,7 +3836,6 @@ int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
*
|
||||
*/
|
||||
int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config);
|
||||
int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config);
|
||||
|
||||
/*! \brief Decodes an NFAPI P7 message header
|
||||
* \param pMessageBuf A pointer to an encoded P7 message header
|
||||
@@ -4057,7 +3861,6 @@ int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, vo
|
||||
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p7 message structure pointer to by pUnpackedBuf
|
||||
*/
|
||||
int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config);
|
||||
int nfapi_nr_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config);
|
||||
|
||||
/*! \brief Calculates the checksum of a message
|
||||
*
|
||||
@@ -4083,42 +3886,4 @@ int nfapi_p7_update_checksum(uint8_t* buffer, uint32_t len);
|
||||
*/
|
||||
int nfapi_p7_update_transmit_timestamp(uint8_t* buffer, uint32_t timestamp);
|
||||
|
||||
/*! \brief Encodes a nfapi_nr_srs_normalized_channel_iq_matrix_t to a buffer
|
||||
*
|
||||
* \param pMessageBuf A pointer to a nfapi_nr_srs_normalized_channel_iq_matrix_t structure
|
||||
* \param pPackedBuf A pointer to the buffer that the nfapi_nr_srs_normalized_channel_iq_matrix_t will be packed into
|
||||
* \param packedBufLen The size of the buffer
|
||||
* \return number of bytes written to the buffer
|
||||
*/
|
||||
int pack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen);
|
||||
|
||||
/*! \brief Decodes a nfapi_nr_srs_normalized_channel_iq_matrix_t from a buffer
|
||||
*
|
||||
* \param pMessageBuf A pointer to an encoded nfapi_nr_srs_normalized_channel_iq_matrix_t
|
||||
* \param messageBufLen The size of the encoded nfapi_nr_srs_normalized_channel_iq_matrix_t
|
||||
* \param pUnpackedBuf A pointer to the nfapi_nr_srs_normalized_channel_iq_matrix_t
|
||||
* \param unpackedBufLen The size of nfapi_nr_srs_normalized_channel_iq_matrix_t structure.
|
||||
* \return 0 means success, -1 means failure.
|
||||
*/
|
||||
int unpack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen);
|
||||
|
||||
/*! \brief Encodes a nfapi_nr_srs_beamforming_report_t to a buffer
|
||||
*
|
||||
* \param pMessageBuf A pointer to a nfapi_nr_srs_beamforming_report_t structure
|
||||
* \param pPackedBuf A pointer to the buffer that the nfapi_nr_srs_beamforming_report_t will be packed into
|
||||
* \param packedBufLen The size of the buffer
|
||||
* \return number of bytes written to the buffer
|
||||
*/
|
||||
int pack_nr_srs_beamforming_report(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen);
|
||||
|
||||
/*! \brief Decodes a nfapi_nr_srs_beamforming_report_t from a buffer
|
||||
*
|
||||
* \param pMessageBuf A pointer to an encoded nfapi_nr_srs_beamforming_report_t
|
||||
* \param messageBufLen The size of the encoded nfapi_nr_srs_beamforming_report_t
|
||||
* \param pUnpackedBuf A pointer to the nfapi_nr_srs_beamforming_report_t
|
||||
* \param unpackedBufLen The size of nfapi_nr_srs_beamforming_report_t structure.
|
||||
* \return 0 means success, -1 means failure.
|
||||
*/
|
||||
int unpack_nr_srs_beamforming_report(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen);
|
||||
|
||||
#endif /* _NFAPI_INTERFACE_H_ */
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#ifndef _NFAPI_NR_INTERFACE_H_
|
||||
#define _NFAPI_NR_INTERFACE_H_
|
||||
#include "nfapi_common_interface.h"
|
||||
|
||||
#define NFAPI_NR_P5_HEADER_LENGTH 10
|
||||
#define NFAPI_NR_P7_HEADER_LENGTH 18
|
||||
|
||||
//These TLVs are used exclusively by nFAPI
|
||||
#define NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG 0x0100
|
||||
@@ -26,6 +30,22 @@
|
||||
#define NFAPI_NR_FAPI_NUM_BEAMS_PERIOD_VENDOR_EXTENSION_TAG 0xA000
|
||||
#define NFAPI_NR_FAPI_ANALOG_BF_VENDOR_EXTENSION_TAG 0xA001
|
||||
|
||||
typedef struct {
|
||||
uint16_t phy_id;
|
||||
uint16_t message_id;
|
||||
uint32_t message_length;
|
||||
uint16_t spare;
|
||||
} nfapi_nr_p4_p5_message_header_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t phy_id;
|
||||
uint16_t message_id;
|
||||
uint32_t message_length;
|
||||
uint16_t m_segment_sequence; /* This consists of 3 fields - namely, M, Segement & Sequence number*/
|
||||
uint32_t checksum;
|
||||
uint32_t transmit_timestamp;
|
||||
} nfapi_nr_p7_message_header_t;
|
||||
|
||||
typedef enum {
|
||||
NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED=1,
|
||||
NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED=0
|
||||
@@ -48,4 +68,178 @@ typedef enum {
|
||||
NFAPI_NR_SRS_ANTENNASWITCH = 3
|
||||
} nfapi_nr_srs_usage_e;
|
||||
|
||||
/*! \brief Encodes an NFAPI 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.
|
||||
*
|
||||
* The function will encode a nFAPI P5 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
|
||||
* The function returns the message length that was packed
|
||||
*/
|
||||
int nfapi_nr_p5_message_pack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pPackedBuf,
|
||||
uint32_t packedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config);
|
||||
|
||||
/*! \brief Packs a NFAPI P5 message body
|
||||
* \param header A pointer to the header of the P5 message
|
||||
* \param ppWritePackedMsg A pointer to the buffer where to pack the P5 message
|
||||
* \param end Pointer to the end of the packing buffer
|
||||
* \param config A pointer to the nfapi configuration structure
|
||||
* \return 1 means success, 0 means failure.
|
||||
*
|
||||
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf
|
||||
*/
|
||||
uint8_t pack_nr_p5_message_body(nfapi_nr_p4_p5_message_header_t *header,
|
||||
uint8_t **ppWritePackedMsg,
|
||||
uint8_t *end,
|
||||
nfapi_p4_p5_codec_config_t *config);
|
||||
|
||||
/*! \brief Decodes an NFAPI 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 10 ( size of the unpacked header ) on success, -1 on failure.
|
||||
*
|
||||
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 header structure pointed to by pUnpackedBuf
|
||||
*/
|
||||
int nfapi_nr_p5_message_header_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config);
|
||||
|
||||
/*! \brief Decodes a NFAPI 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 != -1 means success, -1 means failure.
|
||||
*
|
||||
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf
|
||||
*/
|
||||
int nfapi_nr_p5_message_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config);
|
||||
|
||||
/*! \brief Encodes an NFAPI P7 message to a buffer
|
||||
* \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.
|
||||
*
|
||||
* The function will encode a nFAPI P7 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
|
||||
* The function returns the message length packed
|
||||
*/
|
||||
int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t *config);
|
||||
|
||||
/*! \brief Decodes an NFAPI P7 message header
|
||||
* \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 0 means success, -1 means failure.
|
||||
*
|
||||
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p7_message_header structure pointer to by
|
||||
pUnpackedBuf
|
||||
|
||||
*/
|
||||
int nfapi_nr_p7_message_header_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p7_codec_config_t *config);
|
||||
|
||||
/*! \brief Decodes a NFAPI P7 message
|
||||
* \param pMessageBuf A pointer to an encoded P7 message
|
||||
* \param messageBufLen The size of the encoded P7 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 0 means success, -1 means failure.
|
||||
*
|
||||
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p7 message structure pointer to by pUnpackedBuf
|
||||
*/
|
||||
int nfapi_nr_p7_message_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p7_codec_config_t *config);
|
||||
|
||||
/*! \brief Calculates the checksum of a message
|
||||
*
|
||||
* \param buffer Pointer to the packed message
|
||||
* \param len The length of the message
|
||||
* \return The checksum. If there is an error the function with return -1
|
||||
*/
|
||||
uint32_t nfapi_nr_p7_calculate_checksum(uint8_t *buffer, uint32_t len);
|
||||
|
||||
/*! \brief Calculates & updates the checksum in the message
|
||||
*
|
||||
* \param buffer Pointer to the packed message
|
||||
* \param len The length of the message
|
||||
* \return 0 means success, -1 means failure.
|
||||
*/
|
||||
int nfapi_nr_p7_update_checksum(uint8_t *buffer, uint32_t len);
|
||||
|
||||
/*! \brief Updates the transmition time stamp in the p7 message header
|
||||
*
|
||||
* \param buffer Pointer to the packed message
|
||||
* \param timestamp The time stamp value
|
||||
* \return 0 means success, -1 means failure.
|
||||
*/
|
||||
int nfapi_nr_p7_update_transmit_timestamp(uint8_t *buffer, uint32_t timestamp);
|
||||
|
||||
/*! \brief Encodes a nfapi_nr_srs_normalized_channel_iq_matrix_t to a buffer
|
||||
*
|
||||
* \param pMessageBuf A pointer to a nfapi_nr_srs_normalized_channel_iq_matrix_t structure
|
||||
* \param pPackedBuf A pointer to the buffer that the nfapi_nr_srs_normalized_channel_iq_matrix_t will be packed into
|
||||
* \param packedBufLen The size of the buffer
|
||||
* \return number of bytes written to the buffer
|
||||
*/
|
||||
int pack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen);
|
||||
|
||||
/*! \brief Decodes a nfapi_nr_srs_normalized_channel_iq_matrix_t from a buffer
|
||||
*
|
||||
* \param pMessageBuf A pointer to an encoded nfapi_nr_srs_normalized_channel_iq_matrix_t
|
||||
* \param messageBufLen The size of the encoded nfapi_nr_srs_normalized_channel_iq_matrix_t
|
||||
* \param pUnpackedBuf A pointer to the nfapi_nr_srs_normalized_channel_iq_matrix_t
|
||||
* \param unpackedBufLen The size of nfapi_nr_srs_normalized_channel_iq_matrix_t structure.
|
||||
* \return 0 means success, -1 means failure.
|
||||
*/
|
||||
int unpack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen);
|
||||
|
||||
/*! \brief Encodes a nfapi_nr_srs_beamforming_report_t to a buffer
|
||||
*
|
||||
* \param pMessageBuf A pointer to a nfapi_nr_srs_beamforming_report_t structure
|
||||
* \param pPackedBuf A pointer to the buffer that the nfapi_nr_srs_beamforming_report_t will be packed into
|
||||
* \param packedBufLen The size of the buffer
|
||||
* \return number of bytes written to the buffer
|
||||
*/
|
||||
int pack_nr_srs_beamforming_report(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen);
|
||||
|
||||
/*! \brief Decodes a nfapi_nr_srs_beamforming_report_t from a buffer
|
||||
*
|
||||
* \param pMessageBuf A pointer to an encoded nfapi_nr_srs_beamforming_report_t
|
||||
* \param messageBufLen The size of the encoded nfapi_nr_srs_beamforming_report_t
|
||||
* \param pUnpackedBuf A pointer to the nfapi_nr_srs_beamforming_report_t
|
||||
* \param unpackedBufLen The size of nfapi_nr_srs_beamforming_report_t structure.
|
||||
* \return 0 means success, -1 means failure.
|
||||
*/
|
||||
int unpack_nr_srs_beamforming_report(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "stddef.h"
|
||||
#include "nfapi_interface.h"
|
||||
#include "nfapi_nr_interface.h"
|
||||
|
||||
#define NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS 5
|
||||
#define NFAPI_NR_MAX_NB_TCI_STATES_PDCCH 64
|
||||
@@ -510,12 +511,12 @@ typedef enum { // Table 2-27
|
||||
|
||||
//PNF P5 NR
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_pnf_param_request_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
uint8_t error_code;
|
||||
uint8_t num_tlvs;
|
||||
nfapi_pnf_param_general_t pnf_param_general;
|
||||
@@ -524,36 +525,36 @@ typedef struct {
|
||||
} nfapi_nr_pnf_param_response_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
uint8_t num_tlvs;
|
||||
nfapi_pnf_phy_rf_config_t pnf_phy_rf_config;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_pnf_config_request_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
uint8_t error_code;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_pnf_config_response_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_pnf_start_request_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
uint32_t error_code;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_pnf_start_response_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_pnf_stop_request_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
uint32_t error_code;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_pnf_stop_response_t;
|
||||
@@ -561,13 +562,13 @@ typedef struct {
|
||||
|
||||
/* PARAM.REQUEST */
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_param_request_scf_t;
|
||||
|
||||
/* PARAM.RESPONSE */
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
uint8_t error_code;
|
||||
|
||||
uint8_t num_tlv;
|
||||
@@ -589,7 +590,7 @@ typedef struct {
|
||||
|
||||
/* CONFIG.REQUEST */
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
|
||||
uint8_t num_tlv;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
@@ -627,7 +628,7 @@ typedef struct {
|
||||
|
||||
/* CONFIG.RESPONSE */
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
uint8_t error_code;
|
||||
uint8_t num_invalid_tlvs;
|
||||
uint8_t num_invalid_tlvs_configured_in_idle;
|
||||
@@ -644,12 +645,12 @@ typedef struct {
|
||||
//3.3.3 START
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_start_request_scf_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
nfapi_nr_start_errors_e error_code;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_start_response_scf_t;
|
||||
@@ -657,17 +658,17 @@ typedef struct {
|
||||
//3.3.4 STOP
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_stop_request_scf_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_stop_indication_scf_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
uint16_t sfn;
|
||||
uint16_t slot;
|
||||
uint8_t message_id; // Which message received on the PNF has an error
|
||||
@@ -708,7 +709,7 @@ typedef struct {
|
||||
#define NFAPI_NR_SLOT_INDICATION_PERIOD_NUMEROLOGY_3 125 //us
|
||||
|
||||
typedef struct {
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t sfn; //0->1023
|
||||
uint16_t slot;//0->319
|
||||
|
||||
@@ -1070,23 +1071,46 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint32_t t1;
|
||||
int32_t delta_sfn_slot;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_dl_node_sync_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint32_t t1;
|
||||
uint32_t t2;
|
||||
uint32_t t3;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_ul_node_sync_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
|
||||
uint32_t last_sfn;
|
||||
uint32_t last_slot;
|
||||
uint32_t time_since_last_timing_info;
|
||||
|
||||
uint32_t dl_tti_jitter;
|
||||
uint32_t tx_data_request_jitter;
|
||||
uint32_t ul_tti_jitter;
|
||||
uint32_t ul_dci_jitter;
|
||||
|
||||
int32_t dl_tti_latest_delay;
|
||||
int32_t tx_data_request_latest_delay;
|
||||
int32_t ul_tti_latest_delay;
|
||||
int32_t ul_dci_latest_delay;
|
||||
|
||||
int32_t dl_tti_earliest_arrival;
|
||||
int32_t tx_data_request_earliest_arrival;
|
||||
int32_t ul_tti_earliest_arrival;
|
||||
int32_t ul_dci_earliest_arrival;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_timing_info_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
/// System Frame Number (0-1023)
|
||||
uint16_t SFN;
|
||||
/// Slot number (0-19)
|
||||
@@ -1420,7 +1444,7 @@ typedef struct
|
||||
} nfapi_nr_ul_tti_request_number_of_groups_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t SFN; //0->1023
|
||||
uint16_t Slot;//0->319
|
||||
uint8_t n_pdus;//Number of PDUs that are included in this message. All PDUs in the message are numbered in order. Value 0 -> 255
|
||||
@@ -1464,7 +1488,7 @@ typedef struct {
|
||||
} nfapi_nr_ul_dci_request_pdus_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t SFN;
|
||||
uint16_t Slot;
|
||||
uint8_t numPdus;
|
||||
@@ -1510,7 +1534,7 @@ typedef struct
|
||||
#define NFAPI_NR_MAX_TX_REQUEST_PDUS 16
|
||||
typedef struct
|
||||
{
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t SFN;
|
||||
uint16_t Slot;
|
||||
uint16_t Number_of_PDUs;
|
||||
@@ -1545,7 +1569,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t sfn;
|
||||
uint16_t slot;
|
||||
uint16_t number_of_pdus;
|
||||
@@ -1573,7 +1597,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t sfn;
|
||||
uint16_t slot;
|
||||
uint16_t number_crcs;
|
||||
@@ -1710,7 +1734,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t sfn;
|
||||
uint16_t slot;
|
||||
uint16_t num_ucis;
|
||||
@@ -1770,7 +1794,7 @@ typedef struct {
|
||||
} nfapi_nr_srs_indication_pdu_t;
|
||||
|
||||
typedef struct {
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t sfn; // SFN. Value: 0 -> 1023
|
||||
uint16_t slot; // Slot. Value: 0 -> 159
|
||||
uint16_t control_length; // Size of control portion of SRS indication. 0 if reports are included inline; >0 if reports are concatenated to the end of the message.
|
||||
@@ -1803,7 +1827,7 @@ typedef struct{
|
||||
|
||||
typedef struct
|
||||
{
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t sfn;
|
||||
uint16_t slot;
|
||||
uint8_t number_of_pdus;
|
||||
|
||||
@@ -1616,7 +1616,12 @@ int nfapi_p4_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPack
|
||||
|
||||
// Main unpack functions - public
|
||||
|
||||
int nfapi_p4_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t *config) {
|
||||
int nfapi_p4_message_header_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
{
|
||||
nfapi_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
|
||||
@@ -1632,17 +1637,21 @@ int nfapi_p4_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, vo
|
||||
return -1;
|
||||
}
|
||||
|
||||
// process the headei
|
||||
if (pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->spare, end))
|
||||
// process the header
|
||||
if (pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->spare, end))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t *config) {
|
||||
int nfapi_p4_message_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
{
|
||||
int result = 0;
|
||||
nfapi_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
@@ -1661,12 +1670,10 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
// clean the supplied buffer for - tag value blanking
|
||||
(void)memset(pUnpackedBuf, 0, unpackedBufLen);
|
||||
|
||||
// process the header
|
||||
if(!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->spare, end)))
|
||||
if (!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->spare, end)))
|
||||
return -1;
|
||||
|
||||
// look for the specific message
|
||||
@@ -1779,7 +1786,7 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
if (check_unpack_length(NFAPI_SYSTEM_INFORMATION_RESPONSE, unpackedBufLen))
|
||||
result = unpack_system_information_response(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
result = -1;
|
||||
result = -1;
|
||||
|
||||
break;
|
||||
|
||||
@@ -1787,7 +1794,7 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
if (check_unpack_length(NFAPI_SYSTEM_INFORMATION_INDICATION, unpackedBufLen))
|
||||
result = unpack_system_information_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
result = -1;
|
||||
result = -1;
|
||||
|
||||
break;
|
||||
|
||||
@@ -1808,12 +1815,14 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
break;
|
||||
|
||||
default:
|
||||
if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
|
||||
pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||
if(config && config->unpack_p4_p5_vendor_extension) {
|
||||
if (pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||
if (config && config->unpack_p4_p5_vendor_extension) {
|
||||
result = (config->unpack_p4_p5_vendor_extension)(pMessageHeader, &pReadPackedMessage, end, config);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve decoder provided\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR,
|
||||
"%s VE NFAPI message ID %d. No ve decoder provided\n",
|
||||
__FUNCTION__,
|
||||
pMessageHeader->message_id);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown P4 message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
@@ -1822,7 +1831,7 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
break;
|
||||
}
|
||||
|
||||
if(result == 0)
|
||||
if (result == 0)
|
||||
return -1;
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1184,7 +1184,7 @@ static uint8_t pack_measurement_response(void *msg, uint8_t **ppWritePackedMsg,
|
||||
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
|
||||
}
|
||||
|
||||
uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t *header,
|
||||
uint8_t pack_nr_p5_message_body(nfapi_nr_p4_p5_message_header_t *header,
|
||||
uint8_t **ppWritePackedMsg,
|
||||
uint8_t *end,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
@@ -1376,11 +1376,8 @@ int nfapi_nr_p5_message_pack(void *pMessageBuf,
|
||||
uint32_t packedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
{
|
||||
nfapi_p4_p5_message_header_t *pMessageHeader = pMessageBuf;
|
||||
nfapi_nr_p4_p5_message_header_t *pMessageHeader = pMessageBuf;
|
||||
uint8_t *pWritePackedMessage = pPackedBuf;
|
||||
uint32_t packedMsgLen;
|
||||
uint32_t packedBodyLen;
|
||||
uint16_t packedMsgLen16;
|
||||
|
||||
if (pMessageBuf == NULL || pPackedBuf == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 Pack supplied pointers are null\n");
|
||||
@@ -1389,28 +1386,26 @@ int nfapi_nr_p5_message_pack(void *pMessageBuf,
|
||||
|
||||
uint8_t *pPackMessageEnd = pPackedBuf + packedBufLen;
|
||||
uint8_t *pPackedLengthField = &pWritePackedMessage[4];
|
||||
uint8_t *pPacketBodyFieldStart = &pWritePackedMessage[8];
|
||||
uint8_t *pPacketBodyField = &pWritePackedMessage[8];
|
||||
uint8_t *pPacketBodyFieldStart = &pWritePackedMessage[10];
|
||||
uint8_t *pPacketBodyField = &pWritePackedMessage[10];
|
||||
|
||||
// pack the message
|
||||
if (push16(pMessageHeader->phy_id, &pWritePackedMessage, pPackMessageEnd)
|
||||
&& push16(pMessageHeader->message_id, &pWritePackedMessage, pPackMessageEnd)
|
||||
&& push16(0, &pWritePackedMessage, pPackMessageEnd) && push16(pMessageHeader->spare, &pWritePackedMessage, pPackMessageEnd)
|
||||
&& push32(0, &pWritePackedMessage, pPackMessageEnd) && push16(pMessageHeader->spare, &pWritePackedMessage, pPackMessageEnd)
|
||||
&& pack_nr_p5_message_body(pMessageHeader, &pPacketBodyField, pPackMessageEnd, config)) {
|
||||
// to check if whole message is bigger than the buffer provided
|
||||
packedMsgLen = get_packed_msg_len((uintptr_t)pPackedBuf, (uintptr_t)pPacketBodyField);
|
||||
uint32_t packedMsgLen = get_packed_msg_len((uintptr_t)pPackedBuf, (uintptr_t)pPacketBodyField);
|
||||
// obtain the length of the message body to pack
|
||||
packedBodyLen = get_packed_msg_len((uintptr_t)pPacketBodyFieldStart, (uintptr_t)pPacketBodyField);
|
||||
uint32_t packedBodyLen = get_packed_msg_len((uintptr_t)pPacketBodyFieldStart, (uintptr_t)pPacketBodyField);
|
||||
|
||||
if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) {
|
||||
if (packedMsgLen > packedBufLen) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen);
|
||||
return -1;
|
||||
} else {
|
||||
packedMsgLen16 = (uint16_t)packedBodyLen;
|
||||
}
|
||||
|
||||
// Update the message length in the header
|
||||
if (!push16(packedMsgLen16, &pPackedLengthField, pPackMessageEnd))
|
||||
if (!push32(packedBodyLen, &pPackedLengthField, pPackMessageEnd))
|
||||
return -1;
|
||||
|
||||
// return the packed length
|
||||
@@ -2298,7 +2293,12 @@ static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen
|
||||
|
||||
// Main unpack functions - public
|
||||
|
||||
int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t *config) {
|
||||
int nfapi_p5_message_header_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
{
|
||||
nfapi_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
|
||||
@@ -2315,10 +2315,42 @@ int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, vo
|
||||
}
|
||||
|
||||
// process the header
|
||||
return ( pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->spare, end) );
|
||||
if (!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->spare, end))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 8;
|
||||
}
|
||||
|
||||
int nfapi_nr_p5_message_header_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
{
|
||||
nfapi_nr_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
|
||||
if (pMessageBuf == NULL || pUnpackedBuf == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 header unpack supplied pointers are null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t *end = pMessageBuf + messageBufLen;
|
||||
|
||||
if (messageBufLen < NFAPI_NR_P5_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_nr_p4_p5_message_header_t)) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 header unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen);
|
||||
return -1;
|
||||
}
|
||||
// process the header
|
||||
if (!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->spare, end))) {
|
||||
return -1;
|
||||
}
|
||||
return NFAPI_NR_P5_HEADER_LENGTH;
|
||||
}
|
||||
|
||||
int nfapi_nr_p5_message_unpack(void *pMessageBuf,
|
||||
@@ -2327,41 +2359,24 @@ int nfapi_nr_p5_message_unpack(void *pMessageBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p4_p5_codec_config_t *config)
|
||||
{
|
||||
nfapi_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
|
||||
if (pMessageBuf == NULL || pUnpackedBuf == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 unpack supplied pointers are null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t *end = (uint8_t *)pMessageBuf + messageBufLen;
|
||||
|
||||
if (messageBufLen < NFAPI_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p4_p5_message_header_t)) {
|
||||
if (messageBufLen < NFAPI_NR_P5_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_nr_p4_p5_message_header_t)) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t *ptr = pReadPackedMessage;
|
||||
printf("\n Read NR message unpack: ");
|
||||
|
||||
while (ptr < end) {
|
||||
printf(" %02x ", *ptr);
|
||||
ptr++;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
nfapi_nr_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf;
|
||||
// clean the supplied buffer for - tag value blanking
|
||||
(void)memset(pUnpackedBuf, 0, unpackedBufLen);
|
||||
|
||||
// process the header
|
||||
if (!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->spare, end))) {
|
||||
// failed to read the header
|
||||
if (!nfapi_nr_p5_message_header_unpack(pMessageBuf, messageBufLen, pMessageHeader, unpackedBufLen, config)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t *pReadPackedMessage = pMessageBuf + NFAPI_NR_P5_HEADER_LENGTH;
|
||||
uint8_t *end = (uint8_t *)pMessageBuf + messageBufLen;
|
||||
int result = -1;
|
||||
|
||||
if (check_nr_unpack_length(pMessageHeader->message_id, unpackedBufLen) == 0) {
|
||||
|
||||
@@ -62,15 +62,50 @@ int nfapi_p7_update_checksum(uint8_t *buffer, uint32_t len) {
|
||||
return (push32(checksum, &p_write, buffer + len) > 0 ? 0 : -1);
|
||||
}
|
||||
|
||||
int nfapi_p7_update_transmit_timestamp(uint8_t *buffer, uint32_t timestamp) {
|
||||
int nfapi_p7_update_transmit_timestamp(uint8_t *buffer, uint32_t timestamp)
|
||||
{
|
||||
uint8_t *p_write = &buffer[12];
|
||||
return (push32(timestamp, &p_write, buffer + 16) > 0 ? 0 : -1);
|
||||
return (push32(timestamp, &p_write, buffer + NFAPI_P7_HEADER_LENGTH) > 0 ? 0 : -1);
|
||||
}
|
||||
|
||||
uint32_t nfapi_p7_calculate_checksum(uint8_t *buffer, uint32_t len) {
|
||||
return nfapi_calculate_checksum(buffer, len);
|
||||
}
|
||||
|
||||
uint32_t nfapi_nr_calculate_checksum(uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
uint32_t chksum = 0;
|
||||
// calcaulte upto the checksum
|
||||
chksum = crc32(chksum, buffer, 10);
|
||||
// skip the checksum
|
||||
uint8_t zeros[4] = {0, 0, 0, 0};
|
||||
chksum = crc32(chksum, zeros, 4);
|
||||
// continu with the rest of the mesage
|
||||
chksum = crc32(chksum, &buffer[NFAPI_NR_P7_HEADER_LENGTH], len - NFAPI_NR_P7_HEADER_LENGTH);
|
||||
// return the inverse
|
||||
return ~(chksum);
|
||||
}
|
||||
|
||||
int nfapi_nr_p7_update_checksum(uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
uint32_t checksum = nfapi_nr_calculate_checksum(buffer, len);
|
||||
// 10 is the beginning position of checksum
|
||||
uint8_t *p_write = &buffer[10];
|
||||
return (push32(checksum, &p_write, buffer + len) > 0 ? 0 : -1);
|
||||
}
|
||||
|
||||
int nfapi_nr_p7_update_transmit_timestamp(uint8_t *buffer, uint32_t timestamp)
|
||||
{
|
||||
// 14 is the beginning position of transmit_timestamp
|
||||
uint8_t *p_write = &buffer[14];
|
||||
return (push32(timestamp, &p_write, buffer + NFAPI_NR_P7_HEADER_LENGTH) > 0 ? 0 : -1);
|
||||
}
|
||||
|
||||
uint32_t nfapi_nr_p7_calculate_checksum(uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
return nfapi_nr_calculate_checksum(buffer, len);
|
||||
}
|
||||
|
||||
void *nfapi_p7_allocate(size_t size, nfapi_p7_codec_config_t *config) {
|
||||
if(size == 0)
|
||||
return 0;
|
||||
@@ -3632,7 +3667,7 @@ uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *e
|
||||
|
||||
int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
nfapi_p7_message_header_t *pMessageHeader = pMessageBuf;
|
||||
nfapi_nr_p7_message_header_t *pMessageHeader = pMessageBuf;
|
||||
uint8_t *pWritePackedMessage = pPackedBuf;
|
||||
uint8_t *pPackedLengthField = &pWritePackedMessage[4];
|
||||
|
||||
@@ -3645,7 +3680,7 @@ int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packe
|
||||
|
||||
// process the header
|
||||
if (!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) && push16(pMessageHeader->message_id, &pWritePackedMessage, end)
|
||||
&& push16(0 /*pMessageHeader->message_length*/, &pWritePackedMessage, end)
|
||||
&& push32(0 /*pMessageHeader->message_length*/, &pWritePackedMessage, end)
|
||||
&& push16(pMessageHeader->m_segment_sequence, &pWritePackedMessage, end)
|
||||
&& push32(0 /*pMessageHeader->checksum*/, &pWritePackedMessage, end)
|
||||
&& push32(pMessageHeader->transmit_timestamp, &pWritePackedMessage, end))) {
|
||||
@@ -3744,18 +3779,15 @@ int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packe
|
||||
uintptr_t msgHead = (uintptr_t)pPackedBuf;
|
||||
uintptr_t msgEnd = (uintptr_t)pWritePackedMessage;
|
||||
uint32_t packedMsgLen = msgEnd - msgHead;
|
||||
uint16_t packedMsgLen16;
|
||||
if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) {
|
||||
if (packedMsgLen > packedBufLen) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen);
|
||||
return -1;
|
||||
} else {
|
||||
packedMsgLen16 = (uint16_t)packedMsgLen;
|
||||
}
|
||||
|
||||
// Update the message length in the header
|
||||
pMessageHeader->message_length = packedMsgLen16;
|
||||
pMessageHeader->message_length = packedMsgLen;
|
||||
|
||||
if (!push16(packedMsgLen16, &pPackedLengthField, end))
|
||||
if (!push32(pMessageHeader->message_length, &pPackedLengthField, end))
|
||||
return -1;
|
||||
|
||||
if (1) {
|
||||
@@ -8097,7 +8129,12 @@ static int check_nr_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpack
|
||||
|
||||
// Main unpack functions - public
|
||||
|
||||
int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t *config) {
|
||||
int nfapi_p7_message_header_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
nfapi_p7_message_header_t *pMessageHeader = pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
|
||||
@@ -8112,20 +8149,53 @@ int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, vo
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 header unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// process the header
|
||||
if(!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end) &&
|
||||
pull32(&pReadPackedMessage, &pMessageHeader->checksum, end) &&
|
||||
pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end)))
|
||||
if (!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->checksum, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end)))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nfapi_nr_p7_message_header_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
nfapi_nr_p7_message_header_t *pMessageHeader = pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
|
||||
if (pMessageBuf == NULL || pUnpackedBuf == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 header unpack supplied pointers are null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t *end = (uint8_t *)pMessageBuf + messageBufLen;
|
||||
|
||||
if (messageBufLen < NFAPI_NR_P7_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_nr_p7_message_header_t)) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 header unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen);
|
||||
return -1;
|
||||
}
|
||||
// process the header
|
||||
if (!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->checksum, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end)))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t *config) {
|
||||
int nfapi_p7_message_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
int result = 0;
|
||||
nfapi_p7_message_header_t *pMessageHeader = (nfapi_p7_message_header_t *)pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
@@ -8153,19 +8223,16 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
*/
|
||||
// clean the supplied buffer for - tag value blanking
|
||||
(void)memset(pUnpackedBuf, 0, unpackedBufLen);
|
||||
|
||||
// process the header
|
||||
if(!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end) &&
|
||||
pull32(&pReadPackedMessage, &pMessageHeader->checksum, end) &&
|
||||
pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end))) {
|
||||
if (!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->checksum, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end))) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack header failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((uint8_t *)(pMessageBuf + pMessageHeader->message_length) > end) {
|
||||
if ((uint8_t *)(pMessageBuf + pMessageHeader->message_length) > end) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack message length is greater than the message buffer \n");
|
||||
return -1;
|
||||
}
|
||||
@@ -8182,7 +8249,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
switch (pMessageHeader->message_id) {
|
||||
case NFAPI_DL_CONFIG_REQUEST:
|
||||
if (check_unpack_length(NFAPI_DL_CONFIG_REQUEST, unpackedBufLen))
|
||||
result = unpack_dl_config_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_dl_config_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8198,7 +8265,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_TX_REQUEST:
|
||||
if (check_unpack_length(NFAPI_TX_REQUEST, unpackedBufLen))
|
||||
result = unpack_tx_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_tx_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8206,7 +8273,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_HI_DCI0_REQUEST:
|
||||
if (check_unpack_length(NFAPI_HI_DCI0_REQUEST, unpackedBufLen))
|
||||
result = unpack_hi_dci0_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_hi_dci0_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8214,7 +8281,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_UE_RELEASE_REQUEST:
|
||||
if (check_unpack_length(NFAPI_UE_RELEASE_REQUEST, unpackedBufLen))
|
||||
result = unpack_ue_release_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_ue_release_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8222,7 +8289,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_HARQ_INDICATION:
|
||||
if (check_unpack_length(NFAPI_HARQ_INDICATION, unpackedBufLen))
|
||||
result = unpack_harq_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_harq_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8230,7 +8297,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_CRC_INDICATION:
|
||||
if (check_unpack_length(NFAPI_CRC_INDICATION, unpackedBufLen))
|
||||
result = unpack_crc_indication(&pReadPackedMessage,end, pMessageHeader, config);
|
||||
result = unpack_crc_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8238,7 +8305,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_RX_ULSCH_INDICATION:
|
||||
if (check_unpack_length(NFAPI_RX_ULSCH_INDICATION, unpackedBufLen))
|
||||
result = unpack_rx_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_rx_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8246,7 +8313,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_RACH_INDICATION:
|
||||
if (check_unpack_length(NFAPI_RACH_INDICATION, unpackedBufLen))
|
||||
result = unpack_rach_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_rach_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8254,7 +8321,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_SRS_INDICATION:
|
||||
if (check_unpack_length(NFAPI_SRS_INDICATION, unpackedBufLen))
|
||||
result = unpack_srs_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_srs_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8262,7 +8329,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_RX_SR_INDICATION:
|
||||
if (check_unpack_length(NFAPI_RX_SR_INDICATION, unpackedBufLen))
|
||||
result = unpack_sr_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_sr_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8270,7 +8337,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_RX_CQI_INDICATION:
|
||||
if (check_unpack_length(NFAPI_RX_CQI_INDICATION, unpackedBufLen))
|
||||
result = unpack_cqi_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_cqi_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8278,7 +8345,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_LBT_DL_CONFIG_REQUEST:
|
||||
if (check_unpack_length(NFAPI_LBT_DL_CONFIG_REQUEST, unpackedBufLen))
|
||||
result = unpack_lbt_dl_config_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_lbt_dl_config_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8286,7 +8353,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_LBT_DL_INDICATION:
|
||||
if (check_unpack_length(NFAPI_LBT_DL_INDICATION, unpackedBufLen))
|
||||
result = unpack_lbt_dl_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_lbt_dl_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8294,7 +8361,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_NB_HARQ_INDICATION:
|
||||
if (check_unpack_length(NFAPI_NB_HARQ_INDICATION, unpackedBufLen))
|
||||
result = unpack_nb_harq_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_nb_harq_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8302,7 +8369,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_NRACH_INDICATION:
|
||||
if (check_unpack_length(NFAPI_NRACH_INDICATION, unpackedBufLen))
|
||||
result = unpack_nrach_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_nrach_indication(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8310,7 +8377,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_DL_NODE_SYNC:
|
||||
if (check_unpack_length(NFAPI_DL_NODE_SYNC, unpackedBufLen))
|
||||
result = unpack_dl_node_sync(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_dl_node_sync(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -8334,19 +8401,21 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
|
||||
case NFAPI_UE_RELEASE_RESPONSE:
|
||||
if (check_unpack_length(NFAPI_UE_RELEASE_RESPONSE, unpackedBufLen))
|
||||
result = unpack_ue_release_resp(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
result = unpack_ue_release_resp(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
else
|
||||
return -1;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
|
||||
pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||
if(config && config->unpack_p7_vendor_extension) {
|
||||
if (pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||
if (config && config->unpack_p7_vendor_extension) {
|
||||
result = (config->unpack_p7_vendor_extension)(pMessageHeader, &pReadPackedMessage, end, config);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve decoder provided\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR,
|
||||
"%s VE NFAPI message ID %d. No ve decoder provided\n",
|
||||
__FUNCTION__,
|
||||
pMessageHeader->message_id);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
@@ -8355,173 +8424,162 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
|
||||
break;
|
||||
}
|
||||
|
||||
if(result == 0)
|
||||
if (result == 0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nfapi_nr_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config)
|
||||
int nfapi_nr_p7_message_unpack(void *pMessageBuf,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
int result = 0;
|
||||
nfapi_p7_message_header_t *pMessageHeader = (nfapi_p7_message_header_t*)pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
int result = 0;
|
||||
nfapi_nr_p7_message_header_t *pMessageHeader = (nfapi_nr_p7_message_header_t *)pUnpackedBuf;
|
||||
uint8_t *pReadPackedMessage = pMessageBuf;
|
||||
|
||||
if (pMessageBuf == NULL || pUnpackedBuf == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied pointers are null\n");
|
||||
return -1;
|
||||
}
|
||||
if (pMessageBuf == NULL || pUnpackedBuf == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied pointers are null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t *end = (uint8_t*)pMessageBuf + messageBufLen;
|
||||
uint8_t *end = (uint8_t *)pMessageBuf + messageBufLen;
|
||||
|
||||
if (messageBufLen < NFAPI_P7_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p7_message_header_t))
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen);
|
||||
return -1;
|
||||
}
|
||||
if (messageBufLen < NFAPI_NR_P7_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_nr_p7_message_header_t)) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// clean the supplied buffer for - tag value blanking
|
||||
(void)memset(pUnpackedBuf, 0, unpackedBufLen);
|
||||
// process the header
|
||||
if (!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && pull16(&pReadPackedMessage, &pMessageHeader->message_id, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->message_length, end)
|
||||
&& pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->checksum, end)
|
||||
&& pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end))) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack header failed\n");
|
||||
return -1;
|
||||
}
|
||||
if ((uint8_t *)(pMessageBuf + pMessageHeader->message_length) > end) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack message length is greater than the message buffer \n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// process the header
|
||||
if(!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) &&
|
||||
pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end) &&
|
||||
pull32(&pReadPackedMessage, &pMessageHeader->checksum, end) &&
|
||||
pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end)))
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack header failed\n");
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
if(check_unpack_length(pMessageHeader->message_id, unpackedBufLen) == 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack unpack buffer is not large enough \n");
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
if((uint8_t*)(pMessageBuf + pMessageHeader->message_length) > end)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack message length is greater than the message buffer \n");
|
||||
return -1;
|
||||
}
|
||||
// look for the specific message
|
||||
switch (pMessageHeader->message_id) {
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST, unpackedBufLen))
|
||||
result = unpack_dl_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
|
||||
/*
|
||||
if(check_unpack_length(pMessageHeader->message_id, unpackedBufLen) == 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack unpack buffer is not large enough \n");
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST, unpackedBufLen))
|
||||
result = unpack_ul_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST, unpackedBufLen))
|
||||
result = unpack_tx_data_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST, unpackedBufLen))
|
||||
result = unpack_ul_dci_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_UE_RELEASE_REQUEST:
|
||||
if (check_unpack_length(NFAPI_UE_RELEASE_REQUEST, unpackedBufLen))
|
||||
result = unpack_ue_release_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION, unpackedBufLen)) {
|
||||
nfapi_nr_slot_indication_scf_t *msg = (nfapi_nr_slot_indication_scf_t *)pMessageHeader;
|
||||
result = unpack_nr_slot_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
|
||||
// look for the specific message
|
||||
switch (pMessageHeader->message_id)
|
||||
{
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST, unpackedBufLen))
|
||||
result = unpack_dl_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION, unpackedBufLen)) {
|
||||
nfapi_nr_rx_data_indication_t *msg = (nfapi_nr_rx_data_indication_t *)pMessageHeader;
|
||||
msg->pdu_list = (nfapi_nr_rx_data_pdu_t *)malloc(sizeof(nfapi_nr_rx_data_pdu_t));
|
||||
msg->pdu_list->pdu = (uint8_t *)malloc(sizeof(uint8_t));
|
||||
result = unpack_nr_rx_data_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST, unpackedBufLen))
|
||||
result = unpack_ul_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST, unpackedBufLen))
|
||||
result = unpack_tx_data_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST, unpackedBufLen))
|
||||
result = unpack_ul_dci_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_UE_RELEASE_REQUEST:
|
||||
if (check_unpack_length(NFAPI_UE_RELEASE_REQUEST, unpackedBufLen))
|
||||
result = unpack_ue_release_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION, unpackedBufLen)){
|
||||
nfapi_nr_slot_indication_scf_t* msg = (nfapi_nr_slot_indication_scf_t*) pMessageHeader;
|
||||
result = unpack_nr_slot_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION, unpackedBufLen)) {
|
||||
nfapi_nr_crc_indication_t *msg = (nfapi_nr_crc_indication_t *)pMessageHeader;
|
||||
msg->crc_list = (nfapi_nr_crc_t *)malloc(sizeof(nfapi_nr_crc_t));
|
||||
result = unpack_nr_crc_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION, unpackedBufLen)){
|
||||
nfapi_nr_rx_data_indication_t* msg = (nfapi_nr_rx_data_indication_t*) pMessageHeader;
|
||||
msg->pdu_list = (nfapi_nr_rx_data_pdu_t*) malloc(sizeof(nfapi_nr_rx_data_pdu_t));
|
||||
msg->pdu_list->pdu = (uint8_t *) malloc(sizeof(uint8_t));
|
||||
result = unpack_nr_rx_data_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION, unpackedBufLen)) {
|
||||
nfapi_nr_uci_indication_t *msg = (nfapi_nr_uci_indication_t *)pMessageHeader;
|
||||
msg->uci_list = (nfapi_nr_uci_t *)malloc(sizeof(nfapi_nr_uci_t));
|
||||
result = unpack_nr_uci_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION, unpackedBufLen)){
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION, unpackedBufLen)) {
|
||||
nfapi_nr_srs_indication_t *msg = (nfapi_nr_srs_indication_t *)pMessageHeader;
|
||||
msg->pdu_list = (nfapi_nr_srs_indication_pdu_t *)malloc(sizeof(nfapi_nr_srs_indication_pdu_t));
|
||||
result = unpack_nr_srs_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
|
||||
nfapi_nr_crc_indication_t* msg = (nfapi_nr_crc_indication_t*) pMessageHeader;
|
||||
msg->crc_list = (nfapi_nr_crc_t*) malloc(sizeof(nfapi_nr_crc_t));
|
||||
result = unpack_nr_crc_indication(&pReadPackedMessage,end , msg, config);
|
||||
}
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION, unpackedBufLen)) {
|
||||
nfapi_nr_rach_indication_t *msg = (nfapi_nr_rach_indication_t *)pMessageHeader;
|
||||
result = unpack_nr_rach_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION, unpackedBufLen)){
|
||||
nfapi_nr_uci_indication_t* msg = (nfapi_nr_uci_indication_t*) pMessageHeader;
|
||||
msg->uci_list = (nfapi_nr_uci_t*) malloc(sizeof(nfapi_nr_uci_t));
|
||||
result = unpack_nr_uci_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC, unpackedBufLen))
|
||||
result = unpack_nr_dl_node_sync(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION, unpackedBufLen)){
|
||||
nfapi_nr_srs_indication_t* msg = (nfapi_nr_srs_indication_t*) pMessageHeader;
|
||||
msg->pdu_list = (nfapi_nr_srs_indication_pdu_t*) malloc(sizeof(nfapi_nr_srs_indication_pdu_t));
|
||||
result = unpack_nr_srs_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC, unpackedBufLen))
|
||||
result = unpack_nr_ul_node_sync(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION, unpackedBufLen)){
|
||||
nfapi_nr_rach_indication_t* msg = (nfapi_nr_rach_indication_t*) pMessageHeader;
|
||||
result = unpack_nr_rach_indication(&pReadPackedMessage, end, msg, config);
|
||||
}
|
||||
break;
|
||||
case NFAPI_TIMING_INFO:
|
||||
if (check_unpack_length(NFAPI_TIMING_INFO, unpackedBufLen))
|
||||
result = unpack_nr_timing_info(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC, unpackedBufLen))
|
||||
result = unpack_nr_dl_node_sync(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
case NFAPI_UE_RELEASE_RESPONSE:
|
||||
if (check_unpack_length(NFAPI_UE_RELEASE_RESPONSE, unpackedBufLen))
|
||||
result = unpack_ue_release_resp(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC:
|
||||
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC, unpackedBufLen))
|
||||
result = unpack_nr_ul_node_sync(&pReadPackedMessage, end , pMessageHeader, config);
|
||||
break;
|
||||
default:
|
||||
|
||||
case NFAPI_TIMING_INFO:
|
||||
if (check_unpack_length(NFAPI_TIMING_INFO, unpackedBufLen))
|
||||
result = unpack_nr_timing_info(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
|
||||
case NFAPI_UE_RELEASE_RESPONSE:
|
||||
if (check_unpack_length(NFAPI_UE_RELEASE_RESPONSE, unpackedBufLen))
|
||||
result = unpack_ue_release_resp(&pReadPackedMessage, end, pMessageHeader, config);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
|
||||
pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX)
|
||||
{
|
||||
if(config && config->unpack_p7_vendor_extension)
|
||||
{
|
||||
result = (config->unpack_p7_vendor_extension)(pMessageHeader, &pReadPackedMessage, end, config);
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve decoder provided\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||
if (config && config->unpack_p7_vendor_extension) {
|
||||
result = (config->unpack_p7_vendor_extension)(pMessageHeader, &pReadPackedMessage, end, config);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR,
|
||||
"%s VE NFAPI message ID %d. No ve decoder provided\n",
|
||||
__FUNCTION__,
|
||||
pMessageHeader->message_id);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (result == 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack failed to pack message\n");
|
||||
|
||||
@@ -40,7 +40,7 @@ int pnf_connect(pnf_t *pnf);
|
||||
int pnf_message_pump(pnf_t *pnf);
|
||||
int pnf_nr_message_pump(pnf_t *pnf);
|
||||
|
||||
int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len);
|
||||
int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_nr_p4_p5_message_header_t* msg, uint32_t msg_len);
|
||||
int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len);
|
||||
int pnf_pack_and_send_p4_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len);
|
||||
int pnf_send_message(pnf_t* pnf, uint8_t* msg, uint32_t msg_len, uint16_t stream_id);
|
||||
|
||||
@@ -148,7 +148,7 @@ typedef struct {
|
||||
int pnf_p7_message_pump(pnf_p7_t* pnf_p7);
|
||||
int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7);
|
||||
int pnf_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* msg, uint32_t msg_len);
|
||||
int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* header, uint32_t msg_len);
|
||||
int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_nr_p7_message_header_t* header, uint32_t msg_len);
|
||||
int pnf_p7_send_message(pnf_p7_t* pnf_p7, uint8_t* msg, uint32_t msg_len);
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ pnf_p7_rx_message_t* pnf_p7_rx_reassembly_queue_add_segment(pnf_p7_t* pnf_p7, pn
|
||||
void pnf_p7_rx_reassembly_queue_remove_msg(pnf_p7_t* pnf_p7, pnf_p7_rx_reassembly_queue_t* queue, pnf_p7_rx_message_t* msg);
|
||||
void pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7_t* pnf_p7, pnf_p7_rx_reassembly_queue_t* queue, uint32_t rx_hr_time, uint32_t delta);
|
||||
|
||||
int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* header, uint32_t msg_len);
|
||||
int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_nr_p7_message_header_t* header, uint32_t msg_len);
|
||||
|
||||
#endif /* _PNF_P7_H_ */
|
||||
|
||||
|
||||
@@ -305,19 +305,19 @@ typedef struct nfapi_pnf_config
|
||||
* \param msg A pointer to the decode P4/P5 message
|
||||
* \return not current used
|
||||
*/
|
||||
int (*vendor_ext)(nfapi_pnf_config_t* config, nfapi_p4_p5_message_header_t* msg);
|
||||
int (*vendor_ext)(nfapi_pnf_config_t* config, void* msg);
|
||||
|
||||
/*! A callback to allocate vendor extension message
|
||||
* \param message_id The message id from the decode P4/P5 message header
|
||||
* \param msg_size A pointer a the size of the allocated message structure. The callee should set this
|
||||
* \return A pointer to a allocated P4/P5 message structure
|
||||
*/
|
||||
nfapi_p4_p5_message_header_t* (*allocate_p4_p5_vendor_ext)(uint16_t message_id, uint16_t* msg_size);
|
||||
void* (*allocate_p4_p5_vendor_ext)(uint16_t message_id, uint16_t* msg_size);
|
||||
|
||||
/*! A callback to deallocate vendor extension message
|
||||
* \param header A pointer to an P4/P5 message structure
|
||||
*/
|
||||
void (*deallocate_p4_p5_vendor_ext)(nfapi_p4_p5_message_header_t* header);
|
||||
void (*deallocate_p4_p5_vendor_ext)(void* header);
|
||||
|
||||
|
||||
|
||||
@@ -711,7 +711,7 @@ typedef struct nfapi_pnf_p7_config
|
||||
* \param msg A pointer to a decode vendor extention message
|
||||
* \return not currently used
|
||||
*/
|
||||
int (*vendor_ext)(nfapi_pnf_p7_config_t* config, nfapi_p7_message_header_t* msg);
|
||||
int (*vendor_ext)(nfapi_pnf_p7_config_t* config, void* msg);
|
||||
|
||||
/*! A callback to allocate vendor extension message
|
||||
* \param message_id The vendor extention message id from the decode message header
|
||||
@@ -720,12 +720,12 @@ typedef struct nfapi_pnf_p7_config
|
||||
*
|
||||
*
|
||||
*/
|
||||
nfapi_p7_message_header_t* (*allocate_p7_vendor_ext)(uint16_t message_id, uint16_t* msg_size);
|
||||
void* (*allocate_p7_vendor_ext)(uint16_t message_id, uint16_t* msg_size);
|
||||
|
||||
/*! A callback to deallocate vendor extension message
|
||||
* \param header A pointer to a p7 vendor extention message
|
||||
*/
|
||||
void (*deallocate_p7_vendor_ext)(nfapi_p7_message_header_t* header);
|
||||
void (*deallocate_p7_vendor_ext)(void* header);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1519,100 +1519,96 @@ void pnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_t* pnf, uin
|
||||
}
|
||||
}
|
||||
|
||||
void pnf_nr_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
|
||||
void pnf_nr_handle_p5_message(pnf_t* pnf, void* pRecvMsg, int recvMsgLen)
|
||||
{
|
||||
nfapi_p4_p5_message_header_t messageHeader;
|
||||
nfapi_nr_p4_p5_message_header_t messageHeader;
|
||||
|
||||
// validate the input params
|
||||
if(pRecvMsg == NULL || recvMsgLen < NFAPI_HEADER_LENGTH)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
// validate the input params
|
||||
if (pRecvMsg == NULL || recvMsgLen < NFAPI_HEADER_LENGTH) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
// unpack the message header
|
||||
if (nfapi_p5_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p4_p5_message_header_t), &pnf->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
}
|
||||
// unpack the message header
|
||||
if (nfapi_nr_p5_message_header_unpack(pRecvMsg,
|
||||
recvMsgLen,
|
||||
&messageHeader,
|
||||
sizeof(nfapi_nr_p4_p5_message_header_t),
|
||||
&pnf->_public.codec_config)
|
||||
< 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (messageHeader.message_id)
|
||||
{
|
||||
case NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_REQUEST:
|
||||
pnf_nr_handle_pnf_param_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
switch (messageHeader.message_id) {
|
||||
case NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_REQUEST:
|
||||
pnf_nr_handle_pnf_param_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_REQUEST:
|
||||
pnf_nr_handle_pnf_config_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_REQUEST:
|
||||
pnf_nr_handle_pnf_config_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_PNF_START_REQUEST:
|
||||
pnf_nr_handle_pnf_start_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_PNF_START_REQUEST:
|
||||
pnf_nr_handle_pnf_start_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_PNF_STOP_REQUEST:
|
||||
pnf_handle_pnf_stop_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_PNF_STOP_REQUEST:
|
||||
pnf_handle_pnf_stop_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
|
||||
pnf_nr_handle_param_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
|
||||
pnf_nr_handle_param_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
|
||||
pnf_nr_handle_config_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
|
||||
pnf_nr_handle_config_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
|
||||
pnf_nr_handle_start_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
|
||||
pnf_nr_handle_start_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
|
||||
pnf_nr_handle_stop_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
|
||||
pnf_nr_handle_stop_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_MEASUREMENT_REQUEST:
|
||||
pnf_handle_measurement_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_MEASUREMENT_REQUEST:
|
||||
pnf_handle_measurement_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_RSSI_REQUEST:
|
||||
pnf_handle_rssi_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_RSSI_REQUEST:
|
||||
pnf_handle_rssi_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_CELL_SEARCH_REQUEST:
|
||||
pnf_handle_cell_search_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_CELL_SEARCH_REQUEST:
|
||||
pnf_handle_cell_search_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_BROADCAST_DETECT_REQUEST:
|
||||
pnf_handle_broadcast_detect_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_BROADCAST_DETECT_REQUEST:
|
||||
pnf_handle_broadcast_detect_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST:
|
||||
pnf_handle_system_information_schedule_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST:
|
||||
pnf_handle_system_information_schedule_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_SYSTEM_INFORMATION_REQUEST:
|
||||
pnf_handle_system_information_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_SYSTEM_INFORMATION_REQUEST:
|
||||
pnf_handle_system_information_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
case NFAPI_NMM_STOP_REQUEST:
|
||||
pnf_handle_nmm_stop_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
case NFAPI_NMM_STOP_REQUEST:
|
||||
pnf_handle_nmm_stop_request(pnf, pRecvMsg, recvMsgLen);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
if(messageHeader.message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
|
||||
messageHeader.message_id <= NFAPI_VENDOR_EXT_MSG_MAX)
|
||||
{
|
||||
pnf_handle_vendor_extension(pRecvMsg, recvMsgLen, pnf, messageHeader.message_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P5 Unknown message ID %d\n", __FUNCTION__, messageHeader.message_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (messageHeader.message_id >= NFAPI_VENDOR_EXT_MSG_MIN && messageHeader.message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||
pnf_handle_vendor_extension(pRecvMsg, recvMsgLen, pnf, messageHeader.message_id);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P5 Unknown message ID %d\n", __FUNCTION__, messageHeader.message_id);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void pnf_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
|
||||
@@ -1711,21 +1707,17 @@ 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 pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_nr_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->_public.codec_config);
|
||||
int packed_len =
|
||||
nfapi_nr_p5_message_pack(msg, msg_len, pnf->tx_message_buffer, sizeof(pnf->tx_message_buffer), &pnf->_public.codec_config);
|
||||
|
||||
if (packed_len < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p5_message_pack failed (%d)\n", packed_len);
|
||||
return -1;
|
||||
}
|
||||
if (packed_len < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_nr_p5_message_pack failed (%d)\n", packed_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return pnf_send_message(pnf, pnf->tx_message_buffer, packed_len, 0/*msg->stream_id*/);
|
||||
return pnf_send_message(pnf, pnf->tx_message_buffer, packed_len, 0 /*msg->stream_id*/);
|
||||
}
|
||||
|
||||
|
||||
@@ -2123,7 +2115,7 @@ int pnf_nr_read_dispatch_message(pnf_t* pnf)
|
||||
// 3. Read the buffer
|
||||
// 4. Handle the p5 message
|
||||
|
||||
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
|
||||
uint32_t header_buffer_size = NFAPI_NR_P5_HEADER_LENGTH;
|
||||
uint8_t header_buffer[header_buffer_size];
|
||||
|
||||
uint32_t stack_buffer_size = 32; // should it be the size of then sctp_notificatoin structure
|
||||
@@ -2155,8 +2147,8 @@ int pnf_nr_read_dispatch_message(pnf_t* pnf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
int unpack_result = nfapi_nr_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
|
||||
if (unpack_result < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to unpack p5 message header\n");
|
||||
return 0;
|
||||
|
||||
+236
-264
@@ -666,95 +666,83 @@ int pnf_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t*
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* header, uint32_t msg_len)
|
||||
int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_nr_p7_message_header_t* header, uint32_t msg_len)
|
||||
{
|
||||
header->m_segment_sequence = NFAPI_P7_SET_MSS(0, 0, pnf_p7->sequence_number);
|
||||
header->m_segment_sequence = NFAPI_P7_SET_MSS(0, 0, pnf_p7->sequence_number);
|
||||
|
||||
// Need to guard against different threads calling the encode function at the same time
|
||||
if(pthread_mutex_lock(&(pnf_p7->pack_mutex)) != 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n");
|
||||
return -1;
|
||||
}
|
||||
// Need to guard against different threads calling the encode function at the same time
|
||||
if (pthread_mutex_lock(&(pnf_p7->pack_mutex)) != 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int len = nfapi_nr_p7_message_pack(header, pnf_p7->tx_message_buffer, sizeof(pnf_p7->tx_message_buffer), &pnf_p7->_public.codec_config);
|
||||
int len =
|
||||
nfapi_nr_p7_message_pack(header, pnf_p7->tx_message_buffer, sizeof(pnf_p7->tx_message_buffer), &pnf_p7->_public.codec_config);
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
if(pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p7_message_pack failed with return %d\n", len );
|
||||
return -1;
|
||||
}
|
||||
if (len < 0) {
|
||||
if (pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(len > pnf_p7->_public.segment_size)
|
||||
{
|
||||
int msg_body_len = len - NFAPI_P7_HEADER_LENGTH ;
|
||||
int seg_body_len = pnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH ;
|
||||
int segment_count = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0);
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p7_message_pack failed with return %d\n", len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int segment = 0;
|
||||
int offset = NFAPI_P7_HEADER_LENGTH;
|
||||
uint8_t buffer[pnf_p7->_public.segment_size];
|
||||
for(segment = 0; segment < segment_count; ++segment)
|
||||
{
|
||||
uint8_t last = 0;
|
||||
uint16_t size = pnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH;
|
||||
if(segment + 1 == segment_count)
|
||||
{
|
||||
last = 1;
|
||||
size = (msg_body_len) - (seg_body_len * segment);
|
||||
}
|
||||
if (len > pnf_p7->_public.segment_size) {
|
||||
int msg_body_len = len - NFAPI_NR_P7_HEADER_LENGTH;
|
||||
int seg_body_len = pnf_p7->_public.segment_size - NFAPI_NR_P7_HEADER_LENGTH;
|
||||
int segment_count = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0);
|
||||
|
||||
uint16_t segment_size = size + NFAPI_P7_HEADER_LENGTH;
|
||||
int segment = 0;
|
||||
int offset = NFAPI_NR_P7_HEADER_LENGTH;
|
||||
uint8_t buffer[pnf_p7->_public.segment_size];
|
||||
for (segment = 0; segment < segment_count; ++segment) {
|
||||
uint8_t last = 0;
|
||||
uint16_t size = pnf_p7->_public.segment_size - NFAPI_NR_P7_HEADER_LENGTH;
|
||||
if (segment + 1 == segment_count) {
|
||||
last = 1;
|
||||
size = (msg_body_len) - (seg_body_len * segment);
|
||||
}
|
||||
|
||||
// Update the header with the m and segement
|
||||
memcpy(&buffer[0], pnf_p7->tx_message_buffer, NFAPI_P7_HEADER_LENGTH);
|
||||
uint16_t segment_size = size + NFAPI_NR_P7_HEADER_LENGTH;
|
||||
|
||||
// set the segment length
|
||||
buffer[4] = (segment_size & 0xFF00) >> 8;
|
||||
buffer[5] = (segment_size & 0xFF);
|
||||
// Update the header with the m and segement
|
||||
memcpy(&buffer[0], pnf_p7->tx_message_buffer, NFAPI_NR_P7_HEADER_LENGTH);
|
||||
|
||||
// set the m & segment number
|
||||
buffer[6] = ((!last) << 7) + segment;
|
||||
// set the segment length
|
||||
buffer[6] = (segment_size & 0xFF00) >> 8;
|
||||
buffer[7] = (segment_size & 0xFF);
|
||||
|
||||
memcpy(&buffer[NFAPI_P7_HEADER_LENGTH], pnf_p7->tx_message_buffer + offset, size);
|
||||
offset += size;
|
||||
// set the m & segment number
|
||||
buffer[8] = ((!last) << 7) + segment;
|
||||
|
||||
if(pnf_p7->_public.checksum_enabled)
|
||||
{
|
||||
nfapi_p7_update_checksum(buffer, segment_size);
|
||||
}
|
||||
memcpy(&buffer[NFAPI_NR_P7_HEADER_LENGTH], pnf_p7->tx_message_buffer + offset, size);
|
||||
offset += size;
|
||||
|
||||
if (pnf_p7->_public.checksum_enabled) {
|
||||
nfapi_nr_p7_update_checksum(buffer, segment_size);
|
||||
}
|
||||
|
||||
pnf_p7_send_message(pnf_p7, &buffer[0], segment_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pnf_p7->_public.checksum_enabled)
|
||||
{
|
||||
nfapi_p7_update_checksum(pnf_p7->tx_message_buffer, len);
|
||||
}
|
||||
pnf_p7_send_message(pnf_p7, &buffer[0], segment_size);
|
||||
}
|
||||
} else {
|
||||
if (pnf_p7->_public.checksum_enabled) {
|
||||
nfapi_nr_p7_update_checksum(pnf_p7->tx_message_buffer, len);
|
||||
}
|
||||
|
||||
// simple case that the message fits in a single segment
|
||||
pnf_p7_send_message(pnf_p7, pnf_p7->tx_message_buffer, len);
|
||||
}
|
||||
// simple case that the message fits in a single segment
|
||||
pnf_p7_send_message(pnf_p7, pnf_p7->tx_message_buffer, len);
|
||||
}
|
||||
|
||||
pnf_p7->sequence_number++;
|
||||
|
||||
if(pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return -1;
|
||||
}
|
||||
pnf_p7->sequence_number++;
|
||||
|
||||
return 0;
|
||||
if (pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pnf_pack_and_send_timing_info(pnf_p7_t* pnf_p7)
|
||||
@@ -2607,62 +2595,52 @@ void pnf_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7,
|
||||
}
|
||||
}
|
||||
|
||||
void pnf_nr_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
|
||||
void pnf_nr_dispatch_p7_message(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
|
||||
{
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
|
||||
// validate the input params
|
||||
if(pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
// validate the input params
|
||||
if (pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
// unpack the message header
|
||||
if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &header, sizeof(header), &pnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
}
|
||||
// unpack the message header
|
||||
if (nfapi_nr_p7_message_header_unpack(pRecvMsg, recvMsgLen, &header, sizeof(header), &pnf_p7->_public.codec_config) < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// ensure the message is sensible
|
||||
if (recvMsgLen < 8 || pRecvMsg == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen);
|
||||
return;
|
||||
}
|
||||
// ensure the message is sensible
|
||||
if (recvMsgLen < 8 || pRecvMsg == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (header.message_id)
|
||||
{
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
|
||||
pnf_nr_handle_dl_node_sync(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
|
||||
pnf_handle_dl_tti_request(pRecvMsg, recvMsgLen, pnf_p7);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
|
||||
pnf_handle_ul_tti_request(pRecvMsg, recvMsgLen, pnf_p7);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
|
||||
pnf_handle_ul_dci_request(pRecvMsg, recvMsgLen, pnf_p7);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
|
||||
pnf_handle_tx_data_request(pRecvMsg, recvMsgLen, pnf_p7);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if(header.message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
|
||||
header.message_id <= NFAPI_VENDOR_EXT_MSG_MAX)
|
||||
{
|
||||
pnf_handle_p7_vendor_extension(pRecvMsg, recvMsgLen, pnf_p7, header.message_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P7 Unknown message ID %d\n", __FUNCTION__, header.message_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (header.message_id) {
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
|
||||
pnf_nr_handle_dl_node_sync(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
|
||||
pnf_handle_dl_tti_request(pRecvMsg, recvMsgLen, pnf_p7);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
|
||||
pnf_handle_ul_tti_request(pRecvMsg, recvMsgLen, pnf_p7);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
|
||||
pnf_handle_ul_dci_request(pRecvMsg, recvMsgLen, pnf_p7);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
|
||||
pnf_handle_tx_data_request(pRecvMsg, recvMsgLen, pnf_p7);
|
||||
break;
|
||||
default: {
|
||||
if (header.message_id >= NFAPI_VENDOR_EXT_MSG_MIN && header.message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||
pnf_handle_p7_vendor_extension(pRecvMsg, recvMsgLen, pnf_p7, header.message_id);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P7 Unknown message ID %d\n", __FUNCTION__, header.message_id);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void pnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
|
||||
@@ -2771,110 +2749,104 @@ void pnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, ui
|
||||
|
||||
}
|
||||
|
||||
void pnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
|
||||
void pnf_nr_handle_p7_message(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
|
||||
{
|
||||
nfapi_p7_message_header_t messageHeader;
|
||||
nfapi_nr_p7_message_header_t messageHeader;
|
||||
|
||||
// validate the input params
|
||||
if(pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "pnf_handle_p7_message: invalid input params (%p %d %p)\n", pRecvMsg, recvMsgLen, pnf_p7);
|
||||
return;
|
||||
}
|
||||
// validate the input params
|
||||
if (pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "pnf_handle_p7_message: invalid input params (%p %d %p)\n", pRecvMsg, recvMsgLen, pnf_p7);
|
||||
return;
|
||||
}
|
||||
|
||||
// unpack the message header
|
||||
if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p7_message_header_t), &pnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
}
|
||||
// unpack the message header
|
||||
if (nfapi_nr_p7_message_header_unpack(pRecvMsg,
|
||||
recvMsgLen,
|
||||
&messageHeader,
|
||||
sizeof(nfapi_nr_p7_message_header_t),
|
||||
&pnf_p7->_public.codec_config)
|
||||
< 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t m = NFAPI_P7_GET_MORE(messageHeader.m_segment_sequence);
|
||||
uint8_t sequence_num = NFAPI_P7_GET_SEQUENCE(messageHeader.m_segment_sequence);
|
||||
uint8_t segment_num = NFAPI_P7_GET_SEGMENT(messageHeader.m_segment_sequence);
|
||||
uint8_t m = NFAPI_P7_GET_MORE(messageHeader.m_segment_sequence);
|
||||
uint8_t sequence_num = NFAPI_P7_GET_SEQUENCE(messageHeader.m_segment_sequence);
|
||||
uint8_t segment_num = NFAPI_P7_GET_SEGMENT(messageHeader.m_segment_sequence);
|
||||
|
||||
if(pnf_p7->_public.checksum_enabled)
|
||||
{
|
||||
uint32_t checksum = nfapi_p7_calculate_checksum(pRecvMsg, recvMsgLen);
|
||||
if(checksum != messageHeader.checksum)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Checksum verification failed %d %d\n", checksum, messageHeader.checksum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (pnf_p7->_public.checksum_enabled) {
|
||||
uint32_t checksum = nfapi_nr_p7_calculate_checksum(pRecvMsg, recvMsgLen);
|
||||
if (checksum != messageHeader.checksum) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Checksum verification failed %d %d\n", checksum, messageHeader.checksum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(m == 0 && segment_num == 0)
|
||||
{
|
||||
// we have a complete message
|
||||
// ensure the message is sensible
|
||||
if (recvMsgLen < 8 || pRecvMsg == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen);
|
||||
return;
|
||||
}
|
||||
if (m == 0 && segment_num == 0) {
|
||||
// we have a complete message
|
||||
// ensure the message is sensible
|
||||
if (recvMsgLen < 8 || pRecvMsg == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen);
|
||||
return;
|
||||
}
|
||||
|
||||
pnf_nr_dispatch_p7_message(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
pnf_p7_rx_message_t* rx_msg = pnf_p7_rx_reassembly_queue_add_segment(pnf_p7, &(pnf_p7->reassembly_queue), rx_hr_time, sequence_num, segment_num, m, pRecvMsg, recvMsgLen);
|
||||
pnf_nr_dispatch_p7_message(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time);
|
||||
} else {
|
||||
pnf_p7_rx_message_t* rx_msg = pnf_p7_rx_reassembly_queue_add_segment(pnf_p7,
|
||||
&(pnf_p7->reassembly_queue),
|
||||
rx_hr_time,
|
||||
sequence_num,
|
||||
segment_num,
|
||||
m,
|
||||
pRecvMsg,
|
||||
recvMsgLen);
|
||||
|
||||
if(rx_msg->num_segments_received == rx_msg->num_segments_expected)
|
||||
{
|
||||
// send the buffer on
|
||||
uint16_t i = 0;
|
||||
uint16_t length = 0;
|
||||
for(i = 0; i < rx_msg->num_segments_expected; ++i)
|
||||
{
|
||||
length += rx_msg->segments[i].length - (i > 0 ? NFAPI_P7_HEADER_LENGTH : 0);
|
||||
}
|
||||
|
||||
if(pnf_p7->reassemby_buffer_size < length)
|
||||
{
|
||||
pnf_p7_free(pnf_p7, pnf_p7->reassemby_buffer);
|
||||
pnf_p7->reassemby_buffer = 0;
|
||||
}
|
||||
if (rx_msg->num_segments_received == rx_msg->num_segments_expected) {
|
||||
// send the buffer on
|
||||
uint16_t i = 0;
|
||||
uint16_t length = 0;
|
||||
for (i = 0; i < rx_msg->num_segments_expected; ++i) {
|
||||
length += rx_msg->segments[i].length - (i > 0 ? NFAPI_NR_P7_HEADER_LENGTH : 0);
|
||||
}
|
||||
|
||||
if(pnf_p7->reassemby_buffer == 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "Resizing PNF_P7 Reassembly buffer %d->%d\n", pnf_p7->reassemby_buffer_size, length);
|
||||
pnf_p7->reassemby_buffer = (uint8_t*)pnf_p7_malloc(pnf_p7, length);
|
||||
if (pnf_p7->reassemby_buffer_size < length) {
|
||||
pnf_p7_free(pnf_p7, pnf_p7->reassemby_buffer);
|
||||
pnf_p7->reassemby_buffer = 0;
|
||||
}
|
||||
|
||||
if(pnf_p7->reassemby_buffer == 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "Failed to allocate PNF_P7 reassemby buffer len:%d\n", length);
|
||||
return;
|
||||
}
|
||||
memset(pnf_p7->reassemby_buffer, 0, length);
|
||||
pnf_p7->reassemby_buffer_size = length;
|
||||
}
|
||||
|
||||
uint16_t offset = 0;
|
||||
for(i = 0; i < rx_msg->num_segments_expected; ++i)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
memcpy(pnf_p7->reassemby_buffer, rx_msg->segments[i].buffer, rx_msg->segments[i].length);
|
||||
offset += rx_msg->segments[i].length;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(pnf_p7->reassemby_buffer + offset, rx_msg->segments[i].buffer + NFAPI_P7_HEADER_LENGTH, rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH);
|
||||
offset += rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH;
|
||||
}
|
||||
}
|
||||
if (pnf_p7->reassemby_buffer == 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "Resizing PNF_P7 Reassembly buffer %d->%d\n", pnf_p7->reassemby_buffer_size, length);
|
||||
pnf_p7->reassemby_buffer = (uint8_t*)pnf_p7_malloc(pnf_p7, length);
|
||||
|
||||
|
||||
pnf_nr_dispatch_p7_message(pnf_p7->reassemby_buffer, length, pnf_p7, rx_msg->rx_hr_time);
|
||||
if (pnf_p7->reassemby_buffer == 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "Failed to allocate PNF_P7 reassemby buffer len:%d\n", length);
|
||||
return;
|
||||
}
|
||||
memset(pnf_p7->reassemby_buffer, 0, length);
|
||||
pnf_p7->reassemby_buffer_size = length;
|
||||
}
|
||||
|
||||
uint16_t offset = 0;
|
||||
for (i = 0; i < rx_msg->num_segments_expected; ++i) {
|
||||
if (i == 0) {
|
||||
memcpy(pnf_p7->reassemby_buffer, rx_msg->segments[i].buffer, rx_msg->segments[i].length);
|
||||
offset += rx_msg->segments[i].length;
|
||||
} else {
|
||||
memcpy(pnf_p7->reassemby_buffer + offset,
|
||||
rx_msg->segments[i].buffer + NFAPI_NR_P7_HEADER_LENGTH,
|
||||
rx_msg->segments[i].length - NFAPI_NR_P7_HEADER_LENGTH);
|
||||
offset += rx_msg->segments[i].length - NFAPI_NR_P7_HEADER_LENGTH;
|
||||
}
|
||||
}
|
||||
|
||||
// delete the structure
|
||||
pnf_p7_rx_reassembly_queue_remove_msg(pnf_p7, &(pnf_p7->reassembly_queue), rx_msg);
|
||||
}
|
||||
}
|
||||
pnf_nr_dispatch_p7_message(pnf_p7->reassemby_buffer, length, pnf_p7, rx_msg->rx_hr_time);
|
||||
|
||||
pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7, &(pnf_p7->reassembly_queue), rx_hr_time, 1000);
|
||||
|
||||
// delete the structure
|
||||
pnf_p7_rx_reassembly_queue_remove_msg(pnf_p7, &(pnf_p7->reassembly_queue), rx_msg);
|
||||
}
|
||||
}
|
||||
|
||||
pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7, &(pnf_p7->reassembly_queue), rx_hr_time, 1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -2949,63 +2921,63 @@ void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time)
|
||||
|
||||
void pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time)
|
||||
{
|
||||
int recvfrom_result = 0;
|
||||
struct sockaddr_in remote_addr;
|
||||
socklen_t remote_addr_size = sizeof(remote_addr);
|
||||
remote_addr.sin_family = 2; //hardcoded
|
||||
do
|
||||
{
|
||||
// peek the header
|
||||
uint8_t header_buffer[NFAPI_P7_HEADER_LENGTH];
|
||||
recvfrom_result = recvfrom(pnf_p7->p7_sock, header_buffer, NFAPI_P7_HEADER_LENGTH, MSG_DONTWAIT | MSG_PEEK, (struct sockaddr*)&remote_addr, &remote_addr_size);
|
||||
if(recvfrom_result > 0)
|
||||
{
|
||||
// get the segment size
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_p7_message_header_unpack(header_buffer, NFAPI_P7_HEADER_LENGTH, &header, 34, 0);
|
||||
int recvfrom_result = 0;
|
||||
struct sockaddr_in remote_addr;
|
||||
socklen_t remote_addr_size = sizeof(remote_addr);
|
||||
remote_addr.sin_family = 2; // hardcoded
|
||||
do {
|
||||
// peek the header
|
||||
uint8_t header_buffer[NFAPI_NR_P7_HEADER_LENGTH];
|
||||
recvfrom_result = recvfrom(pnf_p7->p7_sock,
|
||||
header_buffer,
|
||||
NFAPI_NR_P7_HEADER_LENGTH,
|
||||
MSG_DONTWAIT | MSG_PEEK,
|
||||
(struct sockaddr*)&remote_addr,
|
||||
&remote_addr_size);
|
||||
if (recvfrom_result > 0) {
|
||||
// get the segment size
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_unpack(header_buffer, NFAPI_NR_P7_HEADER_LENGTH, &header, 34, 0);
|
||||
|
||||
// resize the buffer if we have a large segment
|
||||
if(header.message_length > pnf_p7->rx_message_buffer_size)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length);
|
||||
pnf_p7->rx_message_buffer = realloc(pnf_p7->rx_message_buffer, header.message_length);
|
||||
pnf_p7->rx_message_buffer_size = header.message_length;
|
||||
}
|
||||
// resize the buffer if we have a large segment
|
||||
if (header.message_length > pnf_p7->rx_message_buffer_size) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length);
|
||||
pnf_p7->rx_message_buffer = realloc(pnf_p7->rx_message_buffer, header.message_length);
|
||||
pnf_p7->rx_message_buffer_size = header.message_length;
|
||||
}
|
||||
|
||||
// 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);
|
||||
// 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);
|
||||
|
||||
now_hr_time = pnf_get_current_time_hr(); //moved to here - get closer timestamp???
|
||||
now_hr_time = pnf_get_current_time_hr(); // moved to here - get closer timestamp???
|
||||
|
||||
if(recvfrom_result > 0)
|
||||
{
|
||||
pnf_nr_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);
|
||||
}
|
||||
}
|
||||
else if(recvfrom_result == 0)
|
||||
{
|
||||
// recv zero length message
|
||||
recvfrom_result = recvfrom(pnf_p7->p7_sock, header_buffer, 0, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size);
|
||||
}
|
||||
if (recvfrom_result > 0) {
|
||||
pnf_nr_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);
|
||||
}
|
||||
} else if (recvfrom_result == 0) {
|
||||
// recv zero length message
|
||||
recvfrom_result =
|
||||
recvfrom(pnf_p7->p7_sock, header_buffer, 0, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size);
|
||||
}
|
||||
|
||||
if(recvfrom_result == -1)
|
||||
{
|
||||
if(errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
{
|
||||
// return to the select
|
||||
//NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom would block :%d\n", __FUNCTION__, errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom failed errno:%d\n", __FUNCTION__, errno);
|
||||
}
|
||||
}
|
||||
if (recvfrom_result == -1) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
// return to the select
|
||||
// NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom would block :%d\n", __FUNCTION__, errno);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom failed errno:%d\n", __FUNCTION__, errno);
|
||||
}
|
||||
}
|
||||
|
||||
// need to update the time as we would only use the value from the
|
||||
// select
|
||||
}
|
||||
while(recvfrom_result > 0);
|
||||
// need to update the time as we would only use the value from the
|
||||
// select
|
||||
} while (recvfrom_result > 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ int nfapi_pnf_p7_nr_slot_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_slot_indica
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_nr_slot_indication_scf_t));
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_slot_indication_scf_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_rx_data_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rx_data_indication_t* ind)
|
||||
@@ -271,7 +271,7 @@ int nfapi_pnf_p7_nr_rx_data_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rx_data_
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_nr_rx_data_indication_t));
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_rx_data_indication_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_crc_indication_t* ind)
|
||||
@@ -283,7 +283,7 @@ int nfapi_pnf_p7_nr_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_crc_indicati
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_nr_crc_indication_t));
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_crc_indication_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_srs_indication_t* ind)
|
||||
@@ -295,7 +295,7 @@ int nfapi_pnf_p7_nr_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_srs_indicati
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_nr_srs_indication_t));
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_srs_indication_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_uci_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_uci_indication_t* ind)
|
||||
@@ -307,7 +307,7 @@ int nfapi_pnf_p7_nr_uci_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_uci_indicati
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_nr_uci_indication_t));
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_uci_indication_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rach_indication_t* ind)
|
||||
@@ -319,5 +319,5 @@ int nfapi_pnf_p7_nr_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rach_indica
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_nr_rach_indication_t));
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_rach_indication_t));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ typedef struct
|
||||
|
||||
|
||||
int vnf_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len);
|
||||
int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len);
|
||||
int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_nr_p4_p5_message_header_t* msg, uint16_t msg_len);
|
||||
|
||||
int vnf_pack_and_send_p4_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len);
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_find(vnf_p7_t* vnf_p
|
||||
nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_delete(vnf_p7_t* vnf_p7, uint16_t phy_id);
|
||||
|
||||
int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header);
|
||||
int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header);
|
||||
int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_t* header);
|
||||
|
||||
void vnf_p7_release_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header);
|
||||
void vnf_p7_release_pdu(vnf_p7_t* vnf_p7, void* pdu);
|
||||
|
||||
@@ -434,7 +434,7 @@ typedef struct nfapi_vnf_config
|
||||
* \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);
|
||||
int (*vendor_ext)(nfapi_vnf_config_t* config, int p5_idx, void* msg);
|
||||
|
||||
/*! A callback to allocate vendor extension messages
|
||||
* \param message_id The message is taken from the message header
|
||||
@@ -442,12 +442,12 @@ typedef struct nfapi_vnf_config
|
||||
* 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);
|
||||
void* (*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
|
||||
*/
|
||||
void (*deallocate_p4_p5_vendor_ext)(nfapi_p4_p5_message_header_t* header);
|
||||
void (*deallocate_p4_p5_vendor_ext)(void* header);
|
||||
|
||||
|
||||
|
||||
@@ -860,7 +860,7 @@ typedef struct nfapi_vnf_p7_config
|
||||
* 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);
|
||||
int (*vendor_ext)(struct nfapi_vnf_p7_config* config, void* msg);
|
||||
|
||||
/*! Optional userdata that will be passed back in the callbacks*/
|
||||
void* user_data;
|
||||
@@ -871,12 +871,12 @@ typedef struct nfapi_vnf_p7_config
|
||||
* 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);
|
||||
void* (*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
|
||||
*/
|
||||
void (*deallocate_p7_vendor_ext)(nfapi_p7_message_header_t* header);
|
||||
void (*deallocate_p7_vendor_ext)(void* header);
|
||||
|
||||
|
||||
} nfapi_vnf_p7_config_t;
|
||||
|
||||
@@ -1063,7 +1063,7 @@ void vnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, nfapi_vnf_confi
|
||||
|
||||
void vnf_nr_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfapi_vnf_config_t* config)
|
||||
{
|
||||
nfapi_p4_p5_message_header_t messageHeader;
|
||||
nfapi_nr_p4_p5_message_header_t messageHeader;
|
||||
|
||||
// validate the input params
|
||||
if(pRecvMsg == NULL || recvMsgLen < NFAPI_HEADER_LENGTH || config == NULL)
|
||||
@@ -1073,7 +1073,7 @@ void vnf_nr_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfa
|
||||
}
|
||||
|
||||
// unpack the message header
|
||||
if (nfapi_p5_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p4_p5_message_header_t), &config->codec_config) < 0)
|
||||
if (nfapi_nr_p5_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_nr_p4_p5_message_header_t), &config->codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
@@ -1255,7 +1255,7 @@ int vnf_nr_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_
|
||||
// 3. Read the buffer
|
||||
// 4. Handle the p5 message
|
||||
|
||||
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
|
||||
uint32_t header_buffer_size = NFAPI_NR_P5_HEADER_LENGTH;
|
||||
uint8_t header_buffer[header_buffer_size];
|
||||
|
||||
uint32_t stack_buffer_size = 32; // should it be the size of then sctp_notificatoin structure
|
||||
@@ -1282,8 +1282,8 @@ int vnf_nr_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_
|
||||
return 0;
|
||||
}
|
||||
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
|
||||
nfapi_nr_p4_p5_message_header_t header;
|
||||
int unpack_result = nfapi_nr_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
|
||||
if (unpack_result < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to decode message header %d\n", unpack_result);
|
||||
return 0;
|
||||
@@ -1518,7 +1518,7 @@ static int vnf_send_p5_msg(nfapi_vnf_pnf_info_t* pnf, const void *msg, int len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len)
|
||||
int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_nr_p4_p5_message_header_t* msg, uint16_t msg_len)
|
||||
{
|
||||
nfapi_vnf_pnf_info_t* pnf = nfapi_vnf_pnf_list_find(&(vnf->_public), p5_idx);
|
||||
|
||||
@@ -1547,7 +1547,7 @@ int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_mes
|
||||
&vnf->_public.codec_config);
|
||||
|
||||
if (packedMessageLength < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p5_message_pack failed with return %d\n", packedMessageLength);
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_nr_p5_message_pack failed with return %d\n", packedMessageLength);
|
||||
return -1;
|
||||
}
|
||||
// printf("msg id = 0x%02x, entire message length: %d\n", msg->message_id, packedMessageLength);
|
||||
|
||||
@@ -474,14 +474,14 @@ int vnf_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info, u
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header)
|
||||
int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_t* header)
|
||||
{
|
||||
|
||||
nfapi_vnf_p7_connection_info_t* p7_connection = vnf_p7_connection_info_list_find(vnf_p7, header->phy_id);
|
||||
if(p7_connection)
|
||||
{
|
||||
int send_result = 0;
|
||||
uint8_t buffer[1024 * 32];
|
||||
uint8_t buffer[1024*1024*3];
|
||||
|
||||
header->m_segment_sequence = NFAPI_P7_SET_MSS(0, 0, p7_connection->sequence_number);
|
||||
|
||||
@@ -501,45 +501,45 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t*
|
||||
// todo : worry about blocking writes?
|
||||
|
||||
// segmenting the transmit
|
||||
int msg_body_len = len - NFAPI_P7_HEADER_LENGTH ;
|
||||
int seg_body_len = vnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH ;
|
||||
int msg_body_len = len - NFAPI_NR_P7_HEADER_LENGTH ;
|
||||
int seg_body_len = vnf_p7->_public.segment_size - NFAPI_NR_P7_HEADER_LENGTH ;
|
||||
int segment_count = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0);
|
||||
|
||||
int segment = 0;
|
||||
int offset = NFAPI_P7_HEADER_LENGTH;
|
||||
int offset = NFAPI_NR_P7_HEADER_LENGTH;
|
||||
uint8_t tx_buffer[vnf_p7->_public.segment_size];
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() MORE THAN ONE SEGMENT phy_id:%d nfapi_p7_message_pack()=len=%d vnf_p7->_public.segment_size:%u\n", __FUNCTION__, header->phy_id, len, vnf_p7->_public.segment_size);
|
||||
for(segment = 0; segment < segment_count; ++segment)
|
||||
{
|
||||
uint8_t last = 0;
|
||||
uint16_t size = vnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH;
|
||||
uint16_t size = vnf_p7->_public.segment_size - NFAPI_NR_P7_HEADER_LENGTH;
|
||||
if(segment + 1 == segment_count)
|
||||
{
|
||||
last = 1;
|
||||
size = (msg_body_len) - (seg_body_len * segment);
|
||||
}
|
||||
|
||||
uint16_t segment_size = size + NFAPI_P7_HEADER_LENGTH;
|
||||
uint16_t segment_size = size + NFAPI_NR_P7_HEADER_LENGTH;
|
||||
|
||||
// Update the header with the m and segement
|
||||
memcpy(&tx_buffer[0], buffer, NFAPI_P7_HEADER_LENGTH);
|
||||
memcpy(&tx_buffer[0], buffer, NFAPI_NR_P7_HEADER_LENGTH);
|
||||
|
||||
// set the segment length
|
||||
tx_buffer[4] = (segment_size & 0xFF00) >> 8;
|
||||
tx_buffer[5] = (segment_size & 0xFF);
|
||||
tx_buffer[6] = (segment_size & 0xFF00) >> 8;
|
||||
tx_buffer[7] = (segment_size & 0xFF);
|
||||
|
||||
// set the m & segment number
|
||||
tx_buffer[6] = ((!last) << 7) + segment;
|
||||
tx_buffer[8] = ((!last) << 7) + segment;
|
||||
|
||||
memcpy(&tx_buffer[NFAPI_P7_HEADER_LENGTH], &buffer[0] + offset, size);
|
||||
memcpy(&tx_buffer[NFAPI_NR_P7_HEADER_LENGTH], &buffer[0] + offset, size);
|
||||
offset += size;
|
||||
|
||||
if(vnf_p7->_public.checksum_enabled)
|
||||
{
|
||||
nfapi_p7_update_checksum(tx_buffer, segment_size);
|
||||
nfapi_nr_p7_update_checksum(tx_buffer, segment_size);
|
||||
}
|
||||
|
||||
nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
|
||||
send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &tx_buffer[0], segment_size);
|
||||
|
||||
@@ -549,10 +549,10 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t*
|
||||
{
|
||||
if(vnf_p7->_public.checksum_enabled)
|
||||
{
|
||||
nfapi_p7_update_checksum(buffer, len);
|
||||
nfapi_nr_p7_update_checksum(buffer, len);
|
||||
}
|
||||
|
||||
nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
|
||||
// simple case that the message fits in a single segement
|
||||
send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &buffer[0], len);
|
||||
@@ -1084,6 +1084,37 @@ void vnf_handle_p7_vendor_extension(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vn
|
||||
}
|
||||
|
||||
|
||||
void vnf_nr_handle_p7_vendor_extension(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7, uint16_t message_id)
|
||||
{
|
||||
if (pRecvMsg == NULL || vnf_p7 == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
|
||||
}
|
||||
else if(vnf_p7->_public.allocate_p7_vendor_ext)
|
||||
{
|
||||
uint16_t msg_size;
|
||||
nfapi_nr_p7_message_header_t* msg = vnf_p7->_public.allocate_p7_vendor_ext(message_id, &msg_size);
|
||||
|
||||
if(msg == 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
int unpack_result = nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, msg, msg_size, &vnf_p7->_public.codec_config);
|
||||
|
||||
if(unpack_result == 0)
|
||||
{
|
||||
if(vnf_p7->_public.vendor_ext)
|
||||
vnf_p7->_public.vendor_ext(&(vnf_p7->_public), msg);
|
||||
}
|
||||
|
||||
if(vnf_p7->_public.deallocate_p7_vendor_ext)
|
||||
vnf_p7->_public.deallocate_p7_vendor_ext(msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
uint32_t now_time_hr = vnf_get_current_time_hr();
|
||||
@@ -2166,7 +2197,7 @@ void vnf_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
|
||||
void vnf_nr_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
nfapi_p7_message_header_t header;
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
|
||||
// validate the input params
|
||||
if(pRecvMsg == NULL || recvMsgLen < 4 || vnf_p7 == NULL)
|
||||
@@ -2176,7 +2207,7 @@ void vnf_nr_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
}
|
||||
|
||||
// unpack the message header
|
||||
if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &header, sizeof(header), &vnf_p7->_public.codec_config) < 0)
|
||||
if (nfapi_nr_p7_message_header_unpack(pRecvMsg, recvMsgLen, &header, sizeof(header), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
@@ -2363,7 +2394,7 @@ void vnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
|
||||
void vnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
nfapi_p7_message_header_t messageHeader;
|
||||
nfapi_nr_p7_message_header_t messageHeader;
|
||||
|
||||
// validate the input params
|
||||
if(pRecvMsg == NULL || recvMsgLen < 4 || vnf_p7 == NULL)
|
||||
@@ -2373,7 +2404,7 @@ void vnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
}
|
||||
|
||||
// unpack the message header
|
||||
if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p7_message_header_t), &vnf_p7->_public.codec_config) < 0)
|
||||
if (nfapi_nr_p7_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_nr_p7_message_header_t), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return;
|
||||
@@ -2381,7 +2412,7 @@ void vnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
|
||||
if(vnf_p7->_public.checksum_enabled)
|
||||
{
|
||||
uint32_t checksum = nfapi_p7_calculate_checksum(pRecvMsg, recvMsgLen);
|
||||
uint32_t checksum = nfapi_nr_p7_calculate_checksum(pRecvMsg, recvMsgLen);
|
||||
if(checksum != messageHeader.checksum)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Checksum verification failed %d %d msg:%d len:%d\n", checksum, messageHeader.checksum, messageHeader.message_id, recvMsgLen);
|
||||
@@ -2422,7 +2453,7 @@ void vnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
uint16_t length = 0;
|
||||
for(i = 0; i < rx_msg->num_segments_expected; ++i)
|
||||
{
|
||||
length += rx_msg->segments[i].length - (i > 0 ? NFAPI_P7_HEADER_LENGTH : 0);
|
||||
length += rx_msg->segments[i].length - (i > 0 ? NFAPI_NR_P7_HEADER_LENGTH : 0);
|
||||
}
|
||||
|
||||
if(phy->reassembly_buffer_size < length)
|
||||
@@ -2455,8 +2486,8 @@ void vnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(phy->reassembly_buffer + offset, rx_msg->segments[i].buffer + NFAPI_P7_HEADER_LENGTH, rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH);
|
||||
offset += rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH;
|
||||
memcpy(phy->reassembly_buffer + offset, rx_msg->segments[i].buffer + NFAPI_NR_P7_HEADER_LENGTH, rx_msg->segments[i].length - NFAPI_NR_P7_HEADER_LENGTH);
|
||||
offset += rx_msg->segments[i].length - NFAPI_NR_P7_HEADER_LENGTH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2488,14 +2519,14 @@ int vnf_nr_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
|
||||
do
|
||||
{
|
||||
// peek the header
|
||||
uint8_t header_buffer[NFAPI_P7_HEADER_LENGTH];
|
||||
recvfrom_result = recvfrom(vnf_p7->socket, header_buffer, NFAPI_P7_HEADER_LENGTH, MSG_DONTWAIT | MSG_PEEK, (struct sockaddr*)&remote_addr, &remote_addr_size);
|
||||
uint8_t header_buffer[NFAPI_NR_P7_HEADER_LENGTH];
|
||||
recvfrom_result = recvfrom(vnf_p7->socket, header_buffer, NFAPI_NR_P7_HEADER_LENGTH, MSG_DONTWAIT | MSG_PEEK, (struct sockaddr*)&remote_addr, &remote_addr_size);
|
||||
|
||||
if(recvfrom_result > 0)
|
||||
{
|
||||
// get the segment size
|
||||
nfapi_p7_message_header_t header;
|
||||
if(nfapi_p7_message_header_unpack(header_buffer, NFAPI_P7_HEADER_LENGTH, &header, sizeof(header), 0) < 0)
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
if(nfapi_nr_p7_message_header_unpack(header_buffer, NFAPI_NR_P7_HEADER_LENGTH, &header, sizeof(header), 0) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user