SIM-119: Update value of MeasurementTypeName and MeasurementTypeID to constraint 35/12935/1 master
authorTuan Nguyen <hoang.su.tk@gmail.com>
Mon, 3 Jun 2024 10:59:49 +0000 (10:59 +0000)
committerTuan Nguyen <hoang.su.tk@gmail.com>
Mon, 3 Jun 2024 10:59:49 +0000 (10:59 +0000)
Change-Id: I72fce472e941571b5e8ad2256051ce1257d58a61
Signed-off-by: Tuan Nguyen <hoang.su.tk@gmail.com>
e2sim/Dockerfile_kpm
e2sim/e2sm_examples/kpm_e2sm/e2sim-dev_1.0.0_amd64.deb [deleted file]
e2sim/e2sm_examples/kpm_e2sm/e2sim_1.0.0_amd64.deb [deleted file]
e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp
e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp
e2sim/src/DEF/e2sim_defs.h
e2sim/src/base/e2sim.cpp
e2sim/src/encoding/encode_e2apv1.cpp
e2sim/src/messagerouting/e2ap_asn1c_codec.c
e2sim/src/messagerouting/e2ap_message_handler.cpp

index a5ddfa7..63a77b0 100755 (executable)
 # the builder has: git, wget, cmake, gcc/g++, make, python2/3. v7 dropped nng support
 #
 ARG CONTAINER_PULL_REGISTRY=nexus3.o-ran-sc.org:10001
 # the builder has: git, wget, cmake, gcc/g++, make, python2/3. v7 dropped nng support
 #
 ARG CONTAINER_PULL_REGISTRY=nexus3.o-ran-sc.org:10001
-FROM ${CONTAINER_PULL_REGISTRY}/o-ran-sc/bldr-ubuntu18-c-go:1.9.0 as buildenv
+FROM ${CONTAINER_PULL_REGISTRY}/o-ran-sc/bldr-ubuntu22-c-go:1.0.0 as buildenv
 
 # spaces to save things in the build image to copy to final image
 
 # spaces to save things in the build image to copy to final image
-RUN mkdir -p /playpen/assets /playpen/src /playpen/bin /playpen/asn1c
+RUN mkdir -p /playpen/assets /playpen/src /playpen/bin /playpen/asn1c /playpen/e2sim
 ARG SRC=.
 
 WORKDIR /playpen
 ARG SRC=.
 
 WORKDIR /playpen
@@ -65,10 +65,16 @@ RUN apt-get update \
        nmap \
   && apt-get clean
 
        nmap \
   && apt-get clean
 
-COPY e2sm_examples/kpm_e2sm/e2sim_1.0.0_amd64.deb /playpen
-COPY e2sm_examples/kpm_e2sm/e2sim-dev_1.0.0_amd64.deb /playpen
+COPY asn1c/ /playpen/e2sim/asn1c
+COPY e2sm_examples/ /playpen/e2sim/e2sm_examples
+COPY src/ /playpen/e2sim/src
+COPY CMakeLists.txt /playpen/e2sim
 
 
-RUN dpkg -i e2sim_1.0.0_amd64.deb e2sim-dev_1.0.0_amd64.deb
+RUN mkdir /playpen/e2sim/build && cd /playpen/e2sim/build && cmake .. && make package && cmake .. -DDEV_PKG=1 && make package
+
+RUN dpkg -i /playpen/e2sim/build/e2sim_1.0.0_amd64.deb /playpen/e2sim/build/e2sim-dev_1.0.0_amd64.deb
+
+RUN rm -rf /playpen/e2sim
 
 RUN mkdir /usr/local/include/nlohmann
 RUN git clone https://github.com/azadkuh/nlohmann_json_release.git
 
 RUN mkdir /usr/local/include/nlohmann
 RUN git clone https://github.com/azadkuh/nlohmann_json_release.git
@@ -85,4 +91,4 @@ RUN wc -l /playpen/src/reports.json
                make install
 
 #CMD sleep 100000000000
                make install
 
 #CMD sleep 100000000000
-#CMD kpm_sim 10.111.138.172 36422
+#CMD kpm_sim 10.111.138.172 32222
diff --git a/e2sim/e2sm_examples/kpm_e2sm/e2sim-dev_1.0.0_amd64.deb b/e2sim/e2sm_examples/kpm_e2sm/e2sim-dev_1.0.0_amd64.deb
deleted file mode 100755 (executable)
index 7abedad..0000000
Binary files a/e2sim/e2sm_examples/kpm_e2sm/e2sim-dev_1.0.0_amd64.deb and /dev/null differ
diff --git a/e2sim/e2sm_examples/kpm_e2sm/e2sim_1.0.0_amd64.deb b/e2sim/e2sm_examples/kpm_e2sm/e2sim_1.0.0_amd64.deb
deleted file mode 100755 (executable)
index 7dda0da..0000000
Binary files a/e2sim/e2sm_examples/kpm_e2sm/e2sim_1.0.0_amd64.deb and /dev/null differ
index 8bfe7c6..7ab086c 100755 (executable)
 #include "e2sim_defs.h"
 using namespace std;
 
 #include "e2sim_defs.h"
 using namespace std;
 
+const char* performance_measurements[] = {
+  "DRB.RlcSduTransmittedVolumeDL",
+  "DRB.RlcSduTransmittedVolumeUL",
+  "DRB.PerDataVolumeDLDist.Bin",
+  "DRB.PerDataVolumeULDist.Bin",
+  "DRB.RlcPacketDropRateDLDist",
+  "DRB.PacketLossRateULDist",
+  "L1M.DL-SS-RSRP.SSB",
+  "L1M.DL-SS-SINR.SSB",
+  "L1M.UL-SRS-RSRP"
+  };
+
+int NUMBER_MEASUREMENTS = 9;
+
 void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc_desc) {
   uint8_t* short_name = (uint8_t*)"ORAN-E2SM-KPM";
   uint8_t* func_desc = (uint8_t*)"KPM Monitor";
   uint8_t* e2sm_odi = (uint8_t*)"OID123";
 
   LOG_I("short_name: %s, func_desc: %s, e2sm_odi: %s", short_name, func_desc, e2sm_odi);
 void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc_desc) {
   uint8_t* short_name = (uint8_t*)"ORAN-E2SM-KPM";
   uint8_t* func_desc = (uint8_t*)"KPM Monitor";
   uint8_t* e2sm_odi = (uint8_t*)"OID123";
 
   LOG_I("short_name: %s, func_desc: %s, e2sm_odi: %s", short_name, func_desc, e2sm_odi);
-
-  long inst = 1;
-
   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc);
 
   ranfunc_desc->ranFunction_Name.ranFunction_ShortName.size = strlen((char*)short_name);
   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc);
 
   ranfunc_desc->ranFunction_Name.ranFunction_ShortName.size = strlen((char*)short_name);
@@ -49,7 +60,8 @@ void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc
   memcpy(ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, func_desc,
          strlen((char*)func_desc));
   ranfunc_desc->ranFunction_Name.ranFunction_Description.size = strlen((char*)func_desc);
   memcpy(ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, func_desc,
          strlen((char*)func_desc));
   ranfunc_desc->ranFunction_Name.ranFunction_Description.size = strlen((char*)func_desc);
-  ranfunc_desc->ranFunction_Name.ranFunction_Instance = &inst;
+  ranfunc_desc->ranFunction_Name.ranFunction_Instance = (long *)calloc(1, sizeof(long));
+  *ranfunc_desc->ranFunction_Name.ranFunction_Instance = 1;
 
   ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf =
       (uint8_t*)calloc(1, strlen((char*)e2sm_odi));
 
   ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf =
       (uint8_t*)calloc(1, strlen((char*)e2sm_odi));
@@ -66,7 +78,7 @@ void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc
   trigger_style->ric_EventTriggerStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)style_name));
   memcpy(trigger_style->ric_EventTriggerStyle_Name.buf, style_name, strlen((char*)style_name));
   trigger_style->ric_EventTriggerStyle_Name.size = strlen((char*)style_name);
   trigger_style->ric_EventTriggerStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)style_name));
   memcpy(trigger_style->ric_EventTriggerStyle_Name.buf, style_name, strlen((char*)style_name));
   trigger_style->ric_EventTriggerStyle_Name.size = strlen((char*)style_name);
-  trigger_style->ric_EventTriggerFormat_Type = 5;
+  trigger_style->ric_EventTriggerFormat_Type = 1;
 
   ranfunc_desc->ric_EventTriggerStyle_List =
       (E2SM_KPM_RANfunction_Description::
 
   ranfunc_desc->ric_EventTriggerStyle_List =
       (E2SM_KPM_RANfunction_Description::
@@ -80,10 +92,9 @@ void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc
 
   MeasurementInfo_Action_List_t* measInfo_Action_List =
       (MeasurementInfo_Action_List_t*)calloc(1, sizeof(MeasurementInfo_Action_List_t));
 
   MeasurementInfo_Action_List_t* measInfo_Action_List =
       (MeasurementInfo_Action_List_t*)calloc(1, sizeof(MeasurementInfo_Action_List_t));
-  uint8_t* measured_metrics[] = {(uint8_t*)"CQI", (uint8_t*)"RSRP", (uint8_t*)"RSRQ"};
 
 
-  for (int i = 0; i < 3; i++) {
-    uint8_t* metrics = measured_metrics[i];
+  for (int i = 0; i < NUMBER_MEASUREMENTS; i++) {
+    uint8_t* metrics = (uint8_t *)performance_measurements[i];
     MeasurementInfo_Action_Item_t* measItem =
         (MeasurementInfo_Action_Item_t*)calloc(1, sizeof(MeasurementInfo_Action_Item_t));
     measItem->measName.buf = (uint8_t*)calloc(1, strlen((char*)metrics));
     MeasurementInfo_Action_Item_t* measItem =
         (MeasurementInfo_Action_Item_t*)calloc(1, sizeof(MeasurementInfo_Action_Item_t));
     measItem->measName.buf = (uint8_t*)calloc(1, strlen((char*)metrics));
@@ -92,7 +103,7 @@ void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc
     measItem->measName.size = strlen((char*)metrics);
 
     measItem->measID = (MeasurementTypeID_t*)calloc(1, sizeof(MeasurementTypeID_t));
     measItem->measName.size = strlen((char*)metrics);
 
     measItem->measID = (MeasurementTypeID_t*)calloc(1, sizeof(MeasurementTypeID_t));
-    *measItem->measID = i;
+    *measItem->measID = i+1;
 
     ASN_SEQUENCE_ADD(&measInfo_Action_List->list, measItem);
   }
 
     ASN_SEQUENCE_ADD(&measInfo_Action_List->list, measItem);
   }
@@ -218,90 +229,67 @@ void kpm_report_indication_header_initialized(E2SM_KPM_IndicationHeader_t* ihead
   ind_header->colletStartTime = *ts;
   if (ts) free(ts);
 
   ind_header->colletStartTime = *ts;
   if (ts) free(ts);
 
-  uint8_t* buf5 = (uint8_t*)"1.0";
-  ind_header->fileFormatversion = (PrintableString_t*)calloc(1, sizeof(PrintableString_t));
-  ind_header->fileFormatversion->buf = (uint8_t*)calloc(1, strlen((char*)buf5));
-  memcpy(ind_header->fileFormatversion->buf, buf5, strlen((char*)buf5));
-  ind_header->fileFormatversion->size = strlen((char*)buf5);
-
   ihead->indicationHeader_formats.present =
       E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_indicationHeader_Format1;
   ihead->indicationHeader_formats.choice.indicationHeader_Format1 = ind_header;
 
   ihead->indicationHeader_formats.present =
       E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_indicationHeader_Format1;
   ihead->indicationHeader_formats.choice.indicationHeader_Format1 = ind_header;
 
-  // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationHeader, ihead);
 }
 
 void ue_meas_kpm_report_indication_message_initialized(
     E2SM_KPM_IndicationMessage_t* indicationmessage, uint8_t* nrcellid_buf, uint8_t* crnti_buf,
     const uint8_t* serving_buf, const uint8_t* neighbor_buf) {
 }
 
 void ue_meas_kpm_report_indication_message_initialized(
     E2SM_KPM_IndicationMessage_t* indicationmessage, uint8_t* nrcellid_buf, uint8_t* crnti_buf,
     const uint8_t* serving_buf, const uint8_t* neighbor_buf) {
-  GranularityPeriod_t period = 1;
-  MeasurementData_t* measData = (MeasurementData_t*)calloc(1, sizeof(MeasurementData_t));
-  MeasurementDataItem_t* measDataItem =
-      (MeasurementDataItem_t*)calloc(1, sizeof(MeasurementDataItem_t));
-  MeasurementRecord_t* measDataItem_record =
-      (MeasurementRecord_t*)calloc(1, sizeof(MeasurementRecord_t));
-  MeasurementRecordItem_t* measDataRecordItem =
-      (MeasurementRecordItem_t*)calloc(1, sizeof(MeasurementRecordItem_t));
-
-  unsigned long val = 1;
-  measDataRecordItem->present = MeasurementRecordItem_PR_integer;
-  measDataRecordItem->choice.integer = val;
-
-  ASN_SEQUENCE_ADD(&measDataItem_record->list, measDataRecordItem);
+  
+  MeasurementRecord_t* measDataItem_record = (MeasurementRecord_t*)calloc(1, sizeof(MeasurementRecord_t));
+  for (size_t i = 0; i < NUMBER_MEASUREMENTS; i++)
+  {
+    MeasurementRecordItem_t* measDataRecordItem = (MeasurementRecordItem_t*)calloc(1, sizeof(MeasurementRecordItem_t));
+    measDataRecordItem->present = MeasurementRecordItem_PR_integer;
+    measDataRecordItem->choice.integer = 1;
+
+    ASN_SEQUENCE_ADD(&measDataItem_record->list, measDataRecordItem);
+  }
 
 
+  MeasurementDataItem_t* measDataItem = (MeasurementDataItem_t*)calloc(1, sizeof(MeasurementDataItem_t));
   measDataItem->measRecord = *measDataItem_record;
   measDataItem->measRecord = *measDataItem_record;
-  long incomplete = 0;
   measDataItem->incompleteFlag = (long*)calloc(1, sizeof(long));
   measDataItem->incompleteFlag = (long*)calloc(1, sizeof(long));
-  *measDataItem->incompleteFlag = incomplete;
+  *measDataItem->incompleteFlag = 0;
+
+  MeasurementData_t* measData = (MeasurementData_t*)calloc(1, sizeof(MeasurementData_t));
   ASN_SEQUENCE_ADD(&measData->list, measDataItem);
 
   ASN_SEQUENCE_ADD(&measData->list, measDataItem);
 
+  MeasurementInfoList_t* measList = (MeasurementInfoList_t*)calloc(1, sizeof(MeasurementInfoList_t));
+  for (size_t i = 0; i < NUMBER_MEASUREMENTS; i++)
+  {
+    MeasurementLabel_t* measLabel = (MeasurementLabel_t*)calloc(1, sizeof(MeasurementLabel_t));
+    measLabel->noLabel = (long *)calloc(1, sizeof(long));
+    *measLabel->noLabel = 0;
+
+    LabelInfoItem_t* labelItem = (LabelInfoItem_t*)calloc(1, sizeof(LabelInfoItem_t));
+    labelItem->measLabel = *measLabel;
+
+    LabelInfoList_t* labelList = (LabelInfoList_t*)calloc(1, sizeof(LabelInfoList_t));
+    ASN_SEQUENCE_ADD(&labelList->list, labelItem);
+
+    MeasurementType_t measType;
+    measType.present = MeasurementType_PR_measID;
+    uint8_t* metrics = (uint8_t *)performance_measurements[i];
+    measType.choice.measName.buf = (uint8_t*)calloc(1, strlen((char*)metrics));
+    memcpy(measType.choice.measName.buf, metrics, strlen((char*)metrics));
+    measType.choice.measName.size = strlen((char*)metrics);
+
+    MeasurementInfoItem_t* measItem = (MeasurementInfoItem_t*)calloc(1, sizeof(MeasurementInfoItem_t));
+    measItem->measType = measType;
+    measItem->labelInfoList = *labelList;
+    if (labelList) free(labelList);
+    
+    ASN_SEQUENCE_ADD(&measList->list, measItem);
+  }
+  
   E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
       1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
   format->granulPeriod = (GranularityPeriod_t*)calloc(1, sizeof(GranularityPeriod_t));
   E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
       1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
   format->granulPeriod = (GranularityPeriod_t*)calloc(1, sizeof(GranularityPeriod_t));
-  *format->granulPeriod = period;
+  *format->granulPeriod = 1;
   format->measData = *measData;
   format->measData = *measData;
-
-  MeasurementInfoList_t* measList =
-      (MeasurementInfoList_t*)calloc(1, sizeof(MeasurementInfoList_t));
-  MeasurementInfoItem_t* measItem =
-      (MeasurementInfoItem_t*)calloc(1, sizeof(MeasurementInfoItem_t));
-  LabelInfoList_t* labelList = (LabelInfoList_t*)calloc(1, sizeof(LabelInfoList_t));
-  LabelInfoItem_t* labelItem = (LabelInfoItem_t*)calloc(1, sizeof(LabelInfoItem_t));
-  MeasurementLabel_t* measLabel = (MeasurementLabel_t*)calloc(1, sizeof(MeasurementLabel_t));
-
-  uint8_t* plmnid_buf = (uint8_t*)"747";
-  uint8_t* sst_buf = (uint8_t*)"1";
-  uint8_t* sd_buf = (uint8_t*)"100";
-
-  S_NSSAI_t* snssai = (S_NSSAI_t*)calloc(1, sizeof(S_NSSAI_t));
-  snssai->sST.buf = (uint8_t*)calloc(strlen((char*)sst_buf), sizeof(uint8_t));
-  snssai->sST.size = strlen((char*)sst_buf);
-  memcpy(snssai->sST.buf, sst_buf, strlen((char*)sst_buf));
-
-  snssai->sD = (SD_t*)calloc(1, sizeof(SD_t));
-  snssai->sD->buf = (uint8_t*)calloc(strlen((char*)sd_buf), sizeof(uint8_t));
-  snssai->sD->size = strlen((char*)sd_buf);
-  memcpy(snssai->sD->buf, sd_buf, strlen((char*)sd_buf));
-
-  int plmnid_size = strlen((char*)plmnid_buf);
-  PLMNIdentity_t* plmnidstr = (PLMNIdentity_t*)calloc(1, sizeof(PLMNIdentity_t));
-  plmnidstr->buf = (uint8_t*)calloc(plmnid_size, 1);
-  plmnidstr->size = plmnid_size;
-  memcpy(plmnidstr->buf, plmnid_buf, plmnidstr->size);
-
-  measLabel->plmnID = plmnidstr;
-  measLabel->sliceID = snssai;
-
-  labelItem->measLabel = *measLabel;
-  ASN_SEQUENCE_ADD(&labelList->list, labelItem);
-  measItem->labelInfoList = *labelList;
-  if (labelList) free(labelList);
-  MeasurementType_t measType;
-  measType.present = MeasurementType_PR_measID;
-  measType.choice.measID = 1;
-  measItem->measType = measType;
-  ASN_SEQUENCE_ADD(&measList->list, measItem);
-
   format->measInfoList = measList;
 
   E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
   format->measInfoList = measList;
 
   E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
@@ -320,6 +308,7 @@ void ue_meas_kpm_report_indication_message_initialized(
 
   if (ret) {
     LOG_I("Constraint validation of indication message failed: %s", error_buf);
 
   if (ret) {
     LOG_I("Constraint validation of indication message failed: %s", error_buf);
+    exit(1);
   }
 
   // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
   }
 
   // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
@@ -416,8 +405,8 @@ void cell_meas_kpm_report_indication_message_style_1_initialized(
 
   if (ret) {
     LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
 
   if (ret) {
     LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
+    exit(1);
   }
   }
-  // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
 }
 
 void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) {
 }
 
 void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) {
@@ -466,6 +455,7 @@ void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) {
 
   if (ret) {
     LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
 
   if (ret) {
     LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
+    exit(1);
   }
 
   uint8_t e2smbuffer[8192] = {
   }
 
   uint8_t e2smbuffer[8192] = {
@@ -478,9 +468,11 @@ void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) {
                            indicationmessage, e2smbuffer, e2smbuffer_size);
 
   if (er.encoded == -1) {
                            indicationmessage, e2smbuffer, e2smbuffer_size);
 
   if (er.encoded == -1) {
-    LOG_I("Failed to serialize message. Detail: %s.\n", asn_DEF_E2SM_KPM_IndicationMessage.name);
+    LOG_E("Failed to serialize message. Detail: %s.\n", asn_DEF_E2SM_KPM_IndicationMessage.name);
+    exit(1);
   } else if (er.encoded > e2smbuffer_size) {
   } else if (er.encoded > e2smbuffer_size) {
-    LOG_I("Buffer of size %zu is too small for %s, need %zu\n", e2smbuffer_size, asn_DEF_E2SM_KPM_IndicationMessage.name, er.encoded);
+    LOG_E("Buffer of size %zu is too small for %s, need %zu\n", e2smbuffer_size, asn_DEF_E2SM_KPM_IndicationMessage.name, er.encoded);
+    exit(1);
   }
 }
 
   }
 }
 
index 59bd744..2c94856 100755 (executable)
@@ -50,11 +50,13 @@ extern "C" {
 #include "viavi_connector.hpp"
 #include "errno.h"
 #include "e2sim_defs.h"
 #include "viavi_connector.hpp"
 #include "errno.h"
 #include "e2sim_defs.h"
+#include <cstdlib>
+
 using json = nlohmann::json;
 
 using namespace std;
 class E2Sim;
 using json = nlohmann::json;
 
 using namespace std;
 class E2Sim;
-
+int gFuncId;
 
 E2Sim e2sim;
 
 
 E2Sim e2sim;
 
@@ -97,10 +99,12 @@ int main(int argc, char* argv[]) {
   ranfunc_ostr->buf = (uint8_t*)calloc(1,er.encoded);
   ranfunc_ostr->size = er.encoded;
   memcpy(ranfunc_ostr->buf,e2smbuffer,er.encoded);
   ranfunc_ostr->buf = (uint8_t*)calloc(1,er.encoded);
   ranfunc_ostr->size = er.encoded;
   memcpy(ranfunc_ostr->buf,e2smbuffer,er.encoded);
-  e2sim.register_e2sm(0,ranfunc_ostr);
-  e2sim.register_subscription_callback(0,&callback_kpm_subscription_request);
 
 
+  const char* func_id_str = std::getenv("RAN_FUNC_ID");
+  ::gFuncId = func_id_str == nullptr ? 0 : std::stoi(func_id_str);
+
+  e2sim.register_e2sm(gFuncId, ranfunc_ostr);
+  e2sim.register_subscription_callback(gFuncId, &callback_kpm_subscription_request);
   e2sim.run_loop(argc, argv);
 
 }
   e2sim.run_loop(argc, argv);
 
 }
@@ -337,7 +341,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long
                                LOG_I("Buffer of size %zu is too small for %s, need %zu\n", e2sm_message_buf_size_cucp_ue, asn_DEF_E2SM_KPM_IndicationMessage.name, er_message_cucp_ue.encoded);
                                exit(1);
                        } else {
                                LOG_I("Buffer of size %zu is too small for %s, need %zu\n", e2sm_message_buf_size_cucp_ue, asn_DEF_E2SM_KPM_IndicationMessage.name, er_message_cucp_ue.encoded);
                                exit(1);
                        } else {
-                               LOG_I("Encoded UE indication message succesfully, size in bytes: %d", er_message_cucp_ue.encoded)
+                               LOG_I("Encoded UE indication message succesfully, size in bytes: %zu", er_message_cucp_ue.encoded)
                        }
 
                        ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_cucp_ue); 
                        }
 
                        ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_cucp_ue); 
@@ -362,7 +366,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long
                                LOG_I("Buffer of size %zu is too small for %s, need %zu\n", e2sm_header_buf_size_cucp_ue, asn_DEF_E2SM_KPM_IndicationHeader.name, er_header_cucp_ue.encoded);
                                exit(1);
                        } else {
                                LOG_I("Buffer of size %zu is too small for %s, need %zu\n", e2sm_header_buf_size_cucp_ue, asn_DEF_E2SM_KPM_IndicationHeader.name, er_header_cucp_ue.encoded);
                                exit(1);
                        } else {
-                               LOG_I("Encoded UE indication header succesfully, size in bytes: %d", er_header_cucp_ue.encoded);
+                               LOG_I("Encoded UE indication header succesfully, size in bytes: %zu", er_header_cucp_ue.encoded);
                                for(int i = 0; i < er_header_cucp_ue.encoded; i ++) {
                                        printf("%x ", e2sm_header_buf_cucp_ue[i]);
                                }
                                for(int i = 0; i < er_header_cucp_ue.encoded; i ++) {
                                        printf("%x ", e2sm_header_buf_cucp_ue[i]);
                                }
@@ -381,7 +385,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long
                                                                                        er_message_cucp_ue.encoded);
                        
                        e2sim.encode_and_send_sctp_data(pdu_cucp_ue);
                                                                                        er_message_cucp_ue.encoded);
                        
                        e2sim.encode_and_send_sctp_data(pdu_cucp_ue);
-                       LOG_I("Measurement report for UE %d has been sent\n", i);
+                       LOG_I("Measurement report for UE %d has been sent", i);
                        seqNum++;
                        std::this_thread::sleep_for (std::chrono::milliseconds(50));
                }
                        seqNum++;
                        std::this_thread::sleep_for (std::chrono::milliseconds(50));
                }
@@ -473,13 +477,13 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long
                                                                                e2sm_message_buf_style1, e2sm_message_buf_size_style1);
                        
                        if(er_message_style1.encoded == -1) {
                                                                                e2sm_message_buf_style1, e2sm_message_buf_size_style1);
                        
                        if(er_message_style1.encoded == -1) {
-                               LOG_I("Failed to serialize data. Detail: %s.\n", asn_DEF_E2SM_KPM_IndicationMessage.name);
+                               LOG_I("Failed to serialize data. Detail: %s.", asn_DEF_E2SM_KPM_IndicationMessage.name);
                                exit(1);
                        } else if(er_message_style1.encoded > e2sm_message_buf_size_style1) {
                                LOG_I("Buffer of size %zu is too small for %s, need %zu\n", e2sm_message_buf_size_style1, asn_DEF_E2SM_KPM_IndicationMessage.name, er_message_style1.encoded);
                                exit(1);
                        } else {
                                exit(1);
                        } else if(er_message_style1.encoded > e2sm_message_buf_size_style1) {
                                LOG_I("Buffer of size %zu is too small for %s, need %zu\n", e2sm_message_buf_size_style1, asn_DEF_E2SM_KPM_IndicationMessage.name, er_message_style1.encoded);
                                exit(1);
                        } else {
-                               LOG_I("Encoded Cell indication message succesfully, size in bytes: %d", er_message_style1.encoded)
+                               LOG_I("Encoded Cell indication message succesfully, size in bytes: %ld", er_message_style1.encoded)
                        }
 
                        ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_message_style1);
                        }
 
                        ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_message_style1);
@@ -531,8 +535,6 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long
 
 void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) {
 
 
 void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) {
 
-  fprintf(stderr, "[%s:%d]Calling callback_kpm_subscription_request");
-
   //Record RIC Request ID
   //Go through RIC action to be Setup List
   //Find first entry with REPORT action Type
   //Record RIC Request ID
   //Go through RIC action to be Setup List
   //Find first entry with REPORT action Type
@@ -563,79 +565,70 @@ void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) {
     RICsubscriptionRequest_IEs_t *next_ie = ies[i];
     pres = next_ie->value.present;
     
     RICsubscriptionRequest_IEs_t *next_ie = ies[i];
     pres = next_ie->value.present;
     
-    LOG_I("The next present value %d\n", pres);
+    LOG_I("The next present value %d", pres);
 
     switch(pres) {
 
     switch(pres) {
-    case RICsubscriptionRequest_IEs__value_PR_RICrequestID:
-      {
-       LOG_I("in case request id");    
-       RICrequestID_t reqId = next_ie->value.choice.RICrequestID;
-       long requestorId = reqId.ricRequestorID;
-       long instanceId = reqId.ricInstanceID;
-       LOG_I("requestorId %d\n", requestorId);
-       LOG_I("instanceId %d\n", instanceId);
-       reqRequestorId = requestorId;
-       reqInstanceId = instanceId;
-
-       break;
-      }
-    case RICsubscriptionRequest_IEs__value_PR_RANfunctionID:
-      {
-       LOG_I("in case ran func id");   
-       break;
-      }
-    case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails:
-      {
-       RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails;
-       RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition;
-       RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List;
-       //We are ignoring the trigger definition
-
-       //We identify the first action whose type is REPORT
-       //That is the only one accepted; all others are rejected
-       
-       int actionCount = actionList.list.count;
-       LOG_I("Action count%d\n", actionCount);
+               case RICsubscriptionRequest_IEs__value_PR_RICrequestID: {
+                       LOG_I("in case request id");
+                       RICrequestID_t reqId = next_ie->value.choice.RICrequestID;
+                       long requestorId = reqId.ricRequestorID;
+                       long instanceId = reqId.ricInstanceID;
 
 
-       auto **item_array = actionList.list.array;
+                       LOG_I("requestorId: %ld, InstanceID: %ld", requestorId, instanceId);
 
 
-       bool foundAction = false;
+                       reqRequestorId = requestorId;
+                       reqInstanceId = instanceId;
 
 
-       for (int i=0; i < actionCount; i++) {
+                       break;
+               }
+               case RICsubscriptionRequest_IEs__value_PR_RANfunctionID: {
+                       LOG_I("in case ran func id");
+                       break;
+               }
+               case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails: {
+                       RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails;
+                       RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition;
+                       RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List;
+                       //We are ignoring the trigger definition
 
 
-         auto *next_item = item_array[i];
-         RICactionID_t actionId = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionID;
-         RICactionType_t actionType = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionType;
+                       //We identify the first action whose type is REPORT
+                       //That is the only one accepted; all others are rejected
 
 
-         if (!foundAction && actionType == RICactionType_report) {
-           reqActionId = actionId;
-           actionIdsAccept.push_back(reqActionId);
-           foundAction = true;
-         } else {
-           reqActionId = actionId;
-           actionIdsReject.push_back(reqActionId);
-         }
-       }
-       
-       break;
-      }
-    default:
-      {
-       break;
-      }      
+                       int actionCount = actionList.list.count;
+                       LOG_I("Action count%d", actionCount);
+
+                       auto **item_array = actionList.list.array;
+
+                       bool foundAction = false;
+
+                       for (int i=0; i < actionCount; i++) {
+                               auto *next_item = item_array[i];
+                               RICactionID_t actionId = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionID;
+                               RICactionType_t actionType = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionType;
+
+                               if (!foundAction && actionType == RICactionType_report) {
+                                       reqActionId = actionId;
+                                       actionIdsAccept.push_back(reqActionId);
+                                       foundAction = true;
+                               } else {
+                                       reqActionId = actionId;
+                                       actionIdsReject.push_back(reqActionId);
+                               }
+                       }
+
+                       break;
+               }
+               default: {
+                       break;
+               }
     }
     
   }
 
   LOG_I("After Processing Subscription Request");
 
     }
     
   }
 
   LOG_I("After Processing Subscription Request");
 
-  LOG_I("requestorId %d\n", reqRequestorId);
-  LOG_I("instanceId %d\n", reqInstanceId);
-
-
   for (int i=0; i < actionIdsAccept.size(); i++) {
   for (int i=0; i < actionIdsAccept.size(); i++) {
-    LOG_I("Action ID %d %ld\n", i, actionIdsAccept.at(i));
-    
+    LOG_D("Action ID %d %ld\n", i, actionIdsAccept.at(i));
   }
 
   E2AP_PDU *e2ap_pdu = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
   }
 
   E2AP_PDU *e2ap_pdu = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
@@ -650,8 +643,7 @@ void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu) {
   LOG_I("Encode and sending E2AP subscription success response via SCTP");
   e2sim.encode_and_send_sctp_data(e2ap_pdu);
 
   LOG_I("Encode and sending E2AP subscription success response via SCTP");
   e2sim.encode_and_send_sctp_data(e2ap_pdu);
 
-  long funcId = 0;
-
-  run_report_loop(reqRequestorId, reqInstanceId, funcId, reqActionId);
+  LOG_I("Now generating data for subscription request");
+  run_report_loop(reqRequestorId, reqInstanceId, gFuncId, reqActionId);
 
 }
 
 }
index f10cebf..dc469ba 100755 (executable)
@@ -49,12 +49,40 @@ char* time_stamp(void);
         else { \
             fileName = file; \
         } \
         else { \
             fileName = file; \
         } \
-        printf("[%s:%d] ", fileName, __LINE__); \
-        printf(format, ##__VA_ARGS__); \
-        printf("\n"); \
+        fprintf(stderr, "[%s:%d] [INFO] ", fileName, __LINE__); \
+        fprintf(stderr, format, ##__VA_ARGS__); \
+        fprintf(stderr, "\n"); \
+    } while (0);
+
+#define LOG_D(format, ...) \
+    do { \
+        const char *file = __FILE__; \
+        const char *fileName = strrchr(file, '/'); \
+        if (fileName != NULL) { \
+            fileName++; \
+        } \
+        else { \
+            fileName = file; \
+        } \
+        fprintf(stderr, "[%s:%d] [DEBUG] ", fileName, __LINE__); \
+        fprintf(stderr, format, ##__VA_ARGS__); \
+        fprintf(stderr, "\n"); \
+    } while (0);
+
+#define LOG_E(format, ...) \
+    do { \
+        const char *file = __FILE__; \
+        const char *fileName = strrchr(file, '/'); \
+        if (fileName != NULL) { \
+            fileName++; \
+        } \
+        else { \
+            fileName = file; \
+        } \
+        fprintf(stderr, "[%s:%d] [ERROR] ", fileName, __LINE__); \
+        fprintf(stderr, format, ##__VA_ARGS__); \
+        fprintf(stderr, "\n"); \
     } while (0);
     } while (0);
-#define LOG_E(...) {printf(__VA_ARGS__); printf("\n");}
-#define LOG_D(...) {printf(__VA_ARGS__); printf("\n");}
 
 typedef struct SCTP_DATA {
   unsigned char *data;
 
 typedef struct SCTP_DATA {
   unsigned char *data;
@@ -74,6 +102,4 @@ typedef struct {
 
 options_t read_input_options(int argc, char *argv[]);
 
 
 options_t read_input_options(int argc, char *argv[]);
 
-#define min(a, b) ((a) < (b)) ? (a) : (b)
-
 #endif
 #endif
index 9c3ec42..6203171 100755 (executable)
@@ -40,13 +40,13 @@ std::unordered_map<long, OCTET_STRING_t*> E2Sim::getRegistered_ran_functions() {
 }
 
 void E2Sim::register_subscription_callback(long func_id, SubscriptionCallback cb) {
 }
 
 void E2Sim::register_subscription_callback(long func_id, SubscriptionCallback cb) {
-  fprintf(stderr,"%%%%about to register callback for subscription for func_id %d\n", func_id);
+  LOG_I("About to register callback for subscription for RAN function with ID %d", func_id);
   subscription_callbacks[func_id] = cb;
   
 }
 
 SubscriptionCallback E2Sim::get_subscription_callback(long func_id) {
   subscription_callbacks[func_id] = cb;
   
 }
 
 SubscriptionCallback E2Sim::get_subscription_callback(long func_id) {
-  fprintf(stderr, "%%%%we are getting the subscription callback for func id %d\n", func_id);
+  LOG_I("We are getting the subscription callback for func id %d", func_id);
   SubscriptionCallback cb;
 
   try {
   SubscriptionCallback cb;
 
   try {
@@ -62,14 +62,10 @@ void E2Sim::register_e2sm(long func_id, OCTET_STRING_t *ostr) {
 
   //Error conditions:
   //If we already have an entry for func_id
 
   //Error conditions:
   //If we already have an entry for func_id
-  
-  printf("%%%%about to register e2sm func desc for %d\n", func_id);
-
+  LOG_I("About to register E2SM RAN function description with ID %d", func_id);
   ran_functions_registered[func_id] = ostr;
   ran_functions_registered[func_id] = ostr;
-
 }
 
 }
 
-
 void E2Sim::encode_and_send_sctp_data(E2AP_PDU_t* pdu)
 {
   uint8_t       *buf;
 void E2Sim::encode_and_send_sctp_data(E2AP_PDU_t* pdu)
 {
   uint8_t       *buf;
@@ -78,9 +74,6 @@ void E2Sim::encode_and_send_sctp_data(E2AP_PDU_t* pdu)
   data.len = e2ap_asn1c_encode_pdu(pdu, &buf);
   memcpy(data.buffer, buf, min(data.len, MAX_SCTP_BUFFER));
   if (buf) free(buf);
   data.len = e2ap_asn1c_encode_pdu(pdu, &buf);
   memcpy(data.buffer, buf, min(data.len, MAX_SCTP_BUFFER));
   if (buf) free(buf);
-  
-  LOG_I("Number of bytes sent via SCTP connection %d", min(data.len, MAX_SCTP_BUFFER));
-
   sctp_send_data(client_fd, data);
 }
 
   sctp_send_data(client_fd, data);
 }
 
@@ -108,7 +101,7 @@ void E2Sim::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu,
 
 int E2Sim::run_loop(int argc, char* argv[]){
 
 
 int E2Sim::run_loop(int argc, char* argv[]){
 
-  printf("Start E2 Agent (E2 Simulator\n");
+  LOG_I("Start E2 Agent (E2 Simulator)");
 
   ifstream simfile;
   string line;
 
   ifstream simfile;
   string line;
@@ -129,7 +122,7 @@ int E2Sim::run_loop(int argc, char* argv[]){
 
   options_t ops = read_input_options(argc, argv);
 
 
   options_t ops = read_input_options(argc, argv);
 
-  printf("After reading input options\n");
+  LOG_I("After reading input options");
 
   //E2 Agent will automatically restart upon sctp disconnection
   //  int server_fd = sctp_start_server(ops.server_ip, ops.server_port);
 
   //E2 Agent will automatically restart upon sctp disconnection
   //  int server_fd = sctp_start_server(ops.server_ip, ops.server_port);
@@ -137,8 +130,7 @@ int E2Sim::run_loop(int argc, char* argv[]){
   client_fd = sctp_start_client(ops.server_ip, ops.server_port);
   E2AP_PDU_t* pdu_setup = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU));
 
   client_fd = sctp_start_client(ops.server_ip, ops.server_port);
   E2AP_PDU_t* pdu_setup = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU));
 
-  printf("After starting client\n");
-  printf("client_fd value is %d\n", client_fd);
+  LOG_I("SCTP client has been started");
   
   std::vector<encoding::ran_func_info> all_funcs;
   RANfunctionOID_t *ranFunctionOIDe = (RANfunctionOID_t*)calloc(1,sizeof(RANfunctionOID_t));
   
   std::vector<encoding::ran_func_info> all_funcs;
   RANfunctionOID_t *ranFunctionOIDe = (RANfunctionOID_t*)calloc(1,sizeof(RANfunctionOID_t));
@@ -148,9 +140,14 @@ int E2Sim::run_loop(int argc, char* argv[]){
   ranFunctionOIDe->size = strlen((char*)buf);
 
   //Loop through RAN function definitions that are registered
   ranFunctionOIDe->size = strlen((char*)buf);
 
   //Loop through RAN function definitions that are registered
-
+  LOG_I("Constructing a list of RAN functions based on registered information");
   for (std::pair<long, OCTET_STRING_t*> elem : ran_functions_registered) {
   for (std::pair<long, OCTET_STRING_t*> elem : ran_functions_registered) {
-    printf("looping through ran func\n");
+    char* ran_desc = (char*) calloc(1, elem.second->size+1);
+    ran_desc = (char*)elem.second->buf;
+    ran_desc[elem.second->size] = '\0';
+
+    LOG_I("Adding RAN function ID %ld, description: %s to the list", elem.first, ran_desc);
+
     encoding::ran_func_info next_func;
 
     next_func.ranFunctionId = elem.first;
     encoding::ran_func_info next_func;
 
     next_func.ranFunctionId = elem.first;
@@ -161,15 +158,11 @@ int E2Sim::run_loop(int argc, char* argv[]){
     all_funcs.push_back(next_func);
   }
     
     all_funcs.push_back(next_func);
   }
     
-  printf("about to call setup request encode\n");
+  LOG_I("Generate E2AP v1 setup request for all registered RAN functions");
   generate_e2apv1_setup_request_parameterized(pdu_setup, all_funcs);
 
   generate_e2apv1_setup_request_parameterized(pdu_setup, all_funcs);
 
-  printf("After generating e2setup req\n");
-
   xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu_setup);
 
   xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu_setup);
 
-  printf("After XER Encoding\n");
-
   auto buffer_size = MAX_SCTP_BUFFER;
   unsigned char buffer[MAX_SCTP_BUFFER];
   
   auto buffer_size = MAX_SCTP_BUFFER;
   unsigned char buffer[MAX_SCTP_BUFFER];
   
@@ -179,66 +172,41 @@ int E2Sim::run_loop(int argc, char* argv[]){
   size_t errlen = 0;
 
   asn_check_constraints(&asn_DEF_E2AP_PDU, pdu_setup, error_buf, &errlen);
   size_t errlen = 0;
 
   asn_check_constraints(&asn_DEF_E2AP_PDU, pdu_setup, error_buf, &errlen);
-  printf("error length %d\n", errlen);
-  printf("error buf %s\n", error_buf);
+  LOG_I("Error length %d, error buf %s", errlen, error_buf);
 
   auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_setup, buffer, buffer_size);
 
   data.len = er.encoded;
 
 
   auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_setup, buffer, buffer_size);
 
   data.len = er.encoded;
 
-  fprintf(stderr, "er encded is %d\n", er.encoded);
+  LOG_I("Error encoded %d", er.encoded);
 
   memcpy(data.buffer, buffer, er.encoded);
 
   if(sctp_send_data(client_fd, data) > 0) {
 
   memcpy(data.buffer, buffer, er.encoded);
 
   if(sctp_send_data(client_fd, data) > 0) {
-    LOG_I("[SCTP] Sent E2-SETUP-REQUEST");
+    LOG_I("Sent E2-SETUP-REQUEST as E2AP message");
   } else {
   } else {
-    LOG_E("[SCTP] Unable to send E2-SETUP-REQUEST to peer");
+    LOG_E("Fail to send E2-SETUP-REQUEST to peer");
   }
 
   buffer_size = MAX_SCTP_BUFFER;
   memset(buffer, '\0', sizeof(buffer));
   }
 
   buffer_size = MAX_SCTP_BUFFER;
   memset(buffer, '\0', sizeof(buffer));
-  E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU));
-
-  LOG_D("about to call E2ResetRequest encode\n");
-
-  encoding::generate_e2apv2_reset_request(pdu);
-
-  LOG_D("[E2AP] Created E2ResetRequest");
-
-  e2ap_asn1c_print_pdu(pdu);
-
-  sctp_buffer_t resetdata;
-
-  error_buf[300] = {0, };
-   errlen = 0;
-
-  asn_check_constraints(&asn_DEF_E2AP_PDU, pdu, error_buf, &errlen);
-  printf("error length %d\n", errlen);
-  printf("error buf %s\n", error_buf);
-  er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu, buffer, buffer_size);
-
-  resetdata.len = er.encoded;
-  fprintf(stderr, "er encoded is %d\n", er.encoded);
-
-  memcpy(resetdata.buffer, buffer, er.encoded);
-
-  LOG_I("Test to delete ReSet code");
 
   sctp_buffer_t recv_buf;
 
 
   sctp_buffer_t recv_buf;
 
-  LOG_I("[SCTP] Waiting for SCTP data");
+  LOG_I("Waiting for SCTP data");
 
   while(1) //constantly looking for data on SCTP interface
   {
     if(sctp_receive_data(client_fd, recv_buf) <= 0)
       break;
 
 
   while(1) //constantly looking for data on SCTP interface
   {
     if(sctp_receive_data(client_fd, recv_buf) <= 0)
       break;
 
-    LOG_I("[SCTP] Received new data of size %d", recv_buf.len);
+    LOG_I("Received new data of size %d", recv_buf.len);
 
     e2ap_handle_sctp_data(client_fd, recv_buf, xmlenc, this);
     if (xmlenc) xmlenc = false;
   }
 
 
     e2ap_handle_sctp_data(client_fd, recv_buf, xmlenc, this);
     if (xmlenc) xmlenc = false;
   }
 
+  close(client_fd);
+
   return 0;
 }
   return 0;
 }
index 85d8cbf..85dae2a 100755 (executable)
@@ -71,8 +71,7 @@ long encoding::get_function_id_from_subscription(E2AP_PDU_t *e2ap_pdu) {
   
   RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array;
 
   
   RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array;
 
-  fprintf(stderr, "count%d\n", count);
-  fprintf(stderr, "size%d\n", size);
+  LOG_I("Number of IEs in original request: %d, size: %d", count, size);
 
   RICsubscriptionRequest_IEs__value_PR pres;
 
 
   RICsubscriptionRequest_IEs__value_PR pres;
 
@@ -82,17 +81,15 @@ long encoding::get_function_id_from_subscription(E2AP_PDU_t *e2ap_pdu) {
     RICsubscriptionRequest_IEs_t *next_ie = ies[i];
     pres = next_ie->value.present;
     
     RICsubscriptionRequest_IEs_t *next_ie = ies[i];
     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);
+    LOG_D("Next present value: %d, pres RAN func id: %d", pres, RICsubscriptionRequest_IEs__value_PR_RANfunctionID);
 
     if (pres == RICsubscriptionRequest_IEs__value_PR_RANfunctionID) {
 
     if (pres == RICsubscriptionRequest_IEs__value_PR_RANfunctionID) {
-      fprintf(stderr, "equal pres to ranfuncid\n");
+      LOG_E("equal pres to ranfuncid");
       func_id = next_ie->value.choice.RANfunctionID;
     }
       func_id = next_ie->value.choice.RANfunctionID;
     }
-    
   }
 
   }
 
-  fprintf(stderr, "After loop, func_id is %d\n", func_id);
+  LOG_I("After loop, func_id is %d", func_id);
 
   return func_id;  
 
 
   return func_id;  
 
@@ -100,7 +97,7 @@ long encoding::get_function_id_from_subscription(E2AP_PDU_t *e2ap_pdu) {
 
 void encoding::generate_e2apv1_service_update(E2AP_PDU_t *e2ap_pdu, std::vector<encoding::ran_func_info> all_funcs) {
   char* ran_function_op_type = getenv("RAN_FUNCTION_OP_TYPE");
 
 void encoding::generate_e2apv1_service_update(E2AP_PDU_t *e2ap_pdu, std::vector<encoding::ran_func_info> all_funcs) {
   char* ran_function_op_type = getenv("RAN_FUNCTION_OP_TYPE");
-  LOG_D("Ran funciton : %s", ran_function_op_type);
+  LOG_D("Ran function : %s", ran_function_op_type);
   ProtocolIE_ID_t prID;
   if (ran_function_op_type != NULL)
   {
   ProtocolIE_ID_t prID;
   if (ran_function_op_type != NULL)
   {
@@ -668,7 +665,7 @@ void encoding::generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu,
   respfuncid->id = ProtocolIE_ID_id_RANfunctionID;
   respfuncid->criticality = 0;
   respfuncid->value.present = RICsubscriptionResponse_IEs__value_PR_RANfunctionID;
   respfuncid->id = ProtocolIE_ID_id_RANfunctionID;
   respfuncid->criticality = 0;
   respfuncid->value.present = RICsubscriptionResponse_IEs__value_PR_RANfunctionID;
-  respfuncid->value.choice.RANfunctionID = (long)0;
+  respfuncid->value.choice.RANfunctionID = (long)147;
   
 
   RICsubscriptionResponse_IEs_t *ricactionadmitted =
   
 
   RICsubscriptionResponse_IEs_t *ricactionadmitted =
@@ -756,14 +753,9 @@ void encoding::generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu,
   size_t errlen = 0;
 
   asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
   size_t errlen = 0;
 
   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);
-
-  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");  
 
 
-  
+  LOG_I("Subscription response");
+  xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu); 
 }
 
 void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req_pdu) {
 }
 
 void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req_pdu) {
@@ -781,8 +773,7 @@ void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PD
   
   RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array;
 
   
   RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array;
 
-  fprintf(stderr, "count%d\n", count);
-  fprintf(stderr, "size%d\n", size);
+  LOG_I("Number of IEs in original request: %d, size: %d", count, size);
 
   RICsubscriptionRequest_IEs__value_PR pres;
 
 
   RICsubscriptionRequest_IEs__value_PR pres;
 
@@ -796,61 +787,49 @@ void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PD
     RICsubscriptionRequest_IEs_t *next_ie = ies[i];
     pres = next_ie->value.present;
     
     RICsubscriptionRequest_IEs_t *next_ie = ies[i];
     pres = next_ie->value.present;
     
-    fprintf(stderr, "next present value %d\n", pres);
+    LOG_D("Next present value %d", pres);
 
     switch(pres) {
     case RICsubscriptionRequest_IEs__value_PR_RICrequestID:
       {
 
     switch(pres) {
     case RICsubscriptionRequest_IEs__value_PR_RICrequestID:
       {
-       RICrequestID_t reqId = next_ie->value.choice.RICrequestID;
-       long requestorId = reqId.ricRequestorID;
-       long instanceId = reqId.ricInstanceID;
-       fprintf(stderr, "requestorId %d\n", requestorId);
-       fprintf(stderr, "instanceId %d\n", instanceId);
-       responseRequestorId = requestorId;
-       responseInstanceId = instanceId;
-               
-       break;
+        RICrequestID_t reqId = next_ie->value.choice.RICrequestID;
+        long requestorId = reqId.ricRequestorID;
+        long instanceId = reqId.ricInstanceID;
+
+        LOG_I("RequestorId %d, InstanceId: %d", requestorId, instanceId);
+        
+        responseRequestorId = requestorId;
+        responseInstanceId = instanceId;
+             break;
       }
     case RICsubscriptionRequest_IEs__value_PR_RANfunctionID:
       break;
     case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails:
       {
       }
     case RICsubscriptionRequest_IEs__value_PR_RANfunctionID:
       break;
     case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails:
       {
-       RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; 
-       RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition;
-       RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List;
-       
-       int actionCount = actionList.list.count;
-       fprintf(stderr, "action count%d\n", actionCount);
-
-       auto **item_array = actionList.list.array;
-
-       for (int i=0; i < actionCount; i++) {
-         //RICaction_ToBeSetup_Item_t
-         auto *next_item = item_array[i];
-         RICactionID_t actionId = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionID;
-         fprintf(stderr, "Next Action ID %ld\n", actionId);
-         responseActionId = actionId;
-         actionIds.push_back(responseActionId);
-       }
-       
-       break;
+        RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; 
+        RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition;
+        RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List;
+        
+        int actionCount = actionList.list.count;
+        LOG_I("Action count%d", actionCount);
+
+        auto **item_array = actionList.list.array;
+
+        for (int i=0; i < actionCount; i++) {
+          //RICaction_ToBeSetup_Item_t
+          auto *next_item = item_array[i];
+          RICactionID_t actionId = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionID;
+          LOG_D("Next Action ID %ld", actionId);
+          responseActionId = actionId;
+          actionIds.push_back(responseActionId);
+        }
+        
+        break;
       }
     }
     
   }
 
       }
     }
     
   }
 
-  fprintf(stderr, "After Processing Subscription Request\n");
-
-  fprintf(stderr, "requestorId %d\n", responseRequestorId);
-  fprintf(stderr, "instanceId %d\n", responseInstanceId);
-
-
-  for (int i=0; i < actionIds.size(); i++) {
-    fprintf(stderr, "Action ID %d %ld\n", i, actionIds.at(i));
-    
-  }
-
-
   RICsubscriptionResponse_IEs_t *respricreqid =
     (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
   
   RICsubscriptionResponse_IEs_t *respricreqid =
     (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
   
@@ -861,7 +840,6 @@ void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PD
   
   respricreqid->value.choice.RICrequestID.ricInstanceID = responseInstanceId;
 
   
   respricreqid->value.choice.RICrequestID.ricInstanceID = responseInstanceId;
 
-
   RICsubscriptionResponse_IEs_t *ricactionadmitted =
     (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
   ricactionadmitted->id = ProtocolIE_ID_id_RICactions_Admitted;
   RICsubscriptionResponse_IEs_t *ricactionadmitted =
     (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
   ricactionadmitted->id = ProtocolIE_ID_id_RICactions_Admitted;
@@ -873,8 +851,6 @@ void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PD
   ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist;
 
   for (int i=0; i < actionIds.size(); i++) {
   ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist;
 
   for (int i=0; i < actionIds.size(); i++) {
-    fprintf(stderr, "in for loop i = %d\n", i);
-
     long aid = actionIds.at(i);
 
     RICaction_Admitted_ItemIEs_t *admitie = (RICaction_Admitted_ItemIEs_t*)calloc(1,sizeof(RICaction_Admitted_ItemIEs_t));
     long aid = actionIds.at(i);
 
     RICaction_Admitted_ItemIEs_t *admitie = (RICaction_Admitted_ItemIEs_t*)calloc(1,sizeof(RICaction_Admitted_ItemIEs_t));
@@ -887,7 +863,6 @@ void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PD
 
   }
 
 
   }
 
-
   RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t));
   
   ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid);
   RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t));
   
   ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid);
@@ -911,11 +886,6 @@ void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PD
   size_t errlen = 0;
 
   asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
   size_t errlen = 0;
 
   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);
-
-
-  
 }
 
 void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu,
 }
 
 void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu,
@@ -929,7 +899,7 @@ void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_p
                                                                uint8_t *ind_message_buf,
                                                                int message_length) {
   
                                                                uint8_t *ind_message_buf,
                                                                int message_length) {
   
-  printf("Initializing E2AP request\n");
+  LOG_I("Initializing E2AP request");
 
   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_ies = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
   RICindication_IEs_t *ricind_ies2 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
@@ -1044,11 +1014,6 @@ void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_p
   int ret = asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
 
   if(ret) {
   int ret = asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
 
   if(ret) {
-    fprintf(stderr, "Constraint validation of E2AP PDU message failed: %s\n", error_buf);
+    LOG_I("Constraint validation of E2AP PDU message failed: %s\n", error_buf);
   }
   }
-
-  //xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu);  
-
-}
-
-
+}
\ No newline at end of file
index b17431e..8e1bff2 100755 (executable)
 
 void e2ap_asn1c_print_pdu(const E2AP_PDU_t* pdu)
 {
 
 void e2ap_asn1c_print_pdu(const E2AP_PDU_t* pdu)
 {
-  printf("before\n");
   //  xer_fprint(stdout, &asn_DEF_E2AP_PDU, (void *)pdu);
   xer_fprint(stdout, &asn_DEF_E2AP_PDU, pdu);
   //  xer_fprint(stdout, &asn_DEF_E2AP_PDU, (void *)pdu);
   xer_fprint(stdout, &asn_DEF_E2AP_PDU, pdu);
-  printf("after\n");
-  printf("\n");
 }
 
 void asn1c_xer_print(asn_TYPE_descriptor_t *typeDescriptor, void *data)
 {
   xer_fprint(stdout, typeDescriptor, (void *)data);
 }
 
 void asn1c_xer_print(asn_TYPE_descriptor_t *typeDescriptor, void *data)
 {
   xer_fprint(stdout, typeDescriptor, (void *)data);
-  printf("\n");
 }
 
 
 }
 
 
@@ -208,7 +204,7 @@ int e2ap_asn1c_get_procedureCode(E2AP_PDU_t* pdu)
   switch(pdu->present)
   {
     case E2AP_PDU_PR_initiatingMessage:
   switch(pdu->present)
   {
     case E2AP_PDU_PR_initiatingMessage:
-      fprintf(stderr,"initiating message\n");
+      LOG_I("Initiating E2AP PDU PR message");
       procedureCode = pdu->choice.initiatingMessage->procedureCode;
       break;
 
       procedureCode = pdu->choice.initiatingMessage->procedureCode;
       break;
 
index 57d28c2..7b712a7 100755 (executable)
 \r
 //#include <iostream>\r
 //#include <vector>\r
 \r
 //#include <iostream>\r
 //#include <vector>\r
+#include <stdexcept>\r
+#include <unistd.h>\r
 \r
 #include "encode_e2apv1.hpp"\r
 \r
 \r
 #include "encode_e2apv1.hpp"\r
 \r
-\r
-#include <unistd.h>\r
-\r
-void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc, E2Sim *e2sim)\r
-{\r
-  fprintf(stderr, "in e2ap_handle_sctp_data()\n");\r
-  //decode the data into E2AP-PDU\r
+void e2ap_handle_sctp_data(int& socket_fd, sctp_buffer_t& data, bool xmlenc, E2Sim* e2sim) {\r
   E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU));\r
   ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);\r
 \r
   E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU));\r
   ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);\r
 \r
-  fprintf(stderr, "decoding...\n");\r
-\r
   asn_transfer_syntax syntax;\r
   asn_transfer_syntax syntax;\r
-  \r
 \r
   syntax = ATS_ALIGNED_BASIC_PER;\r
 \r
   syntax = ATS_ALIGNED_BASIC_PER;\r
-  \r
-\r
-  fprintf(stderr, "full buffer\n%s\n", data.buffer);\r
-  //  e2ap_asn1c_decode_pdu(pdu, data.buffer, data.len);\r
-\r
-  auto rval = asn_decode(nullptr, syntax, &asn_DEF_E2AP_PDU, (void **) &pdu,\r
-                   data.buffer, data.len);\r
-  \r
+  auto rval = asn_decode(nullptr, syntax, &asn_DEF_E2AP_PDU, (void**)&pdu, data.buffer, data.len);\r
+\r
+  switch (rval.code) {\r
+    case RC_WMORE:\r
+    case RC_FAIL:\r
+      LOG_E("Failed to decode E2AP data from SCTP connection");\r
+      ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);\r
+      exit(1);\r
+    default:\r
+      break;\r
+  }\r
 \r
 \r
-  int index = (int)pdu->present;\r
-  fprintf(stderr, "length of data %d\n", rval.consumed);\r
-  fprintf(stderr, "result %d\n", rval.code);\r
-  fprintf(stderr, "index is %d\n", index);\r
-  \r
-  fprintf(stderr, "showing xer of data\n");  \r
-  \r
-  xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu);\r
-  \r
-  int procedureCode = e2ap_asn1c_get_procedureCode(pdu);\r
-  index = (int)pdu->present;\r
-\r
-  LOG_D("[E2AP] Unpacked E2AP-PDU: index = %d, procedureCode = %d\n",\r
-                            index, procedureCode);\r
-\r
-  switch(procedureCode)\r
-    {\r
-      \r
-    case ProcedureCode_id_E2setup:\r
-      switch(index)\r
-       {\r
+  int procedureCode = e2ap_asn1c_get_procedureCode(pdu);
+  int index = (int)pdu->present;
+
+  LOG_D("Unpacked E2AP-PDU: index = %d, procedureCode = %d", index, procedureCode);
+
+  switch (procedureCode) {
+    case ProcedureCode_id_E2setup:
+      LOG_I("Received a message of E2 setup procedure");\r
+      switch (index) {\r
         case E2AP_PDU_PR_initiatingMessage:\r
         case E2AP_PDU_PR_initiatingMessage:\r
-         e2ap_handle_E2SetupRequest(pdu, socket_fd);\r
-          LOG_I("[E2AP] Received SETUP-REQUEST");\r
+          e2ap_handle_E2SetupRequest(pdu, socket_fd);\r
+          LOG_I("Received SETUP-REQUEST");\r
           break;\r
           break;\r
-         \r
+\r
         case E2AP_PDU_PR_successfulOutcome:\r
         case E2AP_PDU_PR_successfulOutcome:\r
-          LOG_I("[E2AP] Received SETUP-RESPONSE-SUCCESS");\r
+          LOG_I("Received SETUP-RESPONSE-SUCCESS");\r
           break;\r
           break;\r
-         \r
+\r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r
-          LOG_I("[E2AP] Received SETUP-RESPONSE-FAILURE");\r
+          LOG_I("Received SETUP-RESPONSE-FAILURE");\r
           break;\r
           break;\r
-         \r
+\r
         default:\r
         default:\r
-          LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index);\r
+          LOG_E("Invalid message index=%d in E2AP-PDU", index);\r
           break;\r
           break;\r
-       }\r
-      break;    \r
-      \r
-    case ProcedureCode_id_Reset: //reset = 7\r
-      switch(index)\r
-       {\r
+      }\r
+      break;\r
+\r
+    case ProcedureCode_id_Reset:  // reset = 7\r
+      LOG_I("Received a message of Reset procedure");\r
+      switch (index) {\r
         case E2AP_PDU_PR_initiatingMessage:\r
         case E2AP_PDU_PR_initiatingMessage:\r
-          LOG_I("[E2AP] Received RESET-REQUEST");\r
+          LOG_I("Received RESET-REQUEST");\r
           break;\r
           break;\r
-         \r
+\r
         case E2AP_PDU_PR_successfulOutcome:\r
           break;\r
         case E2AP_PDU_PR_successfulOutcome:\r
           break;\r
-         \r
+\r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r
           break;\r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r
           break;\r
-         \r
+\r
         default:\r
         default:\r
-          LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index);\r
+          LOG_E("Invalid message index=%d in E2AP-PDU", index);\r
           break;\r
           break;\r
-       }\r
+      }\r
       break;\r
       break;\r
-      \r
-    case ProcedureCode_id_RICsubscription: //RIC SUBSCRIPTION = 201\r
-      switch(index)\r
-       {\r
-        case E2AP_PDU_PR_initiatingMessage: { //initiatingMessage \r
-          LOG_I("[E2AP] Received RIC-SUBSCRIPTION-REQUEST");\r
-         //          e2ap_handle_RICSubscriptionRequest(pdu, socket_fd);\r
-         long func_id = encoding::get_function_id_from_subscription(pdu);\r
-         fprintf(stderr, "Function Id of message is %d\n", func_id);\r
-         SubscriptionCallback cb;\r
-\r
-         bool func_exists = true;\r
-\r
-         try {\r
-           cb = e2sim->get_subscription_callback(func_id);\r
-         } catch(const std::out_of_range& e) {\r
-           func_exists = false;\r
-         }\r
-\r
-         if (func_exists) {\r
-           fprintf(stderr, "Calling callback function\n");\r
-           cb(pdu);\r
-         } else {\r
-           fprintf(stderr, "Error: No RAN Function with this ID exists\n");\r
-         }\r
-         //      callback_kpm_subscription_request(pdu, socket_fd);\r
-\r
-       }\r
-          break;\r
-         \r
-        case E2AP_PDU_PR_successfulOutcome:\r
-          LOG_I("[E2AP] Received RIC-SUBSCRIPTION-RESPONSE");\r
+\r
+    case ProcedureCode_id_RICsubscription:  // RIC SUBSCRIPTION = 201\r
+      LOG_I("Received a message of RIC subscription procedure");
+      switch (index) {
+        case E2AP_PDU_PR_initiatingMessage: {  // initiatingMessage
+          long func_id = encoding::get_function_id_from_subscription(pdu);
+          LOG_I("Received RIC subscription request for function with ID %d", func_id);
+
+          try {
+            SubscriptionCallback cb;
+            cb = e2sim->get_subscription_callback(func_id);
+            LOG_I("Calling callback subscription function to handle subscription request to function with ID %d", func_id);
+            cb(pdu);
+          } catch (const std::out_of_range& e) {
+            LOG_E("No RAN Function with this ID exists\n");
+          }
+
+          break;
+        }
+
+        case E2AP_PDU_PR_successfulOutcome:
+          LOG_I("Received RIC-SUBSCRIPTION-RESPONSE");
           break;\r
           break;\r
-         \r
+\r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r
-          LOG_I("[E2AP] Received RIC-SUBSCRIPTION-FAILURE");\r
+          LOG_I("Received RIC-SUBSCRIPTION-FAILURE");\r
           break;\r
           break;\r
-         \r
+\r
         default:\r
         default:\r
-          LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index);\r
+          LOG_E("Invalid message index=%d in E2AP-PDU", index);\r
           break;\r
           break;\r
-       }\r
+      }\r
       break;\r
 \r
       break;\r
 \r
-    case ProcedureCode_id_RICindication: // 205\r
-      switch(index)\r
-       {\r
-        case E2AP_PDU_PR_initiatingMessage: //initiatingMessage\r
-          LOG_I("[E2AP] Received RIC-INDICATION-REQUEST");\r
+    case ProcedureCode_id_RICindication:  // 205\r
+      LOG_I("Received a message of RIC indication procedure");\r
+      switch (index) {\r
+        case E2AP_PDU_PR_initiatingMessage:  // initiatingMessage\r
+          LOG_I("Received RIC-INDICATION-REQUEST");\r
           // e2ap_handle_RICSubscriptionRequest(pdu, socket_fd);\r
           break;\r
         case E2AP_PDU_PR_successfulOutcome:\r
           // e2ap_handle_RICSubscriptionRequest(pdu, socket_fd);\r
           break;\r
         case E2AP_PDU_PR_successfulOutcome:\r
-          LOG_I("[E2AP] Received RIC-INDICATION-RESPONSE");\r
+          LOG_I("Received RIC-INDICATION-RESPONSE");\r
           break;\r
           break;\r
-         \r
+\r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r
-          LOG_I("[E2AP] Received RIC-INDICATION-FAILURE");\r
+          LOG_I("Received RIC-INDICATION-FAILURE");\r
           break;\r
           break;\r
-         \r
+\r
         default:\r
         default:\r
-          LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index,\r
-                                    (int)ProcedureCode_id_RICindication);\r
+          LOG_E("Invalid message index=%d in E2AP-PDU %d", index, (int)ProcedureCode_id_RICindication);\r
           break;\r
           break;\r
-       }\r
+      }\r
       break;\r
 \r
     case ProcedureCode_id_RICserviceQuery:\r
       break;\r
 \r
     case ProcedureCode_id_RICserviceQuery:\r
-      switch (index)\r
-        {\r
-          case E2AP_PDU_PR_initiatingMessage:\r
-          LOG_I("[E2AP] Received RIC-Service-Query")\r
+      LOG_I("Received a message of RIC service query procedure");\r
+      switch (index) {\r
+        case E2AP_PDU_PR_initiatingMessage:\r
+          LOG_I("Received RIC-Service-Query")\r
           e2ap_handle_E2SeviceRequest(pdu, socket_fd, e2sim);\r
           break;\r
 \r
           e2ap_handle_E2SeviceRequest(pdu, socket_fd, e2sim);\r
           break;\r
 \r
-          default:\r
-            LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index,\r
-                                    (int)ProcedureCode_id_RICserviceQuery);\r
+        default:\r
+          LOG_E("Invalid message index=%d in E2AP-PDU %d", index, (int)ProcedureCode_id_RICserviceQuery);\r
           break;\r
           break;\r
-        }\r
+      }\r
       break;\r
 \r
     case ProcedureCode_id_E2nodeConfigurationUpdate:\r
       break;\r
 \r
     case ProcedureCode_id_E2nodeConfigurationUpdate:\r
-      switch (index)\r
-        {\r
-          case E2AP_PDU_PR_successfulOutcome:\r
-          LOG_I("[E2AP] Received E2nodeConfigurationUpdate")\r
+      LOG_I("Received a message of E2 node configuration update procedure");\r
+      switch (index) {\r
+        case E2AP_PDU_PR_successfulOutcome:\r
+          LOG_I("Received E2nodeConfigurationUpdate")\r
           break;\r
 \r
           break;\r
 \r
-          default:\r
-            LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index,\r
-                                    (int)ProcedureCode_id_E2nodeConfigurationUpdate);\r
+        default:\r
+          LOG_E("Invalid message index=%d in E2AP-PDU %d", index, (int)ProcedureCode_id_E2nodeConfigurationUpdate);\r
           break;\r
           break;\r
-        }\r
+      }\r
       break;\r
 \r
     case ProcedureCode_id_RICserviceUpdate:\r
       break;\r
 \r
     case ProcedureCode_id_RICserviceUpdate:\r
-      switch (index)\r
-        {\r
-          case E2AP_PDU_PR_successfulOutcome:\r
-          LOG_I("[E2AP] Received RIC-SERVICE-UPDATE-SUCCESS")\r
+      LOG_I("Received a message of RIC service update procedure");\r
+      switch (index) {\r
+        case E2AP_PDU_PR_successfulOutcome:\r
+          LOG_I("Received RIC-SERVICE-UPDATE-SUCCESS")\r
           break;\r
 \r
           break;\r
 \r
-          case E2AP_PDU_PR_unsuccessfulOutcome:\r
-          LOG_I("[E2AP] Received RIC-SERVICE-UPDATE-FAILURE")\r
+        case E2AP_PDU_PR_unsuccessfulOutcome:\r
+          LOG_I("Received RIC-SERVICE-UPDATE-FAILURE")\r
           break;\r
 \r
           break;\r
 \r
-          default:\r
-            LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index,\r
-                                    (int)ProcedureCode_id_RICserviceUpdate);\r
+        default:\r
+          LOG_E("Invalid message index=%d in E2AP-PDU %d", index, (int)ProcedureCode_id_RICserviceUpdate);\r
           break;\r
           break;\r
-        }\r
+      }\r
       break;\r
       break;\r
-    \r
-    default:\r
-      \r
-      LOG_E("[E2AP] No available handler for procedureCode=%d", procedureCode);\r
 \r
 \r
+    default:\r
+      LOG_E("No available handler for procedureCode=%d", procedureCode);\r
       break;\r
       break;\r
-    }\r
+  }\r
   ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);\r
 }\r
 \r
   ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);\r
 }\r
 \r
-void e2ap_handle_E2SeviceRequest(E2AP_PDU_t* pdu, int &socket_fd, E2Sim *e2sim) {\r
-\r
+void e2ap_handle_E2SeviceRequest(E2AP_PDU_t* pdu, int& socket_fd, E2Sim* e2sim) {\r
   auto buffer_size = MAX_SCTP_BUFFER;\r
   unsigned char buffer[MAX_SCTP_BUFFER];\r
   auto buffer_size = MAX_SCTP_BUFFER;\r
   unsigned char buffer[MAX_SCTP_BUFFER];\r
-  E2AP_PDU_t* res_pdu = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU));\r
+  E2AP_PDU_t* res_pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU));\r
 \r
   // prepare ran function defination\r
   std::vector<encoding::ran_func_info> all_funcs;\r
 \r
 \r
   // prepare ran function defination\r
   std::vector<encoding::ran_func_info> all_funcs;\r
 \r
-  //Loop through RAN function definitions that are registered\r
+  // Loop through RAN function definitions that are registered\r
 \r
   for (std::pair<long, OCTET_STRING_t*> elem : e2sim->getRegistered_ran_functions()) {\r
     printf("looping through ran func\n");\r
 \r
   for (std::pair<long, OCTET_STRING_t*> elem : e2sim->getRegistered_ran_functions()) {\r
     printf("looping through ran func\n");\r
@@ -250,18 +217,20 @@ void e2ap_handle_E2SeviceRequest(E2AP_PDU_t* pdu, int &socket_fd, E2Sim *e2sim)
     next_func.ranFunctionRev = (long)3;\r
     all_funcs.push_back(next_func);\r
   }\r
     next_func.ranFunctionRev = (long)3;\r
     all_funcs.push_back(next_func);\r
   }\r
-    \r
+\r
   printf("about to call service update encode\n");\r
 \r
   encoding::generate_e2apv1_service_update(res_pdu, all_funcs);\r
 \r
   printf("about to call service update encode\n");\r
 \r
   encoding::generate_e2apv1_service_update(res_pdu, all_funcs);\r
 \r
-  LOG_D("[E2AP] Created E2-SERVICE-UPDATE");\r
+  LOG_D("Created E2-SERVICE-UPDATE");\r
 \r
   e2ap_asn1c_print_pdu(res_pdu);\r
 \r
   sctp_buffer_t data;\r
 \r
 \r
   e2ap_asn1c_print_pdu(res_pdu);\r
 \r
   sctp_buffer_t data;\r
 \r
-  char error_buf[300] = {0, };\r
+  char error_buf[300] = {\r
+      0,\r
+  };\r
   size_t errlen = 0;\r
 \r
   asn_check_constraints(&asn_DEF_E2AP_PDU, res_pdu, error_buf, &errlen);\r
   size_t errlen = 0;\r
 \r
   asn_check_constraints(&asn_DEF_E2AP_PDU, res_pdu, error_buf, &errlen);\r
@@ -269,92 +238,107 @@ void e2ap_handle_E2SeviceRequest(E2AP_PDU_t* pdu, int &socket_fd, E2Sim *e2sim)
   printf("error buf %s\n", error_buf);\r
 \r
   auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, res_pdu, buffer, buffer_size);\r
   printf("error buf %s\n", error_buf);\r
 \r
   auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, res_pdu, buffer, buffer_size);\r
+  \r
+  if (er.encoded == -1) {\r
+    LOG_E("Failed to serialize message. Detail: %s.\n", asn_DEF_E2AP_PDU.name);\r
+    exit(1);\r
+  } else if (er.encoded > buffer_size) {\r
+    LOG_E("Buffer of size %zu is too small for %s, need %zu\n", buffer_size, asn_DEF_E2AP_PDU.name, er.encoded);\r
+    exit(1);\r
+  }\r
 \r
   data.len = er.encoded;\r
 \r
   data.len = er.encoded;\r
-  fprintf(stderr, "er encoded is %d\n", er.encoded);\r
 \r
   memcpy(data.buffer, buffer, er.encoded);\r
 \r
 \r
   memcpy(data.buffer, buffer, er.encoded);\r
 \r
-  //send response data over sctp\r
-  if(sctp_send_data(socket_fd, data) > 0) {\r
-    LOG_I("[SCTP] Sent E2-SERVICE-UPDATE");\r
+  // send response data over sctp\r
+  if (sctp_send_data(socket_fd, data) > 0) {\r
+    LOG_I("Sent E2-SERVICE-UPDATE");\r
   } else {\r
   } else {\r
-    LOG_E("[SCTP] Unable to send E2-SERVICE-UPDATE to peer");\r
+    LOG_E("Unable to send E2-SERVICE-UPDATE to peer");\r
   }\r
 }\r
 \r
   }\r
 }\r
 \r
-void e2ap_send_e2nodeConfigUpdate(int &socket_fd) {\r
-\r
+void e2ap_send_e2nodeConfigUpdate(int& socket_fd) {\r
   auto buffer_size = MAX_SCTP_BUFFER;\r
   unsigned char buffer[MAX_SCTP_BUFFER];\r
   auto buffer_size = MAX_SCTP_BUFFER;\r
   unsigned char buffer[MAX_SCTP_BUFFER];\r
-  E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU));\r
+  E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU));\r
 \r
 \r
-  LOG_D("about to call e2nodeconfigUpdate encode\n");\r
+  LOG_I("Generating E2 node configure update");\r
 \r
   encoding::generate_e2apv2_config_update(pdu);\r
 \r
 \r
   encoding::generate_e2apv2_config_update(pdu);\r
 \r
-  LOG_D("[E2AP] Created E2nodeConfigUpdate");\r
-\r
   e2ap_asn1c_print_pdu(pdu);\r
 \r
   sctp_buffer_t data;\r
 \r
   e2ap_asn1c_print_pdu(pdu);\r
 \r
   sctp_buffer_t data;\r
 \r
-  char error_buf[300] = {0, };\r
+  char error_buf[300] = {\r
+      0,\r
+  };\r
   size_t errlen = 0;\r
 \r
   asn_check_constraints(&asn_DEF_E2AP_PDU, pdu, error_buf, &errlen);\r
 \r
   auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu, buffer, buffer_size);\r
 \r
   size_t errlen = 0;\r
 \r
   asn_check_constraints(&asn_DEF_E2AP_PDU, pdu, error_buf, &errlen);\r
 \r
   auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu, buffer, buffer_size);\r
 \r
+  if (er.encoded == -1) {\r
+    LOG_E("Failed to serialize message. Detail: %s.\n", asn_DEF_E2AP_PDU.name);\r
+    exit(1);\r
+  } else if (er.encoded > buffer_size) {\r
+    LOG_E("Buffer of size %zu is too small for %s, need %zu\n", buffer_size, asn_DEF_E2AP_PDU.name, er.encoded);\r
+    exit(1);\r
+  }\r
+\r
   data.len = er.encoded;\r
   data.len = er.encoded;\r
-  fprintf(stderr, "er encoded is %d\n", er.encoded);\r
 \r
   memcpy(data.buffer, buffer, er.encoded);\r
 \r
 \r
   memcpy(data.buffer, buffer, er.encoded);\r
 \r
-  //send response data over sctp\r
-  if(sctp_send_data(socket_fd, data) > 0) {\r
-    LOG_I("[SCTP] Sent E2nodeConfigUpdate");\r
+  // send response data over sctp\r
+  if (sctp_send_data(socket_fd, data) > 0) {\r
+    LOG_I("Sent E2nodeConfigUpdate");\r
   } else {\r
     LOG_E("[SCTP] Unable to send E2nodeConfigUpdate to peer");\r
   }\r
 }\r
 \r
   } else {\r
     LOG_E("[SCTP] Unable to send E2nodeConfigUpdate to peer");\r
   }\r
 }\r
 \r
-void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd) {\r
-\r
-  \r
+void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int& socket_fd) {\r
   E2AP_PDU_t* res_pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU));\r
   encoding::generate_e2apv1_setup_response(res_pdu);\r
 \r
   E2AP_PDU_t* res_pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU));\r
   encoding::generate_e2apv1_setup_response(res_pdu);\r
 \r
-  \r
-  LOG_D("[E2AP] Created E2-SETUP-RESPONSE");\r
+  LOG_D("Created E2-SETUP-RESPONSE");\r
 \r
   e2ap_asn1c_print_pdu(res_pdu);\r
 \r
 \r
   e2ap_asn1c_print_pdu(res_pdu);\r
 \r
-\r
   auto buffer_size = MAX_SCTP_BUFFER;\r
   unsigned char buffer[MAX_SCTP_BUFFER];\r
   auto buffer_size = MAX_SCTP_BUFFER;\r
   unsigned char buffer[MAX_SCTP_BUFFER];\r
-  \r
+\r
   sctp_buffer_t data;\r
   auto er = asn_encode_to_buffer(nullptr, ATS_BASIC_XER, &asn_DEF_E2AP_PDU, res_pdu, buffer, buffer_size);\r
 \r
   sctp_buffer_t data;\r
   auto er = asn_encode_to_buffer(nullptr, ATS_BASIC_XER, &asn_DEF_E2AP_PDU, res_pdu, buffer, buffer_size);\r
 \r
+  if (er.encoded == -1) {\r
+    LOG_E("Failed to serialize message. Detail: %s.\n", asn_DEF_E2AP_PDU.name);\r
+    exit(1);\r
+  } else if (er.encoded > buffer_size) {\r
+    LOG_E("Buffer of size %zu is too small for %s, need %zu\n", buffer_size, asn_DEF_E2AP_PDU.name, er.encoded);\r
+    exit(1);\r
+  }\r
+\r
   data.len = er.encoded;\r
   data.len = er.encoded;\r
-  fprintf(stderr, "er encoded is %d\n", er.encoded);  \r
   \r
   \r
-  //data.len = e2ap_asn1c_encode_pdu(res_pdu, &buf);\r
   memcpy(data.buffer, buffer, er.encoded);\r
 \r
   memcpy(data.buffer, buffer, er.encoded);\r
 \r
-  //send response data over sctp\r
-  if(sctp_send_data(socket_fd, data) > 0) {\r
-    LOG_I("[SCTP] Sent E2-SETUP-RESPONSE");\r
+  // send response data over sctp\r
+  if (sctp_send_data(socket_fd, data) > 0) {\r
+    LOG_I("Sent E2-SETUP-RESPONSE");\r
   } else {\r
     LOG_E("[SCTP] Unable to send E2-SETUP-RESPONSE to peer");\r
   }\r
 \r
   sleep(5);\r
 \r
   } else {\r
     LOG_E("[SCTP] Unable to send E2-SETUP-RESPONSE to peer");\r
   }\r
 \r
   sleep(5);\r
 \r
-  //Sending Subscription Request\r
+  // Sending Subscription Request\r
 \r
 \r
-  E2AP_PDU_t* pdu_sub = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU));\r
+  E2AP_PDU_t* pdu_sub = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU));\r
 \r
   encoding::generate_e2apv1_subscription_request(pdu_sub);\r
 \r
 \r
   encoding::generate_e2apv1_subscription_request(pdu_sub);\r
 \r
@@ -362,23 +346,27 @@ void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd) {
 \r
   auto buffer_size2 = MAX_SCTP_BUFFER;\r
   unsigned char buffer2[MAX_SCTP_BUFFER];\r
 \r
   auto buffer_size2 = MAX_SCTP_BUFFER;\r
   unsigned char buffer2[MAX_SCTP_BUFFER];\r
-  \r
+\r
   sctp_buffer_t data2;\r
 \r
   auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_sub, buffer2, buffer_size2);\r
   sctp_buffer_t data2;\r
 \r
   auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_sub, buffer2, buffer_size2);\r
-  \r
+\r
+  if (er2.encoded == -1) {\r
+    LOG_E("Failed to serialize message. Detail: %s.\n", asn_DEF_E2AP_PDU.name);\r
+    exit(1);\r
+  } else if (er2.encoded > buffer_size2) {\r
+    LOG_E("Buffer of size %zu is too small for %s, need %zu\n", buffer_size2, asn_DEF_E2AP_PDU.name, er2.encoded);\r
+    exit(1);\r
+  }\r
+\r
   data2.len = er2.encoded;\r
   memcpy(data2.buffer, buffer2, er2.encoded);\r
   data2.len = er2.encoded;\r
   memcpy(data2.buffer, buffer2, er2.encoded);\r
-  \r
-  fprintf(stderr, "er encded is %d\n", er2.encoded);\r
 \r
 \r
-  if(sctp_send_data(socket_fd, data2) > 0) {\r
-    LOG_I("[SCTP] Sent E2-SUBSCRIPTION-REQUEST");\r
+  if (sctp_send_data(socket_fd, data2) > 0) {\r
+    LOG_I("Sent E2-SUBSCRIPTION-REQUEST");\r
   } else {\r
     LOG_E("[SCTP] Unable to send E2-SUBSCRIPTION-REQUEST to peer");\r
   } else {\r
     LOG_E("[SCTP] Unable to send E2-SUBSCRIPTION-REQUEST to peer");\r
-  }  \r
-\r
-\r
+  }\r
 }\r
 \r
 /*\r
 }\r
 \r
 /*\r
@@ -397,7 +385,7 @@ void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd)
 \r
   auto buffer_size2 = MAX_SCTP_BUFFER;\r
   unsigned char buffer2[MAX_SCTP_BUFFER];\r
 \r
   auto buffer_size2 = MAX_SCTP_BUFFER;\r
   unsigned char buffer2[MAX_SCTP_BUFFER];\r
-  \r
+\r
   sctp_buffer_t data2;\r
 \r
   auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_resp, buffer2, buffer_size2);\r
   sctp_buffer_t data2;\r
 \r
   auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_resp, buffer2, buffer_size2);\r
@@ -408,12 +396,12 @@ void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd)
   memcpy(data2.buffer, buffer2, er2.encoded);\r
 \r
   if(sctp_send_data(socket_fd, data2) > 0) {\r
   memcpy(data2.buffer, buffer2, er2.encoded);\r
 \r
   if(sctp_send_data(socket_fd, data2) > 0) {\r
-    LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-RESPONSE");\r
+    LOG_I("Sent RIC-SUBSCRIPTION-RESPONSE");\r
   } else {\r
     LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE to peer");\r
   }\r
   } else {\r
     LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE to peer");\r
   }\r
-  \r
-  \r
+\r
+\r
   //Send back an Indication\r
 \r
   E2AP_PDU_t* pdu_ind = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU));\r
   //Send back an Indication\r
 \r
   E2AP_PDU_t* pdu_ind = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU));\r
@@ -424,7 +412,7 @@ void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd)
 \r
   auto buffer_size = MAX_SCTP_BUFFER;\r
   unsigned char buffer[MAX_SCTP_BUFFER];\r
 \r
   auto buffer_size = MAX_SCTP_BUFFER;\r
   unsigned char buffer[MAX_SCTP_BUFFER];\r
-  \r
+\r
   sctp_buffer_t data;\r
 \r
   auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_ind, buffer, buffer_size);\r
   sctp_buffer_t data;\r
 \r
   auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_ind, buffer, buffer_size);\r
@@ -435,13 +423,10 @@ void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd)
   memcpy(data.buffer, buffer, er.encoded);\r
 \r
   if(sctp_send_data(socket_fd, data) > 0) {\r
   memcpy(data.buffer, buffer, er.encoded);\r
 \r
   if(sctp_send_data(socket_fd, data) > 0) {\r
-    LOG_I("[SCTP] Sent RIC-INDICATION-REQUEST");\r
+    LOG_I("Sent RIC-INDICATION-REQUEST");\r
   } else {\r
     LOG_E("[SCTP] Unable to send RIC-INDICATION-REQUEST to peer");\r
   } else {\r
     LOG_E("[SCTP] Unable to send RIC-INDICATION-REQUEST to peer");\r
-  }  \r
+  }\r
 \r
 }\r
 */\r
 \r
 }\r
 */\r
-\r
-\r
-\r