Commit 7578cd31 authored by Konstantinos Alexandris's avatar Konstantinos Alexandris Committed by Robert Schmidt

fixes: segmentation faults issues in RRC CM for RRC Measurement report,...

fixes: segmentation faults issues in RRC CM for RRC Measurement report, clean-up and re-implementation of functions in RAN API
parent 7410e80d
......@@ -412,7 +412,6 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
Protocol__FlexEutraMeasurements **eutra_meas = NULL;
if (neigh_meas->n_eutra_meas > 0) {
eutra_meas = malloc(sizeof(Protocol__FlexEutraMeasurements) * neigh_meas->n_eutra_meas);
if (eutra_meas == NULL) {
free(neigh_meas);
......@@ -438,38 +437,48 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
eutra_meas[j]->phys_cell_id = flexran_get_rrc_neigh_phy_cell_id(mod_id, rnti, j);
eutra_meas[j]->has_phys_cell_id = 1;
/* Initialize CGI measurements. */
Protocol__FlexEutraCgiMeasurements *cgi_meas;
cgi_meas = malloc(sizeof(Protocol__FlexEutraCgiMeasurements));
if (flexran_get_rrc_neigh_cgi(mod_id, rnti, j)) {
/* Initialize CGI measurements. */
Protocol__FlexEutraCgiMeasurements *cgi_meas;
cgi_meas = malloc(sizeof(Protocol__FlexEutraCgiMeasurements));
protocol__flex_eutra_cgi_measurements__init(cgi_meas);
protocol__flex_eutra_cgi_measurements__init(cgi_meas);
/* EUTRA Cell Global Identity (CGI) */
Protocol__FlexCellGlobalEutraId *cgi;
cgi = malloc(sizeof(Protocol__FlexCellGlobalEutraId));
/* EUTRA Cell Global Identity (CGI) */
Protocol__FlexCellGlobalEutraId *cgi;
cgi = malloc(sizeof(Protocol__FlexCellGlobalEutraId));
protocol__flex_cell_global_eutra_id__init(cgi);
protocol__flex_cell_global_eutra_id__init(cgi);
cgi->cell_id = flexran_get_rrc_neigh_cgi_cell_id(mod_id, rnti, eutra_meas[j]->phys_cell_id);
cgi->has_cell_id = 1;
cgi->cell_id = flexran_get_rrc_neigh_cgi_cell_id(mod_id, rnti, j);
cgi->has_cell_id = 1;
cgi_meas->tracking_area_code = flexran_get_rrc_neigh_cgi_tac(mod_id, rnti, eutra_meas[j]->phys_cell_id);
cgi_meas->has_tracking_area_code = 1;
cgi_meas->tracking_area_code = flexran_get_rrc_neigh_cgi_tac(mod_id, rnti, j);
cgi_meas->has_tracking_area_code = 1;
/* PLMN for neighbouring cell */
Protocol__FlexPlmnIdentity *plmn_id;
plmn_id = malloc(sizeof(Protocol__FlexPlmnIdentity));
/* PLMN for neighbouring cell */
Protocol__FlexPlmnIdentity *plmn_id;
plmn_id = malloc(sizeof(Protocol__FlexPlmnIdentity));
protocol__flex_plmn_identity__init(plmn_id);
protocol__flex_plmn_identity__init(plmn_id);
plmn_id->mcc = 0;
for (int m = 0; m < flexran_get_rrc_neigh_cgi_num_mcc(mod_id, rnti, eutra_meas[j]->phys_cell_id); m++) {
plmn_id->mcc += flexran_get_rrc_neigh_cgi_mcc(mod_id, rnti, eutra_meas[j]->phys_cell_id, m);
}
plmn_id->mcc = 0;
plmn_id->n_mcc = flexran_get_rrc_neigh_cgi_num_mcc(mod_id, rnti, j);
for (int m = 0; m < plmn_id->n_mcc; m++) {
plmn_id->mcc += flexran_get_rrc_neigh_cgi_mcc(mod_id, rnti, j, m);
}
plmn_id->mnc = 0;
plmn_id->n_mnc = flexran_get_rrc_neigh_cgi_num_mnc(mod_id, rnti, j);
for (int m = 0; m < plmn_id->n_mnc; m++) {
plmn_id->mnc += flexran_get_rrc_neigh_cgi_mnc(mod_id, rnti, j, m);
}
plmn_id->mnc = 0;
for (int m = 0; m < flexran_get_rrc_neigh_cgi_num_mnc(mod_id, rnti, eutra_meas[j]->phys_cell_id); m++) {
plmn_id->mnc += flexran_get_rrc_neigh_cgi_mnc(mod_id, rnti, eutra_meas[j]->phys_cell_id, m);
cgi->plmn_id = plmn_id;
cgi_meas->cgi = cgi;
eutra_meas[j]->cgi_meas = cgi_meas;
}
/*RSRP/RSRQ of the neighbouring cell */
......@@ -478,13 +487,12 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
protocol__flex_eutra_ref_signal_meas__init(meas_result);
meas_result->rsrp = flexran_get_rrc_neigh_rsrp(mod_id, rnti, eutra_meas[j]->phys_cell_id);
meas_result->rsrp = flexran_get_rrc_neigh_rsrp(mod_id, rnti, j);
meas_result->has_rsrp = 1;
meas_result->rsrq = flexran_get_rrc_neigh_rsrq(mod_id, rnti, eutra_meas[j]->phys_cell_id);
meas_result->rsrq = flexran_get_rrc_neigh_rsrq(mod_id, rnti, j);
meas_result->has_rsrq = 1;
eutra_meas[j]->cgi_meas = cgi_meas;
eutra_meas[j]->meas_result = meas_result;
}
......@@ -500,11 +508,8 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
}
}
}
return 0;
error:
for (int i = 0; i < report_config->nr_ue; i++) {
if (ue_report[i]->rrc_measurements && ue_report[i]->rrc_measurements->neigh_meas != NULL) {
for (int j = 0; j < ue_report[i]->rrc_measurements->neigh_meas->n_eutra_meas; j++) {
......@@ -518,7 +523,6 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
free(cell_report);
if (ue_report != NULL)
free(ue_report);
return -1;
}
......
......@@ -1474,7 +1474,7 @@ int flexran_get_rrc_num_ncell(mid_t mod_id, rnti_t rnti) {
if (!ue_context_p) return 0;
if (!ue_context_p->ue_context.measResults) return 0;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return 0;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return 0;
//if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return 0;
return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count;
}
......@@ -1484,79 +1484,59 @@ long flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, rnti_t rnti, long cell_id)
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
//if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1;
return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->physCellId;
}
int flexran_get_rrc_neigh_cgi(mid_t mod_id, rnti_t rnti, long cell_id) {
if (!rrc_is_present(mod_id)) return 0;
struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
if (!ue_context_p) return 0;
if (!ue_context_p->ue_context.measResults) return 0;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return 0;
//if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return 0;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return 0;
return (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info)?0:1;
}
uint32_t flexran_get_rrc_neigh_cgi_cell_id(mid_t mod_id, rnti_t rnti, long cell_id) {
if (!rrc_is_present(mod_id)) return -1;
struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1;
uint8_t *cId = ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info->cellGlobalId.cellIdentity.buf;
return ((cId[0] << 20) + (cId[1] << 12) + (cId[2] << 4) + (cId[3] >> 4));
}
uint32_t flexran_get_rrc_neigh_cgi_tac(mid_t mod_id, rnti_t rnti, long cell_id) {
if (!rrc_is_present(mod_id)) return -1;
struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1;
uint8_t *tac = ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info->trackingAreaCode.buf;
return (tac[0] << 8) + (tac[1]);
}
uint32_t flexran_get_rrc_neigh_cgi_num_mnc(mid_t mod_id, rnti_t rnti, long cell_id) {
if (!rrc_is_present(mod_id)) return -1;
int flexran_get_rrc_neigh_cgi_num_mnc(mid_t mod_id, rnti_t rnti, long cell_id) {
struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1;
return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info->cellGlobalId.plmn_Identity.mnc.list.count;
}
uint32_t flexran_get_rrc_neigh_cgi_num_mcc(mid_t mod_id, rnti_t rnti, long cell_id) {
if (!rrc_is_present(mod_id)) return -1;
int flexran_get_rrc_neigh_cgi_num_mcc(mid_t mod_id, rnti_t rnti, long cell_id) {
struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1;
return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info->cellGlobalId.plmn_Identity.mcc->list.count;
}
uint32_t flexran_get_rrc_neigh_cgi_mnc(mid_t mod_id, rnti_t rnti, long cell_id, int mnc_id) {
if (!rrc_is_present(mod_id)) return -1;
struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1;
int num_mnc = ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info->cellGlobalId.plmn_Identity.mnc.list.count;
return *(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info->cellGlobalId.plmn_Identity.mnc.list.array[mnc_id]) *
((uint32_t) pow(10, num_mnc - mnc_id - 1));
}
uint32_t flexran_get_rrc_neigh_cgi_mcc(mid_t mod_id, rnti_t rnti, long cell_id, int mcc_id) {
if (!rrc_is_present(mod_id)) return -1;
struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1;
int num_mcc = ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info->cellGlobalId.plmn_Identity.mcc->list.count;
return *(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->cgi_Info->cellGlobalId.plmn_Identity.mcc->list.array[mcc_id]) *
((uint32_t) pow(10, num_mcc - mcc_id - 1));
......@@ -1568,9 +1548,9 @@ float flexran_get_rrc_neigh_rsrp(mid_t mod_id, rnti_t rnti, long cell_id) {
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
//if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult) return 0;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult) return -1;
return RSRP_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult)];
}
......@@ -1580,8 +1560,8 @@ float flexran_get_rrc_neigh_rsrq(mid_t mod_id, rnti_t rnti, long cell_id) {
if (!ue_context_p) return -1;
if (!ue_context_p->ue_context.measResults) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult) return 0;
//if (ue_context_p->ue_context.measResults->measResultNeighCells->present != LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1;
if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult) return -1;
return RSRQ_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult)];
}
......
......@@ -513,6 +513,9 @@ int flexran_get_rrc_num_ncell(mid_t mod_id, rnti_t rnti);
/* Get neighbouring physical cell id */
long flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, rnti_t rnti, long cell_id);
/* Get neighbouring cgi */
int flexran_get_rrc_neigh_cgi(mid_t mod_id, rnti_t rnti, long cell_id);
/* Get neighbouring cgi info cell id */
uint32_t flexran_get_rrc_neigh_cgi_cell_id(mid_t mod_id, rnti_t rnti, long cell_id);
......@@ -520,10 +523,10 @@ uint32_t flexran_get_rrc_neigh_cgi_cell_id(mid_t mod_id, rnti_t rnti, long cell_
uint32_t flexran_get_rrc_neigh_cgi_tac(mid_t mod_id, rnti_t rnti, long cell_id);
/* Get the number of neighbouring cgi mnc */
uint32_t flexran_get_rrc_neigh_cgi_num_mnc(mid_t mod_id, rnti_t rnti, long cell_id);
int flexran_get_rrc_neigh_cgi_num_mnc(mid_t mod_id, rnti_t rnti, long cell_id);
/* Get the number of neighbouring cgi mcc */
uint32_t flexran_get_rrc_neigh_cgi_num_mcc(mid_t mod_id, rnti_t rnti, long cell_id);
int flexran_get_rrc_neigh_cgi_num_mcc(mid_t mod_id, rnti_t rnti, long cell_id);
/* Get neighbouring cgi mnc */
uint32_t flexran_get_rrc_neigh_cgi_mnc(mid_t mod_id, rnti_t rnti, long cell_id, int mnc_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment