From c371a26d48604a5d60686d9ca347e68671e69637 Mon Sep 17 00:00:00 2001 From: pborla Date: Fri, 17 Nov 2023 12:53:34 +0530 Subject: [PATCH] [Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-532] RIC Subscription Delete Rsp Change-Id: Ida681cbb6ccee7f1bc18e2662c76c4a896577c3f Signed-off-by: pborla --- src/du_app/du_e2ap_mgr.c | 34 +++++--- src/du_app/du_e2ap_msg_hdl.c | 167 +++++++++++++++++++++++++++++++++++++++- src/du_app/du_e2ap_msg_hdl.h | 2 + src/du_app/du_msg_hdl.c | 9 +++ src/ric_stub/ric_e2ap_msg_hdl.c | 91 ++++++++++++++++++++++ 5 files changed, 292 insertions(+), 11 deletions(-) diff --git a/src/du_app/du_e2ap_mgr.c b/src/du_app/du_e2ap_mgr.c index ed0d8187c..eabc0d6b2 100644 --- a/src/du_app/du_e2ap_mgr.c +++ b/src/du_app/du_e2ap_mgr.c @@ -1494,24 +1494,40 @@ uint8_t e2ProcStatsDeleteRsp(MacStatsDeleteRsp *statsDeleteRsp) * in statistics delete response */ if(fetchSubsInfoFromSubsId(statsDeleteRsp->subscriptionId, &ranFuncDb, &ricSubscriptionNode, &ricSubscriptionInfo) != ROK) { - DU_LOG("\nERROR --> E2AP : extractStatsMeasurement: Failed to fetch subscriprtion details"); + DU_LOG("\nERROR --> E2AP : e2ProcStatsDeleteRsp: Failed to fetch subscriprtion details"); return RFAILED; } deleteRicSubscriptionNode(ricSubscriptionNode); -#if 0 - /* TODO */ - if(statsDeleteRsp->result == MAC_DU_APP_RSP_NOK && statsDeleteRsp->status == STATS_ID_NOT_FOUND) + + if(statsDeleteRsp->result == MAC_DU_APP_RSP_NOK) { - failureCause->causeType =E2_RIC_REQUEST; - failureCause->cause = E2_REQUEST_INFORMATION_UNAVAILABLE; - BuildAndSendRicSubscriptionDeleteFailure(ricSubscriptionInfo->ranFuncId, ricSubscriptionInfo->requestId, failureCause); + if(statsDeleteRsp->status == STATS_ID_NOT_FOUND) + { + failureCause.causeType =E2_RIC_REQUEST; + failureCause.cause = E2_REQUEST_INFORMATION_UNAVAILABLE; + } + else + { + failureCause.causeType = E2_MISCELLANEOUS; + failureCause.cause = E2_MISCELLANEOUS_CAUSE_UNSPECIFIED; + } + + if(BuildAndSendRicSubscriptionDeleteFailure(ricSubscriptionInfo->ranFuncId, ricSubscriptionInfo->requestId, failureCause) != ROK) + { + DU_LOG("\nERROR --> E2AP : e2ProcStatsDeleteRsp: failed to build and send ric subs delete failure"); + return RFAILED; + } } else { - BuildAndSendRicSubscriptionDeleteResponse(ricSubscriptionInfo->ranFuncId, ricSubscriptionInfo->requestId); + if(BuildAndSendRicSubscriptionDeleteResponse(ricSubscriptionInfo->ranFuncId, ricSubscriptionInfo->requestId) != ROK) + { + DU_LOG("\nERROR --> E2AP : e2ProcStatsDeleteRsp: failed to build and send ric subs delete rsp"); + return RFAILED; + } } -#endif + return ROK; } diff --git a/src/du_app/du_e2ap_msg_hdl.c b/src/du_app/du_e2ap_msg_hdl.c index 8fc58eb51..bddc73b81 100644 --- a/src/du_app/du_e2ap_msg_hdl.c +++ b/src/du_app/du_e2ap_msg_hdl.c @@ -3496,7 +3496,6 @@ uint8_t procRicSubscriptionRequest(E2AP_PDU_t *e2apMsg) /* Send RIC Subcription Failure */ BuildAndSendRicSubscriptionFailure(ricReqId, ranFuncId, failureCause); } - return ret; } @@ -7527,7 +7526,7 @@ uint8_t BuildAndSendRicSubscriptionDeleteRequired() ******************************************************************/ void FreeRicSubscriptionDeleteFailure(E2AP_PDU_t *e2apMsg) { - uint8_t ieIdx = 0, arrIdx = 0; + uint8_t ieIdx = 0; RICsubscriptionDeleteFailure_t *ricSubsDelFailure = NULLP; if(e2apMsg) @@ -7681,6 +7680,170 @@ uint8_t BuildAndSendRicSubscriptionDeleteFailure(uint16_t ranFuncId, RicRequest return ret; } + +/******************************************************************* + * + * @brief Free RIC Subscription Delete Response Message + * + * @details + * + * Function : FreeRicSubscriptionDeleteResponse + * + * Functionality: Free RIC Subscription Delete Response + * + * @param E2AP Message PDU + * @return void + * + ******************************************************************/ +void FreeRicSubscriptionDeleteResponse(E2AP_PDU_t *e2apMsg) +{ + uint8_t ieIdx = 0; + RICsubscriptionDeleteResponse_t *ricSubsDelRsp = NULLP; + + if(e2apMsg) + { + if(e2apMsg->choice.successfulOutcome) + { + ricSubsDelRsp = &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionDeleteResponse; + if(ricSubsDelRsp->protocolIEs.list.array) + { + for(ieIdx = 0; ieIdx < ricSubsDelRsp->protocolIEs.list.count; ieIdx++) + { + DU_FREE(ricSubsDelRsp->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteResponse_IEs_t)); + } + DU_FREE(ricSubsDelRsp->protocolIEs.list.array, ricSubsDelRsp->protocolIEs.list.size); + } + DU_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); + } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));; + } +} + +/******************************************************************* + * + * @brief Builds and Send RIC Subscription delete Response + * + * @details + * + * Function : BuildAndSendRicSubscriptionDeleteResponse + * + * Functionality: Build and send RIC subscription delete Response. + * + * @params[in] + * Ran Func Id + * Ric Req Id + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ +uint8_t BuildAndSendRicSubscriptionDeleteResponse(uint16_t ranFuncId, RicRequestId requestId) +{ + uint8_t elementCnt = 0, ieIdx = 0, ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + RICsubscriptionDeleteResponse_t *ricSubsDelRsp = NULLP; + RICsubscriptionDeleteResponse_IEs_t *ricSubsDelRspIe = NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ + + while(true) + { + DU_LOG("\nINFO --> E2AP : Building RIC Subscription Delete Response Message\n"); + + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) + { + DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__); + break; + } + + e2apMsg->present = E2AP_PDU_PR_successfulOutcome; + DU_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); + if(e2apMsg->choice.successfulOutcome == NULLP) + { + DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__); + break; + } + e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_RICsubscriptionDelete; + e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject; + e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_RICsubscriptionDeleteResponse; + + + ricSubsDelRsp = &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionDeleteResponse; + + elementCnt = 2; + ricSubsDelRsp->protocolIEs.list.count = elementCnt; + ricSubsDelRsp->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionDeleteResponse_IEs_t *); + + DU_ALLOC(ricSubsDelRsp->protocolIEs.list.array, ricSubsDelRsp->protocolIEs.list.size); + if(ricSubsDelRsp->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for array elements at line %d",__func__, __LINE__); + break; + } + + for(ieIdx = 0; ieIdx < elementCnt; ieIdx++) + { + DU_ALLOC(ricSubsDelRsp->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteResponse_IEs_t)); + if(ricSubsDelRsp->protocolIEs.list.array[ieIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for index [%d] at line %d", \ + __func__, ieIdx, __LINE__); + break; + } + } + if(ieIdx < elementCnt) + break; + + ieIdx = 0; + ricSubsDelRspIe = ricSubsDelRsp->protocolIEs.list.array[ieIdx]; + ricSubsDelRspIe->id = ProtocolIE_IDE2_id_RICrequestID; + ricSubsDelRspIe->criticality = CriticalityE2_reject; + ricSubsDelRspIe->value.present = RICsubscriptionDeleteResponse_IEs__value_PR_RICrequestID; + ricSubsDelRspIe->value.choice.RICrequestID.ricRequestorID= requestId.requestorId; + ricSubsDelRspIe->value.choice.RICrequestID.ricInstanceID = requestId.instanceId; + + ieIdx++; + ricSubsDelRspIe = ricSubsDelRsp->protocolIEs.list.array[ieIdx]; + ricSubsDelRspIe->id = ProtocolIE_IDE2_id_RANfunctionID; + ricSubsDelRspIe->criticality = CriticalityE2_reject; + ricSubsDelRspIe->value.present = RICsubscriptionDeleteResponse_IEs__value_PR_RANfunctionID; + ricSubsDelRspIe->value.choice.RANfunctionID = ranFuncId; + + /* Prints the Msg formed */ + xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg); + memset(encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf); + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Delete Response Message (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Subscription Delete Response Message \n"); +#ifdef DEBUG_ASN_PRINT + for(int i=0; i< encBufSize; i++) + { + printf("%x",encBuf[i]); + } +#endif + } + + if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to send RIC Susbcription Delete Response Message"); + break; + } + + ret = ROK; + break; + } + + FreeRicSubscriptionDeleteResponse(e2apMsg); + return ret; +} + /******************************************************************* * * @brief Free RIC Subscription Delete Request Message diff --git a/src/du_app/du_e2ap_msg_hdl.h b/src/du_app/du_e2ap_msg_hdl.h index f19fce371..f61e3057d 100644 --- a/src/du_app/du_e2ap_msg_hdl.h +++ b/src/du_app/du_e2ap_msg_hdl.h @@ -31,6 +31,8 @@ uint8_t BuildAndSendStatsReq(RicSubscription *ricSubscriptionInfo); uint8_t BuildAndSendRicSubscriptionRsp(PendingSubsRspInfo *subsRspInfo); uint8_t BuildAndSendRicSubscriptionFailure(RicRequestId ricReqId, uint16_t ranFuncId, E2FailureCause failureCause); uint8_t BuildAndSendRicIndication(RicSubscription *ricSubscriptionInfo, ActionInfo *actionInfo); +uint8_t BuildAndSendRicSubscriptionDeleteResponse(uint16_t ranFuncId, RicRequestId requestId); +uint8_t BuildAndSendRicSubscriptionDeleteFailure(uint16_t ranFuncId, RicRequestId requestId, E2FailureCause failureCause); /********************************************************************** End of file diff --git a/src/du_app/du_msg_hdl.c b/src/du_app/du_msg_hdl.c index 07524c2c9..9f3b50c92 100644 --- a/src/du_app/du_msg_hdl.c +++ b/src/du_app/du_msg_hdl.c @@ -2339,6 +2339,7 @@ uint8_t DuProcMacStatsDeleteRsp(Pst *pst, MacStatsDeleteRsp *statsDeleteRsp) uint8_t BuildAndSendStatsDeleteReqToMac(RicSubscription *ricSubscriptionInfo) { Pst pst; + E2FailureCause failureCause; MacStatsDeleteReq *macStatsDelete = NULLP; /* Fill MAC statistics delete */ @@ -2346,6 +2347,14 @@ uint8_t BuildAndSendStatsDeleteReqToMac(RicSubscription *ricSubscriptionInfo) if(macStatsDelete == NULLP) { DU_LOG("\nERROR --> DU_APP : Memory allocation failed for macStatsDelete in BuildAndSendStatsDeleteReqToMac"); + failureCause.causeType = E2_MISCELLANEOUS; + failureCause.cause = E2_MISCELLANEOUS_CAUSE_UNSPECIFIED; + + if(BuildAndSendRicSubscriptionDeleteFailure(ricSubscriptionInfo->ranFuncId, ricSubscriptionInfo->requestId, failureCause) != ROK) + { + DU_LOG("\nERROR --> E2AP : e2ProcStatsDeleteRsp: failed to build and send ric subs delete failure"); + return RFAILED; + } return RFAILED; } diff --git a/src/ric_stub/ric_e2ap_msg_hdl.c b/src/ric_stub/ric_e2ap_msg_hdl.c index 86129983c..f9540ce22 100644 --- a/src/ric_stub/ric_e2ap_msg_hdl.c +++ b/src/ric_stub/ric_e2ap_msg_hdl.c @@ -7134,6 +7134,92 @@ void ProcRicSubsDeleteFailure(RICsubscriptionDeleteFailure_t *ricSubsDeleteFail) } } + +/****************************************************************** + * + * @brief Processes the Ric Subs delete rsp msg + * + * @details + * + * Function : ProcRicSubsDeleteRsp + * + * Functionality: Processes the Ric Subs delete rsp msg + * + * @params[in] + * Ric Subs delete rsp information + * + * @return void + * + * ****************************************************************/ +void ProcRicSubsDeleteRsp(uint32_t duId, RICsubscriptionDeleteResponse_t *ricSubsDeleteRsp) +{ + uint8_t ieIdx = 0; + uint8_t duIdx= 0; + uint16_t ranFuncId=0; + RanFunction *ranFuncDb = NULLP; + RicRequestId ricReqId; + DuDb *duDb = NULLP; + RicSubscription *ricSubs = NULLP; + CmLList *ricSubsNode = NULLP; + + SEARCH_DU_DB(duIdx, duId, duDb); + if(duDb == NULLP) + { + DU_LOG("\nERROR --> E2AP : duDb is not present for duId %d",duId); + return; + } + + if(!ricSubsDeleteRsp) + { + DU_LOG("\nERROR --> E2AP : ricSubsDeleteRsp pointer is null"); + return; + } + + if(!ricSubsDeleteRsp->protocolIEs.list.array) + { + DU_LOG("\nERROR --> E2AP : ricSubsDeleteRsp array pointer is null"); + return; + } + for(ieIdx=0; ieIdx < ricSubsDeleteRsp->protocolIEs.list.count; ieIdx++) + { + if(ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]) + { + switch(ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]->id) + { + case ProtocolIE_IDE2_id_RICrequestID: + { + ricReqId.requestorId = ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]->value.choice.RICrequestID.ricRequestorID; + ricReqId.instanceId = ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]->value.choice.RICrequestID.ricInstanceID; + break; + } + case ProtocolIE_IDE2_id_RANfunctionID: + { + ranFuncId = ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]->value.choice.RANfunctionID; + ranFuncDb = fetchRanFuncFromRanFuncId(duDb, ranFuncId); + if(!ranFuncDb) + { + DU_LOG("\nERROR --> E2AP : Invalid Ran Function id %d received",ranFuncId); + return; + } + + ricSubs = fetchSubsInfoFromRicReqId(ricReqId, ranFuncDb, &ricSubsNode); + if(ricSubs) + { + deleteRicSubscriptionNode(ricSubsNode); + DU_LOG("\nINFO --> E2AP : Ric subscription node deleted successfully"); + } + else + { + DU_LOG("\nERROR --> E2AP : Ric subscription node is not present "); + return; + } + break; + } + } + } + } +} + /******************************************************************* * * @brief Handles received E2AP message and sends back response @@ -7297,6 +7383,11 @@ void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf) ProcE2ConnectionUpdateAck(*duId, &e2apMsg->choice.successfulOutcome->value.choice.E2connectionUpdateAcknowledge); break; } + case SuccessfulOutcomeE2__value_PR_RICsubscriptionDeleteResponse: + { + ProcRicSubsDeleteRsp(*duId, &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionDeleteResponse); + break; + } default: { DU_LOG("\nERROR --> E2AP : Invalid type of successfulOutcome message [%d]", \ -- 2.16.6