1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 #include "common_def.h"
24 #include "du_app_mac_inf.h"
25 #include "du_app_rlc_inf.h"
26 #include "du_e2ap_mgr.h"
27 #include "du_e2ap_msg_hdl.h"
30 #include "du_mgr_main.h"
32 #include "GlobalE2node-gNB-ID.h"
33 #include "ProtocolIE-FieldE2.h"
34 #include "E2setupRequest.h"
35 #include "InitiatingMessageE2.h"
36 #include "SuccessfulOutcomeE2.h"
37 #include "UnsuccessfulOutcomeE2.h"
39 #include "odu_common_codec.h"
40 #include "E2nodeComponentInterfaceF1.h"
41 #include "E2setupRequest.h"
42 #include "du_e2_conversions.h"
43 #include "E2SM-KPM-RANfunction-Description.h"
44 #include "RANfunction-Name.h"
45 #include "RIC-EventTriggerStyle-Item.h"
46 #include "RIC-ReportStyle-Item.h"
47 #include "MeasurementInfo-Action-Item.h"
48 #include "E2SM-KPM-EventTriggerDefinition.h"
49 #include "E2SM-KPM-EventTriggerDefinition-Format1.h"
50 #include "E2SM-KPM-ActionDefinition.h"
51 #include "E2SM-KPM-ActionDefinition-Format1.h"
52 #include "MeasurementInfoItem.h"
53 #include "RANfunctionsIDcause-List.h"
55 /*******************************************************************
57 * @brief Fill E2 Failure Cause
61 * Function : fillE2Cause
63 * Functionality: Fill E2 Failure Cause
65 * @params[in] E2 Cause pointer to be filled in
66 * E2 Cause to be filled from
69 ******************************************************************/
70 void fillE2Cause(CauseE2_t *e2Cause, E2FailureCause failureCause)
72 e2Cause->present = failureCause.causeType;
73 switch(e2Cause->present)
75 case CauseE2_PR_ricRequest:
77 e2Cause->choice.ricRequest = failureCause.cause;
80 case CauseE2_PR_ricService:
82 e2Cause->choice.ricService = failureCause.cause;
85 case CauseE2_PR_e2Node:
87 e2Cause->choice.e2Node = failureCause.cause;
90 case CauseE2_PR_transport:
92 e2Cause->choice.transport = failureCause.cause;
95 case CauseE2_PR_protocol:
97 e2Cause->choice.protocol = failureCause.cause;
100 case CauseE2_PR_misc:
102 e2Cause->choice.misc = failureCause.cause;
105 case CauseE2_PR_NOTHING:
111 /*******************************************************************
113 * @brief Free the ErrorIndication Message
117 * Function : FreeRicIndication
119 * Functionality: Free the ErrorIndication Message
122 * E2AP_PDU is to freed
125 ******************************************************************/
126 void FreeErrorIndication(E2AP_PDU_t *e2apMsg)
129 ErrorIndicationE2_t *errorIndicationMsg= NULLP;
133 if(e2apMsg->choice.initiatingMessage != NULLP)
135 errorIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.ErrorIndicationE2;
136 if(errorIndicationMsg!= NULLP)
138 if(errorIndicationMsg->protocolIEs.list.array != NULLP)
140 for(arrIdx=0; arrIdx<errorIndicationMsg->protocolIEs.list.count; arrIdx++)
142 DU_FREE(errorIndicationMsg->protocolIEs.list.array[arrIdx],sizeof(ErrorIndicationE2_t));
144 DU_FREE(errorIndicationMsg->protocolIEs.list.array,errorIndicationMsg->protocolIEs.list.size);
147 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
149 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
153 /*******************************************************************
155 * @brief Builds and Send the ErrorIndication Message
159 * Function : BuildAndSendErrorIndication
161 * Functionality:Fills the ErrorIndication Message
168 * @return ROK - success
171 ******************************************************************/
173 uint8_t BuildAndSendErrorIndication(int8_t transId, RicRequestId requestId, uint16_t ranFuncId, E2FailureCause failureCause)
175 uint8_t elementCnt =0, arrIdx=0, ret = RFAILED;
176 E2AP_PDU_t *e2apMsg = NULLP;
177 ErrorIndicationE2_t *errorIndicationMsg=NULLP;
178 asn_enc_rval_t encRetVal; /* Encoder return value */
182 DU_LOG("\nINFO --> E2AP : Building Error Indication Message\n");
184 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
187 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed in %s at line %d",__func__, __LINE__);
191 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
192 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
193 if(e2apMsg->choice.initiatingMessage == NULLP)
195 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed in %s at line %d",__func__, __LINE__);
198 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_ErrorIndicationE2;
199 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
200 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ErrorIndicationE2;
202 errorIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.ErrorIndicationE2;
204 /* Element count is 2 for TransactionID/RICrequestID and Cause.
205 * If the RAN function id is present, the count will be increased.*/
212 errorIndicationMsg->protocolIEs.list.count = elementCnt;
213 errorIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(ErrorIndicationE2_IEs_t*);
215 /* Initialize the E2Setup members */
216 DU_ALLOC(errorIndicationMsg->protocolIEs.list.array, errorIndicationMsg->protocolIEs.list.size);
217 if(errorIndicationMsg->protocolIEs.list.array == NULLP)
219 DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements in %s at line %d",__func__, __LINE__);
223 for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++)
225 DU_ALLOC(errorIndicationMsg->protocolIEs.list.array[arrIdx], sizeof(ErrorIndicationE2_IEs_t));
226 if(errorIndicationMsg->protocolIEs.list.array[arrIdx] == NULLP)
228 DU_LOG("\nERROR --> E2AP : Memory allocation failed for array [%d] elements in %s at line %d", arrIdx, __func__, __LINE__);
232 if(arrIdx < elementCnt)
237 if(transId >=0 && transId<=255)
240 errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
241 errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
242 errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_TransactionID;
243 errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId;
248 errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RICrequestID;
249 errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
250 errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_RICrequestID;
251 errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RICrequestID.ricRequestorID = requestId.requestorId;
252 errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RICrequestID.ricInstanceID = requestId.instanceId;
257 /* RAN Function ID */
259 errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionID;
260 errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
261 errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_RANfunctionID;
262 errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionID = ranFuncId;
267 errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_CauseE2;
268 errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_ignore;
269 errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_CauseE2;
270 fillE2Cause(&errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.CauseE2, failureCause);
272 /* Prints the Msg formed */
273 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
274 memset(encBuf, 0, ENC_BUF_MAX_LEN);
276 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
278 if(encRetVal.encoded == ENCODE_FAIL)
280 DU_LOG("\nERROR --> E2AP : Could not encode Error Indication Message (at %s)\n",\
281 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
286 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for Error Indication Message \n");
287 #ifdef DEBUG_ASN_PRINT
288 for(int i=0; i< encBufSize; i++)
290 printf("%x",encBuf[i]);
295 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
297 DU_LOG("\nINFO --> E2AP : Sending Error Indication Message");
303 FreeErrorIndication(e2apMsg);
307 /******************************************************************
309 * @brief Deallocation of memory allocated by aper decoder for e2
310 * Config Update Failure
314 * Function : freeAperDecodingOfE2Node Config UpdateFailure
316 * Functionality: Deallocation of memory allocated by aper decoder
317 * for e2 Config Update Failure
319 * @params[in] E2nodeConfigurationUpdateFailure_t to be deallocated
322 * ****************************************************************/
324 void freeAperDecodingOfE2NodeConfigUpdateFailure(E2nodeConfigurationUpdateFailure_t *e2NodeCfgUpdFail)
330 if(e2NodeCfgUpdFail->protocolIEs.list.array)
332 for(arrIdx=0; arrIdx<e2NodeCfgUpdFail->protocolIEs.list.count; arrIdx++)
334 if(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx])
336 free(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]);
339 free(e2NodeCfgUpdFail->protocolIEs.list.array);
344 /******************************************************************
346 * @brief Processes E2 Node Config Update Failure sent by RIC
350 * Function : procE2NodeConfigUpdateFailure
352 * Functionality: Processes E2 Node Config Update failure sent by RIC
354 * @params[in] E2AP_PDU_t ASN decoded E2AP message
355 * @return ROK - success
358 * ****************************************************************/
360 void procE2NodeConfigUpdateFailure(E2AP_PDU_t *e2apMsg)
362 uint8_t arrIdx =0, transId =0, timerValue=0;
363 E2nodeConfigurationUpdateFailure_t *e2NodeCfgUpdFail=NULL;
365 DU_LOG("\nINFO --> E2AP : E2 Node Config Update failure received");
366 e2NodeCfgUpdFail = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2nodeConfigurationUpdateFailure;
368 for(arrIdx=0; arrIdx<e2NodeCfgUpdFail->protocolIEs.list.count; arrIdx++)
370 switch(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->id)
372 case ProtocolIE_IDE2_id_TransactionID:
374 transId = e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
375 if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
376 (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
378 memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
382 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
386 case ProtocolIE_IDE2_id_TimeToWaitE2:
388 timerValue = convertE2WaitTimerEnumToValue(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2);
389 if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_NODE_CONFIG_UPDATE_TMR)) == FALSE)
391 duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_NODE_CONFIG_UPDATE_TMR, timerValue);
395 DU_LOG("\nERROR --> E2AP : EVENT_E2_NODE_CONFIG_UPDATE_TMR timer is already running");
402 freeAperDecodingOfE2NodeConfigUpdateFailure(e2NodeCfgUpdFail);
405 /*******************************************************************
407 * @brief Builds Global gNodeB Params
411 * Function : BuildGlobalgNBId
413 * Functionality: Building the Plmn and gNB id
415 * @params[in] GlobalE2node_gNB_ID_t *gNbId
416 * @return ROK - success
419 ******************************************************************/
421 uint8_t BuildGlobalgNBId(GlobalE2node_gNB_ID_t *gNbId)
424 uint8_t byteSize = 4;
425 uint8_t gnbId = duCb.gnbId;
428 /* fill Global gNB ID Id */
429 gNbId->global_gNB_ID.plmn_id.size = 3 * sizeof(uint8_t);
430 gNbId->global_gNB_ID.plmn_id.buf = NULLP;
431 DU_ALLOC(gNbId->global_gNB_ID.plmn_id.buf , gNbId->global_gNB_ID.plmn_id.size);
432 if(gNbId->global_gNB_ID.plmn_id.buf == NULLP)
434 DU_LOG("\nERROR --> E2AP: Memory allocation failed for Plmn buffer");
439 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
440 gNbId->global_gNB_ID.plmn_id.buf);
441 gNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID;
442 /* Allocate Buffer size */
443 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = byteSize * sizeof(uint8_t);
444 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf = NULLP;
445 DU_ALLOC(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf, \
446 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size);
447 if(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf == NULLP)
449 DU_LOG("\nERROR --> E2AP: Memory allocation failed for gnb buffer");
454 fillBitString(&gNbId->global_gNB_ID.gnb_id.choice.gnb_ID, unused, byteSize, gnbId);
459 DU_ALLOC( gNbId->gNB_DU_ID, sizeof(GNB_DU_ID_t));
460 if(gNbId->gNB_DU_ID == NULLP)
462 DU_LOG("\nERROR --> E2AP: Memory allocation failed for gNB_DU_ID ");
467 gNbId->gNB_DU_ID->size = sizeof(uint8_t);
468 DU_ALLOC( gNbId->gNB_DU_ID->buf, sizeof(uint8_t));
469 if(gNbId->gNB_DU_ID->buf)
471 gNbId->gNB_DU_ID->buf[0] =duCb.e2apDb.e2NodeId;
475 DU_LOG("\nERROR --> E2AP: Memory allocation failed for gNB_DU_ID buffer");
483 /*******************************************************************
485 * @brief fill the E2 node config information
489 * Function : fillE2NodeConfig
491 * Functionality: fill E2 node config information
494 * Pointer to e2NodeCfg to be filled
495 * E2 Node Component information
496 * Type of configuration
497 * @return ROK - success
500 ******************************************************************/
502 uint8_t fillE2NodeConfig(PTR e2NodeCfg, E2NodeComponent *e2NodeComponentInfo, ConfigType configType)
504 E2nodeComponentInterfaceType_t *interfaceType=NULLP;
505 E2nodeComponentID_t *componentID =NULLP;
506 E2nodeComponentConfiguration_t *configuration=NULLP;
507 E2nodeComponentConfigAddition_Item_t *e2NodeAddItem=NULL;
508 E2nodeComponentConfigUpdate_Item_t *e2NodeUpdateItem =NULL;
509 E2nodeComponentConfigRemoval_Item_t *e2NodeRemovalItem=NULL;
515 e2NodeAddItem = (E2nodeComponentConfigAddition_Item_t*)e2NodeCfg;
516 interfaceType = &e2NodeAddItem->e2nodeComponentInterfaceType;
517 componentID = &e2NodeAddItem->e2nodeComponentID;
518 configuration = &e2NodeAddItem->e2nodeComponentConfiguration;
523 e2NodeUpdateItem = (E2nodeComponentConfigUpdate_Item_t *) e2NodeCfg;
524 interfaceType = &e2NodeUpdateItem->e2nodeComponentInterfaceType;
525 componentID = &e2NodeUpdateItem->e2nodeComponentID;
526 configuration = &e2NodeUpdateItem->e2nodeComponentConfiguration;
531 e2NodeRemovalItem = (E2nodeComponentConfigRemoval_Item_t*) e2NodeCfg;
532 interfaceType = &e2NodeRemovalItem->e2nodeComponentInterfaceType;
533 componentID = &e2NodeRemovalItem->e2nodeComponentID;
538 DU_LOG("\nERROR --> E2AP : Configuration type %d does not supported ", configType);
542 /* E2nodeComponentInterfaceType */
543 *interfaceType = convertInterfaceToE2ComponentInterfaceType(e2NodeComponentInfo->interfaceType);
545 /* We now only support the F1 interface out of these interfaces
546 * (NG,XN,E1,F1,W1,S1,X2), therefore only the F1 component identifier was filled in. */
548 if(*interfaceType == F1)
550 /* E2 Node Component ID */
551 componentID->present = E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1;
552 DU_ALLOC(componentID->choice.e2nodeComponentInterfaceTypeF1,sizeof(E2nodeComponentInterfaceF1_t));
553 if(componentID->choice.e2nodeComponentInterfaceTypeF1 == NULLP)
555 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__);
558 componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size = sizeof(uint8_t);
559 DU_ALLOC(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\
560 componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size);
562 if(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf == NULLP)
564 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__);
567 memcpy(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf, &e2NodeComponentInfo->componentId,\
568 componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size);
571 if(configType == CONFIG_DEL)
573 /* We don't need to fill out the E2 Node Component Request and Response
574 * information in the case of CONFIG_DEL, therefore returning ROK from here. */
578 /* E2 Node Component Request Part */
579 if(e2NodeComponentInfo->componentRequestPart)
581 configuration->e2nodeComponentRequestPart.size = e2NodeComponentInfo->reqBufSize ;
582 DU_ALLOC(configuration->e2nodeComponentRequestPart.buf,\
583 configuration->e2nodeComponentRequestPart.size);
584 if(configuration->e2nodeComponentRequestPart.buf == NULLP)
586 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__);
590 memcpy(configuration->e2nodeComponentRequestPart.buf,\
591 e2NodeComponentInfo->componentRequestPart, configuration->\
592 e2nodeComponentRequestPart.size);
596 DU_LOG("\nERROR --> E2AP: componentRequestPart is null ");
600 /* E2 Node Component Response Part */
601 if(e2NodeComponentInfo->componentResponsePart)
603 configuration->e2nodeComponentResponsePart.size = e2NodeComponentInfo->rspBufSize;
604 DU_ALLOC(configuration->e2nodeComponentResponsePart.buf, configuration->e2nodeComponentResponsePart.size);
605 if(configuration->e2nodeComponentResponsePart.buf == NULLP)
607 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__);
610 memcpy(configuration->e2nodeComponentResponsePart.buf, e2NodeComponentInfo->componentResponsePart, configuration->\
611 e2nodeComponentResponsePart.size);
615 DU_LOG("\nERROR --> E2AP: componentResponsePart is null");
622 /*******************************************************************
624 * @brief Builds E2 node config addition list
628 * Function : BuildE2NodeConfigAddList
630 * Functionality: Building E2 node config addition list
633 * E2nodeComponentConfigAddition_List_t to be filled
635 * Count of E2 node to be added in the list
636 * Received list of E2 node configuration
638 * @return ROK - success
641 ******************************************************************/
643 uint8_t BuildE2NodeConfigAddList(E2nodeComponentConfigAddition_List_t *e2NodeAddList, uint8_t procedureCode, uint16_t count, E2NodeConfigItem *e2NodeList)
647 E2NodeComponent *e2NodeComponentInfo=NULL;
648 E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItemIe=NULL;
649 E2nodeComponentConfigAddition_Item_t *e2NodeAddItem=NULL;
652 /* For ProcedureCodeE2_id_E2setup, the number of E2 node configuration list items is
653 * equal to the number of E2 node configuration entries stored in the database.
654 * For any other procedure, the E2 node configuration list count is equal
655 * to the count of E2 node configuration obtained from the function's caller */
657 if(procedureCode == ProcedureCodeE2_id_E2setup)
658 e2NodeAddList->list.count = duCb.e2apDb.e2NodeComponentList.count;
660 e2NodeAddList->list.count = count;
662 e2NodeAddList->list.size = e2NodeAddList->list.count * sizeof(E2nodeComponentConfigAddition_ItemIEs_t *);
663 DU_ALLOC(e2NodeAddList->list.array, e2NodeAddList->list.size);
664 if(e2NodeAddList->list.array == NULLP)
666 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
670 for(arrIdx = 0; arrIdx< e2NodeAddList->list.count; arrIdx++)
672 DU_ALLOC(e2NodeAddList->list.array[arrIdx], sizeof(E2nodeComponentConfigAddition_ItemIEs_t));
673 if(e2NodeAddList->list.array[arrIdx] == NULLP)
675 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
679 if(procedureCode == ProcedureCodeE2_id_E2setup)
681 /* Getting all of the E2 node configuration's information from DuCb one by one*/
684 CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node);
692 DU_LOG("\nERROR --> E2AP : E2 node component list node is null");
695 e2NodeComponentInfo = (E2NodeComponent*)node->node;
699 /* Getting only those E2 node configuration from DuCb whose interface
700 * and action type is present in the received array */
701 e2NodeComponentInfo = fetchE2NodeComponentInfo(e2NodeList[arrIdx].interface, e2NodeList[arrIdx].actionType, &node);
704 if(!e2NodeComponentInfo)
706 DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__);
710 e2NodeAddItemIe = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[arrIdx];
711 e2NodeAddItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition_Item;
712 e2NodeAddItemIe->criticality = CriticalityE2_reject;
713 e2NodeAddItemIe->value.present = E2nodeComponentConfigAddition_ItemIEs__value_PR_E2nodeComponentConfigAddition_Item;
714 e2NodeAddItem = &e2NodeAddItemIe->value.choice.E2nodeComponentConfigAddition_Item;
715 if(fillE2NodeConfig((PTR)e2NodeAddItem, e2NodeComponentInfo, CONFIG_ADD) != ROK)
717 DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration");
724 /*******************************************************************
726 * @brief Builds E2 node config update list
730 * Function : BuildE2NodeConfigUpdateList
732 * Functionality: Building E2 node config update list
735 * E2nodeComponentConfigUpdate_List_t to be filled
736 * Count of E2 node to be update in the list
737 * Received list of E2 node configuration
739 * @return ROK - success
742 ******************************************************************/
744 uint8_t BuildE2NodeConfigUpdateList(E2nodeComponentConfigUpdate_List_t *e2NodeUpdateList, uint16_t count, E2NodeConfigItem *updateE2Node)
748 E2NodeComponent *e2NodeComponentInfo =NULL;
749 E2nodeComponentConfigUpdate_ItemIEs_t *e2NodeUpdateItemIe =NULL;
750 E2nodeComponentConfigUpdate_Item_t *e2NodeUpdateItem =NULL;
752 e2NodeUpdateList->list.count = count;
753 e2NodeUpdateList->list.size = e2NodeUpdateList->list.count * sizeof(E2nodeComponentConfigUpdate_ItemIEs_t *);
754 DU_ALLOC(e2NodeUpdateList->list.array, e2NodeUpdateList->list.size);
755 if(e2NodeUpdateList->list.array == NULLP)
757 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigUpdateList %d",__LINE__);
761 for(arrIdx = 0; arrIdx< e2NodeUpdateList->list.count; arrIdx++)
763 DU_ALLOC(e2NodeUpdateList->list.array[arrIdx], sizeof(E2nodeComponentConfigUpdate_ItemIEs_t));
764 if(e2NodeUpdateList->list.array[arrIdx] == NULLP)
766 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigUpdateList %d",__LINE__);
770 e2NodeComponentInfo= fetchE2NodeComponentInfo(updateE2Node[arrIdx].interface, updateE2Node[arrIdx].actionType, &node);
771 if(!e2NodeComponentInfo)
773 DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__);
777 e2NodeUpdateItemIe = (E2nodeComponentConfigUpdate_ItemIEs_t *) e2NodeUpdateList->list.array[arrIdx];
778 e2NodeUpdateItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate_Item;
779 e2NodeUpdateItemIe->criticality = CriticalityE2_reject;
780 e2NodeUpdateItemIe->value.present = E2nodeComponentConfigUpdate_ItemIEs__value_PR_E2nodeComponentConfigUpdate_Item;
781 e2NodeUpdateItem = &e2NodeUpdateItemIe->value.choice.E2nodeComponentConfigUpdate_Item;
783 if(fillE2NodeConfig((PTR)e2NodeUpdateItem, e2NodeComponentInfo, CONFIG_MOD) != ROK)
785 DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration");
795 /*******************************************************************
797 * @brief Builds E2 node config remove list
801 * Function :BuildE2NodeConfigRemoveList
803 * Functionality: Building E2 node config remove list
806 * E2nodeComponentConfigRemoval_List_t to be filled
807 * Count of E2 node to be remove in the list
808 * Received list of E2 node configuration
809 * @return ROK - success
812 ******************************************************************/
814 uint8_t BuildE2NodeConfigRemoveList(E2nodeComponentConfigRemoval_List_t *e2NodeRemoveList, uint16_t count, E2NodeConfigItem *updateE2Node)
818 E2NodeComponent *e2NodeComponentInfo=NULL;
819 E2nodeComponentConfigRemoval_ItemIEs_t *e2NodeRemovalItemIe=NULL;
820 E2nodeComponentConfigRemoval_Item_t *e2NodeRemovalItem=NULL;
822 e2NodeRemoveList->list.count = count;
823 e2NodeRemoveList->list.size = e2NodeRemoveList->list.count * sizeof(E2nodeComponentConfigRemoval_ItemIEs_t *);
824 DU_ALLOC(e2NodeRemoveList->list.array, e2NodeRemoveList->list.size);
825 if(e2NodeRemoveList->list.array == NULLP)
827 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigRemoveList %d",__LINE__);
831 for(arrIdx = 0; arrIdx< e2NodeRemoveList->list.count; arrIdx++)
833 DU_ALLOC(e2NodeRemoveList->list.array[arrIdx], sizeof(E2nodeComponentConfigRemoval_ItemIEs_t));
834 if(e2NodeRemoveList->list.array[arrIdx] == NULLP)
836 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigRemoveList %d",__LINE__);
840 e2NodeComponentInfo= fetchE2NodeComponentInfo(updateE2Node[arrIdx].interface, updateE2Node[arrIdx].actionType, &node);
841 if(!e2NodeComponentInfo)
843 DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__);
847 e2NodeRemovalItemIe = (E2nodeComponentConfigRemoval_ItemIEs_t *) e2NodeRemoveList->list.array[arrIdx];
848 e2NodeRemovalItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval_Item;
849 e2NodeRemovalItemIe->criticality = CriticalityE2_reject;
850 e2NodeRemovalItemIe->value.present = E2nodeComponentConfigRemoval_ItemIEs__value_PR_E2nodeComponentConfigRemoval_Item;
851 e2NodeRemovalItem = &e2NodeRemovalItemIe->value.choice.E2nodeComponentConfigRemoval_Item;
853 if(fillE2NodeConfig((PTR)e2NodeRemovalItem, e2NodeComponentInfo, CONFIG_DEL) != ROK)
855 DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration");
862 /*******************************************************************
864 * @brief deallocation of E2SM_KPM_RANfunction_Description_t
868 * Function : freeE2smKpmRanFunctionDefinition
870 * Functionality: deallocation of E2SM_KPM_RANfunction_Description_t
872 * @params[in] E2SM_KPM_RANfunction_Description_t *ranFunctionDefinition
875 ******************************************************************/
877 void freeE2smKpmRanFunctionDefinition(E2SM_KPM_RANfunction_Description_t *ranFunctionDefinition)
879 MeasurementInfo_Action_Item_t *measInfoList;
880 uint8_t eventTriggerIdx, reportStyleIdx, measInfoIdx;
881 RANfunction_Name_t *ranFuncName;
882 struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle;
883 struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *eventTriggerStyle;
884 if(ranFunctionDefinition)
886 ranFuncName = &ranFunctionDefinition->ranFunction_Name;
887 /* Free RAN function Name */
888 DU_FREE(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size);
889 DU_FREE(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size);
890 DU_FREE(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size);
892 /* Sequence of Event Trigger styles */
893 eventTriggerStyle = ranFunctionDefinition->ric_EventTriggerStyle_List;
894 if(eventTriggerStyle)
896 if(eventTriggerStyle->list.array)
898 for(eventTriggerIdx =0;eventTriggerIdx<eventTriggerStyle->list.count; eventTriggerIdx++)
900 if(eventTriggerStyle->list.array[eventTriggerIdx])
902 DU_FREE(eventTriggerStyle->list.array[eventTriggerIdx]->ric_EventTriggerStyle_Name.buf,\
903 eventTriggerStyle->list.array[eventTriggerIdx]->ric_EventTriggerStyle_Name.size);
904 DU_FREE(eventTriggerStyle->list.array[eventTriggerIdx], sizeof(RIC_EventTriggerStyle_Item_t ));
907 DU_FREE(eventTriggerStyle->list.array, eventTriggerStyle->list.size)
909 DU_FREE(eventTriggerStyle, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List));
912 /* Sequence of Report styles */
913 ricReportStyle = ranFunctionDefinition->ric_ReportStyle_List;
916 if(ricReportStyle->list.array)
918 for(reportStyleIdx =0;reportStyleIdx<ricReportStyle->list.count; reportStyleIdx++)
920 if(ricReportStyle->list.array[reportStyleIdx])
922 if(ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.buf)
924 DU_FREE(ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.buf,\
925 ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.size);
927 if(ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.array)
929 for(measInfoIdx=0; measInfoIdx<ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.count; \
932 measInfoList = ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.array[measInfoIdx];
935 DU_FREE(measInfoList->measID, sizeof(long));
936 DU_FREE(measInfoList->measName.buf, measInfoList->measName.size);
937 DU_FREE(measInfoList,sizeof(MeasurementInfo_Action_Item_t));
940 DU_FREE(measInfoList,ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.size);
942 DU_FREE(ricReportStyle->list.array[reportStyleIdx], sizeof(RIC_ReportStyle_Item_t));
945 DU_FREE(ricReportStyle->list.array, ricReportStyle->list.size);
947 DU_FREE(ricReportStyle, sizeof(struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List));
949 DU_FREE(ranFunctionDefinition, sizeof(E2SM_KPM_RANfunction_Description_t));
953 /*******************************************************************
955 * @brief fill the e2sm ric report style
959 * Function : fillRicReportStyle
961 * Functionality: fill the report style
963 * @params[in] RanFunction *ranFuncDb, struct
964 * E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle
965 * @return ROK - success
968 ******************************************************************/
969 uint8_t fillRicReportStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle)
971 uint8_t styleIdx, measInfoIdx;
972 MeasurementInfo_Action_List_t *measInfo;
975 ricReportStyle->list.count = ranFuncDb->numOfReportStyleSupported;
976 ricReportStyle->list.size = ricReportStyle->list.count * sizeof(RIC_ReportStyle_Item_t*);
977 DU_ALLOC(ricReportStyle->list.array, ricReportStyle->list.size);
978 if(!ricReportStyle->list.array)
980 DU_LOG("\nERROR --> E2AP: Memory allocation failed for ranFuncDefinition %d",__LINE__);
984 for(styleIdx =0;styleIdx<ricReportStyle->list.count; styleIdx++)
986 DU_ALLOC(ricReportStyle->list.array[styleIdx], sizeof(RIC_ReportStyle_Item_t));
987 if(!ricReportStyle->list.array[styleIdx])
989 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
993 /* RIC Report Style Type */
994 ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Type = ranFuncDb->reportStyleList[styleIdx].reportStyle.styleType;
996 /* RIC Report Style Format Type */
997 ricReportStyle->list.array[styleIdx]->ric_ActionFormat_Type = ranFuncDb->reportStyleList[styleIdx].reportStyle.formatType;
999 /* RIC Report Style Name */
1000 ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size = strlen(ranFuncDb->reportStyleList[styleIdx].reportStyle.name);
1001 DU_ALLOC(ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf,\
1002 ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size);
1003 if(!ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf)
1005 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1008 memcpy(ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf, ranFuncDb->reportStyleList[styleIdx].reportStyle.name,\
1009 ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size);
1011 /* RIC Indication Header Format Type*/
1012 ricReportStyle->list.array[styleIdx]->ric_IndicationHeaderFormat_Type = ranFuncDb->ricIndicationHeaderFormat;
1014 /* RIC Indication Message Format Type*/
1015 ricReportStyle->list.array[styleIdx]->ric_IndicationMessageFormat_Type = ranFuncDb->ricIndicationMessageFormat;
1017 /* Measurement Info Action List */
1018 CmLListCp measInfoList =ranFuncDb->reportStyleList[styleIdx].measurementInfoList;
1019 if(!measInfoList.count)
1024 CM_LLIST_FIRST_NODE(&ranFuncDb->reportStyleList[styleIdx].measurementInfoList, node);
1025 measInfo = &ricReportStyle->list.array[styleIdx]->measInfo_Action_List;
1027 measInfo->list.count = measInfoList.count;
1028 measInfo->list.size = measInfoList.count*sizeof(MeasurementInfo_Action_Item_t*);
1029 DU_ALLOC(measInfo->list.array, measInfo->list.size);
1030 if(!measInfo->list.array)
1032 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1036 for(measInfoIdx=0; measInfoIdx<measInfo->list.count; measInfoIdx++)
1040 DU_LOG("\nERROR --> E2AP: Measurement info node is null");
1044 DU_ALLOC(measInfo->list.array[measInfoIdx],sizeof(MeasurementInfo_Action_Item_t));
1045 if(!measInfo->list.array[measInfoIdx])
1047 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1050 MeasurementInfoForAction *measInfoForAction= (MeasurementInfoForAction*)node->node;
1051 DU_ALLOC(measInfo->list.array[measInfoIdx]->measID, sizeof(long));
1052 if(!measInfo->list.array[measInfoIdx]->measID)
1054 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1058 memcpy(measInfo->list.array[measInfoIdx]->measID, &measInfoForAction->measurementTypeId,sizeof(long));
1059 measInfo->list.array[measInfoIdx]->measName.size= strlen(measInfoForAction->measurementTypeName);
1060 DU_ALLOC(measInfo->list.array[measInfoIdx]->measName.buf, measInfo->list.array[measInfoIdx]->measName.size);
1061 if(!measInfo->list.array[measInfoIdx]->measName.size)
1063 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1067 memcpy(measInfo->list.array[measInfoIdx]->measName.buf, \
1068 measInfoForAction->measurementTypeName,\
1069 measInfo->list.array[measInfoIdx]->measName.size);
1076 /*******************************************************************
1078 * @brief fill the ric event trigger style
1082 * Function : fillRicEventTriggerStyle
1084 * Functionality: fill the ric event trigger style
1087 * @return ROK - success
1090 ******************************************************************/
1091 uint8_t fillRicEventTriggerStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *ricEventTriggerStyle)
1095 ricEventTriggerStyle->list.count = ranFuncDb->numOfEventTriggerStyleSupported;
1096 ricEventTriggerStyle->list.size = ricEventTriggerStyle->list.count* sizeof(RIC_EventTriggerStyle_Item_t *);
1097 DU_ALLOC(ricEventTriggerStyle->list.array, ricEventTriggerStyle->list.size);
1098 if(!ricEventTriggerStyle->list.array)
1100 DU_LOG("\nERROR --> E2AP: Memory allocation failed for ric_EventTriggerStyle_List %d",__LINE__);
1104 for(styleIdx =0;styleIdx<ricEventTriggerStyle->list.count; styleIdx++)
1106 DU_ALLOC(ricEventTriggerStyle->list.array[styleIdx], sizeof(RIC_EventTriggerStyle_Item_t ));
1107 if(!ricEventTriggerStyle->list.array[styleIdx])
1109 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1112 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Type = ranFuncDb->eventTriggerStyleList[styleIdx].styleType;
1114 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerFormat_Type = ranFuncDb->eventTriggerStyleList[styleIdx].formatType;
1116 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size = strlen(ranFuncDb->eventTriggerStyleList[styleIdx].name);
1117 DU_ALLOC(ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf,\
1118 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size);
1119 if(!ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf)
1121 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1124 memcpy(ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf,ranFuncDb->eventTriggerStyleList[styleIdx].name,\
1125 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size);
1131 /*******************************************************************
1133 * @brief Builds Ran function item
1137 * Function : BuildRanFunctionItem
1139 * Functionality: Building RAN function item
1142 * RAN function item that has to be filled
1143 * Stored RAN Function information
1144 * @return ROK - success
1147 ******************************************************************/
1149 uint8_t BuildRanFunctionItem(RANfunction_Item_t *ranFuncItem, RanFunction *ranFuncDb)
1151 uint8_t ret =RFAILED;
1152 RANfunctionDefinition_t *ranFunctionDefinition;
1153 RANfunction_Name_t *ranFuncName;
1154 asn_enc_rval_t encRetVal;
1155 E2SM_KPM_RANfunction_Description_t *ranFuncDefinition;
1159 /* RAN function Id*/
1160 ranFuncItem->ranFunctionID = ranFuncDb->id;
1162 /* RAN Function Revision*/
1163 ranFuncItem->ranFunctionRevision = ranFuncDb->revisionCounter;
1165 /* RAN function OID*/
1166 ranFuncItem->ranFunctionOID.size = strlen(ranFuncDb->name.serviceModelOID);
1167 DU_ALLOC(ranFuncItem->ranFunctionOID.buf, ranFuncItem->ranFunctionOID.size);
1168 if(!ranFuncItem->ranFunctionOID.buf)
1170 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1173 memcpy(ranFuncItem->ranFunctionOID.buf, ranFuncDb->name.serviceModelOID, ranFuncItem->ranFunctionOID.size);
1175 /* RAN function Definition */
1176 DU_ALLOC(ranFuncDefinition, sizeof(E2SM_KPM_RANfunction_Description_t));
1177 if(!ranFuncDefinition)
1179 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1183 /* RAN function Name */
1184 ranFuncName = &ranFuncDefinition->ranFunction_Name;
1186 /* RAN function ShortName */
1187 ranFuncName->ranFunction_ShortName.size = strlen(ranFuncDb->name.shortName);
1188 DU_ALLOC(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size);
1189 if(!ranFuncName->ranFunction_ShortName.buf)
1191 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1194 memcpy(ranFuncName->ranFunction_ShortName.buf, ranFuncDb->name.shortName, strlen(ranFuncDb->name.shortName));
1196 /* RAN function E2SM_OID */
1197 ranFuncName->ranFunction_E2SM_OID.size = strlen(ranFuncDb->name.serviceModelOID);
1198 DU_ALLOC(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size);
1199 if(!ranFuncName->ranFunction_E2SM_OID.buf)
1201 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1204 memcpy(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncDb->name.serviceModelOID, ranFuncName->ranFunction_E2SM_OID.size);
1206 /* RAN Function Name Description */
1207 ranFuncName->ranFunction_Description.size = strlen(ranFuncDb->name.description);
1208 DU_ALLOC(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size);
1209 if(!ranFuncName->ranFunction_Description.buf)
1211 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1214 memcpy(ranFuncName->ranFunction_Description.buf, ranFuncDb->name.description, ranFuncName->ranFunction_Description.size);
1216 /* RIC Event Trigger Style List */
1217 DU_ALLOC(ranFuncDefinition->ric_EventTriggerStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List));
1218 if(!ranFuncDefinition->ric_EventTriggerStyle_List)
1220 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1224 if(fillRicEventTriggerStyle(ranFuncDb, ranFuncDefinition->ric_EventTriggerStyle_List)!=ROK)
1226 DU_LOG("\nERROR --> E2AP: failed to fill ric event trigger style");
1230 /* RIC Report Style List */
1231 DU_ALLOC(ranFuncDefinition->ric_ReportStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List));
1232 if(!ranFuncDefinition->ric_ReportStyle_List)
1234 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
1237 if(fillRicReportStyle(ranFuncDb, ranFuncDefinition->ric_ReportStyle_List) != ROK)
1239 DU_LOG("\nERROR --> E2AP: failed to fill ric report style");
1243 /* Encode the F1SetupRequest type as APER */
1244 xer_fprint(stdout, &asn_DEF_E2SM_KPM_RANfunction_Description, ranFuncDefinition);
1246 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1248 encRetVal = aper_encode(&asn_DEF_E2SM_KPM_RANfunction_Description, 0, ranFuncDefinition, PrepFinalEncBuf, encBuf);
1250 /* Encode results */
1251 if(encRetVal.encoded == ENCODE_FAIL)
1253 DU_LOG("\nERROR --> F1AP : Could not encode RAN function definition (at %s)\n",\
1254 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1259 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RAN function definition \n");
1260 for(uint8_t measIeIdx=0; measIeIdx< encBufSize; measIeIdx++)
1262 printf("%x",encBuf[measIeIdx]);
1264 ranFunctionDefinition = &ranFuncItem->ranFunctionDefinition;
1265 ranFunctionDefinition->size = encBufSize;
1266 DU_ALLOC(ranFunctionDefinition->buf, encBufSize);
1267 if(ranFunctionDefinition->buf == NULLP)
1269 DU_LOG("\nERROR --> F1AP : Memory allocation failed for RAN function definition buffer");
1272 memcpy(ranFunctionDefinition->buf, &encBuf, encBufSize);
1277 freeE2smKpmRanFunctionDefinition(ranFuncDefinition);
1281 /*******************************************************************
1283 * @brief Builds Ran function add list based on the procedure code
1287 * Function : BuildRanFunctionAddList
1289 * Functionality: Building RAN addition addition list
1290 * In case of ProcedureCodeE2_id_E2setup we add all the RAN Function list
1291 * which is present in E2 database.
1292 * In the case of other procedures, we just fill the RAN functions whose ID
1293 * is contained in recvList
1298 * Count of ran functions to be added in the list
1299 * Received list of RAN functions
1301 * @return ROK - success
1304 ******************************************************************/
1306 uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList, uint8_t procedureCode, uint8_t count, RanFuncInfo *recvList)
1309 RanFunction *ranFuncDb;
1311 RANfunction_ItemIEs_t *ranFuncItemIe;
1313 /* For ProcedureCodeE2_id_E2setup, the number of RAN function list items is
1314 * equal to the number of ran function entries stored in the database.
1315 * For any other procedure, the RAN function list count is equal
1316 * to the count of ran functions obtained from the function's caller */
1318 if(procedureCode == ProcedureCodeE2_id_E2setup)
1319 ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction;
1321 ranFunctionsList->list.count = count;
1323 ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*);
1324 DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size);
1325 if(ranFunctionsList->list.array == NULLP)
1327 DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
1331 for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++)
1333 DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
1334 if(ranFunctionsList->list.array[ranFuncIdx] == NULLP)
1336 DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
1339 if(procedureCode == ProcedureCodeE2_id_E2setup)
1341 /* Getting all of the RAN function's information from DuCb one by one*/
1342 ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx];
1346 /* Getting only the RAN function information from DuCb whose Id is
1347 * present in the received array */
1348 id =recvList[ranFuncIdx].id;
1349 ranFuncDb = &duCb.e2apDb.ranFunction[id-1];
1351 ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx];
1352 ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item;
1353 ranFuncItemIe->criticality = CriticalityE2_ignore;
1354 ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
1355 BuildRanFunctionItem(&ranFuncItemIe->value.choice.RANfunction_Item, ranFuncDb);
1360 /*******************************************************************
1362 * @brief De Allocate E2 Setup Request Message
1366 * Function : FreeE2SetupReq
1368 * Functionality: De-Allocating E2 Setup request Message
1370 * @params[in] E2AP_PDU_t *e2apMsg
1374 * ****************************************************************/
1376 void FreeE2SetupReq(E2AP_PDU_t *e2apMsg)
1379 uint8_t e2NodeAddListIdx =0, ranFuncAddListIdx;
1380 E2setupRequest_t *e2SetupReq;
1381 E2nodeComponentConfigAddition_List_t *e2NodeAddList;
1382 E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem;
1383 RANfunctions_List_t *ranFunctionsList;
1384 RANfunction_ItemIEs_t *ranFuncItemIe;
1385 RANfunction_Item_t *ranFunItem;
1387 /* De-allocating Memory */
1388 if(e2apMsg != NULLP)
1390 if(e2apMsg->choice.initiatingMessage != NULLP)
1392 e2SetupReq = &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest;
1393 if(e2SetupReq->protocolIEs.list.array != NULLP)
1395 for(arrIdx = 0; arrIdx < e2SetupReq->protocolIEs.list.count; arrIdx++)
1397 if(e2SetupReq->protocolIEs.list.array[arrIdx] != NULLP)
1399 switch(e2SetupReq->protocolIEs.list.array[arrIdx]->id)
1401 case ProtocolIE_IDE2_id_TransactionID:
1403 case ProtocolIE_IDE2_id_GlobalE2node_ID:
1405 if(e2SetupReq->protocolIEs.list.array[arrIdx]->\
1406 value.choice.GlobalE2node_ID.choice.gNB != NULLP)
1408 GlobalE2node_gNB_ID_t *gNbId = NULLP;
1409 gNbId = e2SetupReq->protocolIEs.list.array[arrIdx]->\
1410 value.choice.GlobalE2node_ID.choice.gNB;
1411 if(gNbId->global_gNB_ID.plmn_id.buf != NULLP)
1413 DU_FREE(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf,\
1414 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size);
1415 DU_FREE(gNbId->global_gNB_ID.plmn_id.buf,\
1416 gNbId->global_gNB_ID.plmn_id.size);
1419 if(gNbId->gNB_DU_ID != NULLP)
1421 DU_FREE( gNbId->gNB_DU_ID->buf, gNbId->gNB_DU_ID->size);
1422 DU_FREE(gNbId->gNB_DU_ID, sizeof(GNB_DU_ID_t));
1424 DU_FREE(e2SetupReq->protocolIEs.list.array[arrIdx]->value.\
1425 choice.GlobalE2node_ID.choice.gNB, sizeof(GlobalE2node_gNB_ID_t));
1429 case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition:
1431 e2NodeAddList = &e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List;
1432 if(e2NodeAddList->list.array)
1434 for(e2NodeAddListIdx = 0; e2NodeAddListIdx< e2NodeAddList->list.count; e2NodeAddListIdx++)
1436 e2NodeAddItem = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[e2NodeAddListIdx];
1438 /* Free E2 Node Component Request Part */
1439 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\
1440 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentRequestPart.size);
1442 /* Free E2 Node Component Response Part */
1443 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.\
1444 e2nodeComponentResponsePart.buf, \
1445 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentResponsePart.size);
1447 /* Free E2 Node Component ID */
1448 if(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1)
1450 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
1451 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\
1452 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
1453 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size);
1454 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1,\
1455 sizeof(E2nodeComponentInterfaceF1_t));
1457 DU_FREE(e2NodeAddList->list.array[e2NodeAddListIdx], sizeof(E2nodeComponentConfigAddition_ItemIEs_t));
1459 DU_FREE(e2NodeAddList->list.array, e2NodeAddList->list.size);
1463 case ProtocolIE_IDE2_id_RANfunctionsAdded:
1465 ranFunctionsList = &(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List);
1466 if(ranFunctionsList->list.array)
1468 for(ranFuncAddListIdx= 0; ranFuncAddListIdx< ranFunctionsList->list.count; ranFuncAddListIdx++)
1470 if(ranFunctionsList->list.array[ranFuncAddListIdx])
1472 ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncAddListIdx];
1473 ranFunItem = &ranFuncItemIe->value.choice.RANfunction_Item;
1474 DU_FREE(ranFunItem->ranFunctionOID.buf, ranFunItem->ranFunctionOID.size);
1475 DU_FREE(ranFunItem->ranFunctionDefinition.buf, ranFunItem->ranFunctionDefinition.size);
1476 DU_FREE(ranFunctionsList->list.array[ranFuncAddListIdx], sizeof(RANfunction_ItemIEs_t));
1479 DU_FREE(ranFunctionsList->list.array, ranFunctionsList->list.size);
1485 DU_LOG("\nERROR --> E2AP: Invalid event at e2SetupRequet %ld ",\
1486 (e2SetupReq->protocolIEs.list.array[arrIdx]->id));
1489 DU_FREE(e2SetupReq->protocolIEs.list.array[arrIdx], sizeof(E2setupRequestIEs_t));
1492 DU_FREE(e2SetupReq->protocolIEs.list.array, e2SetupReq->protocolIEs.list.size);
1494 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1496 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
1500 /*******************************************************************
1502 * @brief Builds and Send the E2SetupRequest
1506 * Function : BuildAndSendE2SetupReq
1508 * Functionality:Fills the E2SetupRequest
1510 * @return ROK - success
1513 ******************************************************************/
1515 uint8_t BuildAndSendE2SetupReq()
1517 uint8_t arrIdx = 0, elementCnt=0;
1518 uint8_t transId = 0, ret = ROK;
1519 bool memAllocFailed;
1520 E2AP_PDU_t *e2apMsg = NULLP;
1521 E2setupRequest_t *e2SetupReq = NULLP;
1522 asn_enc_rval_t encRetVal; /* Encoder return value */
1524 DU_LOG("\nINFO --> E2AP : Building E2 Setup Request\n");
1527 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
1528 if(e2apMsg == NULLP)
1530 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1533 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
1534 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1535 if(e2apMsg->choice.initiatingMessage == NULLP)
1537 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1540 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
1541 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2setup;
1542 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_E2setupRequest;
1543 e2SetupReq = &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest;
1546 e2SetupReq->protocolIEs.list.count = elementCnt;
1547 e2SetupReq->protocolIEs.list.size = elementCnt * sizeof(E2setupRequestIEs_t*);
1549 /* Initialize the E2Setup members */
1550 DU_ALLOC(e2SetupReq->protocolIEs.list.array, \
1551 e2SetupReq->protocolIEs.list.size);
1552 if(e2SetupReq->protocolIEs.list.array == NULLP)
1554 DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements");
1557 for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++)
1559 DU_ALLOC(e2SetupReq->protocolIEs.list.array[arrIdx],\
1560 sizeof(E2setupRequestIEs_t));
1561 if(e2SetupReq->protocolIEs.list.array[arrIdx] == NULLP)
1563 memAllocFailed = true;
1564 DU_LOG("\nERROR --> E2AP : Memory allocation failed for arrayarrIdx [%d]", arrIdx);
1568 if(memAllocFailed == true)
1574 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
1575 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
1576 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_TransactionID;
1577 transId = assignTransactionId();
1578 e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId;
1581 /* GlobalE2node_gNB_ID */
1582 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_GlobalE2node_ID;
1583 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
1584 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_GlobalE2node_ID;
1585 e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.GlobalE2node_ID.present = GlobalE2node_ID_PR_gNB;
1587 DU_ALLOC(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.\
1588 GlobalE2node_ID.choice.gNB, sizeof(GlobalE2node_gNB_ID_t));
1589 if(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.\
1590 GlobalE2node_ID.choice.gNB == NULLP)
1592 DU_LOG("\nERROR --> E2AP : Memory allocation failed for gNbId");
1597 ret = BuildGlobalgNBId(e2SetupReq->protocolIEs.list.array[arrIdx]->value.\
1598 choice.GlobalE2node_ID.choice.gNB);
1601 DU_LOG("\nERROR --> E2AP : Failed to build Global Gnb Id");
1606 /* RAN Functions Added List */
1608 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAdded;
1609 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
1610 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_RANfunctions_List;
1611 if(BuildRanFunctionAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List), ProcedureCodeE2_id_E2setup, 0, NULL)!=ROK)
1613 DU_LOG("\nERROR --> E2AP : Failed to create RAN Function");
1617 /* E2 Node Component Configuration Addition List */
1619 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition;
1620 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
1621 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_E2nodeComponentConfigAddition_List;
1622 if(BuildE2NodeConfigAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List), ProcedureCodeE2_id_E2setup, 0, NULL)!=ROK)
1624 DU_LOG("\nERROR --> E2AP : Failed to create E2 Node config list");
1630 /* Prints the Msg formed */
1631 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
1633 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1635 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
1637 if(encRetVal.encoded == ENCODE_FAIL)
1639 DU_LOG("\nERROR --> E2AP : Could not encode E2SetupRequest structure (at %s)\n",\
1640 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1645 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SetupRequest\n");
1646 #ifdef DEBUG_ASN_PRINT
1647 for(int i=0; i< encBufSize; i++)
1649 printf("%x",encBuf[i]);
1653 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
1655 DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed");
1660 duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
1661 duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
1663 FreeE2SetupReq(e2apMsg);
1665 }/* End of BuildAndSendE2SetupReq */
1667 /*******************************************************************
1669 * @brief Builds RIC Action Admitted List
1673 * Function : BuildRicActionAdmitList
1675 * Functionality: Builds RIC Action Admitted List
1677 * @params[in] Pointer to RIC Action Admitted List to be filled
1678 * Subscription Response information
1679 * @return ROK - success
1682 * ****************************************************************/
1683 uint8_t BuildRicActionAdmitList(RICaction_Admitted_List_t *admitList, PendingSubsRspInfo *subsRspInfo)
1686 uint8_t elementCnt = 0;
1687 RICaction_Admitted_ItemIEs_t *admitItem = NULLP;
1689 elementCnt = subsRspInfo->numOfAcceptedActions;
1691 admitList->list.count = elementCnt;
1692 admitList->list.size = elementCnt * sizeof(RICaction_Admitted_ItemIEs_t *);
1694 DU_ALLOC(admitList->list.array, admitList->list.size);
1695 if(admitList->list.array == NULLP)
1697 DU_LOG("\nERROR --> E2AP : Memory allocation failed at [%s] : line [%d]", __func__, __LINE__);
1701 for(idx=0; idx<elementCnt; idx++)
1703 DU_ALLOC(admitList->list.array[idx], sizeof(RICaction_Admitted_ItemIEs_t));
1704 if(admitList->list.array[idx] == NULLP)
1706 DU_LOG("\nERROR --> E2AP : Memory allocation failed at [%s] : line [%d]", __func__, __LINE__);
1710 admitItem = (RICaction_Admitted_ItemIEs_t *)admitList->list.array[idx];
1711 admitItem->id = ProtocolIE_IDE2_id_RICaction_Admitted_Item;
1712 admitItem->criticality = CriticalityE2_reject;
1713 admitItem->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item;
1714 admitItem->value.choice.RICaction_Admitted_Item.ricActionID = subsRspInfo->acceptedActionList[idx];
1719 /*******************************************************************
1721 * @brief Builds RIC Action Not Admitted List
1725 * Function : BuildRicActionNotAdmitList
1727 * Functionality: Builds RIC Action Not Admitted List
1729 * @params[in] Pointer to RIC Action Not Admitted List to be filled
1730 * Subscription Response information
1731 * @return ROK - success
1734 * ****************************************************************/
1735 uint8_t BuildRicActionNotAdmitList(RICaction_NotAdmitted_List_t *notAdmitList, PendingSubsRspInfo *subsRspInfo)
1738 uint8_t elementCnt = 0;
1739 RICaction_NotAdmitted_ItemIEs_t *notAdmitItem = NULLP;
1741 elementCnt = subsRspInfo->numOfRejectedActions;
1743 notAdmitList->list.count = elementCnt;
1744 notAdmitList->list.size = elementCnt * sizeof(RICaction_NotAdmitted_ItemIEs_t *);
1746 DU_ALLOC(notAdmitList->list.array, notAdmitList->list.size);
1747 if(notAdmitList->list.array == NULLP)
1749 DU_LOG("\nERROR --> E2AP : Memory allocation failed at [%s] : line [%d]", __func__, __LINE__);
1753 for(idx=0; idx<elementCnt; idx++)
1755 DU_ALLOC(notAdmitList->list.array[idx], sizeof(RICaction_NotAdmitted_ItemIEs_t));
1756 if(notAdmitList->list.array[idx] == NULLP)
1758 DU_LOG("\nERROR --> E2AP : Memory allocation failed at [%s] : line [%d]", __func__, __LINE__);
1762 notAdmitItem = (RICaction_NotAdmitted_ItemIEs_t *)notAdmitList->list.array[idx];
1763 notAdmitItem->id = ProtocolIE_IDE2_id_RICaction_NotAdmitted_Item;
1764 notAdmitItem->criticality = CriticalityE2_reject;
1765 notAdmitItem->value.present = RICaction_NotAdmitted_ItemIEs__value_PR_RICaction_NotAdmitted_Item;
1766 notAdmitItem->value.choice.RICaction_NotAdmitted_Item.ricActionID = \
1767 subsRspInfo->rejectedActionList[idx].id;
1768 fillE2Cause(¬AdmitItem->value.choice.RICaction_NotAdmitted_Item.cause, \
1769 subsRspInfo->rejectedActionList[idx].failureCause);
1774 /*******************************************************************
1776 * @breif Deallocation of BuildAndSendRicSubscriptionRsp memory
1780 * Function : FreeRicSubscriptionRsp
1782 * Functionality:Free the RicSubscriptionRsp
1784 * @param[in] E2AP_PDU_t *e2apRicMsg
1788 ******************************************************************/
1789 void FreeRicSubscriptionRsp(E2AP_PDU_t *e2apRicMsg)
1791 RICsubscriptionResponse_t *ricSubscriptionRsp= NULLP;
1794 RICaction_Admitted_List_t *admitList = NULLP;
1795 RICaction_NotAdmitted_List_t *notAdmitList = NULLP;
1797 if(e2apRicMsg != NULLP)
1799 if(e2apRicMsg->choice.successfulOutcome != NULLP)
1801 ricSubscriptionRsp = &e2apRicMsg->choice.successfulOutcome->value.choice.RICsubscriptionResponse;
1802 if(ricSubscriptionRsp)
1804 if(ricSubscriptionRsp->protocolIEs.list.array != NULLP)
1806 for(idx=0; idx<ricSubscriptionRsp->protocolIEs.list.count; idx++)
1808 if(ricSubscriptionRsp->protocolIEs.list.array[idx] != NULLP)
1810 switch(ricSubscriptionRsp->protocolIEs.list.array[idx]->id)
1812 case ProtocolIE_IDE2_id_RICactions_Admitted:
1814 admitList = &ricSubscriptionRsp->protocolIEs.list.\
1815 array[idx]->value.choice.RICaction_Admitted_List;
1816 if(admitList->list.array != NULLP)
1818 for(listIdx=0 ; listIdx < admitList->list.count; listIdx++)
1820 DU_FREE(admitList->list.array[listIdx], sizeof(RICaction_Admitted_ItemIEs_t));
1822 DU_FREE(admitList->list.array, admitList->list.size);
1826 case ProtocolIE_IDE2_id_RICactions_NotAdmitted:
1828 notAdmitList = &ricSubscriptionRsp->protocolIEs.list.\
1829 array[idx]->value.choice.RICaction_NotAdmitted_List;
1830 if(notAdmitList->list.array != NULLP)
1832 for(listIdx=0 ; listIdx < notAdmitList->list.count; listIdx++)
1834 DU_FREE(notAdmitList->list.array[listIdx], sizeof(RICaction_NotAdmitted_ItemIEs_t));
1836 DU_FREE(notAdmitList->list.array, notAdmitList->list.size);
1843 DU_FREE(ricSubscriptionRsp->protocolIEs.list.array[idx], sizeof(RICsubscriptionResponse_IEs_t));
1846 DU_FREE(ricSubscriptionRsp->protocolIEs.list.array, ricSubscriptionRsp->protocolIEs.list.size);
1849 DU_FREE(e2apRicMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
1851 DU_FREE(e2apRicMsg, sizeof(E2AP_PDU_t));
1855 /*******************************************************************
1857 * @brief Fill RIC Subscription Response IEs
1861 * Function : fillRicSubscriptionRsp
1863 * functionality: Fill RIC Subscription Response IEs
1865 * @param Pointer to RIC subscription response
1866 * Subscription response information
1867 * @return ROK - success
1870 ******************************************************************/
1871 uint8_t fillRicSubscriptionRsp(RICsubscriptionResponse_t *ricSubscriptionRsp, PendingSubsRspInfo *subsRspInfo)
1874 uint8_t elementCnt = 0;
1875 RICsubscriptionResponse_IEs_t *subsRspIe = NULLP;
1878 if(subsRspInfo->numOfRejectedActions)
1881 ricSubscriptionRsp->protocolIEs.list.count = elementCnt;
1882 ricSubscriptionRsp->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionResponse_IEs_t);
1883 DU_ALLOC(ricSubscriptionRsp->protocolIEs.list.array, ricSubscriptionRsp->protocolIEs.list.size);
1884 if(ricSubscriptionRsp->protocolIEs.list.array == NULLP)
1886 DU_LOG("\nERROR --> E2AP : Memory allocation failed at %s : line %d", __func__, __LINE__);
1890 for(ieIdx=0; ieIdx<ricSubscriptionRsp->protocolIEs.list.count; ieIdx++)
1892 DU_ALLOC(ricSubscriptionRsp->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionResponse_IEs_t));
1893 if(ricSubscriptionRsp->protocolIEs.list.array[ieIdx] == NULLP)
1895 DU_LOG("\nERROR --> E2AP : Memory allocation failed at [%s] : line [%d] : ieIdx [%d]", __func__, __LINE__,ieIdx);
1900 /* RIC Request ID */
1902 subsRspIe = ricSubscriptionRsp->protocolIEs.list.array[ieIdx];
1903 subsRspIe->id = ProtocolIE_IDE2_id_RICrequestID;
1904 subsRspIe->criticality = CriticalityE2_reject;
1905 subsRspIe->value.present = RICsubscriptionRequest_IEs__value_PR_RICrequestID;
1906 subsRspIe->value.choice.RICrequestID.ricRequestorID = subsRspInfo->requestId.requestorId;
1907 subsRspIe->value.choice.RICrequestID.ricInstanceID = subsRspInfo->requestId.instanceId;
1909 /* RAN Function ID */
1911 subsRspIe = ricSubscriptionRsp->protocolIEs.list.array[ieIdx];
1912 subsRspIe->id = ProtocolIE_IDE2_id_RANfunctionID;
1913 subsRspIe->criticality = CriticalityE2_reject;
1914 subsRspIe->value.present = RICsubscriptionRequest_IEs__value_PR_RANfunctionID;
1915 subsRspIe->value.choice.RANfunctionID = subsRspInfo->ranFuncId;
1917 /* RIC Action Admitted List */
1919 subsRspIe = ricSubscriptionRsp->protocolIEs.list.array[ieIdx];
1920 subsRspIe->id = ProtocolIE_IDE2_id_RICactions_Admitted;
1921 subsRspIe->criticality = CriticalityE2_reject;
1922 subsRspIe->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List;
1923 if(BuildRicActionAdmitList(&subsRspIe->value.choice.RICaction_Admitted_List, subsRspInfo) != ROK)
1925 DU_LOG("\nERROR --> E2AP : Failed to fill RIC Action Admitted List in RIC Subscription Response");
1929 /* RIC Action Not Admitted List */
1930 if(subsRspInfo->numOfRejectedActions)
1933 subsRspIe = ricSubscriptionRsp->protocolIEs.list.array[ieIdx];
1934 subsRspIe->id = ProtocolIE_IDE2_id_RICactions_NotAdmitted;
1935 subsRspIe->criticality = CriticalityE2_reject;
1936 subsRspIe->criticality = CriticalityE2_reject;
1937 subsRspIe->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_NotAdmitted_List;
1938 if(BuildRicActionNotAdmitList(&subsRspIe->value.choice.RICaction_NotAdmitted_List, subsRspInfo) != ROK)
1940 DU_LOG("\nERROR --> E2AP : Failed to fill RIC Action Not Admitted List in RIC Subscription Response");
1948 /*******************************************************************
1950 * @brief Builds and Send the RicSubscriptionRsp
1954 * Function : BuildAndSendRicSubscriptionRsp
1956 * Functionality:Fills the RicSubscriptionRsp
1958 * @return ROK - success
1961 ******************************************************************/
1963 uint8_t BuildAndSendRicSubscriptionRsp(PendingSubsRspInfo *subsRspInfo)
1965 uint8_t ret = RFAILED;
1966 E2AP_PDU_t *e2apRicMsg = NULLP;
1967 RICsubscriptionResponse_t *ricSubscriptionRsp=NULLP;
1968 asn_enc_rval_t encRetVal;
1972 DU_LOG("\nINFO --> E2AP : Building RIC Subscription Response\n");
1974 DU_ALLOC(e2apRicMsg, sizeof(E2AP_PDU_t));
1975 if(e2apRicMsg == NULLP)
1977 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1981 e2apRicMsg->present = E2AP_PDU_PR_successfulOutcome;
1982 DU_ALLOC(e2apRicMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
1983 if(e2apRicMsg->choice.successfulOutcome == NULLP)
1985 DU_LOG("\nERROR --> E2AP : Memory allocation for RIC subscription Response failed");
1989 e2apRicMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_RICsubscription;
1990 e2apRicMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
1991 e2apRicMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_RICsubscriptionResponse;
1993 ricSubscriptionRsp = &e2apRicMsg->choice.successfulOutcome->value.choice.RICsubscriptionResponse;
1995 if(fillRicSubscriptionRsp(ricSubscriptionRsp, subsRspInfo) != ROK)
1997 DU_LOG("\nERROR --> E2AP : Memory allocation for RICsubscriptionResponseIE failed");
2001 /* Prints the Msg formed */
2002 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apRicMsg);
2004 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2006 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apRicMsg, PrepFinalEncBuf, encBuf);
2007 if(encRetVal.encoded == ENCODE_FAIL)
2009 DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Response structure (at %s)\n",\
2010 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2015 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC subscription response \n");
2016 #ifdef DEBUG_ASN_PRINT
2017 for(int i=0; i< encBufSize; i++)
2019 printf("%x",encBuf[i]);
2024 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
2026 DU_LOG("\nERROR --> E2AP : Sending RIC Subscription Response failed");
2035 FreeRicSubscriptionRsp(e2apRicMsg);
2039 /******************************************************************
2041 * @brief Deallocation of memory allocated by aper decoder for e2 setup response
2045 * Function : freeAperDecodingOfE2SetupRsp
2047 * Functionality: Deallocation of memory allocated by aper decoder for e2
2050 * @params[in] E2setupResponse_t *e2SetRspMsg;
2053 * ****************************************************************/
2054 void freeAperDecodingOfE2SetupRsp(E2setupResponse_t *e2SetRspMsg)
2056 uint8_t arrIdx, e2NodeConfigAddAckListIdx;
2057 E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAddAckItem;
2058 E2nodeComponentConfigAdditionAck_List_t *e2NodeConfigAddAckList;
2062 if(e2SetRspMsg->protocolIEs.list.array)
2064 for(arrIdx=0; arrIdx<e2SetRspMsg->protocolIEs.list.count; arrIdx++)
2066 if(e2SetRspMsg->protocolIEs.list.array[arrIdx])
2068 switch(e2SetRspMsg->protocolIEs.list.array[arrIdx]->id)
2070 case ProtocolIE_IDE2_id_TransactionID:
2073 case ProtocolIE_IDE2_id_GlobalRIC_ID:
2075 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.pLMN_Identity.buf);
2076 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.ric_ID.buf);
2080 case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
2082 e2NodeConfigAddAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List;
2083 if(e2NodeConfigAddAckList->list.array )
2085 for(e2NodeConfigAddAckListIdx = 0; e2NodeConfigAddAckListIdx< e2NodeConfigAddAckList->list.count; e2NodeConfigAddAckListIdx++)
2087 if(e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx])
2089 e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx];
2090 free(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.choice.\
2091 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf);
2092 free(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.choice.\
2093 e2nodeComponentInterfaceTypeF1);
2094 free(e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx]);
2097 free(e2NodeConfigAddAckList->list.array);
2102 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]);
2105 free(e2SetRspMsg->protocolIEs.list.array);
2109 /******************************************************************
2111 * @brief Processes E2 Setup Response sent by RIC
2115 * Function : procE2SetupRsp
2117 * Functionality: Processes E2 Setup Response sent by RIC
2119 * @params[in] E2AP_PDU_t ASN decoded E2AP message
2120 * @return ROK - success
2123 * ****************************************************************/
2125 uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg)
2127 uint8_t arrIdx =0, transId=0, idx=0;
2128 uint32_t recvBufLen;
2129 E2setupResponse_t *e2SetRspMsg=NULL;
2131 E2NodeComponent *e2NodeComponentInfo=NULL;
2132 E2nodeComponentConfigAdditionAck_List_t *e2NodeCfgAckList=NULL;
2133 E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAddAckItem=NULL;
2135 DU_LOG("\nINFO --> E2AP : E2 Setup Response received");
2136 duCb.e2Status = TRUE; //Set E2 status as true
2137 e2SetRspMsg = &e2apMsg->choice.successfulOutcome->value.choice.E2setupResponse;
2139 for(arrIdx=0; arrIdx<e2SetRspMsg->protocolIEs.list.count; arrIdx++)
2141 switch(e2SetRspMsg->protocolIEs.list.array[arrIdx]->id)
2143 case ProtocolIE_IDE2_id_TransactionID:
2145 transId = e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
2146 if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
2147 (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
2149 memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
2153 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
2159 case ProtocolIE_IDE2_id_GlobalRIC_ID:
2161 /* To store the Ric Id Params */
2162 recvBufLen = sizeof(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value\
2163 .choice.GlobalRIC_ID.pLMN_Identity.size);
2164 memcpy(&duCb.e2apDb.ricId.plmnId, e2SetRspMsg->protocolIEs.list.array[arrIdx]\
2165 ->value.choice.GlobalRIC_ID.pLMN_Identity.buf, recvBufLen);
2166 bitStringToInt(&e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.ric_ID, &duCb.e2apDb.ricId);
2167 /*TODO : duCb.e2apDb.ricId.plmnId memory to be deallocated after the usage */
2171 case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
2173 e2NodeCfgAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List;
2174 for(idx =0; idx <e2NodeCfgAckList->list.count; idx++)
2176 e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeCfgAckList->list.array[idx];
2177 switch(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.present)
2179 case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1:
2181 e2NodeComponentInfo = fetchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD, &node);
2182 if(!e2NodeComponentInfo)
2184 DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__);
2189 cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node);
2190 DU_FREE(e2NodeComponentInfo->componentRequestPart, e2NodeComponentInfo->reqBufSize);
2191 DU_FREE(e2NodeComponentInfo->componentResponsePart, e2NodeComponentInfo->rspBufSize);
2192 DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
2193 DU_FREE(node, sizeof(CmLList));
2205 DU_LOG("\nERROR --> E2AP : Invalid IE received in E2SetupRsp:%ld",
2206 e2SetRspMsg->protocolIEs.list.array[arrIdx]->id);
2210 freeAperDecodingOfE2SetupRsp(e2SetRspMsg);
2212 if(duSendE2NodeConfigurationUpdate() != ROK)
2214 DU_LOG("\nERROR --> E2AP : Failed to send E2 node config update");
2220 /*******************************************************************
2222 * @brief Free RIC Subscription Request
2226 * Function : freeAperDecodingOfRicSubsReq
2228 * Functionality : Free RIC Subscription Request
2232 ******************************************************************/
2233 void freeAperDecodingOfRicSubsReq(RICsubscriptionRequest_t *ricSubscriptionReq)
2236 uint8_t elementIdx = 0;
2237 RICsubscriptionDetails_t *subsDetails = NULLP;
2238 RICaction_ToBeSetup_ItemIEs_t *actionItem = NULLP;
2240 if(ricSubscriptionReq->protocolIEs.list.array)
2242 for(idx=0; idx < ricSubscriptionReq->protocolIEs.list.count; idx++)
2244 switch(ricSubscriptionReq->protocolIEs.list.array[idx]->id)
2246 case ProtocolIE_IDE2_id_RICsubscriptionDetails:
2248 subsDetails = &(ricSubscriptionReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails);
2249 free(subsDetails->ricEventTriggerDefinition.buf);
2251 if(subsDetails->ricAction_ToBeSetup_List.list.array)
2253 for(elementIdx = 0; elementIdx < subsDetails->ricAction_ToBeSetup_List.list.count; elementIdx++)
2255 if(subsDetails->ricAction_ToBeSetup_List.list.array[elementIdx])
2257 actionItem = (RICaction_ToBeSetup_ItemIEs_t *)subsDetails->ricAction_ToBeSetup_List.list.array[elementIdx];
2258 if(actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition)
2260 free(actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition->buf);
2261 free(actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition);
2263 free(subsDetails->ricAction_ToBeSetup_List.list.array[elementIdx]);
2266 free(subsDetails->ricAction_ToBeSetup_List.list.array);
2271 free(ricSubscriptionReq->protocolIEs.list.array[idx]);
2273 free(ricSubscriptionReq->protocolIEs.list.array);
2277 /*******************************************************************
2279 * @brief Free Event Trigger Definition
2283 * Function : freeAperDecodingOfEventTriggerDef
2285 * Functionality: Free Event Trigger Definition
2287 * @params[in] E2SM-KPM Event Trigger Definition
2290 * ****************************************************************/
2291 void freeAperDecodingOfEventTriggerDef(E2SM_KPM_EventTriggerDefinition_t *eventTiggerDef)
2295 switch(eventTiggerDef->eventDefinition_formats.present)
2297 case E2SM_KPM_EventTriggerDefinition__eventDefinition_formats_PR_NOTHING:
2300 case E2SM_KPM_EventTriggerDefinition__eventDefinition_formats_PR_eventDefinition_Format1:
2301 free(eventTiggerDef->eventDefinition_formats.choice.eventDefinition_Format1);
2307 /*******************************************************************
2309 * @brief Extract E2SM-KPM Event trigger definition
2313 * Function : extractEventTriggerDef
2315 * Functionality : This function :
2316 * - Decodes E2SM-KPM Event Trigger Definition
2317 * - Validates that even trigger style is supported by E2 node
2318 * - Stores event trigger details in local DB
2320 * @params[in] RAN Function Database structure
2321 * RIC Subscription Info to be added to RAN function
2322 * RIC Event Trigger Definition buffer received from RIC
2323 * @return ROK - success
2326 ******************************************************************/
2327 uint8_t extractEventTriggerDef(RanFunction *ranFuncDb, RicSubscription *ricSubscriptionInfo, \
2328 RICeventTriggerDefinition_t *ricEventTriggerDef, E2FailureCause *failureCause)
2330 uint8_t ret = RFAILED;
2331 uint8_t eventIdx = 0;
2332 asn_dec_rval_t rval ={0};
2333 E2SM_KPM_EventTriggerDefinition_t eventTiggerDef, *eventTiggerDefPtr = NULLP;
2335 /* Decoding E2SM-KPM Even Trigger Definition */
2336 eventTiggerDefPtr = &eventTiggerDef;
2337 memset(eventTiggerDefPtr, 0, sizeof(E2SM_KPM_EventTriggerDefinition_t));
2339 rval = aper_decode(0, &asn_DEF_E2SM_KPM_EventTriggerDefinition, (void **)&eventTiggerDefPtr, ricEventTriggerDef->buf,\
2340 ricEventTriggerDef->size, 0, 0);
2341 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
2343 DU_LOG("\nERROR --> E2AP : ASN decode failed for E2SM-KPM Event Trigger Definition");
2344 failureCause->causeType = E2_PROTOCOL;
2345 failureCause->cause = E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE;
2349 xer_fprint(stdout, &asn_DEF_E2SM_KPM_EventTriggerDefinition, eventTiggerDefPtr);
2351 /* Validating the received event trigger definition format */
2352 for(eventIdx = 0; eventIdx < ranFuncDb->numOfEventTriggerStyleSupported; eventIdx++)
2354 if((eventTiggerDefPtr->eventDefinition_formats.present != \
2355 E2SM_KPM_EventTriggerDefinition__eventDefinition_formats_PR_NOTHING) && \
2356 (eventTiggerDefPtr->eventDefinition_formats.present == ranFuncDb->eventTriggerStyleList[eventIdx].formatType))
2358 ricSubscriptionInfo->eventTriggerDefinition.formatType = ranFuncDb->eventTriggerStyleList[eventIdx].formatType;
2359 ricSubscriptionInfo->eventTriggerDefinition.choice.format1.reportingPeriod = \
2360 eventTiggerDefPtr->eventDefinition_formats.choice.eventDefinition_Format1->reportingPeriod;
2369 failureCause->causeType = E2_RIC_REQUEST;
2370 failureCause->cause = E2_EVENT_TRIGGER_NOT_SUPPORTED;
2372 /* Free E2SM_KPM_EventTriggerDefinition_t */
2373 freeAperDecodingOfEventTriggerDef(eventTiggerDefPtr);
2377 /*******************************************************************
2379 * @brief Free RIC Action Definition
2383 * Function : freeAperDecodingOfRicActionDefinition
2385 * Functionality: Free RIC Action Definition
2387 * @params[in] E2SM-KPM Action definition
2390 * ****************************************************************/
2391 void freeAperDecodingOfRicActionDefinition(E2SM_KPM_ActionDefinition_t *actionDef)
2393 uint8_t elementIdx = 0;
2394 E2SM_KPM_ActionDefinition_Format1_t *actionFormat1 = NULLP;
2395 MeasurementInfoItem_t *measItem = NULLP;
2397 switch(actionDef->actionDefinition_formats.present)
2399 case E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format1:
2401 if(actionDef->actionDefinition_formats.choice.actionDefinition_Format1)
2403 actionFormat1 = actionDef->actionDefinition_formats.choice.actionDefinition_Format1;
2404 if(actionFormat1->measInfoList.list.array)
2406 for(elementIdx = 0; elementIdx < actionFormat1->measInfoList.list.count; elementIdx++)
2408 if(actionFormat1->measInfoList.list.array[elementIdx])
2410 measItem = actionFormat1->measInfoList.list.array[elementIdx];
2411 switch(measItem->measType.present)
2413 case MeasurementType_PR_NOTHING:
2416 case MeasurementType_PR_measName:
2418 free(measItem->measType.choice.measName.buf);
2422 case MeasurementType_PR_measID:
2428 free(actionFormat1->measInfoList.list.array);
2430 free(actionFormat1);
2434 case E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format2:
2435 case E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format3:
2436 case E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format4:
2437 case E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format5:
2443 /*******************************************************************
2445 * @brief Extract Measurement Info list from action definition
2449 * Function : extractMeasInfoList
2451 * Functionality : This function :
2452 * - Traverses Measurement-to-be-subscribed list
2453 * - Validates that each measurement in Measurement-to-be-subscribed
2454 * list is supported in RAN-Function->Measurement-supported list.
2455 * - If all measurements in an action is supported by RAN function,
2456 * it is added to measurement-subscribed list in local DB
2458 * @params[in] Measurement Info supported list by RAN function
2459 * Measurement Info to be subscribed as requested by RIC
2460 * Measurement Info finally subscribed
2461 * Memory failure indicator
2462 * @return ROK - success
2465 ******************************************************************/
2466 uint8_t extractMeasInfoList(CmLListCp *measInfoSupportedList, MeasurementInfoList_t *measInfoToBeSubscribedList, \
2467 CmLListCp *measInfoSubscribedList, bool *memFailure)
2469 uint8_t elementIdx = 0;
2470 MeasurementInfoForAction *measInfoSupportedDb = NULLP;
2471 MeasurementInfo *measInfoSubscribedDb = NULLP, *measInfoToDel = NULLP;
2472 CmLList *supportedMeasNode = NULLP, *measToAddNode = NULLP, *measToDelNode = NULLP;;
2473 MeasurementInfoItem_t *measItem = NULLP;
2475 /* Validate Measurement list is supported by E2 node.
2477 * Traverse and compare the Measurement-Supported List in E2
2478 * node with Measurement-to-be-subscribed list received from RIC.
2479 * If a match is found, add it to measurement-subscription list.
2481 for(elementIdx = 0; elementIdx < measInfoToBeSubscribedList->list.count; elementIdx++)
2483 measInfoSubscribedDb = NULLP;
2484 measToAddNode = NULLP;
2485 measItem = measInfoToBeSubscribedList->list.array[elementIdx];
2487 CM_LLIST_FIRST_NODE(measInfoSupportedList, supportedMeasNode);
2488 while(supportedMeasNode)
2490 measInfoSupportedDb = (MeasurementInfoForAction*)supportedMeasNode->node;
2491 switch(measItem->measType.present)
2493 case MeasurementType_PR_measName:
2495 if(!strcmp(measInfoSupportedDb->measurementTypeName, (char *)measItem->measType.choice.measName.buf))
2497 DU_ALLOC(measInfoSubscribedDb, sizeof(MeasurementInfo));
2502 case MeasurementType_PR_measID:
2504 if(measInfoSupportedDb->measurementTypeId == measItem->measType.choice.measID)
2506 DU_ALLOC(measInfoSubscribedDb, sizeof(MeasurementInfo));
2513 DU_LOG("\nERROR -> DUAPP: Invalid Measurement-type identifier in \
2514 E2SM-KPM Action Definition Format");
2517 } /* End of switch, for measurement type identifier */
2519 /* If measurement type is supported, add to measurement-subscription list */
2520 if(measInfoSubscribedDb)
2522 measInfoSubscribedDb->measurementTypeId = measInfoSupportedDb->measurementTypeId;
2523 memcpy(measInfoSubscribedDb->measurementTypeName, measInfoSupportedDb->measurementTypeName, \
2524 strlen(measInfoSupportedDb->measurementTypeName));
2526 DU_ALLOC(measToAddNode, sizeof(CmLList));
2529 measToAddNode->node = (PTR) measInfoSubscribedDb;
2530 cmLListAdd2Tail(measInfoSubscribedList, measToAddNode);
2532 /* Break out of while loop if measurement info is found in measurement-supported list */
2537 DU_FREE(measInfoSubscribedDb, sizeof(MeasurementInfo));
2538 measInfoSubscribedDb = NULLP;
2544 supportedMeasNode = supportedMeasNode->next;
2546 } /* End of while for traversing measurement-supported list in a report style */
2548 /* If a measurement-to-be-subscribed is not found in measurement-supported list in this report style
2550 * Delete all entries from measurement-subscription list and
2551 * Break out of for loop to search in next report style */
2552 if(!measInfoSubscribedDb)
2554 while(measInfoSubscribedList->count)
2556 measToDelNode = cmLListDelFrm(measInfoSubscribedList, measInfoSubscribedList->first);
2557 measInfoToDel = (MeasurementInfo*)measToDelNode->node;
2558 DU_FREE(measInfoToDel, sizeof(MeasurementInfo));
2559 DU_FREE(measToDelNode, sizeof(CmLList));
2564 } /* End of for loop , traversing measurement-to-be-subscribed list */
2566 /* If all measurement-to-be-subscribed was found in measurement-supported list and
2567 * was added to measurement-subscription list successfully, return from here */
2568 if(measInfoToBeSubscribedList->list.count == measInfoSubscribedList->count)
2574 /*******************************************************************
2576 * @brief Extract E2SM-KPM Action definition
2580 * Function : extractRicActionDef
2582 * Functionality : This function :
2583 * - Decodes E2SM-KPM Action Definition
2584 * - Validates that action is supported by E2 node
2585 * - Stores action details in local DB
2587 * @params[in] RAN Function Database structure
2588 * RIC subscription's Action definition to be added to
2590 * RIC Action Definition buffer received from RIC
2591 * @return ROK - success
2594 ******************************************************************/
2595 uint8_t extractRicActionDef(RanFunction *ranFuncDb, ActionDefinition *actionDefDb, RICactionDefinition_t *ricActionDef,\
2596 E2FailureCause *failureCause)
2598 bool memFailure = false;
2599 uint8_t styleIdx = 0;
2600 asn_dec_rval_t rval ={0};
2602 E2SM_KPM_ActionDefinition_t actionDef, *actionDefPtr = NULLP;
2603 E2SM_KPM_ActionDefinition_Format1_t *actionFormat1 = NULLP;
2604 CmLListCp *measInfoSupportedList = NULLP;
2605 CmLListCp *measInfoSubscribedList = NULLP;
2607 /* Decoding E2SM-KPM Action Definition */
2608 actionDefPtr = &actionDef;
2609 memset(actionDefPtr, 0, sizeof(E2SM_KPM_EventTriggerDefinition_t));
2611 rval = aper_decode(0, &asn_DEF_E2SM_KPM_ActionDefinition, (void **)&actionDefPtr, ricActionDef->buf,\
2612 ricActionDef->size, 0, 0);
2613 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
2615 DU_LOG("\nERROR --> E2AP : ASN decode failed for E2SM-KPM Action Definition");
2616 failureCause->causeType = E2_PROTOCOL;
2617 failureCause->cause = E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE;
2621 xer_fprint(stdout, &asn_DEF_E2SM_KPM_ActionDefinition, actionDefPtr);
2624 /* Validate if Report style to subscribe is supported by E2 Node */
2625 for(styleIdx= 0; styleIdx < ranFuncDb->numOfReportStyleSupported; styleIdx++)
2627 /* Validate Report style type and report style format type is supported by E2 Node */
2628 if((ranFuncDb->reportStyleList[styleIdx].reportStyle.styleType == actionDefPtr->ric_Style_Type) &&
2629 (ranFuncDb->reportStyleList[styleIdx].reportStyle.formatType == actionDefPtr->actionDefinition_formats.present))
2631 /* Fetch Report stype type and format type */
2632 actionDefDb->styleType = actionDefPtr->ric_Style_Type;
2633 actionDefDb->formatType = actionDefPtr->actionDefinition_formats.present;
2635 switch(actionDefPtr->actionDefinition_formats.present)
2637 case E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format1:
2639 actionFormat1 = actionDefPtr->actionDefinition_formats.choice.actionDefinition_Format1;
2641 /* Fetch granularity period */
2642 actionDefDb->choice.format1.granularityPeriod = actionFormat1->granulPeriod;
2644 /* Validate and add the Measurement to subscription list */
2645 measInfoSupportedList = &ranFuncDb->reportStyleList[styleIdx].measurementInfoList;
2646 measInfoSubscribedList = &actionDefDb->choice.format1.measurementInfoList;
2647 if(extractMeasInfoList(measInfoSupportedList, &actionFormat1->measInfoList, \
2648 measInfoSubscribedList, &memFailure) == ROK)
2652 /* Free E2SM_KPM_ActionDefinition_t */
2653 freeAperDecodingOfRicActionDefinition(actionDefPtr);
2658 break; /* End of E2SM-KPM Action definition format 1 case */
2663 DU_LOG("\nERROR -> DUAPP: Only E2SM-KPM Action Definition Format 1 is supported");
2666 } /* End of switch for E2SM-KPM Action definition formats */
2671 failureCause->causeType = E2_MISCELLANEOUS;
2672 failureCause->cause = E2_MISCELLANEOUS_CAUSE_UNSPECIFIED;
2675 } /* End of for loop, traversing Report-styles-supported list in E2 node */
2677 /* Memset action Db and Free E2SM_KPM_ActionDefinition_t */
2678 memset(actionDefDb, 0, sizeof(ActionDefinition));
2679 freeAperDecodingOfRicActionDefinition(actionDefPtr);
2681 if(failureCause->causeType == E2_NOTHING)
2683 failureCause->causeType = E2_RIC_REQUEST;
2684 failureCause->cause = E2_ACTION_NOT_SUPPORTED;
2689 /*******************************************************************
2691 * @brief Extract RIC Action to be setup
2695 * Function : extractRicActionToBeSetup
2697 * Functionality : This function :
2698 * - Validates that each action-to-be-setup is supported by E2 node
2699 * - Stores event trigger details in local DB
2701 * @params[in] RAN Function Database structure
2702 * RIC Subscription Info to be added to RAN function
2703 * RIC Action To Be Setup List received from RIC
2704 * @return ROK - success
2707 ******************************************************************/
2708 uint8_t extractRicActionToBeSetup(RanFunction *ranFuncDb, RicSubscription *ricSubscriptionInfo, \
2709 RICactions_ToBeSetup_List_t *actionList, E2FailureCause *failureCause, PendingSubsRspInfo *subsRsp)
2711 uint8_t actionIdx = 0;
2712 uint8_t ricActionId = 0;
2713 RICaction_ToBeSetup_ItemIEs_t *actionItem = NULLP;
2715 if(actionList->list.array)
2717 for(actionIdx = 0; actionIdx < actionList->list.count; actionIdx++)
2719 actionItem =(RICaction_ToBeSetup_ItemIEs_t *)actionList->list.array[actionIdx];
2720 switch(actionItem->id)
2722 case ProtocolIE_IDE2_id_RICaction_ToBeSetup_Item:
2724 /* If Action type is REPORT and
2725 * If RIC action definition's extraction and validation passes,
2727 * This action is added to action sequence list of subscription info */
2728 ricActionId = actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionID;
2730 if(actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionType == RICactionType_report)
2732 ricSubscriptionInfo->actionSequence[ricActionId-1].id = ricActionId;
2733 ricSubscriptionInfo->actionSequence[ricActionId-1].type = REPORT;
2735 if(extractRicActionDef(ranFuncDb, &ricSubscriptionInfo->actionSequence[ricActionId-1].definition, \
2736 actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition, failureCause) == ROK)
2738 ricSubscriptionInfo->actionSequence[ricActionId-1].action = CONFIG_ADD;
2739 ricSubscriptionInfo->numOfActions++;
2744 /* In case of any failure, action is rejected
2745 * Added to rejected-action-list in subscription response */
2746 memset(&ricSubscriptionInfo->actionSequence[ricActionId-1], 0, sizeof(ActionInfo));
2747 subsRsp->rejectedActionList[subsRsp->numOfRejectedActions].id = ricActionId;
2748 if(failureCause->causeType == E2_NOTHING)
2750 failureCause->causeType = E2_RIC_REQUEST;
2751 failureCause->cause = E2_ACTION_NOT_SUPPORTED;
2753 memcpy(&subsRsp->rejectedActionList[subsRsp->numOfRejectedActions].failureCause, \
2754 failureCause, sizeof(E2FailureCause));
2755 subsRsp->numOfRejectedActions++;
2759 DU_LOG("\nERROR --> E2AP : Invalid IE received in RicSetupLst:%ld",actionItem->id);
2765 /* If there is even 1 action that can be added, return ROK */
2766 if(ricSubscriptionInfo->numOfActions)
2769 if(failureCause->causeType == E2_NOTHING)
2771 failureCause->causeType = E2_RIC_REQUEST;
2772 failureCause->cause = E2_ACTION_NOT_SUPPORTED;
2777 /******************************************************************
2779 * @brief Processes RIC Subscription Req sent by RIC
2783 * Function : procRicSubscriptionRequest
2785 * Functionality: Processes RIC Subscription Request from RIC
2787 * @params[in] E2AP_PDU_t ASN decoded E2AP message
2788 * @return ROK - success
2791 * ****************************************************************/
2792 uint8_t procRicSubscriptionRequest(E2AP_PDU_t *e2apMsg)
2796 uint16_t ranFuncId = 0;
2797 RicRequestId ricReqId;
2798 CmLList *ricSubscriptionNode = NULLP;
2799 RanFunction *ranFuncDb = NULLP;
2800 RICsubscriptionRequest_t *ricSubsReq = NULLP;
2801 RICsubscriptionDetails_t *subsDetails = NULLP;
2802 RicSubscription *ricSubscriptionInfo = NULLP;
2803 E2FailureCause failureCause;
2805 DU_LOG("\nINFO --> E2AP : RIC Subscription request received");
2807 memset(&failureCause, 0, sizeof(E2FailureCause));
2808 memset(&ricReqId, 0, sizeof(RicRequestId));
2810 ricSubsReq = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionRequest;
2811 for(idx=0; idx<ricSubsReq->protocolIEs.list.count; idx++)
2813 if(ricSubsReq->protocolIEs.list.array[idx])
2815 switch(ricSubsReq->protocolIEs.list.array[idx]->id)
2817 case ProtocolIE_IDE2_id_RICrequestID:
2819 ricReqId.requestorId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID;
2820 ricReqId.instanceId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID;
2825 case ProtocolIE_IDE2_id_RANfunctionID:
2827 ranFuncId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RANfunctionID;
2829 /* Validating RAN Function id */
2830 ranFuncDb = fetchRanFuncFromRanFuncId(ranFuncId);
2834 failureCause.causeType = E2_RIC_REQUEST;
2835 failureCause.cause = E2_RAN_FUNCTION_ID_INVALID;
2840 if(ranFuncDb->numPendingSubsRsp >= MAX_PENDING_SUBSCRIPTION_RSP)
2842 failureCause.causeType = E2_RIC_REQUEST;
2843 failureCause.cause = E2_FUNCTION_RESOURCE_LIMIT;
2848 DU_ALLOC(ricSubscriptionInfo, sizeof(RicSubscription));
2849 if(!ricSubscriptionInfo)
2851 DU_LOG("\nERROR --> E2AP : Memory allocation failed for ricSubscriptionInfo");
2852 failureCause.causeType = E2_MISCELLANEOUS;
2853 failureCause.cause = E2_MISCELLANEOUS_CAUSE_UNSPECIFIED;
2857 ricSubscriptionInfo->requestId.requestorId = ricReqId.requestorId;
2858 ricSubscriptionInfo->requestId.instanceId = ricReqId.instanceId;
2860 memset(&ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp], 0, sizeof(PendingSubsRspInfo));
2861 memcpy(&ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp].requestId,
2862 &ricReqId, sizeof(RicRequestId));
2863 ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp].ranFuncId = ranFuncId;
2867 case ProtocolIE_IDE2_id_RICsubscriptionDetails:
2869 subsDetails = &ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails;
2871 /* Decode, Validate and record Event Trigger Definition */
2872 if(extractEventTriggerDef(ranFuncDb, ricSubscriptionInfo, &subsDetails->ricEventTriggerDefinition, \
2873 &failureCause) != ROK)
2879 /* Decode, Validate and record RIC actions */
2880 if(extractRicActionToBeSetup(ranFuncDb, ricSubscriptionInfo, &subsDetails->ricAction_ToBeSetup_List, \
2881 &failureCause, &ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp]) != ROK)
2890 DU_LOG("\nERROR --> E2AP : Invalid IE received in RIC SubsReq:%ld",
2891 ricSubsReq->protocolIEs.list.array[idx]->id);
2900 freeAperDecodingOfRicSubsReq(ricSubsReq);
2904 /* Add RAN subcription detail to RAN function */
2905 DU_ALLOC(ricSubscriptionNode, sizeof(CmLList));
2906 if(ricSubscriptionNode)
2908 ricSubscriptionNode->node = (PTR) ricSubscriptionInfo;
2909 cmLListAdd2Tail(&ranFuncDb->subscriptionList, ricSubscriptionNode);
2912 ranFuncDb->numPendingSubsRsp++;
2914 #ifdef KPI_CALCULATION
2915 /* Send statistics request to other DU entities */
2916 BuildAndSendStatsReq(ranFuncId, ricSubscriptionInfo);
2919 /* TODO : Trigger RIC Indication once statistics indication is
2920 * received from MAC .
2921 * TBD in future gerrit */
2922 //BuildAndSendRicIndication(ricSubscriptionInfo);
2926 DU_FREE(ricSubscriptionInfo, sizeof(RicSubscription));
2930 memset(&ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp], 0, sizeof(PendingSubsRspInfo));
2933 /* Send RIC Subcription Failure */
2934 BuildAndSendRicSubscriptionFailure(ricReqId, ranFuncId, failureCause);
2940 /******************************************************************
2942 * @brief Free RIC Subscription Failure
2946 * Function : FreeRicSubscriptionFailure
2948 * Functionality: Free RIC Subscription Failure
2950 * @params[in] E2AP PDU
2953 * ****************************************************************/
2954 void FreeRicSubscriptionFailure(E2AP_PDU_t *e2apMsg)
2956 uint8_t elemIdx = 0;
2957 RICsubscriptionFailure_t *ricSubscriptionFailure = NULLP;
2961 if(e2apMsg->choice.unsuccessfulOutcome)
2963 ricSubscriptionFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICsubscriptionFailure;
2964 if(ricSubscriptionFailure->protocolIEs.list.array)
2966 for(elemIdx = 0; elemIdx < ricSubscriptionFailure->protocolIEs.list.count; elemIdx++)
2968 DU_ALLOC(ricSubscriptionFailure->protocolIEs.list.array[elemIdx], sizeof(RICsubscriptionFailure_IEs_t));
2970 DU_ALLOC(ricSubscriptionFailure->protocolIEs.list.array, ricSubscriptionFailure->protocolIEs.list.size);
2972 DU_ALLOC(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t));
2974 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
2978 /******************************************************************
2980 * @brief Fill and Send RIC Subscription Failure to RIC
2984 * Function : BuildAndSendRicSubscriptionFailure
2986 * Functionality: Fill and Send RIC Subscription Failure to RIC
2988 * @params[in] RIC Request ID
2991 * @return ROK - success
2994 * ****************************************************************/
2995 uint8_t BuildAndSendRicSubscriptionFailure(RicRequestId ricReqId, uint16_t ranFuncId, E2FailureCause failureCause)
2997 uint8_t ret = RFAILED;
2998 uint8_t elementCnt = 0, elemIdx = 0;
2999 E2AP_PDU_t *e2apMsg = NULLP;
3000 asn_enc_rval_t encRetVal; /* Encoder return value */
3001 RICsubscriptionFailure_t *ricSubscriptionFailure = NULLP;
3002 RICsubscriptionFailure_IEs_t *ricSubsFailIe = NULLP;
3006 DU_LOG("\nINFO --> E2AP : Building RIC Subscription Failure\n");
3008 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
3009 if(e2apMsg == NULLP)
3011 DU_LOG("\nERROR --> E2AP : Memory allocation at [%s] : Line [%d]", __func__, __LINE__);
3015 e2apMsg->present = E2AP_PDU_PR_unsuccessfulOutcome;
3016 DU_ALLOC(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t));
3017 if(e2apMsg->choice.unsuccessfulOutcome == NULLP)
3019 DU_LOG("\nERROR --> E2AP : Memory allocation at [%s] : Line [%d]", __func__, __LINE__);
3022 e2apMsg->choice.unsuccessfulOutcome->procedureCode = ProcedureCodeE2_id_RICsubscription;
3023 e2apMsg->choice.unsuccessfulOutcome->criticality = CriticalityE2_reject;
3024 e2apMsg->choice.unsuccessfulOutcome->value.present = UnsuccessfulOutcomeE2__value_PR_RICsubscriptionFailure;
3026 ricSubscriptionFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICsubscriptionFailure;
3029 ricSubscriptionFailure->protocolIEs.list.count = elementCnt;
3030 ricSubscriptionFailure->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionFailure_IEs_t *);
3031 DU_ALLOC(ricSubscriptionFailure->protocolIEs.list.array, ricSubscriptionFailure->protocolIEs.list.size);
3032 if(!ricSubscriptionFailure->protocolIEs.list.array)
3034 DU_LOG("\nERROR --> E2AP : Memory allocation at [%s] : Line [%d]", __func__, __LINE__);
3038 for(elemIdx = 0; elemIdx < elementCnt; elemIdx++)
3040 DU_ALLOC(ricSubscriptionFailure->protocolIEs.list.array[elemIdx], sizeof(RICsubscriptionFailure_IEs_t));
3041 if(!ricSubscriptionFailure->protocolIEs.list.array[elemIdx])
3043 DU_LOG("\nERROR --> E2AP : Memory allocation at [%s] : Line [%d] for IE at index [%d]", \
3044 __func__, __LINE__, elemIdx);
3048 if(elemIdx < elementCnt)
3053 /* RIC Request ID */
3054 ricSubsFailIe = ricSubscriptionFailure->protocolIEs.list.array[elemIdx++];
3055 ricSubsFailIe->id = ProtocolIE_IDE2_id_RICrequestID;
3056 ricSubsFailIe->criticality = CriticalityE2_reject;
3057 ricSubsFailIe->value.present = RICsubscriptionFailure_IEs__value_PR_RICrequestID;
3058 ricSubsFailIe->value.choice.RICrequestID.ricRequestorID = ricReqId.requestorId;
3059 ricSubsFailIe->value.choice.RICrequestID.ricInstanceID = ricReqId.instanceId;
3061 /* RAN Function ID */
3062 ricSubsFailIe = ricSubscriptionFailure->protocolIEs.list.array[elemIdx++];
3063 ricSubsFailIe->id = ProtocolIE_IDE2_id_RANfunctionID;
3064 ricSubsFailIe->criticality = CriticalityE2_reject;
3065 ricSubsFailIe->value.present = RICsubscriptionFailure_IEs__value_PR_RANfunctionID;
3066 ricSubsFailIe->value.choice.RANfunctionID = ranFuncId;
3069 ricSubsFailIe = ricSubscriptionFailure->protocolIEs.list.array[elemIdx++];
3070 ricSubsFailIe->id = ProtocolIE_IDE2_id_CauseE2;
3071 ricSubsFailIe->criticality = CriticalityE2_reject;
3072 ricSubsFailIe->value.present = RICsubscriptionFailure_IEs__value_PR_CauseE2;
3073 fillE2Cause(&ricSubsFailIe->value.choice.CauseE2, failureCause);
3075 /* Prints the Msg formed */
3076 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
3077 memset(encBuf, 0, ENC_BUF_MAX_LEN);
3079 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
3080 if(encRetVal.encoded == ENCODE_FAIL)
3082 DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Failure Message (at %s)\n",\
3083 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
3088 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Subscription Failure Message \n");
3089 #ifdef DEBUG_ASN_PRINT
3090 for(int i=0; i< encBufSize; i++)
3092 printf("%x",encBuf[i]);
3097 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
3099 DU_LOG("\nINFO --> E2AP : Sending RIC Subscription Failure");
3105 FreeRicSubscriptionFailure(e2apMsg);
3109 /*******************************************************************
3111 * @brief Free the RicIndication Message
3115 * Function : FreeRicIndication
3117 * Functionality: Free the RicIndication Message
3122 ******************************************************************/
3123 void FreeRicIndication(E2AP_PDU_t *e2apMsg)
3126 RICindication_t *ricIndicationMsg= NULLP;
3128 if(e2apMsg != NULLP)
3130 if(e2apMsg->choice.initiatingMessage != NULLP)
3132 ricIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.RICindication;
3133 if(ricIndicationMsg!= NULLP)
3135 if(ricIndicationMsg->protocolIEs.list.array != NULLP)
3137 for(idx=0; idx<ricIndicationMsg->protocolIEs.list.count; idx++)
3139 if(ricIndicationMsg->protocolIEs.list.array[idx] != NULLP)
3141 switch(ricIndicationMsg->protocolIEs.list.array[idx]->id)
3143 case ProtocolIE_IDE2_id_RICrequestID:
3146 case ProtocolIE_IDE2_id_RANfunctionID:
3149 case ProtocolIE_IDE2_id_RICactionID:
3152 case ProtocolIE_IDE2_id_RICindicationType:
3155 case ProtocolIE_IDE2_id_RICindicationHeader:
3157 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf,\
3158 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size);
3161 case ProtocolIE_IDE2_id_RICindicationMessage:
3163 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf,\
3164 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size);
3170 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx],sizeof(RICindication_IEs_t));
3173 DU_FREE(ricIndicationMsg->protocolIEs.list.array,ricIndicationMsg->protocolIEs.list.size);
3176 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
3178 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
3182 /*******************************************************************
3184 * brief Fill the RicIndication Message
3188 * Function : FillRicIndication
3190 * Functionality:Fills the RicIndication Message
3192 * @return ROK - success
3195 ******************************************************************/
3196 uint8_t FillRicIndication(RICindication_t *ricIndicationMsg, RicSubscription *ricSubscriptionInfo)
3198 uint8_t elementCnt=0;
3203 ricIndicationMsg->protocolIEs.list.count = elementCnt;
3204 ricIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(RICindication_t);
3205 /* Initialize the Ric Indication members */
3206 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array, \
3207 ricIndicationMsg->protocolIEs.list.size);
3208 if(ricIndicationMsg->protocolIEs.list.array == NULLP)
3210 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
3215 for(idx=0; idx<elementCnt; idx++)
3217 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx],\
3218 sizeof(RICindication_IEs_t));
3219 if(ricIndicationMsg->protocolIEs.list.array[idx] == NULLP)
3221 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
3229 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICrequestID;
3230 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
3231 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
3232 RICindication_IEs__value_PR_RICrequestID;
3233 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID =ricSubscriptionInfo->requestId.requestorId;
3234 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID = ricSubscriptionInfo->requestId.instanceId;
3237 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionID;
3238 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
3239 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
3240 RICindication_IEs__value_PR_RANfunctionID;
3241 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RANfunctionID = duCb.e2apDb.ranFunction[0].id;
3244 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICactionID;
3245 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
3246 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
3247 RICindication_IEs__value_PR_RICactionID;
3248 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICactionID = ricSubscriptionInfo->actionSequence[0].id;
3251 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationType;
3252 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
3253 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
3254 RICindication_IEs__value_PR_RICindicationType;
3255 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationType = ricSubscriptionInfo->actionSequence[0].type;
3258 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationHeader;
3259 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
3260 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
3261 RICindication_IEs__value_PR_RICindicationHeader;
3262 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size = 3 *
3264 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf ,\
3265 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size);
3266 if(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf == NULLP)
3268 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
3273 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
3274 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf);
3276 /* TO BE CHANGED: RIC INDICATION DATA */
3277 /* For now filling a dummy octect data, need to tested with PRBs*/
3278 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationMessage;
3279 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
3280 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
3281 RICindication_IEs__value_PR_RICindicationMessage;
3282 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size = 3 *
3284 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf ,\
3285 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size);
3286 if(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf == NULLP)
3288 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
3293 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
3294 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf);
3302 /*******************************************************************
3304 * @brief Builds and Send the RicIndication Message
3308 * Function : BuildAndSendRicIndication
3310 * Functionality:Fills the RicIndication Message
3312 * @return ROK - success
3315 ******************************************************************/
3317 uint8_t BuildAndSendRicIndication(RicSubscription *ricSubscriptionInfo)
3319 E2AP_PDU_t *e2apMsg = NULLP;
3320 RICindication_t *ricIndicationMsg=NULLP;
3321 asn_enc_rval_t encRetVal; /* Encoder return value */
3322 uint8_t ret = RFAILED;
3323 uint8_t FillRicIndicationret = ROK;
3327 DU_LOG("\nINFO --> E2AP : Building RIC Indication Message\n");
3329 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
3330 if(e2apMsg == NULLP)
3332 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
3336 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
3337 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
3338 if(e2apMsg->choice.initiatingMessage == NULLP)
3340 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
3343 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICindication;
3344 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
3345 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICindication;
3347 ricIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.RICindication;
3349 FillRicIndicationret = FillRicIndication(ricIndicationMsg, ricSubscriptionInfo);
3350 if(FillRicIndicationret != ROK)
3354 /* Prints the Msg formed */
3355 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
3356 memset(encBuf, 0, ENC_BUF_MAX_LEN);
3358 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
3360 if(encRetVal.encoded == ENCODE_FAIL)
3362 DU_LOG("\nERROR --> E2AP : Could not encode RIC Indication Message (at %s)\n",\
3363 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
3368 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Indication Message \n");
3369 #ifdef DEBUG_ASN_PRINT
3370 for(int i=0; i< encBufSize; i++)
3372 printf("%x",encBuf[i]);
3377 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
3379 DU_LOG("\nINFO --> E2AP : Sending RIC Indication Message");
3385 FreeRicIndication(e2apMsg);
3389 /*******************************************************************
3391 * @brief free e2 node component configuration req and rsp
3395 * Function : freeE2NodeComponentConfiguration
3398 * - free e2 node component configuration req and rsp
3400 * @params[in] E2nodeComponentConfiguration_t *e2nodeComponentConfiguration
3401 * @return ROK - success
3404 * ****************************************************************/
3406 void freeE2NodeComponentConfiguration(E2nodeComponentConfiguration_t *e2nodeComponentConfiguration)
3408 /* Free E2 Node Component Request Part */
3409 DU_FREE(e2nodeComponentConfiguration->e2nodeComponentRequestPart.buf, e2nodeComponentConfiguration->e2nodeComponentRequestPart.size);
3411 /* Free E2 Node Component Response Part */
3412 DU_FREE(e2nodeComponentConfiguration->e2nodeComponentResponsePart.buf, e2nodeComponentConfiguration->e2nodeComponentResponsePart.size);
3416 /*******************************************************************
3418 * @brief free e2 node component component identifier
3422 * Function : freeE2NodeComponentIdentifier
3425 * - free e2 node component component identifier
3427 * @params[in] E2nodeComponentID_t *componentID
3428 * @return ROK - success
3431 * ****************************************************************/
3433 void freeE2NodeComponentIdentifier(E2nodeComponentID_t *componentID)
3435 if(componentID->choice.e2nodeComponentInterfaceTypeF1)
3437 DU_FREE(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf, componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size);
3438 DU_FREE(componentID->choice.e2nodeComponentInterfaceTypeF1, sizeof(E2nodeComponentInterfaceF1_t));
3443 /*******************************************************************
3445 * @brief Deallocate the memory allocated for E2nodeConfigurationUpdate msg
3449 * Function : FreeE2NodeConfigUpdate
3452 * - freeing the memory allocated for E2nodeConfigurationUpdate
3454 * @params[in] E2AP_PDU_t *e2apMsg
3455 * @return ROK - success
3458 * ****************************************************************/
3460 void FreeE2NodeConfigUpdate(E2AP_PDU_t *e2apMsg)
3462 uint8_t arrIdx =0, e2NodeUpdateListIdx=0, e2NodeRemovalListIdx=0, e2NodeAddListIdx=0;
3463 E2nodeConfigurationUpdate_t *e2NodeConfigUpdate =NULL;
3464 E2nodeComponentConfigUpdate_List_t *e2NodeUpdateList =NULL;
3465 E2nodeComponentConfigUpdate_ItemIEs_t *e2NodeUpdateItem =NULL;
3466 E2nodeComponentConfigRemoval_List_t *e2NodeRemovalList =NULL;
3467 E2nodeComponentConfigRemoval_ItemIEs_t *e2NodeRemovalItem =NULL;
3468 E2nodeComponentConfigAddition_List_t *e2NodeAddList =NULL;
3469 E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem =NULL;
3471 if(e2apMsg != NULLP)
3473 if(e2apMsg->choice.initiatingMessage != NULLP)
3475 e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate;
3476 if(e2NodeConfigUpdate->protocolIEs.list.array != NULLP)
3478 for(arrIdx = 0; arrIdx < e2NodeConfigUpdate->protocolIEs.list.count; arrIdx++)
3480 if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx])
3483 switch(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id)
3485 case ProtocolIE_IDE2_id_TransactionID:
3488 case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition:
3490 e2NodeAddList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List;
3491 if(e2NodeAddList->list.array)
3493 for(e2NodeAddListIdx = 0; e2NodeAddListIdx< e2NodeAddList->list.count; e2NodeAddListIdx++)
3495 e2NodeAddItem = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[e2NodeAddListIdx];
3497 freeE2NodeComponentConfiguration(&e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration);
3498 freeE2NodeComponentIdentifier(&e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID);
3499 DU_FREE(e2NodeAddItem, sizeof(E2nodeComponentConfigAddition_ItemIEs_t));
3501 DU_FREE(e2NodeAddList->list.array, e2NodeAddList->list.size);
3505 case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate:
3507 e2NodeUpdateList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdate_List;
3508 if(e2NodeUpdateList->list.array)
3510 for(e2NodeUpdateListIdx = 0; e2NodeUpdateListIdx< e2NodeUpdateList->list.count; e2NodeUpdateListIdx++)
3512 e2NodeUpdateItem = (E2nodeComponentConfigUpdate_ItemIEs_t *) e2NodeUpdateList->list.array[e2NodeUpdateListIdx];
3514 freeE2NodeComponentConfiguration(&e2NodeUpdateItem->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentConfiguration);
3515 freeE2NodeComponentIdentifier(&e2NodeUpdateItem->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentID);
3516 DU_FREE(e2NodeUpdateItem, sizeof(E2nodeComponentConfigUpdate_ItemIEs_t));
3518 DU_FREE(e2NodeUpdateList->list.array, e2NodeUpdateList->list.size);
3522 case ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval:
3524 e2NodeRemovalList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemoval_List;
3525 if(e2NodeRemovalList->list.array)
3527 for(e2NodeRemovalListIdx = 0; e2NodeRemovalListIdx< e2NodeRemovalList->list.count; e2NodeRemovalListIdx++)
3529 e2NodeRemovalItem = (E2nodeComponentConfigRemoval_ItemIEs_t *) e2NodeRemovalList->list.array[e2NodeRemovalListIdx];
3531 freeE2NodeComponentIdentifier(&e2NodeRemovalItem->value.choice.E2nodeComponentConfigRemoval_Item.e2nodeComponentID);
3532 DU_FREE(e2NodeRemovalItem, sizeof(E2nodeComponentConfigRemoval_ItemIEs_t));
3534 DU_FREE(e2NodeRemovalList->list.array, e2NodeRemovalList->list.size);
3542 DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t));
3545 DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size);
3547 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
3549 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
3553 /*******************************************************************
3555 * @brief Buld and send the E2 node config update msg
3559 * Function : BuildAndSendE2NodeConfigUpdate
3562 * - Buld and send the E2 node config update msg
3565 * @return ROK - success
3568 * ****************************************************************/
3570 uint8_t BuildAndSendE2NodeConfigUpdate(E2NodeConfigList *e2NodeList)
3572 uint8_t ret = RFAILED;
3573 uint8_t arrIdx = 0,elementCnt = 0, transId=0;
3574 E2AP_PDU_t *e2apMsg = NULLP;
3575 asn_enc_rval_t encRetVal; /* Encoder return value */
3576 E2nodeConfigurationUpdate_t *e2NodeConfigUpdate = NULLP;
3578 DU_LOG("\nINFO --> E2AP : Building E2 Node config update\n");
3581 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
3582 if(e2apMsg == NULLP)
3584 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
3588 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
3589 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
3590 if(e2apMsg->choice.initiatingMessage == NULLP)
3592 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
3595 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
3596 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2nodeConfigurationUpdate;
3597 e2apMsg->choice.initiatingMessage->value.present = \
3598 InitiatingMessageE2__value_PR_E2nodeConfigurationUpdate;
3599 e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate;
3602 if(e2NodeList->addE2NodeCount)
3604 if(e2NodeList->updateE2NodeCount)
3606 if(e2NodeList->removeE2NodeCount)
3609 e2NodeConfigUpdate->protocolIEs.list.count = elementCnt;
3610 e2NodeConfigUpdate->protocolIEs.list.size = elementCnt * sizeof(E2nodeConfigurationUpdate_IEs_t*);
3611 DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size);
3612 if(e2NodeConfigUpdate->protocolIEs.list.array == NULLP)
3614 DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed");
3618 for(arrIdx =0; arrIdx<elementCnt; arrIdx++)
3620 DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t));
3621 if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx] == NULLP)
3624 DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed");
3629 if(arrIdx<elementCnt)
3633 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
3634 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
3635 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_TransactionID;
3636 transId = assignTransactionId();
3637 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId;
3639 if(e2NodeList->addE2NodeCount)
3642 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition;
3643 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
3644 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigAddition_List;
3645 if(BuildE2NodeConfigAddList(&(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List),\
3646 ProcedureCodeE2_id_E2nodeConfigurationUpdate, e2NodeList->addE2NodeCount, e2NodeList->addE2Node)!=ROK)
3648 DU_LOG("\nERROR --> E2AP : Failed to create E2 Node config list");
3653 if(e2NodeList->updateE2NodeCount)
3656 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate;
3657 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
3658 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigUpdate_List;
3659 if(BuildE2NodeConfigUpdateList(&e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdate_List,\
3660 e2NodeList->updateE2NodeCount, e2NodeList->updateE2Node) != ROK)
3663 DU_LOG("\nERROR --> E2AP : Failed to update the E2 node configuration");
3668 if(e2NodeList->removeE2NodeCount)
3671 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval;
3672 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
3673 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigRemoval_List;
3674 if(BuildE2NodeConfigRemoveList(&e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemoval_List,\
3675 e2NodeList->removeE2NodeCount, e2NodeList->removeE2Node) != ROK)
3678 DU_LOG("\nERROR --> E2AP : Failed to remove the E2 node configuration");
3683 /* Prints the Msg formed */
3684 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
3686 memset(encBuf, 0, ENC_BUF_MAX_LEN);
3688 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
3689 if(encRetVal.encoded == ENCODE_FAIL)
3691 DU_LOG("\nERROR --> E2AP : Could not encode E2nodeConfigurationUpdate structure (at %s)\n",\
3692 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
3697 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2nodeConfigurationUpdate\n");
3698 #ifdef DEBUG_ASN_PRINT
3699 for(int i=0; i< encBufSize; i++)
3701 printf("%x",encBuf[i]);
3705 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize))
3707 DU_LOG("\nERROR --> E2AP : Sending E2 node config update failed");
3711 duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
3712 duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
3713 memcpy(&duCb.e2apDb.e2TimersInfo.e2Timers.e2NodeConfigUpdate.configList, e2NodeList, sizeof(E2NodeConfigList));
3718 FreeE2NodeConfigUpdate(e2apMsg);
3722 /*******************************************************************
3724 * @brief Deallocate the memory allocated for E2ResetRequest msg
3728 * Function : FreeE2ResetRequest
3731 * - freeing the memory allocated for E2ResetRequest
3733 * @params[in] E2AP_PDU_t *e2apMsg
3734 * @return ROK - success
3737 * ****************************************************************/
3738 void FreeE2ResetRequest(E2AP_PDU_t *e2apMsg)
3741 ResetRequestE2_t *resetReq = NULLP;
3743 if(e2apMsg != NULLP)
3745 if(e2apMsg->choice.initiatingMessage != NULLP)
3747 resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2;
3748 if(resetReq->protocolIEs.list.array)
3750 for(ieIdx = 0; ieIdx < resetReq->protocolIEs.list.count; ieIdx++)
3752 DU_FREE(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t));
3754 DU_FREE(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size);
3756 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
3758 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
3762 /*******************************************************************
3764 * @brief Build and send the E2 reset request msg
3768 * Function : BuildAndSendE2ResetRequest
3771 * - Buld and send the E2 reset request msg to RIC
3774 * @return ROK - success
3777 * ****************************************************************/
3778 uint8_t BuildAndSendE2ResetRequest(E2FailureCause resetCause)
3780 uint8_t ieIdx = 0, elementCnt = 0, transId = 0;
3781 uint8_t ret = RFAILED;
3782 E2AP_PDU_t *e2apMsg = NULLP;
3783 ResetRequestE2_t *resetReq = NULLP;
3784 asn_enc_rval_t encRetVal; /* Encoder return value */
3786 DU_LOG("\nINFO --> E2AP : Building E2 Reset Request\n");
3790 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
3791 if(e2apMsg == NULLP)
3793 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for E2AP-PDU failed");
3797 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
3798 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
3799 if(e2apMsg->choice.initiatingMessage == NULLP)
3801 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for initiatingMessage");
3805 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_Reset;
3806 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
3807 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ResetRequestE2;
3808 resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2;
3811 resetReq->protocolIEs.list.count = elementCnt;
3812 resetReq->protocolIEs.list.size = elementCnt * sizeof(ResetRequestIEs_t *);
3814 DU_ALLOC(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size);
3815 if(!resetReq->protocolIEs.list.array)
3817 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \
3818 Reset Request IE array");
3822 for(ieIdx = 0; ieIdx < elementCnt; ieIdx++)
3824 DU_ALLOC(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t));
3825 if(!resetReq->protocolIEs.list.array[ieIdx])
3827 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \
3828 Reset Request IE array element");
3833 /* In case of failure */
3834 if(ieIdx < elementCnt)
3838 resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
3839 resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
3840 resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_TransactionID;
3841 transId = assignTransactionId();
3842 resetReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
3845 resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_CauseE2;
3846 resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_ignore;
3847 resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_CauseE2;
3848 fillE2Cause(&resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2, resetCause);
3850 /* Prints the Msg formed */
3851 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
3853 memset(encBuf, 0, ENC_BUF_MAX_LEN);
3855 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
3857 if(encRetVal.encoded == ENCODE_FAIL)
3859 DU_LOG("\nERROR --> E2AP : Could not encode E2SetupRequest structure (at %s)\n",\
3860 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
3865 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SetupRequest\n");
3866 #ifdef DEBUG_ASN_PRINT
3867 for(int i=0; i< encBufSize; i++)
3869 printf("%x",encBuf[i]);
3873 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
3875 DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed");
3879 /* In case the message is sent successfully, store the transaction info to
3880 * be used when response is received */
3881 duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
3882 duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
3888 /* Free all memory */
3889 FreeE2ResetRequest(e2apMsg);
3893 /*******************************************************************
3895 * @brief Deallocate the memory allocated for Reset Response msg
3899 * Function : freeAperDecodingOfE2ResetRsp
3902 * - freeing the memory allocated for Reset response
3904 * @params[in] ResetResponseE2_t *resetResponse
3907 * ****************************************************************/
3908 void freeAperDecodingOfE2ResetRsp(ResetResponseE2_t *resetResponse)
3914 if(resetResponse->protocolIEs.list.array)
3916 for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++)
3918 if(resetResponse->protocolIEs.list.array[ieIdx])
3920 switch(resetResponse->protocolIEs.list.array[ieIdx]->id)
3922 case ProtocolIE_IDE2_id_TransactionID:
3925 case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
3928 free(resetResponse->protocolIEs.list.array[ieIdx]);
3931 free(resetResponse->protocolIEs.list.array);
3936 /******************************************************************
3938 * @brief Processes E2 Reset Response sent by RIC
3942 * Function : procResetResponse
3944 * Functionality: Processes E2 Reset Response sent by RIC
3946 * @params[in] E2AP_PDU_t ASN decoded E2AP message
3947 * @return ROK - success
3950 * ****************************************************************/
3951 uint8_t procResetResponse(E2AP_PDU_t *e2apMsg)
3953 uint8_t ieIdx =0, transId;
3954 ResetResponseE2_t *resetResponse;
3956 DU_LOG("\nINFO --> E2AP : E2 Reset Response received");
3957 resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2;;
3959 for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++)
3961 switch(resetResponse->protocolIEs.list.array[ieIdx]->id)
3963 case ProtocolIE_IDE2_id_TransactionID:
3964 transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
3965 if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) && \
3966 (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
3968 memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
3972 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
3976 case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
3977 /* As per ORAN WG3 E2AP spec v3.0, section 9.2.2
3978 Criticality Diagnostics IE is sent by Near-RT RIC when parts of a received message i.e.
3979 Reset Request in this case, have not been comprehended or were missing, or if the message
3980 contained logical errors.
3982 Processing of this ID should be implemented when negative call flows are to be supported.
3986 DU_LOG("\nERROR --> E2AP : Invalid IE received in E2 Reset Response : %ld",
3987 resetResponse->protocolIEs.list.array[ieIdx]->id);
3992 freeAperDecodingOfE2ResetRsp(resetResponse);
3996 /******************************************************************
3998 * @brief Deallocation of memory allocated by aper decoder for e2 setup Failure
4002 * Function : freeAperDecodingOfE2SetupFailure
4004 * Functionality: Deallocation of memory allocated by aper decoder for e2
4007 * @params[in] E2setupFailure_t *e2SetupFailure;
4010 * ****************************************************************/
4011 void freeAperDecodingOfE2SetupFailure(E2setupFailure_t *e2SetupFailure)
4017 if(e2SetupFailure->protocolIEs.list.array)
4019 for(arrIdx=0; arrIdx<e2SetupFailure->protocolIEs.list.count; arrIdx++)
4021 if(e2SetupFailure->protocolIEs.list.array[arrIdx])
4023 free(e2SetupFailure->protocolIEs.list.array[arrIdx]);
4026 free(e2SetupFailure->protocolIEs.list.array);
4030 /******************************************************************
4032 * @brief Processes E2 Setup Failure sent by RIC
4036 * Function : procE2SetupFailure
4038 * Functionality: Processes E2 Setup failure sent by RIC
4040 * @params[in] E2AP_PDU_t ASN decoded E2AP message
4041 * @return ROK - success
4044 * ****************************************************************/
4045 void procE2SetupFailure(E2AP_PDU_t *e2apMsg)
4047 uint8_t arrIdx =0, transId =0, timerValue=0;
4048 E2setupFailure_t *e2SetupFailure;
4050 DU_LOG("\nINFO --> E2AP : E2 Setup failure received");
4051 e2SetupFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2setupFailure;
4053 for(arrIdx=0; arrIdx<e2SetupFailure->protocolIEs.list.count; arrIdx++)
4055 switch(e2SetupFailure->protocolIEs.list.array[arrIdx]->id)
4057 case ProtocolIE_IDE2_id_TransactionID:
4059 transId = e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
4060 if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
4061 (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
4063 memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
4067 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
4072 case ProtocolIE_IDE2_id_TimeToWaitE2:
4074 timerValue = convertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2);
4075 if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR)) == FALSE)
4077 duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR, timerValue);
4081 DU_LOG("\nERROR --> E2AP : EVENT_E2_SETUP_TMR timer is already running");
4089 freeAperDecodingOfE2SetupFailure(e2SetupFailure);
4091 /******************************************************************
4093 * @brief Deallocation of memory allocated by aper decoder for RIC service Query
4097 * Function : freeAperDecodingOfRicServiceQuery
4099 * Functionality: Deallocation of memory allocated by aper decoder for RIC
4102 * @params[in] RICserviceQuery_t *ricServiceQuery;
4105 * ****************************************************************/
4107 void freeAperDecodingOfRicServiceQuery(RICserviceQuery_t *ricServiceQuery)
4109 uint8_t arrIdx,ranFuncIdx;
4110 RANfunctionsID_List_t *ranFuncAddedList;
4114 if(ricServiceQuery->protocolIEs.list.array)
4116 for(arrIdx=0; arrIdx<ricServiceQuery->protocolIEs.list.count; arrIdx++)
4118 if(ricServiceQuery->protocolIEs.list.array[arrIdx])
4120 switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id)
4122 case ProtocolIE_IDE2_id_RANfunctionsAccepted:
4124 ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List;
4125 if(ranFuncAddedList->list.array)
4127 for(ranFuncIdx=0;ranFuncIdx<ranFuncAddedList->list.count; ranFuncIdx++)
4129 free(ranFuncAddedList->list.array[ranFuncIdx]);
4131 free(ranFuncAddedList->list.array);;
4138 free(ricServiceQuery->protocolIEs.list.array[arrIdx]);
4141 free(ricServiceQuery->protocolIEs.list.array);
4145 /*******************************************************************
4147 * @brief Build RanFunction Delete List
4151 * Function : BuildRanFunctionDeleteList
4153 * Functionality: Build RanFunction Delete List
4156 * RANfunctionsID List
4157 * Count of the RAN function
4158 * Received RAN function list
4160 * @return ROK - success
4163 ******************************************************************/
4165 uint8_t BuildRanFunctionDeleteList(RANfunctionsID_List_t *deleteList, uint8_t count, RanFuncInfo *recvdRanFunc)
4167 uint8_t ranFuncIdx=0;
4168 RANfunctionID_ItemIEs_t *delRanFuncItem;
4172 deleteList->list.count = count;
4173 deleteList->list.size = deleteList->list.count * sizeof(RANfunctionID_ItemIEs_t*);
4174 DU_ALLOC(deleteList->list.array, deleteList->list.size);
4175 if(deleteList->list.array == NULLP)
4177 DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
4180 for(ranFuncIdx = 0; ranFuncIdx< deleteList->list.count; ranFuncIdx++)
4182 DU_ALLOC(deleteList->list.array[ranFuncIdx], sizeof(RANfunctionID_ItemIEs_t));
4183 if(deleteList->list.array[ranFuncIdx] == NULLP)
4185 DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
4188 delRanFuncItem= (RANfunctionID_ItemIEs_t *) deleteList->list.array[ranFuncIdx];
4189 delRanFuncItem->id = ProtocolIE_IDE2_id_RANfunctionID_Item;
4190 delRanFuncItem->criticality = CriticalityE2_ignore;
4191 delRanFuncItem->value.choice.RANfunctionID_Item.ranFunctionID = recvdRanFunc[ranFuncIdx].id;
4192 delRanFuncItem->value.choice.RANfunctionID_Item.ranFunctionRevision = recvdRanFunc[ranFuncIdx].revisionCounter;
4198 /*******************************************************************
4200 * @brief De Allocate Ric Service Update message
4204 * Function : FreeRicServiceUpdate
4206 * Functionality: De-Allocating Ric Service Update message
4208 * @params[in] E2AP_PDU_t *e2apMsg
4212 * ****************************************************************/
4214 void FreeRicServiceUpdate(E2AP_PDU_t *e2apMsg)
4217 uint8_t ranFuncAddListIdx=0, ranFuncDelIdx=0;
4218 RICserviceUpdate_t *ricServiceUpdate;
4219 RANfunctions_List_t *ranFunctionsList;
4220 RANfunction_ItemIEs_t *ranFuncItemIe;
4221 RANfunction_Item_t *ranFunItem;
4222 RANfunctionsID_List_t *deleteList;
4224 /* De-allocating Memory */
4225 if(e2apMsg != NULLP)
4227 if(e2apMsg->choice.initiatingMessage != NULLP)
4229 ricServiceUpdate = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceUpdate;
4230 if(ricServiceUpdate->protocolIEs.list.array != NULLP)
4232 for(arrIdx = 0; arrIdx < ricServiceUpdate->protocolIEs.list.count; arrIdx++)
4234 if(ricServiceUpdate->protocolIEs.list.array[arrIdx] != NULLP)
4236 switch(ricServiceUpdate->protocolIEs.list.array[arrIdx]->id)
4238 case ProtocolIE_IDE2_id_TransactionID:
4241 case ProtocolIE_IDE2_id_RANfunctionsAdded:
4242 case ProtocolIE_IDE2_id_RANfunctionsModified:
4244 ranFunctionsList = &(ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List);
4245 if(ranFunctionsList->list.array)
4247 for(ranFuncAddListIdx= 0; ranFuncAddListIdx< ranFunctionsList->list.count; ranFuncAddListIdx++)
4249 if(ranFunctionsList->list.array[ranFuncAddListIdx])
4251 ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncAddListIdx];
4252 ranFunItem = &ranFuncItemIe->value.choice.RANfunction_Item;
4253 DU_FREE(ranFunItem->ranFunctionOID.buf, ranFunItem->ranFunctionOID.size);
4254 DU_FREE(ranFunItem->ranFunctionDefinition.buf, ranFunItem->ranFunctionDefinition.size);
4255 DU_FREE(ranFunctionsList->list.array[ranFuncAddListIdx], sizeof(RANfunction_ItemIEs_t));
4258 DU_FREE(ranFunctionsList->list.array, ranFunctionsList->list.size);
4262 case ProtocolIE_IDE2_id_RANfunctionsDeleted:
4264 deleteList= &ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List;
4265 if(deleteList->list.array)
4267 for(ranFuncDelIdx = 0; ranFuncDelIdx< deleteList->list.count; ranFuncDelIdx++)
4269 DU_FREE(deleteList->list.array[ranFuncDelIdx], sizeof(RANfunctionID_ItemIEs_t));
4271 DU_FREE(deleteList->list.array, deleteList->list.size);
4277 DU_LOG("\nERROR --> E2AP: Invalid event at ricServiceUpdate %ld ",\
4278 (ricServiceUpdate->protocolIEs.list.array[arrIdx]->id));
4281 DU_FREE(ricServiceUpdate->protocolIEs.list.array[arrIdx], sizeof(RICserviceUpdate_IEs_t));
4284 DU_FREE(ricServiceUpdate->protocolIEs.list.array, ricServiceUpdate->protocolIEs.list.size);
4286 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
4288 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
4292 /*******************************************************************
4294 * @brief Builds and Send the RicServiceUpdateuest
4298 * Function : BuildAndSendRicServiceUpdate
4300 * Functionality:Fills the RicServiceUpdateuest
4302 * @return ROK - success
4305 ******************************************************************/
4307 uint8_t BuildAndSendRicServiceUpdate(RicServiceUpdate serviceUpdate)
4309 uint8_t arrIdx = 0, elementCnt=0;
4310 uint8_t transId = 0, ret = RFAILED;
4311 bool memAllocFailed =false;
4312 E2AP_PDU_t *e2apMsg = NULLP;
4313 RICserviceUpdate_t *ricServiceUpdate = NULLP;
4314 asn_enc_rval_t encRetVal; /* Encoder return value */
4316 DU_LOG("\nINFO --> E2AP : Building Ric Service Update\n");
4319 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
4320 if(e2apMsg == NULLP)
4322 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
4325 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
4326 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
4327 if(e2apMsg->choice.initiatingMessage == NULLP)
4329 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
4332 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
4333 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICserviceUpdate;
4334 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICserviceUpdate;
4335 ricServiceUpdate = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceUpdate;
4337 /* For TransId IE, set elementCnt to 1.
4338 If there is any item in the RAN function add list, RAN function modification list, or RAN function delete list, increment the elementCnt.*/
4341 if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded)
4343 if(serviceUpdate.recvRanFuncList.numOfRanFunToBeModified)
4345 if(serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted)
4348 ricServiceUpdate->protocolIEs.list.count = elementCnt;
4349 ricServiceUpdate->protocolIEs.list.size = elementCnt * sizeof(RICserviceUpdate_IEs_t*);
4351 /* Initialize the E2Setup members */
4352 DU_ALLOC(ricServiceUpdate->protocolIEs.list.array, ricServiceUpdate->protocolIEs.list.size);
4353 if(ricServiceUpdate->protocolIEs.list.array == NULLP)
4355 DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements");
4359 for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++)
4361 DU_ALLOC(ricServiceUpdate->protocolIEs.list.array[arrIdx], sizeof(RICserviceUpdate_IEs_t));
4362 if(ricServiceUpdate->protocolIEs.list.array[arrIdx] == NULLP)
4364 memAllocFailed = true;
4365 DU_LOG("\nERROR --> E2AP : Memory allocation failed for arrayIdx [%d]", arrIdx);
4369 if(memAllocFailed == true)
4375 ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
4376 ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
4377 ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_TransactionID;
4378 if(serviceUpdate.dir == E2_NODE_INITIATED)
4379 transId = assignTransactionId();
4381 transId = serviceUpdate.transId;
4382 ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId;
4384 if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded)
4387 ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAdded;
4388 ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
4389 ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List;
4390 if(BuildRanFunctionAddList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List,\
4391 e2apMsg->choice.initiatingMessage->procedureCode, serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded, serviceUpdate.recvRanFuncList.ranFunToBeAdded) !=ROK)
4397 if(serviceUpdate.recvRanFuncList.numOfRanFunToBeModified)
4400 ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsModified;
4401 ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
4402 ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List;
4403 if(BuildRanFunctionAddList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List,
4404 e2apMsg->choice.initiatingMessage->procedureCode, serviceUpdate.recvRanFuncList.numOfRanFunToBeModified, serviceUpdate.recvRanFuncList.ranFunToBeModified) !=ROK)
4410 if(serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted)
4413 ricServiceUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsDeleted;
4414 ricServiceUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
4415 ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdate_IEs__value_PR_RANfunctionsID_List;
4416 if(BuildRanFunctionDeleteList(&ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List,\
4417 serviceUpdate.recvRanFuncList.numOfRanFunToBeDeleted, serviceUpdate.recvRanFuncList.ranFunToBeDeleted) != ROK)
4422 /* Prints the Msg formed */
4423 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
4425 memset(encBuf, 0, ENC_BUF_MAX_LEN);
4427 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
4428 if(encRetVal.encoded == ENCODE_FAIL)
4430 DU_LOG("\nERROR --> E2AP : Could not encode RicServiceUpdateuest structure (at %s)\n",\
4431 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
4436 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RicServiceUpdateuest\n");
4437 #ifdef DEBUG_ASN_PRINT
4438 for(int i=0; i< encBufSize; i++)
4440 printf("%x",encBuf[i]);
4444 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
4446 DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed");
4455 if(serviceUpdate.dir == E2_NODE_INITIATED)
4457 duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
4458 duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
4462 duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].transactionId = transId;
4463 duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
4465 duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.dir = serviceUpdate.dir;
4466 duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.transId =transId;
4467 memcpy(&duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.ricService.recvRanFuncList, &serviceUpdate.recvRanFuncList, sizeof(E2TmpRanFunList));
4469 FreeRicServiceUpdate(e2apMsg);
4472 /******************************************************************
4474 * @brief Processes RIC service Query sent by RIC
4478 * Function : procRicServiceQuery
4480 * Functionality: Processes RIC service Query sent by RIC
4482 * @params[in] E2AP_PDU_t ASN decoded E2AP message
4483 * @return ROK - success
4486 * ****************************************************************/
4488 void procRicServiceQuery(E2AP_PDU_t *e2apMsg)
4491 uint16_t arrIdx =0, ranFuncIdx=0,tmpIdx=0;
4492 uint16_t id,revisionCcounter;
4493 bool tmpArray[MAX_RAN_FUNCTION] = {false};
4494 RICserviceQuery_t *ricServiceQuery=NULL;
4495 RicServiceUpdate ricUpdate;
4496 RANfunctionID_ItemIEs_t *ranFuncAddedItemIe;
4497 RANfunctionsID_List_t *ranFuncAddedList;
4499 DU_LOG("\nINFO --> E2AP : RIC Service Query received");
4500 memset(&ricUpdate, 0, sizeof(RicServiceUpdate));
4501 ricUpdate.dir = RIC_INITIATED;
4502 ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery;
4504 for(arrIdx=0; arrIdx<ricServiceQuery->protocolIEs.list.count; arrIdx++)
4506 switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id)
4508 /* TODO completing in next patch/gerrit */
4509 case ProtocolIE_IDE2_id_TransactionID:
4511 ricUpdate.transId = ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
4515 case ProtocolIE_IDE2_id_RANfunctionsAccepted:
4517 ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List;
4518 if(ranFuncAddedList->list.array)
4520 for(ranFuncIdx=0;ranFuncIdx<ranFuncAddedList->list.count; ranFuncIdx++)
4522 if(ranFuncAddedList->list.array[ranFuncIdx])
4524 /* Using the RAN function Id, identify the RAN function to be modified or deleted. */
4526 ranFuncAddedItemIe = (RANfunctionID_ItemIEs_t*)ranFuncAddedList->list.array[ranFuncIdx];
4527 id = ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID;
4528 revisionCcounter = ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision;
4530 if((id != duCb.e2apDb.ranFunction[id-1].id))
4532 action = CONFIG_DEL;
4534 else if((id == duCb.e2apDb.ranFunction[id-1].id)&&(revisionCcounter!=duCb.e2apDb.ranFunction[id-1].revisionCounter))
4536 action = CONFIG_MOD;
4539 if(action == CONFIG_DEL)
4541 ricUpdate.recvRanFuncList.ranFunToBeDeleted[ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted].id = id;
4542 ricUpdate.recvRanFuncList.ranFunToBeDeleted[ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted].revisionCounter = revisionCcounter;
4543 ricUpdate.recvRanFuncList.numOfRanFunToBeDeleted++;
4545 else if(action == CONFIG_MOD)
4547 ricUpdate.recvRanFuncList.ranFunToBeModified[ricUpdate.recvRanFuncList.numOfRanFunToBeModified].id = id;
4548 ricUpdate.recvRanFuncList.ranFunToBeModified[ricUpdate.recvRanFuncList.numOfRanFunToBeModified].revisionCounter = revisionCcounter;
4549 ricUpdate.recvRanFuncList.numOfRanFunToBeModified++;
4552 /* If any ID is set to true, it means that the ID has been used in either modification or deletion list.
4553 * Else we will add the IDs into the added list */
4554 tmpArray[id-1] = true;
4563 /* Traversing the whole RAN function list in ducb to check if any new Ran function ids have been added. */
4564 for(arrIdx =0; arrIdx<MAX_RAN_FUNCTION; arrIdx++)
4566 tmpIdx= ricUpdate.recvRanFuncList.numOfRanFunToBeAdded;
4567 if((duCb.e2apDb.ranFunction[arrIdx].id >0)&&(!tmpArray[arrIdx]))
4569 ricUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].id = duCb.e2apDb.ranFunction[arrIdx].id;
4570 ricUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].revisionCounter = duCb.e2apDb.ranFunction[arrIdx].revisionCounter;
4571 ricUpdate.recvRanFuncList.numOfRanFunToBeAdded++;
4575 if(BuildAndSendRicServiceUpdate(ricUpdate)!= ROK)
4577 DU_LOG("\nERROR --> E2AP : Failed to build and send ric service update message");
4580 freeAperDecodingOfRicServiceQuery(ricServiceQuery);
4583 /******************************************************************
4585 * @brief Deallocation of memory allocated by aper decoder for
4586 * RIC service update ack
4590 * Function : freeAperDecodingOfRicServiceUpdateAck
4592 * Functionality: Deallocation of memory allocated by aper decoder
4593 * for RIC service update ack
4595 * @params[in] RICserviceUpdateAck_t *ricServiceAck;
4598 * ****************************************************************/
4600 void freeAperDecodingOfRicServiceUpdateAck(RICserviceUpdateAcknowledge_t *ricServiceAck)
4602 uint8_t arrIdx=0,ranFuncIdx=0;
4603 RANfunctionsID_List_t *ranFuncAddedList=NULL;
4607 if(ricServiceAck->protocolIEs.list.array)
4609 for(arrIdx=0; arrIdx<ricServiceAck->protocolIEs.list.count; arrIdx++)
4611 if(ricServiceAck->protocolIEs.list.array[arrIdx])
4613 switch(ricServiceAck->protocolIEs.list.array[arrIdx]->id)
4615 case ProtocolIE_IDE2_id_RANfunctionsAccepted:
4617 ranFuncAddedList= &ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List;
4618 if(ranFuncAddedList->list.array)
4620 for(ranFuncIdx=0;ranFuncIdx<ranFuncAddedList->list.count; ranFuncIdx++)
4622 free(ranFuncAddedList->list.array[ranFuncIdx]);
4624 free(ranFuncAddedList->list.array);
4631 free(ricServiceAck->protocolIEs.list.array[arrIdx]);
4634 free(ricServiceAck->protocolIEs.list.array);
4639 /******************************************************************
4641 * @brief Processes RIC service update ack sent by RIC
4645 * Function : procRicServiceUpdateAck
4647 * Functionality: Processes RIC service update ack sent by RIC
4649 * @params[in] E2AP_PDU_t ASN decoded E2AP message
4650 * @return ROK - success
4653 * ****************************************************************/
4655 void procRicServiceUpdateAck(E2AP_PDU_t *e2apMsg)
4657 uint8_t arrIdx =0, transId =0;
4658 uint16_t id =0, tmpIdx=0, ranFuncIdx=0;
4659 RicServiceUpdate serviceUpdate;
4660 RANfunctionsIDcause_List_t *rejectedList=NULL;
4661 RICserviceUpdateAcknowledge_t *ricServiceAck=NULL;
4662 RANfunctionIDcause_ItemIEs_t *ranFuncRejectedItemIe=NULL;
4664 DU_LOG("\nINFO --> E2AP : RIC service update ack received");
4665 memset(&serviceUpdate, 0, sizeof(RicServiceUpdate));
4666 ricServiceAck = &e2apMsg->choice.successfulOutcome->value.choice.RICserviceUpdateAcknowledge;
4668 for(arrIdx=0; arrIdx<ricServiceAck->protocolIEs.list.count; arrIdx++)
4670 switch(ricServiceAck->protocolIEs.list.array[arrIdx]->id)
4672 case ProtocolIE_IDE2_id_TransactionID:
4674 transId = ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
4675 if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
4676 (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
4678 memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
4680 else if((duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].transactionId == transId) &&\
4681 (duCb.e2apDb.e2TransInfo.ricInitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
4683 memset(&duCb.e2apDb.e2TransInfo.ricInitTransaction[transId], 0, sizeof(E2TransInfo));
4687 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
4693 case ProtocolIE_IDE2_id_RANfunctionsAccepted:
4696 case ProtocolIE_IDE2_id_RANfunctionsRejected:
4698 rejectedList= &ricServiceAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsIDcause_List;
4699 if(rejectedList->list.array)
4701 for(ranFuncIdx=0;ranFuncIdx<rejectedList->list.count; ranFuncIdx++)
4703 ranFuncRejectedItemIe = (RANfunctionIDcause_ItemIEs_t*)rejectedList->list.array[ranFuncIdx];
4704 id = ranFuncRejectedItemIe->value.choice.RANfunctionIDcause_Item.ranFunctionID;
4705 tmpIdx= serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded;
4706 serviceUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].id = duCb.e2apDb.ranFunction[id-1].id;
4707 serviceUpdate.recvRanFuncList.ranFunToBeAdded[tmpIdx].revisionCounter = duCb.e2apDb.ranFunction[id-1].revisionCounter;
4708 serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded++;
4717 if(serviceUpdate.recvRanFuncList.numOfRanFunToBeAdded)
4719 serviceUpdate.dir = E2_NODE_INITIATED;
4720 BuildAndSendRicServiceUpdate(serviceUpdate);
4722 freeAperDecodingOfRicServiceUpdateAck(ricServiceAck);
4725 /******************************************************************
4727 * @brief Deallocation of memory allocated by aper decoder for
4728 * RIC service update failure
4732 * Function : freeAperDecodingOfRicServiceUpdateFailure
4734 * Functionality: Deallocation of memory allocated by aper decoder
4735 * for RIC service update failure
4737 * @params[in] RICserviceUpdateFailure_t *ricServiceFailure;
4740 * ****************************************************************/
4742 void freeAperDecodingOfRicServiceUpdateFailure(RICserviceUpdateFailure_t *ricServiceFailure)
4746 if(ricServiceFailure)
4748 if(ricServiceFailure->protocolIEs.list.array)
4750 for(arrIdx=0; arrIdx<ricServiceFailure->protocolIEs.list.count; arrIdx++)
4752 if(ricServiceFailure->protocolIEs.list.array[arrIdx])
4754 free(ricServiceFailure->protocolIEs.list.array[arrIdx]);
4757 free(ricServiceFailure->protocolIEs.list.array);
4762 /******************************************************************
4764 * @brief Processes RIC service update failure sent by RIC
4768 * Function : procRicServiceUpdateFailure
4770 * Functionality: Processes RIC service update failure sent by RIC
4772 * @params[in] E2AP_PDU_t ASN decoded E2AP message
4773 * @return ROK - success
4776 * ****************************************************************/
4778 void procRicServiceUpdateFailure(E2AP_PDU_t *e2apMsg)
4780 uint8_t arrIdx =0, timerValue=0;
4781 RICserviceUpdateFailure_t *ricServiceFailure=NULL;
4783 DU_LOG("\nINFO --> E2AP : RIC service update failure received");
4784 ricServiceFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICserviceUpdateFailure;
4786 for(arrIdx=0; arrIdx<ricServiceFailure->protocolIEs.list.count; arrIdx++)
4788 switch(ricServiceFailure->protocolIEs.list.array[arrIdx]->id)
4790 case ProtocolIE_IDE2_id_TransactionID:
4794 case ProtocolIE_IDE2_id_TimeToWaitE2:
4796 timerValue = convertE2WaitTimerEnumToValue(ricServiceFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2);
4797 if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer), EVENT_RIC_SERVICE_UPDATE_TMR)) == FALSE)
4799 duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer), EVENT_RIC_SERVICE_UPDATE_TMR, timerValue);
4803 DU_LOG("\nERROR --> E2AP : EVENT_RIC_SERVICE_UPDATE_TMR timer is already running");
4808 case ProtocolIE_IDE2_id_CauseE2:
4815 freeAperDecodingOfRicServiceUpdateFailure(ricServiceFailure);
4818 /******************************************************************
4820 * @brief DU Send E2 Node Configuration Update
4824 * Function : duSendE2NodeConfigurationUpdate
4826 * Functionality: DU Send E2 Node Configuration Update
4828 * @return ROK - success
4831 * ****************************************************************/
4833 uint8_t duSendE2NodeConfigurationUpdate()
4835 E2NodeConfigList e2NodeList;
4836 CmLList *node =NULL;
4837 E2NodeComponent *e2NodeComponentInfo=NULL;
4839 memset(&e2NodeList, 0, sizeof(E2NodeConfigList));
4840 CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node);
4843 e2NodeComponentInfo = (E2NodeComponent*)node->node;
4845 if(e2NodeComponentInfo->componentRequestPart && e2NodeComponentInfo->componentResponsePart)
4847 switch(e2NodeComponentInfo->componentActionType)
4849 case E2_NODE_COMPONENT_ADD:
4851 e2NodeList.addE2Node[e2NodeList.addE2NodeCount].interface = e2NodeComponentInfo->interfaceType;
4852 e2NodeList.addE2Node[e2NodeList.addE2NodeCount].actionType = e2NodeComponentInfo->componentActionType;
4853 e2NodeList.removeE2NodeCount++;
4856 case E2_NODE_COMPONENT_UPDATE:
4858 e2NodeList.updateE2Node[e2NodeList.updateE2NodeCount].interface = e2NodeComponentInfo->interfaceType;
4859 e2NodeList.updateE2Node[e2NodeList.updateE2NodeCount].actionType = e2NodeComponentInfo->componentActionType;
4860 e2NodeList.updateE2NodeCount++;
4864 case E2_NODE_COMPONENT_DEL:
4866 e2NodeList.removeE2Node[e2NodeList.removeE2NodeCount].interface = e2NodeComponentInfo->interfaceType;
4867 e2NodeList.removeE2Node[e2NodeList.removeE2NodeCount].actionType = e2NodeComponentInfo->componentActionType;
4868 e2NodeList.removeE2NodeCount++;
4876 if(BuildAndSendE2NodeConfigUpdate(&e2NodeList) !=ROK)
4878 DU_LOG("\nERROR --> E2AP : Failed to build and send e2 node config update message to RIC_stub");
4883 /*******************************************************************
4885 * @brief Handles received E2AP message and sends back response
4889 * Function : E2APMsgHdlr
4892 * - Decodes received E2AP control message
4893 * - Prepares response message, encodes and sends to SCTP
4896 * @return ROK - success
4899 * ****************************************************************/
4900 void E2APMsgHdlr(Buffer *mBuf)
4903 char *recvBuf = NULLP;
4905 MsgLen recvBufLen =0;
4906 E2AP_PDU_t *e2apMsg = NULLP;
4907 asn_dec_rval_t rval ={0}; /* Decoder return value */
4908 E2AP_PDU_t e2apasnmsg={0} ;
4910 DU_LOG("\nDEBUG --> E2AP : Received E2AP message buffer");
4911 ODU_PRINT_MSG(mBuf, 0,0);
4913 /* Copy mBuf into char array to decode it */
4914 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
4915 DU_ALLOC(recvBuf, (Size)recvBufLen);
4917 if(recvBuf == NULLP)
4919 DU_LOG("\nERROR --> E2AP : Memory allocation failed");
4922 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
4924 DU_LOG("\nERROR --> E2AP : Failed while copying %d", copyCnt);
4928 #ifdef DEBUG_ASN_PRINT
4929 printf("\nDEBUG --> E2AP : Received flat buffer to be decoded : ");
4930 for(i=0; i< recvBufLen; i++)
4932 printf("%x",recvBuf[i]);
4936 /* Decoding flat buffer into E2AP messsage */
4937 e2apMsg = &e2apasnmsg;
4938 memset(e2apMsg, 0, sizeof(E2AP_PDU_t));
4940 rval = aper_decode(0, &asn_DEF_E2AP_PDU, (void **)&e2apMsg, recvBuf, recvBufLen, 0, 0);
4941 DU_FREE(recvBuf, (Size)recvBufLen);
4943 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
4945 DU_LOG("\nERROR --> E2AP : ASN decode failed");
4949 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
4951 switch(e2apMsg->present)
4953 case E2AP_PDU_PR_unsuccessfulOutcome:
4955 switch(e2apMsg->choice.unsuccessfulOutcome->value.present)
4957 case UnsuccessfulOutcomeE2__value_PR_E2setupFailure:
4959 procE2SetupFailure(e2apMsg);
4962 case UnsuccessfulOutcomeE2__value_PR_E2nodeConfigurationUpdateFailure:
4964 procE2NodeConfigUpdateFailure(e2apMsg);
4967 case UnsuccessfulOutcomeE2__value_PR_RICserviceUpdateFailure:
4969 procRicServiceUpdateFailure(e2apMsg);
4974 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_unsuccessfulOutcome [%d]",\
4975 e2apMsg->choice.unsuccessfulOutcome->value.present);
4981 case E2AP_PDU_PR_successfulOutcome:
4983 switch(e2apMsg->choice.successfulOutcome->value.present)
4985 case SuccessfulOutcomeE2__value_PR_E2setupResponse:
4989 procE2SetupRsp(e2apMsg);
4993 case SuccessfulOutcomeE2__value_PR_E2nodeConfigurationUpdateAcknowledge:
4995 DU_LOG("\nDEBUG --> E2AP : E2 node Config update ack message recevied");
4998 case SuccessfulOutcomeE2__value_PR_ResetResponseE2:
5000 procResetResponse(e2apMsg);
5003 case SuccessfulOutcomeE2__value_PR_RICserviceUpdateAcknowledge:
5005 procRicServiceUpdateAck(e2apMsg);
5012 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_successfulOutcome [%d]",\
5013 e2apMsg->choice.successfulOutcome->value.present);
5016 }/* End of switch(successfulOutcome) */
5017 free(e2apMsg->choice.successfulOutcome);
5021 case E2AP_PDU_PR_initiatingMessage:
5023 switch(e2apMsg->choice.initiatingMessage->value.present)
5025 case InitiatingMessageE2__value_PR_RICsubscriptionRequest:
5027 procRicSubscriptionRequest(e2apMsg);
5030 case InitiatingMessageE2__value_PR_RICserviceQuery:
5032 procRicServiceQuery(e2apMsg);
5035 case InitiatingMessageE2__value_PR_ErrorIndicationE2:
5037 DU_LOG("\nINFO --> E2AP : Error indication received");
5042 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_initiatingMessage [%d]",\
5043 e2apMsg->choice.initiatingMessage->value.present);
5046 }/* End of switch(initiatingMessage) */
5047 free(e2apMsg->choice.initiatingMessage);
5052 DU_LOG("\nERROR --> E2AP : Invalid type of e2apMsg->present [%d]",e2apMsg->present);
5057 }/* End of switch(e2apMsg->present) */
5059 } /* End of E2APMsgHdlr */
5061 /**********************************************************************
5063 **********************************************************************/