From e86af0d54882624aafd1281eebaa3972921d1a01 Mon Sep 17 00:00:00 2001 From: swc Date: Mon, 5 Oct 2020 19:09:00 +0900 Subject: [PATCH] bugfix for subscription - Modified Type of transaction_identifier - Fixed me_id from getting NULL - Modified to check subscription error (time out) Issue-ID: RICAPP148 Signed-off-by: swc Change-Id: I517e31414161b0e83bcfe5216856e9598ee619de --- src/xapp-mgmt/msgs_proc.cc | 18 ++++++++++++++---- src/xapp-mgmt/subs_mgmt.cc | 4 ++-- src/xapp-mgmt/subs_mgmt.hpp | 17 +++++++++-------- src/xapp.cc | 12 +++++++----- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/xapp-mgmt/msgs_proc.cc b/src/xapp-mgmt/msgs_proc.cc index 99eb453..767ef27 100644 --- a/src/xapp-mgmt/msgs_proc.cc +++ b/src/xapp-mgmt/msgs_proc.cc @@ -83,7 +83,7 @@ bool XappMsgHandler::decode_subscription_response(unsigned char* data_buf, size_ bool XappMsgHandler::a1_policy_handler(char * message, int *message_len, a1_policy_helper &helper){ rapidjson::Document doc; - if (doc.Parse(message).HasParseError()){ + if (doc.Parse(message).HasParseError()){ mdclog_write(MDCLOG_ERR, "Error: %s, %d :: Could not decode A1 JSON message %s\n", __FILE__, __LINE__, message); return false; } @@ -151,6 +151,7 @@ void XappMsgHandler::operator()(rmr_mbuf_t *message, bool *resend){ } a1_policy_helper helper; bool res=false; + std::string str_meid; switch(message->mtype){ //need to fix the health check. case (RIC_HEALTH_CHECK_REQ): @@ -163,15 +164,24 @@ void XappMsgHandler::operator()(rmr_mbuf_t *message, bool *resend){ case (RIC_SUB_RESP): mdclog_write(MDCLOG_INFO, "Received subscription message of type = %d", message->mtype); unsigned char *me_id; - rmr_get_meid(message, me_id); + if( (me_id = (unsigned char *) malloc( sizeof( unsigned char ) * RMR_MAX_MEID )) == NULL ) { + mdclog_write(MDCLOG_ERR, "Error : %s, %d : malloc failed for me_id", __FILE__, __LINE__); + me_id = rmr_get_meid(message, NULL); + } else { + rmr_get_meid(message, me_id); + } mdclog_write(MDCLOG_INFO,"RMR Received MEID: %s",me_id); - + str_meid.insert(0,(char*)me_id); if(_ref_sub_handler !=NULL){ - _ref_sub_handler->manage_subscription_response(message->mtype, me_id); + _ref_sub_handler->manage_subscription_response(message->mtype, str_meid); } else { mdclog_write(MDCLOG_ERR, " Error :: %s, %d : Subscription handler not assigned in message processor !", __FILE__, __LINE__); } *resend = false; + if (me_id != NULL) { + mdclog_write(MDCLOG_INFO, "Free RMR Received MEID memory: %s(0x%x)", me_id, me_id); + free(me_id); + } break; case A1_POLICY_REQ: diff --git a/src/xapp-mgmt/subs_mgmt.cc b/src/xapp-mgmt/subs_mgmt.cc index 4b17f5a..58da73c 100644 --- a/src/xapp-mgmt/subs_mgmt.cc +++ b/src/xapp-mgmt/subs_mgmt.cc @@ -67,10 +67,10 @@ bool SubscriptionHandler::delete_request_entry(transaction_identifier id){ if (search != status_table.end()){ status_table.erase(search); - mdclog_write(MDCLOG_INFO,"Entry for Transaction ID deleted: %d",id); + mdclog_write(MDCLOG_INFO,"Entry for Transaction ID deleted: %s",id.c_str()); return true; } - mdclog_write(MDCLOG_INFO,"Entry not found in SubscriptionHandler for Transaction ID: %d",id); + mdclog_write(MDCLOG_INFO,"Entry not found in SubscriptionHandler for Transaction ID: %s",id.c_str()); return false; }; diff --git a/src/xapp-mgmt/subs_mgmt.hpp b/src/xapp-mgmt/subs_mgmt.hpp index 5673308..4cc328a 100644 --- a/src/xapp-mgmt/subs_mgmt.hpp +++ b/src/xapp-mgmt/subs_mgmt.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "../xapp-asn/e2ap/subscription_delete_request.hpp" #include "../xapp-asn/e2ap/subscription_delete_response.hpp" @@ -92,7 +93,7 @@ typedef enum { request_duplicate }Subscription_Status_Types; -using transaction_identifier = unsigned char*; +using transaction_identifier = std::string; using transaction_status = Subscription_Status_Types; class SubscriptionHandler { @@ -176,10 +177,10 @@ int SubscriptionHandler::manage_subscription_request(transaction_identifier rmr_ if (!flg){ // clear state delete_request_entry(rmr_trans_id); - mdclog_write(MDCLOG_ERR, "%s, %d :: Error transmitting subscription request %s", __FILE__, __LINE__, rmr_trans_id ); + mdclog_write(MDCLOG_ERR, "%s, %d :: Error transmitting subscription request %s", __FILE__, __LINE__, rmr_trans_id.c_str() ); return SUBSCR_ERR_TX; } else { - mdclog_write(MDCLOG_INFO, "%s, %d :: Transmitted subscription request for trans_id %s", __FILE__, __LINE__, rmr_trans_id ); + mdclog_write(MDCLOG_INFO, "%s, %d :: Transmitted subscription request for trans_id %s", __FILE__, __LINE__, rmr_trans_id.c_str() ); add_transmitter_entry(rmr_trans_id, tx); } @@ -198,7 +199,7 @@ int SubscriptionHandler::manage_subscription_request(transaction_identifier rmr_ int status = get_request_status(rmr_trans_id); if (status == request_success){ - mdclog_write(MDCLOG_INFO, "Successfully subscribed for request for trans_id %s", rmr_trans_id); + mdclog_write(MDCLOG_INFO, "Successfully subscribed for request for trans_id %s", rmr_trans_id.c_str()); res = SUBSCR_SUCCESS; break; } @@ -210,15 +211,15 @@ int SubscriptionHandler::manage_subscription_request(transaction_identifier rmr_ if ( f > _time_out){ - mdclog_write(MDCLOG_ERR, "%s, %d:: Subscription request with transaction id %s timed out waiting for response ", __FILE__, __LINE__, rmr_trans_id); + mdclog_write(MDCLOG_ERR, "%s, %d:: Subscription request with transaction id %s timed out waiting for response ", __FILE__, __LINE__, rmr_trans_id.c_str()); - //res = SUBSCR_ERR_TIMEOUT; + res = SUBSCR_ERR_TIMEOUT; //sunny side scenario. assuming subscription response is received. - res = SUBSCR_SUCCESS; + //res = SUBSCR_SUCCESS; break; } else{ - mdclog_write(MDCLOG_INFO, "Subscription request with transaction id %s Waiting for response....", rmr_trans_id); + mdclog_write(MDCLOG_INFO, "Subscription request with transaction id %s Waiting for response....", rmr_trans_id.c_str()); continue; } diff --git a/src/xapp.cc b/src/xapp.cc index d8e0476..7d5d2b3 100644 --- a/src/xapp.cc +++ b/src/xapp.cc @@ -176,10 +176,12 @@ void Xapp::startup_subscribe_requests(void ){ mdclog_write(MDCLOG_INFO,"Sending subscription in file= %s, line=%d for MEID %s",__FILE__,__LINE__, meid); auto transmitter = std::bind(&XappRmr::xapp_rmr_send,rmr_ref, &rmr_header, (void*)buf );//(void*)data); - int result = subhandler_ref->manage_subscription_request(meid, transmitter); - if(result){ - mdclog_write(MDCLOG_INFO,"Subscription SUCCESSFUL in file= %s, line=%d for MEID %s",__FILE__,__LINE__, meid); - + int result = subhandler_ref->manage_subscription_request(gnblist[i], transmitter); + if(result==SUBSCR_SUCCESS){ + mdclog_write(MDCLOG_INFO,"Subscription SUCCESSFUL in file= %s, line=%d for MEID %s",__FILE__,__LINE__, meid); + } + else { + mdclog_write(MDCLOG_ERR,"Subscription FAILED in file= %s, line=%d for MEID %s",__FILE__,__LINE__, meid); } } @@ -215,7 +217,7 @@ void Xapp::set_rnib_gnblist(void) { Document doc; - ParseResult parseJson = doc.Parse((char*)result); + ParseResult parseJson = doc.Parse((char*)result); if (!parseJson) { std::cerr << "JSON parse error: %s (%u)", GetParseErrorFunc(parseJson.Code()); return; -- 2.16.6