SIM-119: Update value of MeasurementTypeName and MeasurementTypeID to constraint
[sim/e2-interface.git] / e2sim / src / messagerouting / e2ap_message_handler.cpp
index c08d55c..7b712a7 100755 (executable)
@@ -22,7 +22,7 @@
 \r
 //#include <iostream>\r
 //#include <vector>\r
-\r
+#include <stdexcept>\r
 #include <unistd.h>\r
 \r
 #include "encode_e2apv1.hpp"\r
@@ -39,19 +39,20 @@ void e2ap_handle_sctp_data(int& socket_fd, sctp_buffer_t& data, bool xmlenc, E2S
   switch (rval.code) {\r
     case RC_WMORE:\r
     case RC_FAIL:\r
-    default:\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
-  int procedureCode = e2ap_asn1c_get_procedureCode(pdu);\r
-  int index = (int)pdu->present;\r
-\r
-  LOG_D("Unpacked E2AP-PDU: index = %d, procedureCode = %d\n", index, procedureCode);\r
-\r
-  switch (procedureCode) {\r
-    case ProcedureCode_id_E2setup:\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
@@ -93,35 +94,26 @@ void e2ap_handle_sctp_data(int& socket_fd, sctp_buffer_t& data, bool xmlenc, E2S
       break;\r
 \r
     case ProcedureCode_id_RICsubscription:  // RIC SUBSCRIPTION = 201\r
-      LOG_I("Received a message of RIC subscription procedure");\r
-      switch (index) {\r
-        case E2AP_PDU_PR_initiatingMessage: {  // initiatingMessage\r
-          LOG_I("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
-        } break;\r
-\r
-        case E2AP_PDU_PR_successfulOutcome:\r
-          LOG_I("Received RIC-SUBSCRIPTION-RESPONSE");\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
 \r
         case E2AP_PDU_PR_unsuccessfulOutcome:\r