X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fric_stub%2Fric_e2ap_msg_hdl.c;h=b8ddf2ba01716eb64e1b17d52c3c851eba15bef1;hb=bb8df345963bb5ef2e035ead7731c1171e4cbbe0;hp=565d17f478e39d6737ed8345a6fd2ff06a81d79b;hpb=ef711b0830aedde36f4a1beceed146d08e77ce58;p=o-du%2Fl2.git diff --git a/src/ric_stub/ric_e2ap_msg_hdl.c b/src/ric_stub/ric_e2ap_msg_hdl.c index 565d17f47..b8ddf2ba0 100644 --- a/src/ric_stub/ric_e2ap_msg_hdl.c +++ b/src/ric_stub/ric_e2ap_msg_hdl.c @@ -21,34 +21,9 @@ #include "ric_stub_sctp.h" #include "ric_e2ap_msg_hdl.h" #include "GlobalE2node-gNB-ID.h" +#include "odu_common_codec.h" -char encBuf[ENC_BUF_MAX_LEN]; Bool ricSubsStatus; -S16 SendE2APMsg(Region , Pool ); - -/******************************************************************* - * - * @brief Writes the encoded chunks into a buffer - * - * @details - * - * Function : PrepFinalEncBuf - * - * Functionality:Fills the encoded buffer - * - * @params[in] void *buffer,initial encoded data - * @params[in] size_t size,size of buffer - * @params[in] void *encodedBuf,final buffer - * @return ROK - success - * RFAILED - failure - * - * ****************************************************************/ -static int PrepFinalEncBuf(const void *buffer, size_t size, void *encodedBuf) -{ - memcpy(encodedBuf + encBufSize, buffer, size); - encBufSize += size; - return 0; -} /* PrepFinalEncBuf */ /******************************************************************* * @@ -79,107 +54,28 @@ S16 SendE2APMsg(Region region, Pool pool) if(sctpSend(mBuf) != ROK) { - DU_LOG("\nF1AP : SCTP Send for E2 failed"); + DU_LOG("\nE2AP : SCTP Send for E2 failed"); SPutMsg(mBuf); - RETVALUE(RFAILED); + return RFAILED; } } else { - DU_LOG("\nF1AP : SAddPstMsgMult failed"); + DU_LOG("\nE2AP : SAddPstMsgMult failed"); SPutMsg(mBuf); - RETVALUE(RFAILED); + return RFAILED; } SPutMsg(mBuf); } else { - DU_LOG("\nF1AP : Failed to allocate memory"); - RETVALUE(RFAILED); + DU_LOG("\nE2AP : Failed to allocate memory"); + return RFAILED; } - RETVALUE(ROK); + return ROK; } /* SendE2APMsg */ -/******************************************************************* - * - * @brief Builds PLMN ID - * - * @details - * - * Function : plmnBuildRic - * - * Functionality: Building the PLMN ID - * - * @params[in] PLMNID plmn - * OCTET_STRING_t *octe - * @return ROK - success - * RFAILED - failure - * - * ****************************************************************/ - -void plmnBuildRic(Plmn plmn, OCTET_STRING_t *octe) -{ - U8 mncCnt; - octe->size = 3; - RIC_ALLOC(octe->buf, octe->size * sizeof(U8)); - if(octe->buf == NULLP) - { - RETVALUE(RFAILED); - } - mncCnt = 2; - octe->buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0])); - if(mncCnt == 2) - { - octe->buf[1] = ((0xf0) | (plmn.mcc[2])); - octe->buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0])); - } - else - { - octe->buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2])); - octe->buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1])); - } -} - -/******************************************************************* - * - * @brief Fills the RicId - * - * @details - * - * Function : FillRicId - * - * Functionality: Fills the RicId - * - * @params[in] BIT_STRING_t *nbid, - * U8 unusedBits - * U8 byteSize - * U8 val - * - * @return ROK - success - * RFAILED - failure - * - * ****************************************************************/ - -S16 FillRicId(BIT_STRING_t *id, U8 unusedBits, U8 byteSize, U8 val) -{ - U8 tmp; - id->size = byteSize; - RIC_ALLOC(id->buf, id->size * sizeof(U8)); - if(id->buf == NULLP) - { - RETVALUE(RFAILED); - } - - for (tmp = 0 ; tmp < (byteSize-1); tmp++) - { - id->buf[tmp] = tmp; - } - id->buf[byteSize-1] = val; //change this - id->bits_unused = unusedBits; - RETVALUE(ROK); -} - /******************************************************************* * * @brief Builds Global RIC Id Params @@ -203,45 +99,16 @@ S16 BuildGlobalRicId(GlobalRIC_ID_t *ricId) U8 val = 1; if(ricId != NULLP) { - plmnBuildRic(cuCfgParams.plmn , &ricId->pLMN_Identity); + ricId->pLMN_Identity.size = byteSize * sizeof(U8); + RIC_ALLOC(ricId->pLMN_Identity.buf, ricId->pLMN_Identity.size); + buildPlmnId(ricCfgParams.plmn , &ricId->pLMN_Identity); /* fill ric Id */ - FillRicId(&ricId->ric_ID, unused, byteSize, val); - } - RETVALUE(ROK); -} -#if 0 -RANfunctionID_ItemIEs_t* FillRanFuncItems(RANfunctionID_ItemIEs_t *items) -{ - if(items != NULLP) - { - items->id = ProtocolIE_IDE2_id_RANfunction_Item; - items->criticality = CriticalityE2_reject; - items->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item; - items->value.choice.RANfunctionID_Item.ranFunctionID = 1; - items->value.choice.RANfunctionID_Item.ranFunctionRevision = 4; - } - RETVALUE(items); -} - -S16 BuildRANfuncIdList(RANfunctionsID_List_t *funcIdList) -{ - U8 elementCnt; - RANfunctionID_ItemIEs_t *funcIdItems; - - elementCnt = 1; - funcIdList->list.count = elementCnt; - funcIdList->list.size = elementCnt * sizeof(RANfunctionID_ItemIEs_t); - RIC_ALLOC(funcIdList->list.array, funcIdList->list.size); - if(funcIdList->list.array == NULLP) - { - DU_LOG("\nE2AP : Memory allocation for RAN Function List failed"); - RETVALUE(RFAILED); + ricId->ric_ID.size = byteSize * sizeof(U8); + RIC_ALLOC(ricId->ric_ID.buf, ricId->ric_ID.size); + fillBitString(&ricId->ric_ID, unused, byteSize, val); } - RIC_ALLOC(funcIdList->list.array[0], sizeof(RANfunctionID_ItemIEs_t)); - FillRanFuncItems(funcIdList->list.array[0]); - RETVALUE(ROK); + return ROK; } -#endif /******************************************************************* * @@ -276,7 +143,7 @@ S16 BuildAndSendE2SetupRsp() if(e2apMsg == NULLP) { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); - RETVALUE(RFAILED); + return RFAILED; } e2apMsg->present = E2AP_PDU_PR_successfulOutcome; RIC_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); @@ -284,7 +151,7 @@ S16 BuildAndSendE2SetupRsp() { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_E2setup; @@ -304,7 +171,7 @@ S16 BuildAndSendE2SetupRsp() DU_LOG("\nE2AP : Memory allocation for E2ResponseIEs failed"); RIC_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } for(idx=0; idxchoice.successfulOutcome, \ sizeof(SuccessfulOutcomeE2_t)); RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } } /* Global RIC ID */ @@ -340,7 +207,7 @@ S16 BuildAndSendE2SetupRsp() { DU_LOG("\nE2AP : Could not encode E2SetupResponse structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - RETVALUE(RFAILED); + return RFAILED; } else { @@ -354,11 +221,11 @@ S16 BuildAndSendE2SetupRsp() if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL) != ROK) { - DU_LOG("\nF1AP : Sending E2 Setup Response failed"); - RETVALUE(RFAILED); + DU_LOG("\nE2AP : Sending E2 Setup Response failed"); + return RFAILED; } - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -385,7 +252,7 @@ S16 BuildRicRequestId(RICrequestID_t *ricReqId) ricReqId->ricRequestorID = 1; ricReqId->ricInstanceID = 1; } - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -439,7 +306,7 @@ S16 fillSubsDetails(RICaction_ToBeSetup_ItemIEs_t *items) items->value.present = RICaction_ToBeSetup_ItemIEs__value_PR_RICaction_ToBeSetup_Item; fillSetupItems(&(items->value.choice.RICaction_ToBeSetup_Item)); } - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -465,8 +332,12 @@ S16 BuildRicSubsDetails(RICsubscriptionDetails_t *subsDetails) if(subsDetails != NULLP) { - /* Plmn is not called */ - plmnBuildRic(cuCfgParams.plmn, &subsDetails->ricEventTriggerDefinition); + /* Octet string to be build here */ + /* Sending PLMN as Octect string */ + U8 byteSize = 3; + subsDetails->ricEventTriggerDefinition.size = byteSize * sizeof(U8); + RIC_ALLOC(subsDetails->ricEventTriggerDefinition.buf, subsDetails->ricEventTriggerDefinition.size); + buildPlmnId(ricCfgParams.plmn, &subsDetails->ricEventTriggerDefinition); elementCnt = 1; subsDetails->ricAction_ToBeSetup_List.list.count = elementCnt; subsDetails->ricAction_ToBeSetup_List.list.size = \ @@ -476,13 +347,13 @@ S16 BuildRicSubsDetails(RICsubscriptionDetails_t *subsDetails) if(subsDetails->ricAction_ToBeSetup_List.list.array == NULLP) { DU_LOG("\nE2AP : Memory allocation for RICactionToBeSetup Items failed"); - RETVALUE(RFAILED); + return RFAILED; } RIC_ALLOC(subsDetails->ricAction_ToBeSetup_List.list.array[0],\ sizeof(RICaction_ToBeSetup_ItemIEs_t)); fillSubsDetails(subsDetails->ricAction_ToBeSetup_List.list.array[0]); } - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -518,7 +389,7 @@ S16 BuildAndSendRicSubscriptionReq() if(e2apRicMsg == NULLP) { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); - RETVALUE(RFAILED); + return RFAILED; } e2apRicMsg->present = E2AP_PDU_PR_initiatingMessage; @@ -527,7 +398,7 @@ S16 BuildAndSendRicSubscriptionReq() { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); RIC_FREE(e2apRicMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } e2apRicMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICsubscription; e2apRicMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; @@ -548,7 +419,7 @@ S16 BuildAndSendRicSubscriptionReq() DU_LOG("\nE2AP : Memory allocation for RICSubscriptionRequestIEs failed"); RIC_FREE(e2apRicMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); RIC_FREE(e2apRicMsg, (Size)sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } for(idx=0; idxchoice.initiatingMessage, \ sizeof(InitiatingMessageE2_t)); RIC_FREE(e2apRicMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } } @@ -611,7 +482,7 @@ S16 BuildAndSendRicSubscriptionReq() { DU_LOG("\nE2AP : Could not encode RicSubscriptionRequest structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - RETVALUE(RFAILED); + return RFAILED; } else { @@ -627,10 +498,10 @@ S16 BuildAndSendRicSubscriptionReq() if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL) != ROK) { DU_LOG("\nE2AP : Sending RIC subscription Request failed"); - RETVALUE(RFAILED); + return RFAILED; } - RETVALUE(ROK); + return ROK; } @@ -683,7 +554,7 @@ void E2APMsgHdlr(Buffer *mBuf) printf("%x",recvBuf[i]); } - /* Decoding flat buffer into F1AP messsage */ + /* Decoding flat buffer into E2AP messsage */ e2apMsg = &e2apasnmsg; memset(e2apMsg, 0, sizeof(E2AP_PDU_t));