From 50c32c08fb607bb7b1ac098f90c4b3a21eac169c Mon Sep 17 00:00:00 2001 From: Ron Shacham Date: Tue, 22 Sep 2020 20:01:31 -0400 Subject: [PATCH] Fixed up issues with last commit Signed-off-by: Ron Shacham Change-Id: I30187c4dcbfe2fae518e0c2ab640a4b400c9f43c Signed-off-by: Ron Shacham --- e2sim/e2sm_examples/kpm_e2sm/Dockerfile | 20 +- e2sim/e2sm_examples/kpm_e2sm/helm/Chart.yaml | 22 ++ .../kpm_e2sm/helm/templates/deployment.yaml | 40 +++ e2sim/e2sm_examples/kpm_e2sm/helm/values.yaml | 21 ++ .../e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp | 5 +- .../kpm_e2sm/src/kpm/kpm_callbacks.cpp | 257 +++++++++++++---- e2sim/src/base/e2sim.cpp | 12 +- e2sim/src/encoding/encode_e2apv1.cpp | 311 ++------------------- e2sim/src/messagerouting/e2ap_message_handler.cpp | 19 +- 9 files changed, 348 insertions(+), 359 deletions(-) create mode 100644 e2sim/e2sm_examples/kpm_e2sm/helm/Chart.yaml create mode 100755 e2sim/e2sm_examples/kpm_e2sm/helm/templates/deployment.yaml create mode 100644 e2sim/e2sm_examples/kpm_e2sm/helm/values.yaml diff --git a/e2sim/e2sm_examples/kpm_e2sm/Dockerfile b/e2sim/e2sm_examples/kpm_e2sm/Dockerfile index 6b16671..04aa2c9 100644 --- a/e2sim/e2sm_examples/kpm_e2sm/Dockerfile +++ b/e2sim/e2sm_examples/kpm_e2sm/Dockerfile @@ -43,8 +43,8 @@ WORKDIR /playpen ARG E2SIM_VER=1.0.0 # package cloud urls for wget -ARG PC_REL_URL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch -ARG PC_STG_URL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch +#ARG PC_REL_URL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch +#ARG PC_STG_URL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch # snarf up E2SIM dependencies, then pull E2SIM package and install @@ -73,22 +73,24 @@ RUN apt-get update \ && apt-get clean -RUN wget -nv --content-disposition ${PC_STG_URL}/sdl_${SDL_VER}-1_amd64.deb/download.deb && \ - wget -nv --content-disposition ${PC_STG_URL}/sdl-dev_${SDL_VER}-1_amd64.deb/download.deb &&\ - dpkg -i sdl-dev_${SDL_VER}-1_amd64.deb sdl_${SDL_VER}-1_amd64.deb +#RUN wget -nv --content-disposition ${PC_STG_URL}/sdl_${SDL_VER}-1_amd64.deb/download.deb && \ +# wget -nv --content-disposition ${PC_STG_URL}/sdl-dev_${SDL_VER}-1_amd64.deb/download.deb &&\ +# dpkg -i sdl-dev_${SDL_VER}-1_amd64.deb sdl_${SDL_VER}-1_amd64.deb # # build and install the application(s) # -#COPY e2sim_1.0.0_amd64.deb /playpen -#COPY e2sim-dev_1.0.0_amd64.deb /playpen +COPY e2sim_1.0.0_amd64.deb /playpen +COPY e2sim-dev_1.0.0_amd64.deb /playpen RUN dpkg -i e2sim_1.0.0_amd64.deb e2sim-dev_1.0.0_amd64.deb + RUN mkdir /usr/local/include/nlohmann -COPY nlohmann_json_release/json.hpp /usr/local/include/nlohmann +RUN git clone https://github.com/azadkuh/nlohmann_json_release.git +RUN cp nlohmann_json_release/json.hpp /usr/local/include/nlohmann COPY . /playpen/src/ RUN cd /playpen/src && \ @@ -99,4 +101,4 @@ RUN cd /playpen/src && \ make install -CMD [ "/usr/local/bin/ts_xapp" ] +CMD kpm_sim 10.98.179.210 36422 diff --git a/e2sim/e2sm_examples/kpm_e2sm/helm/Chart.yaml b/e2sim/e2sm_examples/kpm_e2sm/helm/Chart.yaml new file mode 100644 index 0000000..fdd3174 --- /dev/null +++ b/e2sim/e2sm_examples/kpm_e2sm/helm/Chart.yaml @@ -0,0 +1,22 @@ +# ================================================================================== +# Copyright (c) 2020 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 +# +# 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. +# ================================================================================== + +apiVersion: v1 +appVersion: "1.0" +description: Helm chart for E2Sim Kubernetes +name: e2sim +namespace: ricplt +version: 3.0.0 diff --git a/e2sim/e2sm_examples/kpm_e2sm/helm/templates/deployment.yaml b/e2sim/e2sm_examples/kpm_e2sm/helm/templates/deployment.yaml new file mode 100755 index 0000000..6ea5f8d --- /dev/null +++ b/e2sim/e2sm_examples/kpm_e2sm/helm/templates/deployment.yaml @@ -0,0 +1,40 @@ +# ================================================================================== +# Copyright (c) 2020 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 +# +# 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. +# ================================================================================== + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: e2sim + namespace: ricplt +spec: + selector: + matchLabels: + app: e2simulator + release: {{ .Release.Name }} + template: + metadata: + labels: + app: e2simulator + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + spec: + containers: + - name: e2sim + image: e2simul:0.0.2 + imagePullPolicy: IfNotPresent + restartPolicy: Always + diff --git a/e2sim/e2sm_examples/kpm_e2sm/helm/values.yaml b/e2sim/e2sm_examples/kpm_e2sm/helm/values.yaml new file mode 100644 index 0000000..da0d320 --- /dev/null +++ b/e2sim/e2sm_examples/kpm_e2sm/helm/values.yaml @@ -0,0 +1,21 @@ +# ================================================================================== +# Copyright (c) 2020 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 +# +# 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. +# ================================================================================== + +################################################################# +# Application configuration defaults. +################################################################# +# application image + diff --git a/e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp b/e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp index 29b6a48..fe09f64 100644 --- a/e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp +++ b/e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp @@ -16,7 +16,6 @@ # * ******************************************************************************/ - #include #include #include @@ -1211,10 +1210,10 @@ void encode_kpm_report_style5_parameterized(E2SM_KPM_IndicationMessage_t* indica bytesul->size = 4; } - + long fqi = 9; FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t)); ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem); - fqilistitem->fiveQI = 9; + fqilistitem->fiveQI = fqi; fqilistitem->pDCPBytesDL = bytesdl; fqilistitem->pDCPBytesUL = bytesul; diff --git a/e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp b/e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp index 3f0d013..98f99bb 100644 --- a/e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp +++ b/e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp @@ -29,6 +29,8 @@ extern "C" { #include "E2SM-KPM-IndicationMessage.h" #include "FQIPERSlicesPerPlmnListItem.h" #include "E2SM-KPM-RANfunction-Description.h" + #include "E2SM-KPM-IndicationHeader-Format1.h" + #include "E2SM-KPM-IndicationHeader.h" #include "Timestamp.h" #include "E2AP-PDU.h" #include "RICsubscriptionRequest.h" @@ -58,6 +60,8 @@ E2Sim e2sim; int main(int argc, char* argv[]) { + fprintf(stderr, "Starting KPM processor sim"); + asn_codec_ctx_t *opt_cod; E2SM_KPM_RANfunction_Description_t *ranfunc_desc = @@ -100,13 +104,19 @@ int main(int argc, char* argv[]) { printf("value of this index is %d\n", ranfuncdesc[100]); printf("value of this index is %d\n", ranfuncdesc[101]); - e2sim.register_e2sm(1,ranfunc_ostr); - e2sim.register_subscription_callback(1,&callback_kpm_subscription_request); + e2sim.register_e2sm(0,ranfunc_ostr); + e2sim.register_subscription_callback(0,&callback_kpm_subscription_request); e2sim.run_loop(argc, argv); } +/* +void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long actionId) { + +} +*/ + void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long actionId) { //Process simulation file @@ -118,10 +128,10 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long simfile.open("simulation.txt", ios::in); - cout << "step1" << endl; - - std::ifstream ue_stream("ueMeasReport.txt"); - std::ifstream cell_stream("cellMeasReport.txt"); + // cout << "step1" << endl; + + std::ifstream ue_stream("/playpen/src/ueMeasReport.txt"); + std::ifstream cell_stream("/playpen/src/cellMeasReport.txt"); json all_ues_json; @@ -133,8 +143,8 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long asn_codec_ctx_t *opt_cod; - cout << "UE RF Measurements" << endl; - cout << "******************" << endl; + // cout << "UE RF Measurements" << endl; + // cout << "******************" << endl; int numMeasReports = (all_ues_json["/ueMeasReport/ueMeasReportList"_json_pointer]).size(); @@ -143,21 +153,21 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long int nextRsrp; int nextRsrq; int nextRssinr; - cout << "UE number " + i << endl; - cout << "**********" << endl; + // cout << "UE number " + i << endl; + // cout << "**********" << endl; json::json_pointer p1(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/nrCellIdentity"); nextCellId = all_ues_json[p1].get(); - cout << "Serving Cell " << nextCellId << endl; + // cout << "Serving Cell " << nextCellId << endl; json::json_pointer p2(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rsrp"); nextRsrp = all_ues_json[p2].get(); - cout << " RSRP " << nextRsrp << endl; + // cout << " RSRP " << nextRsrp << endl; json::json_pointer p3(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rsrq"); nextRsrq = all_ues_json[p3].get(); - cout << " RSRQ " << nextRsrq << endl; + // cout << " RSRQ " << nextRsrq << endl; json::json_pointer p4(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rssinr"); nextRssinr = all_ues_json[p4].get(); - cout << " RSSINR " << nextRssinr << endl; + // cout << " RSSINR " << nextRssinr << endl; json::json_pointer p5(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList"); @@ -194,21 +204,21 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long for (int j = 0; j < numNeighborCells; j++) { json::json_pointer p8(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList/" + std::to_string(j) + "/nbCellIdentity"); nextNbCell = all_ues_json[p8].get(); - cout << "Neighbor Cell " << all_ues_json[p8] << endl; + //cout << "Neighbor Cell " << all_ues_json[p8] << endl; json::json_pointer p9(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rsrp"); nextNbRsrp = all_ues_json[p9].get(); - cout << " RSRP " << nextNbRsrp << endl; + //cout << " RSRP " << nextNbRsrp << endl; json::json_pointer p10(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rsrq"); nextNbRsrq = all_ues_json[p10].get(); - cout << " RSRQ " << nextNbRsrq << endl; + //cout << " RSRQ " << nextNbRsrq << endl; json::json_pointer p11(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rssinr"); nextNbRssinr = all_ues_json[p11].get(); - cout << " RSSINR " << nextNbRssinr << endl; + //cout << " RSSINR " << nextNbRssinr << endl; if (j != 0) { neighbor_str += ","; @@ -224,11 +234,12 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long const uint8_t *neighbor_buf = reinterpret_cast(neighbor_str.c_str()); - printf("Neighbor string\n%s", neighbor_buf); + // printf("Neighbor string\n%s", neighbor_buf); uint8_t *plmnid_buf = (uint8_t*)"747"; uint8_t *nrcellid_buf = (uint8_t*)"12340"; - + + /* encode_kpm_report_rancontainer_cucp_parameterized(ind_msg3, plmnid_buf, nrcellid_buf, crnti_buf, serving_buf, neighbor_buf); uint8_t e2smbuffer3[8192]; @@ -242,21 +253,22 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long fprintf(stderr, "er encded is %d\n", er3.encoded); fprintf(stderr, "after encoding message\n"); - uint8_t *e2smheader_buf3 = (uint8_t*)"header"; + uint8_t *e2smheader_buf3 = (uint8_t*)""; - e2sim.generate_e2apv1_indication_request_parameterized(pdu3, requestorId, - instanceId, ranFunctionId, - actionId, seqNum, e2smheader_buf3, 6, e2smbuffer3, er3.encoded); + generate_e2apv1_indication_request_parameterized(pdu3, requestorId, + instanceId, ranFunctionId, + actionId, seqNum, e2smheader_buf3, 0, e2smbuffer3, er3.encoded); - e2sim.encode_and_send_sctp_data(pdu3); + e2sim.encode_and_send_sctp_data(pdu3); + */ seqNum++; } - cout << "Cell Measurements" << endl; - cout << "******************" << endl; + // cout << "Cell Measurements" << endl; + // cout << "******************" << endl; int numCellMeasReports = (all_cells_json["/cellMeasReport/cellMeasReportList"_json_pointer]).size(); @@ -274,17 +286,17 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long json::json_pointer p1(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/nrCellIdentity"); nextCellId = all_cells_json[p1].get(); - cout << std::string("Cell number ") << nextCellId << endl; + // cout << std::string("Cell number ") << nextCellId << endl; - cout << "**********" << endl; + // cout << "**********" << endl; json::json_pointer p2(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/pdcpByteMeasReport/pdcpBytesDl"); nextPdcpBytesDL = all_cells_json[p2].get(); - cout << std::string(" PDCP Bytes DL ") << nextPdcpBytesDL << endl; + // cout << std::string(" PDCP Bytes DL ") << nextPdcpBytesDL << endl; json::json_pointer p3(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/pdcpByteMeasReport/pdcpBytesUl"); nextPdcpBytesUL = all_cells_json[p3].get(); - cout << std::string(" PDCP Bytes UL ") << nextPdcpBytesUL << endl; + // cout << std::string(" PDCP Bytes UL ") << nextPdcpBytesUL << endl; uint8_t *buf = (uint8_t*)"GNBCUUP5"; @@ -293,7 +305,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long int bytes_ul = nextPdcpBytesUL; // int bytes_dl = 3905; - // int bytes_ul = 1609321; + // int bytes_ul = 1609321; E2SM_KPM_IndicationMessage_t *ind_msg2 = (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t)); @@ -308,28 +320,153 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationMessage, ind_msg2, e2smbuffer2, e2smbuffer_size2); - + fprintf(stderr, "er encded is %d\n", er2.encoded); fprintf(stderr, "after encoding message\n"); - uint8_t *e2smheader_buf2 = (uint8_t*)"header"; + + E2SM_KPM_IndicationHeader_t *ihead = + (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t)); + + + E2SM_KPM_IndicationHeader_Format1_t* ind_header = + (E2SM_KPM_IndicationHeader_Format1_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_Format1_t)); + + OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); + plmnid->buf = (uint8_t*)calloc(3,1); + plmnid->size = 3; + memcpy(plmnid->buf, plmnid_buf, plmnid->size); + + long fqival = 9; + long qcival = 9; + + OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); + sst->size = 6; + sst->buf = (uint8_t*)calloc(1,6); + memcpy(sst->buf,sst_buf,sst->size); + + + OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); + sds->size = 3; + sds->buf = (uint8_t*)calloc(1,3); + memcpy(sds->buf, sd_buf, sds->size); + + + SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t)); + ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai); + snssai->sST.buf = (uint8_t*)calloc(1,1); + snssai->sST.size = 1; + memcpy(snssai->sST.buf, sst_buf, 1); + snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); + snssai->sD->buf = (uint8_t*)calloc(1,3); + snssai->sD->size = 3; + memcpy(snssai->sD->buf, sd_buf, 3); + + + ind_header->pLMN_Identity = plmnid; + ind_header->fiveQI = &fqival; + + BIT_STRING_t *nrcellid = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));; + nrcellid->buf = (uint8_t*)calloc(1,5); + nrcellid->size = 5; + nrcellid->buf[0] = 0x22; + nrcellid->buf[1] = 0x5B; + nrcellid->buf[2] = 0xD6; + nrcellid->buf[3] = 0x00; + nrcellid->buf[4] = 0x70; + + nrcellid->bits_unused = 4; + + BIT_STRING_t *gnb_bstring = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));; + gnb_bstring->buf = (uint8_t*)calloc(1,4); + gnb_bstring->size = 4; + gnb_bstring->buf[0] = 0xB5; + gnb_bstring->buf[1] = 0xC6; + gnb_bstring->buf[2] = 0x77; + gnb_bstring->buf[3] = 0x88; + + gnb_bstring->bits_unused = 3; + + INTEGER_t *cuup_id = (INTEGER_t*)calloc(1, sizeof(INTEGER_t)); + uint8_t buffer[1]; + buffer[0] = 20000; + cuup_id->buf = (uint8_t*)calloc(1,1); + memcpy(cuup_id->buf, buffer, 1); + cuup_id->size = 1; + + ind_header->id_GlobalKPMnode_ID = (GlobalKPMnode_ID*)calloc(1,sizeof(GlobalKPMnode_ID)); + ind_header->id_GlobalKPMnode_ID->present = GlobalKPMnode_ID_PR_gNB; + ind_header->id_GlobalKPMnode_ID->choice.gNB.global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID; + ind_header->id_GlobalKPMnode_ID->choice.gNB.global_gNB_ID.gnb_id.choice.gnb_ID = *gnb_bstring; + ind_header->id_GlobalKPMnode_ID->choice.gNB.global_gNB_ID.plmn_id = *plmnid; + ind_header->id_GlobalKPMnode_ID->choice.gNB.gNB_CU_UP_ID = cuup_id; + + ind_header->nRCGI = (NRCGI*)calloc(1,sizeof(NRCGI)); + ind_header->nRCGI->pLMN_Identity = *plmnid; + ind_header->nRCGI->nRCellIdentity = *nrcellid; + + ind_header->sliceID = snssai; + ind_header->qci = &qcival; + // ind_header->message_Type = ; + // ind_header->gNB_DU_ID = ; + + + uint8_t *buf5 = (uint8_t*)"GNBCUUP5"; + OCTET_STRING_t *cuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); + cuupname->size = 8; + cuupname->buf = (uint8_t*)calloc(1,8); + memcpy(cuupname->buf, buf5, cuupname->size); + - e2sim.generate_e2apv1_indication_request_parameterized(pdu2, requestorId, - instanceId, ranFunctionId, - actionId, seqNum, e2smheader_buf2, 6, e2smbuffer2, er2.encoded); + ind_header->gNB_Name = (GNB_Name*)calloc(1,sizeof(GNB_Name)); + ind_header->gNB_Name->present = GNB_Name_PR_gNB_CU_UP_Name; + ind_header->gNB_Name->choice.gNB_CU_UP_Name = *cuupname; + + + ind_header->global_GNB_ID = (GlobalgNB_ID*)calloc(1,sizeof(GlobalgNB_ID)); + ind_header->global_GNB_ID->plmn_id = *plmnid; + ind_header->global_GNB_ID->gnb_id.present = GNB_ID_Choice_PR_gnb_ID; + ind_header->global_GNB_ID->gnb_id.choice.gnb_ID = *gnb_bstring; - e2sim.encode_and_send_sctp_data(pdu2); + + ihead->present = E2SM_KPM_IndicationHeader_PR_indicationHeader_Format1; + ihead->choice.indicationHeader_Format1 = *ind_header; + + printf("IndicationHeader - now printing xer\n"); + xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationHeader, ihead); + printf("IndicationHeader - done printing xer\n"); + + uint8_t e2sm_header_buffer[8192]; + size_t e2sm_header_buffer_size = 8192; + + asn_enc_rval_t er4 = asn_encode_to_buffer(opt_cod, + ATS_ALIGNED_BASIC_PER, + &asn_DEF_E2SM_KPM_IndicationHeader, + ihead, e2sm_header_buffer, e2sm_header_buffer_size); + + uint8_t *e2smheader_buf2 = (uint8_t*)""; + + int seqNum0 = 1; + + if (i == 0) { + encoding::generate_e2apv1_indication_request_parameterized(pdu2, requestorId, + instanceId, ranFunctionId, + actionId, seqNum0, e2sm_header_buffer, er4.encoded, e2smbuffer2, er2.encoded); + + e2sim.encode_and_send_sctp_data(pdu2); + } + seqNum++; json::json_pointer p4(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/prbMeasReport/availPrbDl"); nextPRBBytesDL = all_cells_json[p4].get(); - cout << std::string(" PRB Bytes DL ") << all_cells_json[p4] << endl; + // cout << std::string(" PRB Bytes DL ") << all_cells_json[p4] << endl; json::json_pointer p5(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/prbMeasReport/availPrbUl"); nextPRBBytesUL = all_cells_json[p5].get(); - cout << std::string(" PRB Bytes UL ") << all_cells_json[p5] << endl; + // cout << std::string(" PRB Bytes UL ") << all_cells_json[p5] << endl; //REPORT Message 1 -- Encode and send ODU cell-level report @@ -343,7 +480,8 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long uint8_t *nrcellid_buf = (uint8_t*)"12340"; long dl_prbs = nextPRBBytesDL; long ul_prbs = nextPRBBytesUL; - + + /* encode_kpm_report_style1_parameterized(ind_msg1, fiveqi, dl_prbs, ul_prbs, sst_buf, sd_buf, plmnid_buf, nrcellid_buf, &dl_prbs, &ul_prbs); uint8_t e2smbuffer[8192]; @@ -356,22 +494,23 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long fprintf(stderr, "er encded is %d\n", er.encoded); fprintf(stderr, "after encoding message\n"); - uint8_t *e2smheader_buf = (uint8_t*)"header"; + uint8_t *e2smheader_buf = (uint8_t*)""; uint8_t *cpid_buf = (uint8_t*)"CPID"; fprintf(stderr, "About to encode Indication\n"); - e2sim.generate_e2apv1_indication_request_parameterized(pdu, requestorId, - instanceId, ranFunctionId, - actionId, seqNum, e2smheader_buf, 6, e2smbuffer, er.encoded); - - e2sim.encode_and_send_sctp_data(pdu); + generate_e2apv1_indication_request_parameterized(pdu, requestorId, + instanceId, ranFunctionId, + actionId, seqNum, e2smheader_buf, 0, e2smbuffer, er.encoded); + e2sim.encode_and_send_sctp_data(pdu); + */ seqNum++; } + /* if (simfile.is_open()) { @@ -532,8 +671,10 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long } + void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) { + fprintf(stderr, "Calling callback_kpm_subscription_request\n"); //Record RIC Request ID //Go through RIC action to be Setup List @@ -568,11 +709,12 @@ void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) { RICsubscriptionRequest_IEs_t *next_ie = ies[i]; pres = next_ie->value.present; - fprintf(stderr, "next present value %d\n", pres); + fprintf(stderr, "The next present value %d\n", pres); switch(pres) { case RICsubscriptionRequest_IEs__value_PR_RICrequestID: { + fprintf(stderr,"in case request id\n"); RICrequestID_t reqId = next_ie->value.choice.RICrequestID; long requestorId = reqId.ricRequestorID; long instanceId = reqId.ricInstanceID; @@ -584,13 +726,19 @@ void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) { break; } case RICsubscriptionRequest_IEs__value_PR_RANfunctionID: - break; + { + fprintf(stderr,"in case ran func id\n"); + break; + } case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails: { - RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; + fprintf(stderr,"in case subscription details\n"); + RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; + fprintf(stderr,"in case subscription details 1\n"); RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition; + fprintf(stderr,"in case subscription details 2\n"); RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List; - + fprintf(stderr,"in case subscription details 3\n"); //We are ignoring the trigger definition //We identify the first action whose type is REPORT @@ -623,6 +771,11 @@ void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) { break; } + default: + { + fprintf(stderr,"in case default\n"); + break; + } } } @@ -645,7 +798,7 @@ void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) { int accept_size = actionIdsAccept.size(); int reject_size = actionIdsReject.size(); - e2sim.generate_e2apv1_subscription_response_success(e2ap_pdu, accept_array, reject_array, accept_size, reject_size, reqRequestorId, reqInstanceId); + encoding::generate_e2apv1_subscription_response_success(e2ap_pdu, accept_array, reject_array, accept_size, reject_size, reqRequestorId, reqInstanceId); e2sim.encode_and_send_sctp_data(e2ap_pdu); diff --git a/e2sim/src/base/e2sim.cpp b/e2sim/src/base/e2sim.cpp index 1f74389..fa62bed 100644 --- a/e2sim/src/base/e2sim.cpp +++ b/e2sim/src/base/e2sim.cpp @@ -34,14 +34,20 @@ using namespace std; int client_fd = 0; void E2Sim::register_subscription_callback(long func_id, SubscriptionCallback cb) { - printf("%%%%about to register callback for subscription for func_id %d\n", func_id); + fprintf(stderr,"%%%%about to register callback for subscription for func_id %d\n", func_id); subscription_callbacks[func_id] = cb; } SubscriptionCallback E2Sim::get_subscription_callback(long func_id) { - printf("%%%%we are getting the subscription callback for func id %d\n", func_id); - SubscriptionCallback cb = subscription_callbacks[func_id]; + fprintf(stderr, "%%%%we are getting the subscription callback for func id %d\n", func_id); + SubscriptionCallback cb; + + try { + cb = subscription_callbacks.at(func_id); + } catch(const std::out_of_range& e) { + throw std::out_of_range("Function ID is not registered"); + } return cb; } diff --git a/e2sim/src/encoding/encode_e2apv1.cpp b/e2sim/src/encoding/encode_e2apv1.cpp index 5c33fef..d1c2c06 100644 --- a/e2sim/src/encoding/encode_e2apv1.cpp +++ b/e2sim/src/encoding/encode_e2apv1.cpp @@ -30,7 +30,7 @@ #include "encode_e2apv1.hpp" extern "C" { - //#include "E2SM-KPM-RANfunction-Description.h" + #include "e2ap_asn1c_codec.h" #include "GlobalE2node-ID.h" @@ -80,13 +80,17 @@ long encoding::get_function_id_from_subscription(E2AP_PDU_t *e2ap_pdu) { pres = next_ie->value.present; fprintf(stderr, "next present value %d\n", pres); + fprintf(stderr, "value of pres ranfuncid is %d\n", RICsubscriptionRequest_IEs__value_PR_RANfunctionID); if (pres == RICsubscriptionRequest_IEs__value_PR_RANfunctionID) { + fprintf(stderr, "equal pres to ranfuncid\n"); func_id = next_ie->value.choice.RANfunctionID; } } + fprintf(stderr, "After loop, func_id is %d\n", func_id); + return func_id; } @@ -190,117 +194,7 @@ void encoding::generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu, } -/* -void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) { - - // uint8_t *buf = (uint8_t *)"gnb1" - - BIT_STRING_t *gnb_bstring = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));; - gnb_bstring->buf = (uint8_t*)calloc(1,4); - gnb_bstring->size = 4; - gnb_bstring->buf[0] = 0xB5; - gnb_bstring->buf[1] = 0xC6; - gnb_bstring->buf[2] = 0x77; - gnb_bstring->buf[3] = 0x88; - - gnb_bstring->bits_unused = 3; - - uint8_t *buf2 = (uint8_t *)"747"; - OCTET_STRING_t *plmn = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); - plmn->buf = (uint8_t*)calloc(1,3); - memcpy(plmn->buf, buf2, 3); - plmn->size = 3; - - GNB_ID_Choice_t *gnbchoice = (GNB_ID_Choice_t*)calloc(1,sizeof(GNB_ID_Choice_t)); - GNB_ID_Choice_PR pres2 = GNB_ID_Choice_PR_gnb_ID; - gnbchoice->present = pres2; - gnbchoice->choice.gnb_ID = *gnb_bstring; - - GlobalgNB_ID_t *gnb = (GlobalgNB_ID_t*)calloc(1, sizeof(GlobalgNB_ID_t)); - gnb->plmn_id = *plmn; - gnb->gnb_id = *gnbchoice; - - GlobalE2node_gNB_ID_t *e2gnb = (GlobalE2node_gNB_ID_t*)calloc(1, sizeof(GlobalE2node_gNB_ID_t)); - e2gnb->global_gNB_ID = *gnb; - - GlobalE2node_ID_t *globale2nodeid = (GlobalE2node_ID_t*)calloc(1, sizeof(GlobalE2node_ID_t)); - GlobalE2node_ID_PR pres; - pres = GlobalE2node_ID_PR_gNB; - globale2nodeid->present = pres; - globale2nodeid->choice.gNB = e2gnb; - - E2setupRequestIEs_t *e2setuprid = (E2setupRequestIEs_t*)calloc(1, sizeof(E2setupRequestIEs_t)); - E2setupRequestIEs__value_PR pres3; - pres3 = E2setupRequestIEs__value_PR_GlobalE2node_ID; - e2setuprid->id = 3; - e2setuprid->criticality = 0; - e2setuprid->value.choice.GlobalE2node_ID = *globale2nodeid; - e2setuprid->value.present = pres3; - - - auto *ranFlistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t)); - ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, ranFlistIEs); - ranFlistIEs->criticality = 0; - ranFlistIEs->id = ProtocolIE_ID_id_RANfunctionsAdded; - ranFlistIEs->value.present = E2setupRequestIEs__value_PR_RANfunctions_List; - - auto *itemIes = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t)); - itemIes->id = ProtocolIE_ID_id_RANfunction_Item; - itemIes->criticality = Criticality_reject; - itemIes->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item; - itemIes->value.choice.RANfunction_Item.ranFunctionID = 1; - E2SM_KPM_RANfunction_Description_t *ranfunc_desc = - (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t)); - encode_kpm_function_description(ranfunc_desc); - - uint8_t e2smbuffer[8192]; - size_t e2smbuffer_size = 8192; - - asn_codec_ctx_t *opt_cod; - - asn_enc_rval_t er = - asn_encode_to_buffer(opt_cod, - ATS_ALIGNED_BASIC_PER, - &asn_DEF_E2SM_KPM_RANfunction_Description, - ranfunc_desc, e2smbuffer, e2smbuffer_size); - - fprintf(stderr, "er encded is %d\n", er.encoded); - fprintf(stderr, "after encoding message\n"); - - OCTET_STRING_t *ranfuncdesc_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); - ranfuncdesc_str->buf = (uint8_t*)calloc(1,er.encoded); - ranfuncdesc_str->size = er.encoded; - memcpy(ranfuncdesc_str->buf, e2smbuffer, er.encoded); - - - itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *ranfuncdesc_str; - itemIes->value.choice.RANfunction_Item.ranFunctionRevision = (long)2; - - ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes); - - E2setupRequest_t *e2setupreq = (E2setupRequest_t*)calloc(1, sizeof(E2setupRequest_t)); - ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, e2setuprid); - ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, ranFlistIEs); - - InitiatingMessage__value_PR pres4; - pres4 = InitiatingMessage__value_PR_E2setupRequest; - InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t)); - - initmsg->procedureCode = ProcedureCode_id_E2setup; - initmsg->criticality = Criticality_reject; - initmsg->value.present = pres4; - initmsg->value.choice.E2setupRequest = *e2setupreq; - - E2AP_PDU_PR pres5; - pres5 = E2AP_PDU_PR_initiatingMessage; - - - e2ap_pdu->present = pres5; - e2ap_pdu->choice.initiatingMessage = initmsg; - -} -*/ void encoding::generate_e2apv1_setup_response(E2AP_PDU_t *e2ap_pdu) { @@ -479,6 +373,13 @@ void encoding::generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, respricreqid->value.choice.RICrequestID.ricInstanceID = reqInstanceId; + RICsubscriptionResponse_IEs_t *respfuncid = + (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); + respfuncid->id = ProtocolIE_ID_id_RANfunctionID; + respfuncid->criticality = 0; + respfuncid->value.present = RICsubscriptionResponse_IEs__value_PR_RANfunctionID; + respfuncid->value.choice.RANfunctionID = (long)0; + RICsubscriptionResponse_IEs_t *ricactionadmitted = (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); @@ -513,6 +414,7 @@ void encoding::generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t)); ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid); + ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respfuncid); ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionadmitted); @@ -565,6 +467,10 @@ void encoding::generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, printf("error length %d\n", errlen); printf("error buf %s\n", error_buf); + printf("now printing xer of subscription response\n"); + xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu); + printf("done printing xer of subscription response\n"); + } @@ -715,6 +621,8 @@ void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PD asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); printf("error length %d\n", errlen); printf("error buf %s\n", error_buf); + + } @@ -816,7 +724,7 @@ void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_p fprintf(stderr, "after encoding message 4\n"); memcpy(ricind_ies7->value.choice.RICindicationMessage.buf, ind_message_buf, message_length); - fprintf(stderr, "after encoding message 5\n"); + fprintf(stderr, "after encoding message 5\n"); uint8_t *cpid_buf = (uint8_t *)"cpid"; OCTET_STRING_t cpid_str; @@ -866,7 +774,7 @@ void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_p ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7); - // ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); InitiatingMessage__value_PR pres4; @@ -894,181 +802,4 @@ void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_p } -/* -void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { - fprintf(stderr, "ind1\n"); - RICindication_IEs_t *ricind_ies = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies2 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies3 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies4 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies5 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies6 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies7 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies8 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - - RICindication_IEs__value_PR pres3; - - pres3 = RICindication_IEs__value_PR_RICrequestID; - ricind_ies->id = ProtocolIE_ID_id_RICrequestID; - ricind_ies->criticality = 0; - ricind_ies->value.present = pres3; - ricind_ies->value.choice.RICrequestID.ricRequestorID = 25; - ricind_ies->value.choice.RICrequestID.ricInstanceID = 3; - - fprintf(stderr, "ind2\n"); - - pres3 = RICindication_IEs__value_PR_RANfunctionID; - ricind_ies2->id = ProtocolIE_ID_id_RANfunctionID; - ricind_ies2->criticality = 0; - ricind_ies2->value.present = pres3; - ricind_ies2->value.choice.RANfunctionID = 70; - - - ricind_ies3->id = ProtocolIE_ID_id_RICactionID; - ricind_ies3->criticality = 0; - pres3 = RICindication_IEs__value_PR_RICactionID; - ricind_ies3->value.present = pres3; - ricind_ies3->value.choice.RICactionID = 80; - - - pres3 = RICindication_IEs__value_PR_RICindicationSN; - ricind_ies4->id = ProtocolIE_ID_id_RICindicationSN; - ricind_ies4->criticality = 0; - ricind_ies4->value.present = pres3; - ricind_ies4->value.choice.RICindicationSN = 45; - - pres3 = RICindication_IEs__value_PR_RICindicationType; - ricind_ies5->id = ProtocolIE_ID_id_RICindicationType; - ricind_ies5->criticality = 0; - ricind_ies5->value.present = pres3; - ricind_ies5->value.choice.RICindicationType = 0; - - - uint8_t *buf2 = (uint8_t *)"reportheader"; - OCTET_STRING_t *hdr_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); - hdr_str->buf = (uint8_t*)calloc(1,12); - hdr_str->size = 12; - memcpy(hdr_str->buf, buf2, 12); - - fprintf(stderr, "ind3\n"); - - ricind_ies6->value.choice.RICindicationHeader.buf = (uint8_t*)calloc(1,12); - - pres3 = RICindication_IEs__value_PR_RICindicationHeader; - ricind_ies6->id = ProtocolIE_ID_id_RICindicationHeader; - ricind_ies6->criticality = 0; - ricind_ies6->value.present = pres3; - ricind_ies6->value.choice.RICindicationHeader.size = 12; - memcpy(ricind_ies6->value.choice.RICindicationHeader.buf, buf2, 12); - - ricind_ies7->value.choice.RICindicationMessage.buf = (uint8_t*)calloc(1,8192); - - - - E2SM_KPM_RANfunction_Description_t *e2sm_desc = - (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t)); - - encode_kpm_function_description(e2sm_desc); - - - uint8_t e2smbuffer[8192]; - size_t e2smbuffer_size = 8192; - - asn_codec_ctx_t *opt_cod; - - - asn_enc_rval_t er = - asn_encode_to_buffer(opt_cod, - ATS_ALIGNED_BASIC_PER, - &asn_DEF_E2SM_KPM_RANfunction_Description, - e2sm_desc, e2smbuffer, e2smbuffer_size); - - - fprintf(stderr, "er encded is %d\n", er.encoded); - fprintf(stderr, "after encoding message\n"); - - OCTET_STRING_t *msg_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); - msg_str->buf = (uint8_t*)calloc(1,er.encoded); - msg_str->size = er.encoded; - memcpy(msg_str->buf, e2smbuffer, er.encoded); - - - pres3 = RICindication_IEs__value_PR_RICindicationMessage; - ricind_ies7->id = ProtocolIE_ID_id_RICindicationMessage; - fprintf(stderr, "after encoding message 1\n"); - - ricind_ies7->criticality = 0; - ricind_ies7->value.present = pres3; - - fprintf(stderr, "after encoding message 2\n"); - - fprintf(stderr, "after encoding message 3\n"); - ricind_ies7->value.choice.RICindicationMessage.size = er.encoded; - - fprintf(stderr, "after encoding message 4\n"); - memcpy(ricind_ies7->value.choice.RICindicationMessage.buf, e2smbuffer, er.encoded); - - fprintf(stderr, "after encoding message 5\n"); - - uint8_t *buf4 = (uint8_t *)"cpid"; - OCTET_STRING_t cpid_str; - cpid_str.buf = buf4; - cpid_str.size = 4; - - - pres3 = RICindication_IEs__value_PR_RICcallProcessID; - ricind_ies8->id = ProtocolIE_ID_id_RICcallProcessID; - - ricind_ies8->criticality = 0; - ricind_ies8->value.present = pres3; - - ricind_ies8->value.choice.RICcallProcessID = cpid_str; - - - RICindication_t *ricindication = (RICindication_t*)calloc(1, sizeof(RICindication_t)); - - - int ret; -*/ - /* - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies2); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies3); - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies4); - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies5); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies6); - */ -/* - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); - - - InitiatingMessage__value_PR pres4; - pres4 = InitiatingMessage__value_PR_RICindication; - InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t)); - initmsg->procedureCode = 5; - initmsg->criticality = 1; - initmsg->value.present = pres4; - initmsg->value.choice.RICindication = *ricindication; - - E2AP_PDU_PR pres5; - pres5 = E2AP_PDU_PR_initiatingMessage; - - e2ap_pdu->present = pres5; - e2ap_pdu->choice.initiatingMessage = initmsg; - - char *error_buf = (char*)calloc(300, sizeof(char));; - size_t errlen; - - asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); - printf("error length %d\n", errlen); - printf("error buf %s\n", error_buf); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu); -} -*/ diff --git a/e2sim/src/messagerouting/e2ap_message_handler.cpp b/e2sim/src/messagerouting/e2ap_message_handler.cpp index 3e8da63..0e23c8d 100644 --- a/e2sim/src/messagerouting/e2ap_message_handler.cpp +++ b/e2sim/src/messagerouting/e2ap_message_handler.cpp @@ -115,8 +115,23 @@ void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc, E2S LOG_I("[E2AP] Received RIC-SUBSCRIPTION-REQUEST"); // e2ap_handle_RICSubscriptionRequest(pdu, socket_fd); long func_id = encoding::get_function_id_from_subscription(pdu); - SubscriptionCallback cb = e2sim->get_subscription_callback(func_id); - cb(pdu); + fprintf(stderr, "Function Id of message is %d\n", func_id); + SubscriptionCallback cb; + + bool func_exists = true; + + try { + cb = e2sim->get_subscription_callback(func_id); + } catch(const std::out_of_range& e) { + func_exists = false; + } + + if (func_exists) { + fprintf(stderr, "Calling callback function\n"); + cb(pdu); + } else { + fprintf(stderr, "Error: No RAN Function with this ID exists\n"); + } // callback_kpm_subscription_request(pdu, socket_fd); } -- 2.16.6