diff --git a/README.txt b/README.txt index 37f6a86571..8204bb0cb5 100644 --- a/README.txt +++ b/README.txt @@ -63,3 +63,4 @@ v1.0.0 -> January 2019. This version first implements the architectural split de A lot of bugfixes and a proper automated Continuous Integration process validates contributions. v1.0.1 -> February 2019: Bug fix for the UE L1 simulator. v1.0.2 -> February 2019: Full OAI support for 3.13.1 UHD +v1.0.3 -> June 2019: Bug fix for LimeSuite v19.04.0 API diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index 8dbbc9a544..fde8f745d0 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -1277,8 +1277,7 @@ function run_test_on_vm { do for BW in ${BW_CASES[@]} do - # Not Running in TDD-10MHz and TDD-20MHz : too unstable - #if [[ $TMODE =~ .*tdd.* ]] && [[ $BW =~ .*10.* ]]; then continue; fi + # Not Running in TDD-20MHz : too unstable if [[ $TMODE =~ .*tdd.* ]] && [[ $BW =~ .*20.* ]]; then continue; fi if [[ $BW =~ .*05.* ]]; then PRB=25; fi @@ -1300,15 +1299,9 @@ function run_test_on_vm { if [ $UE_SYNC -eq 0 ] then echo "Problem w/ eNB and UE not syncing" - terminate_enb_ue_basic_sim $VM_CMDS $VM_IP_ADDR 0 - scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_ENB_LOG_FILE $ARCHIVES_LOC - scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_UE_LOG_FILE $ARCHIVES_LOC - recover_core_dump $VM_CMDS $VM_IP_ADDR $ARCHIVES_LOC/$CURRENT_ENB_LOG_FILE $ARCHIVES_LOC - terminate_epc $EPC_VM_CMDS $EPC_VM_IP_ADDR - full_basic_sim_destroy - echo "TEST_KO" > $ARCHIVES_LOC/test_final_status.log + full_terminate STATUS=-1 - return + continue fi get_ue_ip_addr $VM_CMDS $VM_IP_ADDR 1 @@ -1739,14 +1732,8 @@ function run_test_on_vm { terminate_enb_ue_basic_sim $UE_VM_CMDS $UE_VM_IP_ADDR 2 scp -o StrictHostKeyChecking=no ubuntu@$ENB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_ENB_LOG_FILE $ARCHIVES_LOC scp -o StrictHostKeyChecking=no ubuntu@$UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_UE_LOG_FILE $ARCHIVES_LOC - if [ $S1_NOS1_CFG -eq 1 ] - then - terminate_epc $EPC_VM_CMDS $EPC_VM_IP_ADDR - fi - full_l2_sim_destroy - echo "TEST_KO" > $ARCHIVES_LOC/test_final_status.log STATUS=-1 - return + continue fi if [ $S1_NOS1_CFG -eq 1 ] diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index 0083c2e66b..249765a46e 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -41,7 +41,7 @@ int parse_stringlist(paramdef_t *cfgoptions, char *val) { char *atoken; - char *tokctx; + char *tokctx = NULL; char *tmpval=strdup(val); int numelt=0; cfgoptions->numelt=0; @@ -214,7 +214,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) /* first check help options, either --help, -h or --help_
*/ if (strncmp(oneargv, "-h",2) == 0 || strncmp(oneargv, "--help",6) == 0 ) { - char *tokctx; + char *tokctx = NULL; pp=strtok_r(oneargv, "_",&tokctx); config_get_if()->argv_info[i] |= CONFIG_CMDLINEOPT_PROCESSED; diff --git a/doc/BUILD.md b/doc/BUILD.md index 094900daac..a2d62c31a0 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -36,11 +36,7 @@ The oai softmodem supports many use cases, and new ones are regularly added. Mos - all simulators, with exception of PHY simulators, which are distinct executables. -Calling the `build_oai` script with the -h option gives the list of all available options, but a process to simplify and check the requirements of all these options is on-going. Check the - -[table]: BUILD.md "`build_oai` options" - -At the end of this page to know the status of `buid_oai` options which are not described hereafter. +Calling the `build_oai` script with the -h option gives the list of all available options, but a process to simplify and check the requirements of all these options is on-going. Check the [table](BUILD.md "# `build_oai` options") At the end of this page to know the status of `buid_oai` options which are not described hereafter. # Building PHY Simulators @@ -53,7 +49,7 @@ After downloading the source files, a single build command can be used to get th ``` cd /openairinterface5g/ source oaienv -cd ../cmake_targets/ +cd cmake_targets/ ./build_oai -I -w USRP --eNB --UE ``` @@ -78,10 +74,16 @@ or `./build_oai --build-lib telnetsrv` +You can get documentation about the telnet server [here](common/utils/telnetsrv/DOC/telnetsrv.md) + ## USRP record player The USRP record player today needs a specific build. Work to make it available as a run time option is under consideration +## Other optional libraries + +Using the help option of the build script you can get the list of available optional libraries. Those which haven't been mentioned above are known to need more tests and documentation + # `build_oai` options | Option | Status | Description | @@ -89,7 +91,7 @@ The USRP record player today needs a specific build. Work to make it available a | -h | maintained | get help | | -c | maintained | erase all previously built files for this target before starting the new build. | | -C | maintained, needs improvement | erase all previously built files for any target before starting the new build. | -| --verbose-compile | maintained | | +| --verbose-compile | maintained | get compilation messages, as when running `make` or `gcc` directly. | | --cflags_processor | maintained | used to pass options to the compiler | | --clean-kernel | unknown | no code in the script corresponding to this option | | --install-system-files | maintained | install oai built binaries in linux system files repositories | diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 7110f681d7..656cedfe62 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -122,8 +122,13 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, for (j = 0; j < ue_report[i]->n_rlc_report; j++) { rlc_reports[j] = malloc(sizeof(Protocol__FlexRlcBsr)); - if (rlc_reports[j] == NULL) + if (rlc_reports[j] == NULL){ + for (k = 0; k < j; k++){ + free(rlc_reports[k]); + } + free(rlc_reports); goto error; + } protocol__flex_rlc_bsr__init(rlc_reports[j]); rlc_reports[j]->lc_id = j+1; rlc_reports[j]->has_lc_id = 1; @@ -180,8 +185,10 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, //Create the actual CSI reports. Protocol__FlexDlCsi **csi_reports; csi_reports = malloc(sizeof(Protocol__FlexDlCsi *)*dl_report->n_csi_report); - if (csi_reports == NULL) + if (csi_reports == NULL) { + free(dl_report); goto error; + } for (j = 0; j < dl_report->n_csi_report; j++) { csi_reports[j] = malloc(sizeof(Protocol__FlexDlCsi)); @@ -402,14 +409,18 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, //Provide a report for each pending paging message Protocol__FlexPagingInfo **p_info; p_info = malloc(sizeof(Protocol__FlexPagingInfo *) * paging_report->n_paging_info); - if (p_info == NULL) + if (p_info == NULL){ + free(paging_report); goto error; + } for (j = 0; j < paging_report->n_paging_info; j++) { p_info[j] = malloc(sizeof(Protocol__FlexPagingInfo)); - if(p_info[j] == NULL) + if(p_info[j] == NULL){ + free(paging_report); goto error; + } protocol__flex_paging_info__init(p_info[j]); //TODO: Set paging index. This index is the same that will be used for the scheduling of the //paging message by the controller @@ -450,14 +461,22 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, full_ul_report->n_cqi_meas = 1; Protocol__FlexUlCqi **ul_report; ul_report = malloc(sizeof(Protocol__FlexUlCqi *) * full_ul_report->n_cqi_meas); - if(ul_report == NULL) + if(ul_report == NULL) { + free(full_ul_report); goto error; + } //Fill each UL report of the UE for each of the configured report types for(j = 0; j < full_ul_report->n_cqi_meas; j++) { ul_report[j] = malloc(sizeof(Protocol__FlexUlCqi)); - if(ul_report[j] == NULL) - goto error; + if(ul_report[j] == NULL) { + for (k = 0; k < j; k++) { + free(ul_report[k]); + } + free(ul_report); + free(full_ul_report); + goto error; + } protocol__flex_ul_cqi__init(ul_report[j]); //TODO: Set the type of the UL report. As an example set it to SRS UL report // See enum flex_ul_cqi_type in FlexRAN specification for more details @@ -468,8 +487,14 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, ul_report[j]->n_sinr = 0; uint32_t *sinr_meas; sinr_meas = (uint32_t *) malloc(sizeof(uint32_t) * ul_report[j]->n_sinr); - if (sinr_meas == NULL) + if (sinr_meas == NULL) { + for (k = 0; k < j; k++) { + free(ul_report[k]); + } + free(ul_report); + free(full_ul_report); goto error; + } //TODO:Set the SINR measurements for the specified type for (k = 0; k < ul_report[j]->n_sinr; k++) { sinr_meas[k] = 10; @@ -573,8 +598,10 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, Protocol__FlexMacSdusDl ** mac_sdus; mac_sdus = malloc(sizeof(Protocol__FlexMacSdusDl) * flexran_get_num_mac_sdu_tx(mod_id, UE_id, cc_id)); - if (mac_sdus == NULL) + if (mac_sdus == NULL) { + free(macstats); goto error; + } macstats->n_mac_sdus_dl = flexran_get_num_mac_sdu_tx(mod_id, UE_id, cc_id); @@ -653,10 +680,125 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, error: - if (cell_report != NULL) - free(cell_report); - if (ue_report != NULL) - free(ue_report); + if (cell_report != NULL) { + if (report_config->nr_cc > 0) { + for (i = 0; i < report_config->nr_cc; i++) { + if (cell_report[i]->noise_inter_report != NULL) { + free(cell_report[i]->noise_inter_report); + cell_report[i]->noise_inter_report = NULL; + } + } + } + free(cell_report); + cell_report = NULL; + } + + if (ue_report != NULL) { + if (report_config->nr_ue > 0) { + for (i = 0; i < report_config->nr_ue; i++) { + if (ue_report[i]->bsr != NULL) { + free(ue_report[i]->bsr); + ue_report[i]->bsr = NULL; + } + if (ue_report[i]->rlc_report != NULL) { + for (j = 0; j < ue_report[i]->n_rlc_report; j++) { + if (ue_report[i]->rlc_report[j] != NULL) { + free(ue_report[i]->rlc_report[j]); + ue_report[i]->rlc_report[j] = NULL; + } + } + free(ue_report[i]->rlc_report); + ue_report[i]->rlc_report = NULL; + } + if (ue_report[i]->dl_cqi_report != NULL) { + if (ue_report[i]->dl_cqi_report->csi_report != NULL) { + for (j = 0; j < ue_report[i]->dl_cqi_report->n_csi_report; j++) { + if (ue_report[i]->dl_cqi_report->csi_report[j] != NULL) { + if (ue_report[i]->dl_cqi_report->csi_report[j]->p10csi != NULL) { + free(ue_report[i]->dl_cqi_report->csi_report[j]->p10csi); + ue_report[i]->dl_cqi_report->csi_report[j]->p10csi = NULL; + } + if (ue_report[i]->dl_cqi_report->csi_report[j]->p11csi != NULL) { + if (ue_report[i]->dl_cqi_report->csi_report[j]->p11csi->wb_cqi != NULL) { + free(ue_report[i]->dl_cqi_report->csi_report[j]->p11csi->wb_cqi); + ue_report[i]->dl_cqi_report->csi_report[j]->p11csi->wb_cqi = NULL; + } + free(ue_report[i]->dl_cqi_report->csi_report[j]->p11csi); + ue_report[i]->dl_cqi_report->csi_report[j]->p11csi = NULL; + } + if (ue_report[i]->dl_cqi_report->csi_report[j]->p20csi != NULL) { + free(ue_report[i]->dl_cqi_report->csi_report[j]->p20csi); + ue_report[i]->dl_cqi_report->csi_report[j]->p20csi = NULL; + } + free(ue_report[i]->dl_cqi_report->csi_report[j]); + ue_report[i]->dl_cqi_report->csi_report[j] = NULL; + } + } + free(ue_report[i]->dl_cqi_report->csi_report); + ue_report[i]->dl_cqi_report->csi_report = NULL; + } + free(ue_report[i]->dl_cqi_report); + ue_report[i]->dl_cqi_report = NULL; + } + if (ue_report[i]->pbr != NULL) { + if (ue_report[i]->pbr->paging_info != NULL) { + for (j = 0; j < ue_report[i]->pbr->n_paging_info; j++) { + free(ue_report[i]->pbr->paging_info[j]); + ue_report[i]->pbr->paging_info[j] = NULL; + } + free(ue_report[i]->pbr->paging_info); + ue_report[i]->pbr->paging_info = NULL; + } + free(ue_report[i]->pbr); + ue_report[i]->pbr = NULL; + } + if (ue_report[i]->ul_cqi_report != NULL) { + if (ue_report[i]->ul_cqi_report->cqi_meas != NULL) { + for (j = 0; j < ue_report[i]->ul_cqi_report->n_cqi_meas; j++) { + if (ue_report[i]->ul_cqi_report->cqi_meas[j] != NULL) { + if (ue_report[i]->ul_cqi_report->cqi_meas[j]->sinr != NULL) { + free(ue_report[i]->ul_cqi_report->cqi_meas[j]->sinr); + ue_report[i]->ul_cqi_report->cqi_meas[j]->sinr = NULL; + } + free(ue_report[i]->ul_cqi_report->cqi_meas[j]); + ue_report[i]->ul_cqi_report->cqi_meas[j] = NULL; + } + } + free(ue_report[i]->ul_cqi_report->cqi_meas); + ue_report[i]->ul_cqi_report->cqi_meas = NULL; + } + if (ue_report[i]->ul_cqi_report->pucch_dbm != NULL) { + for (j = 0; j < MAX_NUM_CCs; j++) { + if (ue_report[i]->ul_cqi_report->pucch_dbm[j] != NULL) { + free(ue_report[i]->ul_cqi_report->pucch_dbm[j]); + ue_report[i]->ul_cqi_report->pucch_dbm[j] = NULL; + } + } + free(ue_report[i]->ul_cqi_report->pucch_dbm); + ue_report[i]->ul_cqi_report->pucch_dbm = NULL; + } + free(ue_report[i]->ul_cqi_report); + ue_report[i]->ul_cqi_report = NULL; + } + if (ue_report[i]->mac_stats != NULL) { + if (ue_report[i]->mac_stats->mac_sdus_dl != NULL) { + for (j = 0; j < ue_report[i]->mac_stats->n_mac_sdus_dl; j++) { + if (ue_report[i]->mac_stats->mac_sdus_dl[j] != NULL) { + free(ue_report[i]->mac_stats->mac_sdus_dl[j]); + ue_report[i]->mac_stats->mac_sdus_dl[j] = NULL; + } + } + free(ue_report[i]->mac_stats->mac_sdus_dl); + ue_report[i]->mac_stats->mac_sdus_dl = NULL; + } + free(ue_report[i]->mac_stats); + ue_report[i]->mac_stats = NULL; + } + } + } + free(ue_report); + ue_report = NULL; + } return -1; } @@ -1014,11 +1156,28 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle if (header != NULL) free(header); if (sf_trigger_msg != NULL) { - for (i = 0; i < sf_trigger_msg->n_dl_info; i++) { - free(sf_trigger_msg->dl_info[i]->harq_status); + if (sf_trigger_msg->dl_info != NULL) { + for (i = 0; i < sf_trigger_msg->n_dl_info; i++) { + if (sf_trigger_msg->dl_info[i] != NULL) { + if (sf_trigger_msg->dl_info[i]->harq_status != NULL) { + free(sf_trigger_msg->dl_info[i]->harq_status); + } + free(sf_trigger_msg->dl_info[i]); + } + } + free(sf_trigger_msg->dl_info); + } + if (sf_trigger_msg->ul_info != NULL) { + for (i = 0; i < sf_trigger_msg->n_ul_info; i++) { + if (sf_trigger_msg->ul_info[i] != NULL) { + if (sf_trigger_msg->ul_info[i]->ul_reception != NULL) { + free(sf_trigger_msg->ul_info[i]->ul_reception); + } + free(sf_trigger_msg->ul_info[i]); + } + } + free(sf_trigger_msg->ul_info); } - free(sf_trigger_msg->dl_info); - free(sf_trigger_msg->ul_info); free(sf_trigger_msg); } if(*msg != NULL) @@ -1063,6 +1222,7 @@ int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMess Protocol__FlexDlMacConfig *dl_mac_config_msg; dl_mac_config_msg = malloc(sizeof(Protocol__FlexDlMacConfig)); if (dl_mac_config_msg == NULL) { + free(header); goto error; } protocol__flex_dl_mac_config__init(dl_mac_config_msg); @@ -1072,8 +1232,11 @@ int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMess dl_mac_config_msg->sfn_sf = flexran_get_sfn_sf(mod_id); *msg = malloc(sizeof(Protocol__FlexranMessage)); - if(*msg == NULL) + if(*msg == NULL) { + free(dl_mac_config_msg); + free(header); goto error; + } protocol__flexran_message__init(*msg); (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_DL_MAC_CONFIG_MSG; (*msg)->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__INITIATING_MESSAGE; @@ -1167,8 +1330,10 @@ int flexran_agent_mac_create_empty_ul_config(mid_t mod_id, Protocol__FlexranMess ul_mac_config_msg->sfn_sf = flexran_get_sfn_sf(mod_id); *msg = malloc(sizeof(Protocol__FlexranMessage)); - if(*msg == NULL) + if(*msg == NULL) { + free(ul_mac_config_msg); goto error; + } protocol__flexran_message__init(*msg); (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_UL_MAC_CONFIG_MSG; (*msg)->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__INITIATING_MESSAGE; @@ -1177,6 +1342,10 @@ int flexran_agent_mac_create_empty_ul_config(mid_t mod_id, Protocol__FlexranMess return 0; error: + if(header){ + free(header); + header = NULL; + } return -1; } @@ -1292,7 +1461,7 @@ void flexran_agent_init_mac_agent(mid_t mod_id) { void flexran_agent_send_sr_info(mid_t mod_id) { int size; - Protocol__FlexranMessage *msg; + Protocol__FlexranMessage *msg = NULL; void *data; int priority = 0; err_code_t err_code; @@ -1322,7 +1491,7 @@ void flexran_agent_send_sr_info(mid_t mod_id) { void flexran_agent_send_sf_trigger(mid_t mod_id) { int size; - Protocol__FlexranMessage *msg; + Protocol__FlexranMessage *msg = NULL; void *data; int priority = 0; err_code_t err_code; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index 6ce9038923..2a7d1fe186 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -151,6 +151,15 @@ Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol return msg; error: + if (stats_reply_msg) { + if (stats_reply_msg->ue_report) { + free(stats_reply_msg->ue_report); + } + if (stats_reply_msg->cell_report) { + free(stats_reply_msg->cell_report); + } + free(stats_reply_msg); + } return NULL; } @@ -233,6 +242,12 @@ Protocol__FlexUeStatsReport * copy_ue_stats_report(Protocol__FlexUeStatsReport * return copy; error: + if (copy){ + if (copy->bsr){ + free(copy->bsr); + } + free(copy); + } return NULL; } @@ -303,6 +318,20 @@ Protocol__FlexUlCqiReport * copy_ul_cqi_report(Protocol__FlexUlCqiReport * origi return full_ul_report; error: + if (full_ul_report){ + if (ul_report){ + for (i = 0; i < full_ul_report->n_cqi_meas; i++){ + if (ul_report[i]){ + if ( ul_report[i]->sinr ){ + free(ul_report[i]->sinr); + } + free(ul_report[i]); + } + } + free(ul_report); + } + free(full_ul_report); + } return NULL; } @@ -369,6 +398,18 @@ Protocol__FlexPagingBufferReport * copy_paging_buffer_report(Protocol__FlexPagin error: /*TODO: free memory properly*/ + if (copy){ + if (p_info){ + for (i = 0; i < copy->n_paging_info; i++){ + if (p_info[i]){ + free(p_info[i]); + } + } + free(p_info); + } + free(copy); + copy = NULL; + } return NULL; } @@ -902,6 +943,13 @@ int load_dl_scheduler_function(mid_t mod_id, const char *function_name) { LOG_I(FLEXRAN_AGENT, "Scheduler could not be loaded\n"); } + if (flexran_agent_get_mac_xface(mod_id)) { + if (flexran_agent_get_mac_xface(mod_id)->dl_scheduler_loaded_lib != lib) { + dlclose(lib); + } + } else { + dlclose(lib); + } return 0; error: diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index a785c68163..dfc50683ff 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -44,6 +44,8 @@ void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_ch int size; Protocol__FlexranMessage *msg = NULL; Protocol__FlexHeader *header = NULL; + Protocol__FlexUeStateChange *ue_state_change_msg = NULL; + Protocol__FlexUeConfig *config = NULL; void *data; int priority = 0; err_code_t err_code=0; @@ -53,7 +55,6 @@ void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_ch if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_UE_STATE_CHANGE, &header) != 0) goto error; - Protocol__FlexUeStateChange *ue_state_change_msg; ue_state_change_msg = malloc(sizeof(Protocol__FlexUeStateChange)); if(ue_state_change_msg == NULL) { goto error; @@ -62,7 +63,6 @@ void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_ch ue_state_change_msg->has_type = 1; ue_state_change_msg->type = state_change; - Protocol__FlexUeConfig *config; config = malloc(sizeof(Protocol__FlexUeConfig)); if (config == NULL) { goto error; @@ -103,11 +103,24 @@ void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_ch } LOG_D(FLEXRAN_AGENT,"sent message with size %d\n", size); + free(header); return; error: if (err_code != 0) LOG_E(FLEXRAN_AGENT, "Could not send UE state message becasue of %d for RNTI %x\n", err_code, rnti); + if (header){ + free(header); + } + if (ue_state_change_msg) { + free(ue_state_change_msg); + } + if (config) { + free(config); + } + if (msg) { + free(msg); + } } @@ -405,8 +418,13 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id, for (int j = 0; j < neigh_meas->n_eutra_meas; j++ ){ eutra_meas[j] = malloc(sizeof(Protocol__FlexEutraMeasurements)); - if (eutra_meas[j] == NULL) + if (eutra_meas[j] == NULL) { + for (int k = 0 ; k < j ; k++) { + free(eutra_meas[k]); + } + free(eutra_meas); goto error; + } protocol__flex_eutra_measurements__init(eutra_meas[j]); diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 3d9b88b667..87d50732c6 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -2572,6 +2572,8 @@ int RCconfig_parallel(void) { set_worker_conf(worker_conf); } + free(worker_conf); + free(parallel_conf); return 0; } diff --git a/openair2/ENB_APP/flexran_agent_async.c b/openair2/ENB_APP/flexran_agent_async.c index fa2e0c9ff5..26c0d93259 100644 --- a/openair2/ENB_APP/flexran_agent_async.c +++ b/openair2/ENB_APP/flexran_agent_async.c @@ -84,6 +84,9 @@ flexran_agent_async_channel_t * flexran_agent_async_channel_info(mid_t mod_id, c error: LOG_I(FLEXRAN_AGENT, "%s(): there was an error\n", __func__); + if (channel){ + free(channel); + } return NULL; } diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 88db41bbe3..16f74ccd2f 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -514,8 +514,13 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl // Fill the config for each UE for (int i = 0; i < lc_config_reply_msg->n_lc_ue_config; i++) { lc_ue_config[i] = malloc(sizeof(Protocol__FlexLcUeConfig)); - - if (!lc_ue_config[i]) goto error; + if (!lc_ue_config[i]){ + for (int j = 0; j < i; j++){ + free(lc_ue_config[j]); + } + free(lc_ue_config); + goto error; + } protocol__flex_lc_ue_config__init(lc_ue_config[i]); const int UE_id = flexran_get_mac_ue_id(mod_id, i); @@ -527,8 +532,13 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl *msg = malloc(sizeof(Protocol__FlexranMessage)); - if (*msg == NULL) + if (*msg == NULL){ + for (int k = 0; k < lc_config_reply_msg->n_lc_ue_config; k++){ + free(lc_ue_config[k]); + } + free(lc_ue_config); goto error; + } protocol__flexran_message__init(*msg); (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_LC_CONFIG_REPLY_MSG; @@ -736,7 +746,13 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F for(int i = 0; i < enb_config_reply_msg->n_cell_config; i++) { cell_conf[i] = malloc(sizeof(Protocol__FlexCellConfig)); - if (!cell_conf[i]) goto error; + if (!cell_conf[i]) { + for (int j = 0; j < i; j++) { + free(cell_conf[j]); + } + free(cell_conf); + goto error; + } protocol__flex_cell_config__init(cell_conf[i]); @@ -758,8 +774,13 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F *msg = malloc(sizeof(Protocol__FlexranMessage)); - if(*msg == NULL) + if(*msg == NULL) { + for (int k = 0; k < enb_config_reply_msg->n_cell_config; k++) { + free(cell_conf[k]); + } + free(cell_conf); goto error; + } protocol__flexran_message__init(*msg); (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_ENB_CONFIG_REPLY_MSG; @@ -789,6 +810,8 @@ int flexran_agent_rrc_measurement(mid_t mod_id, const void *params, Protocol__Fl Protocol__FlexRrcTriggering *triggering = input->rrc_triggering; agent_reconf_rrc *reconf_param = malloc(sizeof(agent_reconf_rrc)); reconf_param->trigger_policy = triggering->rrc_trigger; + reconf_param->report_interval = 0; + reconf_param->report_amount = 0; struct rrc_eNB_ue_context_s *ue_context_p = NULL; RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[mod_id]->rrc_ue_head)) { PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, ue_context_p->ue_context.rnti, flexran_get_current_frame(mod_id), flexran_get_current_subframe (mod_id), mod_id); diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index 9ffb1e6cec..0c2c32e4d6 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -293,7 +293,7 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr /* Check if request was periodical */ if (comp_req->report_frequency == PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_PERIODICAL) { /* Create a one off flexran message as an argument for the periodical task */ - Protocol__FlexranMessage *timer_msg; + Protocol__FlexranMessage *timer_msg = NULL; stats_request_config_t request_config; request_config.report_type = PROTOCOL__FLEX_STATS_TYPE__FLST_COMPLETE_STATS; request_config.report_frequency = PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_ONCE; @@ -311,7 +311,10 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr report_config.ue_report_type[0].ue_report_flags = ue_flags; } request_config.config = &report_config; - flexran_agent_stats_request(enb_id, xid, &request_config, &timer_msg); + if (flexran_agent_stats_request(enb_id, xid, &request_config, &timer_msg) == -1) { + err_code = -100; + goto error; + } /* Create a timer */ long timer_id = 0; flexran_agent_timer_args_t *timer_args = malloc(sizeof(flexran_agent_timer_args_t)); @@ -420,19 +423,21 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *report_config, Protocol__FlexranMessage **msg){ Protocol__FlexHeader *header = NULL; - err_code_t err_code; - int i; + Protocol__FlexUeStatsReport **ue_report = NULL; + Protocol__FlexCellStatsReport **cell_report = NULL; + Protocol__FlexStatsReply *stats_reply_msg = NULL; + err_code_t err_code = PROTOCOL__FLEXRAN_ERR__UNEXPECTED; + int i,j; - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) { goto error; - - - Protocol__FlexStatsReply *stats_reply_msg; + } stats_reply_msg = malloc(sizeof(Protocol__FlexStatsReply)); - if (stats_reply_msg == NULL) + if (stats_reply_msg == NULL) { goto error; + } protocol__flex_stats_reply__init(stats_reply_msg); stats_reply_msg->header = header; @@ -442,16 +447,18 @@ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *re // UE report - Protocol__FlexUeStatsReport **ue_report; - - ue_report = malloc(sizeof(Protocol__FlexUeStatsReport *) * report_config->nr_ue); - if (ue_report == NULL) - goto error; + + if (ue_report == NULL) { + goto error; + } for (i = 0; i < report_config->nr_ue; i++) { ue_report[i] = malloc(sizeof(Protocol__FlexUeStatsReport)); + if (ue_report[i] == NULL) { + goto error; + } protocol__flex_ue_stats_report__init(ue_report[i]); ue_report[i]->rnti = report_config->ue_report_type[i].ue_rnti; ue_report[i]->has_rnti = 1; @@ -460,19 +467,18 @@ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *re } // cell rpoert - - Protocol__FlexCellStatsReport **cell_report; - cell_report = malloc(sizeof(Protocol__FlexCellStatsReport *) * report_config->nr_cc); - if (cell_report == NULL) + if (cell_report == NULL) { goto error; + } for (i = 0; i < report_config->nr_cc; i++) { cell_report[i] = malloc(sizeof(Protocol__FlexCellStatsReport)); - if(cell_report[i] == NULL) + if(cell_report[i] == NULL) { goto error; + } protocol__flex_cell_stats_report__init(cell_report[i]); cell_report[i]->carrier_index = report_config->cc_report_type[i].cc_id; @@ -507,8 +513,9 @@ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *re stats_reply_msg->ue_report = ue_report; *msg = malloc(sizeof(Protocol__FlexranMessage)); - if(*msg == NULL) + if(*msg == NULL) { goto error; + } protocol__flexran_message__init(*msg); (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG; (*msg)->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__SUCCESSFUL_OUTCOME; @@ -518,8 +525,38 @@ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *re error : LOG_E(FLEXRAN_AGENT, "errno %d occured\n", err_code); - return err_code; + if (header != NULL) { + free(header); + header = NULL; + } + + if (stats_reply_msg != NULL) { + free(stats_reply_msg); + stats_reply_msg = NULL; + } + + if (ue_report != NULL) { + for (j = 0; j < report_config->nr_ue; j++) { + if (ue_report[j] != NULL) { + free(ue_report[j]); + } + } + free(ue_report); + ue_report = NULL; + } + + if (cell_report != NULL) { + for (j = 0; j < report_config->nr_cc; j++) { + if (cell_report[j] != NULL) { + free(cell_report[j]); + } + } + free(cell_report); + cell_report = NULL; + } + + return err_code; } /* @@ -705,7 +742,7 @@ err_code_t flexran_agent_enable_cont_stats_update(mid_t mod_id, goto error; } - Protocol__FlexranMessage *req_msg; + Protocol__FlexranMessage *req_msg = NULL; flexran_agent_stats_request(mod_id, xid, stats_req, &req_msg); stats_context[mod_id].stats_req = req_msg; diff --git a/openair2/F1AP/f1ap_common.c b/openair2/F1AP/f1ap_common.c index e9e69732be..267626dd5c 100644 --- a/openair2/F1AP/f1ap_common.c +++ b/openair2/F1AP/f1ap_common.c @@ -177,7 +177,7 @@ int f1ap_du_add_cu_ue_id(f1ap_cudu_inst_t *f1_inst, module_id_t du_ue_f1ap_id, module_id_t cu_ue_f1ap_id) { module_id_t f1ap_uid = f1ap_get_du_uid(f1_inst,du_ue_f1ap_id); - if (f1ap_uid < 0) return -1; + if (f1ap_uid < 0 || f1ap_uid >= MAX_MOBILES_PER_ENB) return -1; f1_inst->f1ap_ue[f1ap_uid].cu_ue_f1ap_id = cu_ue_f1ap_id; LOG_I(F1AP, "Adding cu_ue_f1ap_id %d for UE with RNTI %x\n", cu_ue_f1ap_id, f1_inst->f1ap_ue[f1ap_uid].rnti); return 0; @@ -187,7 +187,7 @@ int f1ap_cu_add_du_ue_id(f1ap_cudu_inst_t *f1_inst, module_id_t cu_ue_f1ap_id, module_id_t du_ue_f1ap_id) { module_id_t f1ap_uid = f1ap_get_cu_uid(f1_inst,cu_ue_f1ap_id); - if (f1ap_uid < 0) return -1; + if (f1ap_uid < 0 || f1ap_uid >= MAX_MOBILES_PER_ENB) return -1; f1_inst->f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id; LOG_I(F1AP, "Adding du_ue_f1ap_id %d for UE with RNTI %x\n", du_ue_f1ap_id, f1_inst->f1ap_ue[f1ap_uid].rnti); return 0; diff --git a/openair2/F1AP/f1ap_cu_interface_management.c b/openair2/F1AP/f1ap_cu_interface_management.c index b451a01457..941dc41a4d 100644 --- a/openair2/F1AP/f1ap_cu_interface_management.c +++ b/openair2/F1AP/f1ap_cu_interface_management.c @@ -327,6 +327,7 @@ int CU_send_F1_SETUP_RESPONSE(instance_t instance, /* - nRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_setup_resp->mcc[i], f1ap_setup_resp->mnc[i], f1ap_setup_resp->mnc_digit_length[i], &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(f1ap_setup_resp->nr_cellid[i], &nRCGI.nRCellIdentity); @@ -562,6 +563,7 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, module_id_t du_mod_ /* - nRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); @@ -611,6 +613,7 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, module_id_t du_mod_ /* - nRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); @@ -787,6 +790,7 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, module_id_t du_mod_ /* - nRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI,0,sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 6f6a84e404..edc5a2c0a9 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -95,6 +95,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_NRCGI; /* - nRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_ue_context_setup_req->mcc, f1ap_ue_context_setup_req->mnc, f1ap_ue_context_setup_req->mnc_digit_length, @@ -1183,6 +1184,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { // /* - sCell_ID */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); @@ -1222,6 +1224,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { /* - sCell_ID */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index f076b28a44..83f3da57b2 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -169,6 +169,7 @@ int DU_send_F1_SETUP_REQUEST(instance_t instance) { /* - nRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &nRCGI.pLMN_Identity); LOG_D(F1AP, "plmn: (%d,%d)\n",f1ap_du_data->mcc[i],f1ap_du_data->mnc[i]); //MCC_MNC_TO_PLMNID(208, 95, 2, &nRCGI.pLMN_Identity); @@ -619,6 +620,7 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, memset((void *)&served_cell_information, 0, sizeof(F1AP_Served_Cell_Information_t)); /* - nRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], &nRCGI.pLMN_Identity); LOG_D(F1AP, "nr_cellId : %x %x %x %x %x\n", nRCGI.nRCellIdentity.buf[0], @@ -778,6 +780,7 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, /* 3.1 oldNRCGI */ F1AP_NRCGI_t oldNRCGI; + memset(&oldNRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], &oldNRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(f1ap_setup_req->nr_cellid[i], &oldNRCGI.nRCellIdentity); @@ -790,6 +793,7 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, /* - nRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(f1ap_setup_req->nr_cellid[i], &nRCGI.nRCellIdentity); @@ -944,6 +948,7 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, /* 3.1 oldNRCGI */ F1AP_NRCGI_t oldNRCGI; + memset(&oldNRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], &oldNRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(f1ap_setup_req->nr_cellid[i], &oldNRCGI.nRCellIdentity); @@ -980,6 +985,7 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, /* 3.1 oldNRCGI */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(f1ap_setup_req->nr_cellid[i], &nRCGI.nRCellIdentity); diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index bb477f5696..6ece2d53a5 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -799,6 +799,7 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, ie->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_NRCGI; F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[0], f1ap_du_data->mnc[0], f1ap_du_data->mnc_digit_length[0], &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[0], &nRCGI.nRCellIdentity); diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 1a80132ea8..f6fd66d50a 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -470,6 +470,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance) { /* sCell_ID */ F1AP_NRCGI_t nRCGI; // issue here + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[0], &nRCGI.nRCellIdentity); @@ -1155,6 +1156,7 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { /* - sCell_ID */ F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &nRCGI.pLMN_Identity); diff --git a/openair2/F1AP/f1ap_handlers.c b/openair2/F1AP/f1ap_handlers.c index a5b6a09963..12aba18a9d 100644 --- a/openair2/F1AP/f1ap_handlers.c +++ b/openair2/F1AP/f1ap_handlers.c @@ -98,7 +98,7 @@ int f1ap_handle_message(instance_t instance, uint32_t assoc_id, int32_t stream, } /* Checking procedure Code and direction of message */ - if (pdu.choice.initiatingMessage->procedureCode > sizeof(f1ap_messages_callback) / (3 * sizeof( + if (pdu.choice.initiatingMessage->procedureCode >= sizeof(f1ap_messages_callback) / (3 * sizeof( f1ap_message_decoded_callback)) || (pdu.present > F1AP_F1AP_PDU_PR_unsuccessfulOutcome)) { LOG_E(F1AP, "[SCTP %d] Either procedureCode %ld or direction %d exceed expected\n", diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index e70ed082f9..f68db9ffec 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -1399,7 +1399,6 @@ dlsch_scheduler_pre_processor_reset(module_id_t module_idP, // for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { - LOG_D(MAC, "Running preprocessor for UE %d (%x)\n", UE_id,(int)(UE_RNTI(module_idP, UE_id))); // initialize harq_pid and round cc = &RC.mac[module_idP]->common_channels[CC_id]; N_RBG[CC_id] = to_rbg(cc->mib->message.dl_Bandwidth); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 17d386343b..b2a7e9ddfc 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -499,7 +499,7 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) (void)data_p; pdcp_t *pdcp_p = NULL; //TTN for D2D (PC5S) - int prose_addr_len; + int prose_addr_len = sizeof(prose_pdcp_addr); char send_buf[BUFSIZE], receive_buf[BUFSIZE]; //int optval; int bytes_received; diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c index 18db23eb55..a0569b7f00 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c @@ -112,7 +112,7 @@ signed int rlc_um_get_pdu_infos( // PROTOCOL_RLC_UM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs ", // PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), // pdu_info_pP->sn); - if(pdu_info_pP->num_li > RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { + if(pdu_info_pP->num_li >= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs \n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), pdu_info_pP->sn); diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 4ee71c13be..1dd3a26053 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -3915,6 +3915,27 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); + + free(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ); + quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = NULL; + + free(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP); + quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = NULL; + + free(quantityConfig->quantityConfigEUTRA); + quantityConfig->quantityConfigEUTRA = NULL; + + free(quantityConfig); + quantityConfig = NULL; + + free(mac_MainConfig->ul_SCH_Config); + mac_MainConfig->ul_SCH_Config = NULL; + + free(mac_MainConfig->phr_Config); + mac_MainConfig->phr_Config = NULL; + + free(mac_MainConfig); + mac_MainConfig = NULL; } @@ -7736,9 +7757,9 @@ void *rrc_enb_process_itti_msg(void *notUsed) { &ctxt, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); - if (RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= RRC_BUFFER_SIZE_MAX) { + if (RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= CCCH_SDU_SIZE) { LOG_I(RRC, "CCCH message has size %d > %d\n", - RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX); + RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,CCCH_SDU_SIZE); break; } @@ -8154,7 +8175,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( //----------------------------------------------------------------------------- { uint8_t buffer[RRC_BUF_SIZE]; - uint16_t size = -1; + uint16_t size = 0; memset(buffer, 0, RRC_BUF_SIZE); // allocate dedicated pools for UE -sl-CommConfig/sl-DiscConfig (sl-V2X-ConfigDedicated) @@ -8291,6 +8312,7 @@ LTE_SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool( const protocol_ctxt_t * LTE_SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, int n_discoveryMessages ) { //TODO LTE_SL_DiscConfig_r12_t sl_DiscConfig; + memset(&sl_DiscConfig,0,sizeof(LTE_SL_DiscConfig_r12_t)); sl_DiscConfig.discTxResources_r12 = CALLOC(1,sizeof(*sl_DiscConfig.discTxResources_r12)); sl_DiscConfig.discTxResources_r12->present = LTE_SL_DiscConfig_r12__discTxResources_r12_PR_setup; sl_DiscConfig.discTxResources_r12->choice.setup.present = LTE_SL_DiscConfig_r12__discTxResources_r12__setup_PR_scheduled_r12; diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 6357bcfc64..ddcd6983c8 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -846,6 +846,7 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( uint8_t srb_id; struct rrc_eNB_ue_context_s *ue_context_p = NULL; protocol_ctxt_t ctxt; + memset(&ctxt, 0, sizeof(protocol_ctxt_t)); ue_initial_id = S1AP_DOWNLINK_NAS (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); diff --git a/openair2/UTIL/ASYNC_IF/socket_link.c b/openair2/UTIL/ASYNC_IF/socket_link.c index e40fba4a04..5717624930 100644 --- a/openair2/UTIL/ASYNC_IF/socket_link.c +++ b/openair2/UTIL/ASYNC_IF/socket_link.c @@ -228,7 +228,7 @@ socket_link_t *new_link_udp_client(const char *server, int port){ struct sockaddr_in si_other; int s; - socklen_t slen; + socklen_t slen = sizeof(si_other); if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1){ goto error; @@ -402,7 +402,7 @@ static int socket_udp_receive(int socket_fd, void *buf, int size) LOG_D(PROTO_AGENT,"UDP RECEIVE\n"); struct sockaddr_in client; - socklen_t slen; + socklen_t slen = sizeof(client); int l; l = recvfrom(socket_fd, buf, size, 0, (struct sockaddr *) &client, &slen); diff --git a/openair2/X2AP/x2ap_eNB_handler.c b/openair2/X2AP/x2ap_eNB_handler.c index 96ffac162e..dd59791ec9 100644 --- a/openair2/X2AP/x2ap_eNB_handler.c +++ b/openair2/X2AP/x2ap_eNB_handler.c @@ -192,7 +192,7 @@ int x2ap_eNB_handle_message(instance_t instance, uint32_t assoc_id, int32_t stre case X2AP_X2AP_PDU_PR_initiatingMessage: /* Checking procedure Code and direction of message */ - if (pdu.choice.initiatingMessage.procedureCode > sizeof(x2ap_messages_callback) / (3 * sizeof( + if (pdu.choice.initiatingMessage.procedureCode >= sizeof(x2ap_messages_callback) / (3 * sizeof( x2ap_message_decoded_callback))) { //|| (pdu.present > X2AP_X2AP_PDU_PR_unsuccessfulOutcome)) { X2AP_ERROR("[SCTP %d] Either procedureCode %ld exceed expected\n", @@ -218,7 +218,7 @@ int x2ap_eNB_handle_message(instance_t instance, uint32_t assoc_id, int32_t stre case X2AP_X2AP_PDU_PR_successfulOutcome: /* Checking procedure Code and direction of message */ - if (pdu.choice.successfulOutcome.procedureCode > sizeof(x2ap_messages_callback) / (3 * sizeof( + if (pdu.choice.successfulOutcome.procedureCode >= sizeof(x2ap_messages_callback) / (3 * sizeof( x2ap_message_decoded_callback))) { //|| (pdu.present > X2AP_X2AP_PDU_PR_unsuccessfulOutcome)) { X2AP_ERROR("[SCTP %d] Either procedureCode %ld exceed expected\n", @@ -244,7 +244,7 @@ int x2ap_eNB_handle_message(instance_t instance, uint32_t assoc_id, int32_t stre case X2AP_X2AP_PDU_PR_unsuccessfulOutcome: /* Checking procedure Code and direction of message */ - if (pdu.choice.unsuccessfulOutcome.procedureCode > sizeof(x2ap_messages_callback) / (3 * sizeof( + if (pdu.choice.unsuccessfulOutcome.procedureCode >= sizeof(x2ap_messages_callback) / (3 * sizeof( x2ap_message_decoded_callback))) { //|| (pdu.present > X2AP_X2AP_PDU_PR_unsuccessfulOutcome)) { X2AP_ERROR("[SCTP %d] Either procedureCode %ld exceed expected\n", diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index d904e90f22..b04d0dbf28 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -986,7 +986,7 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue rnti %x in hashtable ue_mapping\n", data_req_p->rnti); } else { - if ((data_req_p->rab_id >= GTPV1U_BEARER_OFFSET) && (data_req_p->rab_id <= max_val_LTE_DRB_Identity)) { + if ((data_req_p->rab_id >= GTPV1U_BEARER_OFFSET) && (data_req_p->rab_id < max_val_LTE_DRB_Identity)) { enb_s1u_teid = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].teid_eNB; sgw_s1u_teid = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].teid_sgw; stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU; diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index 0c3b1ee25b..18c6d98601 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -220,7 +220,7 @@ int s1ap_eNB_handle_message(uint32_t assoc_id, int32_t stream, } /* Checking procedure Code and direction of message */ - if (pdu.choice.initiatingMessage.procedureCode > sizeof(messages_callback) / (3 * sizeof( + if (pdu.choice.initiatingMessage.procedureCode >= sizeof(messages_callback) / (3 * sizeof( s1ap_message_decoded_callback)) || (pdu.present > S1AP_S1AP_PDU_PR_unsuccessfulOutcome)) { S1AP_ERROR("[SCTP %d] Either procedureCode %ld or direction %d exceed expected\n", diff --git a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp index 1f0d78aba5..a57ebf8b6d 100644 --- a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp +++ b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp @@ -193,7 +193,7 @@ int trx_lms_start(openair0_device *device){ LMS_EnableChannel(lms_device,LMS_CH_RX,1,true); LMS_EnableChannel(lms_device,LMS_CH_TX,1,true); } */ - LMS_VCTCXOWrite(lms_device,129, true); + LMS_VCTCXOWrite(lms_device, 129); if (LMS_SetSampleRate(lms_device,device->openair0_cfg->sample_rate,2)!=0) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 93a2440b94..1f8d6aac81 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -678,6 +678,7 @@ static void *emulatedRF_thread(void *param) { req.tv_sec = 0; req.tv_nsec = (numerology>0)? ((microsec * 1000L)/numerology):(microsec * 1000L)*2; cpu_set_t cpuset; + CPU_ZERO(&cpuset); CPU_SET(1,&cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); int policy; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index a117c6b9c1..0dfbcff954 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -618,6 +618,8 @@ int main( int argc, char **argv ) { ctxt.instance = 0; ctxt.rnti = 0; ctxt.enb_flag = 1; + ctxt.frame = 0; + ctxt.subframe = 0; pdcp_run(&ctxt); }