X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fdu_app%2Fdu_e2ap_msg_hdl.c;h=ece43c87beba5f7250c8220a59965d33c2b3793d;hb=refs%2Fchanges%2F63%2F11863%2F5;hp=2041f9bc844421fcc37bf7299919863ccc318dac;hpb=44eab7aaa4e6b2f7e5f2338979e64164eee7d536;p=o-du%2Fl2.git diff --git a/src/du_app/du_e2ap_msg_hdl.c b/src/du_app/du_e2ap_msg_hdl.c index 2041f9bc8..ece43c87b 100644 --- a/src/du_app/du_e2ap_msg_hdl.c +++ b/src/du_app/du_e2ap_msg_hdl.c @@ -119,41 +119,98 @@ void fillE2Cause(CauseE2_t *e2Cause, E2FailureCause failureCause) /******************************************************************* * - * @brief Free the ErrorIndication Message + * @brief Printing Type and Cause of failure * * @details * - * Function : FreeRicIndication + * Function : printE2ErrorCause * - * Functionality: Free the ErrorIndication Message + * Functionality: Printing Type and Cause of failure * - * @params[in] - * E2AP_PDU is to freed + * @params[in] E2 Cause * @return void * ******************************************************************/ -void FreeErrorIndication(E2AP_PDU_t *e2apMsg) +void printE2ErrorCause(CauseE2_t *cause) { - uint8_t arrIdx = 0; - ErrorIndicationE2_t *errorIndicationMsg= NULLP; + switch(cause->present) + { + case CauseE2_PR_ricRequest: + { + DU_LOG("Failure_Type [%s] Cause [%ld]", "RIC_Request", cause->choice.ricRequest); + break; + } + case CauseE2_PR_ricService: + { + DU_LOG("Failure_Type [%s] Cause [%ld]", "RIC_Service", cause->choice.ricService); + break; + } + case CauseE2_PR_e2Node: + { + DU_LOG("Failure_Type [%s] Cause [%ld]", "E2_Node", cause->choice.e2Node); + break; + } + case CauseE2_PR_transport: + { + DU_LOG("Failure_Type [%s] Cause [%ld]", "Transport", cause->choice.transport); + break; + } + case CauseE2_PR_protocol: + { + DU_LOG("Failure_Type [%s] Cause [%ld]", "Protocol", cause->choice.protocol); + break; + } + case CauseE2_PR_misc: + { + DU_LOG("Failure_Type [%s] Cause [%ld]", "Miscellaneous", cause->choice.misc); + break; + } + default: + { + DU_LOG("Failure_Type and Cause unknown"); + break; + } + } +} + +/******************************************************************* + * + * @brief Deallocate the memory allocated for E2 Removal Failure + * + * @details + * + * Function : FreeE2RemovalFailure + * + * Functionality: + * - freeing the memory allocated for E2RemovalFailure + * + * @params[in] E2AP_PDU_t *e2apMsg + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void FreeE2RemovalFailure(E2AP_PDU_t *e2apMsg) +{ + uint8_t ieIdx =0; + E2RemovalFailure_t *e2RemovalFailure=NULLP; if(e2apMsg != NULLP) { - if(e2apMsg->choice.initiatingMessage != NULLP) + if(e2apMsg->choice.unsuccessfulOutcome != NULLP) { - errorIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.ErrorIndicationE2; - if(errorIndicationMsg!= NULLP) + e2RemovalFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2RemovalFailure; + if(e2RemovalFailure->protocolIEs.list.array) { - if(errorIndicationMsg->protocolIEs.list.array != NULLP) + for(ieIdx=0; ieIdx < e2RemovalFailure->protocolIEs.list.count; ieIdx++) { - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + if(e2RemovalFailure->protocolIEs.list.array[ieIdx]) { - DU_FREE(errorIndicationMsg->protocolIEs.list.array[arrIdx],sizeof(ErrorIndicationE2_t)); + DU_FREE(e2RemovalFailure->protocolIEs.list.array[ieIdx], sizeof(E2RemovalFailureIEs_t)); } - DU_FREE(errorIndicationMsg->protocolIEs.list.array,errorIndicationMsg->protocolIEs.list.size); } + DU_FREE(e2RemovalFailure->protocolIEs.list.array, e2RemovalFailure->protocolIEs.list.size); } - DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + DU_FREE(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t)); } DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } @@ -161,1247 +218,1658 @@ void FreeErrorIndication(E2AP_PDU_t *e2apMsg) /******************************************************************* * - * @brief Builds and Send the ErrorIndication Message + * @brief Buld and send the E2 Removal Failure msg * * @details * - * Function : BuildAndSendErrorIndication - * - * Functionality:Fills the ErrorIndication Message + * Function : BuildAndSendE2RemovalFailure * - * @params[in] - * Trans id - * Ric req id - * Ran function id - * Cause of failure + * Functionality: + * - Buld and send the E2 Removal Failure Message + * @params[in] Trans Id * @return ROK - success * RFAILED - failure * - ******************************************************************/ + * ****************************************************************/ -uint8_t BuildAndSendErrorIndication(int8_t transId, RicRequestId requestId, uint16_t ranFuncId, E2FailureCause failureCause) +uint8_t BuildAndSendRemovalFailure(uint8_t transId, E2FailureCause failureCause) { - uint8_t elementCnt =0, arrIdx=0, ret = RFAILED; - E2AP_PDU_t *e2apMsg = NULLP; - ErrorIndicationE2_t *errorIndicationMsg=NULLP; - asn_enc_rval_t encRetVal; /* Encoder return value */ + uint8_t ieIdx = 0, elementCnt = 0; + uint8_t ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + E2RemovalFailure_t *e2RemovalFailure=NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ - while(true) + DU_LOG("\nINFO --> E2AP : Building E2 Removal Failure Message\n"); + do { - DU_LOG("\nINFO --> E2AP : Building Error Indication Message\n"); - DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); if(e2apMsg == NULLP) { - DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed in %s at line %d",__func__, __LINE__); + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); break; } + e2apMsg->present = E2AP_PDU_PR_unsuccessfulOutcome; - e2apMsg->present = E2AP_PDU_PR_initiatingMessage; - DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); - if(e2apMsg->choice.initiatingMessage == NULLP) + DU_ALLOC(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t)); + if(e2apMsg->choice.unsuccessfulOutcome == NULLP) { - DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed in %s at line %d",__func__, __LINE__); + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); break; } - e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_ErrorIndicationE2; - e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; - e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ErrorIndicationE2; - errorIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.ErrorIndicationE2; - - /* Element count is 2 for TransactionID/RICrequestID and Cause. - * If the RAN function id is present, the count will be increased.*/ - elementCnt = 2; - if(ranFuncId>0) - { - elementCnt++; - } - - errorIndicationMsg->protocolIEs.list.count = elementCnt; - errorIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(ErrorIndicationE2_IEs_t*); + e2apMsg->choice.unsuccessfulOutcome->procedureCode = ProcedureCodeE2_id_E2removal; + e2apMsg->choice.unsuccessfulOutcome->criticality = CriticalityE2_reject; + e2apMsg->choice.unsuccessfulOutcome->value.present = UnsuccessfulOutcomeE2__value_PR_E2RemovalFailure; + e2RemovalFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2RemovalFailure; - /* Initialize the E2Setup members */ - DU_ALLOC(errorIndicationMsg->protocolIEs.list.array, errorIndicationMsg->protocolIEs.list.size); - if(errorIndicationMsg->protocolIEs.list.array == NULLP) + elementCnt = 2; + e2RemovalFailure->protocolIEs.list.count = elementCnt; + e2RemovalFailure->protocolIEs.list.size = elementCnt * sizeof(E2RemovalFailureIEs_t *); + DU_ALLOC(e2RemovalFailure->protocolIEs.list.array, e2RemovalFailure->protocolIEs.list.size); + if(!e2RemovalFailure->protocolIEs.list.array) { - DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements in %s at line %d",__func__, __LINE__); + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); break; } - - for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++) + + for(ieIdx=0; ieIdx < elementCnt; ieIdx++) { - DU_ALLOC(errorIndicationMsg->protocolIEs.list.array[arrIdx], sizeof(ErrorIndicationE2_IEs_t)); - if(errorIndicationMsg->protocolIEs.list.array[arrIdx] == NULLP) + DU_ALLOC(e2RemovalFailure->protocolIEs.list.array[ieIdx], sizeof(E2RemovalFailureIEs_t)); + if(!e2RemovalFailure->protocolIEs.list.array[ieIdx]) { - DU_LOG("\nERROR --> E2AP : Memory allocation failed for array [%d] elements in %s at line %d", arrIdx, __func__, __LINE__); + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); break; } } - if(arrIdx < elementCnt) + if(ieIdx < elementCnt) break; - arrIdx = 0; - - if(transId >=0 && transId<=255) - { - /* TransactionID */ - errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_TransactionID; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; - } - else - { - /* RICrequestID */ - errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RICrequestID; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_RICrequestID; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RICrequestID.ricRequestorID = requestId.requestorId; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RICrequestID.ricInstanceID = requestId.instanceId; - } - - if(ranFuncId>0) - { - /* RAN Function ID */ - arrIdx++; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionID; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_RANfunctionID; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionID = ranFuncId; - } + ieIdx = 0; + e2RemovalFailure->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID; + e2RemovalFailure->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject; + e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.present = E2RemovalFailureIEs__value_PR_TransactionID; + e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId; /* Cause */ - arrIdx++; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_CauseE2; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_ignore; - errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_CauseE2; - fillE2Cause(&errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.CauseE2, failureCause); - - /* Prints the Msg formed */ + ieIdx++; + e2RemovalFailure->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_CauseE2; + e2RemovalFailure->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_ignore; + e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.present = ErrorIndicationE2_IEs__value_PR_CauseE2; + fillE2Cause(&e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.choice.CauseE2, failureCause); + 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); + encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf); if(encRetVal.encoded == ENCODE_FAIL) { - DU_LOG("\nERROR --> E2AP : Could not encode Error Indication Message (at %s)\n",\ + DU_LOG("\nERROR --> E2AP : Could not encode E2 removal failure structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); break; } else { - DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for Error Indication Message \n"); -#ifdef DEBUG_ASN_PRINT + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2 Removal Failure \n"); for(int i=0; i< encBufSize; i++) { - printf("%x",encBuf[i]); - } -#endif + DU_LOG("%x",encBuf[i]); + } } + /* Sending msg */ if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK) { - DU_LOG("\nINFO --> E2AP : Sending Error Indication Message"); - + DU_LOG("\nERROR --> E2AP : Failed to send E2 Removal Failure"); + break; } + ret = ROK; break; - } - FreeErrorIndication(e2apMsg); + }while(true); + + FreeE2RemovalFailure(e2apMsg); return ret; } -/****************************************************************** +/******************************************************************* * - * @brief Deallocation of memory allocated by aper decoder for e2 - * Config Update Failure + * @brief Deallocate the memory allocated for E2 Removal Response * * @details * - * Function : freeAperDecodingOfE2Node Config UpdateFailure + * Function : FreeE2RemovalResponse * - * Functionality: Deallocation of memory allocated by aper decoder - * for e2 Config Update Failure + * Functionality: + * - freeing the memory allocated for E2RemovalResponse * - * @params[in] E2nodeConfigurationUpdateFailure_t to be deallocated - * @return void + * @params[in] E2AP_PDU_t *e2apMsg + * @return ROK - success + * RFAILED - failure * * ****************************************************************/ - -void freeAperDecodingOfE2NodeConfigUpdateFailure(E2nodeConfigurationUpdateFailure_t *e2NodeCfgUpdFail) +void FreeE2RemovalResponse(E2AP_PDU_t *e2apMsg) { - uint8_t arrIdx =0; + uint8_t ieIdx =0; + E2RemovalResponse_t *e2RemovalResponse=NULLP; - if(e2NodeCfgUpdFail) + if(e2apMsg != NULLP) { - if(e2NodeCfgUpdFail->protocolIEs.list.array) + if(e2apMsg->choice.successfulOutcome != NULLP) { - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + e2RemovalResponse = &e2apMsg->choice.successfulOutcome->value.choice.E2RemovalResponse; + if(e2RemovalResponse->protocolIEs.list.array) { - if(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]) + for(ieIdx=0; ieIdx < e2RemovalResponse->protocolIEs.list.count; ieIdx++) { - free(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]); + if(e2RemovalResponse->protocolIEs.list.array[ieIdx]) + { + DU_FREE(e2RemovalResponse->protocolIEs.list.array[ieIdx], sizeof(E2RemovalResponseIEs_t)); + } } + DU_FREE(e2RemovalResponse->protocolIEs.list.array, e2RemovalResponse->protocolIEs.list.size); } - free(e2NodeCfgUpdFail->protocolIEs.list.array); + DU_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } } -/****************************************************************** +/******************************************************************* * - * @brief Processes E2 Node Config Update Failure sent by RIC + * @brief Buld and send the E2 Removal Response msg * * @details * - * Function : procE2NodeConfigUpdateFailure - * - * Functionality: Processes E2 Node Config Update failure sent by RIC + * Function : BuildAndSendE2RemovalResponse * - * @params[in] E2AP_PDU_t ASN decoded E2AP message + * Functionality: + * - Buld and send the E2 Removal Response Message + * @params[in] Trans Id * @return ROK - success * RFAILED - failure * * ****************************************************************/ - -void procE2NodeConfigUpdateFailure(E2AP_PDU_t *e2apMsg) +uint8_t BuildAndSendRemovalResponse(uint8_t transId) { - uint8_t arrIdx =0, transId =0, timerValue=0; - E2nodeConfigurationUpdateFailure_t *e2NodeCfgUpdFail=NULL; - - DU_LOG("\nINFO --> E2AP : E2 Node Config Update failure received"); - e2NodeCfgUpdFail = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2nodeConfigurationUpdateFailure; + uint8_t ieIdx = 0, elementCnt = 0; + uint8_t ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + E2RemovalResponse_t *e2RemovalResponse=NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + DU_LOG("\nINFO --> E2AP : Building E2 Removal Response Message\n"); + do { - switch(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->id) + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) { - case ProtocolIE_IDE2_id_TransactionID: - { - transId = e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; - if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\ - (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) - { - memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); - } - else - { - DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); - } - break; - } - case ProtocolIE_IDE2_id_TimeToWaitE2: - { - timerValue = convertE2WaitTimerEnumToValue(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); - if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_NODE_CONFIG_UPDATE_TMR)) == FALSE) - { - duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_NODE_CONFIG_UPDATE_TMR, timerValue); - } - else - { - DU_LOG("\nERROR --> E2AP : EVENT_E2_NODE_CONFIG_UPDATE_TMR timer is already running"); - } - break; - } + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); + break; } - } + e2apMsg->present = E2AP_PDU_PR_successfulOutcome; - freeAperDecodingOfE2NodeConfigUpdateFailure(e2NodeCfgUpdFail); + DU_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); + if(e2apMsg->choice.successfulOutcome == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); + break; + } + + e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_E2removal; + e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject; + e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_E2RemovalResponse; + e2RemovalResponse = &e2apMsg->choice.successfulOutcome->value.choice.E2RemovalResponse; + + elementCnt = 1; + e2RemovalResponse->protocolIEs.list.count = elementCnt; + e2RemovalResponse->protocolIEs.list.size = elementCnt * sizeof(E2RemovalResponseIEs_t *); + DU_ALLOC(e2RemovalResponse->protocolIEs.list.array, e2RemovalResponse->protocolIEs.list.size); + if(!e2RemovalResponse->protocolIEs.list.array) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); + break; + } + + for(ieIdx=0; ieIdx < elementCnt; ieIdx++) + { + DU_ALLOC(e2RemovalResponse->protocolIEs.list.array[ieIdx], sizeof(E2RemovalResponseIEs_t)); + if(!e2RemovalResponse->protocolIEs.list.array[ieIdx]) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); + break; + } + } + if(ieIdx < elementCnt) + break; + + ieIdx = 0; + e2RemovalResponse->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID; + e2RemovalResponse->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject; + e2RemovalResponse->protocolIEs.list.array[ieIdx]->value.present = E2RemovalResponseIEs__value_PR_TransactionID; + e2RemovalResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId; + + 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 E2 removal response structure (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2 Removal Response \n"); + for(int i=0; i< encBufSize; i++) + { + DU_LOG("%x",encBuf[i]); + } + } + + /* Sending msg */ + if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to send E2 Removal Response"); + break; + } + + ret = ROK; + break; + }while(true); + + FreeE2RemovalResponse(e2apMsg); + return ret; } -/******************************************************************* +/****************************************************************** * - * @brief Builds Global gNodeB Params + * @brief Deallocation of memory allocated by aper decoder for Removal req * * @details * - * Function : BuildGlobalgNBId + * Function : freeAperDecodingOfE2RemovalReq * - * Functionality: Building the Plmn and gNB id + * Functionality: Deallocation of memory allocated by aper decoder for + * Removal req * - * @params[in] GlobalE2node_gNB_ID_t *gNbId - * @return ROK - success - * RFAILED - failure + * @params[in] Pointer to removalReq + * @return void * - ******************************************************************/ - -uint8_t BuildGlobalgNBId(GlobalE2node_gNB_ID_t *gNbId) + * ****************************************************************/ +void freeAperDecodingOfE2RemovalReq(E2RemovalRequest_t *removalReq) { - uint8_t unused = 0; - uint8_t byteSize = 4; - uint8_t gnbId = duCb.gnbId; - uint8_t ret = ROK; - - /* fill Global gNB ID Id */ - gNbId->global_gNB_ID.plmn_id.size = 3 * sizeof(uint8_t); - gNbId->global_gNB_ID.plmn_id.buf = NULLP; - DU_ALLOC(gNbId->global_gNB_ID.plmn_id.buf , gNbId->global_gNB_ID.plmn_id.size); - if(gNbId->global_gNB_ID.plmn_id.buf == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for Plmn buffer"); - ret = RFAILED; - } - else - { - buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \ - gNbId->global_gNB_ID.plmn_id.buf); - gNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID; - /* Allocate Buffer size */ - gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = byteSize * sizeof(uint8_t); - gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf = NULLP; - DU_ALLOC(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf, \ - gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size); - if(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for gnb buffer"); - ret = RFAILED; - } - else - { - fillBitString(&gNbId->global_gNB_ID.gnb_id.choice.gnb_ID, unused, byteSize, gnbId); - } - } + uint8_t arrIdx=0; - /* fill gNB-DU ID */ - DU_ALLOC( gNbId->gNB_DU_ID, sizeof(GNB_DU_ID_t)); - if(gNbId->gNB_DU_ID == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for gNB_DU_ID "); - ret = RFAILED; - } - else + if(removalReq) { - gNbId->gNB_DU_ID->size = sizeof(uint8_t); - DU_ALLOC( gNbId->gNB_DU_ID->buf, sizeof(uint8_t)); - if(gNbId->gNB_DU_ID->buf) - { - gNbId->gNB_DU_ID->buf[0] =duCb.e2apDb.e2NodeId; - } - else + if(removalReq->protocolIEs.list.array) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for gNB_DU_ID buffer"); - ret = RFAILED; + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + if(removalReq->protocolIEs.list.array[arrIdx]) + { + free(removalReq->protocolIEs.list.array[arrIdx]); + } + } + free(removalReq->protocolIEs.list.array); } } - - return ret; } /******************************************************************* * - * @brief fill the E2 node config information + * @brief Process Removal req received from RIC * * @details * - * Function : fillE2NodeConfig + * Function : procE2RemovalRequest * - * Functionality: fill E2 node config information + * Functionality: Process Removal req received from RIC * - * @params[in] - * Pointer to e2NodeCfg to be filled - * E2 Node Component information - * Type of configuration - * @return ROK - success - * RFAILED - failure + * @param E2AP_PDU_t *e2apMsg + * @return void * ******************************************************************/ -uint8_t fillE2NodeConfig(PTR e2NodeCfg, E2NodeComponent *e2NodeComponentInfo, ConfigType configType) +void procE2RemovalRequest(E2AP_PDU_t *e2apMsg) { - E2nodeComponentInterfaceType_t *interfaceType=NULLP; - E2nodeComponentID_t *componentID =NULLP; - E2nodeComponentConfiguration_t *configuration=NULLP; - E2nodeComponentConfigAddition_Item_t *e2NodeAddItem=NULL; - E2nodeComponentConfigUpdate_Item_t *e2NodeUpdateItem =NULL; - E2nodeComponentConfigRemoval_Item_t *e2NodeRemovalItem=NULL; + uint8_t arrIdx =0, transId =0, count =0; + E2FailureCause failureCause; + E2RemovalRequest_t *removalReq=NULLP; + + DU_LOG("\nINFO --> E2AP : E2 Removal request received"); + removalReq = &e2apMsg->choice.initiatingMessage->value.choice.E2RemovalRequest; - switch(configType) + count =removalReq->protocolIEs.list.count; + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) { - case CONFIG_ADD: - { - e2NodeAddItem = (E2nodeComponentConfigAddition_Item_t*)e2NodeCfg; - interfaceType = &e2NodeAddItem->e2nodeComponentInterfaceType; - componentID = &e2NodeAddItem->e2nodeComponentID; - configuration = &e2NodeAddItem->e2nodeComponentConfiguration; - break; - } - case CONFIG_MOD: - { - e2NodeUpdateItem = (E2nodeComponentConfigUpdate_Item_t *) e2NodeCfg; - interfaceType = &e2NodeUpdateItem->e2nodeComponentInterfaceType; - componentID = &e2NodeUpdateItem->e2nodeComponentID; - configuration = &e2NodeUpdateItem->e2nodeComponentConfiguration; - break; - } - case CONFIG_DEL: - { - e2NodeRemovalItem = (E2nodeComponentConfigRemoval_Item_t*) e2NodeCfg; - interfaceType = &e2NodeRemovalItem->e2nodeComponentInterfaceType; - componentID = &e2NodeRemovalItem->e2nodeComponentID; - break; - } - default: + switch(removalReq->protocolIEs.list.array[arrIdx]->id) { - DU_LOG("\nERROR --> E2AP : Configuration type %d does not supported ", configType); - return RFAILED; + case ProtocolIE_IDE2_id_TransactionID: + { + transId = removalReq->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + break; + } + default: + { + DU_LOG("\nERROR --> E2AP : Invalid IE recevied [%d]", transId); + break; + } } } - /* E2nodeComponentInterfaceType */ - *interfaceType = convertInterfaceToE2ComponentInterfaceType(e2NodeComponentInfo->interfaceType); - - /* We now only support the F1 interface out of these interfaces - * (NG,XN,E1,F1,W1,S1,X2), therefore only the F1 component identifier was filled in. */ - if(*interfaceType == F1) - { - /* E2 Node Component ID */ - componentID->present = E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1; - DU_ALLOC(componentID->choice.e2nodeComponentInterfaceTypeF1,sizeof(E2nodeComponentInterfaceF1_t)); - if(componentID->choice.e2nodeComponentInterfaceTypeF1 == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); - return RFAILED; - } - componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size = sizeof(uint8_t); - DU_ALLOC(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\ - componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); - - if(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); - return RFAILED; - } - memcpy(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf, &e2NodeComponentInfo->componentId,\ - componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); - } - - if(configType == CONFIG_DEL) - { - /* We don't need to fill out the E2 Node Component Request and Response - * information in the case of CONFIG_DEL, therefore returning ROK from here. */ - return ROK; - } - - /* E2 Node Component Request Part */ - if(e2NodeComponentInfo->componentRequestPart) + if(transId>=0 && transId<=255) { - configuration->e2nodeComponentRequestPart.size = e2NodeComponentInfo->reqBufSize ; - DU_ALLOC(configuration->e2nodeComponentRequestPart.buf,\ - configuration->e2nodeComponentRequestPart.size); - if(configuration->e2nodeComponentRequestPart.buf == NULLP) + if(BuildAndSendRemovalResponse(transId) != ROK) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP : Failed to build and send Removal response"); } - - memcpy(configuration->e2nodeComponentRequestPart.buf,\ - e2NodeComponentInfo->componentRequestPart, configuration->\ - e2nodeComponentRequestPart.size); } else { - DU_LOG("\nERROR --> E2AP: componentRequestPart is null "); - return RFAILED; - } + failureCause.causeType = E2_PROTOCOL; + failureCause.cause = E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE; - /* E2 Node Component Response Part */ - if(e2NodeComponentInfo->componentResponsePart) - { - configuration->e2nodeComponentResponsePart.size = e2NodeComponentInfo->rspBufSize; - DU_ALLOC(configuration->e2nodeComponentResponsePart.buf, configuration->e2nodeComponentResponsePart.size); - if(configuration->e2nodeComponentResponsePart.buf == NULLP) + if(BuildAndSendRemovalFailure(transId, failureCause) != ROK) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP : Failed to build and send Removal response"); } - memcpy(configuration->e2nodeComponentResponsePart.buf, e2NodeComponentInfo->componentResponsePart, configuration->\ - e2nodeComponentResponsePart.size); - } - else - { - DU_LOG("\nERROR --> E2AP: componentResponsePart is null"); - return RFAILED; } - - return ROK; + freeAperDecodingOfE2RemovalReq(removalReq); } /******************************************************************* * - * @brief Builds E2 node config addition list + * @brief Free the ErrorIndication Message * * @details * - * Function : BuildE2NodeConfigAddList + * Function : FreeRicIndication * - * Functionality: Building E2 node config addition list + * Functionality: Free the ErrorIndication Message * * @params[in] - * E2nodeComponentConfigAddition_List_t to be filled - * Procedure Code - * Count of E2 node to be added in the list - * Received list of E2 node configuration - * - * @return ROK - success - * RFAILED - failure + * E2AP_PDU is to freed + * @return void * ******************************************************************/ - -uint8_t BuildE2NodeConfigAddList(E2nodeComponentConfigAddition_List_t *e2NodeAddList, uint8_t procedureCode, uint16_t count, E2NodeConfigItem *e2NodeList) +void FreeErrorIndication(E2AP_PDU_t *e2apMsg) { uint8_t arrIdx = 0; - CmLList *node =NULL; - E2NodeComponent *e2NodeComponentInfo=NULL; - E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItemIe=NULL; - E2nodeComponentConfigAddition_Item_t *e2NodeAddItem=NULL; - - - /* For ProcedureCodeE2_id_E2setup, the number of E2 node configuration list items is - * equal to the number of E2 node configuration entries stored in the database. - * For any other procedure, the E2 node configuration list count is equal - * to the count of E2 node configuration obtained from the function's caller */ - - if(procedureCode == ProcedureCodeE2_id_E2setup) - e2NodeAddList->list.count = duCb.e2apDb.e2NodeComponentList.count; - else - e2NodeAddList->list.count = count; - - e2NodeAddList->list.size = e2NodeAddList->list.count * sizeof(E2nodeComponentConfigAddition_ItemIEs_t *); - DU_ALLOC(e2NodeAddList->list.array, e2NodeAddList->list.size); - if(e2NodeAddList->list.array == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); - return RFAILED; - } + ErrorIndicationE2_t *errorIndicationMsg= NULLP; - for(arrIdx = 0; arrIdx< e2NodeAddList->list.count; arrIdx++) + if(e2apMsg != NULLP) { - DU_ALLOC(e2NodeAddList->list.array[arrIdx], sizeof(E2nodeComponentConfigAddition_ItemIEs_t)); - if(e2NodeAddList->list.array[arrIdx] == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); - return RFAILED; - } - - if(procedureCode == ProcedureCodeE2_id_E2setup) + if(e2apMsg->choice.initiatingMessage != NULLP) { - /* Getting all of the E2 node configuration's information from DuCb one by one*/ - if(arrIdx == 0) - { - CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node); - } - else - { - node = node->next; - } - if(!node) + errorIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.ErrorIndicationE2; + if(errorIndicationMsg!= NULLP) { - DU_LOG("\nERROR --> E2AP : E2 node component list node is null"); - return RFAILED; + if(errorIndicationMsg->protocolIEs.list.array != NULLP) + { + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + DU_FREE(errorIndicationMsg->protocolIEs.list.array[arrIdx],sizeof(ErrorIndicationE2_t)); + } + DU_FREE(errorIndicationMsg->protocolIEs.list.array,errorIndicationMsg->protocolIEs.list.size); + } } - e2NodeComponentInfo = (E2NodeComponent*)node->node; - } - else - { - /* Getting only those E2 node configuration from DuCb whose interface - * and action type is present in the received array */ - e2NodeComponentInfo = fetchE2NodeComponentInfo(e2NodeList[arrIdx].interface, e2NodeList[arrIdx].actionType, &node); - } - - if(!e2NodeComponentInfo) - { - DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); - return RFAILED; - } - - e2NodeAddItemIe = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[arrIdx]; - e2NodeAddItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition_Item; - e2NodeAddItemIe->criticality = CriticalityE2_reject; - e2NodeAddItemIe->value.present = E2nodeComponentConfigAddition_ItemIEs__value_PR_E2nodeComponentConfigAddition_Item; - e2NodeAddItem = &e2NodeAddItemIe->value.choice.E2nodeComponentConfigAddition_Item; - if(fillE2NodeConfig((PTR)e2NodeAddItem, e2NodeComponentInfo, CONFIG_ADD) != ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); - return RFAILED; + DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } - return ROK; } /******************************************************************* * - * @brief Builds E2 node config update list + * @brief Builds and Send the ErrorIndication Message * * @details * - * Function : BuildE2NodeConfigUpdateList + * Function : BuildAndSendErrorIndication * - * Functionality: Building E2 node config update list + * Functionality:Fills the ErrorIndication Message * * @params[in] - * E2nodeComponentConfigUpdate_List_t to be filled - * Count of E2 node to be update in the list - * Received list of E2 node configuration - * + * Trans id + * Ric req id + * Ran function id + * Cause of failure * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t BuildE2NodeConfigUpdateList(E2nodeComponentConfigUpdate_List_t *e2NodeUpdateList, uint16_t count, E2NodeConfigItem *updateE2Node) +uint8_t BuildAndSendErrorIndication(int8_t transId, RicRequestId requestId, uint16_t ranFuncId, E2FailureCause failureCause) { - uint8_t arrIdx = 0; - CmLList *node =NULL; - E2NodeComponent *e2NodeComponentInfo =NULL; - E2nodeComponentConfigUpdate_ItemIEs_t *e2NodeUpdateItemIe =NULL; - E2nodeComponentConfigUpdate_Item_t *e2NodeUpdateItem =NULL; + uint8_t elementCnt =0, arrIdx=0, ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + ErrorIndicationE2_t *errorIndicationMsg=NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ - e2NodeUpdateList->list.count = count; - e2NodeUpdateList->list.size = e2NodeUpdateList->list.count * sizeof(E2nodeComponentConfigUpdate_ItemIEs_t *); - DU_ALLOC(e2NodeUpdateList->list.array, e2NodeUpdateList->list.size); - if(e2NodeUpdateList->list.array == NULLP) + while(true) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigUpdateList %d",__LINE__); - return RFAILED; - } + DU_LOG("\nINFO --> E2AP : Building Error Indication Message\n"); - for(arrIdx = 0; arrIdx< e2NodeUpdateList->list.count; arrIdx++) - { - DU_ALLOC(e2NodeUpdateList->list.array[arrIdx], sizeof(E2nodeComponentConfigUpdate_ItemIEs_t)); - if(e2NodeUpdateList->list.array[arrIdx] == NULLP) + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigUpdateList %d",__LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed in %s at line %d",__func__, __LINE__); + break; } - e2NodeComponentInfo= fetchE2NodeComponentInfo(updateE2Node[arrIdx].interface, updateE2Node[arrIdx].actionType, &node); - if(!e2NodeComponentInfo) + e2apMsg->present = E2AP_PDU_PR_initiatingMessage; + DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + if(e2apMsg->choice.initiatingMessage == NULLP) { - DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed in %s at line %d",__func__, __LINE__); + break; } + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_ErrorIndicationE2; + e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; + e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ErrorIndicationE2; - e2NodeUpdateItemIe = (E2nodeComponentConfigUpdate_ItemIEs_t *) e2NodeUpdateList->list.array[arrIdx]; - e2NodeUpdateItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate_Item; - e2NodeUpdateItemIe->criticality = CriticalityE2_reject; - e2NodeUpdateItemIe->value.present = E2nodeComponentConfigUpdate_ItemIEs__value_PR_E2nodeComponentConfigUpdate_Item; - e2NodeUpdateItem = &e2NodeUpdateItemIe->value.choice.E2nodeComponentConfigUpdate_Item; + errorIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.ErrorIndicationE2; + + /* Element count is 2 for TransactionID/RICrequestID and Cause. + * If the RAN function id is present, the count will be increased.*/ + elementCnt = 2; + if(ranFuncId>0) + { + elementCnt++; + } + + errorIndicationMsg->protocolIEs.list.count = elementCnt; + errorIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(ErrorIndicationE2_IEs_t*); - if(fillE2NodeConfig((PTR)e2NodeUpdateItem, e2NodeComponentInfo, CONFIG_MOD) != ROK) + /* Initialize the E2Setup members */ + DU_ALLOC(errorIndicationMsg->protocolIEs.list.array, errorIndicationMsg->protocolIEs.list.size); + if(errorIndicationMsg->protocolIEs.list.array == NULLP) { - DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); - return RFAILED; + DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements in %s at line %d",__func__, __LINE__); + break; + } + + for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++) + { + DU_ALLOC(errorIndicationMsg->protocolIEs.list.array[arrIdx], sizeof(ErrorIndicationE2_IEs_t)); + if(errorIndicationMsg->protocolIEs.list.array[arrIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed for array [%d] elements in %s at line %d", arrIdx, __func__, __LINE__); + break; + } } + if(arrIdx < elementCnt) + break; - } - return ROK; + arrIdx = 0; -} + if(transId >=0 && transId<=255) + { + /* TransactionID */ + errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_TransactionID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; + } + else + { + /* RICrequestID */ + errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RICrequestID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_RICrequestID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RICrequestID.ricRequestorID = requestId.requestorId; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RICrequestID.ricInstanceID = requestId.instanceId; + } + + if(ranFuncId>0) + { + /* RAN Function ID */ + arrIdx++; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_RANfunctionID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionID = ranFuncId; + } + /* Cause */ + arrIdx++; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_CauseE2; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_ignore; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_CauseE2; + fillE2Cause(&errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.CauseE2, failureCause); -/******************************************************************* + /* 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 Error Indication Message (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for Error Indication 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("\nINFO --> E2AP : Sending Error Indication Message"); + + } + ret = ROK; + break; + } + FreeErrorIndication(e2apMsg); + return ret; +} + +/****************************************************************** * - * @brief Builds E2 node config remove list + * @brief Deallocation of memory allocated by aper decoder for e2 + * Config Update Failure * * @details * - * Function :BuildE2NodeConfigRemoveList + * Function : freeAperDecodingOfE2Node Config UpdateFailure * - * Functionality: Building E2 node config remove list + * Functionality: Deallocation of memory allocated by aper decoder + * for e2 Config Update Failure * - * @params[in] - * E2nodeComponentConfigRemoval_List_t to be filled - * Count of E2 node to be remove in the list - * Received list of E2 node configuration - * @return ROK - success - * RFAILED - failure + * @params[in] E2nodeConfigurationUpdateFailure_t to be deallocated + * @return void * - ******************************************************************/ + * ****************************************************************/ -uint8_t BuildE2NodeConfigRemoveList(E2nodeComponentConfigRemoval_List_t *e2NodeRemoveList, uint16_t count, E2NodeConfigItem *updateE2Node) +void freeAperDecodingOfE2NodeConfigUpdateFailure(E2nodeConfigurationUpdateFailure_t *e2NodeCfgUpdFail) { - uint8_t arrIdx = 0; - CmLList *node=NULL; - E2NodeComponent *e2NodeComponentInfo=NULL; - E2nodeComponentConfigRemoval_ItemIEs_t *e2NodeRemovalItemIe=NULL; - E2nodeComponentConfigRemoval_Item_t *e2NodeRemovalItem=NULL; - - e2NodeRemoveList->list.count = count; - e2NodeRemoveList->list.size = e2NodeRemoveList->list.count * sizeof(E2nodeComponentConfigRemoval_ItemIEs_t *); - DU_ALLOC(e2NodeRemoveList->list.array, e2NodeRemoveList->list.size); - if(e2NodeRemoveList->list.array == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigRemoveList %d",__LINE__); - return RFAILED; - } + uint8_t arrIdx =0; - for(arrIdx = 0; arrIdx< e2NodeRemoveList->list.count; arrIdx++) + if(e2NodeCfgUpdFail) { - DU_ALLOC(e2NodeRemoveList->list.array[arrIdx], sizeof(E2nodeComponentConfigRemoval_ItemIEs_t)); - if(e2NodeRemoveList->list.array[arrIdx] == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigRemoveList %d",__LINE__); - return RFAILED; - } - - e2NodeComponentInfo= fetchE2NodeComponentInfo(updateE2Node[arrIdx].interface, updateE2Node[arrIdx].actionType, &node); - if(!e2NodeComponentInfo) - { - DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); - return RFAILED; - } - - e2NodeRemovalItemIe = (E2nodeComponentConfigRemoval_ItemIEs_t *) e2NodeRemoveList->list.array[arrIdx]; - e2NodeRemovalItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval_Item; - e2NodeRemovalItemIe->criticality = CriticalityE2_reject; - e2NodeRemovalItemIe->value.present = E2nodeComponentConfigRemoval_ItemIEs__value_PR_E2nodeComponentConfigRemoval_Item; - e2NodeRemovalItem = &e2NodeRemovalItemIe->value.choice.E2nodeComponentConfigRemoval_Item; - - if(fillE2NodeConfig((PTR)e2NodeRemovalItem, e2NodeComponentInfo, CONFIG_DEL) != ROK) + if(e2NodeCfgUpdFail->protocolIEs.list.array) { - DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); - return RFAILED; + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + if(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]) + { + free(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]); + } + } + free(e2NodeCfgUpdFail->protocolIEs.list.array); } - } - return ROK; } -/******************************************************************* + +/****************************************************************** * - * @brief deallocation of E2SM_KPM_RANfunction_Description_t + * @brief Processes E2 Node Config Update Failure sent by RIC * * @details * - * Function : freeE2smKpmRanFunctionDefinition + * Function : procE2NodeConfigUpdateFailure * - * Functionality: deallocation of E2SM_KPM_RANfunction_Description_t + * Functionality: Processes E2 Node Config Update failure sent by RIC * - * @params[in] E2SM_KPM_RANfunction_Description_t *ranFunctionDefinition - * @return void + * @params[in] E2AP_PDU_t ASN decoded E2AP message + * @return ROK - success + * RFAILED - failure * - ******************************************************************/ + * ****************************************************************/ -void freeE2smKpmRanFunctionDefinition(E2SM_KPM_RANfunction_Description_t *ranFunctionDefinition) +void procE2NodeConfigUpdateFailure(E2AP_PDU_t *e2apMsg) { - MeasurementInfo_Action_Item_t *measInfoList; - uint8_t eventTriggerIdx, reportStyleIdx, measInfoIdx; - RANfunction_Name_t *ranFuncName; - struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle; - struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *eventTriggerStyle; - if(ranFunctionDefinition) - { - ranFuncName = &ranFunctionDefinition->ranFunction_Name; - /* Free RAN function Name */ - DU_FREE(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size); - DU_FREE(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size); - DU_FREE(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size); + uint8_t arrIdx =0, transId =0, timerValue=0; + E2nodeConfigurationUpdateFailure_t *e2NodeCfgUpdFail=NULL; - /* Sequence of Event Trigger styles */ - eventTriggerStyle = ranFunctionDefinition->ric_EventTriggerStyle_List; - if(eventTriggerStyle) + DU_LOG("\nINFO --> E2AP : E2 Node Config Update failure received"); + e2NodeCfgUpdFail = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2nodeConfigurationUpdateFailure; + + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + switch(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->id) { - if(eventTriggerStyle->list.array) - { - for(eventTriggerIdx =0;eventTriggerIdxlist.count; eventTriggerIdx++) + case ProtocolIE_IDE2_id_TransactionID: { - if(eventTriggerStyle->list.array[eventTriggerIdx]) + transId = e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\ + (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) { - DU_FREE(eventTriggerStyle->list.array[eventTriggerIdx]->ric_EventTriggerStyle_Name.buf,\ - eventTriggerStyle->list.array[eventTriggerIdx]->ric_EventTriggerStyle_Name.size); - DU_FREE(eventTriggerStyle->list.array[eventTriggerIdx], sizeof(RIC_EventTriggerStyle_Item_t )); + memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); } - } - DU_FREE(eventTriggerStyle->list.array, eventTriggerStyle->list.size) + else + { + DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); + } + break; } - DU_FREE(eventTriggerStyle, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List)); - } - - /* Sequence of Report styles */ - ricReportStyle = ranFunctionDefinition->ric_ReportStyle_List; - if(ricReportStyle) - { - if(ricReportStyle->list.array) - { - for(reportStyleIdx =0;reportStyleIdxlist.count; reportStyleIdx++) + case ProtocolIE_IDE2_id_TimeToWaitE2: { - if(ricReportStyle->list.array[reportStyleIdx]) + timerValue = convertE2WaitTimerEnumToValue(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); + if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_NODE_CONFIG_UPDATE_TMR)) == FALSE) { - if(ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.buf) - { - DU_FREE(ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.buf,\ - ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.size); - } - if(ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.array) - { - for(measInfoIdx=0; measInfoIdxlist.array[reportStyleIdx]->measInfo_Action_List.list.count; \ - measInfoIdx++) - { - measInfoList = ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.array[measInfoIdx]; - if(measInfoList) - { - DU_FREE(measInfoList->measID, sizeof(long)); - DU_FREE(measInfoList->measName.buf, measInfoList->measName.size); - DU_FREE(measInfoList,sizeof(MeasurementInfo_Action_Item_t)); - } - } - DU_FREE(measInfoList,ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.size); - } - DU_FREE(ricReportStyle->list.array[reportStyleIdx], sizeof(RIC_ReportStyle_Item_t)); + duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_NODE_CONFIG_UPDATE_TMR, timerValue); + } + else + { + DU_LOG("\nERROR --> E2AP : EVENT_E2_NODE_CONFIG_UPDATE_TMR timer is already running"); } + break; } - DU_FREE(ricReportStyle->list.array, ricReportStyle->list.size); - } - DU_FREE(ricReportStyle, sizeof(struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List)); } - DU_FREE(ranFunctionDefinition, sizeof(E2SM_KPM_RANfunction_Description_t)); } + + freeAperDecodingOfE2NodeConfigUpdateFailure(e2NodeCfgUpdFail); } /******************************************************************* * - * @brief fill the e2sm ric report style + * @brief Builds Global gNodeB Params * * @details * - * Function : fillRicReportStyle + * Function : BuildGlobalgNBId * - * Functionality: fill the report style + * Functionality: Building the Plmn and gNB id * - * @params[in] RanFunction *ranFuncDb, struct - * E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle + * @params[in] GlobalE2node_gNB_ID_t *gNbId * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t fillRicReportStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle) + +uint8_t BuildGlobalgNBId(GlobalE2node_gNB_ID_t *gNbId) { - uint8_t styleIdx, measInfoIdx; - MeasurementInfo_Action_List_t *measInfo; - CmLList *node; - - ricReportStyle->list.count = ranFuncDb->numOfReportStyleSupported; - ricReportStyle->list.size = ricReportStyle->list.count * sizeof(RIC_ReportStyle_Item_t*); - DU_ALLOC(ricReportStyle->list.array, ricReportStyle->list.size); - if(!ricReportStyle->list.array) + uint8_t unused = 0; + uint8_t byteSize = 4; + uint8_t gnbId = duCb.gnbId; + uint8_t ret = ROK; + + /* fill Global gNB ID Id */ + gNbId->global_gNB_ID.plmn_id.size = 3 * sizeof(uint8_t); + gNbId->global_gNB_ID.plmn_id.buf = NULLP; + DU_ALLOC(gNbId->global_gNB_ID.plmn_id.buf , gNbId->global_gNB_ID.plmn_id.size); + if(gNbId->global_gNB_ID.plmn_id.buf == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for ranFuncDefinition %d",__LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP: Memory allocation failed for Plmn buffer"); + ret = RFAILED; } - - for(styleIdx =0;styleIdxlist.count; styleIdx++) + else { - DU_ALLOC(ricReportStyle->list.array[styleIdx], sizeof(RIC_ReportStyle_Item_t)); - if(!ricReportStyle->list.array[styleIdx]) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; - } - - /* RIC Report Style Type */ - ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Type = ranFuncDb->reportStyleList[styleIdx].reportStyle.styleType; - - /* RIC Report Style Format Type */ - ricReportStyle->list.array[styleIdx]->ric_ActionFormat_Type = ranFuncDb->reportStyleList[styleIdx].reportStyle.formatType; - - /* RIC Report Style Name */ - ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size = strlen(ranFuncDb->reportStyleList[styleIdx].reportStyle.name); - DU_ALLOC(ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf,\ - ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size); - if(!ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf) + buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \ + gNbId->global_gNB_ID.plmn_id.buf); + gNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID; + /* Allocate Buffer size */ + gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = byteSize * sizeof(uint8_t); + gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf = NULLP; + DU_ALLOC(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf, \ + gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size); + if(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP: Memory allocation failed for gnb buffer"); + ret = RFAILED; } - memcpy(ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf, ranFuncDb->reportStyleList[styleIdx].reportStyle.name,\ - ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size); - - /* RIC Indication Header Format Type*/ - ricReportStyle->list.array[styleIdx]->ric_IndicationHeaderFormat_Type = ranFuncDb->ricIndicationHeaderFormat; - - /* RIC Indication Message Format Type*/ - ricReportStyle->list.array[styleIdx]->ric_IndicationMessageFormat_Type = ranFuncDb->ricIndicationMessageFormat; - - /* Measurement Info Action List */ - CmLListCp measInfoList =ranFuncDb->reportStyleList[styleIdx].measurementInfoList; - if(!measInfoList.count) + else { - continue; + fillBitString(&gNbId->global_gNB_ID.gnb_id.choice.gnb_ID, unused, byteSize, gnbId); } + } - CM_LLIST_FIRST_NODE(&ranFuncDb->reportStyleList[styleIdx].measurementInfoList, node); - measInfo = &ricReportStyle->list.array[styleIdx]->measInfo_Action_List; - - measInfo->list.count = measInfoList.count; - measInfo->list.size = measInfoList.count*sizeof(MeasurementInfo_Action_Item_t*); - DU_ALLOC(measInfo->list.array, measInfo->list.size); - if(!measInfo->list.array) + /* fill gNB-DU ID */ + DU_ALLOC( gNbId->gNB_DU_ID, sizeof(GNB_DU_ID_t)); + if(gNbId->gNB_DU_ID == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed for gNB_DU_ID "); + ret = RFAILED; + } + else + { + gNbId->gNB_DU_ID->size = sizeof(uint8_t); + DU_ALLOC( gNbId->gNB_DU_ID->buf, sizeof(uint8_t)); + if(gNbId->gNB_DU_ID->buf) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + gNbId->gNB_DU_ID->buf[0] =duCb.e2apDb.e2NodeId; } - - for(measInfoIdx=0; measInfoIdxlist.count; measInfoIdx++) + else { - if(!node) - { - DU_LOG("\nERROR --> E2AP: Measurement info node is null"); - return RFAILED; - } - - DU_ALLOC(measInfo->list.array[measInfoIdx],sizeof(MeasurementInfo_Action_Item_t)); - if(!measInfo->list.array[measInfoIdx]) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; - } - MeasurementInfoForAction *measInfoForAction= (MeasurementInfoForAction*)node->node; - DU_ALLOC(measInfo->list.array[measInfoIdx]->measID, sizeof(long)); - if(!measInfo->list.array[measInfoIdx]->measID) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; - } - - memcpy(measInfo->list.array[measInfoIdx]->measID, &measInfoForAction->measurementTypeId,sizeof(long)); - measInfo->list.array[measInfoIdx]->measName.size= strlen(measInfoForAction->measurementTypeName); - DU_ALLOC(measInfo->list.array[measInfoIdx]->measName.buf, measInfo->list.array[measInfoIdx]->measName.size); - if(!measInfo->list.array[measInfoIdx]->measName.size) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; - } - - memcpy(measInfo->list.array[measInfoIdx]->measName.buf, \ - measInfoForAction->measurementTypeName,\ - measInfo->list.array[measInfoIdx]->measName.size); - node = node->next; + DU_LOG("\nERROR --> E2AP: Memory allocation failed for gNB_DU_ID buffer"); + ret = RFAILED; } - } - return ROK; + + return ret; } + /******************************************************************* * - * @brief fill the ric event trigger style + * @brief fill the E2 node config information * * @details * - * Function : fillRicEventTriggerStyle + * Function : fillE2NodeConfig * - * Functionality: fill the ric event trigger style + * Functionality: fill E2 node config information * - * @params[in] + * @params[in] + * Pointer to e2NodeCfg to be filled + * E2 Node Component information + * Type of configuration * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t fillRicEventTriggerStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *ricEventTriggerStyle) + +uint8_t fillE2NodeConfig(PTR e2NodeCfg, E2NodeComponent *e2NodeComponentInfo, ConfigType configType) { - uint8_t styleIdx; + E2NodeConfig *e2NodeConfig=NULLP; + E2nodeComponentInterfaceType_t *interfaceType=NULLP; + E2nodeComponentID_t *componentID =NULLP; + E2nodeComponentConfiguration_t *configuration=NULLP; + E2nodeComponentConfigAddition_Item_t *e2NodeAddItem=NULL; + E2nodeComponentConfigUpdate_Item_t *e2NodeUpdateItem =NULL; + E2nodeComponentConfigRemoval_Item_t *e2NodeRemovalItem=NULL; + + switch(configType) + { + case CONFIG_ADD: + { + e2NodeAddItem = (E2nodeComponentConfigAddition_Item_t*)e2NodeCfg; + interfaceType = &e2NodeAddItem->e2nodeComponentInterfaceType; + componentID = &e2NodeAddItem->e2nodeComponentID; + configuration = &e2NodeAddItem->e2nodeComponentConfiguration; + e2NodeConfig = e2NodeComponentInfo->addConfiguration; + break; + } + case CONFIG_MOD: + { + e2NodeUpdateItem = (E2nodeComponentConfigUpdate_Item_t *) e2NodeCfg; + interfaceType = &e2NodeUpdateItem->e2nodeComponentInterfaceType; + componentID = &e2NodeUpdateItem->e2nodeComponentID; + configuration = &e2NodeUpdateItem->e2nodeComponentConfiguration; + e2NodeConfig = e2NodeComponentInfo->updateConfiguration; + break; + } + case CONFIG_DEL: + { + e2NodeRemovalItem = (E2nodeComponentConfigRemoval_Item_t*) e2NodeCfg; + interfaceType = &e2NodeRemovalItem->e2nodeComponentInterfaceType; + componentID = &e2NodeRemovalItem->e2nodeComponentID; + break; + } + default: + { + DU_LOG("\nERROR --> E2AP : Configuration type %d does not supported ", configType); + return RFAILED; + } + } + /* E2nodeComponentInterfaceType */ + *interfaceType = convertInterfaceToE2ComponentInterfaceType(e2NodeComponentInfo->interfaceType); + + /* We now only support the F1 interface out of these interfaces + * (NG,XN,E1,F1,W1,S1,X2), therefore only the F1 component identifier was filled in. */ + + if(*interfaceType == F1) + { + /* E2 Node Component ID */ + componentID->present = E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1; + DU_ALLOC(componentID->choice.e2nodeComponentInterfaceTypeF1,sizeof(E2nodeComponentInterfaceF1_t)); + if(componentID->choice.e2nodeComponentInterfaceTypeF1 == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); + return RFAILED; + } + componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size = sizeof(uint8_t); + DU_ALLOC(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\ + componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); - ricEventTriggerStyle->list.count = ranFuncDb->numOfEventTriggerStyleSupported; - ricEventTriggerStyle->list.size = ricEventTriggerStyle->list.count* sizeof(RIC_EventTriggerStyle_Item_t *); - DU_ALLOC(ricEventTriggerStyle->list.array, ricEventTriggerStyle->list.size); - if(!ricEventTriggerStyle->list.array) + if(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); + return RFAILED; + } + memcpy(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf, &e2NodeComponentInfo->componentId,\ + componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); + } + + if(configType == CONFIG_DEL) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for ric_EventTriggerStyle_List %d",__LINE__); - return RFAILED; + /* We don't need to fill out the E2 Node Component Request and Response + * information in the case of CONFIG_DEL, therefore returning ROK from here. */ + return ROK; } - for(styleIdx =0;styleIdxlist.count; styleIdx++) + /* E2 Node Component Request Part */ + if(e2NodeConfig->componentRequestPart) { - DU_ALLOC(ricEventTriggerStyle->list.array[styleIdx], sizeof(RIC_EventTriggerStyle_Item_t )); - if(!ricEventTriggerStyle->list.array[styleIdx]) + configuration->e2nodeComponentRequestPart.size = e2NodeConfig->reqBufSize ; + DU_ALLOC(configuration->e2nodeComponentRequestPart.buf,\ + configuration->e2nodeComponentRequestPart.size); + if(configuration->e2nodeComponentRequestPart.buf == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); return RFAILED; } - ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Type = ranFuncDb->eventTriggerStyleList[styleIdx].styleType; - ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerFormat_Type = ranFuncDb->eventTriggerStyleList[styleIdx].formatType; + memcpy(configuration->e2nodeComponentRequestPart.buf,\ + e2NodeConfig->componentRequestPart, configuration->\ + e2nodeComponentRequestPart.size); + } + else + { + DU_LOG("\nERROR --> E2AP: componentRequestPart is null "); + return RFAILED; + } - ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size = strlen(ranFuncDb->eventTriggerStyleList[styleIdx].name); - DU_ALLOC(ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf,\ - ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size); - if(!ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf) + /* E2 Node Component Response Part */ + if(e2NodeConfig->componentResponsePart) + { + configuration->e2nodeComponentResponsePart.size = e2NodeConfig->rspBufSize; + DU_ALLOC(configuration->e2nodeComponentResponsePart.buf, configuration->e2nodeComponentResponsePart.size); + if(configuration->e2nodeComponentResponsePart.buf == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); return RFAILED; } - memcpy(ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf,ranFuncDb->eventTriggerStyleList[styleIdx].name,\ - ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size); - + memcpy(configuration->e2nodeComponentResponsePart.buf, e2NodeConfig->componentResponsePart, configuration->\ + e2nodeComponentResponsePart.size); + } + else + { + DU_LOG("\nERROR --> E2AP: componentResponsePart is null"); + return RFAILED; } + return ROK; } /******************************************************************* * - * @brief Builds Ran function item + * @brief Builds E2 node config addition list * * @details * - * Function : BuildRanFunctionItem + * Function : BuildE2NodeConfigAddList * - * Functionality: Building RAN function item + * Functionality: Building E2 node config addition list * * @params[in] - * RAN function item that has to be filled - * Stored RAN Function information + * E2nodeComponentConfigAddition_List_t to be filled + * Procedure Code + * Count of E2 node to be added in the list + * Received list of E2 node configuration + * * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t BuildRanFunctionItem(RANfunction_Item_t *ranFuncItem, RanFunction *ranFuncDb) +uint8_t BuildE2NodeConfigAddList(E2nodeComponentConfigAddition_List_t *e2NodeAddList, uint8_t procedureCode, uint16_t count, E2NodeConfigItem *e2NodeList) { - uint8_t ret =RFAILED; - RANfunctionDefinition_t *ranFunctionDefinition; - RANfunction_Name_t *ranFuncName; - asn_enc_rval_t encRetVal; - E2SM_KPM_RANfunction_Description_t *ranFuncDefinition; + uint8_t arrIdx = 0; + CmLList *node =NULL; + E2NodeComponent *e2NodeComponentInfo=NULL; + E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItemIe=NULL; + E2nodeComponentConfigAddition_Item_t *e2NodeAddItem=NULL; - while(true) - { - /* RAN function Id*/ - ranFuncItem->ranFunctionID = ranFuncDb->id; - /* RAN Function Revision*/ - ranFuncItem->ranFunctionRevision = ranFuncDb->revisionCounter; - - /* RAN function OID*/ - ranFuncItem->ranFunctionOID.size = strlen(ranFuncDb->name.serviceModelOID); - DU_ALLOC(ranFuncItem->ranFunctionOID.buf, ranFuncItem->ranFunctionOID.size); - if(!ranFuncItem->ranFunctionOID.buf) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - break; - } - memcpy(ranFuncItem->ranFunctionOID.buf, ranFuncDb->name.serviceModelOID, ranFuncItem->ranFunctionOID.size); + /* For ProcedureCodeE2_id_E2setup, the number of E2 node configuration list items is + * equal to the number of E2 node configuration entries stored in the database. + * For any other procedure, the E2 node configuration list count is equal + * to the count of E2 node configuration obtained from the function's caller */ - /* RAN function Definition */ - DU_ALLOC(ranFuncDefinition, sizeof(E2SM_KPM_RANfunction_Description_t)); - if(!ranFuncDefinition) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - break; - } + if(procedureCode == ProcedureCodeE2_id_E2setup) + e2NodeAddList->list.count = duCb.e2apDb.e2NodeComponentList.count; + else + e2NodeAddList->list.count = count; - /* RAN function Name */ - ranFuncName = &ranFuncDefinition->ranFunction_Name; + e2NodeAddList->list.size = e2NodeAddList->list.count * sizeof(E2nodeComponentConfigAddition_ItemIEs_t *); + DU_ALLOC(e2NodeAddList->list.array, e2NodeAddList->list.size); + if(e2NodeAddList->list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); + return RFAILED; + } - /* RAN function ShortName */ - ranFuncName->ranFunction_ShortName.size = strlen(ranFuncDb->name.shortName); - DU_ALLOC(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size); - if(!ranFuncName->ranFunction_ShortName.buf) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - break; - } - memcpy(ranFuncName->ranFunction_ShortName.buf, ranFuncDb->name.shortName, strlen(ranFuncDb->name.shortName)); - - /* RAN function E2SM_OID */ - ranFuncName->ranFunction_E2SM_OID.size = strlen(ranFuncDb->name.serviceModelOID); - DU_ALLOC(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size); - if(!ranFuncName->ranFunction_E2SM_OID.buf) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - break; - } - memcpy(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncDb->name.serviceModelOID, ranFuncName->ranFunction_E2SM_OID.size); - - /* RAN Function Name Description */ - ranFuncName->ranFunction_Description.size = strlen(ranFuncDb->name.description); - DU_ALLOC(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size); - if(!ranFuncName->ranFunction_Description.buf) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - break; - } - memcpy(ranFuncName->ranFunction_Description.buf, ranFuncDb->name.description, ranFuncName->ranFunction_Description.size); - - /* RIC Event Trigger Style List */ - DU_ALLOC(ranFuncDefinition->ric_EventTriggerStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List)); - if(!ranFuncDefinition->ric_EventTriggerStyle_List) + for(arrIdx = 0; arrIdx< e2NodeAddList->list.count; arrIdx++) + { + DU_ALLOC(e2NodeAddList->list.array[arrIdx], sizeof(E2nodeComponentConfigAddition_ItemIEs_t)); + if(e2NodeAddList->list.array[arrIdx] == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - break; + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); + return RFAILED; } - - if(fillRicEventTriggerStyle(ranFuncDb, ranFuncDefinition->ric_EventTriggerStyle_List)!=ROK) + + if(procedureCode == ProcedureCodeE2_id_E2setup) { - DU_LOG("\nERROR --> E2AP: failed to fill ric event trigger style"); - break; + /* Getting all of the E2 node configuration's information from DuCb one by one*/ + if(arrIdx == 0) + { + CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node); + } + else + { + node = node->next; + } + if(!node) + { + DU_LOG("\nERROR --> E2AP : E2 node component list node is null"); + return RFAILED; + } + e2NodeComponentInfo = (E2NodeComponent*)node->node; } - - /* RIC Report Style List */ - DU_ALLOC(ranFuncDefinition->ric_ReportStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List)); - if(!ranFuncDefinition->ric_ReportStyle_List) + else { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - break; + /* Getting only those E2 node configuration from DuCb whose interface + * and action type is present in the received array */ + e2NodeComponentInfo = fetchE2NodeComponentInfo(e2NodeList[arrIdx].interface, e2NodeList[arrIdx].componentId, &node); } - if(fillRicReportStyle(ranFuncDb, ranFuncDefinition->ric_ReportStyle_List) != ROK) + + if(!e2NodeComponentInfo) { - DU_LOG("\nERROR --> E2AP: failed to fill ric report style"); - break; + DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); + return RFAILED; } - /* Encode the F1SetupRequest type as APER */ - xer_fprint(stdout, &asn_DEF_E2SM_KPM_RANfunction_Description, ranFuncDefinition); - - memset(encBuf, 0, ENC_BUF_MAX_LEN); - encBufSize = 0; - encRetVal = aper_encode(&asn_DEF_E2SM_KPM_RANfunction_Description, 0, ranFuncDefinition, PrepFinalEncBuf, encBuf); - - /* Encode results */ - if(encRetVal.encoded == ENCODE_FAIL) - { - DU_LOG("\nERROR --> F1AP : Could not encode RAN function definition (at %s)\n",\ - encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - break; - } - else + e2NodeAddItemIe = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[arrIdx]; + e2NodeAddItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition_Item; + e2NodeAddItemIe->criticality = CriticalityE2_reject; + e2NodeAddItemIe->value.present = E2nodeComponentConfigAddition_ItemIEs__value_PR_E2nodeComponentConfigAddition_Item; + e2NodeAddItem = &e2NodeAddItemIe->value.choice.E2nodeComponentConfigAddition_Item; + if(fillE2NodeConfig((PTR)e2NodeAddItem, e2NodeComponentInfo, CONFIG_ADD) != ROK) { - DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RAN function definition \n"); - for(uint8_t measIeIdx=0; measIeIdx< encBufSize; measIeIdx++) - { - printf("%x",encBuf[measIeIdx]); - } - ranFunctionDefinition = &ranFuncItem->ranFunctionDefinition; - ranFunctionDefinition->size = encBufSize; - DU_ALLOC(ranFunctionDefinition->buf, encBufSize); - if(ranFunctionDefinition->buf == NULLP) - { - DU_LOG("\nERROR --> F1AP : Memory allocation failed for RAN function definition buffer"); - break; - } - memcpy(ranFunctionDefinition->buf, &encBuf, encBufSize); - ret = ROK; - break; + DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); + return RFAILED; } } - freeE2smKpmRanFunctionDefinition(ranFuncDefinition); - return ret; + return ROK; } /******************************************************************* * - * @brief Builds Ran function add list based on the procedure code + * @brief Builds E2 node config update list * * @details * - * Function : BuildRanFunctionAddList + * Function : BuildE2NodeConfigUpdateList * - * Functionality: Building RAN addition addition list - * In case of ProcedureCodeE2_id_E2setup we add all the RAN Function list - * which is present in E2 database. - * In the case of other procedures, we just fill the RAN functions whose ID - * is contained in recvList + * Functionality: Building E2 node config update list * * @params[in] - * RAN Function list - * Procedure code - * Count of ran functions to be added in the list - * Received list of RAN functions + * E2nodeComponentConfigUpdate_List_t to be filled + * Count of E2 node to be update in the list + * Received list of E2 node configuration * * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList, uint8_t procedureCode, uint8_t count, RanFuncInfo *recvList) +uint8_t BuildE2NodeConfigUpdateList(E2nodeComponentConfigUpdate_List_t *e2NodeUpdateList, uint16_t count, E2NodeConfigItem *updateE2Node) { - uint16_t id; - RanFunction *ranFuncDb; - uint8_t ranFuncIdx; - RANfunction_ItemIEs_t *ranFuncItemIe; - - /* For ProcedureCodeE2_id_E2setup, the number of RAN function list items is - * equal to the number of ran function entries stored in the database. - * For any other procedure, the RAN function list count is equal - * to the count of ran functions obtained from the function's caller */ - - if(procedureCode == ProcedureCodeE2_id_E2setup) - ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction; - else - ranFunctionsList->list.count = count; + uint8_t arrIdx = 0; + CmLList *node =NULL; + E2NodeComponent *e2NodeComponentInfo =NULL; + E2nodeComponentConfigUpdate_ItemIEs_t *e2NodeUpdateItemIe =NULL; + E2nodeComponentConfigUpdate_Item_t *e2NodeUpdateItem =NULL; - ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*); - DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size); - if(ranFunctionsList->list.array == NULLP) + e2NodeUpdateList->list.count = count; + e2NodeUpdateList->list.size = e2NodeUpdateList->list.count * sizeof(E2nodeComponentConfigUpdate_ItemIEs_t *); + DU_ALLOC(e2NodeUpdateList->list.array, e2NodeUpdateList->list.size); + if(e2NodeUpdateList->list.array == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigUpdateList %d",__LINE__); return RFAILED; } - for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++) + for(arrIdx = 0; arrIdx< e2NodeUpdateList->list.count; arrIdx++) { - DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); - if(ranFunctionsList->list.array[ranFuncIdx] == NULLP) + DU_ALLOC(e2NodeUpdateList->list.array[arrIdx], sizeof(E2nodeComponentConfigUpdate_ItemIEs_t)); + if(e2NodeUpdateList->list.array[arrIdx] == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigUpdateList %d",__LINE__); return RFAILED; } - if(procedureCode == ProcedureCodeE2_id_E2setup) + + e2NodeComponentInfo= fetchE2NodeComponentInfo(updateE2Node[arrIdx].interface, updateE2Node[arrIdx].componentId, &node); + if(!e2NodeComponentInfo) { - /* Getting all of the RAN function's information from DuCb one by one*/ - ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx]; + DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); + return RFAILED; } - else + + e2NodeUpdateItemIe = (E2nodeComponentConfigUpdate_ItemIEs_t *) e2NodeUpdateList->list.array[arrIdx]; + e2NodeUpdateItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate_Item; + e2NodeUpdateItemIe->criticality = CriticalityE2_reject; + e2NodeUpdateItemIe->value.present = E2nodeComponentConfigUpdate_ItemIEs__value_PR_E2nodeComponentConfigUpdate_Item; + e2NodeUpdateItem = &e2NodeUpdateItemIe->value.choice.E2nodeComponentConfigUpdate_Item; + + if(fillE2NodeConfig((PTR)e2NodeUpdateItem, e2NodeComponentInfo, CONFIG_MOD) != ROK) { - /* Getting only the RAN function information from DuCb whose Id is - * present in the received array */ - id =recvList[ranFuncIdx].id; - ranFuncDb = &duCb.e2apDb.ranFunction[id-1]; + DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); + return RFAILED; } - ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx]; - ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item; - ranFuncItemIe->criticality = CriticalityE2_ignore; - ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item; - BuildRanFunctionItem(&ranFuncItemIe->value.choice.RANfunction_Item, ranFuncDb); + } return ROK; -} + +} + /******************************************************************* * - * @brief De Allocate E2 Setup Request Message + * @brief Builds E2 node config remove list * * @details * - * Function : FreeE2SetupReq + * Function :BuildE2NodeConfigRemoveList * - * Functionality: De-Allocating E2 Setup request Message + * Functionality: Building E2 node config remove list * - * @params[in] E2AP_PDU_t *e2apMsg - - * @return void + * @params[in] + * E2nodeComponentConfigRemoval_List_t to be filled + * Count of E2 node to be remove in the list + * Received list of E2 node configuration + * @return ROK - success + * RFAILED - failure * - * ****************************************************************/ + ******************************************************************/ -void FreeE2SetupReq(E2AP_PDU_t *e2apMsg) +uint8_t BuildE2NodeConfigRemoveList(E2nodeComponentConfigRemoval_List_t *e2NodeRemoveList, uint16_t count, E2NodeConfigItem *updateE2Node) { uint8_t arrIdx = 0; - uint8_t e2NodeAddListIdx =0, ranFuncAddListIdx; - E2setupRequest_t *e2SetupReq; - E2nodeComponentConfigAddition_List_t *e2NodeAddList; - E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem; - RANfunctions_List_t *ranFunctionsList; - RANfunction_ItemIEs_t *ranFuncItemIe; - RANfunction_Item_t *ranFunItem; + CmLList *node=NULL; + E2NodeComponent *e2NodeComponentInfo=NULL; + E2nodeComponentConfigRemoval_ItemIEs_t *e2NodeRemovalItemIe=NULL; + E2nodeComponentConfigRemoval_Item_t *e2NodeRemovalItem=NULL; - /* De-allocating Memory */ - if(e2apMsg != NULLP) + e2NodeRemoveList->list.count = count; + e2NodeRemoveList->list.size = e2NodeRemoveList->list.count * sizeof(E2nodeComponentConfigRemoval_ItemIEs_t *); + DU_ALLOC(e2NodeRemoveList->list.array, e2NodeRemoveList->list.size); + if(e2NodeRemoveList->list.array == NULLP) { - if(e2apMsg->choice.initiatingMessage != NULLP) + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigRemoveList %d",__LINE__); + return RFAILED; + } + + for(arrIdx = 0; arrIdx< e2NodeRemoveList->list.count; arrIdx++) + { + DU_ALLOC(e2NodeRemoveList->list.array[arrIdx], sizeof(E2nodeComponentConfigRemoval_ItemIEs_t)); + if(e2NodeRemoveList->list.array[arrIdx] == NULLP) { - e2SetupReq = &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest; - if(e2SetupReq->protocolIEs.list.array != NULLP) - { - for(arrIdx = 0; arrIdx < e2SetupReq->protocolIEs.list.count; arrIdx++) + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigRemoveList %d",__LINE__); + return RFAILED; + } + + e2NodeComponentInfo= fetchE2NodeComponentInfo(updateE2Node[arrIdx].interface,updateE2Node[arrIdx].componentId, &node); + if(!e2NodeComponentInfo) + { + DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); + return RFAILED; + } + + e2NodeRemovalItemIe = (E2nodeComponentConfigRemoval_ItemIEs_t *) e2NodeRemoveList->list.array[arrIdx]; + e2NodeRemovalItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval_Item; + e2NodeRemovalItemIe->criticality = CriticalityE2_reject; + e2NodeRemovalItemIe->value.present = E2nodeComponentConfigRemoval_ItemIEs__value_PR_E2nodeComponentConfigRemoval_Item; + e2NodeRemovalItem = &e2NodeRemovalItemIe->value.choice.E2nodeComponentConfigRemoval_Item; + + if(fillE2NodeConfig((PTR)e2NodeRemovalItem, e2NodeComponentInfo, CONFIG_DEL) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); + return RFAILED; + } + + } + return ROK; +} +/******************************************************************* + * + * @brief deallocation of E2SM_KPM_RANfunction_Description_t + * + * @details + * + * Function : freeE2smKpmRanFunctionDefinition + * + * Functionality: deallocation of E2SM_KPM_RANfunction_Description_t + * + * @params[in] E2SM_KPM_RANfunction_Description_t *ranFunctionDefinition + * @return void + * + ******************************************************************/ + +void freeE2smKpmRanFunctionDefinition(E2SM_KPM_RANfunction_Description_t *ranFunctionDefinition) +{ + MeasurementInfo_Action_Item_t *measInfoList; + uint8_t eventTriggerIdx, reportStyleIdx, measInfoIdx; + RANfunction_Name_t *ranFuncName; + struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle; + struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *eventTriggerStyle; + if(ranFunctionDefinition) + { + ranFuncName = &ranFunctionDefinition->ranFunction_Name; + /* Free RAN function Name */ + DU_FREE(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size); + DU_FREE(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size); + DU_FREE(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size); + + /* Sequence of Event Trigger styles */ + eventTriggerStyle = ranFunctionDefinition->ric_EventTriggerStyle_List; + if(eventTriggerStyle) + { + if(eventTriggerStyle->list.array) + { + for(eventTriggerIdx =0;eventTriggerIdxlist.count; eventTriggerIdx++) + { + if(eventTriggerStyle->list.array[eventTriggerIdx]) + { + DU_FREE(eventTriggerStyle->list.array[eventTriggerIdx]->ric_EventTriggerStyle_Name.buf,\ + eventTriggerStyle->list.array[eventTriggerIdx]->ric_EventTriggerStyle_Name.size); + DU_FREE(eventTriggerStyle->list.array[eventTriggerIdx], sizeof(RIC_EventTriggerStyle_Item_t )); + } + } + DU_FREE(eventTriggerStyle->list.array, eventTriggerStyle->list.size) + } + DU_FREE(eventTriggerStyle, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List)); + } + + /* Sequence of Report styles */ + ricReportStyle = ranFunctionDefinition->ric_ReportStyle_List; + if(ricReportStyle) + { + if(ricReportStyle->list.array) + { + for(reportStyleIdx =0;reportStyleIdxlist.count; reportStyleIdx++) + { + if(ricReportStyle->list.array[reportStyleIdx]) + { + if(ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.buf) + { + DU_FREE(ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.buf,\ + ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.size); + } + if(ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.array) + { + for(measInfoIdx=0; measInfoIdxlist.array[reportStyleIdx]->measInfo_Action_List.list.count; \ + measInfoIdx++) + { + measInfoList = ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.array[measInfoIdx]; + if(measInfoList) + { + DU_FREE(measInfoList->measID, sizeof(long)); + DU_FREE(measInfoList->measName.buf, measInfoList->measName.size); + DU_FREE(measInfoList,sizeof(MeasurementInfo_Action_Item_t)); + } + } + DU_FREE(measInfoList,ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.size); + } + DU_FREE(ricReportStyle->list.array[reportStyleIdx], sizeof(RIC_ReportStyle_Item_t)); + } + } + DU_FREE(ricReportStyle->list.array, ricReportStyle->list.size); + } + DU_FREE(ricReportStyle, sizeof(struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List)); + } + DU_FREE(ranFunctionDefinition, sizeof(E2SM_KPM_RANfunction_Description_t)); + } +} + +/******************************************************************* + * + * @brief fill the e2sm ric report style + * + * @details + * + * Function : fillRicReportStyle + * + * Functionality: fill the report style + * + * @params[in] RanFunction *ranFuncDb, struct + * E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ +uint8_t fillRicReportStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle) +{ + uint8_t styleIdx, measInfoIdx; + MeasurementInfo_Action_List_t *measInfo; + CmLList *node; + + ricReportStyle->list.count = ranFuncDb->numOfReportStyleSupported; + ricReportStyle->list.size = ricReportStyle->list.count * sizeof(RIC_ReportStyle_Item_t*); + DU_ALLOC(ricReportStyle->list.array, ricReportStyle->list.size); + if(!ricReportStyle->list.array) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed for ranFuncDefinition %d",__LINE__); + return RFAILED; + } + + for(styleIdx =0;styleIdxlist.count; styleIdx++) + { + DU_ALLOC(ricReportStyle->list.array[styleIdx], sizeof(RIC_ReportStyle_Item_t)); + if(!ricReportStyle->list.array[styleIdx]) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + return RFAILED; + } + + /* RIC Report Style Type */ + ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Type = ranFuncDb->reportStyleList[styleIdx].reportStyle.styleType; + + /* RIC Report Style Format Type */ + ricReportStyle->list.array[styleIdx]->ric_ActionFormat_Type = ranFuncDb->reportStyleList[styleIdx].reportStyle.formatType; + + /* RIC Report Style Name */ + ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size = strlen(ranFuncDb->reportStyleList[styleIdx].reportStyle.name); + DU_ALLOC(ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf,\ + ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size); + if(!ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + return RFAILED; + } + memcpy(ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf, ranFuncDb->reportStyleList[styleIdx].reportStyle.name,\ + ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size); + + /* RIC Indication Header Format Type*/ + ricReportStyle->list.array[styleIdx]->ric_IndicationHeaderFormat_Type = ranFuncDb->ricIndicationHeaderFormat; + + /* RIC Indication Message Format Type*/ + ricReportStyle->list.array[styleIdx]->ric_IndicationMessageFormat_Type = ranFuncDb->ricIndicationMessageFormat; + + /* Measurement Info Action List */ + CmLListCp measInfoList =ranFuncDb->reportStyleList[styleIdx].measurementInfoList; + if(!measInfoList.count) + { + continue; + } + + CM_LLIST_FIRST_NODE(&ranFuncDb->reportStyleList[styleIdx].measurementInfoList, node); + measInfo = &ricReportStyle->list.array[styleIdx]->measInfo_Action_List; + + measInfo->list.count = measInfoList.count; + measInfo->list.size = measInfoList.count*sizeof(MeasurementInfo_Action_Item_t*); + DU_ALLOC(measInfo->list.array, measInfo->list.size); + if(!measInfo->list.array) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + return RFAILED; + } + + for(measInfoIdx=0; measInfoIdxlist.count; measInfoIdx++) + { + if(!node) + { + DU_LOG("\nERROR --> E2AP: Measurement info node is null"); + return RFAILED; + } + + DU_ALLOC(measInfo->list.array[measInfoIdx],sizeof(MeasurementInfo_Action_Item_t)); + if(!measInfo->list.array[measInfoIdx]) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + return RFAILED; + } + MeasurementInfoForAction *measInfoForAction= (MeasurementInfoForAction*)node->node; + DU_ALLOC(measInfo->list.array[measInfoIdx]->measID, sizeof(long)); + if(!measInfo->list.array[measInfoIdx]->measID) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + return RFAILED; + } + + memcpy(measInfo->list.array[measInfoIdx]->measID, &measInfoForAction->measurementTypeId,sizeof(long)); + measInfo->list.array[measInfoIdx]->measName.size= strlen(measInfoForAction->measurementTypeName); + DU_ALLOC(measInfo->list.array[measInfoIdx]->measName.buf, measInfo->list.array[measInfoIdx]->measName.size); + if(!measInfo->list.array[measInfoIdx]->measName.size) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + return RFAILED; + } + + memcpy(measInfo->list.array[measInfoIdx]->measName.buf, \ + measInfoForAction->measurementTypeName,\ + measInfo->list.array[measInfoIdx]->measName.size); + node = node->next; + } + + } + return ROK; +} +/******************************************************************* + * + * @brief fill the ric event trigger style + * + * @details + * + * Function : fillRicEventTriggerStyle + * + * Functionality: fill the ric event trigger style + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ +uint8_t fillRicEventTriggerStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *ricEventTriggerStyle) +{ + uint8_t styleIdx; + + ricEventTriggerStyle->list.count = ranFuncDb->numOfEventTriggerStyleSupported; + ricEventTriggerStyle->list.size = ricEventTriggerStyle->list.count* sizeof(RIC_EventTriggerStyle_Item_t *); + DU_ALLOC(ricEventTriggerStyle->list.array, ricEventTriggerStyle->list.size); + if(!ricEventTriggerStyle->list.array) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed for ric_EventTriggerStyle_List %d",__LINE__); + return RFAILED; + } + + for(styleIdx =0;styleIdxlist.count; styleIdx++) + { + DU_ALLOC(ricEventTriggerStyle->list.array[styleIdx], sizeof(RIC_EventTriggerStyle_Item_t )); + if(!ricEventTriggerStyle->list.array[styleIdx]) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + return RFAILED; + } + ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Type = ranFuncDb->eventTriggerStyleList[styleIdx].styleType; + + ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerFormat_Type = ranFuncDb->eventTriggerStyleList[styleIdx].formatType; + + ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size = strlen(ranFuncDb->eventTriggerStyleList[styleIdx].name); + DU_ALLOC(ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf,\ + ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size); + if(!ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + return RFAILED; + } + memcpy(ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf,ranFuncDb->eventTriggerStyleList[styleIdx].name,\ + ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size); + + } + return ROK; +} + +/******************************************************************* + * + * @brief Builds Ran function item + * + * @details + * + * Function : BuildRanFunctionItem + * + * Functionality: Building RAN function item + * + * @params[in] + * RAN function item that has to be filled + * Stored RAN Function information + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +uint8_t BuildRanFunctionItem(RANfunction_Item_t *ranFuncItem, RanFunction *ranFuncDb) +{ + uint8_t ret =RFAILED; + RANfunctionDefinition_t *ranFunctionDefinition; + RANfunction_Name_t *ranFuncName; + asn_enc_rval_t encRetVal; + E2SM_KPM_RANfunction_Description_t *ranFuncDefinition; + + while(true) + { + /* RAN function Id*/ + ranFuncItem->ranFunctionID = ranFuncDb->id; + + /* RAN Function Revision*/ + ranFuncItem->ranFunctionRevision = ranFuncDb->revisionCounter; + + /* RAN function OID*/ + ranFuncItem->ranFunctionOID.size = strlen(ranFuncDb->name.serviceModelOID); + DU_ALLOC(ranFuncItem->ranFunctionOID.buf, ranFuncItem->ranFunctionOID.size); + if(!ranFuncItem->ranFunctionOID.buf) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + break; + } + memcpy(ranFuncItem->ranFunctionOID.buf, ranFuncDb->name.serviceModelOID, ranFuncItem->ranFunctionOID.size); + + /* RAN function Definition */ + DU_ALLOC(ranFuncDefinition, sizeof(E2SM_KPM_RANfunction_Description_t)); + if(!ranFuncDefinition) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + break; + } + + /* RAN function Name */ + ranFuncName = &ranFuncDefinition->ranFunction_Name; + + /* RAN function ShortName */ + ranFuncName->ranFunction_ShortName.size = strlen(ranFuncDb->name.shortName); + DU_ALLOC(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size); + if(!ranFuncName->ranFunction_ShortName.buf) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + break; + } + memcpy(ranFuncName->ranFunction_ShortName.buf, ranFuncDb->name.shortName, strlen(ranFuncDb->name.shortName)); + + /* RAN function E2SM_OID */ + ranFuncName->ranFunction_E2SM_OID.size = strlen(ranFuncDb->name.serviceModelOID); + DU_ALLOC(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size); + if(!ranFuncName->ranFunction_E2SM_OID.buf) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + break; + } + memcpy(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncDb->name.serviceModelOID, ranFuncName->ranFunction_E2SM_OID.size); + + /* RAN Function Name Description */ + ranFuncName->ranFunction_Description.size = strlen(ranFuncDb->name.description); + DU_ALLOC(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size); + if(!ranFuncName->ranFunction_Description.buf) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + break; + } + memcpy(ranFuncName->ranFunction_Description.buf, ranFuncDb->name.description, ranFuncName->ranFunction_Description.size); + + /* RIC Event Trigger Style List */ + DU_ALLOC(ranFuncDefinition->ric_EventTriggerStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List)); + if(!ranFuncDefinition->ric_EventTriggerStyle_List) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + break; + } + + if(fillRicEventTriggerStyle(ranFuncDb, ranFuncDefinition->ric_EventTriggerStyle_List)!=ROK) + { + DU_LOG("\nERROR --> E2AP: failed to fill ric event trigger style"); + break; + } + + /* RIC Report Style List */ + DU_ALLOC(ranFuncDefinition->ric_ReportStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List)); + if(!ranFuncDefinition->ric_ReportStyle_List) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); + break; + } + if(fillRicReportStyle(ranFuncDb, ranFuncDefinition->ric_ReportStyle_List) != ROK) + { + DU_LOG("\nERROR --> E2AP: failed to fill ric report style"); + break; + } + + /* Encode the F1SetupRequest type as APER */ + xer_fprint(stdout, &asn_DEF_E2SM_KPM_RANfunction_Description, ranFuncDefinition); + + memset(encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + encRetVal = aper_encode(&asn_DEF_E2SM_KPM_RANfunction_Description, 0, ranFuncDefinition, PrepFinalEncBuf, encBuf); + + /* Encode results */ + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> F1AP : Could not encode RAN function definition (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RAN function definition \n"); + for(uint8_t measIeIdx=0; measIeIdx< encBufSize; measIeIdx++) + { + printf("%x",encBuf[measIeIdx]); + } + ranFunctionDefinition = &ranFuncItem->ranFunctionDefinition; + ranFunctionDefinition->size = encBufSize; + DU_ALLOC(ranFunctionDefinition->buf, encBufSize); + if(ranFunctionDefinition->buf == NULLP) + { + DU_LOG("\nERROR --> F1AP : Memory allocation failed for RAN function definition buffer"); + break; + } + memcpy(ranFunctionDefinition->buf, &encBuf, encBufSize); + ret = ROK; + break; + } + } + freeE2smKpmRanFunctionDefinition(ranFuncDefinition); + return ret; +} + +/******************************************************************* + * + * @brief Builds Ran function add list based on the procedure code + * + * @details + * + * Function : BuildRanFunctionAddList + * + * Functionality: Building RAN addition addition list + * In case of ProcedureCodeE2_id_E2setup we add all the RAN Function list + * which is present in E2 database. + * In the case of other procedures, we just fill the RAN functions whose ID + * is contained in recvList + * + * @params[in] + * RAN Function list + * Procedure code + * Count of ran functions to be added in the list + * Received list of RAN functions + * + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList, uint8_t procedureCode, uint8_t count, RanFuncInfo *recvList) +{ + uint16_t id; + RanFunction *ranFuncDb; + uint8_t ranFuncIdx; + RANfunction_ItemIEs_t *ranFuncItemIe; + + /* For ProcedureCodeE2_id_E2setup, the number of RAN function list items is + * equal to the number of ran function entries stored in the database. + * For any other procedure, the RAN function list count is equal + * to the count of ran functions obtained from the function's caller */ + + if(procedureCode == ProcedureCodeE2_id_E2setup) + ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction; + else + ranFunctionsList->list.count = count; + + ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*); + DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size); + if(ranFunctionsList->list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); + return RFAILED; + } + + for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++) + { + DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); + if(ranFunctionsList->list.array[ranFuncIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); + return RFAILED; + } + if(procedureCode == ProcedureCodeE2_id_E2setup) + { + /* Getting all of the RAN function's information from DuCb one by one*/ + ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx]; + } + else + { + /* Getting only the RAN function information from DuCb whose Id is + * present in the received array */ + id =recvList[ranFuncIdx].id; + ranFuncDb = &duCb.e2apDb.ranFunction[id-1]; + } + ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx]; + ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item; + ranFuncItemIe->criticality = CriticalityE2_ignore; + ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item; + BuildRanFunctionItem(&ranFuncItemIe->value.choice.RANfunction_Item, ranFuncDb); + } + return ROK; +} + +/******************************************************************* + * + * @brief De Allocate E2 Setup Request Message + * + * @details + * + * Function : FreeE2SetupReq + * + * Functionality: De-Allocating E2 Setup request Message + * + * @params[in] E2AP_PDU_t *e2apMsg + + * @return void + * + * ****************************************************************/ + +void FreeE2SetupReq(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx = 0; + uint8_t e2NodeAddListIdx =0, ranFuncAddListIdx; + E2setupRequest_t *e2SetupReq; + E2nodeComponentConfigAddition_List_t *e2NodeAddList; + E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem; + RANfunctions_List_t *ranFunctionsList; + RANfunction_ItemIEs_t *ranFuncItemIe; + RANfunction_Item_t *ranFunItem; + + /* De-allocating Memory */ + if(e2apMsg != NULLP) + { + if(e2apMsg->choice.initiatingMessage != NULLP) + { + e2SetupReq = &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest; + if(e2SetupReq->protocolIEs.list.array != NULLP) + { + for(arrIdx = 0; arrIdx < e2SetupReq->protocolIEs.list.count; arrIdx++) { if(e2SetupReq->protocolIEs.list.array[arrIdx] != NULLP) { @@ -1524,8 +1992,8 @@ void FreeE2SetupReq(E2AP_PDU_t *e2apMsg) uint8_t BuildAndSendE2SetupReq() { uint8_t arrIdx = 0, elementCnt=0; - uint8_t transId = 0, ret = ROK; - bool memAllocFailed; + uint8_t transId = 0, ret = RFAILED; + bool memAllocFailed = false; E2AP_PDU_t *e2apMsg = NULLP; E2setupRequest_t *e2SetupReq = NULLP; asn_enc_rval_t encRetVal; /* Encoder return value */ @@ -2111,10 +2579,111 @@ void freeAperDecodingOfE2SetupRsp(E2setupResponse_t *e2SetRspMsg) free(e2SetRspMsg->protocolIEs.list.array[arrIdx]); } } - free(e2SetRspMsg->protocolIEs.list.array); - } + free(e2SetRspMsg->protocolIEs.list.array); + } + } +} + +/****************************************************************** + * + * @brief handling of e2 noe config update ack ies + * + * @details + * + * Function :handleE2NodeConfigUpdateAckIes + * + * Functionality: handling of e2 noe config update ack ies + * + * @params[in] + * Pointer to the E2 Node cfg + * Procedure code + * @return void +******************************************************************/ + +void handleE2NodeConfigUpdateAckIes(PTR e2NodeCfg, uint8_t procedureCode) +{ + CmLList *node=NULLP; + E2NodeComponent *e2NodeComponentInfo=NULLP; + E2nodeComponentID_t *e2nodeComponentID=NULLP; + E2nodeComponentConfigRemovalAck_Item_t *removalAckItem=NULLP; + E2nodeComponentConfigUpdateAck_Item_t *updateAckItem=NULLP; + E2nodeComponentConfigAdditionAck_Item_t *additionAckItem=NULLP; + + switch(procedureCode) + { + case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck: + { + additionAckItem = (E2nodeComponentConfigAdditionAck_Item_t *)e2NodeCfg; + e2nodeComponentID = &additionAckItem->e2nodeComponentID; + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck: + { + updateAckItem = (E2nodeComponentConfigUpdateAck_Item_t*) e2NodeCfg; + e2nodeComponentID = &updateAckItem->e2nodeComponentID; + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck: + { + removalAckItem= (E2nodeComponentConfigRemovalAck_Item_t*)e2NodeCfg; + e2nodeComponentID = &removalAckItem->e2nodeComponentID; + break; + } + } + + switch(e2nodeComponentID->present) + { + case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1: + { + e2NodeComponentInfo = fetchE2NodeComponentInfo(F1, e2nodeComponentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf[0], &node); + if(!e2NodeComponentInfo) + { + DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); + return; + } + break; + } + default: + break; + } + + switch(procedureCode) + { + case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck: + { + DU_FREE(e2NodeComponentInfo->addConfiguration->componentRequestPart, e2NodeComponentInfo->addConfiguration->reqBufSize); + DU_FREE(e2NodeComponentInfo->addConfiguration->componentResponsePart, e2NodeComponentInfo->addConfiguration->rspBufSize); + DU_FREE(e2NodeComponentInfo->addConfiguration, sizeof(E2NodeConfig)); + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck: + { + DU_FREE(e2NodeComponentInfo->updateConfiguration->componentRequestPart, e2NodeComponentInfo->updateConfiguration->reqBufSize); + DU_FREE(e2NodeComponentInfo->updateConfiguration->componentResponsePart, e2NodeComponentInfo->updateConfiguration->rspBufSize); + DU_FREE(e2NodeComponentInfo->updateConfiguration, sizeof(E2NodeConfig)); + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck: + { + cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node); + if(e2NodeComponentInfo->addConfiguration) + { + DU_FREE(e2NodeComponentInfo->addConfiguration->componentRequestPart, e2NodeComponentInfo->addConfiguration->reqBufSize); + DU_FREE(e2NodeComponentInfo->addConfiguration->componentResponsePart, e2NodeComponentInfo->addConfiguration->rspBufSize); + DU_FREE(e2NodeComponentInfo->addConfiguration, sizeof(E2NodeConfig)); + } + if(e2NodeComponentInfo->updateConfiguration) + { + DU_FREE(e2NodeComponentInfo->updateConfiguration->componentRequestPart, e2NodeComponentInfo->updateConfiguration->reqBufSize); + DU_FREE(e2NodeComponentInfo->updateConfiguration->componentResponsePart, e2NodeComponentInfo->updateConfiguration->rspBufSize); + DU_FREE(e2NodeComponentInfo->updateConfiguration, sizeof(E2NodeConfig)); + } + DU_FREE(node, sizeof(CmLList)); + break; + } } } + /****************************************************************** * * @brief Processes E2 Setup Response sent by RIC @@ -2126,18 +2695,16 @@ void freeAperDecodingOfE2SetupRsp(E2setupResponse_t *e2SetRspMsg) * Functionality: Processes E2 Setup Response sent by RIC * * @params[in] E2AP_PDU_t ASN decoded E2AP message - * @return ROK - success - * RFAILED - failure + * @return void * * ****************************************************************/ -uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg) +void procE2SetupRsp(E2AP_PDU_t *e2apMsg) { + bool invalidTransId = false; uint8_t arrIdx =0, transId=0, idx=0; uint32_t recvBufLen; E2setupResponse_t *e2SetRspMsg=NULL; - CmLList *node=NULL; - E2NodeComponent *e2NodeComponentInfo=NULL; E2nodeComponentConfigAdditionAck_List_t *e2NodeCfgAckList=NULL; E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAddAckItem=NULL; @@ -2160,7 +2727,7 @@ uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg) else { DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); - return RFAILED; + invalidTransId = true; } break; } @@ -2170,60 +2737,47 @@ uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg) /* To store the Ric Id Params */ recvBufLen = sizeof(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value\ .choice.GlobalRIC_ID.pLMN_Identity.size); - memcpy(&duCb.e2apDb.ricId.plmnId, e2SetRspMsg->protocolIEs.list.array[arrIdx]\ - ->value.choice.GlobalRIC_ID.pLMN_Identity.buf, recvBufLen); + memcpy(&duCb.e2apDb.ricId.plmnId, e2SetRspMsg->protocolIEs.list.array[arrIdx]\ + ->value.choice.GlobalRIC_ID.pLMN_Identity.buf, recvBufLen); bitStringToInt(&e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.ric_ID, &duCb.e2apDb.ricId); /*TODO : duCb.e2apDb.ricId.plmnId memory to be deallocated after the usage */ break; } case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck: - { - e2NodeCfgAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List; - for(idx =0; idx list.count; idx++) { - e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeCfgAckList->list.array[idx]; - switch(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.present) + e2NodeCfgAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List; + for(idx =0; idx list.count; idx++) { - case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1: - { - e2NodeComponentInfo = fetchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD, &node); - if(!e2NodeComponentInfo) - { - DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); - return RFAILED; - } - else - { - cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node); - DU_FREE(e2NodeComponentInfo->componentRequestPart, e2NodeComponentInfo->reqBufSize); - DU_FREE(e2NodeComponentInfo->componentResponsePart, e2NodeComponentInfo->rspBufSize); - DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent)); - DU_FREE(node, sizeof(CmLList)); - } - break; - } - default: - break; + e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeCfgAckList->list.array[idx]; + handleE2NodeConfigUpdateAckIes((PTR)&e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item,\ + ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck); } + break; } - break; - } default: - DU_LOG("\nERROR --> E2AP : Invalid IE received in E2SetupRsp:%ld", - e2SetRspMsg->protocolIEs.list.array[arrIdx]->id); - break; + { + DU_LOG("\nERROR --> E2AP : Invalid IE received in E2SetupRsp:%ld", + e2SetRspMsg->protocolIEs.list.array[arrIdx]->id); + break; + } + } + + if(invalidTransId == true) + { + break; } } freeAperDecodingOfE2SetupRsp(e2SetRspMsg); - if(duSendE2NodeConfigurationUpdate() != ROK) + if(invalidTransId == false) { - DU_LOG("\nERROR --> E2AP : Failed to send E2 node config update"); - return RFAILED; + if(duSendE2NodeConfigurationUpdate() != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to send E2 node config update"); + } } - return ROK; } /******************************************************************* @@ -2477,8 +3031,8 @@ uint8_t extractMeasInfoList(CmLListCp *measInfoSupportedList, MeasurementInfoLis { uint8_t elementIdx = 0; MeasurementInfoForAction *measInfoSupportedDb = NULLP; - MeasurementInfo *measInfoSubscribedDb = NULLP, *measInfoToDel = NULLP; - CmLList *supportedMeasNode = NULLP, *measToAddNode = NULLP, *measToDelNode = NULLP;; + MeasurementInfo *measInfoSubscribedDb = NULLP; + CmLList *supportedMeasNode = NULLP, *measToAddNode = NULLP; MeasurementInfoItem_t *measItem = NULLP; /* Validate Measurement list is supported by E2 node. @@ -2560,13 +3114,7 @@ uint8_t extractMeasInfoList(CmLListCp *measInfoSupportedList, MeasurementInfoLis * Break out of for loop to search in next report style */ if(!measInfoSubscribedDb) { - while(measInfoSubscribedList->count) - { - measToDelNode = cmLListDelFrm(measInfoSubscribedList, measInfoSubscribedList->first); - measInfoToDel = (MeasurementInfo*)measToDelNode->node; - DU_FREE(measInfoToDel, sizeof(MeasurementInfo)); - DU_FREE(measToDelNode, sizeof(CmLList)); - } + deleteMeasurementInfoList(measInfoSubscribedList); break; } @@ -2752,8 +3300,7 @@ uint8_t extractRicActionToBeSetup(RanFunction *ranFuncDb, RicSubscription *ricSu /* In case of any failure, action is rejected * Added to rejected-action-list in subscription response */ - memset(&ricSubscriptionInfo->actionSequence[ricActionId], 0, sizeof(ActionInfo)); - ricSubscriptionInfo->actionSequence[ricActionId].actionId = -1; + deleteActionSequence(&ricSubscriptionInfo->actionSequence[ricActionId]); subsRsp->rejectedActionList[subsRsp->numOfRejectedActions].id = ricActionId; if(failureCause->causeType == E2_NOTHING) @@ -2919,6 +3466,7 @@ uint8_t procRicSubscriptionRequest(E2AP_PDU_t *e2apMsg) if(ret == ROK) { cmInitTimers(&(ricSubscriptionInfo->ricSubsReportTimer), 1); + ricSubscriptionInfo->action = CONFIG_ADD; /* Add RAN subcription detail to RAN function */ DU_ALLOC(ricSubscriptionNode, sizeof(CmLList)); @@ -3231,428 +3779,809 @@ void freeMeasData(MeasurementData_t *measData) /******************************************************************* * - * @brief Fill measurement info list + * @brief Fill measurement info list + * + * @details + * + * Function : freeMeasInfoList + * + * Functionality: Fills all measurement info within an action + * in a RIC subscription + * + * @param Measurement Info list to be freed + * @return void + * + ******************************************************************/ +void freeMeasInfoList(MeasurementInfoList_t *measInfoList) +{ + uint8_t measInfoIdx = 0; + + if(measInfoList->list.array) + { + for(measInfoIdx = 0; measInfoIdx < measInfoList->list.count; measInfoIdx++) + { + if(measInfoList->list.array[measInfoIdx]) + { + DU_FREE(measInfoList->list.array[measInfoIdx]->measType.choice.measName.buf, \ + measInfoList->list.array[measInfoIdx]->measType.choice.measName.size); + + DU_FREE(measInfoList->list.array[measInfoIdx], measInfoList->list.size); + } + } + DU_FREE(measInfoList->list.array, measInfoList->list.size); + } +} + +/******************************************************************* + * + * @brief Free E2SM-KPM Indication Message + * + * @details + * + * Function : FreeE2smKpmIndicationMessage + * + * Functionality: Free E2SM-KPM Indication Message + * + * @param E2SM-KPM Indication message to be freed + * @return void + * + ******************************************************************/ +void FreeE2smKpmIndicationMessage(E2SM_KPM_IndicationMessage_t *e2smKpmIndMsg) +{ + E2SM_KPM_IndicationMessage_Format1_t *format1Msg = NULLP; + + switch(e2smKpmIndMsg->indicationMessage_formats.present) + { + case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1: + { + if(e2smKpmIndMsg->indicationMessage_formats.choice.indicationMessage_Format1) + { + format1Msg = e2smKpmIndMsg->indicationMessage_formats.choice.indicationMessage_Format1; + + /* Measurement Data */ + freeMeasData(&format1Msg->measData); + + /* Measurement Info List */ + if(format1Msg->measInfoList) + { + freeMeasInfoList(format1Msg->measInfoList); + DU_FREE(format1Msg->measInfoList, sizeof(MeasurementInfoList_t)); + } + + /* Granularity Period */ + DU_FREE(format1Msg->granulPeriod, sizeof(GranularityPeriod_t)); + + DU_FREE(format1Msg, sizeof(E2SM_KPM_IndicationMessage_Format1_t)); + } + break; + } + + case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_NOTHING: + case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format2: + default: + break; + } +} + +/******************************************************************* + * + * @brief Fill measurement record + * + * @details + * + * Function : fillMeasRecord + * + * Functionality: Fills all measurement value for a measurement + * within an action in a RIC subscription + * + * @param Measurement record to be filled + * Measurement database with measurement records + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ +uint8_t fillMeasRecord(MeasurementRecord_t *measRecord, MeasurementInfo *measInfoDb) +{ + uint8_t measRecIdx = 0; + CmLList *measValNode = NULLP; + double measVal = 0; + + measRecord->list.count = measInfoDb->measuredValue.count; + measRecord->list.size = measRecord->list.count * sizeof(MeasurementRecordItem_t *); + + DU_ALLOC(measRecord->list.array, measRecord->list.size); + if(!measRecord->list.array) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } + + for(measRecIdx = 0; measRecIdx < measRecord->list.count; measRecIdx++) + { + DU_ALLOC(measRecord->list.array[measRecIdx], sizeof(MeasurementRecordItem_t)); + if(!measRecord->list.array[measRecIdx]) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } + } + + measRecIdx = 0; + CM_LLIST_FIRST_NODE(&measInfoDb->measuredValue, measValNode); + while(measValNode) + { + measVal = *(double *)measValNode->node; + if(measVal == (int)measVal) + { + measRecord->list.array[measRecIdx]->present = MeasurementRecordItem_PR_integer; + measRecord->list.array[measRecIdx]->choice.integer = (int)measVal; + } + else + { + measRecord->list.array[measRecIdx]->present = MeasurementRecordItem_PR_real; + measRecord->list.array[measRecIdx]->choice.real = measVal; + } + measRecIdx++; + measValNode= measValNode->next; + /* Once the measurement record is added to the message, delete it from DB */ + measVal = 0; + } + deleteMeasuredValueList(&measInfoDb->measuredValue); + return ROK; +} + +/******************************************************************* + * + * @brief Fills measuerement data + * + * @details + * + * Function : fillMeasData + * + * Functionality: Fill all measurement recorded for all measurements + * in an action in a RIC subscription + * + * @param Measurement data to be filled + * Measurement info list from an action DB + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ +uint8_t fillMeasData(MeasurementData_t *measData, CmLListCp *measInfoListDb) +{ + uint8_t measIdx = 0; + CmLList *measInfoNode = NULLP; + MeasurementInfo *measInfoDb = NULLP; + MeasurementRecord_t *measRecord = NULLP; + + measData->list.count = measInfoListDb->count; + measData->list.size = measData->list.count * sizeof(MeasurementDataItem_t *); + + DU_ALLOC(measData->list.array, measData->list.size); + if(!measData->list.array) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } + + measIdx = 0; + CM_LLIST_FIRST_NODE(measInfoListDb, measInfoNode); + while(measInfoNode) + { + measInfoDb = (MeasurementInfo *)measInfoNode->node; + if(measInfoDb) + { + DU_ALLOC(measData->list.array[measIdx], sizeof(MeasurementDataItem_t)); + if(!measData->list.array[measIdx]) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } + + measRecord = &measData->list.array[measIdx]->measRecord; + if(fillMeasRecord(measRecord, measInfoDb) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill measurement record"); + return RFAILED; + } + measIdx++; + } + measInfoNode = measInfoNode->next; + } + + return ROK; +} + +/******************************************************************* + * + * @brief Fill all measurement info * * @details * - * Function : freeMeasInfoList + * Function : fillMeasInfoList * - * Functionality: Fills all measurement info within an action - * in a RIC subscription + * Functionality: Fills all measurement info belonging to an action + * in a RIC subscription * - * @param Measurement Info list to be freed - * @return void + * @param Measurement Info list to be filled + * Measurement Info list from E2AP DB + * @return ROK - success + * RFAILED - failure * ******************************************************************/ -void freeMeasInfoList(MeasurementInfoList_t *measInfoList) +uint8_t fillMeasInfoList(MeasurementInfoList_t *measInfoList, CmLListCp *measInfoListDb) { uint8_t measInfoIdx = 0; + CmLList *measInfoNode = NULLP; + MeasurementInfo *measInfoDb = NULLP; + MeasurementInfoItem_t *measInfoItem = NULLP; - if(measInfoList->list.array) + measInfoList->list.count = measInfoListDb->count; + measInfoList->list.size = measInfoList->list.count * sizeof(MeasurementInfoItem_t *); + + DU_ALLOC(measInfoList->list.array, measInfoList->list.size); + if(!measInfoList->list.array) { - for(measInfoIdx = 0; measInfoIdx < measInfoList->list.count; measInfoIdx++) + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } + + measInfoIdx = 0; + CM_LLIST_FIRST_NODE(measInfoListDb, measInfoNode); + while(measInfoNode) + { + DU_ALLOC(measInfoList->list.array[measInfoIdx], sizeof(MeasurementInfoItem_t)); + if(!measInfoList->list.array[measInfoIdx]) { - if(measInfoList->list.array[measInfoIdx]) - { - DU_FREE(measInfoList->list.array[measInfoIdx]->measType.choice.measName.buf, \ - measInfoList->list.array[measInfoIdx]->measType.choice.measName.size); + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } - DU_FREE(measInfoList->list.array[measInfoIdx], measInfoList->list.size); + measInfoItem = measInfoList->list.array[measInfoIdx]; + measInfoDb = (MeasurementInfo *)measInfoNode->node; + if(measInfoDb) + { + /* Measurement Type */ + measInfoItem->measType.present = MeasurementType_PR_measName; + measInfoItem->measType.choice.measName.size = strlen(measInfoDb->measurementTypeName); + + DU_ALLOC(measInfoItem->measType.choice.measName.buf, measInfoItem->measType.choice.measName.size); + if(!measInfoItem->measType.choice.measName.buf) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; } + + memcpy(measInfoItem->measType.choice.measName.buf, measInfoDb->measurementTypeName,\ + measInfoItem->measType.choice.measName.size); + + measInfoIdx++; } - DU_FREE(measInfoList->list.array, measInfoList->list.size); + measInfoNode = measInfoNode->next; + measInfoDb = NULLP; } + + return ROK; } -/******************************************************************* + /******************************************************************* * - * @brief Free E2SM-KPM Indication Message + * @brief Fill E2SM-KPM Indication Message Format 1 * * @details * - * Function : FreeE2smKpmIndicationMessage + * Function : fillE2smKpmIndMsgFormat1 * - * Functionality: Free E2SM-KPM Indication Message + * Functionality: Fill E2SM-KPM Indication Message Format 1 * - * @param E2SM-KPM Indication message to be freed - * @return void + * @param Format 1 Message to be filled + * Action Definition format 1 from E2AP DB + * @return ROK - success + * RFAILED - failure * ******************************************************************/ -void FreeE2smKpmIndicationMessage(E2SM_KPM_IndicationMessage_t *e2smKpmIndMsg) +uint8_t fillE2smKpmIndMsgFormat1(E2SM_KPM_IndicationMessage_Format1_t *format1Msg, ActionDefFormat1 *format1) { - E2SM_KPM_IndicationMessage_Format1_t *format1Msg = NULLP; - - switch(e2smKpmIndMsg->indicationMessage_formats.present) - { - case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1: - { - if(e2smKpmIndMsg->indicationMessage_formats.choice.indicationMessage_Format1) - { - format1Msg = e2smKpmIndMsg->indicationMessage_formats.choice.indicationMessage_Format1; - - /* Measurement Data */ - freeMeasData(&format1Msg->measData); + /* Measurement Data */ + if(fillMeasData(&format1Msg->measData, &format1->measurementInfoList) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill measurement data"); + return RFAILED; + } - /* Measurement Info List */ - if(format1Msg->measInfoList) - { - freeMeasInfoList(format1Msg->measInfoList); - DU_FREE(format1Msg->measInfoList, sizeof(MeasurementInfoList_t)); - } + /* Measurement Information */ + DU_ALLOC(format1Msg->measInfoList, sizeof(MeasurementInfoList_t)); + if(!format1Msg->measInfoList) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } - /* Granularity Period */ - DU_FREE(format1Msg->granulPeriod, sizeof(GranularityPeriod_t)); + if(fillMeasInfoList(format1Msg->measInfoList, &format1->measurementInfoList) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill measurement information list"); + return RFAILED; + } - DU_FREE(format1Msg, sizeof(E2SM_KPM_IndicationMessage_Format1_t)); - } - break; - } + /* Granularity Period */ + DU_ALLOC(format1Msg->granulPeriod, sizeof(GranularityPeriod_t)); + if(!format1Msg->granulPeriod) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } + *(format1Msg->granulPeriod) = format1->granularityPeriod; - case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_NOTHING: - case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format2: - default: - break; - } + return ROK; } /******************************************************************* * - * @brief Fill measurement record + * @brief Fill RIC Indication Message buffer * * @details * - * Function : fillMeasRecord - * - * Functionality: Fills all measurement value for a measurement - * within an action in a RIC subscription + * Function : fillRicIndMsgBuf * - * @param Measurement record to be filled - * Measurement database with measurement records + * Functionality: Fill E2SM-KPM Indication Message + * Encode this message and copy to RIC Indication Message buffer + * + * @param RIC Indication Message buffer to be filled + * Source action info from E2AP DB * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t fillMeasRecord(MeasurementRecord_t *measRecord, MeasurementInfo *measInfoDb) +uint8_t fillRicIndMsgBuf(RICindicationMessage_t *ricIndMsgBuf, ActionInfo *actionInfo) { - uint8_t measRecIdx = 0; - CmLList *measValNode = NULLP; - double measVal = 0; - - measRecord->list.count = measInfoDb->measuredValue.count; - measRecord->list.size = measRecord->list.count * sizeof(MeasurementRecordItem_t *); + uint8_t ret = RFAILED; + bool failedInFormat = false; + E2SM_KPM_IndicationMessage_t e2smKpmIndMsg; + asn_enc_rval_t encRetVal; /* Encoder return value */ - DU_ALLOC(measRecord->list.array, measRecord->list.size); - if(!measRecord->list.array) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; - } + memset(&e2smKpmIndMsg, 0, sizeof(E2SM_KPM_IndicationMessage_t)); - for(measRecIdx = 0; measRecIdx < measRecord->list.count; measRecIdx++) + while(true) { - DU_ALLOC(measRecord->list.array[measRecIdx], sizeof(MeasurementRecordItem_t)); - if(!measRecord->list.array[measRecIdx]) + /* E2SM-KPM Indication message format type */ + e2smKpmIndMsg.indicationMessage_formats.present = actionInfo->definition.formatType; + switch(e2smKpmIndMsg.indicationMessage_formats.present) { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; + case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1: + { + /* E2SM-KPM Indication message format 1 */ + DU_ALLOC(e2smKpmIndMsg.indicationMessage_formats.choice.indicationMessage_Format1, \ + sizeof(E2SM_KPM_IndicationMessage_Format1_t)); + if(!e2smKpmIndMsg.indicationMessage_formats.choice.indicationMessage_Format1) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + failedInFormat = true; + break; + } + + if(fillE2smKpmIndMsgFormat1(e2smKpmIndMsg.indicationMessage_formats.choice.indicationMessage_Format1, \ + &actionInfo->definition.choice.format1) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill E2SM-KPM Indication message format 1"); + failedInFormat = true; + break; + } + break; + } + + case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_NOTHING: + case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format2: + default: + { + DU_LOG("\nERROR --> E2AP : fillRicIndMsgBuf: Only Format 1 supported"); + failedInFormat = true; + break; + } } - } - measRecIdx = 0; - CM_LLIST_FIRST_NODE(&measInfoDb->measuredValue, measValNode); - while(measValNode) - { - measVal = *(double *)measValNode->node; - if(measVal == (int)measVal) - { - measRecord->list.array[measRecIdx]->present = MeasurementRecordItem_PR_integer; - measRecord->list.array[measRecIdx]->choice.integer = (int)measVal; - } - else - { - measRecord->list.array[measRecIdx]->present = MeasurementRecordItem_PR_real; - measRecord->list.array[measRecIdx]->choice.real = measVal; - } - measRecIdx++; + if(failedInFormat) + break; + + /* Encode E2SM-KPM Indication Message */ + xer_fprint(stdout, &asn_DEF_E2SM_KPM_IndicationMessage, &e2smKpmIndMsg); + memset(encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + encRetVal = aper_encode(&asn_DEF_E2SM_KPM_IndicationMessage, 0, &e2smKpmIndMsg, PrepFinalEncBuf, encBuf); + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> E2AP : Could not encode E2SM-KPM Indication Message (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SM-KPM Indication Message \n"); +#ifdef DEBUG_ASN_PRINT + for(int i=0; i< encBufSize; i++) + { + printf("%x",encBuf[i]); + } +#endif + } - /* Once the measurement record is added to the message, delete it from DB */ - cmLListDelFrm(&measInfoDb->measuredValue, measValNode); - DU_FREE(measValNode->node, sizeof(double)); - DU_FREE(measValNode, sizeof(CmLList)); + /* Copy encoded string to RIC Indication Message buffer */ + ricIndMsgBuf->size = encBufSize; + DU_ALLOC(ricIndMsgBuf->buf, ricIndMsgBuf->size); + if(!ricIndMsgBuf->buf) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + break; + } + memset(ricIndMsgBuf->buf, 0, ricIndMsgBuf->size); + memcpy(ricIndMsgBuf->buf, encBuf, encBufSize); - CM_LLIST_FIRST_NODE(&measInfoDb->measuredValue, measValNode); - measVal = 0; + ret = ROK; + break; } - return ROK; + /* Free E2SM-KPM Indication Message */ + FreeE2smKpmIndicationMessage(&e2smKpmIndMsg); + + return ret; } /******************************************************************* * - * @brief Fills measuerement data + * @brief Free E2SM-KPM Indication Header * * @details * - * Function : fillMeasData - * - * Functionality: Fill all measurement recorded for all measurements - * in an action in a RIC subscription + * Function : FreeE2smKpmIndicationHeader * - * @param Measurement data to be filled - * Measurement info list from an action DB - * @return ROK - success - * RFAILED - failure + * Functionality: Free E2SM-KPM Indication Header + * + * @param E2SM-KPM Indication Header to be free + * @return void * ******************************************************************/ -uint8_t fillMeasData(MeasurementData_t *measData, CmLListCp *measInfoListDb) +void FreeE2smKpmIndicationHeader(E2SM_KPM_IndicationHeader_t *e2smKpmIndHdr) { - uint8_t measIdx = 0; - CmLList *measInfoNode = NULLP; - MeasurementInfo *measInfoDb = NULLP; - MeasurementRecord_t *measRecord = NULLP; - - measData->list.count = measInfoListDb->count; - measData->list.size = measData->list.count * sizeof(MeasurementDataItem_t *); - - DU_ALLOC(measData->list.array, measData->list.size); - if(!measData->list.array) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; - } - - measIdx = 0; - CM_LLIST_FIRST_NODE(measInfoListDb, measInfoNode); - while(measInfoNode) - { - measInfoDb = (MeasurementInfo *)measInfoNode->node; - if(measInfoDb) - { - DU_ALLOC(measData->list.array[measIdx], sizeof(MeasurementDataItem_t)); - if(!measData->list.array[measIdx]) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; - } + E2SM_KPM_IndicationHeader_Format1_t *format1 = NULLP; - measRecord = &measData->list.array[measIdx]->measRecord; - if(fillMeasRecord(measRecord, measInfoDb) != ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to fill measurement record"); - return RFAILED; - } - measIdx++; - } - measInfoNode = measInfoNode->next; - } + if(e2smKpmIndHdr) + { + switch(e2smKpmIndHdr->indicationHeader_formats.present) + { + case E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_indicationHeader_Format1: + { + if(e2smKpmIndHdr->indicationHeader_formats.choice.indicationHeader_Format1) + { + format1 = e2smKpmIndHdr->indicationHeader_formats.choice.indicationHeader_Format1; - return ROK; + DU_FREE(format1->colletStartTime.buf, format1->colletStartTime.size); + DU_FREE(format1, sizeof(E2SM_KPM_IndicationHeader_Format1_t)); + } + break; + } + case E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_NOTHING: + default: + break; + } + } } /******************************************************************* * - * @brief Fill all measurement info + * @brief Fill RIC Indication Header buffer * * @details * - * Function : fillMeasInfoList - * - * Functionality: Fills all measurement info belonging to an action - * in a RIC subscription + * Function : fillRicIndHeader * - * @param Measurement Info list to be filled - * Measurement Info list from E2AP DB + * Functionality: Fill E2SM-KPM Indication Header + * Encode this message and copy to RIC Indication Header buffer + * + * @param RIC Indication Header buffer to be filled + * Source RIC subscription info from E2AP DB * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t fillMeasInfoList(MeasurementInfoList_t *measInfoList, CmLListCp *measInfoListDb) +uint8_t fillRicIndHeader(RICindicationHeader_t *ricIndHdr, RicSubscription *ricSubsInfo) { - uint8_t measInfoIdx = 0; - CmLList *measInfoNode = NULLP; - MeasurementInfo *measInfoDb = NULLP; - MeasurementInfoItem_t *measInfoItem = NULLP; - - measInfoList->list.count = measInfoListDb->count; - measInfoList->list.size = measInfoList->list.count * sizeof(MeasurementInfoItem_t *); - - DU_ALLOC(measInfoList->list.array, measInfoList->list.size); - if(!measInfoList->list.array) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; - } + uint8_t ret = RFAILED; + uint8_t secBufIdx = 0, milliSecBufIdx = 0; + int8_t byteIdx = 0; + bool formatFailure = false; + RanFunction *ranFunc = NULLP; + ReportStartTime *startTime = NULLP; + E2SM_KPM_IndicationHeader_t e2smKpmIndHdr; + E2SM_KPM_IndicationHeader_Format1_t *format1 = NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ - measInfoIdx = 0; - CM_LLIST_FIRST_NODE(measInfoListDb, measInfoNode); - while(measInfoNode) + while(true) { - DU_ALLOC(measInfoList->list.array[measInfoIdx], sizeof(MeasurementInfoItem_t)); - if(!measInfoList->list.array[measInfoIdx]) + ranFunc = fetchRanFuncFromRanFuncId(ricSubsInfo->ranFuncId); + if(ranFunc == NULLP) { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP : RAN Function ID [%d] not found", ricSubsInfo->ranFuncId); + break; } - measInfoItem = measInfoList->list.array[measInfoIdx]; - measInfoDb = (MeasurementInfo *)measInfoNode->node; - if(measInfoDb) + memset(&e2smKpmIndHdr, 0, sizeof(E2SM_KPM_IndicationHeader_t)); + + e2smKpmIndHdr.indicationHeader_formats.present = ranFunc->ricIndicationHeaderFormat; + switch(e2smKpmIndHdr.indicationHeader_formats.present) { - /* Measurement Type */ - measInfoItem->measType.present = MeasurementType_PR_measName; - measInfoItem->measType.choice.measName.size = strlen(measInfoDb->measurementTypeName); + case E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_indicationHeader_Format1: + { + DU_ALLOC(e2smKpmIndHdr.indicationHeader_formats.choice.indicationHeader_Format1, \ + sizeof(E2SM_KPM_IndicationHeader_Format1_t)); + if(!e2smKpmIndHdr.indicationHeader_formats.choice.indicationHeader_Format1) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + formatFailure = true; + break; + } + format1 = e2smKpmIndHdr.indicationHeader_formats.choice.indicationHeader_Format1; - DU_ALLOC(measInfoItem->measType.choice.measName.buf, measInfoItem->measType.choice.measName.size); - if(!measInfoItem->measType.choice.measName.buf) + /* Fetch reporting period start time from DB */ + switch(ricSubsInfo->eventTriggerDefinition.formatType) + { + case 1: + { + startTime = &ricSubsInfo->eventTriggerDefinition.choice.format1.startTime; + } + } + + format1->colletStartTime.size = 8 * sizeof(uint8_t); + DU_ALLOC(format1->colletStartTime.buf, format1->colletStartTime.size); + if(!format1->colletStartTime.buf) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + formatFailure = true; + break; + } + + /* As per O-RAN.WG3.E2SM-KPM-R003-v03.00, section 8.3.12 and + * RFC 5905, section 6 : + * Time stamp has a 64-bit format where first 32-bit is seconds + * and next 32-bit is fraction in picosecond-level. + * This fraction has been rounded in microseconds. + * + * Hence, + * Storing 32-bit seconds at MSB 0-3 and + * 32-bit milliseconds at next 4 bytes i.e. bytes 4-7 + */ + secBufIdx = 0; + milliSecBufIdx = 4; + for(byteIdx = 3; byteIdx >= 0; byteIdx--) + { + format1->colletStartTime.buf[secBufIdx++] = startTime->timeInSec >> (8*byteIdx); + format1->colletStartTime.buf[milliSecBufIdx++] = startTime->timeInMilliSec >> (8*byteIdx); + } + break; + } + + case E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_NOTHING: + default: { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP : Only E2SM-KPM Indication Header Format 1 supported"); + formatFailure = true; + break; } + } - memcpy(measInfoItem->measType.choice.measName.buf, measInfoDb->measurementTypeName,\ - measInfoItem->measType.choice.measName.size); + if(formatFailure) + break; - measInfoIdx++; + /* Encode E2SM-KPM Indication Header */ + xer_fprint(stdout, &asn_DEF_E2SM_KPM_IndicationHeader, &e2smKpmIndHdr); + memset(encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + encRetVal = aper_encode(&asn_DEF_E2SM_KPM_IndicationHeader, 0, &e2smKpmIndHdr, PrepFinalEncBuf, encBuf); + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> E2AP : Could not encode E2SM-KPM Indication Header (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; } - measInfoNode = measInfoNode->next; - measInfoDb = NULLP; + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SM-KPM Indication Header \n"); +#ifdef DEBUG_ASN_PRINT + for(int i=0; i< encBufSize; i++) + { + printf("%x",encBuf[i]); + } +#endif + } + + /* Copy encoded string to RIC Indication Header buffer */ + ricIndHdr->size = encBufSize; + DU_ALLOC(ricIndHdr->buf, ricIndHdr->size); + if(!ricIndHdr->buf) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + break; + } + memset(ricIndHdr->buf, 0, ricIndHdr->size); + memcpy(ricIndHdr->buf, encBuf, encBufSize); + ret = ROK; + break; } - return ROK; + /* Free E2SM-KPM Indication Header */ + FreeE2smKpmIndicationHeader(&e2smKpmIndHdr); + + return ret; } - /******************************************************************* +/******************************************************************* * - * @brief Fill E2SM-KPM Indication Message Format 1 + * brief Fill the RIC Indication Message * * @details * - * Function : fillE2smKpmIndMsgFormat1 + * Function : fillRicIndication * - * Functionality: Fill E2SM-KPM Indication Message Format 1 + * Functionality: Fills the RIC Indication Message * - * @param Format 1 Message to be filled - * Action Definition format 1 from E2AP DB + * @param RIC Indication Message to be filled + * RIC Subscription DB + * Action DB * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t fillE2smKpmIndMsgFormat1(E2SM_KPM_IndicationMessage_Format1_t *format1Msg, ActionDefFormat1 *format1) +uint8_t fillRicIndication(RICindication_t *ricIndicationMsg, RicSubscription *ricSubscriptionInfo, ActionInfo *actionInfo) { - /* Measurement Data */ - if(fillMeasData(&format1Msg->measData, &format1->measurementInfoList) != ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to fill measurement data"); - return RFAILED; - } + uint8_t elementCnt = 0, idx = 0; + uint8_t ret = ROK; - /* Measurement Information */ - DU_ALLOC(format1Msg->measInfoList, sizeof(MeasurementInfoList_t)); - if(!format1Msg->measInfoList) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; - } + elementCnt = 6; - if(fillMeasInfoList(format1Msg->measInfoList, &format1->measurementInfoList) != ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to fill measurement information list"); - return RFAILED; - } + ricIndicationMsg->protocolIEs.list.count = elementCnt; + ricIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(RICindication_IEs_t *); - /* Granularity Period */ - DU_ALLOC(format1Msg->granulPeriod, sizeof(GranularityPeriod_t)); - if(!format1Msg->granulPeriod) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; - } - *(format1Msg->granulPeriod) = format1->granularityPeriod; + /* Initialize the Ric Indication members */ + DU_ALLOC(ricIndicationMsg->protocolIEs.list.array, ricIndicationMsg->protocolIEs.list.size); + if(ricIndicationMsg->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } - return ROK; + for(idx=0; idxprotocolIEs.list.array[idx], sizeof(RICindication_IEs_t)); + if(ricIndicationMsg->protocolIEs.list.array[idx] == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + return RFAILED; + } + } + + /* RIC Request ID */ + idx = 0; + ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICrequestID; + ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; + ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICrequestID; + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID = \ + ricSubscriptionInfo->requestId.requestorId; + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID = \ + ricSubscriptionInfo->requestId.instanceId; + + /* RAN Function ID */ + idx++; + ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionID; + ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; + ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RANfunctionID; + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RANfunctionID = ricSubscriptionInfo->ranFuncId; + + /* RIC Action ID */ + idx++; + ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICactionID; + ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; + ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICactionID; + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICactionID = actionInfo->actionId; + + /* RIC Indication Type */ + idx++; + ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationType; + ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; + ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICindicationType; + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationType = actionInfo->type; + + /* RIC Indication Header */ + idx++; + ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationHeader; + ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; + ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICindicationHeader; + if(fillRicIndHeader(&ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader, \ + ricSubscriptionInfo) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill RIC Indication header"); + return RFAILED; + } + + /* RIC Indication Message */ + idx++; + ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationMessage; + ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; + ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICindicationMessage; + if(fillRicIndMsgBuf(&ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage, \ + actionInfo) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill RIC Indication Message"); + return RFAILED; + } + + return ret; } /******************************************************************* * - * @brief Fill RIC Indication Message buffer + * @brief Builds and Send the RicIndication Message * * @details * - * Function : fillRicIndMsgBuf + * Function : BuildAndSendRicIndication + * + * Functionality:Fills the RicIndication Message * - * Functionality: Fill E2SM-KPM Indication Message - * Encode this message and copy to RIC Indication Message buffer - * - * @param RIC Indication Message buffer to be filled - * Source action info from E2AP DB * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t fillRicIndMsgBuf(RICindicationMessage_t *ricIndMsgBuf, ActionInfo *actionInfo) + +uint8_t BuildAndSendRicIndication(RicSubscription *ricSubscriptionInfo, ActionInfo *actionInfo) { - uint8_t ret = RFAILED; - bool failedInFormat = false; - E2SM_KPM_IndicationMessage_t e2smKpmIndMsg; + uint8_t ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + RICindication_t *ricIndicationMsg = NULLP; asn_enc_rval_t encRetVal; /* Encoder return value */ - memset(&e2smKpmIndMsg, 0, sizeof(E2SM_KPM_IndicationMessage_t)); - while(true) { - /* E2SM-KPM Indication message format type */ - e2smKpmIndMsg.indicationMessage_formats.present = actionInfo->definition.formatType; - switch(e2smKpmIndMsg.indicationMessage_formats.present) - { - case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1: - { - /* E2SM-KPM Indication message format 1 */ - DU_ALLOC(e2smKpmIndMsg.indicationMessage_formats.choice.indicationMessage_Format1, \ - sizeof(E2SM_KPM_IndicationMessage_Format1_t)); - if(!e2smKpmIndMsg.indicationMessage_formats.choice.indicationMessage_Format1) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - failedInFormat = true; - break; - } + DU_LOG("\nINFO --> E2AP : Building RIC Indication Message\n"); - if(fillE2smKpmIndMsgFormat1(e2smKpmIndMsg.indicationMessage_formats.choice.indicationMessage_Format1, \ - &actionInfo->definition.choice.format1) != ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to fill E2SM-KPM Indication message format 1"); - failedInFormat = true; - break; - } - break; - } + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + break; + } - case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_NOTHING: - case E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format2: - default: - { - DU_LOG("\nERROR --> E2AP : fillRicIndMsgBuf: Only Format 1 supported"); - failedInFormat = true; - break; - } + e2apMsg->present = E2AP_PDU_PR_initiatingMessage; + DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + if(e2apMsg->choice.initiatingMessage == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + break; } + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICindication; + e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; + e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICindication; - if(failedInFormat) + ricIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.RICindication; + + if(fillRicIndication(ricIndicationMsg, ricSubscriptionInfo, actionInfo) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill RIC Indication message"); break; + } - /* Encode E2SM-KPM Indication Message */ - xer_fprint(stdout, &asn_DEF_E2SM_KPM_IndicationMessage, &e2smKpmIndMsg); + /* 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_E2SM_KPM_IndicationMessage, 0, &e2smKpmIndMsg, PrepFinalEncBuf, encBuf); + encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\ + encBuf); if(encRetVal.encoded == ENCODE_FAIL) { - DU_LOG("\nERROR --> E2AP : Could not encode E2SM-KPM Indication Message (at %s)\n",\ + DU_LOG("\nERROR --> E2AP : Could not encode RIC Indication Message (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); break; } else { - DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SM-KPM Indication Message \n"); + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Indication Message \n"); #ifdef DEBUG_ASN_PRINT for(int i=0; i< encBufSize; i++) { @@ -3661,770 +4590,927 @@ uint8_t fillRicIndMsgBuf(RICindicationMessage_t *ricIndMsgBuf, ActionInfo *actio #endif } - /* Copy encoded string to RIC Indication Message buffer */ - ricIndMsgBuf->size = encBufSize; - DU_ALLOC(ricIndMsgBuf->buf, ricIndMsgBuf->size); - if(!ricIndMsgBuf->buf) + if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK) { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - break; - } - memset(ricIndMsgBuf->buf, 0, ricIndMsgBuf->size); - memcpy(ricIndMsgBuf->buf, encBuf, encBufSize); + DU_LOG("\nINFO --> E2AP : Sending RIC Indication Message"); + } ret = ROK; break; } + FreeRicIndication(e2apMsg); + return ret; +} + +/******************************************************************* + * + * @brief free e2 node component configuration req and rsp + * + * @details + * + * Function : freeE2NodeComponentConfiguration + * + * Functionality: + * - free e2 node component configuration req and rsp + * + * @params[in] E2nodeComponentConfiguration_t *e2nodeComponentConfiguration + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void freeE2NodeComponentConfiguration(E2nodeComponentConfiguration_t *e2nodeComponentConfiguration) +{ + /* Free E2 Node Component Request Part */ + DU_FREE(e2nodeComponentConfiguration->e2nodeComponentRequestPart.buf, e2nodeComponentConfiguration->e2nodeComponentRequestPart.size); + + /* Free E2 Node Component Response Part */ + DU_FREE(e2nodeComponentConfiguration->e2nodeComponentResponsePart.buf, e2nodeComponentConfiguration->e2nodeComponentResponsePart.size); + +} - /* Free E2SM-KPM Indication Message */ - FreeE2smKpmIndicationMessage(&e2smKpmIndMsg); +/******************************************************************* + * + * @brief free e2 node component component identifier + * + * @details + * + * Function : freeE2NodeComponentIdentifier + * + * Functionality: + * - free e2 node component component identifier + * + * @params[in] E2nodeComponentID_t *componentID + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ - return ret; +void freeE2NodeComponentIdentifier(E2nodeComponentID_t *componentID) +{ + if(componentID->choice.e2nodeComponentInterfaceTypeF1) + { + DU_FREE(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf, componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); + DU_FREE(componentID->choice.e2nodeComponentInterfaceTypeF1, sizeof(E2nodeComponentInterfaceF1_t)); + } + } /******************************************************************* * - * @brief Free E2SM-KPM Indication Header + * @brief Deallocate the memory allocated for E2nodeConfigurationUpdate msg * * @details * - * Function : FreeE2smKpmIndicationHeader + * Function : FreeE2NodeConfigUpdate * - * Functionality: Free E2SM-KPM Indication Header - * - * @param E2SM-KPM Indication Header to be free - * @return void + * Functionality: + * - freeing the memory allocated for E2nodeConfigurationUpdate * - ******************************************************************/ -void FreeE2smKpmIndicationHeader(E2SM_KPM_IndicationHeader_t *e2smKpmIndHdr) + * @params[in] E2AP_PDU_t *e2apMsg + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void FreeE2NodeConfigUpdate(E2AP_PDU_t *e2apMsg) { - E2SM_KPM_IndicationHeader_Format1_t *format1 = NULLP; + uint8_t arrIdx =0, e2NodeUpdateListIdx=0, e2NodeRemovalListIdx=0, e2NodeAddListIdx=0; + E2nodeConfigurationUpdate_t *e2NodeConfigUpdate =NULL; + E2nodeComponentConfigUpdate_List_t *e2NodeUpdateList =NULL; + E2nodeComponentConfigUpdate_ItemIEs_t *e2NodeUpdateItem =NULL; + E2nodeComponentConfigRemoval_List_t *e2NodeRemovalList =NULL; + E2nodeComponentConfigRemoval_ItemIEs_t *e2NodeRemovalItem =NULL; + E2nodeComponentConfigAddition_List_t *e2NodeAddList =NULL; + E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem =NULL; - if(e2smKpmIndHdr) + if(e2apMsg != NULLP) { - switch(e2smKpmIndHdr->indicationHeader_formats.present) + if(e2apMsg->choice.initiatingMessage != NULLP) { - case E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_indicationHeader_Format1: + e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate; + if(e2NodeConfigUpdate->protocolIEs.list.array != NULLP) + { + for(arrIdx = 0; arrIdx < e2NodeConfigUpdate->protocolIEs.list.count; arrIdx++) { - if(e2smKpmIndHdr->indicationHeader_formats.choice.indicationHeader_Format1) + if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]) { - format1 = e2smKpmIndHdr->indicationHeader_formats.choice.indicationHeader_Format1; - DU_FREE(format1->colletStartTime.buf, format1->colletStartTime.size); - DU_FREE(format1, sizeof(E2SM_KPM_IndicationHeader_Format1_t)); + switch(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + break; + + case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition: + { + e2NodeAddList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List; + if(e2NodeAddList->list.array) + { + for(e2NodeAddListIdx = 0; e2NodeAddListIdx< e2NodeAddList->list.count; e2NodeAddListIdx++) + { + e2NodeAddItem = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[e2NodeAddListIdx]; + + freeE2NodeComponentConfiguration(&e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration); + freeE2NodeComponentIdentifier(&e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID); + DU_FREE(e2NodeAddItem, sizeof(E2nodeComponentConfigAddition_ItemIEs_t)); + } + DU_FREE(e2NodeAddList->list.array, e2NodeAddList->list.size); + } + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate: + { + e2NodeUpdateList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdate_List; + if(e2NodeUpdateList->list.array) + { + for(e2NodeUpdateListIdx = 0; e2NodeUpdateListIdx< e2NodeUpdateList->list.count; e2NodeUpdateListIdx++) + { + e2NodeUpdateItem = (E2nodeComponentConfigUpdate_ItemIEs_t *) e2NodeUpdateList->list.array[e2NodeUpdateListIdx]; + + freeE2NodeComponentConfiguration(&e2NodeUpdateItem->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentConfiguration); + freeE2NodeComponentIdentifier(&e2NodeUpdateItem->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentID); + DU_FREE(e2NodeUpdateItem, sizeof(E2nodeComponentConfigUpdate_ItemIEs_t)); + } + DU_FREE(e2NodeUpdateList->list.array, e2NodeUpdateList->list.size); + } + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval: + { + e2NodeRemovalList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemoval_List; + if(e2NodeRemovalList->list.array) + { + for(e2NodeRemovalListIdx = 0; e2NodeRemovalListIdx< e2NodeRemovalList->list.count; e2NodeRemovalListIdx++) + { + e2NodeRemovalItem = (E2nodeComponentConfigRemoval_ItemIEs_t *) e2NodeRemovalList->list.array[e2NodeRemovalListIdx]; + + freeE2NodeComponentIdentifier(&e2NodeRemovalItem->value.choice.E2nodeComponentConfigRemoval_Item.e2nodeComponentID); + DU_FREE(e2NodeRemovalItem, sizeof(E2nodeComponentConfigRemoval_ItemIEs_t)); + } + DU_FREE(e2NodeRemovalList->list.array, e2NodeRemovalList->list.size); + } + break; + } + + default: + break; + } + DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t)); } - break; } - case E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_NOTHING: - default: - break; + DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size); + } + DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } } /******************************************************************* * - * @brief Fill RIC Indication Header buffer + * @brief Buld and send the E2 node config update msg * * @details * - * Function : fillRicIndHeader + * Function : BuildAndSendE2NodeConfigUpdate * - * Functionality: Fill E2SM-KPM Indication Header - * Encode this message and copy to RIC Indication Header buffer - * - * @param RIC Indication Header buffer to be filled - * Source RIC subscription info from E2AP DB + * Functionality: + * - Buld and send the E2 node config update msg + * + * @params[in] * @return ROK - success * RFAILED - failure * - ******************************************************************/ -uint8_t fillRicIndHeader(RICindicationHeader_t *ricIndHdr, RicSubscription *ricSubsInfo) + * ****************************************************************/ + +uint8_t BuildAndSendE2NodeConfigUpdate(E2NodeConfigList *e2NodeList) { uint8_t ret = RFAILED; - uint8_t secBufIdx = 0, milliSecBufIdx = 0; - int8_t byteIdx = 0; - bool formatFailure = false; - RanFunction *ranFunc = NULLP; - ReportStartTime *startTime = NULLP; - E2SM_KPM_IndicationHeader_t e2smKpmIndHdr; - E2SM_KPM_IndicationHeader_Format1_t *format1 = NULLP; - asn_enc_rval_t encRetVal; /* Encoder return value */ + uint8_t arrIdx = 0,elementCnt = 0, transId=0; + E2AP_PDU_t *e2apMsg = NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ + E2nodeConfigurationUpdate_t *e2NodeConfigUpdate = NULLP; - while(true) + DU_LOG("\nINFO --> E2AP : Building E2 Node config update\n"); + do { - ranFunc = fetchRanFuncFromRanFuncId(ricSubsInfo->ranFuncId); - if(ranFunc == NULLP) + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) { - DU_LOG("\nERROR --> E2AP : RAN Function ID [%d] not found", ricSubsInfo->ranFuncId); + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); break; } - memset(&e2smKpmIndHdr, 0, sizeof(E2SM_KPM_IndicationHeader_t)); - - e2smKpmIndHdr.indicationHeader_formats.present = ranFunc->ricIndicationHeaderFormat; - switch(e2smKpmIndHdr.indicationHeader_formats.present) + e2apMsg->present = E2AP_PDU_PR_initiatingMessage; + DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + if(e2apMsg->choice.initiatingMessage == NULLP) { - case E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_indicationHeader_Format1: - { - DU_ALLOC(e2smKpmIndHdr.indicationHeader_formats.choice.indicationHeader_Format1, \ - sizeof(E2SM_KPM_IndicationHeader_Format1_t)); - if(!e2smKpmIndHdr.indicationHeader_formats.choice.indicationHeader_Format1) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - formatFailure = true; - break; - } - format1 = e2smKpmIndHdr.indicationHeader_formats.choice.indicationHeader_Format1; + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + break; + } + e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2nodeConfigurationUpdate; + e2apMsg->choice.initiatingMessage->value.present = \ + InitiatingMessageE2__value_PR_E2nodeConfigurationUpdate; + e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate; + + elementCnt =1; + if(e2NodeList->addE2NodeCount) + elementCnt++; + if(e2NodeList->updateE2NodeCount) + elementCnt++; + if(e2NodeList->removeE2NodeCount) + elementCnt++; - /* Fetch reporting period start time from DB */ - switch(ricSubsInfo->eventTriggerDefinition.formatType) - { - case 1: - { - startTime = &ricSubsInfo->eventTriggerDefinition.choice.format1.startTime; - } - } + e2NodeConfigUpdate->protocolIEs.list.count = elementCnt; + e2NodeConfigUpdate->protocolIEs.list.size = elementCnt * sizeof(E2nodeConfigurationUpdate_IEs_t*); + DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size); + if(e2NodeConfigUpdate->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed"); + break; + } + + for(arrIdx =0; arrIdxprotocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t)); + if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx] == NULLP) + { + + DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed"); + break; + } + } + + if(arrIdxcolletStartTime.size = 8 * sizeof(uint8_t); - DU_ALLOC(format1->colletStartTime.buf, format1->colletStartTime.size); - if(!format1->colletStartTime.buf) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - formatFailure = true; - break; - } + arrIdx = 0; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_TransactionID; + transId = assignTransactionId(); + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; - /* As per O-RAN.WG3.E2SM-KPM-R003-v03.00, section 8.3.12 and - * RFC 5905, section 6 : - * Time stamp has a 64-bit format where first 32-bit is seconds - * and next 32-bit is fraction in picosecond-level. - * This fraction has been rounded in microseconds. - * - * Hence, - * Storing 32-bit seconds at MSB 0-3 and - * 32-bit milliseconds at next 4 bytes i.e. bytes 4-7 - */ - secBufIdx = 0; - milliSecBufIdx = 4; - for(byteIdx = 3; byteIdx >= 0; byteIdx--) - { - format1->colletStartTime.buf[secBufIdx++] = startTime->timeInSec >> (8*byteIdx); - format1->colletStartTime.buf[milliSecBufIdx++] = startTime->timeInMilliSec >> (8*byteIdx); - } - break; - } + if(e2NodeList->addE2NodeCount) + { + arrIdx++; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigAddition_List; + if(BuildE2NodeConfigAddList(&(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List),\ + ProcedureCodeE2_id_E2nodeConfigurationUpdate, e2NodeList->addE2NodeCount, e2NodeList->addE2Node)!=ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to create E2 Node config list"); + break; + } + } + + if(e2NodeList->updateE2NodeCount) + { + arrIdx++; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigUpdate_List; + if(BuildE2NodeConfigUpdateList(&e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdate_List,\ + e2NodeList->updateE2NodeCount, e2NodeList->updateE2Node) != ROK) + { - case E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_NOTHING: - default: + DU_LOG("\nERROR --> E2AP : Failed to update the E2 node configuration"); + break; + } + } + + if(e2NodeList->removeE2NodeCount) + { + arrIdx++; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigRemoval_List; + if(BuildE2NodeConfigRemoveList(&e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemoval_List,\ + e2NodeList->removeE2NodeCount, e2NodeList->removeE2Node) != ROK) { - DU_LOG("\nERROR --> E2AP : Only E2SM-KPM Indication Header Format 1 supported"); - formatFailure = true; - break; + + DU_LOG("\nERROR --> E2AP : Failed to remove the E2 node configuration"); + break; } } - if(formatFailure) - break; + /* Prints the Msg formed */ + xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg); - /* Encode E2SM-KPM Indication Header */ - xer_fprint(stdout, &asn_DEF_E2SM_KPM_IndicationHeader, &e2smKpmIndHdr); memset(encBuf, 0, ENC_BUF_MAX_LEN); encBufSize = 0; - encRetVal = aper_encode(&asn_DEF_E2SM_KPM_IndicationHeader, 0, &e2smKpmIndHdr, PrepFinalEncBuf, encBuf); + encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf); if(encRetVal.encoded == ENCODE_FAIL) { - DU_LOG("\nERROR --> E2AP : Could not encode E2SM-KPM Indication Header (at %s)\n",\ + DU_LOG("\nERROR --> E2AP : Could not encode E2nodeConfigurationUpdate structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); break; } else { - DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SM-KPM Indication Header \n"); + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2nodeConfigurationUpdate\n"); #ifdef DEBUG_ASN_PRINT for(int i=0; i< encBufSize; i++) { printf("%x",encBuf[i]); - } + } #endif } - - /* Copy encoded string to RIC Indication Header buffer */ - ricIndHdr->size = encBufSize; - DU_ALLOC(ricIndHdr->buf, ricIndHdr->size); - if(!ricIndHdr->buf) + if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize)) { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); + DU_LOG("\nERROR --> E2AP : Sending E2 node config update failed"); break; } - memset(ricIndHdr->buf, 0, ricIndHdr->size); - memcpy(ricIndHdr->buf, encBuf, encBufSize); + + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; + memcpy(&duCb.e2apDb.e2TimersInfo.e2Timers.e2NodeConfigUpdate.configList, e2NodeList, sizeof(E2NodeConfigList)); ret = ROK; break; - } - - /* Free E2SM-KPM Indication Header */ - FreeE2smKpmIndicationHeader(&e2smKpmIndHdr); - + }while(true); + + FreeE2NodeConfigUpdate(e2apMsg); return ret; } /******************************************************************* * - * brief Fill the RIC Indication Message + * @brief Deallocate the memory allocated for E2ResetRequest msg * * @details * - * Function : fillRicIndication + * Function : FreeE2ResetRequest * - * Functionality: Fills the RIC Indication Message + * Functionality: + * - freeing the memory allocated for E2ResetRequest * - * @param RIC Indication Message to be filled - * RIC Subscription DB - * Action DB + * @params[in] E2AP_PDU_t *e2apMsg * @return ROK - success * RFAILED - failure * - ******************************************************************/ -uint8_t fillRicIndication(RICindication_t *ricIndicationMsg, RicSubscription *ricSubscriptionInfo, ActionInfo *actionInfo) + * ****************************************************************/ +void FreeE2ResetRequest(E2AP_PDU_t *e2apMsg) { - uint8_t elementCnt = 0, idx = 0; - uint8_t ret = ROK; - - elementCnt = 6; - - ricIndicationMsg->protocolIEs.list.count = elementCnt; - ricIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(RICindication_IEs_t *); - - /* Initialize the Ric Indication members */ - DU_ALLOC(ricIndicationMsg->protocolIEs.list.array, ricIndicationMsg->protocolIEs.list.size); - if(ricIndicationMsg->protocolIEs.list.array == NULLP) - { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; - } + uint8_t ieIdx =0; + ResetRequestE2_t *resetReq = NULLP; - for(idx=0; idxprotocolIEs.list.array[idx], sizeof(RICindication_IEs_t)); - if(ricIndicationMsg->protocolIEs.list.array[idx] == NULLP) + if(e2apMsg->choice.initiatingMessage != NULLP) { - DU_LOG("\nERROR --> E2AP : Memory allocation in [%s] at line [%d]", __func__, __LINE__); - return RFAILED; + resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2; + if(resetReq->protocolIEs.list.array) + { + for(ieIdx = 0; ieIdx < resetReq->protocolIEs.list.count; ieIdx++) + { + DU_FREE(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t)); + } + DU_FREE(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size); + } + DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } - - /* RIC Request ID */ - idx = 0; - ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICrequestID; - ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; - ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICrequestID; - ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID = \ - ricSubscriptionInfo->requestId.requestorId; - ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID = \ - ricSubscriptionInfo->requestId.instanceId; - - /* RAN Function ID */ - idx++; - ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionID; - ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; - ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RANfunctionID; - ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RANfunctionID = ricSubscriptionInfo->ranFuncId; - - /* RIC Action ID */ - idx++; - ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICactionID; - ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; - ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICactionID; - ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICactionID = actionInfo->actionId; - - /* RIC Indication Type */ - idx++; - ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationType; - ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; - ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICindicationType; - ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationType = actionInfo->type; - - /* RIC Indication Header */ - idx++; - ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationHeader; - ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; - ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICindicationHeader; - if(fillRicIndHeader(&ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader, \ - ricSubscriptionInfo) != ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to fill RIC Indication header"); - return RFAILED; - } - - /* RIC Indication Message */ - idx++; - ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationMessage; - ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; - ricIndicationMsg->protocolIEs.list.array[idx]->value.present = RICindication_IEs__value_PR_RICindicationMessage; - if(fillRicIndMsgBuf(&ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage, \ - actionInfo) != ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to fill RIC Indication Message"); - return RFAILED; - } - - return ret; } /******************************************************************* * - * @brief Builds and Send the RicIndication Message + * @brief Build and send the E2 reset request msg * * @details * - * Function : BuildAndSendRicIndication + * Function : BuildAndSendE2ResetRequest * - * Functionality:Fills the RicIndication Message + * Functionality: + * - Buld and send the E2 reset request msg to RIC * + * @params[in] + * Reset cause * @return ROK - success * RFAILED - failure * - ******************************************************************/ - -uint8_t BuildAndSendRicIndication(RicSubscription *ricSubscriptionInfo, ActionInfo *actionInfo) + * ****************************************************************/ +uint8_t BuildAndSendE2ResetRequest(E2FailureCause resetCause) { - uint8_t ret = RFAILED; - E2AP_PDU_t *e2apMsg = NULLP; - RICindication_t *ricIndicationMsg = NULLP; - asn_enc_rval_t encRetVal; /* Encoder return value */ + uint8_t ieIdx = 0, elementCnt = 0, transId = 0; + uint8_t ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + ResetRequestE2_t *resetReq = NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ - while(true) + DU_LOG("\nINFO --> E2AP : Building E2 Reset Request\n"); + + do { - DU_LOG("\nINFO --> E2AP : Building RIC Indication Message\n"); + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) + { + DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for E2AP-PDU failed"); + break; + } + + e2apMsg->present = E2AP_PDU_PR_initiatingMessage; + DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + if(e2apMsg->choice.initiatingMessage == NULLP) + { + DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for initiatingMessage"); + break; + } + + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_Reset; + e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; + e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ResetRequestE2; + resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2; + + elementCnt = 2; + resetReq->protocolIEs.list.count = elementCnt; + resetReq->protocolIEs.list.size = elementCnt * sizeof(ResetRequestIEs_t *); - DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); - if(e2apMsg == NULLP) + DU_ALLOC(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size); + if(!resetReq->protocolIEs.list.array) { - DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \ + Reset Request IE array"); break; } - e2apMsg->present = E2AP_PDU_PR_initiatingMessage; - DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); - if(e2apMsg->choice.initiatingMessage == NULLP) + for(ieIdx = 0; ieIdx < elementCnt; ieIdx++) { - DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); - break; + DU_ALLOC(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t)); + if(!resetReq->protocolIEs.list.array[ieIdx]) + { + DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \ + Reset Request IE array element"); + break; + } } - e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICindication; - e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; - e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICindication; - - ricIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.RICindication; - if(fillRicIndication(ricIndicationMsg, ricSubscriptionInfo, actionInfo) != ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to fill RIC Indication message"); + /* In case of failure */ + if(ieIdx < elementCnt) break; - } + + ieIdx = 0; + resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID; + resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject; + resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_TransactionID; + transId = assignTransactionId(); + resetReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId; + + ieIdx++; + resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_CauseE2; + resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_ignore; + resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_CauseE2; + fillE2Cause(&resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2, resetCause); /* 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 Indication Message (at %s)\n",\ + DU_LOG("\nERROR --> E2AP : Could not encode reset request structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); break; } else { - DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Indication Message \n"); + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for reset request\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("\nINFO --> E2AP : Sending RIC Indication Message"); - + DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed"); + break; } + + /* In case the message is sent successfully, store the transaction info to + * be used when response is received */ + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; + ret = ROK; break; - } - FreeRicIndication(e2apMsg); + }while(true); + + /* Free all memory */ + FreeE2ResetRequest(e2apMsg); return ret; } /******************************************************************* * - * @brief free e2 node component configuration req and rsp + * @brief Deallocate the memory allocated for Reset Response msg * * @details * - * Function : freeE2NodeComponentConfiguration + * Function : freeAperDecodingOfE2ResetRsp * * Functionality: - * - free e2 node component configuration req and rsp + * - freeing the memory allocated for Reset response * - * @params[in] E2nodeComponentConfiguration_t *e2nodeComponentConfiguration - * @return ROK - success - * RFAILED - failure + * @params[in] ResetResponseE2_t *resetResponse + * @return void * * ****************************************************************/ - -void freeE2NodeComponentConfiguration(E2nodeComponentConfiguration_t *e2nodeComponentConfiguration) +void freeAperDecodingOfE2ResetRsp(ResetResponseE2_t *resetResponse) { - /* Free E2 Node Component Request Part */ - DU_FREE(e2nodeComponentConfiguration->e2nodeComponentRequestPart.buf, e2nodeComponentConfiguration->e2nodeComponentRequestPart.size); + uint8_t ieIdx; - /* Free E2 Node Component Response Part */ - DU_FREE(e2nodeComponentConfiguration->e2nodeComponentResponsePart.buf, e2nodeComponentConfiguration->e2nodeComponentResponsePart.size); - + if(resetResponse) + { + if(resetResponse->protocolIEs.list.array) + { + for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++) + { + if(resetResponse->protocolIEs.list.array[ieIdx]) + { + switch(resetResponse->protocolIEs.list.array[ieIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + break; + + case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2: + break; + } + free(resetResponse->protocolIEs.list.array[ieIdx]); + } + } + free(resetResponse->protocolIEs.list.array); + } + } } -/******************************************************************* +/****************************************************************** * - * @brief free e2 node component component identifier + * @brief Processes E2 Reset Response sent by RIC * * @details * - * Function : freeE2NodeComponentIdentifier + * Function : procResetResponse * - * Functionality: - * - free e2 node component component identifier + * Functionality: Processes E2 Reset Response sent by RIC * - * @params[in] E2nodeComponentID_t *componentID - * @return ROK - success - * RFAILED - failure + * @params[in] E2AP_PDU_t ASN decoded E2AP message + * @return void * * ****************************************************************/ +void procResetResponse(E2AP_PDU_t *e2apMsg) +{ + bool invalidTransId=false; + uint8_t ieIdx =0, transId =0; + uint16_t ranFuncIdx=0; + ResetResponseE2_t *resetResponse =NULLP; -void freeE2NodeComponentIdentifier(E2nodeComponentID_t *componentID) + DU_LOG("\nINFO --> E2AP : E2 Reset Response received"); + resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2;; + + for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++) + { + switch(resetResponse->protocolIEs.list.array[ieIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + { + transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID; + if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) && \ + (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode)) + { + memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); + } + else + { + DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); + invalidTransId = true; + } + break; + } + case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2: + { + for(ranFuncIdx=0; ranFuncIdx0) + { + deleteRicSubscriptionList(&(duCb.e2apDb.ranFunction[ranFuncIdx].subscriptionList)); + memset(&(duCb.e2apDb.ranFunction[ranFuncIdx].pendingSubsRspInfo), 0, MAX_PENDING_SUBSCRIPTION_RSP*sizeof(PendingSubsRspInfo)); + } + } + break; + } + default: + { + DU_LOG("\nERROR --> E2AP : Invalid IE received in E2 Reset Response : %ld", + resetResponse->protocolIEs.list.array[ieIdx]->id); + break; + } + } + + if(invalidTransId == true) + { + break; + } + } + + freeAperDecodingOfE2ResetRsp(resetResponse); +} + +/****************************************************************** + * + * @brief Deallocation of memory allocated by aper decoder for e2 setup Failure + * + * @details + * + * Function : freeAperDecodingOfE2SetupFailure + * + * Functionality: Deallocation of memory allocated by aper decoder for e2 + * setup Failure + * + * @params[in] E2setupFailure_t *e2SetupFailure; + * @return void + * + * ****************************************************************/ +void freeAperDecodingOfE2SetupFailure(E2setupFailure_t *e2SetupFailure) { - if(componentID->choice.e2nodeComponentInterfaceTypeF1) + uint8_t arrIdx; + + if(e2SetupFailure) { - DU_FREE(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf, componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); - DU_FREE(componentID->choice.e2nodeComponentInterfaceTypeF1, sizeof(E2nodeComponentInterfaceF1_t)); + if(e2SetupFailure->protocolIEs.list.array) + { + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + if(e2SetupFailure->protocolIEs.list.array[arrIdx]) + { + free(e2SetupFailure->protocolIEs.list.array[arrIdx]); + } + } + free(e2SetupFailure->protocolIEs.list.array); + } } - } +/****************************************************************** + * + * @brief Processes E2 Setup Failure sent by RIC + * + * @details + * + * Function : procE2SetupFailure + * + * Functionality: Processes E2 Setup failure sent by RIC + * + * @params[in] E2AP_PDU_t ASN decoded E2AP message + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void procE2SetupFailure(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx =0, transId =0, timerValue=0; + E2setupFailure_t *e2SetupFailure; + + DU_LOG("\nINFO --> E2AP : E2 Setup failure received"); + e2SetupFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2setupFailure; + + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + switch(e2SetupFailure->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + { + transId = e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\ + (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) + { + memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); + } + else + { + DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); + return ; + } + break; + } + case ProtocolIE_IDE2_id_TimeToWaitE2: + { + timerValue = convertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); + if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR)) == FALSE) + { + duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR, timerValue); + } + else + { + DU_LOG("\nERROR --> E2AP : EVENT_E2_SETUP_TMR timer is already running"); + return; + } + break; + } + } + } -/******************************************************************* + freeAperDecodingOfE2SetupFailure(e2SetupFailure); +} +/****************************************************************** * - * @brief Deallocate the memory allocated for E2nodeConfigurationUpdate msg + * @brief Deallocation of memory allocated by aper decoder for RIC service Query * * @details * - * Function : FreeE2NodeConfigUpdate + * Function : freeAperDecodingOfRicServiceQuery * - * Functionality: - * - freeing the memory allocated for E2nodeConfigurationUpdate + * Functionality: Deallocation of memory allocated by aper decoder for RIC + * service Query * - * @params[in] E2AP_PDU_t *e2apMsg - * @return ROK - success - * RFAILED - failure + * @params[in] RICserviceQuery_t *ricServiceQuery; + * @return void * * ****************************************************************/ -void FreeE2NodeConfigUpdate(E2AP_PDU_t *e2apMsg) +void freeAperDecodingOfRicServiceQuery(RICserviceQuery_t *ricServiceQuery) { - uint8_t arrIdx =0, e2NodeUpdateListIdx=0, e2NodeRemovalListIdx=0, e2NodeAddListIdx=0; - E2nodeConfigurationUpdate_t *e2NodeConfigUpdate =NULL; - E2nodeComponentConfigUpdate_List_t *e2NodeUpdateList =NULL; - E2nodeComponentConfigUpdate_ItemIEs_t *e2NodeUpdateItem =NULL; - E2nodeComponentConfigRemoval_List_t *e2NodeRemovalList =NULL; - E2nodeComponentConfigRemoval_ItemIEs_t *e2NodeRemovalItem =NULL; - E2nodeComponentConfigAddition_List_t *e2NodeAddList =NULL; - E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem =NULL; + uint8_t arrIdx,ranFuncIdx; + RANfunctionsID_List_t *ranFuncAddedList; - if(e2apMsg != NULLP) + if(ricServiceQuery) { - if(e2apMsg->choice.initiatingMessage != NULLP) + if(ricServiceQuery->protocolIEs.list.array) { - e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate; - if(e2NodeConfigUpdate->protocolIEs.list.array != NULLP) + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) { - for(arrIdx = 0; arrIdx < e2NodeConfigUpdate->protocolIEs.list.count; arrIdx++) + if(ricServiceQuery->protocolIEs.list.array[arrIdx]) { - if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]) + switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id) { - - switch(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id) + case ProtocolIE_IDE2_id_RANfunctionsAccepted: { - case ProtocolIE_IDE2_id_TransactionID: - break; - - case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition: + ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(ranFuncAddedList->list.array) { - e2NodeAddList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List; - if(e2NodeAddList->list.array) - { - for(e2NodeAddListIdx = 0; e2NodeAddListIdx< e2NodeAddList->list.count; e2NodeAddListIdx++) - { - e2NodeAddItem = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[e2NodeAddListIdx]; - - freeE2NodeComponentConfiguration(&e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration); - freeE2NodeComponentIdentifier(&e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID); - DU_FREE(e2NodeAddItem, sizeof(E2nodeComponentConfigAddition_ItemIEs_t)); - } - DU_FREE(e2NodeAddList->list.array, e2NodeAddList->list.size); - } - break; - } - case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate: - { - e2NodeUpdateList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdate_List; - if(e2NodeUpdateList->list.array) - { - for(e2NodeUpdateListIdx = 0; e2NodeUpdateListIdx< e2NodeUpdateList->list.count; e2NodeUpdateListIdx++) - { - e2NodeUpdateItem = (E2nodeComponentConfigUpdate_ItemIEs_t *) e2NodeUpdateList->list.array[e2NodeUpdateListIdx]; - - freeE2NodeComponentConfiguration(&e2NodeUpdateItem->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentConfiguration); - freeE2NodeComponentIdentifier(&e2NodeUpdateItem->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentID); - DU_FREE(e2NodeUpdateItem, sizeof(E2nodeComponentConfigUpdate_ItemIEs_t)); - } - DU_FREE(e2NodeUpdateList->list.array, e2NodeUpdateList->list.size); - } - break; - } - case ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval: + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) { - e2NodeRemovalList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemoval_List; - if(e2NodeRemovalList->list.array) - { - for(e2NodeRemovalListIdx = 0; e2NodeRemovalListIdx< e2NodeRemovalList->list.count; e2NodeRemovalListIdx++) - { - e2NodeRemovalItem = (E2nodeComponentConfigRemoval_ItemIEs_t *) e2NodeRemovalList->list.array[e2NodeRemovalListIdx]; - - freeE2NodeComponentIdentifier(&e2NodeRemovalItem->value.choice.E2nodeComponentConfigRemoval_Item.e2nodeComponentID); - DU_FREE(e2NodeRemovalItem, sizeof(E2nodeComponentConfigRemoval_ItemIEs_t)); - } - DU_FREE(e2NodeRemovalList->list.array, e2NodeRemovalList->list.size); - } - break; + free(ranFuncAddedList->list.array[ranFuncIdx]); } - - default: - break; + free(ranFuncAddedList->list.array);; + } + break; } - DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t)); + default: + break; } + free(ricServiceQuery->protocolIEs.list.array[arrIdx]); } - DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size); } - DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + free(ricServiceQuery->protocolIEs.list.array); } - DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } } - /******************************************************************* * - * @brief Buld and send the E2 node config update msg + * @brief Build RanFunction Delete List * * @details * - * Function : BuildAndSendE2NodeConfigUpdate + * Function : BuildRanFunctionDeleteList * - * Functionality: - * - Buld and send the E2 node config update msg + * Functionality: Build RanFunction Delete List + * + * @params[in] + * RANfunctionsID List + * Count of the RAN function + * Received RAN function list * - * @params[in] * @return ROK - success * RFAILED - failure * - * ****************************************************************/ + ******************************************************************/ -uint8_t BuildAndSendE2NodeConfigUpdate(E2NodeConfigList *e2NodeList) +uint8_t BuildRanFunctionDeleteList(RANfunctionsID_List_t *deleteList, uint8_t count, RanFuncInfo *recvdRanFunc) { - uint8_t ret = RFAILED; - uint8_t arrIdx = 0,elementCnt = 0, transId=0; - E2AP_PDU_t *e2apMsg = NULLP; - asn_enc_rval_t encRetVal; /* Encoder return value */ - E2nodeConfigurationUpdate_t *e2NodeConfigUpdate = NULLP; + uint8_t ranFuncIdx=0; + RANfunctionID_ItemIEs_t *delRanFuncItem; - DU_LOG("\nINFO --> E2AP : Building E2 Node config update\n"); - do + if(count) { - DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); - if(e2apMsg == NULLP) - { - DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); - break; - } - - e2apMsg->present = E2AP_PDU_PR_initiatingMessage; - DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); - if(e2apMsg->choice.initiatingMessage == NULLP) - { - DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); - break; - } - e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; - e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2nodeConfigurationUpdate; - e2apMsg->choice.initiatingMessage->value.present = \ - InitiatingMessageE2__value_PR_E2nodeConfigurationUpdate; - e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate; - - elementCnt =1; - if(e2NodeList->addE2NodeCount) - elementCnt++; - if(e2NodeList->updateE2NodeCount) - elementCnt++; - if(e2NodeList->removeE2NodeCount) - elementCnt++; - - e2NodeConfigUpdate->protocolIEs.list.count = elementCnt; - e2NodeConfigUpdate->protocolIEs.list.size = elementCnt * sizeof(E2nodeConfigurationUpdate_IEs_t*); - DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size); - if(e2NodeConfigUpdate->protocolIEs.list.array == NULLP) - { - DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed"); - break; - } - - for(arrIdx =0; arrIdxprotocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t)); - if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx] == NULLP) - { - - DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed"); - break; - } - } - - if(arrIdxprotocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_TransactionID; - transId = assignTransactionId(); - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; - - if(e2NodeList->addE2NodeCount) - { - arrIdx++; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigAddition_List; - if(BuildE2NodeConfigAddList(&(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List),\ - ProcedureCodeE2_id_E2nodeConfigurationUpdate, e2NodeList->addE2NodeCount, e2NodeList->addE2Node)!=ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to create E2 Node config list"); - break; - } - } - - if(e2NodeList->updateE2NodeCount) - { - arrIdx++; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigUpdate_List; - if(BuildE2NodeConfigUpdateList(&e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdate_List,\ - e2NodeList->updateE2NodeCount, e2NodeList->updateE2Node) != ROK) - { - - DU_LOG("\nERROR --> E2AP : Failed to update the E2 node configuration"); - break; - } - } - - if(e2NodeList->removeE2NodeCount) - { - arrIdx++; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigRemoval_List; - if(BuildE2NodeConfigRemoveList(&e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemoval_List,\ - e2NodeList->removeE2NodeCount, e2NodeList->removeE2Node) != ROK) - { - - DU_LOG("\nERROR --> E2AP : Failed to remove the E2 node configuration"); - break; - } - } - - /* 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) + deleteList->list.count = count; + deleteList->list.size = deleteList->list.count * sizeof(RANfunctionID_ItemIEs_t*); + DU_ALLOC(deleteList->list.array, deleteList->list.size); + if(deleteList->list.array == NULLP) { - DU_LOG("\nERROR --> E2AP : Could not encode E2nodeConfigurationUpdate structure (at %s)\n",\ - encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - break; + DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); + return RFAILED; } - else + for(ranFuncIdx = 0; ranFuncIdx< deleteList->list.count; ranFuncIdx++) { - DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2nodeConfigurationUpdate\n"); -#ifdef DEBUG_ASN_PRINT - for(int i=0; i< encBufSize; i++) + DU_ALLOC(deleteList->list.array[ranFuncIdx], sizeof(RANfunctionID_ItemIEs_t)); + if(deleteList->list.array[ranFuncIdx] == NULLP) { - printf("%x",encBuf[i]); + DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); + return RFAILED; } -#endif - } - if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize)) - { - DU_LOG("\nERROR --> E2AP : Sending E2 node config update failed"); - break; - } + delRanFuncItem= (RANfunctionID_ItemIEs_t *) deleteList->list.array[ranFuncIdx]; + delRanFuncItem->id = ProtocolIE_IDE2_id_RANfunctionID_Item; + delRanFuncItem->criticality = CriticalityE2_ignore; + delRanFuncItem->value.choice.RANfunctionID_Item.ranFunctionID = recvdRanFunc[ranFuncIdx].id; + delRanFuncItem->value.choice.RANfunctionID_Item.ranFunctionRevision = recvdRanFunc[ranFuncIdx].revisionCounter; - duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; - duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; - memcpy(&duCb.e2apDb.e2TimersInfo.e2Timers.e2NodeConfigUpdate.configList, e2NodeList, sizeof(E2NodeConfigList)); - ret = ROK; - break; - }while(true); - - FreeE2NodeConfigUpdate(e2apMsg); - return ret; + } + } + return ROK; } - /******************************************************************* * - * @brief Deallocate the memory allocated for E2ResetRequest msg + * @brief De Allocate Ric Service Update message * * @details * - * Function : FreeE2ResetRequest + * Function : FreeRicServiceUpdate * - * Functionality: - * - freeing the memory allocated for E2ResetRequest + * Functionality: De-Allocating Ric Service Update message * * @params[in] E2AP_PDU_t *e2apMsg - * @return ROK - success - * RFAILED - failure + + * @return void * * ****************************************************************/ -void FreeE2ResetRequest(E2AP_PDU_t *e2apMsg) + +void FreeRicServiceUpdate(E2AP_PDU_t *e2apMsg) { - uint8_t ieIdx =0; - ResetRequestE2_t *resetReq = NULLP; + uint8_t arrIdx = 0; + uint8_t ranFuncAddListIdx=0, ranFuncDelIdx=0; + RICserviceUpdate_t *ricServiceUpdate; + RANfunctions_List_t *ranFunctionsList; + RANfunction_ItemIEs_t *ranFuncItemIe; + RANfunction_Item_t *ranFunItem; + RANfunctionsID_List_t *deleteList; + /* De-allocating Memory */ if(e2apMsg != NULLP) { if(e2apMsg->choice.initiatingMessage != NULLP) { - resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2; - if(resetReq->protocolIEs.list.array) + ricServiceUpdate = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceUpdate; + if(ricServiceUpdate->protocolIEs.list.array != NULLP) { - for(ieIdx = 0; ieIdx < resetReq->protocolIEs.list.count; ieIdx++) + for(arrIdx = 0; arrIdx < ricServiceUpdate->protocolIEs.list.count; arrIdx++) { - DU_FREE(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t)); + if(ricServiceUpdate->protocolIEs.list.array[arrIdx] != NULLP) + { + switch(ricServiceUpdate->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + break; + + case ProtocolIE_IDE2_id_RANfunctionsAdded: + case ProtocolIE_IDE2_id_RANfunctionsModified: + { + ranFunctionsList = &(ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List); + if(ranFunctionsList->list.array) + { + for(ranFuncAddListIdx= 0; ranFuncAddListIdx< ranFunctionsList->list.count; ranFuncAddListIdx++) + { + if(ranFunctionsList->list.array[ranFuncAddListIdx]) + { + ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncAddListIdx]; + ranFunItem = &ranFuncItemIe->value.choice.RANfunction_Item; + DU_FREE(ranFunItem->ranFunctionOID.buf, ranFunItem->ranFunctionOID.size); + DU_FREE(ranFunItem->ranFunctionDefinition.buf, ranFunItem->ranFunctionDefinition.size); + DU_FREE(ranFunctionsList->list.array[ranFuncAddListIdx], sizeof(RANfunction_ItemIEs_t)); + } + } + DU_FREE(ranFunctionsList->list.array, ranFunctionsList->list.size); + } + break; + } + case ProtocolIE_IDE2_id_RANfunctionsDeleted: + { + deleteList= &ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(deleteList->list.array) + { + for(ranFuncDelIdx = 0; ranFuncDelIdx< deleteList->list.count; ranFuncDelIdx++) + { + DU_FREE(deleteList->list.array[ranFuncDelIdx], sizeof(RANfunctionID_ItemIEs_t)); + } + DU_FREE(deleteList->list.array, deleteList->list.size); + + } + break; + } + default: + DU_LOG("\nERROR --> E2AP: Invalid event at ricServiceUpdate %ld ",\ + (ricServiceUpdate->protocolIEs.list.array[arrIdx]->id)); + break; + } + DU_FREE(ricServiceUpdate->protocolIEs.list.array[arrIdx], sizeof(RICserviceUpdate_IEs_t)); + } } - DU_FREE(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size); + DU_FREE(ricServiceUpdate->protocolIEs.list.array, ricServiceUpdate->protocolIEs.list.size); } DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); } @@ -4434,108 +5520,149 @@ void FreeE2ResetRequest(E2AP_PDU_t *e2apMsg) /******************************************************************* * - * @brief Build and send the E2 reset request msg + * @brief Builds and Send the RicServiceUpdateuest * * @details * - * Function : BuildAndSendE2ResetRequest + * Function : BuildAndSendRicServiceUpdate * - * Functionality: - * - Buld and send the E2 reset request msg to RIC + * Functionality:Fills the RicServiceUpdateuest * - * @params[in] * @return ROK - success * RFAILED - failure * - * ****************************************************************/ -uint8_t BuildAndSendE2ResetRequest(E2FailureCause resetCause) + ******************************************************************/ + +uint8_t BuildAndSendRicServiceUpdate(RicServiceUpdate serviceUpdate) { - uint8_t ieIdx = 0, elementCnt = 0, transId = 0; - uint8_t ret = RFAILED; + uint8_t arrIdx = 0, elementCnt=0; + uint8_t transId = 0, ret = RFAILED; + bool memAllocFailed =false; E2AP_PDU_t *e2apMsg = NULLP; - ResetRequestE2_t *resetReq = NULLP; + RICserviceUpdate_t *ricServiceUpdate = NULLP; asn_enc_rval_t encRetVal; /* Encoder return value */ - DU_LOG("\nINFO --> E2AP : Building E2 Reset Request\n"); - + DU_LOG("\nINFO --> E2AP : Building Ric Service Update\n"); do { DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); if(e2apMsg == NULLP) { - DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for E2AP-PDU failed"); + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); break; } - e2apMsg->present = E2AP_PDU_PR_initiatingMessage; DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); if(e2apMsg->choice.initiatingMessage == NULLP) { - DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for initiatingMessage"); + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); break; } - - e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_Reset; e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; - e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ResetRequestE2; - resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2; + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICserviceUpdate; + e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICserviceUpdate; + ricServiceUpdate = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceUpdate; + + /* For TransId IE, set elementCnt to 1. + If there is any item in the RAN function add list, RAN function modification list, or RAN function delete list, increment the elementCnt.*/ - elementCnt = 2; - resetReq->protocolIEs.list.count = elementCnt; - resetReq->protocolIEs.list.size = elementCnt * sizeof(ResetRequestIEs_t *); + elementCnt =1; + if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded) + elementCnt++; + if(serviceUpdate.recvRanFuncList.numOfRanFunToBeModified) + elementCnt++; + if(serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted) + elementCnt++; + + ricServiceUpdate->protocolIEs.list.count = elementCnt; + ricServiceUpdate->protocolIEs.list.size = elementCnt * sizeof(RICserviceUpdate_IEs_t*); - DU_ALLOC(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size); - if(!resetReq->protocolIEs.list.array) + /* Initialize the E2Setup members */ + DU_ALLOC(ricServiceUpdate->protocolIEs.list.array, ricServiceUpdate->protocolIEs.list.size); + if(ricServiceUpdate->protocolIEs.list.array == NULLP) { - DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \ - Reset Request IE array"); + DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements"); break; } - - for(ieIdx = 0; ieIdx < elementCnt; ieIdx++) + + for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++) { - DU_ALLOC(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t)); - if(!resetReq->protocolIEs.list.array[ieIdx]) + DU_ALLOC(ricServiceUpdate->protocolIEs.list.array[arrIdx], sizeof(RICserviceUpdate_IEs_t)); + if(ricServiceUpdate->protocolIEs.list.array[arrIdx] == NULLP) { - DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \ - Reset Request IE array element"); + memAllocFailed = true; + DU_LOG("\nERROR --> E2AP : Memory allocation failed for arrayIdx [%d]", arrIdx); break; } } - - /* In case of failure */ - if(ieIdx < elementCnt) + if(memAllocFailed == true) break; - ieIdx = 0; - resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID; - resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject; - resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_TransactionID; - transId = assignTransactionId(); - resetReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId; + arrIdx = 0; - ieIdx++; - resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_CauseE2; - resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_ignore; - resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_CauseE2; - fillE2Cause(&resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2, resetCause); + /* TransactionID */ + ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_TransactionID; + if(serviceUpdate.dir == E2_NODE_INITIATED) + transId = assignTransactionId(); + else + transId = serviceUpdate.transId; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; + + if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded) + { + arrIdx++; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAdded; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List; + if(BuildRanFunctionAddList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List,\ + e2apMsg->choice.initiatingMessage->procedureCode, serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded, serviceUpdate.recvRanFuncList.ranFunToBeAdded) !=ROK) + { + break; + } + } + + if(serviceUpdate.recvRanFuncList.numOfRanFunToBeModified) + { + arrIdx++; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsModified; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List; + if(BuildRanFunctionAddList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List, + e2apMsg->choice.initiatingMessage->procedureCode, serviceUpdate.recvRanFuncList.numOfRanFunToBeModified, serviceUpdate.recvRanFuncList.ranFunToBeModified) !=ROK) + { + break; + } + } + if(serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted) + { + arrIdx++; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsDeleted; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctionsID_List; + if(BuildRanFunctionDeleteList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List,\ + serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted, serviceUpdate.recvRanFuncList.ranFunToBeDeleted) != ROK) + { + break; + } + } /* 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); + 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 E2SetupRequest structure (at %s)\n",\ + DU_LOG("\nERROR --> E2AP : Could not encode RicServiceUpdateuest structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); break; } else { - DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SetupRequest\n"); + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RicServiceUpdateuest\n"); #ifdef DEBUG_ASN_PRINT for(int i=0; i< encBufSize; i++) { @@ -4548,551 +5675,823 @@ uint8_t BuildAndSendE2ResetRequest(E2FailureCause resetCause) DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed"); break; } - - /* In case the message is sent successfully, store the transaction info to - * be used when response is received */ - duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; - duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; - ret = ROK; break; }while(true); - - /* Free all memory */ - FreeE2ResetRequest(e2apMsg); + + if(ret == ROK) + { + if(serviceUpdate.dir == E2_NODE_INITIATED) + { + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; + } + else + { + duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].transactionId = transId; + duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; + } + duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.dir = serviceUpdate.dir; + duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.transId =transId; + memcpy(&duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.recvRanFuncList, &serviceUpdate.recvRanFuncList, sizeof(E2TmpRanFunList)); + } + FreeRicServiceUpdate(e2apMsg); return ret; } +/****************************************************************** + * + * @brief Processes RIC service Query sent by RIC + * + * @details + * + * Function : procRicServiceQuery + * + * Functionality: Processes RIC service Query sent by RIC + * + * @params[in] E2AP_PDU_t ASN decoded E2AP message + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ -/******************************************************************* +void procRicServiceQuery(E2AP_PDU_t *e2apMsg) +{ + ConfigType action; + uint16_t arrIdx =0, ranFuncIdx=0,tmpIdx=0; + uint16_t id,revisionCcounter; + bool tmpArray[MAX_RAN_FUNCTION] = {false}; + RICserviceQuery_t *ricServiceQuery=NULL; + RicServiceUpdate ricUpdate; + RANfunctionID_ItemIEs_t *ranFuncAddedItemIe; + RANfunctionsID_List_t *ranFuncAddedList; + + DU_LOG("\nINFO --> E2AP : RIC Service Query received"); + memset(&ricUpdate, 0, sizeof(RicServiceUpdate)); + ricUpdate.dir = RIC_INITIATED; + ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery; + + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id) + { + /* TODO completing in next patch/gerrit */ + case ProtocolIE_IDE2_id_TransactionID: + { + ricUpdate.transId = ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + break; + } + + case ProtocolIE_IDE2_id_RANfunctionsAccepted: + { + ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(ranFuncAddedList->list.array) + { + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + { + if(ranFuncAddedList->list.array[ranFuncIdx]) + { + /* Using the RAN function Id, identify the RAN function to be modified or deleted. */ + + ranFuncAddedItemIe = (RANfunctionID_ItemIEs_t*)ranFuncAddedList->list.array[ranFuncIdx]; + id = ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID; + revisionCcounter = ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision; + + if((id != duCb.e2apDb.ranFunction[id-1].id)) + { + action = CONFIG_DEL; + } + else if((id == duCb.e2apDb.ranFunction[id-1].id)&&(revisionCcounter!=duCb.e2apDb.ranFunction[id-1].revisionCounter)) + { + action = CONFIG_MOD; + } + + if(action == CONFIG_DEL) + { + ricUpdate.recvRanFuncList.ranFunToBeDeleted[ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted].id = id; + ricUpdate.recvRanFuncList.ranFunToBeDeleted[ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted].revisionCounter = revisionCcounter; + ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted++; + } + else if(action == CONFIG_MOD) + { + ricUpdate.recvRanFuncList.ranFunToBeModified[ricUpdate.recvRanFuncList.numOfRanFunToBeModified].id = id; + ricUpdate.recvRanFuncList.ranFunToBeModified[ricUpdate.recvRanFuncList.numOfRanFunToBeModified].revisionCounter = revisionCcounter; + ricUpdate.recvRanFuncList.numOfRanFunToBeModified++; + } + + /* If any ID is set to true, it means that the ID has been used in either modification or deletion list. + * Else we will add the IDs into the added list */ + tmpArray[id-1] = true; + } + } + } + break; + } + } + } + + /* Traversing the whole RAN function list in ducb to check if any new Ran function ids have been added. */ + for(arrIdx =0; arrIdx0)&&(!tmpArray[arrIdx])) + { + ricUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].id = duCb.e2apDb.ranFunction[arrIdx].id; + ricUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].revisionCounter = duCb.e2apDb.ranFunction[arrIdx].revisionCounter; + ricUpdate.recvRanFuncList.numOfRanFunToBeAdded++; + } + } + + if(BuildAndSendRicServiceUpdate(ricUpdate)!= ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to build and send ric service update message"); + } + + freeAperDecodingOfRicServiceQuery(ricServiceQuery); +} + +/****************************************************************** * - * @brief Deallocate the memory allocated for Reset Response msg + * @brief Deallocation of memory allocated by aper decoder for + * RIC service update ack * * @details * - * Function : freeAperDecodingOfE2ResetRsp + * Function : freeAperDecodingOfRicServiceUpdateAck * - * Functionality: - * - freeing the memory allocated for Reset response + * Functionality: Deallocation of memory allocated by aper decoder + * for RIC service update ack * - * @params[in] ResetResponseE2_t *resetResponse + * @params[in] RICserviceUpdateAck_t *ricServiceAck; * @return void * * ****************************************************************/ -void freeAperDecodingOfE2ResetRsp(ResetResponseE2_t *resetResponse) + +void freeAperDecodingOfRicServiceUpdateAck(RICserviceUpdateAcknowledge_t *ricServiceAck) { - uint8_t ieIdx; + uint8_t arrIdx=0,ranFuncIdx=0; + RANfunctionsID_List_t *ranFuncAddedList=NULL; - if(resetResponse) + if(ricServiceAck) { - if(resetResponse->protocolIEs.list.array) + if(ricServiceAck->protocolIEs.list.array) { - for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++) + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) { - if(resetResponse->protocolIEs.list.array[ieIdx]) + if(ricServiceAck->protocolIEs.list.array[arrIdx]) { - switch(resetResponse->protocolIEs.list.array[ieIdx]->id) + switch(ricServiceAck->protocolIEs.list.array[arrIdx]->id) { - case ProtocolIE_IDE2_id_TransactionID: + case ProtocolIE_IDE2_id_RANfunctionsAccepted: + { + ranFuncAddedList= &ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(ranFuncAddedList->list.array) + { + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + { + free(ranFuncAddedList->list.array[ranFuncIdx]); + } + free(ranFuncAddedList->list.array); + } break; - - case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2: + } + default: break; } - free(resetResponse->protocolIEs.list.array[ieIdx]); + free(ricServiceAck->protocolIEs.list.array[arrIdx]); } } - free(resetResponse->protocolIEs.list.array); + free(ricServiceAck->protocolIEs.list.array); } } } /****************************************************************** * - * @brief Processes E2 Reset Response sent by RIC + * @brief Processes RIC service update ack sent by RIC * * @details * - * Function : procResetResponse + * Function : procRicServiceUpdateAck * - * Functionality: Processes E2 Reset Response sent by RIC + * Functionality: Processes RIC service update ack sent by RIC * * @params[in] E2AP_PDU_t ASN decoded E2AP message * @return ROK - success * RFAILED - failure * * ****************************************************************/ -uint8_t procResetResponse(E2AP_PDU_t *e2apMsg) -{ - uint8_t ieIdx =0, transId; - ResetResponseE2_t *resetResponse; - DU_LOG("\nINFO --> E2AP : E2 Reset Response received"); - resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2;; - - for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++) +void procRicServiceUpdateAck(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx =0, transId =0; + uint16_t id =0, tmpIdx=0, ranFuncIdx=0; + RicServiceUpdate serviceUpdate; + RANfunctionsIDcause_List_t *rejectedList=NULL; + RICserviceUpdateAcknowledge_t *ricServiceAck=NULL; + RANfunctionIDcause_ItemIEs_t *ranFuncRejectedItemIe=NULL; + + DU_LOG("\nINFO --> E2AP : RIC service update ack received"); + memset(&serviceUpdate, 0, sizeof(RicServiceUpdate)); + ricServiceAck = &e2apMsg->choice.successfulOutcome->value.choice.RICserviceUpdateAcknowledge; + + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) { - switch(resetResponse->protocolIEs.list.array[ieIdx]->id) + switch(ricServiceAck->protocolIEs.list.array[arrIdx]->id) { case ProtocolIE_IDE2_id_TransactionID: - transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID; - if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) && \ - (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode)) + { + transId = ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\ + (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) { - memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); + memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); + } + else if((duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].transactionId == transId) &&\ + (duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) + { + memset(&duCb.e2apDb.e2TransInfo.ricInitTransaction[transId], 0, sizeof(E2TransInfo)); } else { DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); - return RFAILED; + return ; } break; - case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2: - /* As per ORAN WG3 E2AP spec v3.0, section 9.2.2 - Criticality Diagnostics IE is sent by Near-RT RIC when parts of a received message i.e. - Reset Request in this case, have not been comprehended or were missing, or if the message - contained logical errors. - - Processing of this ID should be implemented when negative call flows are to be supported. - */ + } + + case ProtocolIE_IDE2_id_RANfunctionsAccepted: break; - default: - DU_LOG("\nERROR --> E2AP : Invalid IE received in E2 Reset Response : %ld", - resetResponse->protocolIEs.list.array[ieIdx]->id); + + case ProtocolIE_IDE2_id_RANfunctionsRejected: + { + rejectedList= &ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsIDcause_List; + if(rejectedList->list.array) + { + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + { + ranFuncRejectedItemIe = (RANfunctionIDcause_ItemIEs_t*)rejectedList->list.array[ranFuncIdx]; + id = ranFuncRejectedItemIe->value.choice.RANfunctionIDcause_Item.ranFunctionID; + tmpIdx= serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded; + serviceUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].id = duCb.e2apDb.ranFunction[id-1].id; + serviceUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].revisionCounter = duCb.e2apDb.ranFunction[id-1].revisionCounter; + serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded++; + } + } break; + } + } } - freeAperDecodingOfE2ResetRsp(resetResponse); - return ROK; + if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded) + { + serviceUpdate.dir = E2_NODE_INITIATED; + BuildAndSendRicServiceUpdate(serviceUpdate); + } + freeAperDecodingOfRicServiceUpdateAck(ricServiceAck); } /****************************************************************** * - * @brief Deallocation of memory allocated by aper decoder for e2 setup Failure + * @brief Deallocation of memory allocated by aper decoder for + * RIC service update failure * * @details * - * Function : freeAperDecodingOfE2SetupFailure + * Function : freeAperDecodingOfRicServiceUpdateFailure * - * Functionality: Deallocation of memory allocated by aper decoder for e2 - * setup Failure + * Functionality: Deallocation of memory allocated by aper decoder + * for RIC service update failure * - * @params[in] E2setupFailure_t *e2SetupFailure; + * @params[in] RICserviceUpdateFailure_t *ricServiceFailure; * @return void * * ****************************************************************/ -void freeAperDecodingOfE2SetupFailure(E2setupFailure_t *e2SetupFailure) + +void freeAperDecodingOfRicServiceUpdateFailure(RICserviceUpdateFailure_t *ricServiceFailure) { - uint8_t arrIdx; + uint8_t arrIdx=0; - if(e2SetupFailure) + if(ricServiceFailure) { - if(e2SetupFailure->protocolIEs.list.array) + if(ricServiceFailure->protocolIEs.list.array) { - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) { - if(e2SetupFailure->protocolIEs.list.array[arrIdx]) + if(ricServiceFailure->protocolIEs.list.array[arrIdx]) { - free(e2SetupFailure->protocolIEs.list.array[arrIdx]); + free(ricServiceFailure->protocolIEs.list.array[arrIdx]); } } - free(e2SetupFailure->protocolIEs.list.array); + free(ricServiceFailure->protocolIEs.list.array); } } } + /****************************************************************** * - * @brief Processes E2 Setup Failure sent by RIC + * @brief Processes RIC service update failure sent by RIC * * @details * - * Function : procE2SetupFailure + * Function : procRicServiceUpdateFailure * - * Functionality: Processes E2 Setup failure sent by RIC + * Functionality: Processes RIC service update failure sent by RIC * * @params[in] E2AP_PDU_t ASN decoded E2AP message * @return ROK - success * RFAILED - failure * * ****************************************************************/ -void procE2SetupFailure(E2AP_PDU_t *e2apMsg) + +void procRicServiceUpdateFailure(E2AP_PDU_t *e2apMsg) { - uint8_t arrIdx =0, transId =0, timerValue=0; - E2setupFailure_t *e2SetupFailure; + uint8_t arrIdx =0, timerValue=0; + RICserviceUpdateFailure_t *ricServiceFailure=NULL; - DU_LOG("\nINFO --> E2AP : E2 Setup failure received"); - e2SetupFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2setupFailure; + DU_LOG("\nINFO --> E2AP : RIC service update failure received"); + ricServiceFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICserviceUpdateFailure; - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) { - switch(e2SetupFailure->protocolIEs.list.array[arrIdx]->id) + switch(ricServiceFailure->protocolIEs.list.array[arrIdx]->id) { case ProtocolIE_IDE2_id_TransactionID: - { - transId = e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; - if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\ - (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) - { - memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); - } - else { - DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); - return ; + break; } - break; - } case ProtocolIE_IDE2_id_TimeToWaitE2: { - timerValue = convertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); - if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR)) == FALSE) + timerValue = convertE2WaitTimerEnumToValue(ricServiceFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); + if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer), EVENT_RIC_SERVICE_UPDATE_TMR)) == FALSE) { - duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR, timerValue); + duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer), EVENT_RIC_SERVICE_UPDATE_TMR, timerValue); } else { - DU_LOG("\nERROR --> E2AP : EVENT_E2_SETUP_TMR timer is already running"); + DU_LOG("\nERROR --> E2AP : EVENT_RIC_SERVICE_UPDATE_TMR timer is already running"); return; } break; } + case ProtocolIE_IDE2_id_CauseE2: + { + break; + } } } - freeAperDecodingOfE2SetupFailure(e2SetupFailure); + freeAperDecodingOfRicServiceUpdateFailure(ricServiceFailure); } + /****************************************************************** * - * @brief Deallocation of memory allocated by aper decoder for RIC service Query + * @brief DU Send E2 Node Configuration Update * * @details * - * Function : freeAperDecodingOfRicServiceQuery + * Function : duSendE2NodeConfigurationUpdate * - * Functionality: Deallocation of memory allocated by aper decoder for RIC - * service Query + * Functionality: DU Send E2 Node Configuration Update * - * @params[in] RICserviceQuery_t *ricServiceQuery; - * @return void + * @return ROK - success + * RFAILED - failure * * ****************************************************************/ -void freeAperDecodingOfRicServiceQuery(RICserviceQuery_t *ricServiceQuery) +uint8_t duSendE2NodeConfigurationUpdate() { - uint8_t arrIdx,ranFuncIdx; - RANfunctionsID_List_t *ranFuncAddedList; + E2NodeConfigList e2NodeList; + CmLList *node =NULL; + E2NodeComponent *e2NodeComponentInfo=NULL; - if(ricServiceQuery) + memset(&e2NodeList, 0, sizeof(E2NodeConfigList)); + CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node); + while(node) { - if(ricServiceQuery->protocolIEs.list.array) + e2NodeComponentInfo = (E2NodeComponent*)node->node; + + if(e2NodeComponentInfo->addConfiguration) { - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + e2NodeList.addE2Node[e2NodeList.addE2NodeCount].interface = e2NodeComponentInfo->interfaceType; + e2NodeList.addE2Node[e2NodeList.addE2NodeCount].componentId= e2NodeComponentInfo->componentId; + e2NodeList.addE2NodeCount++; + break; + } + if(e2NodeComponentInfo->updateConfiguration) + { + e2NodeList.updateE2Node[e2NodeList.updateE2NodeCount].interface = e2NodeComponentInfo->interfaceType; + e2NodeList.updateE2Node[e2NodeList.updateE2NodeCount].componentId= e2NodeComponentInfo->componentId; + e2NodeList.updateE2NodeCount++; + break; + } + if(e2NodeComponentInfo->deleteConfiguration == true) + { + e2NodeList.removeE2Node[e2NodeList.removeE2NodeCount].interface = e2NodeComponentInfo->interfaceType; + e2NodeList.removeE2Node[e2NodeList.removeE2NodeCount].componentId = e2NodeComponentInfo->componentId; + e2NodeList.removeE2NodeCount++; + break; + } + node = node->next; + } + + if(BuildAndSendE2NodeConfigUpdate(&e2NodeList) !=ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to build and send e2 node config update message to RIC_stub"); + return RFAILED; + } + return ROK; +} + +/******************************************************************* + * + * @brief Free RIC Subscription Modification Required + * + * @details + * + * Function : FreeRicSubsModRequired + * + * Functionality: Freqq RIC Subscription Modification required + * + * @param E2AP Message PDU to be freed + * @return void + * + ******************************************************************/ +void FreeRicSubsModRequired(E2AP_PDU_t *e2apMsg) +{ + uint8_t ieIdx = 0, arrIdx = 0; + RICsubscriptionModificationRequired_t *ricSubsModReqd = NULLP; + RICsubscriptionModificationRequired_IEs_t *ricSubsModReqdIe = NULLP; + RICactions_RequiredToBeModified_List_t *actionToBeModList = NULLP; + RICactions_RequiredToBeRemoved_List_t *actionToBeRmvList = NULLP; + + if(e2apMsg) + { + if(e2apMsg->choice.initiatingMessage) + { + ricSubsModReqd = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionModificationRequired; + if(ricSubsModReqd->protocolIEs.list.array) { - if(ricServiceQuery->protocolIEs.list.array[arrIdx]) + for(ieIdx = 0; ieIdx < ricSubsModReqd->protocolIEs.list.count; ieIdx++) { - switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id) + if(ricSubsModReqd->protocolIEs.list.array[ieIdx]) { - case ProtocolIE_IDE2_id_RANfunctionsAccepted: + ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; + switch(ricSubsModReqdIe->id) { - ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; - if(ranFuncAddedList->list.array) - { - for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + case ProtocolIE_IDE2_id_RICactionsRequiredToBeModified_List: { - free(ranFuncAddedList->list.array[ranFuncIdx]); + actionToBeModList = &ricSubsModReqdIe->value.choice.RICactions_RequiredToBeModified_List; + if(actionToBeModList->list.array) + { + for(arrIdx = 0; arrIdx < actionToBeModList->list.count; arrIdx++) + { + DU_FREE(actionToBeModList->list.array[arrIdx], \ + sizeof(RICaction_RequiredToBeModified_ItemIEs_t)); + } + DU_FREE(actionToBeModList->list.array, actionToBeModList->list.size); + } + break; } - free(ranFuncAddedList->list.array);; - } - break; + + case ProtocolIE_IDE2_id_RICactionsRequiredToBeRemoved_List: + { + actionToBeRmvList = &ricSubsModReqdIe->value.choice.RICactions_RequiredToBeRemoved_List; + if(actionToBeRmvList->list.array) + { + for(arrIdx = 0; arrIdx < actionToBeRmvList->list.count; arrIdx++) + { + DU_FREE(actionToBeRmvList->list.array[arrIdx], \ + sizeof(RICaction_RequiredToBeRemoved_ItemIEs_t)); + } + DU_FREE(actionToBeRmvList->list.array, actionToBeRmvList->list.size); + } + break; + } + + default: + break; } - default: - break; + DU_FREE(ricSubsModReqd->protocolIEs.list.array[ieIdx], \ + sizeof(RICsubscriptionModificationRequired_IEs_t)); } - free(ricServiceQuery->protocolIEs.list.array[arrIdx]); } + DU_FREE(ricSubsModReqd->protocolIEs.list.array, ricSubsModReqd->protocolIEs.list.size); + } + DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); + } +} + +/* A RIC Subscription includes RIC subsequent action only for RIC Insert service. + * However, E2SM-KPM supports only RIC Report service. + * Hence there is no subsequent action in RIC subscription that may require modification. + * So commenting the action-modification IEs for the time being + */ +#if 0 +/******************************************************************* + * + * @brief Fill Action required to be modified list + * + * @details + * + * Function : FillActionReqdToBeModList + * + * Functionality: Fill Action required to be modified list + * + * @param RIC Actions Required To Be Modified List to be filled + * Number of actions to be modified + * RIC Subscription DB + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ +uint8_t FillActionReqdToBeModList(RICactions_RequiredToBeModified_List_t *actionToBeModList, uint8_t numActionsMod, \ + RicSubscription *ricSubscription) +{ + uint8_t arrIdx = 0, actionIdx = 0; + RICaction_RequiredToBeModified_ItemIEs_t *actionToBeMod = NULL; + + actionToBeModList->list.count = numActionsMod; + actionToBeModList->list.size = numActionsMod * sizeof(RICaction_RequiredToBeModified_ItemIEs_t *); + DU_ALLOC(actionToBeModList->list.array, actionToBeModList->list.size); + if(!actionToBeModList->list.array) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); + return RFAILED; + } + + arrIdx = 0; + for(actionIdx = 0; actionIdx < MAX_RIC_ACTION; actionIdx++) + { + if(ricSubscription->actionSequence[actionIdx].action == CONFIG_MOD) + { + DU_ALLOC(actionToBeModList->list.array[arrIdx], sizeof(RICaction_RequiredToBeModified_ItemIEs_t)); + if(!actionToBeModList->list.array[arrIdx]) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); + return RFAILED; } - free(ricServiceQuery->protocolIEs.list.array); + actionToBeMod = (RICaction_RequiredToBeModified_ItemIEs_t *)actionToBeModList->list.array[arrIdx]; + + actionToBeMod->id = ProtocolIE_IDE2_id_RICaction_RequiredToBeModified_Item; + actionToBeMod->criticality = CriticalityE2_reject; + actionToBeMod->value.present = \ + RICaction_RequiredToBeModified_ItemIEs__value_PR_RICaction_RequiredToBeModified_Item; + actionToBeMod->value.choice.RICaction_RequiredToBeModified_Item.ricActionID = \ + ricSubscription->actionSequence[actionIdx].actionId; + actionToBeMod->value.choice.RICaction_RequiredToBeModified_Item.ricTimeToWait = RICtimeToWait_w5ms; + + arrIdx++; } } + + return ROK; } +#endif + /******************************************************************* * - * @brief Build RanFunction Delete List + * @brief Fill Action required to be removed list * * @details * - * Function : BuildRanFunctionDeleteList - * - * Functionality: Build RanFunction Delete List + * Function : FillActionReqdToBeRmvList * - * @params[in] - * RANfunctionsID List - * Count of the RAN function - * Received RAN function list + * Functionality: Fill Action required to be removed list * + * @param RIC Actions Required To Be Removed List to be filled + * Number of actions to be removed + * RIC Subscription DB * @return ROK - success * RFAILED - failure * ******************************************************************/ - -uint8_t BuildRanFunctionDeleteList(RANfunctionsID_List_t *deleteList, uint8_t count, RanFuncInfo *recvdRanFunc) +uint8_t FillActionReqdToBeRmvList(RICactions_RequiredToBeRemoved_List_t *actionToBeRmvList, uint8_t numActionsRmv, \ + RicSubscription *ricSubscription) { - uint8_t ranFuncIdx=0; - RANfunctionID_ItemIEs_t *delRanFuncItem; + uint8_t arrIdx = 0, actionIdx = 0; + RICaction_RequiredToBeRemoved_ItemIEs_t *actionToBeRmv = NULL; - if(count) + actionToBeRmvList->list.count = numActionsRmv; + actionToBeRmvList->list.size = numActionsRmv * sizeof(RICaction_RequiredToBeRemoved_ItemIEs_t *); + DU_ALLOC(actionToBeRmvList->list.array, actionToBeRmvList->list.size); + if(!actionToBeRmvList->list.array) { - deleteList->list.count = count; - deleteList->list.size = deleteList->list.count * sizeof(RANfunctionID_ItemIEs_t*); - DU_ALLOC(deleteList->list.array, deleteList->list.size); - if(deleteList->list.array == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); - return RFAILED; - } - for(ranFuncIdx = 0; ranFuncIdx< deleteList->list.count; ranFuncIdx++) + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); + return RFAILED; + } + + arrIdx = 0; + for(actionIdx = 0; actionIdx < MAX_RIC_ACTION; actionIdx++) + { + if(ricSubscription->actionSequence[actionIdx].action == CONFIG_DEL) { - DU_ALLOC(deleteList->list.array[ranFuncIdx], sizeof(RANfunctionID_ItemIEs_t)); - if(deleteList->list.array[ranFuncIdx] == NULLP) + DU_ALLOC(actionToBeRmvList->list.array[arrIdx], sizeof(RICaction_RequiredToBeRemoved_ItemIEs_t)); + if(!actionToBeRmvList->list.array[arrIdx]) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); return RFAILED; } - delRanFuncItem= (RANfunctionID_ItemIEs_t *) deleteList->list.array[ranFuncIdx]; - delRanFuncItem->id = ProtocolIE_IDE2_id_RANfunctionID_Item; - delRanFuncItem->criticality = CriticalityE2_ignore; - delRanFuncItem->value.choice.RANfunctionID_Item.ranFunctionID = recvdRanFunc[ranFuncIdx].id; - delRanFuncItem->value.choice.RANfunctionID_Item.ranFunctionRevision = recvdRanFunc[ranFuncIdx].revisionCounter; + actionToBeRmv = (RICaction_RequiredToBeRemoved_ItemIEs_t *)actionToBeRmvList->list.array[arrIdx]; + + actionToBeRmv->id = ProtocolIE_IDE2_id_RICaction_RequiredToBeRemoved_Item; + actionToBeRmv->criticality = CriticalityE2_reject; + actionToBeRmv->value.present = \ + RICaction_RequiredToBeRemoved_ItemIEs__value_PR_RICaction_RequiredToBeRemoved_Item; + actionToBeRmv->value.choice.RICaction_RequiredToBeRemoved_Item.ricActionID = \ + ricSubscription->actionSequence[actionIdx].actionId; + fillE2Cause(&actionToBeRmv->value.choice.RICaction_RequiredToBeRemoved_Item.cause, \ + ricSubscription->actionSequence[actionIdx].failureCause); + arrIdx++; } } + return ROK; } + /******************************************************************* * - * @brief De Allocate Ric Service Update message + * @brief Fill RIC Subscription Modification Required IEs * * @details * - * Function : FreeRicServiceUpdate + * Function : FillRicSubsModRequired * - * Functionality: De-Allocating Ric Service Update message + * Functionality: Fill RIC Subscription Modification Required IEs * - * @params[in] E2AP_PDU_t *e2apMsg - - * @return void + * @param RIC Subscription Modification Required IEs to be filled + * RIC Subscription DB + * @return ROK - success + * RFAILED - failure * - * ****************************************************************/ - -void FreeRicServiceUpdate(E2AP_PDU_t *e2apMsg) + ******************************************************************/ +uint8_t FillRicSubsModRequired(RICsubscriptionModificationRequired_t *ricSubsModReqd, RicSubscription *ricSubscription) { - uint8_t arrIdx = 0; - uint8_t ranFuncAddListIdx=0, ranFuncDelIdx=0; - RICserviceUpdate_t *ricServiceUpdate; - RANfunctions_List_t *ranFunctionsList; - RANfunction_ItemIEs_t *ranFuncItemIe; - RANfunction_Item_t *ranFunItem; - RANfunctionsID_List_t *deleteList; + uint8_t ieIdx = 0, elementCnt=0, actionIdx = 0; + uint8_t numActionsMod = 0, numActionsRmv = 0; + RICsubscriptionModificationRequired_IEs_t *ricSubsModReqdIe = NULLP; + RICactions_RequiredToBeRemoved_List_t *actionToBeRmvList = NULLP; - /* De-allocating Memory */ - if(e2apMsg != NULLP) +/* Unused in case of E2SM-KPM */ +#if 0 + RICactions_RequiredToBeModified_List_t *actionToBeModList = NULLP; +#endif + + /* Count number of Actions to be modified or deleted */ + for(actionIdx = 0; actionIdx < MAX_RIC_ACTION; actionIdx++) { - if(e2apMsg->choice.initiatingMessage != NULLP) + if(ricSubscription->actionSequence[actionIdx].action == CONFIG_MOD) + numActionsMod++; + else if(ricSubscription->actionSequence[actionIdx].action == CONFIG_DEL) + numActionsRmv++; + } + + /* Count number of IEs to be added to messages */ + elementCnt = 2; + if(numActionsMod) + elementCnt++; + if(numActionsRmv) + elementCnt++; + + ricSubsModReqd->protocolIEs.list.count = elementCnt; + ricSubsModReqd->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionModificationRequired_IEs_t *); + DU_ALLOC(ricSubsModReqd->protocolIEs.list.array, ricSubsModReqd->protocolIEs.list.size); + if(!ricSubsModReqd->protocolIEs.list.array) + { + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); + return RFAILED; + } + + for(ieIdx = 0; ieIdx < elementCnt; ieIdx++) + { + DU_ALLOC(ricSubsModReqd->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionModificationRequired_IEs_t)); + if(!ricSubsModReqd->protocolIEs.list.array[ieIdx]) { - ricServiceUpdate = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceUpdate; - if(ricServiceUpdate->protocolIEs.list.array != NULLP) - { - for(arrIdx = 0; arrIdx < ricServiceUpdate->protocolIEs.list.count; arrIdx++) - { - if(ricServiceUpdate->protocolIEs.list.array[arrIdx] != NULLP) - { - switch(ricServiceUpdate->protocolIEs.list.array[arrIdx]->id) - { - case ProtocolIE_IDE2_id_TransactionID: - break; + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); + return RFAILED; + } + } - case ProtocolIE_IDE2_id_RANfunctionsAdded: - case ProtocolIE_IDE2_id_RANfunctionsModified: - { - ranFunctionsList = &(ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List); - if(ranFunctionsList->list.array) - { - for(ranFuncAddListIdx= 0; ranFuncAddListIdx< ranFunctionsList->list.count; ranFuncAddListIdx++) - { - if(ranFunctionsList->list.array[ranFuncAddListIdx]) - { - ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncAddListIdx]; - ranFunItem = &ranFuncItemIe->value.choice.RANfunction_Item; - DU_FREE(ranFunItem->ranFunctionOID.buf, ranFunItem->ranFunctionOID.size); - DU_FREE(ranFunItem->ranFunctionDefinition.buf, ranFunItem->ranFunctionDefinition.size); - DU_FREE(ranFunctionsList->list.array[ranFuncAddListIdx], sizeof(RANfunction_ItemIEs_t)); - } - } - DU_FREE(ranFunctionsList->list.array, ranFunctionsList->list.size); - } - break; - } - case ProtocolIE_IDE2_id_RANfunctionsDeleted: - { - deleteList= &ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; - if(deleteList->list.array) - { - for(ranFuncDelIdx = 0; ranFuncDelIdx< deleteList->list.count; ranFuncDelIdx++) - { - DU_FREE(deleteList->list.array[ranFuncDelIdx], sizeof(RANfunctionID_ItemIEs_t)); - } - DU_FREE(deleteList->list.array, deleteList->list.size); - - } - break; - } - default: - DU_LOG("\nERROR --> E2AP: Invalid event at ricServiceUpdate %ld ",\ - (ricServiceUpdate->protocolIEs.list.array[arrIdx]->id)); - break; - } - DU_FREE(ricServiceUpdate->protocolIEs.list.array[arrIdx], sizeof(RICserviceUpdate_IEs_t)); - } - } - DU_FREE(ricServiceUpdate->protocolIEs.list.array, ricServiceUpdate->protocolIEs.list.size); - } - DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + /* RIC Request ID */ + ieIdx = 0; + ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; + ricSubsModReqdIe->id = ProtocolIE_IDE2_id_RICrequestID; + ricSubsModReqdIe->criticality = CriticalityE2_reject; + ricSubsModReqdIe->value.present = RICsubscriptionModificationRequired_IEs__value_PR_RICrequestID; + ricSubsModReqdIe->value.choice.RICrequestID.ricRequestorID = ricSubscription->requestId.requestorId; + ricSubsModReqdIe->value.choice.RICrequestID.ricInstanceID = ricSubscription->requestId.instanceId; + + /* RAN Function ID */ + ieIdx++; + ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; + ricSubsModReqdIe->id = ProtocolIE_IDE2_id_RANfunctionID; + ricSubsModReqdIe->criticality = CriticalityE2_reject; + ricSubsModReqdIe->value.present = RICsubscriptionModificationRequired_IEs__value_PR_RANfunctionID; + ricSubsModReqdIe->value.choice.RANfunctionID = ricSubscription->ranFuncId; + +/* A RIC Subscription includes RIC subsequent action only for RIC Insert service. + * However, E2SM-KPM supports only RIC Report service. + * Hence there is no subsequent action in RIC subscription that may require modification. + * So commenting the action-modification IEs for the time being + */ +#if 0 + /* RIC Actions Required to be Modified */ + if(numActionsMod) + { + ieIdx++; + ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; + ricSubsModReqdIe->id = ProtocolIE_IDE2_id_RICactionsRequiredToBeModified_List; + ricSubsModReqdIe->criticality = CriticalityE2_reject; + ricSubsModReqdIe->value.present = \ + RICsubscriptionModificationRequired_IEs__value_PR_RICactions_RequiredToBeModified_List; + actionToBeModList = &ricSubsModReqdIe->value.choice.RICactions_RequiredToBeModified_List; + + if(FillActionReqdToBeModList(actionToBeModList, numActionsMod, ricSubscription) != ROK) + { + DU_LOG("\nERROR --> E2AP : %s: Failed to fill actions required to be modified list", __func__); + return RFAILED; + } + } +#endif + + /* RIC Actions Required to be removed */ + if(numActionsRmv) + { + ieIdx++; + ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; + ricSubsModReqdIe->id = ProtocolIE_IDE2_id_RICactionsRequiredToBeRemoved_List; + ricSubsModReqdIe->criticality = CriticalityE2_reject; + ricSubsModReqdIe->value.present = \ + RICsubscriptionModificationRequired_IEs__value_PR_RICactions_RequiredToBeRemoved_List; + actionToBeRmvList = &ricSubsModReqdIe->value.choice.RICactions_RequiredToBeRemoved_List; + + if(FillActionReqdToBeRmvList(actionToBeRmvList, numActionsRmv, ricSubscription) != ROK) + { + DU_LOG("\nERROR --> E2AP : %s: Failed to fill actions required to be removed list", __func__); + return RFAILED; } - DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } + + return ROK; } /******************************************************************* * - * @brief Builds and Send the RicServiceUpdateuest + * @brief Builds and Send RIC Subscription Modification Required + * message * * @details * - * Function : BuildAndSendRicServiceUpdate + * Function : BuildAndSendRicSubsModRequired * - * Functionality:Fills the RicServiceUpdateuest + * Functionality: Builds and Send RIC Subscription Modification + * Required message * + * @param RIC Subscription DB * @return ROK - success * RFAILED - failure * ******************************************************************/ - -uint8_t BuildAndSendRicServiceUpdate(RicServiceUpdate serviceUpdate) +uint8_t BuildAndSendRicSubsModRequired(RicSubscription *ricSubscription) { - uint8_t arrIdx = 0, elementCnt=0; - uint8_t transId = 0, ret = RFAILED; - bool memAllocFailed =false; + uint8_t ret = RFAILED; E2AP_PDU_t *e2apMsg = NULLP; - RICserviceUpdate_t *ricServiceUpdate = NULLP; + RICsubscriptionModificationRequired_t *ricSubsModReqd = NULLP; asn_enc_rval_t encRetVal; /* Encoder return value */ - DU_LOG("\nINFO --> E2AP : Building Ric Service Update\n"); - do + DU_LOG("\nINFO --> E2AP : Building RIC Subscription Modification Required \n"); + while(true) { DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); if(e2apMsg == NULLP) { - DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); break; } + e2apMsg->present = E2AP_PDU_PR_initiatingMessage; DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); if(e2apMsg->choice.initiatingMessage == NULLP) { - DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); break; } e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; - e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICserviceUpdate; - e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICserviceUpdate; - ricServiceUpdate = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceUpdate; - - /* For TransId IE, set elementCnt to 1. - If there is any item in the RAN function add list, RAN function modification list, or RAN function delete list, increment the elementCnt.*/ + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICsubscriptionModificationRequired; + e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICsubscriptionModificationRequired; - elementCnt =1; - if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded) - elementCnt++; - if(serviceUpdate.recvRanFuncList.numOfRanFunToBeModified) - elementCnt++; - if(serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted) - elementCnt++; - - ricServiceUpdate->protocolIEs.list.count = elementCnt; - ricServiceUpdate->protocolIEs.list.size = elementCnt * sizeof(RICserviceUpdate_IEs_t*); + ricSubsModReqd = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionModificationRequired; - /* Initialize the E2Setup members */ - DU_ALLOC(ricServiceUpdate->protocolIEs.list.array, ricServiceUpdate->protocolIEs.list.size); - if(ricServiceUpdate->protocolIEs.list.array == NULLP) + if(FillRicSubsModRequired(ricSubsModReqd, ricSubscription) != ROK) { - DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements"); + DU_LOG("\nERROR --> E2AP : %s: Failed to fill RIC Subscription Modification Required IEs", __func__); break; } - for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++) - { - DU_ALLOC(ricServiceUpdate->protocolIEs.list.array[arrIdx], sizeof(RICserviceUpdate_IEs_t)); - if(ricServiceUpdate->protocolIEs.list.array[arrIdx] == NULLP) - { - memAllocFailed = true; - DU_LOG("\nERROR --> E2AP : Memory allocation failed for arrayIdx [%d]", arrIdx); - break; - } - } - if(memAllocFailed == true) - break; - - arrIdx = 0; - - /* TransactionID */ - ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_TransactionID; - if(serviceUpdate.dir == E2_NODE_INITIATED) - transId = assignTransactionId(); - else - transId = serviceUpdate.transId; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; - - if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded) - { - arrIdx++; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAdded; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List; - if(BuildRanFunctionAddList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List,\ - e2apMsg->choice.initiatingMessage->procedureCode, serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded, serviceUpdate.recvRanFuncList.ranFunToBeAdded) !=ROK) - { - break; - } - } - - if(serviceUpdate.recvRanFuncList.numOfRanFunToBeModified) - { - arrIdx++; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsModified; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List; - if(BuildRanFunctionAddList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List, - e2apMsg->choice.initiatingMessage->procedureCode, serviceUpdate.recvRanFuncList.numOfRanFunToBeModified, serviceUpdate.recvRanFuncList.ranFunToBeModified) !=ROK) - { - break; - } - } - - if(serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted) - { - arrIdx++; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsDeleted; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; - ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctionsID_List; - if(BuildRanFunctionDeleteList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List,\ - serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted, serviceUpdate.recvRanFuncList.ranFunToBeDeleted) != ROK) - { - break; - } - } - /* Prints the Msg formed */ + /* Encode */ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg); memset(encBuf, 0, ENC_BUF_MAX_LEN); @@ -5100,13 +6499,13 @@ uint8_t BuildAndSendRicServiceUpdate(RicServiceUpdate serviceUpdate) encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf); if(encRetVal.encoded == ENCODE_FAIL) { - DU_LOG("\nERROR --> E2AP : Could not encode RicServiceUpdateuest structure (at %s)\n",\ + DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Modifiction Required structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); break; } else { - DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RicServiceUpdateuest\n"); + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Subscription Modification Required \n"); #ifdef DEBUG_ASN_PRINT for(int i=0; i< encBufSize; i++) { @@ -5116,806 +6515,914 @@ uint8_t BuildAndSendRicServiceUpdate(RicServiceUpdate serviceUpdate) } if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK) { - DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed"); - break; + DU_LOG("\nERROR --> E2AP : Sending RIC Subscription Modification Required failed"); } + ret = ROK; break; - }while(true); - - if(ret == ROK) + } + + /* Free RIC Subscription modification required */ + FreeRicSubsModRequired(e2apMsg); + return ret; +} + +/******************************************************************* + * + * @brief Free APER decoding of RIC Subscription Modification Confirm + * + * @details + * + * Function : freeAperDecodingOfRicSubsModConfirm + * + * Functionality: Free APER decoding of RIC Subscription + * Modification Confirm + * + * @param E2AP Message PDU + * @return void + * + ******************************************************************/ +void freeAperDecodingOfRicSubsModConfirm(E2AP_PDU_t *e2apMsg) +{ + uint8_t ieIdx = 0, arrIdx=0; + RICsubscriptionModificationConfirm_t *ricSubsModCfm = NULLP; + RICsubscriptionModificationConfirm_IEs_t *ricSubsModCfmIe = NULLP; + RICactions_ConfirmedForModification_List_t *modCfmList = NULLP; + RICactions_RefusedToBeModified_List_t *modRefusedList = NULLP; + RICactions_ConfirmedForRemoval_List_t *rmvCfmList = NULLP; + RICactions_RefusedToBeRemoved_List_t *rmvFailList = NULLP; + + if(e2apMsg && e2apMsg->choice.successfulOutcome) { - if(serviceUpdate.dir == E2_NODE_INITIATED) - { - duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; - duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; - } - else + ricSubsModCfm = &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionModificationConfirm; + if(ricSubsModCfm->protocolIEs.list.array) { - duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].transactionId = transId; - duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; + for(ieIdx = 0; ieIdx < ricSubsModCfm->protocolIEs.list.count; ieIdx++) + { + if(ricSubsModCfm->protocolIEs.list.array[ieIdx]) + { + ricSubsModCfmIe = ricSubsModCfm->protocolIEs.list.array[ieIdx]; + switch(ricSubsModCfmIe->id) + { + case ProtocolIE_IDE2_id_RICactionsConfirmedForModification_List: + { + modCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForModification_List; + if(modCfmList->list.array) + { + for(arrIdx = 0; arrIdx < modCfmList->list.count; arrIdx++) + { + if(modCfmList->list.array[arrIdx]) + free(modCfmList->list.array[arrIdx]); + } + free(modCfmList->list.array); + } + break; + } + + case ProtocolIE_IDE2_id_RICactionsRefusedToBeModified_List: + { + modRefusedList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeModified_List; + if(modRefusedList->list.array) + { + for(arrIdx = 0; arrIdx < modRefusedList->list.count; arrIdx++) + { + if(modRefusedList->list.array[arrIdx]) + free(modRefusedList->list.array[arrIdx]); + } + free(modRefusedList->list.array); + } + break; + } + + case ProtocolIE_IDE2_id_RICactionsConfirmedForRemoval_List: + { + rmvCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForRemoval_List; + if(rmvCfmList->list.array) + { + for(arrIdx = 0; arrIdx < rmvCfmList->list.count; arrIdx++) + { + if(rmvCfmList->list.array[arrIdx]) + free(rmvCfmList->list.array[arrIdx]); + } + free(rmvCfmList->list.array); + } + break; + } + + case ProtocolIE_IDE2_id_RICactionsRefusedToBeRemoved_List: + { + rmvFailList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeRemoved_List; + if(rmvFailList->list.array) + { + for(arrIdx = 0; arrIdx < rmvFailList->list.count; arrIdx++) + { + if(rmvFailList->list.array[arrIdx]) + free(rmvFailList->list.array[arrIdx]); + } + free(rmvFailList->list.array); + } + break; + } + + default: + break; + + } + free(ricSubsModCfmIe); + } + } + free(ricSubsModCfm->protocolIEs.list.array); } - duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.dir = serviceUpdate.dir; - duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.transId =transId; - memcpy(&duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.recvRanFuncList, &serviceUpdate.recvRanFuncList, sizeof(E2TmpRanFunList)); } - FreeRicServiceUpdate(e2apMsg); - return ret; } -/****************************************************************** + +/******************************************************************* * - * @brief Processes RIC service Query sent by RIC + * @brief Process RIC Subscription Modification Confirm Message * * @details * - * Function : procRicServiceQuery + * Function : procRicSubscriptionModificationConfirm * - * Functionality: Processes RIC service Query sent by RIC + * Functionality: Process RIC Subscription Modification Confirm + * Message received from RIC. * - * @params[in] E2AP_PDU_t ASN decoded E2AP message - * @return ROK - success - * RFAILED - failure + * @param E2AP Message PDU + * @return void * - * ****************************************************************/ - -void procRicServiceQuery(E2AP_PDU_t *e2apMsg) + ******************************************************************/ +void procRicSubscriptionModificationConfirm(E2AP_PDU_t *e2apMsg) { - ConfigType action; - uint16_t arrIdx =0, ranFuncIdx=0,tmpIdx=0; - uint16_t id,revisionCcounter; - bool tmpArray[MAX_RAN_FUNCTION] = {false}; - RICserviceQuery_t *ricServiceQuery=NULL; - RicServiceUpdate ricUpdate; - RANfunctionID_ItemIEs_t *ranFuncAddedItemIe; - RANfunctionsID_List_t *ranFuncAddedList; + uint8_t actionId = 0, ieIdx = 0, arrIdx = 0; + uint16_t ranFuncId = 0; + bool procFailure = false; + RicRequestId ricReqId; + RanFunction *ranFuncDb = NULLP; + CmLList *ricSubsNode = NULLP; + RicSubscription *ricSubsDb = NULLP; + ActionInfo *actionDb = NULLP; - DU_LOG("\nINFO --> E2AP : RIC Service Query received"); - memset(&ricUpdate, 0, sizeof(RicServiceUpdate)); - ricUpdate.dir = RIC_INITIATED; - ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery; + RICsubscriptionModificationConfirm_t *ricSubsModCfm = NULLP; + RICsubscriptionModificationConfirm_IEs_t *ricSubsModCfmIe = NULLP; - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) - { - switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id) +/* Not used in case of E2SM-KPM */ +#if 0 + RICactions_ConfirmedForModification_List_t *modCfmList = NULLP; + RICaction_ConfirmedForModification_ItemIEs_t *modCfmListItem = NULLP; + + RICactions_RefusedToBeModified_List_t *modRefusedList = NULLP; + RICaction_RefusedToBeModified_ItemIEs_t *modRefusedListItem = NULLP; +#endif + + RICactions_ConfirmedForRemoval_List_t *rmvCfmList = NULLP; + RICaction_ConfirmedForRemoval_ItemIEs_t *rmvCfmListItem = NULLP; + + RICactions_RefusedToBeRemoved_List_t *rmvFailList = NULLP; + RICaction_RefusedToBeRemoved_ItemIEs_t *rmvFailListItem = NULLP; + + DU_LOG("\nINFO --> E2AP : %s: Received RIC Subscription Modification Confirm", __func__); + + do{ + if(!e2apMsg) { - /* TODO completing in next patch/gerrit */ - case ProtocolIE_IDE2_id_TransactionID: + DU_LOG("\nERROR --> E2AP : %s: E2AP Message is NULL", __func__); + break; + } + + if(!e2apMsg->choice.successfulOutcome) + { + DU_LOG("\nERROR --> E2AP : %s: Successful Outcome in E2AP message is NULL", __func__); + break; + } + + ricSubsModCfm = &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionModificationConfirm; + if(!ricSubsModCfm->protocolIEs.list.array) + { + DU_LOG("\nERROR --> E2AP : %s: Array conatining E2AP message IEs is null", __func__); + break; + } + + for(ieIdx = 0; ieIdx < ricSubsModCfm->protocolIEs.list.count; ieIdx++) + { + if(!ricSubsModCfm->protocolIEs.list.array[ieIdx]) { - ricUpdate.transId = ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + DU_LOG("\nERROR --> E2AP : %s: IE at index [%d] in E2AP message IEs list is null", __func__, ieIdx); break; } - case ProtocolIE_IDE2_id_RANfunctionsAccepted: + ricSubsModCfmIe = ricSubsModCfm->protocolIEs.list.array[ieIdx]; + switch(ricSubsModCfmIe->id) { - ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; - if(ranFuncAddedList->list.array) - { - for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + case ProtocolIE_IDE2_id_RICrequestID: { - if(ranFuncAddedList->list.array[ranFuncIdx]) + memset(&ricReqId, 0, sizeof(RicRequestId)); + ricReqId.requestorId = ricSubsModCfmIe->value.choice.RICrequestID.ricRequestorID; + ricReqId.instanceId = ricSubsModCfmIe->value.choice.RICrequestID.ricInstanceID; + break; + } + + case ProtocolIE_IDE2_id_RANfunctionID: + { + ranFuncId = ricSubsModCfmIe->value.choice.RANfunctionID; + ranFuncDb = fetchRanFuncFromRanFuncId(ranFuncId); + if(!ranFuncDb) { - /* Using the RAN function Id, identify the RAN function to be modified or deleted. */ - - ranFuncAddedItemIe = (RANfunctionID_ItemIEs_t*)ranFuncAddedList->list.array[ranFuncIdx]; - id = ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID; - revisionCcounter = ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision; - - if((id != duCb.e2apDb.ranFunction[id-1].id)) + DU_LOG("\nERROR --> E2AP : %s: RAN Function ID [%d] not found", __func__, ranFuncId); + procFailure = true; + break; + } + + ricSubsDb = fetchSubsInfoFromRicReqId(ricReqId, ranFuncDb, &ricSubsNode); + if(!ricSubsDb) + { + DU_LOG("\nERROR --> E2AP : %s: RIC Subscription not found for Requestor_ID [%d] Instance_ID [%d]",\ + __func__, ricReqId.requestorId, ricReqId.instanceId); + procFailure = true; + break; + } + + break; + } + +/* A RIC Subscription includes RIC subsequent action only for RIC Insert service. + * However, E2SM-KPM supports only RIC Report service. + * Hence there is no subsequent action in RIC subscription that may require modification. + * So commenting the action-modification IEs for the time being + */ +#if 0 + case ProtocolIE_IDE2_id_RICactionsConfirmedForModification_List: + { + modCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForModification_List; + for(arrIdx = 0; arrIdx < modCfmList->list.count; arrIdx++) + { + modCfmListItem = (RICaction_ConfirmedForModification_ItemIEs_t *)modCfmList->list.array[arrIdx]; + actionId = modCfmListItem->value.choice.RICaction_ConfirmedForModification_Item.ricActionID; + + actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb); + if(!actionDb) { - action = CONFIG_DEL; + DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId); } - else if((id == duCb.e2apDb.ranFunction[id-1].id)&&(revisionCcounter!=duCb.e2apDb.ranFunction[id-1].revisionCounter)) + else { - action = CONFIG_MOD; + actionDb->action = CONFIG_UNKNOWN; + /* Further handling can be added here in future once the + * use case of this procedure is identified */ } + actionDb = NULLP; + } + break; + } - if(action == CONFIG_DEL) + case ProtocolIE_IDE2_id_RICactionsRefusedToBeModified_List: + { + modRefusedList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeModified_List; + for(arrIdx = 0; arrIdx < modRefusedList->list.count; arrIdx++) + { + modRefusedListItem = (RICaction_RefusedToBeModified_ItemIEs_t *)modRefusedList->list.array[arrIdx]; + actionId = modRefusedListItem->value.choice.RICaction_RefusedToBeModified_Item.ricActionID; + actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb); + if(!actionDb) + { + DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId); + } + else + { + /* Spec doesnt mention if in case of failure, DU should retry for modify action + * Hence, chaging the action from CONFIG_MOD to CONFIG_UNKNOWN + */ + actionDb->action = CONFIG_UNKNOWN; + } + actionDb = NULLP; + } + break; + } +#endif + + case ProtocolIE_IDE2_id_RICactionsConfirmedForRemoval_List: + { + rmvCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForRemoval_List; + for(arrIdx = 0; arrIdx < rmvCfmList->list.count; arrIdx++) + { + rmvCfmListItem = (RICaction_ConfirmedForRemoval_ItemIEs_t *)rmvCfmList->list.array[arrIdx]; + actionId = rmvCfmListItem->value.choice.RICaction_ConfirmedForRemoval_Item.ricActionID; + actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb); + if(!actionDb) { - ricUpdate.recvRanFuncList.ranFunToBeDeleted[ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted].id = id; - ricUpdate.recvRanFuncList.ranFunToBeDeleted[ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted].revisionCounter = revisionCcounter; - ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted++; + DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId); } - else if(action == CONFIG_MOD) + else { - ricUpdate.recvRanFuncList.ranFunToBeModified[ricUpdate.recvRanFuncList.numOfRanFunToBeModified].id = id; - ricUpdate.recvRanFuncList.ranFunToBeModified[ricUpdate.recvRanFuncList.numOfRanFunToBeModified].revisionCounter = revisionCcounter; - ricUpdate.recvRanFuncList.numOfRanFunToBeModified++; + deleteActionSequence(actionDb); + actionDb =NULLP; + ricSubsDb->numOfActions--; + /* Further handling can include : + * Deletion of this action from all DU layers + */ } + actionDb = NULLP; + } + break; + } - /* If any ID is set to true, it means that the ID has been used in either modification or deletion list. - * Else we will add the IDs into the added list */ - tmpArray[id-1] = true; + case ProtocolIE_IDE2_id_RICactionsRefusedToBeRemoved_List: + { + rmvFailList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeRemoved_List; + for(arrIdx = 0; arrIdx < rmvFailList->list.count; arrIdx++) + { + rmvFailListItem = (RICaction_RefusedToBeRemoved_ItemIEs_t *)rmvFailList->list.array[arrIdx]; + actionId = rmvFailListItem->value.choice.RICaction_RefusedToBeRemoved_Item.ricActionID; + actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb); + if(!actionDb) + { + DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId); + } + else + { + actionDb->action = CONFIG_UNKNOWN; + } + actionDb = NULLP; } + break; } - } - break; - } - } - } - /* Traversing the whole RAN function list in ducb to check if any new Ran function ids have been added. */ - for(arrIdx =0; arrIdx0)&&(!tmpArray[arrIdx])) - { - ricUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].id = duCb.e2apDb.ranFunction[arrIdx].id; - ricUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].revisionCounter = duCb.e2apDb.ranFunction[arrIdx].revisionCounter; - ricUpdate.recvRanFuncList.numOfRanFunToBeAdded++; - } - } + default: + break; + } /* End of switch for Protocol IE Id */ + + if(procFailure) + break; + } /* End of for loop for Protocol IE list */ - if(BuildAndSendRicServiceUpdate(ricUpdate)!= ROK) - { - DU_LOG("\nERROR --> E2AP : Failed to build and send ric service update message"); - } + break; + }while(true); - freeAperDecodingOfRicServiceQuery(ricServiceQuery); + freeAperDecodingOfRicSubsModConfirm(e2apMsg); + return; } /****************************************************************** - * - * @brief Deallocation of memory allocated by aper decoder for - * RIC service update ack - * - * @details - * - * Function : freeAperDecodingOfRicServiceUpdateAck - * - * Functionality: Deallocation of memory allocated by aper decoder - * for RIC service update ack - * - * @params[in] RICserviceUpdateAck_t *ricServiceAck; - * @return void - * - * ****************************************************************/ - -void freeAperDecodingOfRicServiceUpdateAck(RICserviceUpdateAcknowledge_t *ricServiceAck) +* @brief Deallocate the memory allocated for E2 Reset Response +* +* @details +* +* Function : FreeE2ResetResponse +* +* Functionality: +* - freeing the memory allocated for E2ResetResponse +* +* @params[in] E2AP_PDU_t *e2apMsg +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +void FreeE2ResetResponse(E2AP_PDU_t *e2apMsg) { - uint8_t arrIdx=0,ranFuncIdx=0; - RANfunctionsID_List_t *ranFuncAddedList=NULL; + uint8_t ieIdx =0; + ResetResponseE2_t *resetResponse; - if(ricServiceAck) + if(e2apMsg != NULLP) { - if(ricServiceAck->protocolIEs.list.array) + if(e2apMsg->choice.successfulOutcome != NULLP) { - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2; + if(resetResponse->protocolIEs.list.array) { - if(ricServiceAck->protocolIEs.list.array[arrIdx]) + for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++) { - switch(ricServiceAck->protocolIEs.list.array[arrIdx]->id) + if(resetResponse->protocolIEs.list.array[ieIdx]) { - case ProtocolIE_IDE2_id_RANfunctionsAccepted: - { - ranFuncAddedList= &ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; - if(ranFuncAddedList->list.array) - { - for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) - { - free(ranFuncAddedList->list.array[ranFuncIdx]); - } - free(ranFuncAddedList->list.array); - } - break; - } - default: - break; + DU_FREE(resetResponse->protocolIEs.list.array[ieIdx], sizeof(ResetResponseIEs_t)); } - free(ricServiceAck->protocolIEs.list.array[arrIdx]); } + DU_FREE(resetResponse->protocolIEs.list.array, resetResponse->protocolIEs.list.size); } - free(ricServiceAck->protocolIEs.list.array); + + DU_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } } -/****************************************************************** +/******************************************************************* * - * @brief Processes RIC service update ack sent by RIC + * @brief Buld and send the E2 Reset Response msg * * @details * - * Function : procRicServiceUpdateAck + * Function : BuildAndSendE2ResetResponse * - * Functionality: Processes RIC service update ack sent by RIC + * Functionality: + * - Buld and send the E2 Reset Response Message * - * @params[in] E2AP_PDU_t ASN decoded E2AP message + * @params[in] Trans Id * @return ROK - success * RFAILED - failure * * ****************************************************************/ - -void procRicServiceUpdateAck(E2AP_PDU_t *e2apMsg) +uint8_t BuildAndSendResetResponse(uint8_t transId) { - uint8_t arrIdx =0, transId =0; - uint16_t id =0, tmpIdx=0, ranFuncIdx=0; - RicServiceUpdate serviceUpdate; - RANfunctionsIDcause_List_t *rejectedList=NULL; - RICserviceUpdateAcknowledge_t *ricServiceAck=NULL; - RANfunctionIDcause_ItemIEs_t *ranFuncRejectedItemIe=NULL; - - DU_LOG("\nINFO --> E2AP : RIC service update ack received"); - memset(&serviceUpdate, 0, sizeof(RicServiceUpdate)); - ricServiceAck = &e2apMsg->choice.successfulOutcome->value.choice.RICserviceUpdateAcknowledge; - - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + uint8_t ieIdx = 0, elementCnt = 0; + uint8_t ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + ResetResponseE2_t *resetResponse; + asn_enc_rval_t encRetVal; /* Encoder return value */ + + DU_LOG("\nINFO --> E2AP : Building E2 Reset Response Message\n"); + do { - switch(ricServiceAck->protocolIEs.list.array[arrIdx]->id) + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) { - case ProtocolIE_IDE2_id_TransactionID: + DU_LOG("\nERROR --> E2AP : BuildAndSendResetResponse(): Memory allocation for E2AP-PDU failed"); + break; + } + e2apMsg->present = E2AP_PDU_PR_successfulOutcome; + + DU_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); + if(e2apMsg->choice.successfulOutcome == NULLP) + { + DU_LOG("\nERROR --> E2AP : BuildAndSendResetResponse: Memory allocation failed for successfulOutcome"); + break; + } + + e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_Reset; + e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject; + e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_ResetResponseE2; + resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2; + + elementCnt = 1; + resetResponse->protocolIEs.list.count = elementCnt; + resetResponse->protocolIEs.list.size = elementCnt * sizeof(ResetResponseIEs_t *); + DU_ALLOC(resetResponse->protocolIEs.list.array, resetResponse->protocolIEs.list.size); + if(!resetResponse->protocolIEs.list.array) + { + DU_LOG("\nERROR --> E2AP : BuildAndSendResetResponse: Memory allocation failed for protocol IE array"); + break; + } + + for(ieIdx=0; ieIdx < elementCnt; ieIdx++) + { + DU_ALLOC(resetResponse->protocolIEs.list.array[ieIdx], sizeof(ResetResponseIEs_t)); + if(!resetResponse->protocolIEs.list.array[ieIdx]) { - transId = ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; - if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\ - (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) - { - memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); - } - else if((duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].transactionId == transId) &&\ - (duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) - { - memset(&duCb.e2apDb.e2TransInfo.ricInitTransaction[transId], 0, sizeof(E2TransInfo)); - } - else - { - DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); - return ; - } + DU_LOG("\nERROR --> E2AP : BuildAndSendResetResponse: Memory allocation failed for protocol IE array element"); break; } - - case ProtocolIE_IDE2_id_RANfunctionsAccepted: - break; + } + if(ieIdx < elementCnt) + break; - case ProtocolIE_IDE2_id_RANfunctionsRejected: + ieIdx = 0; + resetResponse->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID; + resetResponse->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject; + resetResponse->protocolIEs.list.array[ieIdx]->value.present = ResetResponseIEs__value_PR_TransactionID; + resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId; + + 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 E2 reset response structure (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2 Reset Response \n"); + for(int i=0; i< encBufSize; i++) { - rejectedList= &ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsIDcause_List; - if(rejectedList->list.array) - { - for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) - { - ranFuncRejectedItemIe = (RANfunctionIDcause_ItemIEs_t*)rejectedList->list.array[ranFuncIdx]; - id = ranFuncRejectedItemIe->value.choice.RANfunctionIDcause_Item.ranFunctionID; - tmpIdx= serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded; - serviceUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].id = duCb.e2apDb.ranFunction[id-1].id; - serviceUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].revisionCounter = duCb.e2apDb.ranFunction[id-1].revisionCounter; - serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded++; - } - } - break; + DU_LOG("%x",encBuf[i]); } + } + /* Sending msg */ + if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to send E2 Reset Response"); + break; } - } - if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded) - { - serviceUpdate.dir = E2_NODE_INITIATED; - BuildAndSendRicServiceUpdate(serviceUpdate); - } - freeAperDecodingOfRicServiceUpdateAck(ricServiceAck); + ret = ROK; + break; + }while(true); + + FreeE2ResetResponse(e2apMsg); + return ret; } /****************************************************************** * - * @brief Deallocation of memory allocated by aper decoder for - * RIC service update failure + * @brief Deallocation of memory allocated by aper decoder for reset req * * @details * - * Function : freeAperDecodingOfRicServiceUpdateFailure + * Function : freeAperDecodingOfE2ResetReq * - * Functionality: Deallocation of memory allocated by aper decoder - * for RIC service update failure + * Functionality: Deallocation of memory allocated by aper decoder for + * reset req * - * @params[in] RICserviceUpdateFailure_t *ricServiceFailure; + * @params[in] Pointer to resetReq * @return void * * ****************************************************************/ - -void freeAperDecodingOfRicServiceUpdateFailure(RICserviceUpdateFailure_t *ricServiceFailure) +void freeAperDecodingOfE2ResetReq(ResetRequestE2_t *resetReq) { uint8_t arrIdx=0; - if(ricServiceFailure) + if(resetReq) { - if(ricServiceFailure->protocolIEs.list.array) + if(resetReq->protocolIEs.list.array) { - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) { - if(ricServiceFailure->protocolIEs.list.array[arrIdx]) + if(resetReq->protocolIEs.list.array[arrIdx]) { - free(ricServiceFailure->protocolIEs.list.array[arrIdx]); + free(resetReq->protocolIEs.list.array[arrIdx]); } } - free(ricServiceFailure->protocolIEs.list.array); - } - } -} - -/****************************************************************** - * - * @brief Processes RIC service update failure sent by RIC - * - * @details - * - * Function : procRicServiceUpdateFailure - * - * Functionality: Processes RIC service update failure sent by RIC - * - * @params[in] E2AP_PDU_t ASN decoded E2AP message - * @return ROK - success - * RFAILED - failure - * - * ****************************************************************/ - -void procRicServiceUpdateFailure(E2AP_PDU_t *e2apMsg) -{ - uint8_t arrIdx =0, timerValue=0; - RICserviceUpdateFailure_t *ricServiceFailure=NULL; - - DU_LOG("\nINFO --> E2AP : RIC service update failure received"); - ricServiceFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICserviceUpdateFailure; - - for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) - { - switch(ricServiceFailure->protocolIEs.list.array[arrIdx]->id) - { - case ProtocolIE_IDE2_id_TransactionID: - { - break; - } - case ProtocolIE_IDE2_id_TimeToWaitE2: - { - timerValue = convertE2WaitTimerEnumToValue(ricServiceFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); - if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer), EVENT_RIC_SERVICE_UPDATE_TMR)) == FALSE) - { - duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer), EVENT_RIC_SERVICE_UPDATE_TMR, timerValue); - } - else - { - DU_LOG("\nERROR --> E2AP : EVENT_RIC_SERVICE_UPDATE_TMR timer is already running"); - return; - } - break; - } - case ProtocolIE_IDE2_id_CauseE2: - { - break; - } + free(resetReq->protocolIEs.list.array); } } - - freeAperDecodingOfRicServiceUpdateFailure(ricServiceFailure); } -/****************************************************************** +/******************************************************************* * - * @brief DU Send E2 Node Configuration Update + * @brief Process reset req received from RIC * * @details * - * Function : duSendE2NodeConfigurationUpdate + * Function : procE2ResetRequest * - * Functionality: DU Send E2 Node Configuration Update + * Functionality: Process reset req received from RIC * - * @return ROK - success - * RFAILED - failure + * @param E2AP_PDU_t *e2apMsg + * @return void * - * ****************************************************************/ + ******************************************************************/ -uint8_t duSendE2NodeConfigurationUpdate() +void procE2ResetRequest(E2AP_PDU_t *e2apMsg) { - E2NodeConfigList e2NodeList; - CmLList *node =NULL; - E2NodeComponent *e2NodeComponentInfo=NULL; + uint16_t ranFuncIdx=0; + uint8_t arrIdx =0, transId =0; + ResetRequestE2_t *resetReq; - memset(&e2NodeList, 0, sizeof(E2NodeConfigList)); - CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node); - while(node) - { - e2NodeComponentInfo = (E2NodeComponent*)node->node; + DU_LOG("\nINFO --> E2AP : E2 Reset request received"); + resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2; - if(e2NodeComponentInfo->componentRequestPart && e2NodeComponentInfo->componentResponsePart) + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + switch(resetReq->protocolIEs.list.array[arrIdx]->id) { - switch(e2NodeComponentInfo->componentActionType) - { - case E2_NODE_COMPONENT_ADD: - { - e2NodeList.addE2Node[e2NodeList.addE2NodeCount].interface = e2NodeComponentInfo->interfaceType; - e2NodeList.addE2Node[e2NodeList.addE2NodeCount].actionType = e2NodeComponentInfo->componentActionType; - e2NodeList.removeE2NodeCount++; - break; - } - case E2_NODE_COMPONENT_UPDATE: - { - e2NodeList.updateE2Node[e2NodeList.updateE2NodeCount].interface = e2NodeComponentInfo->interfaceType; - e2NodeList.updateE2Node[e2NodeList.updateE2NodeCount].actionType = e2NodeComponentInfo->componentActionType; - e2NodeList.updateE2NodeCount++; - break; + case ProtocolIE_IDE2_id_TransactionID: + { + transId = resetReq->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + break; + } - } - case E2_NODE_COMPONENT_DEL: + case ProtocolIE_IDE2_id_CauseE2: + { + for(ranFuncIdx=0; ranFuncIdxinterfaceType; - e2NodeList.removeE2Node[e2NodeList.removeE2NodeCount].actionType = e2NodeComponentInfo->componentActionType; - e2NodeList.removeE2NodeCount++; - break; + if(duCb.e2apDb.ranFunction[ranFuncIdx].id >0) + { + deleteRicSubscriptionList(&(duCb.e2apDb.ranFunction[ranFuncIdx].subscriptionList)); + memset(&(duCb.e2apDb.ranFunction[ranFuncIdx].pendingSubsRspInfo), 0, MAX_PENDING_SUBSCRIPTION_RSP*sizeof(PendingSubsRspInfo)); + } } - } + break; + } } - node = node->next; } - - if(BuildAndSendE2NodeConfigUpdate(&e2NodeList) !=ROK) + if(BuildAndSendResetResponse(transId) != ROK) { - DU_LOG("\nERROR --> E2AP : Failed to build and send e2 node config update message to RIC_stub"); - return RFAILED; + DU_LOG("\nERROR --> E2AP : Failed to build and send reset response"); } - return ROK; + freeAperDecodingOfE2ResetReq(resetReq); } /******************************************************************* * - * @brief Free RIC Subscription Modification Required + * @brief Free APER decoding of RIC Subscription Modification Refuse * * @details * - * Function : FreeRicSubsModRequired + * Function : freeAperDecodingOfRicSubsModRefuse * - * Functionality: Freqq RIC Subscription Modification required + * Functionality: Free APER decoding of RIC Subscription + * Modification Refuse * - * @param E2AP Message PDU to be freed + * @param E2AP Message PDU * @return void * ******************************************************************/ -void FreeRicSubsModRequired(E2AP_PDU_t *e2apMsg) +void freeAperDecodingOfRicSubsModRefuse(E2AP_PDU_t *e2apMsg) { - uint8_t ieIdx = 0, arrIdx = 0; - RICsubscriptionModificationRequired_t *ricSubsModReqd = NULLP; - RICsubscriptionModificationRequired_IEs_t *ricSubsModReqdIe = NULLP; - RICactions_RequiredToBeModified_List_t *actionToBeModList = NULLP; - RICactions_RequiredToBeRemoved_List_t *actionToBeRmvList = NULLP; + uint8_t ieIdx =0; + RICsubscriptionModificationRefuse_t *ricSubsModRefuse = NULLP; - if(e2apMsg) + if(e2apMsg && e2apMsg->choice.unsuccessfulOutcome) { - if(e2apMsg->choice.initiatingMessage) + ricSubsModRefuse = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICsubscriptionModificationRefuse; + if(ricSubsModRefuse->protocolIEs.list.array) { - ricSubsModReqd = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionModificationRequired; - if(ricSubsModReqd->protocolIEs.list.array) + for(ieIdx = 0; ieIdx < ricSubsModRefuse->protocolIEs.list.count; ieIdx++) { - for(ieIdx = 0; ieIdx < ricSubsModReqd->protocolIEs.list.count; ieIdx++) - { - if(ricSubsModReqd->protocolIEs.list.array[ieIdx]) - { - ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; - switch(ricSubsModReqdIe->id) - { - case ProtocolIE_IDE2_id_RICactionsRequiredToBeModified_List: - { - actionToBeModList = &ricSubsModReqdIe->value.choice.RICactions_RequiredToBeModified_List; - if(actionToBeModList->list.array) - { - for(arrIdx = 0; arrIdx < actionToBeModList->list.count; arrIdx++) - { - DU_FREE(actionToBeModList->list.array[arrIdx], \ - sizeof(RICaction_RequiredToBeModified_ItemIEs_t)); - } - DU_FREE(actionToBeModList->list.array, actionToBeModList->list.size); - } - break; - } - - case ProtocolIE_IDE2_id_RICactionsRequiredToBeRemoved_List: - { - actionToBeRmvList = &ricSubsModReqdIe->value.choice.RICactions_RequiredToBeRemoved_List; - if(actionToBeRmvList->list.array) - { - for(arrIdx = 0; arrIdx < actionToBeRmvList->list.count; arrIdx++) - { - DU_FREE(actionToBeRmvList->list.array[arrIdx], \ - sizeof(RICaction_RequiredToBeRemoved_ItemIEs_t)); - } - DU_FREE(actionToBeRmvList->list.array, actionToBeRmvList->list.size); - } - break; - } - - default: - break; - } - DU_FREE(ricSubsModReqd->protocolIEs.list.array[ieIdx], \ - sizeof(RICsubscriptionModificationRequired_IEs_t)); - } - } - DU_FREE(ricSubsModReqd->protocolIEs.list.array, ricSubsModReqd->protocolIEs.list.size); + if(ricSubsModRefuse->protocolIEs.list.array[ieIdx]) + free(ricSubsModRefuse->protocolIEs.list.array[ieIdx]); } - DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + free(ricSubsModRefuse->protocolIEs.list.array); } - DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); } } -/* A RIC Subscription includes RIC subsequent action only for RIC Insert service. - * However, E2SM-KPM supports only RIC Report service. - * Hence there is no subsequent action in RIC subscription that may require modification. - * So commenting the action-modification IEs for the time being - */ -#if 0 /******************************************************************* * - * @brief Fill Action required to be modified list + * @brief Process RIC Subscription Modification Refuse Message * * @details * - * Function : FillActionReqdToBeModList + * Function : procRicSubscriptionModificationRefuse * - * Functionality: Fill Action required to be modified list + * Functionality: Process RIC Subscription Modification Refuse + * Message received from RIC. * - * @param RIC Actions Required To Be Modified List to be filled - * Number of actions to be modified - * RIC Subscription DB - * @return ROK - success - * RFAILED - failure + * @param E2AP Message PDU + * @return void * ******************************************************************/ -uint8_t FillActionReqdToBeModList(RICactions_RequiredToBeModified_List_t *actionToBeModList, uint8_t numActionsMod, \ - RicSubscription *ricSubscription) +void procRicSubscriptionModificationRefuse(E2AP_PDU_t *e2apMsg) { - uint8_t arrIdx = 0, actionIdx = 0; - RICaction_RequiredToBeModified_ItemIEs_t *actionToBeMod = NULL; + uint8_t ieIdx = 0; + uint16_t ranFuncId = 0; + RicRequestId ricReqId; + RICsubscriptionModificationRefuse_t *ricSubsModRefuse = NULLP; + RICsubscriptionModificationRefuse_IEs_t *ricSubsModRefuseIe = NULLP; + CauseE2_t *cause = NULLP; - actionToBeModList->list.count = numActionsMod; - actionToBeModList->list.size = numActionsMod * sizeof(RICaction_RequiredToBeModified_ItemIEs_t *); - DU_ALLOC(actionToBeModList->list.array, actionToBeModList->list.size); - if(!actionToBeModList->list.array) - { - DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); - return RFAILED; - } + DU_LOG("\nINFO --> E2AP : %s: Received RIC Subscription Modification Refuse", __func__); - arrIdx = 0; - for(actionIdx = 0; actionIdx < MAX_RIC_ACTION; actionIdx++) - { - if(ricSubscription->actionSequence[actionIdx].action == CONFIG_MOD) + do{ + if(!e2apMsg) { - DU_ALLOC(actionToBeModList->list.array[arrIdx], sizeof(RICaction_RequiredToBeModified_ItemIEs_t)); - if(!actionToBeModList->list.array[arrIdx]) + DU_LOG("\nERROR --> E2AP : %s: E2AP Message is NULL", __func__); + break; + } + + if(!e2apMsg->choice.unsuccessfulOutcome) + { + DU_LOG("\nERROR --> E2AP : %s: Unsuccessful Outcome in E2AP message is NULL", __func__); + break; + } + + ricSubsModRefuse = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICsubscriptionModificationRefuse; + if(!ricSubsModRefuse->protocolIEs.list.array) + { + DU_LOG("\nERROR --> E2AP : %s: Array conatining E2AP message IEs is null", __func__); + break; + } + + for(ieIdx = 0; ieIdx < ricSubsModRefuse->protocolIEs.list.count; ieIdx++) + { + if(!ricSubsModRefuse->protocolIEs.list.array[ieIdx]) { - DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__); - return RFAILED; + DU_LOG("\nERROR --> E2AP : %s: IE at index [%d] in E2AP message IEs list is null", __func__, ieIdx); + break; } - actionToBeMod = (RICaction_RequiredToBeModified_ItemIEs_t *)actionToBeModList->list.array[arrIdx]; - actionToBeMod->id = ProtocolIE_IDE2_id_RICaction_RequiredToBeModified_Item; - actionToBeMod->criticality = CriticalityE2_reject; - actionToBeMod->value.present = \ - RICaction_RequiredToBeModified_ItemIEs__value_PR_RICaction_RequiredToBeModified_Item; - actionToBeMod->value.choice.RICaction_RequiredToBeModified_Item.ricActionID = \ - ricSubscription->actionSequence[actionIdx].actionId; - actionToBeMod->value.choice.RICaction_RequiredToBeModified_Item.ricTimeToWait = RICtimeToWait_w5ms; + ricSubsModRefuseIe = ricSubsModRefuse->protocolIEs.list.array[ieIdx]; + switch(ricSubsModRefuseIe->id) + { + case ProtocolIE_IDE2_id_RICrequestID: + { + memset(&ricReqId, 0, sizeof(RicRequestId)); + ricReqId.requestorId = ricSubsModRefuseIe->value.choice.RICrequestID.ricRequestorID; + ricReqId.instanceId = ricSubsModRefuseIe->value.choice.RICrequestID.ricInstanceID; + break; + } - arrIdx++; - } - } + case ProtocolIE_IDE2_id_RANfunctionID: + { + ranFuncId = ricSubsModRefuseIe->value.choice.RANfunctionID; + break; + } - return ROK; + case ProtocolIE_IDE2_id_CauseE2: + { + DU_LOG("\nDEBUG --> E2AP : %s: RIC subscriptiom modification refused for RIC_Requestor_ID [%d] \ + RIC_Instance_ID [%d] RAN_Function_ID [%d] ", __func__, ricReqId.requestorId, \ + ricReqId.instanceId, ranFuncId); + + cause = &ricSubsModRefuseIe->value.choice.CauseE2; + printE2ErrorCause(cause); + } + + default: + break; + } /* End of switch for Protocol IE Id */ + } /* End of for loop for Protocol IE list */ + + break; + }while(true); + + freeAperDecodingOfRicSubsModRefuse(e2apMsg); + return; } -#endif /******************************************************************* * - * @brief Fill Action required to be removed list + * @brief Free RIC Subscription Delete Required Message * * @details * - * Function : FillActionReqdToBeRmvList + * Function : FreeRicSubscriptionDeleteRequired * - * Functionality: Fill Action required to be removed list + * Functionality: Free RIC Subscription Delete Required * - * @param RIC Actions Required To Be Removed List to be filled - * Number of actions to be removed - * RIC Subscription DB - * @return ROK - success - * RFAILED - failure + * @param E2AP Message PDU + * @return void * ******************************************************************/ -uint8_t FillActionReqdToBeRmvList(RICactions_RequiredToBeRemoved_List_t *actionToBeRmvList, uint8_t numActionsRmv, \ - RicSubscription *ricSubscription) +void FreeRicSubscriptionDeleteRequired(E2AP_PDU_t *e2apMsg, CmLListCp *ricSubsToBeDelList) { - uint8_t arrIdx = 0, actionIdx = 0; - RICaction_RequiredToBeRemoved_ItemIEs_t *actionToBeRmv = NULL; - - actionToBeRmvList->list.count = numActionsRmv; - actionToBeRmvList->list.size = numActionsRmv * sizeof(RICaction_RequiredToBeRemoved_ItemIEs_t *); - DU_ALLOC(actionToBeRmvList->list.array, actionToBeRmvList->list.size); - if(!actionToBeRmvList->list.array) - { - DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); - return RFAILED; - } + uint8_t ieIdx = 0, arrIdx = 0; + RICsubscriptionDeleteRequired_t *ricSubsDelRqd = NULLP; + RICsubscriptionDeleteRequired_IEs_t *ricSubsDelRqdIe = NULLP; + RICsubscription_List_withCause_t *ricSubsList = NULLP; + CmLList *subsNode = NULLP; - arrIdx = 0; - for(actionIdx = 0; actionIdx < MAX_RIC_ACTION; actionIdx++) + if(e2apMsg) { - if(ricSubscription->actionSequence[actionIdx].action == CONFIG_DEL) + if(e2apMsg->choice.initiatingMessage) { - DU_ALLOC(actionToBeRmvList->list.array[arrIdx], sizeof(RICaction_RequiredToBeRemoved_ItemIEs_t)); - if(!actionToBeRmvList->list.array[arrIdx]) + ricSubsDelRqd = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionDeleteRequired; + if(ricSubsDelRqd->protocolIEs.list.array) { - DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); - return RFAILED; + for(ieIdx = 0; ieIdx < ricSubsDelRqd->protocolIEs.list.count; ieIdx++) + { + if(ricSubsDelRqd->protocolIEs.list.array[ieIdx]) + { + ricSubsDelRqdIe = ricSubsDelRqd->protocolIEs.list.array[ieIdx]; + switch(ricSubsDelRqdIe->id) + { + case ProtocolIE_IDE2_id_RICsubscriptionToBeRemoved: + { + ricSubsList = &ricSubsDelRqdIe->value.choice.RICsubscription_List_withCause; + if(ricSubsList->list.array) + { + for(arrIdx = 0; arrIdx < ricSubsList->list.count; arrIdx++) + { + DU_FREE(ricSubsList->list.array[ieIdx], sizeof(RICsubscription_withCause_ItemIEs_t)); + } + DU_FREE(ricSubsList->list.array, ricSubsList->list.size); + } + break; + } + } + DU_FREE(ricSubsDelRqd->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteRequired_IEs_t)); + } + } + DU_FREE(ricSubsDelRqd->protocolIEs.list.array, ricSubsDelRqd->protocolIEs.list.size); } - actionToBeRmv = (RICaction_RequiredToBeRemoved_ItemIEs_t *)actionToBeRmvList->list.array[arrIdx]; - - actionToBeRmv->id = ProtocolIE_IDE2_id_RICaction_RequiredToBeRemoved_Item; - actionToBeRmv->criticality = CriticalityE2_reject; - actionToBeRmv->value.present = \ - RICaction_RequiredToBeRemoved_ItemIEs__value_PR_RICaction_RequiredToBeRemoved_Item; - actionToBeRmv->value.choice.RICaction_RequiredToBeRemoved_Item.ricActionID = \ - ricSubscription->actionSequence[actionIdx].actionId; - fillE2Cause(&actionToBeRmv->value.choice.RICaction_RequiredToBeRemoved_Item.cause, \ - ricSubscription->actionSequence[actionIdx].failureCause); - - arrIdx++; + DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));; } - return ROK; + if(ricSubsToBeDelList) + { + CM_LLIST_FIRST_NODE(ricSubsToBeDelList, subsNode); + while(subsNode) + { + cmLListDelFrm(ricSubsToBeDelList, subsNode); + DU_FREE(subsNode, sizeof(CmLList)); + CM_LLIST_FIRST_NODE(ricSubsToBeDelList, subsNode); + } + } } /******************************************************************* * - * @brief Fill RIC Subscription Modification Required IEs + * @brief Fill list of RIC subscriptions required to be deleted + * with the cause of deletion * * @details * - * Function : FillRicSubsModRequired + * Function : fillRicSubsListWithCause * - * Functionality: Fill RIC Subscription Modification Required IEs + * Functionality: Fill list of RIC subscriptions required to be + * deleted with the cause of deletion * - * @param RIC Subscription Modification Required IEs to be filled - * RIC Subscription DB - * @return ROK - success - * RFAILED - failure + * @param E2AP Message PDU + * @return void * ******************************************************************/ -uint8_t FillRicSubsModRequired(RICsubscriptionModificationRequired_t *ricSubsModReqd, RicSubscription *ricSubscription) +uint8_t fillRicSubsListWithCause(RICsubscription_List_withCause_t *ricSubsList, CmLListCp ricSubsToBeDelList) { - uint8_t ieIdx = 0, elementCnt=0, actionIdx = 0; - uint8_t numActionsMod = 0, numActionsRmv = 0; - RICsubscriptionModificationRequired_IEs_t *ricSubsModReqdIe = NULLP; - RICactions_RequiredToBeModified_List_t *actionToBeModList = NULLP; - RICactions_RequiredToBeRemoved_List_t *actionToBeRmvList = NULLP; - - /* Count number of Actions to be modified or deleted */ - for(actionIdx = 0; actionIdx < MAX_RIC_ACTION; actionIdx++) - { - if(ricSubscription->actionSequence[actionIdx].action == CONFIG_MOD) - numActionsMod++; - else if(ricSubscription->actionSequence[actionIdx].action == CONFIG_DEL) - numActionsRmv++; - } - - /* Count number of IEs to be added to messages */ - elementCnt = 2; - if(numActionsMod) - elementCnt++; - if(numActionsRmv) - elementCnt++; - - ricSubsModReqd->protocolIEs.list.count = elementCnt; - ricSubsModReqd->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionModificationRequired_IEs_t *); - DU_ALLOC(ricSubsModReqd->protocolIEs.list.array, ricSubsModReqd->protocolIEs.list.size); - if(!ricSubsModReqd->protocolIEs.list.array) + uint16_t ieIdx = 0; + CmLList *subsNode = NULLP; + RicSubscription *subsInfo = NULLP; + RICsubscription_withCause_ItemIEs_t *subsItemIe = NULLP; + RICsubscription_withCause_Item_t *subsItem = NULLP; + + ricSubsList->list.count = ricSubsToBeDelList.count; + ricSubsList->list.size = ricSubsList->list.count * sizeof(RICsubscription_withCause_ItemIEs_t *); + DU_ALLOC(ricSubsList->list.array, ricSubsList->list.size); + if(!ricSubsList->list.array) { - DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); + DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__); return RFAILED; } - for(ieIdx = 0; ieIdx < elementCnt; ieIdx++) + CM_LLIST_FIRST_NODE(&ricSubsToBeDelList, subsNode); + while(subsNode && (ieIdx < ricSubsList->list.count)) { - DU_ALLOC(ricSubsModReqd->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionModificationRequired_IEs_t)); - if(!ricSubsModReqd->protocolIEs.list.array[ieIdx]) + subsInfo = (RicSubscription *)subsNode->node; + DU_ALLOC(ricSubsList->list.array[ieIdx], sizeof(RICsubscription_withCause_ItemIEs_t)); + if(!ricSubsList->list.array[ieIdx]) { - DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); + DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__); return RFAILED; } - } - - /* RIC Request ID */ - ieIdx = 0; - ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; - ricSubsModReqdIe->id = ProtocolIE_IDE2_id_RICrequestID; - ricSubsModReqdIe->criticality = CriticalityE2_reject; - ricSubsModReqdIe->value.present = RICsubscriptionModificationRequired_IEs__value_PR_RICrequestID; - ricSubsModReqdIe->value.choice.RICrequestID.ricRequestorID = ricSubscription->requestId.requestorId; - ricSubsModReqdIe->value.choice.RICrequestID.ricInstanceID = ricSubscription->requestId.instanceId; - - /* RAN Function ID */ - ieIdx++; - ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; - ricSubsModReqdIe->id = ProtocolIE_IDE2_id_RANfunctionID; - ricSubsModReqdIe->criticality = CriticalityE2_reject; - ricSubsModReqdIe->value.present = RICsubscriptionModificationRequired_IEs__value_PR_RANfunctionID; - ricSubsModReqdIe->value.choice.RANfunctionID = ricSubscription->ranFuncId; -/* A RIC Subscription includes RIC subsequent action only for RIC Insert service. - * However, E2SM-KPM supports only RIC Report service. - * Hence there is no subsequent action in RIC subscription that may require modification. - * So commenting the action-modification IEs for the time being - */ -#if 0 - /* RIC Actions Required to be Modified */ - if(numActionsMod) - { - ieIdx++; - ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; - ricSubsModReqdIe->id = ProtocolIE_IDE2_id_RICactionsRequiredToBeModified_List; - ricSubsModReqdIe->criticality = CriticalityE2_reject; - ricSubsModReqdIe->value.present = \ - RICsubscriptionModificationRequired_IEs__value_PR_RICactions_RequiredToBeModified_List; - actionToBeModList = &ricSubsModReqdIe->value.choice.RICactions_RequiredToBeModified_List; + subsItemIe = (RICsubscription_withCause_ItemIEs_t *)ricSubsList->list.array[ieIdx]; + subsItemIe->id = ProtocolIE_IDE2_id_RICsubscription_withCause_Item; + subsItemIe->criticality = CriticalityE2_ignore; + subsItemIe->value.present = RICsubscription_withCause_ItemIEs__value_PR_RICsubscription_withCause_Item; - if(FillActionReqdToBeModList(actionToBeModList, numActionsMod, ricSubscription) != ROK) - { - DU_LOG("\nERROR --> E2AP : %s: Failed to fill actions required to be modified list", __func__); - return RFAILED; - } - } -#endif + subsItem = & subsItemIe->value.choice.RICsubscription_withCause_Item; + subsItem->ricRequestID.ricRequestorID = subsInfo->requestId.requestorId; + subsItem->ricRequestID.ricInstanceID = subsInfo->requestId.instanceId; + subsItem->ranFunctionID = subsInfo->ranFuncId; + fillE2Cause(&subsItem->cause, subsInfo->failureCause); - /* RIC Actions Required to be removed */ - if(numActionsRmv) - { ieIdx++; - ricSubsModReqdIe = ricSubsModReqd->protocolIEs.list.array[ieIdx]; - ricSubsModReqdIe->id = ProtocolIE_IDE2_id_RICactionsRequiredToBeRemoved_List; - ricSubsModReqdIe->criticality = CriticalityE2_reject; - ricSubsModReqdIe->value.present = \ - RICsubscriptionModificationRequired_IEs__value_PR_RICactions_RequiredToBeRemoved_List; - actionToBeRmvList = &ricSubsModReqdIe->value.choice.RICactions_RequiredToBeRemoved_List; - - if(FillActionReqdToBeRmvList(actionToBeRmvList, numActionsRmv, ricSubscription) != ROK) - { - DU_LOG("\nERROR --> E2AP : %s: Failed to fill actions required to be removed list", __func__); - return RFAILED; - } + subsNode = subsNode->next; } - return ROK; + return ROK; } /******************************************************************* * - * @brief Builds and Send RIC Subscription Modification Required - * message + * @brief Builds and Send RIC Subscription delete required * * @details * - * Function : BuildAndSendRicSubsModRequired - * - * Functionality: Builds and Send RIC Subscription Modification - * Required message + * Function : BuildAndSendRicSubscriptionDeleteRequired + * + * Functionality: Build and send RIC subscription delete required. + * There can be 2 approaches to trigger following. One of these + * approaches may/may not be implemented in future: + * 1. It can be triggerred immediately when a RIC subscription's + * End Time has expired. In this case, only this subscription's + * info will be sent in this message. + * Since we have not yet added support to execute RIC + * Subscription based on Start Time and End Timer, this message is + * not triggered anywhere from DU APP yet. + * 2. Another approach is to have a periodic timer to check subscription + * status running in background. + * When RIC Subscription End Time expires, this subscription is + * marked to be deleted. Later when this background timer expires, + * a RIC Subscription delete required is sent with all the + * subscription's info which is marked to be deleted. + * The following function is implemented keeping in mind the second + * approach. * - * @param RIC Subscription DB + * @params[in] * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t BuildAndSendRicSubsModRequired(RicSubscription *ricSubscription) +uint8_t BuildAndSendRicSubscriptionDeleteRequired() { - uint8_t ret = RFAILED; - E2AP_PDU_t *e2apMsg = NULLP; - RICsubscriptionModificationRequired_t *ricSubsModReqd = NULLP; - asn_enc_rval_t encRetVal; /* Encoder return value */ + uint8_t elementCnt = 0, ieIdx = 0, ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + RICsubscriptionDeleteRequired_t *ricSubsDelRqd = NULLP; + RICsubscriptionDeleteRequired_IEs_t *ricSubsDelRqdIe = NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ + CmLListCp ricSubsToBeDelList; - DU_LOG("\nINFO --> E2AP : Building RIC Subscription Modification Required \n"); while(true) { + /* Check if there are any RIC subscriptions to be deleted */ + cmLListInit(&ricSubsToBeDelList); + fetchRicSubsToBeDeleted(&ricSubsToBeDelList); + if(ricSubsToBeDelList.count == 0) + { + DU_LOG("\nDEBUG --> E2AP : %s: No RIC subscriptions are required to be deleted", __func__); + return ROK; + } + + DU_LOG("\nINFO --> E2AP : Building RIC Subscription Delete Required Message\n"); + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); if(e2apMsg == NULLP) { - DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); + DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__); break; } @@ -5923,208 +7430,155 @@ uint8_t BuildAndSendRicSubsModRequired(RicSubscription *ricSubscription) DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); if(e2apMsg->choice.initiatingMessage == NULLP) { - DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line %d", __func__, __LINE__); + DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__); break; } + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICsubscriptionDeleteRequired; e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; - e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICsubscriptionModificationRequired; - e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICsubscriptionModificationRequired; + e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICsubscriptionDeleteRequired; - ricSubsModReqd = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionModificationRequired; + ricSubsDelRqd = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionDeleteRequired; + + elementCnt = 1; + ricSubsDelRqd->protocolIEs.list.count = elementCnt; + ricSubsDelRqd->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionDeleteRequired_IEs_t *); - if(FillRicSubsModRequired(ricSubsModReqd, ricSubscription) != ROK) + DU_ALLOC(ricSubsDelRqd->protocolIEs.list.array, ricSubsDelRqd->protocolIEs.list.size); + if(ricSubsDelRqd->protocolIEs.list.array == NULLP) { - DU_LOG("\nERROR --> E2AP : %s: Failed to fill RIC Subscription Modification Required IEs", __func__); + DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for array elements at line %d",__func__, __LINE__); break; } - /* Encode */ - xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg); + for(ieIdx = 0; ieIdx < elementCnt; ieIdx++) + { + DU_ALLOC(ricSubsDelRqd->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteRequired_IEs_t)); + if(ricSubsDelRqd->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; + ricSubsDelRqdIe = ricSubsDelRqd->protocolIEs.list.array[ieIdx]; + ricSubsDelRqdIe->id = ProtocolIE_IDE2_id_RICsubscriptionToBeRemoved; + ricSubsDelRqdIe->criticality = CriticalityE2_ignore; + ricSubsDelRqdIe->value.present = RICsubscriptionDeleteRequired_IEs__value_PR_RICsubscription_List_withCause; + if(fillRicSubsListWithCause(&ricSubsDelRqdIe->value.choice.RICsubscription_List_withCause, ricSubsToBeDelList)\ + != ROK) + { + DU_LOG("\nERROR --> E2AP : %s: Failed to fill RIC Subscription list with cause", __func__); + break; + } + /* 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 Modifiction Required structure (at %s)\n",\ + DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Delete Required 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 Modification Required \n"); + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Subscription Delete Required 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 : Sending RIC Subscription Modification Required failed"); - } + DU_LOG("\nERROR --> E2AP : Failed to send RIC Susbcription Delete Required Message"); + } ret = ROK; break; } - /* Free RIC Subscription modification required */ - FreeRicSubsModRequired(e2apMsg); + FreeRicSubscriptionDeleteRequired(e2apMsg, &ricSubsToBeDelList); return ret; -} - -/******************************************************************* - * - * @brief Free APER decoding of RIC Subscription Modification Confirm - * - * @details - * - * Function : freeAperDecodingOfRicSubsModConfirm - * - * Functionality: Free APER decoding of RIC Subscription - * Modification Confirm - * - * @param E2AP Message PDU - * @return void - * - ******************************************************************/ -void freeAperDecodingOfRicSubsModConfirm(E2AP_PDU_t *e2apMsg) -{ - uint8_t ieIdx = 0, arrIdx=0; - RICsubscriptionModificationConfirm_t *ricSubsModCfm = NULLP; - RICsubscriptionModificationConfirm_IEs_t *ricSubsModCfmIe = NULLP; - RICactions_ConfirmedForModification_List_t *modCfmList = NULLP; - RICactions_RefusedToBeModified_List_t *modRefusedList = NULLP; - RICactions_ConfirmedForRemoval_List_t *rmvCfmList = NULLP; - RICactions_RefusedToBeRemoved_List_t *rmvFailList = NULLP; - - if(e2apMsg && e2apMsg->choice.successfulOutcome) - { - ricSubsModCfm = &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionModificationConfirm; - if(ricSubsModCfm->protocolIEs.list.array) - { - for(ieIdx = 0; ieIdx < ricSubsModCfm->protocolIEs.list.count; ieIdx++) - { - if(ricSubsModCfm->protocolIEs.list.array[ieIdx]) - { - ricSubsModCfmIe = ricSubsModCfm->protocolIEs.list.array[ieIdx]; - switch(ricSubsModCfmIe->id) - { - case ProtocolIE_IDE2_id_RICactionsConfirmedForModification_List: - { - modCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForModification_List; - if(modCfmList->list.array) - { - for(arrIdx = 0; arrIdx < modCfmList->list.count; arrIdx++) - { - if(modCfmList->list.array[arrIdx]) - free(modCfmList->list.array[arrIdx]); - } - free(modCfmList->list.array); - } - break; - } - - case ProtocolIE_IDE2_id_RICactionsRefusedToBeModified_List: - { - modRefusedList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeModified_List; - if(modRefusedList->list.array) - { - for(arrIdx = 0; arrIdx < modRefusedList->list.count; arrIdx++) - { - if(modRefusedList->list.array[arrIdx]) - free(modRefusedList->list.array[arrIdx]); - } - free(modRefusedList->list.array); - } - break; - } - - case ProtocolIE_IDE2_id_RICactionsConfirmedForRemoval_List: - { - rmvCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForRemoval_List; - if(rmvCfmList->list.array) - { - for(arrIdx = 0; arrIdx < rmvCfmList->list.count; arrIdx++) - { - if(rmvCfmList->list.array[arrIdx]) - free(rmvCfmList->list.array[arrIdx]); - } - free(rmvCfmList->list.array); - } - break; - } - - case ProtocolIE_IDE2_id_RICactionsRefusedToBeRemoved_List: - { - rmvFailList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeRemoved_List; - if(rmvFailList->list.array) - { - for(arrIdx = 0; arrIdx < rmvFailList->list.count; arrIdx++) - { - if(rmvFailList->list.array[arrIdx]) - free(rmvFailList->list.array[arrIdx]); - } - free(rmvFailList->list.array); - } - break; - } +} - default: - break; +/******************************************************************* + * + * @brief Free RIC Subscription Delete Request Message + * + * @details + * + * Function : freeAperDecodingOfRicSubsDeleteReq + * + * Functionality: Free RIC Subscription Delete Request + * + * @param E2AP Message PDU + * @return void + * + ******************************************************************/ +void freeAperDecodingOfRicSubsDeleteReq(E2AP_PDU_t *e2apMsg) +{ + uint8_t ieIdx = 0; + RICsubscriptionDeleteRequest_t *ricSubsDelReq = NULLP; + if(e2apMsg) + { + if(e2apMsg->choice.initiatingMessage) + { + ricSubsDelReq = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionDeleteRequest; + if(ricSubsDelReq->protocolIEs.list.array) + { + for(ieIdx = 0; ieIdx < ricSubsDelReq->protocolIEs.list.count; ieIdx++) + { + if(ricSubsDelReq->protocolIEs.list.array[ieIdx]) + { + free(ricSubsDelReq->protocolIEs.list.array[ieIdx]); } - free(ricSubsModCfmIe); } + free(ricSubsDelReq->protocolIEs.list.array); } - free(ricSubsModCfm->protocolIEs.list.array); } } } /******************************************************************* * - * @brief Process RIC Subscription Modification Confirm Message + * @brief Process RIC Subscription delete request * * @details * - * Function : procRicSubscriptionModificationConfirm + * Function : procRicSubscriptionDeleteRequest * - * Functionality: Process RIC Subscription Modification Confirm - * Message received from RIC. + * Functionality: Process RIC subscription delete request. + * Fetch RAN Function and RIC subscription to be deleted. + * Send statistics delete request to MAC for all action sequence + * within this RIC subscription. * - * @param E2AP Message PDU + * @params[in] E2AP PDU * @return void * ******************************************************************/ -void procRicSubscriptionModificationConfirm(E2AP_PDU_t *e2apMsg) +void procRicSubscriptionDeleteRequest(E2AP_PDU_t *e2apMsg) { - uint8_t actionId = 0, ieIdx = 0, arrIdx = 0; + uint8_t ieIdx = 0; uint16_t ranFuncId = 0; bool procFailure = false; RicRequestId ricReqId; RanFunction *ranFuncDb = NULLP; CmLList *ricSubsNode = NULLP; RicSubscription *ricSubsDb = NULLP; - ActionInfo *actionDb = NULLP; - - RICsubscriptionModificationConfirm_t *ricSubsModCfm = NULLP; - RICsubscriptionModificationConfirm_IEs_t *ricSubsModCfmIe = NULLP; - - RICactions_ConfirmedForModification_List_t *modCfmList = NULLP; - RICaction_ConfirmedForModification_ItemIEs_t *modCfmListItem = NULLP; - - RICactions_RefusedToBeModified_List_t *modRefusedList = NULLP; - RICaction_RefusedToBeModified_ItemIEs_t *modRefusedListItem = NULLP; - - RICactions_ConfirmedForRemoval_List_t *rmvCfmList = NULLP; - RICaction_ConfirmedForRemoval_ItemIEs_t *rmvCfmListItem = NULLP; - - RICactions_RefusedToBeRemoved_List_t *rmvFailList = NULLP; - RICaction_RefusedToBeRemoved_ItemIEs_t *rmvFailListItem = NULLP; + RICsubscriptionDeleteRequest_t *ricSubsDelReq = NULLP; + RICsubscriptionDeleteRequest_IEs_t *ricSubsDelReqIe = NULLP; - DU_LOG("\nINFO --> E2AP : %s: Received RIC Subscription Modification Confirm", __func__); + DU_LOG("\nINFO --> E2AP : %s: Received RIC Subscription Delete Request", __func__); do{ if(!e2apMsg) @@ -6133,41 +7587,41 @@ void procRicSubscriptionModificationConfirm(E2AP_PDU_t *e2apMsg) break; } - if(!e2apMsg->choice.successfulOutcome) + if(!e2apMsg->choice.initiatingMessage) { - DU_LOG("\nERROR --> E2AP : %s: Successful Outcome in E2AP message is NULL", __func__); + DU_LOG("\nERROR --> E2AP : %s: Initiating Message in E2AP PDU is NULL", __func__); break; } - ricSubsModCfm = &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionModificationConfirm; - if(!ricSubsModCfm->protocolIEs.list.array) + ricSubsDelReq = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionDeleteRequest; + if(!ricSubsDelReq->protocolIEs.list.array) { DU_LOG("\nERROR --> E2AP : %s: Array conatining E2AP message IEs is null", __func__); break; } - for(ieIdx = 0; ieIdx < ricSubsModCfm->protocolIEs.list.count; ieIdx++) + for(ieIdx = 0; ieIdx < ricSubsDelReq->protocolIEs.list.count; ieIdx++) { - if(!ricSubsModCfm->protocolIEs.list.array[ieIdx]) + if(!ricSubsDelReq->protocolIEs.list.array[ieIdx]) { DU_LOG("\nERROR --> E2AP : %s: IE at index [%d] in E2AP message IEs list is null", __func__, ieIdx); break; } - ricSubsModCfmIe = ricSubsModCfm->protocolIEs.list.array[ieIdx]; - switch(ricSubsModCfmIe->id) + ricSubsDelReqIe = ricSubsDelReq->protocolIEs.list.array[ieIdx]; + switch(ricSubsDelReqIe->id) { case ProtocolIE_IDE2_id_RICrequestID: { memset(&ricReqId, 0, sizeof(RicRequestId)); - ricReqId.requestorId = ricSubsModCfmIe->value.choice.RICrequestID.ricRequestorID; - ricReqId.instanceId = ricSubsModCfmIe->value.choice.RICrequestID.ricInstanceID; + ricReqId.requestorId = ricSubsDelReqIe->value.choice.RICrequestID.ricRequestorID; + ricReqId.instanceId = ricSubsDelReqIe->value.choice.RICrequestID.ricInstanceID; break; } case ProtocolIE_IDE2_id_RANfunctionID: { - ranFuncId = ricSubsModCfmIe->value.choice.RANfunctionID; + ranFuncId = ricSubsDelReqIe->value.choice.RANfunctionID; ranFuncDb = fetchRanFuncFromRanFuncId(ranFuncId); if(!ranFuncDb) { @@ -6185,124 +7639,245 @@ void procRicSubscriptionModificationConfirm(E2AP_PDU_t *e2apMsg) break; } + //TODO : Send statistics delete request to MAC break; } -/* A RIC Subscription includes RIC subsequent action only for RIC Insert service. - * However, E2SM-KPM supports only RIC Report service. - * Hence there is no subsequent action in RIC subscription that may require modification. - * So commenting the action-modification IEs for the time being - */ -#if 0 - case ProtocolIE_IDE2_id_RICactionsConfirmedForModification_List: - { - modCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForModification_List; - for(arrIdx = 0; arrIdx < modCfmList->list.count; arrIdx++) - { - modCfmListItem = (RICaction_ConfirmedForModification_ItemIEs_t *)modCfmList->list.array[arrIdx]; - actionId = modCfmListItem->value.choice.RICaction_ConfirmedForModification_Item.ricActionID; + default: + break; + } /* End of switch for Protocol IE Id */ + + if(procFailure) + break; + } /* End of for loop for Protocol IE list */ - actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb); - if(!actionDb) + break; + }while(true); + + freeAperDecodingOfRicSubsDeleteReq(e2apMsg); + return; +} + +/******************************************************************* + * + * @brief Deallocate the memory allocated for E2 node configuration + * update ack msg by aper decoder + * + * @details + * + * Function : freeAperDecodingOfE2NodeConfigUpdateAck + * + * Functionality: + * - Deallocate the memory allocated for E2 node configuration + * update ack msg by aper decoder + * + * @params[in] E2AP_PDU_t *e2apMsg + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void freeAperDecodingOfE2NodeConfigUpdateAck(E2nodeConfigurationUpdateAcknowledge_t *updateAckMsg) +{ + uint8_t arrIdx =0, e2NodeConfigIdx=0; + E2nodeComponentConfigUpdateAck_ItemIEs_t *updateAckItemIe=NULL; + E2nodeComponentConfigUpdateAck_List_t *updateAckList=NULL; + E2nodeComponentConfigRemovalAck_ItemIEs_t *removalAckItemIe=NULL; + E2nodeComponentConfigRemovalAck_List_t *removalAckList=NULL; + E2nodeComponentConfigAdditionAck_ItemIEs_t *additionAckItemIte=NULL; + E2nodeComponentConfigAdditionAck_List_t *additionAckList=NULL; + + E2nodeComponentInterfaceF1_t *f1InterfaceInfo=NULLP; + if(updateAckMsg->protocolIEs.list.array != NULLP) + { + for(arrIdx = 0; arrIdx < updateAckMsg->protocolIEs.list.count; arrIdx++) + { + if(updateAckMsg->protocolIEs.list.array[arrIdx]) + { + switch(updateAckMsg->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck: + { + additionAckList =&updateAckMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List; + if(additionAckList->list.array) { - DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId); + for(e2NodeConfigIdx=0; e2NodeConfigIdxlist.count; e2NodeConfigIdx++) + { + additionAckItemIte = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) additionAckList->list.array[e2NodeConfigIdx]; + if(additionAckItemIte) + { + switch(additionAckItemIte->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.present) + { + case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1: + { + f1InterfaceInfo = additionAckItemIte->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1; + free(f1InterfaceInfo->gNB_DU_ID.buf); + free(f1InterfaceInfo); + break; + } + default: + break; + } + free(additionAckItemIte); + } + free(additionAckList->list.array); + } + break; } - else + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck: + { + updateAckList =&updateAckMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdateAck_List; + if(updateAckList->list.array) { - actionDb->action = CONFIG_UNKNOWN; - /* Further handling can be added here in future once the - * use case of this procedure is identified */ + for(e2NodeConfigIdx=0; e2NodeConfigIdxlist.count; e2NodeConfigIdx++) + { + updateAckItemIe = (E2nodeComponentConfigUpdateAck_ItemIEs_t*) updateAckList->list.array[e2NodeConfigIdx]; + if(updateAckItemIe) + { + switch(updateAckItemIe->value.choice.E2nodeComponentConfigUpdateAck_Item.e2nodeComponentID.present) + { + case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1: + { + f1InterfaceInfo = updateAckItemIe->value.choice.E2nodeComponentConfigUpdateAck_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1; + free(f1InterfaceInfo->gNB_DU_ID.buf); + free(f1InterfaceInfo); + break; + } + default: + break; + } + free(updateAckItemIe); + } + } + free(updateAckList->list.array); } - actionDb = NULLP; + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck: + { + removalAckList =&updateAckMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemovalAck_List; + if(removalAckList->list.array) + { + for(e2NodeConfigIdx=0; e2NodeConfigIdxlist.count; e2NodeConfigIdx++) + { + removalAckItemIe = (E2nodeComponentConfigRemovalAck_ItemIEs_t*) removalAckList->list.array[e2NodeConfigIdx]; + if(removalAckItemIe) + { + switch(removalAckItemIe->value.choice.E2nodeComponentConfigRemovalAck_Item.e2nodeComponentID.present) + { + case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1: + { + f1InterfaceInfo = removalAckItemIe->value.choice.E2nodeComponentConfigRemovalAck_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1; + free(f1InterfaceInfo->gNB_DU_ID.buf); + free(f1InterfaceInfo); + break; + } + default: + break; + } + free(removalAckItemIe); + } + } + free(removalAckList->list.array); + } + break; } + } + free(updateAckMsg->protocolIEs.list.array[arrIdx]); + } + } + free(updateAckMsg->protocolIEs.list.array); + } +} + +/****************************************************************** + * + * @brief Processes the E2 node config update ack msg + * + * @details + * + * Function :procE2NodeConfigUpdateAck + * + * Functionality: Processes the E2 node config update ack msg + * + * @params[in] E2AP_PDU_t ASN decoded E2AP message + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void procE2NodeConfigUpdateAck(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx =0; + uint16_t e2CfgIdx =0; + E2nodeConfigurationUpdateAcknowledge_t *e2NodeConfigUpdateAck =NULLP; + E2nodeComponentConfigUpdateAck_List_t *e2NodeConfigUpdateAckList=NULLP; + E2nodeComponentConfigUpdateAck_ItemIEs_t *e2NodeUpdateAckItem=NULLP; + E2nodeComponentConfigRemovalAck_List_t *e2NodeConfigRemovalAckList=NULLP; + E2nodeComponentConfigRemovalAck_ItemIEs_t *e2NodeRemovalAckItem=NULLP; + E2nodeComponentConfigAdditionAck_List_t *e2NodeConfigAdditionAckList=NULLP; + E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAdditionAckItem=NULLP; + + e2NodeConfigUpdateAck = &e2apMsg->choice.successfulOutcome->value.choice.E2nodeConfigurationUpdateAcknowledge; + + if(e2NodeConfigUpdateAck->protocolIEs.list.array) + { + for(arrIdx =0; arrIdxprotocolIEs.list.count; arrIdx++) + { + switch(e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + { break; } - - case ProtocolIE_IDE2_id_RICactionsRefusedToBeModified_List: + case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck: { - modRefusedList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeModified_List; - for(arrIdx = 0; arrIdx < modRefusedList->list.count; arrIdx++) + e2NodeConfigAdditionAckList = &e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List; + if(e2NodeConfigAdditionAckList->list.array) { - modRefusedListItem = (RICaction_RefusedToBeModified_ItemIEs_t *)modRefusedList->list.array[arrIdx]; - actionId = modRefusedListItem->value.choice.RICaction_RefusedToBeModified_Item.ricActionID; - actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb); - if(!actionDb) - { - DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId); - } - else - { - /* Spec doesnt mention if in case of failure, DU should retry for modify action - * Hence, chaging the action from CONFIG_MOD to CONFIG_UNKNOWN - */ - actionDb->action = CONFIG_UNKNOWN; - } - actionDb = NULLP; + for(e2CfgIdx = 0; e2CfgIdx< e2NodeConfigAdditionAckList->list.count; e2CfgIdx++) + { + e2NodeAdditionAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeConfigAdditionAckList->list.array[e2CfgIdx]; + handleE2NodeConfigUpdateAckIes((PTR)&e2NodeAdditionAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item,\ + ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck); + } } break; } -#endif - - case ProtocolIE_IDE2_id_RICactionsConfirmedForRemoval_List: + case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck: { - rmvCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForRemoval_List; - for(arrIdx = 0; arrIdx < rmvCfmList->list.count; arrIdx++) + e2NodeConfigUpdateAckList = &e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdateAck_List; + if(e2NodeConfigUpdateAckList->list.array) { - rmvCfmListItem = (RICaction_ConfirmedForRemoval_ItemIEs_t *)rmvCfmList->list.array[arrIdx]; - actionId = rmvCfmListItem->value.choice.RICaction_ConfirmedForRemoval_Item.ricActionID; - actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb); - if(!actionDb) - { - DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId); - } - else + for(e2CfgIdx = 0; e2CfgIdx< e2NodeConfigUpdateAckList->list.count; e2CfgIdx++) { - memset(actionDb, 0, sizeof(ActionInfo)); - actionDb->actionId = -1; - ricSubsDb->numOfActions--; - /* Further handling can include : - * Deletion of this action from all DU layers - */ + e2NodeUpdateAckItem = (E2nodeComponentConfigUpdateAck_ItemIEs_t*) e2NodeConfigUpdateAckList->list.array[e2CfgIdx]; + handleE2NodeConfigUpdateAckIes((PTR)&e2NodeUpdateAckItem->value.choice.E2nodeComponentConfigUpdateAck_Item,\ + ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck); } - actionDb = NULLP; } break; } - - case ProtocolIE_IDE2_id_RICactionsRefusedToBeRemoved_List: + case ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck: { - rmvFailList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeRemoved_List; - for(arrIdx = 0; arrIdx < rmvFailList->list.count; arrIdx++) + e2NodeConfigRemovalAckList = &e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemovalAck_List; + if(e2NodeConfigRemovalAckList->list.array) { - rmvFailListItem = (RICaction_RefusedToBeRemoved_ItemIEs_t *)rmvFailList->list.array[arrIdx]; - actionId = rmvFailListItem->value.choice.RICaction_RefusedToBeRemoved_Item.ricActionID; - actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb); - if(!actionDb) - { - DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId); - } - else + for(e2CfgIdx = 0; e2CfgIdx< e2NodeConfigRemovalAckList->list.count; e2CfgIdx++) { - actionDb->action = CONFIG_UNKNOWN; + e2NodeRemovalAckItem = (E2nodeComponentConfigRemovalAck_ItemIEs_t*) e2NodeConfigRemovalAckList->list.array[e2CfgIdx]; + handleE2NodeConfigUpdateAckIes((PTR)&e2NodeRemovalAckItem->value.choice.E2nodeComponentConfigRemovalAck_Item,\ + ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck); } - actionDb = NULLP; } break; } + } + } + } - default: - break; - } /* End of switch for Protocol IE Id */ - - if(procFailure) - break; - } /* End of for loop for Protocol IE list */ - - break; - }while(true); - - freeAperDecodingOfRicSubsModConfirm(e2apMsg); - return; + freeAperDecodingOfE2NodeConfigUpdateAck(e2NodeConfigUpdateAck); } /******************************************************************* @@ -6394,6 +7969,11 @@ void E2APMsgHdlr(Buffer *mBuf) procRicServiceUpdateFailure(e2apMsg); break; } + case UnsuccessfulOutcomeE2__value_PR_RICsubscriptionModificationRefuse: + { + procRicSubscriptionModificationRefuse(e2apMsg); + break; + } default: { DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_unsuccessfulOutcome [%d]",\ @@ -6416,11 +7996,6 @@ void E2APMsgHdlr(Buffer *mBuf) } break; } - case SuccessfulOutcomeE2__value_PR_E2nodeConfigurationUpdateAcknowledge: - { - DU_LOG("\nDEBUG --> E2AP : E2 node Config update ack message recevied"); - break; - } case SuccessfulOutcomeE2__value_PR_ResetResponseE2: { procResetResponse(e2apMsg); @@ -6436,7 +8011,11 @@ void E2APMsgHdlr(Buffer *mBuf) procRicSubscriptionModificationConfirm(e2apMsg); break; } - + case SuccessfulOutcomeE2__value_PR_E2nodeConfigurationUpdateAcknowledge: + { + procE2NodeConfigUpdateAck(e2apMsg); + break; + } default: { DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_successfulOutcome [%d]",\ @@ -6467,6 +8046,24 @@ void E2APMsgHdlr(Buffer *mBuf) DU_LOG("\nINFO --> E2AP : Error indication received"); break; } + case InitiatingMessageE2__value_PR_ResetRequestE2: + { + DU_LOG("\nINFO --> E2AP : Reset request received"); + procE2ResetRequest(e2apMsg); + break; + } + case InitiatingMessageE2__value_PR_RICsubscriptionDeleteRequest: + { + DU_LOG("\nINFO --> E2AP : RIC Subscription Delete Request received"); + procRicSubscriptionDeleteRequest(e2apMsg); + break; + } + case InitiatingMessageE2__value_PR_E2RemovalRequest: + { + DU_LOG("\nINFO --> E2AP : E2 Removal request received"); + procE2RemovalRequest(e2apMsg); + break; + } default: { DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_initiatingMessage [%d]",\