Fixed up issues with last commit
[sim/e2-interface.git] / e2sim / src / messagerouting / e2ap_message_handler.cpp
index 3e8da63..0e23c8d 100644 (file)
@@ -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");\r
          //          e2ap_handle_RICSubscriptionRequest(pdu, socket_fd);\r
          long func_id = encoding::get_function_id_from_subscription(pdu);\r
-         SubscriptionCallback cb = e2sim->get_subscription_callback(func_id);\r
-         cb(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