Move functions for packing/unpacking SLOT.indication
Add unitary test for SLOT.indication ( test pack/unpack, free, copy and compare )
This commit is contained in:
committed by
Robert Schmidt
parent
18799ef44b
commit
a6ab55150c
@@ -33,5 +33,10 @@ uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end,
|
|||||||
uint8_t unpack_dl_tti_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config);
|
uint8_t unpack_dl_tti_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config);
|
||||||
uint8_t pack_ul_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
uint8_t pack_ul_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
||||||
uint8_t unpack_ul_tti_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config);
|
uint8_t unpack_ul_tti_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config);
|
||||||
|
uint8_t unpack_nr_slot_indication(uint8_t **ppReadPackedMsg,
|
||||||
|
uint8_t *end,
|
||||||
|
nfapi_nr_slot_indication_scf_t *msg,
|
||||||
|
nfapi_p7_codec_config_t *config);
|
||||||
|
uint8_t pack_nr_slot_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
||||||
|
|
||||||
#endif // OPENAIRINTERFACE_NR_FAPI_P7_H
|
#endif // OPENAIRINTERFACE_NR_FAPI_P7_H
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ uint8_t fapi_nr_p7_message_body_pack(nfapi_nr_p7_message_header_t *header,
|
|||||||
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
|
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
|
||||||
result = pack_ul_tti_request(header, ppWritePackedMsg, end, config);
|
result = pack_ul_tti_request(header, ppWritePackedMsg, end, config);
|
||||||
break;
|
break;
|
||||||
|
case NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION:
|
||||||
|
result = pack_nr_slot_indication(header, ppWritePackedMsg, end, config);
|
||||||
|
break;
|
||||||
default: {
|
default: {
|
||||||
if (header->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && header->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
if (header->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && header->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||||
if (config && config->pack_p7_vendor_extension) {
|
if (config && config->pack_p7_vendor_extension) {
|
||||||
@@ -145,6 +148,12 @@ int fapi_nr_p7_message_unpack(void *pMessageBuf,
|
|||||||
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST, unpackedBufLen))
|
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST, unpackedBufLen))
|
||||||
result = unpack_ul_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
|
result = unpack_ul_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
|
||||||
break;
|
break;
|
||||||
|
case NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION:
|
||||||
|
if (check_nr_fapi_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;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
if (pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
if (pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||||
@@ -1265,3 +1274,26 @@ uint8_t unpack_ul_tti_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t pack_nr_slot_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
|
||||||
|
{
|
||||||
|
nfapi_nr_slot_indication_scf_t *pNfapiMsg = (nfapi_nr_slot_indication_scf_t *)msg;
|
||||||
|
|
||||||
|
if (!(push16(pNfapiMsg->sfn, ppWritePackedMsg, end) && push16(pNfapiMsg->slot, ppWritePackedMsg, end)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t unpack_nr_slot_indication(uint8_t **ppReadPackedMsg,
|
||||||
|
uint8_t *end,
|
||||||
|
nfapi_nr_slot_indication_scf_t *msg,
|
||||||
|
nfapi_p7_codec_config_t *config)
|
||||||
|
{
|
||||||
|
nfapi_nr_slot_indication_scf_t *pNfapiMsg = (nfapi_nr_slot_indication_scf_t *)msg;
|
||||||
|
|
||||||
|
if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn, end) && pull16(ppReadPackedMsg, &pNfapiMsg->slot, end)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,11 +34,6 @@
|
|||||||
#include "nfapi_interface.h"
|
#include "nfapi_interface.h"
|
||||||
#include "nfapi_nr_interface_scf.h"
|
#include "nfapi_nr_interface_scf.h"
|
||||||
|
|
||||||
uint8_t unpack_nr_slot_indication(uint8_t **ppReadPackedMsg,
|
|
||||||
uint8_t *end,
|
|
||||||
nfapi_nr_slot_indication_scf_t *msg,
|
|
||||||
nfapi_p7_codec_config_t *config);
|
|
||||||
|
|
||||||
void *nfapi_p7_allocate(size_t size, nfapi_p7_codec_config_t *config);
|
void *nfapi_p7_allocate(size_t size, nfapi_p7_codec_config_t *config);
|
||||||
|
|
||||||
uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg,
|
uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg,
|
||||||
@@ -52,8 +47,6 @@ uint8_t pack_ue_release_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *
|
|||||||
|
|
||||||
uint8_t pack_ue_release_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
uint8_t pack_ue_release_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
||||||
|
|
||||||
uint8_t pack_nr_slot_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
|
||||||
|
|
||||||
uint8_t pack_nr_rx_data_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
uint8_t pack_nr_rx_data_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
||||||
|
|
||||||
uint8_t pack_nr_crc_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
uint8_t pack_nr_crc_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
||||||
|
|||||||
@@ -2642,17 +2642,6 @@ uint8_t pack_nr_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end,
|
|||||||
|
|
||||||
//NR UPLINK indication function packing
|
//NR UPLINK indication function packing
|
||||||
|
|
||||||
//SLOT INDICATION
|
|
||||||
|
|
||||||
uint8_t pack_nr_slot_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
|
|
||||||
{
|
|
||||||
nfapi_nr_slot_indication_scf_t *pNfapiMsg = (nfapi_nr_slot_indication_scf_t *)msg;
|
|
||||||
|
|
||||||
if (!(push16(pNfapiMsg->sfn, ppWritePackedMsg, end) && push16(pNfapiMsg->slot, ppWritePackedMsg, end)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//RX DATA INDICATION
|
//RX DATA INDICATION
|
||||||
|
|
||||||
@@ -5009,21 +4998,6 @@ static uint8_t unpack_tx_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *
|
|||||||
|
|
||||||
//UNPACK NR UPLINK INDICATION FUNCTIONS
|
//UNPACK NR UPLINK INDICATION FUNCTIONS
|
||||||
|
|
||||||
//SLOT INDICATION
|
|
||||||
|
|
||||||
uint8_t unpack_nr_slot_indication(uint8_t **ppReadPackedMsg,
|
|
||||||
uint8_t *end,
|
|
||||||
nfapi_nr_slot_indication_scf_t *msg,
|
|
||||||
nfapi_p7_codec_config_t *config)
|
|
||||||
{
|
|
||||||
nfapi_nr_slot_indication_scf_t *pNfapiMsg = (nfapi_nr_slot_indication_scf_t *)msg;
|
|
||||||
|
|
||||||
if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn, end) && pull16(ppReadPackedMsg, &pNfapiMsg->slot, end)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//RX DATA INDICATION
|
//RX DATA INDICATION
|
||||||
|
|
||||||
static uint8_t unpack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t *value,
|
static uint8_t unpack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t *value,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
set(Test_Labels fapi p7)
|
set(Test_Labels fapi p7)
|
||||||
set(_fapi_p7_messages "dci_inversion;dl_tti_request;ul_tti_request")
|
set(_fapi_p7_messages "dci_inversion;dl_tti_request;ul_tti_request;slot_indication")
|
||||||
foreach (fapi_p7_message IN LISTS _fapi_p7_messages)
|
foreach (fapi_p7_message IN LISTS _fapi_p7_messages)
|
||||||
add_executable(nr_fapi_${fapi_p7_message}_test nr_fapi_${fapi_p7_message}_test.c)
|
add_executable(nr_fapi_${fapi_p7_message}_test nr_fapi_${fapi_p7_message}_test.c)
|
||||||
target_link_libraries(nr_fapi_${fapi_p7_message}_test PUBLIC nr_fapi_p7)
|
target_link_libraries(nr_fapi_${fapi_p7_message}_test PUBLIC nr_fapi_p7)
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
#include "dci_payload_utils.h"
|
||||||
|
#include "nr_fapi_p7.h"
|
||||||
|
#include "nr_fapi_p7_utils.h"
|
||||||
|
|
||||||
|
static void fill_slot_indication(nfapi_nr_slot_indication_scf_t *msg)
|
||||||
|
{
|
||||||
|
msg->sfn = rand16_range(0, 1023);
|
||||||
|
msg->slot = rand16_range(0, 159);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_pack_unpack(nfapi_nr_slot_indication_scf_t *req)
|
||||||
|
{
|
||||||
|
uint8_t msg_buf[1024 * 1024 * 2];
|
||||||
|
// first test the packing procedure
|
||||||
|
int pack_result = fapi_nr_p7_message_pack(req, msg_buf, sizeof(msg_buf), NULL);
|
||||||
|
|
||||||
|
// Should always return 4 (2 bytes sfn + 2 bytes slot )
|
||||||
|
DevAssert(pack_result == 4);
|
||||||
|
// update req message_length value with value calculated in message_pack procedure
|
||||||
|
// req->header.message_length = pack_result;
|
||||||
|
// test the unpacking of the header
|
||||||
|
// copy first NFAPI_HEADER_LENGTH bytes into a new buffer, to simulate SCTP PEEK
|
||||||
|
fapi_message_header_t header;
|
||||||
|
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
|
||||||
|
uint8_t header_buffer[header_buffer_size];
|
||||||
|
for (int idx = 0; idx < header_buffer_size; idx++) {
|
||||||
|
header_buffer[idx] = msg_buf[idx];
|
||||||
|
}
|
||||||
|
uint8_t *pReadPackedMessage = header_buffer;
|
||||||
|
int unpack_header_result = fapi_nr_message_header_unpack(&pReadPackedMessage, NFAPI_HEADER_LENGTH, &header, sizeof(header), 0);
|
||||||
|
DevAssert(unpack_header_result >= 0);
|
||||||
|
DevAssert(header.message_id == req->header.message_id);
|
||||||
|
DevAssert(header.message_length == req->header.message_length);
|
||||||
|
// test the unpacking and compare with initial message
|
||||||
|
nfapi_nr_slot_indication_scf_t unpacked_req = {0};
|
||||||
|
int unpack_result =
|
||||||
|
fapi_nr_p7_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), 0);
|
||||||
|
DevAssert(unpack_result >= 0);
|
||||||
|
DevAssert(eq_slot_indication(&unpacked_req, req));
|
||||||
|
free_slot_indication(&unpacked_req);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_copy(const nfapi_nr_slot_indication_scf_t *msg)
|
||||||
|
{
|
||||||
|
// Test copy function
|
||||||
|
nfapi_nr_slot_indication_scf_t copy = {0};
|
||||||
|
copy_slot_indication(msg, ©);
|
||||||
|
DevAssert(eq_slot_indication(msg, ©));
|
||||||
|
free_slot_indication(©);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int n, char *v[])
|
||||||
|
{
|
||||||
|
fapi_test_init();
|
||||||
|
|
||||||
|
nfapi_nr_slot_indication_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION};
|
||||||
|
|
||||||
|
// Fill DL_TTI request
|
||||||
|
fill_slot_indication(&req);
|
||||||
|
// Perform tests
|
||||||
|
test_pack_unpack(&req);
|
||||||
|
test_copy(&req);
|
||||||
|
// All tests successful!
|
||||||
|
free_slot_indication(&req);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user