--- /dev/null
+/*\r
+==================================================================================\r
+\r
+ Copyright (c) 2018-2019 AT&T Intellectual Property.\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================================\r
+*/\r
+\r
+\r
+#include <message_processor_class.hpp>\r
+\r
+void message_processor::register_subscription_handler(SubscriptionHandler * sub){\r
+ _ref_sub_handler = sub;\r
+}\r
+\r
+// main message processing \r
+bool message_processor::operator()(redisContext *redis_context, rmr_mbuf_t *message){\r
+\r
+ bool res;\r
+ int message_type, procedure_code;\r
+ asn_dec_rval_t rval;\r
+ size_t buf_size = BUFFER_LENGTH;\r
+ size_t mlen;\r
+ _num_messages ++;\r
+ std::string response;\r
+\r
+ // main message processing code\r
+ switch(message->mtype){\r
+ \r
+ case RIC_INDICATION:\r
+\r
+ e2ap_recv_pdu = 0;\r
+ e2sm_header = 0;\r
+ \r
+ rval = asn_decode(0,ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, (void**)&(e2ap_recv_pdu), message->payload, message->len);\r
+\r
+ if(likely(rval.code == RC_OK)){\r
+ num_indications ++;\r
+ res = indication_processor.get_fields(e2ap_recv_pdu->choice.initiatingMessage, indication_data);\r
+ if (unlikely(!res)){\r
+ mdclog_write(MDCLOG_ERR, "Error :: %s, %d :: Could not get fields from RICindication message\n", __FILE__, __LINE__);\r
+ return false;\r
+ }\r
+ //std::cout <<"+++++++++++++++++++++++ E2AP Indication ++++++++++++++++++++++++" << std::endl;\r
+ //xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2ap_recv_pdu);\r
+ //std::cout <<"+++++++++++++++++++++++ E2AP Indication ++++++++++++++++++++++++" << std::endl;\r
+ }\r
+ else{\r
+ num_err_indications ++;\r
+ mdclog_write(MDCLOG_ERR, "Error :: %s, %d: Error decoding E2AP PDU\n", __FILE__, __LINE__);\r
+ return false;\r
+ }\r
+\r
+ mdclog_write(MDCLOG_INFO, "E2AP INDICATION :: Successfully received E2AP Indication message with id = %d, sequence no = %d, Number of indication messages = %lu, Number of erroneous indications = %lu\n", indication_data.req_id, indication_data.req_seq_no, num_indications, num_err_indications);\r
+ \r
+ //Decode the SM header\r
+ rval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationHeader, (void**)&(e2sm_header), indication_data.indication_header, indication_data.indication_header_size);\r
+ if (likely(rval.code == RC_OK)){\r
+ res = e2sm_indication_processor.get_header_fields(e2sm_header, header_helper);\r
+ if (unlikely(!res)){\r
+ mdclog_write(MDCLOG_ERR, "Error :: %s, %d :: Could not get fields from E2SM HEADER\n", __FILE__, __LINE__);\r
+ return false;\r
+ }\r
+ \r
+ // std::cout <<"+++++++++++++++++++++++ E2SM Indication Header ++++++++++++++++++++++++" << std::endl;\r
+ // xer_fprint(stdout, &asn_DEF_E2SM_gNB_X2_indicationHeader, e2sm_header);\r
+ // std::cout <<"+++++++++++++++++++++++ E2SM Indication Header ++++++++++++++++++++++++" << std::endl; \r
+ }\r
+ else{\r
+ mdclog_write(MDCLOG_ERR, "Error :: %s, %d: Error decoding E2SM Header.", __FILE__, __LINE__);\r
+ return false;\r
+ }\r
+ mdclog_write(MDCLOG_DEBUG, "E2SM INDICATION HEADER :: Successfully decoded E2SM Indication Header of size %lu\n", indication_data.indication_header_size);\r
+\r
+ // Do the further decoding here for KPI message\r
+\r
+ res = (*_ref_kpi_msg_handler)(redis_context, indication_data.indication_msg, indication_data.indication_msg_size);\r
+\r
+ if(unlikely(!res)){\r
+ return false;\r
+ }\r
+ // NOTE : We assume RICindicationMessage contains payload (not E2SM message)\r
+ ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationHeader, e2sm_header);\r
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, e2ap_recv_pdu);\r
+\r
+ break;\r
+\r
+ case (RIC_SUB_RESP):\r
+ case (RIC_SUB_FAILURE):\r
+ if (_ref_sub_handler != NULL){\r
+ mdclog_write(MDCLOG_INFO, "Received subscription message of type = %d", message->mtype);\r
+ _ref_sub_handler->Response(message->mtype, message->payload, message->len);\r
+ }\r
+ else{\r
+ mdclog_write(MDCLOG_ERR, " Error :: %s, %d : Subscription handler not assigned in message processor !", __FILE__, __LINE__);\r
+ return false;\r
+ }\r
+ \r
+ break;\r
+\r
+ default:\r
+ mdclog_write(MDCLOG_ERR, "Error :: Unknown message type %d received from RMR", message->mtype);\r
+ };\r
+ \r
+ return false;\r
+};\r
+\r
+\r
+unsigned long const message_processor::get_messages (void){\r
+ return _num_messages;\r
+};\r
+\r