diff --git a/openair2/F1AP/f1ap_cu_task.c b/openair2/F1AP/f1ap_cu_task.c index 72e3d86ea2..59e4bb29af 100644 --- a/openair2/F1AP/f1ap_cu_task.c +++ b/openair2/F1AP/f1ap_cu_task.c @@ -34,6 +34,7 @@ #include "f1ap_cu_interface_management.h" #include "f1ap_cu_rrc_message_transfer.h" #include "f1ap_cu_ue_context_management.h" +#include "lib/f1ap_rrc_message_transfer.h" #include "f1ap_cu_paging.h" #include "f1ap_cu_task.h" #include @@ -174,7 +175,7 @@ void *F1AP_CU_task(void *arg) { case F1AP_DL_RRC_MESSAGE: // from rrc CU_send_DL_RRC_MESSAGE_TRANSFER(assoc_id, &F1AP_DL_RRC_MESSAGE(received_msg)); - free(F1AP_DL_RRC_MESSAGE(received_msg).rrc_container); + free_dl_rrc_message_transfer(&F1AP_DL_RRC_MESSAGE(received_msg)); break; case F1AP_UE_CONTEXT_SETUP_REQ: // from rrc diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index 85e963ea6a..8f6114a9e5 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -186,6 +186,8 @@ int DU_handle_F1_SETUP_RESPONSE(instance_t instance, sctp_assoc_t assoc_id, uint } LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message\n"); f1_setup_response(&resp); + // free F1AP message after use + free_f1ap_setup_response(&resp); return 0; } diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index d221d3b35c..0d675a76e1 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -34,6 +34,7 @@ #include "f1ap_du_interface_management.h" #include "f1ap_du_ue_context_management.h" #include "f1ap_du_rrc_message_transfer.h" +#include "lib/f1ap_rrc_message_transfer.h" #include "f1ap_du_task.h" #include @@ -180,6 +181,7 @@ void *F1AP_DU_task(void *arg) { case F1AP_UL_RRC_MESSAGE: // to rrc DU_send_UL_NR_RRC_MESSAGE_TRANSFER(assoc_id, &F1AP_UL_RRC_MESSAGE(msg)); + free_ul_rrc_message_transfer(&F1AP_UL_RRC_MESSAGE(msg)); break; case F1AP_UE_CONTEXT_SETUP_RESP: diff --git a/openair2/F1AP/lib/f1ap_interface_management.c b/openair2/F1AP/lib/f1ap_interface_management.c index cb0b6ab8aa..fe079faa4c 100644 --- a/openair2/F1AP/lib/f1ap_interface_management.c +++ b/openair2/F1AP/lib/f1ap_interface_management.c @@ -955,8 +955,7 @@ bool decode_f1ap_setup_failure(const F1AP_F1AP_PDU_t *pdu, f1ap_setup_failure_t */ bool eq_f1ap_setup_failure(const f1ap_setup_failure_t *a, const f1ap_setup_failure_t *b) { - if (a->transaction_id != b->transaction_id) - return false; + _F1_EQ_CHECK_INT(a->transaction_id, b->transaction_id); return true; } diff --git a/openair2/F1AP/lib/f1ap_lib_common.c b/openair2/F1AP/lib/f1ap_lib_common.c index edf48f426c..2938898aff 100644 --- a/openair2/F1AP/lib/f1ap_lib_common.c +++ b/openair2/F1AP/lib/f1ap_lib_common.c @@ -37,32 +37,24 @@ bool eq_f1ap_plmn(const f1ap_plmn_t *a, const f1ap_plmn_t *b) bool eq_f1ap_freq_info(const f1ap_nr_frequency_info_t *a, const f1ap_nr_frequency_info_t *b) { - if (a->arfcn != b->arfcn) - return false; - if (a->band != b->band) - return false; + _F1_EQ_CHECK_INT(a->arfcn, b->arfcn); + _F1_EQ_CHECK_INT(a->band, b->band); return true; } bool eq_f1ap_tx_bandwidth(const f1ap_transmission_bandwidth_t *a, const f1ap_transmission_bandwidth_t *b) { - if (a->nrb != b->nrb) - return false; - if (a->scs != b->scs) - return false; + _F1_EQ_CHECK_INT(a->nrb, b->nrb); + _F1_EQ_CHECK_INT(a->scs, b->scs); return true; } bool eq_f1ap_cell_info(const f1ap_served_cell_info_t *a, const f1ap_served_cell_info_t *b) { - if (a->nr_cellid != b->nr_cellid) - return false; - if (a->nr_pci != b->nr_pci) - return false; - if (*a->tac != *b->tac) - return false; - if (a->mode != b->mode) - return false; + _F1_EQ_CHECK_LONG(a->nr_cellid, b->nr_cellid); + _F1_EQ_CHECK_INT(a->nr_pci, b->nr_pci); + _F1_EQ_CHECK_INT(*a->tac, *b->tac); + _F1_EQ_CHECK_INT(a->mode, b->mode); if (a->mode == F1AP_MODE_TDD) { /* TDD */ if (!eq_f1ap_tx_bandwidth(&a->tdd.tbw, &b->tdd.tbw)) @@ -80,10 +72,8 @@ bool eq_f1ap_cell_info(const f1ap_served_cell_info_t *a, const f1ap_served_cell_ if (!eq_f1ap_freq_info(&a->fdd.ul_freqinfo, &b->fdd.ul_freqinfo)) return false; } - if (a->measurement_timing_config_len != b->measurement_timing_config_len) - return false; - if (*a->measurement_timing_config != *b->measurement_timing_config) - return false; + _F1_EQ_CHECK_INT(a->measurement_timing_config_len, b->measurement_timing_config_len); + _F1_EQ_CHECK_INT(*a->measurement_timing_config, *b->measurement_timing_config); if (!eq_f1ap_plmn(&a->plmn, &b->plmn)) return false; return true; @@ -92,19 +82,13 @@ bool eq_f1ap_cell_info(const f1ap_served_cell_info_t *a, const f1ap_served_cell_ bool eq_f1ap_sys_info(const f1ap_gnb_du_system_info_t *a, const f1ap_gnb_du_system_info_t *b) { /* MIB */ - if (a->mib_length != b->mib_length) - return false; - for (int i = 0; i < a->mib_length; i++) { - if (a->mib[i] != b->mib[i]) - return false; - } + _F1_EQ_CHECK_INT(a->mib_length, b->mib_length); + for (int i = 0; i < a->mib_length; i++) + _F1_EQ_CHECK_INT(a->mib[i], b->mib[i]); /* SIB1 */ - if (a->sib1_length != b->sib1_length) - return false; - for (int i = 0; i < a->sib1_length; i++) { - if (a->sib1[i] != b->sib1[i]) - return false; - } + _F1_EQ_CHECK_INT(a->sib1_length, b->sib1_length); + for (int i = 0; i < a->sib1_length; i++) + _F1_EQ_CHECK_INT(a->sib1[i], b->sib1[i]); return true; } diff --git a/openair2/F1AP/tests/f1ap_lib_test.c b/openair2/F1AP/tests/f1ap_lib_test.c index 969efc5afa..71d2bea953 100644 --- a/openair2/F1AP/tests/f1ap_lib_test.c +++ b/openair2/F1AP/tests/f1ap_lib_test.c @@ -1,3 +1,33 @@ +/* + * 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 + */ + +/*! \file f1ap_lib_test.c + * \brief Test functions for F1AP encoding/decoding library + * \author Guido Casati, Robert Schmidt + * \date 2024 + * \version 0.1 + * \note + * \warning + */ + #include #include #include @@ -166,7 +196,7 @@ static void test_f1ap_setup_request(void) /* gNB_DU_name */ uint8_t *gNB_DU_name = calloc(strlen("OAI DU") + 1, sizeof(uint8_t)); AssertFatal(gNB_DU_name != NULL, "out of memory\n"); - memcpy((void *)gNB_DU_name, "OAI DU", strlen("OAI DU") + 1); + memcpy(gNB_DU_name, "OAI DU", strlen("OAI DU") + 1); /* sys_info */ uint8_t *mib = calloc(3, sizeof(uint8_t)); uint8_t *sib1 = calloc(3, sizeof(uint8_t)); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c index 407e5869ce..51c655c791 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c @@ -172,8 +172,6 @@ void f1_setup_response(const f1ap_setup_resp_t *resp) AssertFatal(mac->f1_config.setup_resp != NULL, "out of memory\n"); // Copy F1AP message *mac->f1_config.setup_resp = cp_f1ap_setup_response(resp); - // free F1AP message after copy - free_f1ap_setup_response(resp); NR_SCHED_UNLOCK(&mac->sched_lock); // NOTE: Before accepting any UEs, we should initialize the UE states. diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 5ab7c0ba12..e960119d81 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -98,6 +98,7 @@ #include "openair2/SDAP/nr_sdap/nr_sdap_entity.h" #include "openair2/E1AP/e1ap.h" #include "cucp_cuup_if.h" +#include "lib/f1ap_interface_management.h" #include "BIT_STRING.h" #include "assertions.h" @@ -2309,7 +2310,7 @@ void *rrc_gnb_task(void *args_p) { /* From DU -> CU */ case F1AP_UL_RRC_MESSAGE: rrc_gNB_decode_dcch(RC.nrrrc[instance], &F1AP_UL_RRC_MESSAGE(msg_p)); - free(F1AP_UL_RRC_MESSAGE(msg_p).rrc_container); + free_ul_rrc_message_transfer(&F1AP_UL_RRC_MESSAGE(msg_p)); break; case NGAP_DOWNLINK_NAS: @@ -2332,6 +2333,7 @@ void *rrc_gnb_task(void *args_p) { case F1AP_SETUP_REQ: AssertFatal(!NODE_IS_DU(RC.nrrrc[instance]->node_type), "should not receive F1AP_SETUP_REQUEST in DU!\n"); rrc_gNB_process_f1_setup_req(&F1AP_SETUP_REQ(msg_p), msg_p->ittiMsgHeader.originInstance); + free_f1ap_setup_request(&F1AP_SETUP_REQ(msg_p)); break; case F1AP_UE_CONTEXT_SETUP_RESP: @@ -2361,6 +2363,7 @@ void *rrc_gnb_task(void *args_p) { case F1AP_GNB_DU_CONFIGURATION_UPDATE: AssertFatal(!NODE_IS_DU(RC.nrrrc[instance]->node_type), "should not receive F1AP_SETUP_REQUEST in DU!\n"); rrc_gNB_process_f1_du_configuration_update(&F1AP_GNB_DU_CONFIGURATION_UPDATE(msg_p), msg_p->ittiMsgHeader.originInstance); + free_f1ap_du_configuration_update(&F1AP_GNB_DU_CONFIGURATION_UPDATE(msg_p)); break; case F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE: diff --git a/openair2/RRC/NR/rrc_gNB_du.c b/openair2/RRC/NR/rrc_gNB_du.c index e2806edf60..df0bf15a74 100644 --- a/openair2/RRC/NR/rrc_gNB_du.c +++ b/openair2/RRC/NR/rrc_gNB_du.c @@ -383,8 +383,6 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *req, sctp_assoc_t assoc_id) f1ap_setup_resp_t resp = {.transaction_id = req->transaction_id, .num_cells_to_activate = 1, .cells_to_activate[0] = cell}; - // free F1AP message after use - free_f1ap_setup_request(req); int num = read_version(TO_STRING(NR_RRC_VERSION), &resp.rrc_ver[0], &resp.rrc_ver[1], &resp.rrc_ver[2]); AssertFatal(num == 3, "could not read RRC version string %s\n", TO_STRING(NR_RRC_VERSION)); if (rrc->node_name != NULL)