X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fdu_app%2Fdu_e2ap_msg_hdl.c;h=9321ee691fb8bd964a58d8c16c3b12f73ba39a67;hb=8340c342ebcfc82193c3f66e7f15047c1e37399b;hp=4ee88c6b311bcdc266db95485f8880577d024260;hpb=ef711b0830aedde36f4a1beceed146d08e77ce58;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 4ee88c6b3..9321ee691 100644 --- a/src/du_app/du_e2ap_msg_hdl.c +++ b/src/du_app/du_e2ap_msg_hdl.c @@ -19,116 +19,8 @@ #include "du_mgr_main.h" #include "GlobalE2node-gNB-ID.h" -#define ENC_BUF_MAX_LEN 100 - /* Global variable */ DuCfgParams duCfgParam; -char encBuf[ENC_BUF_MAX_LEN]; -int encBufSize; - -/******************************************************************* - * - * @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 */ - -/******************************************************************* - * - * @brief Builds PLMN ID - * - * @details - * - * Function : BuildPlmnId - * - * Functionality: Building the PLMN ID - * - * @params[in] PLMNID plmn - * OCTET_STRING_t *plmnid - * @return ROK - success - * RFAILED - failure - * - * ****************************************************************/ - -S16 BuildPlmnId(PlmnId plmn, OCTET_STRING_t *plmnid) -{ - U8 mncCnt; - plmnid->size = 3; - DU_ALLOC(plmnid->buf, plmnid->size * sizeof(U8)); - if(plmnid->buf == NULLP) - { - RETVALUE(RFAILED); - } - mncCnt = 2; - plmnid->buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0])); - if(mncCnt == 2) - { - plmnid->buf[1] = ((0xf0) | (plmn.mcc[2])); - plmnid->buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0])); - } - else - { - plmnid->buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2])); - plmnid->buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1])); - } - RETVALUE(ROK); -} - -/******************************************************************* - * - * @brief Builds NodeB Id - * - * @details - * - * Function : BuildNodeBId - * - * Functionality: Building the NodeBId - * - * @params[in] BIT_STRING_t *nbid, - * U8 unusedBits - * U8 byteSize - * U8 val - * - * @return ROK - success - * RFAILED - failure - * - * ****************************************************************/ - -S16 BuildNodeBId(BIT_STRING_t *nbid, U8 unusedBits, U8 byteSize, U8 val) -{ - U8 tmp; - nbid->size = byteSize; - DU_ALLOC(nbid->buf, nbid->size * sizeof(U8)); - if(nbid->buf == NULLP) - { - RETVALUE(RFAILED); - } - - for (tmp = 0 ; tmp < ((nbid->size)-1); tmp++) - { - nbid->buf[tmp] = 0; - } - nbid->buf[byteSize-1] = val; - nbid->bits_unused = unusedBits; - RETVALUE(ROK); -} /******************************************************************* * @@ -153,13 +45,20 @@ S16 BuildGlobalgNB(GlobalE2node_gNB_ID_t *gNbId) U8 val = 1; if(gNbId != NULLP) { - BuildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \ + /* Allocate Buffer size */ + gNbId->global_gNB_ID.plmn_id.size = 3 * sizeof(U8); + DU_ALLOC(gNbId->global_gNB_ID.plmn_id.buf , gNbId->global_gNB_ID.plmn_id.size); + buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \ &gNbId->global_gNB_ID.plmn_id); + /* fill gND Id */ - gNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID; - BuildNodeBId(&gNbId->global_gNB_ID.gnb_id.choice.gnb_ID, unused, byteSize, val); + 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(U8); + DU_ALLOC(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf, gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size); + fillBitString(&gNbId->global_gNB_ID.gnb_id.choice.gnb_ID, unused, byteSize, val); } - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -184,7 +83,6 @@ S16 BuildAndSendE2SetupReq() U8 elementCnt; U8 idx; U8 ieId; - S16 ret; asn_enc_rval_t encRetVal; /* Encoder return value */ DU_LOG("\nE2AP : Building E2 Setup Request\n"); @@ -193,7 +91,7 @@ S16 BuildAndSendE2SetupReq() if(e2apMsg == NULLP) { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); - RETVALUE(RFAILED); + return RFAILED; } e2apMsg->present = E2AP_PDU_PR_initiatingMessage; @@ -202,7 +100,7 @@ S16 BuildAndSendE2SetupReq() { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2setup; @@ -224,7 +122,7 @@ S16 BuildAndSendE2SetupReq() DU_LOG("\nE2AP : Memory allocation for E2RequestIEs failed"); DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); DU_FREE(e2apMsg, (Size)sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } for(idx=0; idxchoice.initiatingMessage, \ sizeof(InitiatingMessageE2_t)); DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } } @@ -273,7 +171,7 @@ S16 BuildAndSendE2SetupReq() { DU_LOG("\nE2AP : Could not encode E2SetupRequest structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - RETVALUE(RFAILED); + return RFAILED; } else { @@ -287,10 +185,10 @@ S16 BuildAndSendE2SetupReq() if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK) { DU_LOG("\nE2AP : Sending E2 Setup request failed"); - RETVALUE(RFAILED); + return RFAILED; } - RETVALUE(ROK); + return ROK; }/* End of BuildAndSendE2SetupReq */ /******************************************************************* @@ -316,7 +214,7 @@ S16 BuildRicRequestId(RICrequestID_t *ricReqId) ricReqId->ricRequestorID = 1; ricReqId->ricInstanceID = 1; } - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -345,7 +243,7 @@ S16 fillRicAdmitList(RICaction_Admitted_ItemIEs_t *ricAdmitItems) ricAdmitItems->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item; ricAdmitItems->value.choice.RICaction_Admitted_Item.ricActionID = 1; } - RETVALUE(ROK); + return ROK; } /******************************************************************* * @@ -374,12 +272,12 @@ S16 BuildRicAdmitList(RICaction_Admitted_List_t *admitListPtr) if(admitListPtr->list.array == NULLP) { DU_LOG("\nE2AP : Memory allocation for RIC Admit List failed"); - RETVALUE(RFAILED); + return RFAILED; } DU_ALLOC(admitListPtr->list.array[0], sizeof(RICaction_Admitted_ItemIEs_t)); - fillRicAdmitList(admitListPtr->list.array[0]); + fillRicAdmitList((RICaction_Admitted_ItemIEs_t *)admitListPtr->list.array[0]); - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -413,7 +311,7 @@ S16 BuildAndSendRicSubscriptionRsp() if(e2apRicMsg == NULLP) { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); - RETVALUE(RFAILED); + return RFAILED; } e2apRicMsg->present = E2AP_PDU_PR_successfulOutcome; DU_ALLOC(e2apRicMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); @@ -421,7 +319,7 @@ S16 BuildAndSendRicSubscriptionRsp() { DU_LOG("\nE2AP : Memory allocation for Ric subscription Response failed"); DU_FREE(e2apRicMsg, sizeof(RICsubscriptionResponse_t)); - RETVALUE(RFAILED); + return RFAILED; } e2apRicMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_RICsubscription; @@ -441,7 +339,7 @@ S16 BuildAndSendRicSubscriptionRsp() DU_LOG("\nE2AP : Memory allocation for RICsubscriptionResponseIE failed"); DU_FREE(e2apRicMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); DU_FREE(e2apRicMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } for(idx=0; idxchoice.successfulOutcome, \ sizeof(SuccessfulOutcomeE2_t)); DU_FREE(e2apRicMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } } idx = 0; @@ -491,7 +389,7 @@ S16 BuildAndSendRicSubscriptionRsp() { DU_LOG("\nE2AP : Could not encode RIC Subscription Response structure (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - RETVALUE(RFAILED); + return RFAILED; } else { @@ -505,10 +403,10 @@ S16 BuildAndSendRicSubscriptionRsp() if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK) { DU_LOG("\nE2AP : Sending RIC Subscription Response failed"); - RETVALUE(RFAILED); + return RFAILED; } - RETVALUE(ROK); + return ROK; } /****************************************************************** * @@ -548,10 +446,10 @@ S16 procE2SetupRsp(E2AP_PDU_t *e2apMsg) recvBufLen = sizeof(e2SetRspMsg->protocolIEs.list.array[idx]->value.choice.GlobalRIC_ID.pLMN_Identity); bitStringToInt(&e2SetRspMsg->protocolIEs.list.array[idx]->value.choice.GlobalRIC_ID.ric_ID, &e2SetupRspDb.ricId); - - aper_decode(0, &asn_DEF_PLMN_IdentityE2, (void **)&e2SetupRspDb.plmn, &e2SetRspMsg->protocolIEs.list.array[idx]->value.choice.GlobalRIC_ID.pLMN_Identity, recvBufLen, 0, 0); - //xer_fprint(stdout, &asn_DEF_PLMN_IdentityE2, &e2SetupRspDb.plmn); + aper_decode(0, &asn_DEF_PLMN_IdentityE2, (void **)&e2SetupRspDb.plmn, \ + &e2SetRspMsg->protocolIEs.list.array[idx]->value.choice.GlobalRIC_ID.pLMN_Identity, recvBufLen, 0, 0); + xer_fprint(stdout, &asn_DEF_PLMN_IdentityE2, &e2SetupRspDb.plmn); break; } default: @@ -560,7 +458,7 @@ S16 procE2SetupRsp(E2AP_PDU_t *e2apMsg) break; } } - RETVALUE(ROK); + return ROK; } /****************************************************************** @@ -597,13 +495,16 @@ S16 procRicSubsReq(E2AP_PDU_t *e2apMsg) { case ProtocolIE_IDE2_id_RICrequestID: { - ricReqDb.ricReqId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID; - ricReqDb.ricInstanceId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID; + ricReqDb.ricReqId = ricSubsReq->protocolIEs.list.array[idx]->\ + value.choice.RICrequestID.ricRequestorID; + ricReqDb.ricInstanceId = ricSubsReq->protocolIEs.list.array[idx]-> \ + value.choice.RICrequestID.ricInstanceID; break; } case ProtocolIE_IDE2_id_RANfunctionID: { - ricReqDb.ranFuncId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RANfunctionID; + ricReqDb.ranFuncId = ricSubsReq->protocolIEs.list.array[idx]-> \ + value.choice.RANfunctionID; break; } case ProtocolIE_IDE2_id_RICsubscriptionDetails: @@ -614,9 +515,9 @@ S16 procRicSubsReq(E2AP_PDU_t *e2apMsg) recvBufLen = sizeof(ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition); aper_decode(0, &asn_DEF_RICeventTriggerDefinition, (void **)&ricReqDb.ricEventTrigger, &(ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition), recvBufLen, 0, 0); - //xer_fprint(stdout, &asn_DEF_RICeventTriggerDefinition, &ricReqDb.ricEventTrigger); + xer_fprint(stdout, &asn_DEF_RICeventTriggerDefinition, &ricReqDb.ricEventTrigger); - actionItem = *ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.list.array; + actionItem =(RICaction_ToBeSetup_ItemIEs_t *) ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.list.array[0]; for(ied = 0; ied < ricSubsReq->protocolIEs.list.array[idx]->value.choice.\ RICsubscriptionDetails.ricAction_ToBeSetup_List.list.count; ied++) @@ -673,7 +574,6 @@ S16 BuildAndSendRicIndication() U8 elementCnt; U8 idx; U8 ieId; - S16 ret; asn_enc_rval_t encRetVal; /* Encoder return value */ DU_LOG("\nE2AP : Building Ric Indication Message\n"); @@ -682,7 +582,7 @@ S16 BuildAndSendRicIndication() if(e2apMsg == NULLP) { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); - RETVALUE(RFAILED); + return RFAILED; } e2apMsg->present = E2AP_PDU_PR_initiatingMessage; @@ -691,7 +591,7 @@ S16 BuildAndSendRicIndication() { DU_LOG("\nE2AP : Memory allocation for E2AP-PDU failed"); DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICindication; e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; @@ -713,7 +613,7 @@ S16 BuildAndSendRicIndication() DU_LOG("\nE2AP : Memory allocation for RICindicationIEs failed"); DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); DU_FREE(e2apMsg, (Size)sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } for(idx=0; idxchoice.initiatingMessage, \ sizeof(InitiatingMessageE2_t)); DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); - RETVALUE(RFAILED); + return RFAILED; } } idx = 0; @@ -772,17 +672,23 @@ S16 BuildAndSendRicIndication() ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \ RICindication_IEs__value_PR_RICindicationHeader; - BuildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \ + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size = 3 * sizeof(U8); + DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf ,\ + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size); + buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \ &ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader); /* TO BE CHANGED: RIC INDICATION DATA */ - /* Foe now filling a dummy octect data, need to tested with PRBs*/ + /* For now filling a dummy octect data, need to tested with PRBs*/ 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; - BuildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \ + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size = 3 * sizeof(U8); + DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf ,\ + ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size); + buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \ &ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage); /* Prints the Msg formed */ @@ -796,7 +702,7 @@ S16 BuildAndSendRicIndication() { DU_LOG("\nE2AP : Could not encode RIC Indication Message (at %s)\n",\ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - RETVALUE(RFAILED); + return RFAILED; } else { @@ -810,9 +716,9 @@ S16 BuildAndSendRicIndication() if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK) { DU_LOG("\nE2AP : Sending RIC Indication Message"); - RETVALUE(RFAILED); + return RFAILED; } - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -846,24 +752,24 @@ S16 SendE2APMsg(Region region, Pool pool) { DU_LOG("\nE2AP : SCTP Send for E2 failed"); SPutMsg(mBuf); - RETVALUE(RFAILED); + return RFAILED; } } else { DU_LOG("\nE2AP : SAddPstMsgMult failed"); SPutMsg(mBuf); - RETVALUE(RFAILED); + return RFAILED; } SPutMsg(mBuf); } else { DU_LOG("\nE2AP : Failed to allocate memory"); - RETVALUE(RFAILED); + return RFAILED; } - RETVALUE(ROK); + return ROK; } /* SendE2APMsg */ /*******************************************************************