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"
44 /*******************************************************************
46 * @brief Builds Global gNodeB Params
50 * Function : BuildGlobalgNBId
52 * Functionality: Building the Plmn and gNB id
54 * @params[in] GlobalE2node_gNB_ID_t *gNbId
55 * @return ROK - success
58 ******************************************************************/
60 uint8_t BuildGlobalgNBId(GlobalE2node_gNB_ID_t *gNbId)
67 /* Allocate Buffer size */
68 gNbId->global_gNB_ID.plmn_id.size = 3 * sizeof(uint8_t);
69 gNbId->global_gNB_ID.plmn_id.buf = NULLP;
70 DU_ALLOC(gNbId->global_gNB_ID.plmn_id.buf , gNbId->global_gNB_ID.plmn_id.size);
71 if(gNbId->global_gNB_ID.plmn_id.buf == NULLP)
73 DU_LOG("\nERROR --> E2AP: Memory allocation failed for Plmn buffer");
78 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
79 gNbId->global_gNB_ID.plmn_id.buf);
81 gNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID;
82 /* Allocate Buffer size */
83 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = byteSize * sizeof(uint8_t);
84 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf = NULLP;
85 DU_ALLOC(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf, \
86 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size);
87 if(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf == NULLP)
89 DU_LOG("\nERROR --> E2AP: Memory allocation failed for gnb buffer");
94 fillBitString(&gNbId->global_gNB_ID.gnb_id.choice.gnb_ID, unused, byteSize, gnbId);
100 /******************************************************************
102 * @brief Search E2 node component with the help of action type
106 * Function : searchE2NodeComponentInfo
108 * Functionality: Search E2 node component with the help of action type
110 * @params[in] uint8_t componentActionType
113 * ****************************************************************/
115 CmLList *searchE2NodeComponentInfo(InterfaceType interfaceType, uint8_t componentActionType)
117 E2NodeComponent *e2NodeComponentInfo;
120 if(duCb.e2apDb.e2NodeComponentList.count)
122 CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node);
125 e2NodeComponentInfo = (E2NodeComponent*)node->node;
126 if((e2NodeComponentInfo->interfaceType == interfaceType) && (e2NodeComponentInfo->componentActionType == componentActionType))
134 /*******************************************************************
136 * @brief Builds E2 node config addition list
140 * Function : BuildE2NodeConfigAddList
142 * Functionality: Building E2 node config addition list
144 * @params[in] E2nodeComponentConfigAddition_List_t *e2NodeAddList
145 * @return ROK - success
148 ******************************************************************/
150 uint8_t BuildE2NodeConfigAddList(E2nodeComponentConfigAddition_List_t *e2NodeAddList)
154 E2NodeComponent *e2NodeComponentInfo;
155 E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItemIe;
156 E2nodeComponentConfigAddition_Item_t *e2NodeAddItem;
158 e2NodeAddList->list.count = 1;
159 e2NodeAddList->list.size = e2NodeAddList->list.count * sizeof(E2nodeComponentConfigAddition_ItemIEs_t *);
160 DU_ALLOC(e2NodeAddList->list.array, e2NodeAddList->list.size);
161 if(e2NodeAddList->list.array == NULLP)
163 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
167 for(arrIdx = 0; arrIdx< e2NodeAddList->list.count; arrIdx++)
169 DU_ALLOC(e2NodeAddList->list.array[arrIdx], sizeof(E2nodeComponentConfigAddition_ItemIEs_t));
170 if(e2NodeAddList->list.array[arrIdx] == NULLP)
172 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
177 node = searchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD);
180 DU_LOG("\nERROR --> E2AP : Received e2NodeComponentInfo is null");
183 e2NodeComponentInfo = (E2NodeComponent*)node->node;
186 e2NodeAddItemIe = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[arrIdx];
187 e2NodeAddItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition_Item;
188 e2NodeAddItemIe->criticality = CriticalityE2_reject;
189 e2NodeAddItemIe->value.present = E2nodeComponentConfigAddition_ItemIEs__value_PR_E2nodeComponentConfigAddition_Item;
190 e2NodeAddItem = &e2NodeAddItemIe->value.choice.E2nodeComponentConfigAddition_Item;
192 /* E2nodeComponentInterfaceType */
193 e2NodeAddItem->e2nodeComponentInterfaceType = E2nodeComponentInterfaceType_f1;
195 /* E2 Node Component Request Part */
196 if(e2NodeComponentInfo->componentRequestPart)
198 e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.size = e2NodeComponentInfo->reqBufSize ;
199 DU_ALLOC(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\
200 e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.size);
201 if(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf == NULLP)
203 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
207 memcpy(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\
208 e2NodeComponentInfo->componentRequestPart, e2NodeAddItem->e2nodeComponentConfiguration.\
209 e2nodeComponentRequestPart.size);
213 DU_LOG("\nERROR --> E2AP: componentRequestPart is null ");
218 /* E2 Node Component Response Part */
219 if(e2NodeComponentInfo->componentResponsePart)
221 e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.size = e2NodeComponentInfo->rspBufSize;
222 DU_ALLOC(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf, \
223 e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.size);
224 if(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf == NULLP)
226 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
229 memcpy(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf, \
230 e2NodeComponentInfo->componentResponsePart, e2NodeAddItem->e2nodeComponentConfiguration.\
231 e2nodeComponentResponsePart.size);
235 DU_LOG("\nERROR --> E2AP: componentResponsePart is null");
239 /* E2 Node Component ID */
240 e2NodeAddItem->e2nodeComponentID.present = E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1;
241 DU_ALLOC(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1,\
242 sizeof(E2nodeComponentInterfaceF1_t));
243 if(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1 == NULLP)
245 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
248 e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size = sizeof(uint8_t);
249 DU_ALLOC(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\
250 e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size);
252 if(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf == NULLP)
254 DU_LOG("\nERROR -->list. E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
257 e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf[arrIdx] = e2NodeComponentInfo->componentId;
262 /*******************************************************************
264 * @brief De Allocate E2 Setup Request Message
268 * Function : FreeE2SetupReq
270 * Functionality: De-Allocating E2 Setup request Message
272 * @params[in] E2AP_PDU_t *e2apMsg
276 * ****************************************************************/
278 void FreeE2SetupReq(E2AP_PDU_t *e2apMsg)
281 uint8_t e2NodeAddListIdx =0;
282 E2setupRequest_t *e2SetupReq;
283 E2nodeComponentConfigAddition_List_t *e2NodeAddList;
284 E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem;
286 /* De-allocating Memory */
289 if(e2apMsg->choice.initiatingMessage != NULLP)
291 e2SetupReq = &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest;
292 if(e2SetupReq->protocolIEs.list.array != NULLP)
294 for(arrIdx = 0; arrIdx < e2SetupReq->protocolIEs.list.count; arrIdx++)
296 if(e2SetupReq->protocolIEs.list.array[arrIdx] != NULLP)
298 switch(e2SetupReq->protocolIEs.list.array[arrIdx]->id)
300 case ProtocolIE_IDE2_id_TransactionID:
302 case ProtocolIE_IDE2_id_GlobalE2node_ID:
304 if(e2SetupReq->protocolIEs.list.array[arrIdx]->\
305 value.choice.GlobalE2node_ID.choice.gNB != NULLP)
307 GlobalE2node_gNB_ID_t *gNbId = NULLP;
308 gNbId = e2SetupReq->protocolIEs.list.array[arrIdx]->\
309 value.choice.GlobalE2node_ID.choice.gNB;
310 if(gNbId->global_gNB_ID.plmn_id.buf != NULLP)
312 DU_FREE(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf,\
313 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size);
314 DU_FREE(gNbId->global_gNB_ID.plmn_id.buf,\
315 gNbId->global_gNB_ID.plmn_id.size);
317 DU_FREE(e2SetupReq->protocolIEs.list.array[arrIdx]->value.\
318 choice.GlobalE2node_ID.choice.gNB, sizeof(GlobalE2node_gNB_ID_t));
322 case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition:
324 e2NodeAddList = &e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List;
325 if(e2NodeAddList->list.array)
327 for(e2NodeAddListIdx = 0; e2NodeAddListIdx< e2NodeAddList->list.count; e2NodeAddListIdx++)
329 e2NodeAddItem = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[e2NodeAddListIdx];
331 /* Free E2 Node Component Request Part */
332 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\
333 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentRequestPart.size);
335 /* Free E2 Node Component Response Part */
336 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.\
337 e2nodeComponentResponsePart.buf, \
338 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentResponsePart.size);
340 /* Free E2 Node Component ID */
341 if(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1)
343 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
344 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\
345 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
346 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size);
347 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1,\
348 sizeof(E2nodeComponentInterfaceF1_t));
350 DU_FREE(e2NodeAddList->list.array[e2NodeAddListIdx], sizeof(E2nodeComponentConfigAddition_ItemIEs_t));
352 DU_FREE(e2NodeAddList->list.array, e2NodeAddList->list.size);
357 DU_LOG("\nERROR --> E2AP: Invalid event at e2SetupRequet %ld ",\
358 (e2SetupReq->protocolIEs.list.array[arrIdx]->id));
361 DU_FREE(e2SetupReq->protocolIEs.list.array[arrIdx], sizeof(E2setupRequestIEs_t));
364 DU_FREE(e2SetupReq->protocolIEs.list.array, e2SetupReq->protocolIEs.list.size);
366 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
368 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
372 /*******************************************************************
374 * @brief Builds and Send the E2SetupRequest
378 * Function : BuildAndSendE2SetupReq
380 * Functionality:Fills the E2SetupRequest
382 * @return ROK - success
385 ******************************************************************/
387 uint8_t BuildAndSendE2SetupReq()
389 uint8_t arrIdx = 0, elementCnt=0;
390 uint8_t transId = 0, ret = ROK;
392 E2AP_PDU_t *e2apMsg = NULLP;
393 E2setupRequest_t *e2SetupReq = NULLP;
394 asn_enc_rval_t encRetVal; /* Encoder return value */
396 DU_LOG("\nINFO --> E2AP : Building E2 Setup Request\n");
399 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
402 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
405 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
406 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
407 if(e2apMsg->choice.initiatingMessage == NULLP)
409 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
412 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
413 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2setup;
414 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_E2setupRequest;
415 e2SetupReq = &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest;
418 e2SetupReq->protocolIEs.list.count = elementCnt;
419 e2SetupReq->protocolIEs.list.size = elementCnt * sizeof(E2setupRequestIEs_t*);
421 /* Initialize the E2Setup members */
422 DU_ALLOC(e2SetupReq->protocolIEs.list.array, \
423 e2SetupReq->protocolIEs.list.size);
424 if(e2SetupReq->protocolIEs.list.array == NULLP)
426 DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements");
429 for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++)
431 DU_ALLOC(e2SetupReq->protocolIEs.list.array[arrIdx],\
432 sizeof(E2setupRequestIEs_t));
433 if(e2SetupReq->protocolIEs.list.array[arrIdx] == NULLP)
435 memAllocFailed = true;
436 DU_LOG("\nERROR --> E2AP : Memory allocation failed for arrayarrIdx [%d]", arrIdx);
440 if(memAllocFailed == true)
446 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
447 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
448 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_TransactionID;
449 transId = assignTransactionId();
450 e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId;
453 /* GlobalE2node_gNB_ID */
454 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_GlobalE2node_ID;
455 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
456 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_GlobalE2node_ID;
457 e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.GlobalE2node_ID.present = GlobalE2node_ID_PR_gNB;
459 DU_ALLOC(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.\
460 GlobalE2node_ID.choice.gNB, sizeof(GlobalE2node_gNB_ID_t));
461 if(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.\
462 GlobalE2node_ID.choice.gNB == NULLP)
464 DU_LOG("\nERROR --> E2AP : Memory allocation failed for gNbId");
469 ret = BuildGlobalgNBId(e2SetupReq->protocolIEs.list.array[arrIdx]->value.\
470 choice.GlobalE2node_ID.choice.gNB);
473 DU_LOG("\nERROR --> E2AP : Failed to build Global Gnb Id");
479 /* E2 Node Component Configuration Addition List */
480 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition;
481 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
482 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_E2nodeComponentConfigAddition_List;
483 if(BuildE2NodeConfigAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List))!=ROK)
485 DU_LOG("\nERROR --> E2AP : Failed to E2 Node config addition list");
491 /* Prints the Msg formed */
492 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
494 memset(encBuf, 0, ENC_BUF_MAX_LEN);
496 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
498 if(encRetVal.encoded == ENCODE_FAIL)
500 DU_LOG("\nERROR --> E2AP : Could not encode E2SetupRequest structure (at %s)\n",\
501 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
506 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SetupRequest\n");
507 #ifdef DEBUG_ASN_PRINT
508 for(int i=0; i< encBufSize; i++)
510 printf("%x",encBuf[i]);
514 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
516 DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed");
521 duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId;
522 duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
524 FreeE2SetupReq(e2apMsg);
526 }/* End of BuildAndSendE2SetupReq */
528 /*******************************************************************
530 * @brief Builds Ric Request Id
534 * Function : BuildRicRequestId
536 * Functionality: Building the Ric Request Id
538 * @params[in] RICrequestID_t *ricReqId
539 * @return ROK - success
542 * ****************************************************************/
544 uint8_t BuildRicRequestId(RICrequestID_t *ricReqId)
546 if(ricReqId == NULLP)
551 ricReqId->ricRequestorID = 1;
552 ricReqId->ricInstanceID = 1;
556 /*******************************************************************
558 * @brief Fills the mandatory RicAdmitted List Items
562 * Function : fillRicAdmitList
564 * Functionality: Fills the mandatory Ric Admitted List Items
566 * @params[in] RICaction_Admitted_ItemIEs_t *ricAdmitItems
567 * @return ROK - success
570 * ****************************************************************/
572 uint8_t fillRicAdmitList(RICaction_Admitted_ItemIEs_t *ricAdmitItems)
575 if(ricAdmitItems != NULLP)
577 ricAdmitItems->id = ProtocolIE_IDE2_id_RICaction_Admitted_Item;
578 ricAdmitItems->criticality = CriticalityE2_reject;
579 ricAdmitItems->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item;
580 ricAdmitItems->value.choice.RICaction_Admitted_Item.ricActionID = 1;
588 /*******************************************************************
590 * @brief Builds the mandatory RicAdmitted List Params
594 * Function : BuildRicAdmitList
596 * Functionality: Builds the mandatory Ric Admitted List Params
598 * @params[in] RICaction_Admitted_List_t *admitListPtr
599 * @return ROK - success
602 * ****************************************************************/
604 uint8_t BuildRicAdmitList(RICaction_Admitted_List_t *admitListPtr)
611 if(admitListPtr == NULLP)
613 DU_LOG("\nERROR --> E2AP : Memory allocation for RIC Admit List failed");
618 admitListPtr->list.count = elementCnt;
619 admitListPtr->list.size = elementCnt * sizeof(RICaction_Admitted_ItemIEs_t);
620 DU_ALLOC(admitListPtr->list.array, admitListPtr->list.size);
621 if(admitListPtr->list.array == NULLP)
623 DU_LOG("\nERROR --> E2AP : Memory allocation for RIC Admit List failed");
628 for(idx=0 ; idx<elementCnt ; idx++ )
630 DU_ALLOC(admitListPtr->list.array[idx], sizeof(RICaction_Admitted_ItemIEs_t));
631 if(admitListPtr->list.array[idx] == NULLP)
639 fillRicAdmitList((RICaction_Admitted_ItemIEs_t *)admitListPtr->list.array[idx]);
645 /*******************************************************************
647 * @breif Deallocation of BuildAndSendRicSubscriptionRsp memory
651 * Function : FreeRicSubscriptionRsp
653 * Functionality:Free the RicSubscriptionRsp
655 * @param[in] E2AP_PDU_t *e2apRicMsg
660 ******************************************************************/
661 void FreeRicSubscriptionRsp(E2AP_PDU_t *e2apRicMsg)
663 RICsubscriptionResponse_t *ricSubscriptionRsp= NULLP;
666 RICaction_Admitted_List_t *admitListPtr;
668 if(e2apRicMsg != NULLP)
670 if(e2apRicMsg->choice.successfulOutcome != NULLP)
672 ricSubscriptionRsp = &e2apRicMsg->choice.successfulOutcome->value.choice.RICsubscriptionResponse;
673 if(ricSubscriptionRsp)
675 if(ricSubscriptionRsp->protocolIEs.list.array != NULLP)
677 for(idx=0; idx<ricSubscriptionRsp->protocolIEs.list.count; idx++)
679 if(ricSubscriptionRsp->protocolIEs.list.array[idx] != NULLP)
681 switch(ricSubscriptionRsp->protocolIEs.list.array[idx]->id)
683 case ProtocolIE_IDE2_id_RICrequestID:
686 case ProtocolIE_IDE2_id_RANfunctionID:
689 case ProtocolIE_IDE2_id_RICactions_Admitted:
691 admitListPtr = &ricSubscriptionRsp->protocolIEs.list.\
692 array[idx]->value.choice.RICaction_Admitted_List;
693 if(admitListPtr->list.array != NULLP)
695 for(idx1=0 ; idx1<admitListPtr->list.count; idx1++ )
697 if(admitListPtr->list.array[idx1] != NULLP)
699 DU_FREE(admitListPtr->list.array[idx1],
700 sizeof(RICaction_Admitted_ItemIEs_t));
703 DU_FREE(admitListPtr->list.array, admitListPtr->list.size);
710 DU_FREE(ricSubscriptionRsp->protocolIEs.list.array[idx], \
711 sizeof(RICsubscriptionResponse_IEs_t));
714 DU_FREE(ricSubscriptionRsp->protocolIEs.list.array, \
715 ricSubscriptionRsp->protocolIEs.list.size);
718 DU_FREE(e2apRicMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
720 DU_FREE(e2apRicMsg, sizeof(E2AP_PDU_t));
723 /*******************************************************************
725 * @brief Builds and Send the RicSubscriptionRsp
729 * Function : BuildAndSendRicSubscriptionRsp
731 * functionality:Fills the RicSubscriptionRsp
733 * @return ROK - success
736 ******************************************************************/
737 uint8_t FillRicSubscriptionRsp(RICsubscriptionResponse_t *ricSubscriptionRsp )
741 uint8_t elementCnt = 0;
742 uint8_t BuildRicRequestIdret=ROK;
743 uint8_t BuildRicAdmitListret=ROK;
746 ricSubscriptionRsp->protocolIEs.list.count = elementCnt;
747 ricSubscriptionRsp->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionResponse_IEs_t);
748 DU_ALLOC(ricSubscriptionRsp->protocolIEs.list.array, \
749 ricSubscriptionRsp->protocolIEs.list.size);
750 if(ricSubscriptionRsp->protocolIEs.list.array == NULLP)
752 DU_LOG("\nERROR --> E2AP : Memory allocation for FillRicSubscriptionRsp failed");
757 for(idx=0; idx<ricSubscriptionRsp->protocolIEs.list.count; idx++)
759 DU_ALLOC(ricSubscriptionRsp->protocolIEs.list.array[idx], \
760 sizeof(RICsubscriptionResponse_IEs_t));
761 if(ricSubscriptionRsp->protocolIEs.list.array[idx] == NULLP)
770 ricSubscriptionRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICrequestID;
771 ricSubscriptionRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
772 ricSubscriptionRsp->protocolIEs.list.array[idx]->value.present =\
773 RICsubscriptionRequest_IEs__value_PR_RICrequestID;
774 BuildRicRequestIdret =
775 BuildRicRequestId(&ricSubscriptionRsp->protocolIEs.list.array[idx]->value.choice.RICrequestID);
776 if(BuildRicRequestIdret != ROK)
783 ricSubscriptionRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionID;
784 ricSubscriptionRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
785 ricSubscriptionRsp->protocolIEs.list.array[idx]->value.present =\
786 RICsubscriptionRequest_IEs__value_PR_RANfunctionID;
787 ricSubscriptionRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionID = 1;
790 ricSubscriptionRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICactions_Admitted;
791 ricSubscriptionRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
792 ricSubscriptionRsp->protocolIEs.list.array[idx]->value.present =\
793 RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List;
794 BuildRicAdmitListret =
795 BuildRicAdmitList(&ricSubscriptionRsp->protocolIEs.list.array[idx]->value.choice.RICaction_Admitted_List);
796 if(BuildRicAdmitListret != ROK)
805 /*******************************************************************
807 * @brief Builds and Send the RicSubscriptionRsp
811 * Function : BuildAndSendRicSubscriptionRsp
813 * Functionality:Fills the RicSubscriptionRsp
815 * @return ROK - success
818 ******************************************************************/
820 uint8_t BuildAndSendRicSubscriptionRsp()
823 E2AP_PDU_t *e2apRicMsg = NULLP;
824 RICsubscriptionResponse_t *ricSubscriptionRsp=NULLP;
825 asn_enc_rval_t encRetVal;
826 uint8_t ret = RFAILED;
827 uint8_t FillRicricSubscriptionRspret;
831 DU_LOG("\nINFO --> E2AP : Building RIC Subscription Response\n");
833 DU_ALLOC(e2apRicMsg, sizeof(E2AP_PDU_t));
834 if(e2apRicMsg == NULLP)
836 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
839 e2apRicMsg->present = E2AP_PDU_PR_successfulOutcome;
840 DU_ALLOC(e2apRicMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
841 if(e2apRicMsg->choice.successfulOutcome == NULLP)
843 DU_LOG("\nERROR --> E2AP : Memory allocation for RIC subscription Response failed");
847 e2apRicMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_RICsubscription;
848 e2apRicMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
849 e2apRicMsg->choice.successfulOutcome->value.present = \
850 SuccessfulOutcomeE2__value_PR_RICsubscriptionResponse;
851 ricSubscriptionRsp = &e2apRicMsg->choice.successfulOutcome->value.choice.RICsubscriptionResponse;
853 FillRicricSubscriptionRspret = FillRicSubscriptionRsp(ricSubscriptionRsp);
854 if(FillRicricSubscriptionRspret != ROK)
856 DU_LOG("\nERROR --> E2AP : Memory allocation for RICsubscriptionResponseIE failed");
860 /* Prints the Msg formed */
861 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apRicMsg);
863 memset(encBuf, 0, ENC_BUF_MAX_LEN);
865 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apRicMsg, PrepFinalEncBuf,\
867 if(encRetVal.encoded == ENCODE_FAIL)
869 DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Response structure (at %s)\n",\
870 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
875 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC subscription response \n");
876 #ifdef DEBUG_ASN_PRINT
877 for(int i=0; i< encBufSize; i++)
879 printf("%x",encBuf[i]);
884 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
886 DU_LOG("\nERROR --> E2AP : Sending RIC Subscription Response failed");
894 FreeRicSubscriptionRsp(e2apRicMsg);
899 /******************************************************************
901 * @brief Deallocation of memory allocated bu aper decoder for e2 setup response
905 * Function : freeAperDecodingOfE2SetupRsp
907 * Functionality: Deallocation of memory allocated bu aper decoder for e2
910 * @params[in] E2setupResponse_t *e2SetRspMsg;
913 * ****************************************************************/
914 void freeAperDecodingOfE2SetupRsp(E2setupResponse_t *e2SetRspMsg)
916 uint8_t arrIdx, e2NodeConfigAddAckListIdx;
917 E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAddAckItem;
918 E2nodeComponentConfigAdditionAck_List_t *e2NodeConfigAddAckList;
922 if(e2SetRspMsg->protocolIEs.list.array)
924 for(arrIdx=0; arrIdx<e2SetRspMsg->protocolIEs.list.count; arrIdx++)
926 if(e2SetRspMsg->protocolIEs.list.array[arrIdx])
928 switch(e2SetRspMsg->protocolIEs.list.array[arrIdx]->id)
930 case ProtocolIE_IDE2_id_TransactionID:
933 case ProtocolIE_IDE2_id_GlobalRIC_ID:
935 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.pLMN_Identity.buf);
936 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.ric_ID.buf);
940 case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
942 e2NodeConfigAddAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List;
943 if(e2NodeConfigAddAckList->list.array )
945 for(e2NodeConfigAddAckListIdx = 0; e2NodeConfigAddAckListIdx< e2NodeConfigAddAckList->list.count; e2NodeConfigAddAckListIdx++)
947 if(e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx])
949 e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx];
950 free(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.choice.\
951 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf);
952 free(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.choice.\
953 e2nodeComponentInterfaceTypeF1);
954 free(e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx]);
957 free(e2NodeConfigAddAckList->list.array);
962 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]);
965 free(e2SetRspMsg->protocolIEs.list.array);
969 /******************************************************************
971 * @brief Processes E2 Setup Response sent by RIC
975 * Function : procE2SetupRsp
977 * Functionality: Processes E2 Setup Response sent by RIC
979 * @params[in] E2AP_PDU_t ASN decoded E2AP message
980 * @return ROK - success
983 * ****************************************************************/
984 uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg)
986 uint8_t arrIdx =0, transId=0;
988 E2setupResponse_t *e2SetRspMsg;
990 E2NodeComponent *e2NodeComponentInfo;
992 DU_LOG("\nINFO --> E2AP : E2 Setup Response received");
993 duCb.e2Status = TRUE; //Set E2 status as true
994 e2SetRspMsg = &e2apMsg->choice.successfulOutcome->value.choice.E2setupResponse;
996 for(arrIdx=0; arrIdx<e2SetRspMsg->protocolIEs.list.count; arrIdx++)
998 switch(e2SetRspMsg->protocolIEs.list.array[arrIdx]->id)
1000 case ProtocolIE_IDE2_id_TransactionID:
1002 transId = e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
1003 if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\
1004 (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
1005 memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
1008 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
1014 case ProtocolIE_IDE2_id_GlobalRIC_ID:
1016 /* To store the Ric Id Params */
1017 recvBufLen = sizeof(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value\
1018 .choice.GlobalRIC_ID.pLMN_Identity.size);
1019 memcpy(&duCb.e2apDb.ricId.plmnId, e2SetRspMsg->protocolIEs.list.array[arrIdx]\
1020 ->value.choice.GlobalRIC_ID.pLMN_Identity.buf, recvBufLen);
1021 bitStringToInt(&e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.ric_ID, &duCb.e2apDb.ricId);
1022 /*TODO : duCb.e2apDb.ricId.plmnId memory to be deallocated after the usage */
1026 case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
1030 DU_LOG("\nERROR --> E2AP : Invalid IE received in E2SetupRsp:%ld",
1031 e2SetRspMsg->protocolIEs.list.array[arrIdx]->id);
1035 freeAperDecodingOfE2SetupRsp(e2SetRspMsg);
1037 node = searchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD);
1040 DU_LOG("\nERROR --> E2AP : Received e2NodeComponentInfo is null");
1045 e2NodeComponentInfo = (E2NodeComponent*)node->node;
1046 cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node);
1047 DU_FREE(e2NodeComponentInfo->componentRequestPart, e2NodeComponentInfo->reqBufSize);
1048 DU_FREE(e2NodeComponentInfo->componentResponsePart, e2NodeComponentInfo->rspBufSize);
1049 DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
1050 DU_FREE(node, sizeof(CmLList));
1053 BuildAndSendE2NodeConfigUpdate();
1057 /******************************************************************
1059 * @brief Processes RIC Subscription Req sent by RIC
1063 * Function : procRicSubsReq
1065 * Functionality: Processes E2 Setup Response sent by CU
1067 * @params[in] E2AP_PDU_t ASN decoded E2AP message
1068 * @return ROK - success
1071 * ****************************************************************/
1073 uint8_t procRicSubsReq(E2AP_PDU_t *e2apMsg)
1078 CmLList *ricSubscriptionNode = NULLP;
1079 RICsubscriptionRequest_t *ricSubsReq;
1080 RicSubscription *ricSubscriptionInfo;
1081 RICaction_ToBeSetup_ItemIEs_t *actionItem;
1083 DU_LOG("\nINFO --> E2AP : RIC Subscription request received");
1084 ricSubsReq = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionRequest;
1086 for(idx=0; idx<ricSubsReq->protocolIEs.list.count; idx++)
1088 if(ricSubsReq->protocolIEs.list.array[idx])
1090 switch(ricSubsReq->protocolIEs.list.array[idx]->id)
1092 case ProtocolIE_IDE2_id_RICrequestID:
1094 /* TODO :- ricSubscriptionInfo details will be stored based on
1095 * RAN function id, so first we need to search RAN function and then add
1096 * subscription details to that ran function */
1097 DU_ALLOC(ricSubscriptionInfo, sizeof(RicSubscription));
1098 if(!ricSubscriptionInfo)
1100 DU_LOG("\nERROR --> E2AP : Memory allocation failed for ricSubscriptionInfo");
1103 ricSubscriptionInfo->requestId.requestorId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID;
1104 ricSubscriptionInfo->requestId.instanceId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID;
1105 DU_ALLOC(ricSubscriptionNode, sizeof(CmLList));
1106 if(ricSubscriptionNode)
1108 ricSubscriptionNode->node = (PTR) ricSubscriptionInfo;
1109 cmLListAdd2Tail(&duCb.e2apDb.ranFunction[0].subscriptionList,ricSubscriptionNode);
1113 case ProtocolIE_IDE2_id_RANfunctionID:
1115 duCb.e2apDb.ranFunction[0].id = ricSubsReq->protocolIEs.list.array[idx]-> \
1116 value.choice.RANfunctionID;
1119 case ProtocolIE_IDE2_id_RICsubscriptionDetails:
1121 if(ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.\
1124 actionItem =(RICaction_ToBeSetup_ItemIEs_t *)ricSubsReq->protocolIEs.list\
1125 .array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List\
1128 for(ied = 0; ied < ricSubsReq->protocolIEs.list.array[idx]->value.choice.\
1129 RICsubscriptionDetails.ricAction_ToBeSetup_List.list.count; ied++)
1131 switch(actionItem->id)
1133 case ProtocolIE_IDE2_id_RICaction_ToBeSetup_Item:
1135 ricSubscriptionInfo->actionSequence[0].id = actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionID;
1136 ricSubscriptionInfo->actionSequence[0].type = actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionType;
1140 DU_LOG("\nERROR --> E2AP : Invalid IE received in RicSetupLst:%ld",actionItem->id);
1145 free(ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.\
1152 DU_LOG("\nERROR --> E2AP : Invalid IE received in RIC SubsReq:%ld",
1153 ricSubsReq->protocolIEs.list.array[idx]->id);
1156 free(ricSubsReq->protocolIEs.list.array[idx]);
1159 free(ricSubsReq->protocolIEs.list.array);
1160 ret = BuildAndSendRicSubscriptionRsp();
1162 BuildAndSendRicIndication(ricSubscriptionInfo);
1168 /*******************************************************************
1170 * @brief Free the RicIndication Message
1174 * Function : FreeRicIndication
1176 * Functionality: Free the RicIndication Message
1181 ******************************************************************/
1182 void FreeRicIndication(E2AP_PDU_t *e2apMsg)
1185 RICindication_t *ricIndicationMsg= NULLP;
1188 if(e2apMsg != NULLP)
1190 if(e2apMsg->choice.initiatingMessage != NULLP)
1192 ricIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.RICindication;
1193 if(ricIndicationMsg!= NULLP)
1195 if(ricIndicationMsg->protocolIEs.list.array != NULLP)
1197 for(idx=0; idx<ricIndicationMsg->protocolIEs.list.count; idx++)
1199 if(ricIndicationMsg->protocolIEs.list.array[idx] != NULLP)
1201 switch(ricIndicationMsg->protocolIEs.list.array[idx]->id)
1203 case ProtocolIE_IDE2_id_RICrequestID:
1206 case ProtocolIE_IDE2_id_RANfunctionID:
1209 case ProtocolIE_IDE2_id_RICactionID:
1212 case ProtocolIE_IDE2_id_RICindicationType:
1215 case ProtocolIE_IDE2_id_RICindicationHeader:
1217 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf,\
1218 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size);
1221 case ProtocolIE_IDE2_id_RICindicationMessage:
1223 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf,\
1224 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size);
1230 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx],sizeof(RICindication_IEs_t));
1233 DU_FREE(ricIndicationMsg->protocolIEs.list.array,ricIndicationMsg->protocolIEs.list.size);
1236 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1238 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
1241 /*******************************************************************
1243 * brief Fill the RicIndication Message
1247 * Function : FillRicIndication
1249 * Functionality:Fills the RicIndication Message
1251 * @return ROK - success
1254 ******************************************************************/
1255 uint8_t FillRicIndication(RICindication_t *ricIndicationMsg, RicSubscription *ricSubscriptionInfo)
1257 uint8_t elementCnt=0;
1262 ricIndicationMsg->protocolIEs.list.count = elementCnt;
1263 ricIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(RICindication_t);
1264 /* Initialize the Ric Indication members */
1265 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array, \
1266 ricIndicationMsg->protocolIEs.list.size);
1267 if(ricIndicationMsg->protocolIEs.list.array == NULLP)
1269 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
1274 for(idx=0; idx<elementCnt; idx++)
1276 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx],\
1277 sizeof(RICindication_IEs_t));
1278 if(ricIndicationMsg->protocolIEs.list.array[idx] == NULLP)
1280 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
1288 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICrequestID;
1289 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1290 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1291 RICindication_IEs__value_PR_RICrequestID;
1292 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID =ricSubscriptionInfo->requestId.requestorId;
1293 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID = ricSubscriptionInfo->requestId.instanceId;
1296 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionID;
1297 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1298 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1299 RICindication_IEs__value_PR_RANfunctionID;
1300 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RANfunctionID = duCb.e2apDb.ranFunction[0].id;
1303 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICactionID;
1304 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1305 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1306 RICindication_IEs__value_PR_RICactionID;
1307 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICactionID = ricSubscriptionInfo->actionSequence[0].id;
1310 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationType;
1311 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1312 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1313 RICindication_IEs__value_PR_RICindicationType;
1314 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationType = ricSubscriptionInfo->actionSequence[0].type;
1317 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationHeader;
1318 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1319 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1320 RICindication_IEs__value_PR_RICindicationHeader;
1321 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size = 3 *
1323 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf ,\
1324 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size);
1325 if(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf == NULLP)
1327 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
1332 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
1333 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf);
1335 /* TO BE CHANGED: RIC INDICATION DATA */
1336 /* For now filling a dummy octect data, need to tested with PRBs*/
1337 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationMessage;
1338 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1339 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1340 RICindication_IEs__value_PR_RICindicationMessage;
1341 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size = 3 *
1343 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf ,\
1344 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size);
1345 if(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf == NULLP)
1347 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
1352 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
1353 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf);
1361 /*******************************************************************
1363 * @brief Builds and Send the RicIndication Message
1367 * Function : BuildAndSendRicIndication
1369 * Functionality:Fills the RicIndication Message
1371 * @return ROK - success
1374 ******************************************************************/
1376 uint8_t BuildAndSendRicIndication(RicSubscription *ricSubscriptionInfo)
1378 E2AP_PDU_t *e2apMsg = NULLP;
1379 RICindication_t *ricIndicationMsg=NULLP;
1380 asn_enc_rval_t encRetVal; /* Encoder return value */
1381 uint8_t ret = RFAILED;
1382 uint8_t FillRicIndicationret = ROK;
1386 DU_LOG("\nINFO --> E2AP : Building RIC Indication Message\n");
1388 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
1389 if(e2apMsg == NULLP)
1391 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1395 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
1396 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1397 if(e2apMsg->choice.initiatingMessage == NULLP)
1399 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1402 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICindication;
1403 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
1404 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICindication;
1406 ricIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.RICindication;
1408 FillRicIndicationret = FillRicIndication(ricIndicationMsg, ricSubscriptionInfo);
1409 if(FillRicIndicationret != ROK)
1413 /* Prints the Msg formed */
1414 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
1415 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1417 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
1419 if(encRetVal.encoded == ENCODE_FAIL)
1421 DU_LOG("\nERROR --> E2AP : Could not encode RIC Indication Message (at %s)\n",\
1422 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1427 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Indication Message \n");
1428 #ifdef DEBUG_ASN_PRINT
1429 for(int i=0; i< encBufSize; i++)
1431 printf("%x",encBuf[i]);
1436 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
1438 DU_LOG("\nINFO --> E2AP : Sending RIC Indication Message");
1444 FreeRicIndication(e2apMsg);
1448 /*******************************************************************
1450 * @brief Deallocate the memory allocated for E2nodeConfigurationUpdate msg
1454 * Function : FreeE2NodeConfigUpdate
1457 * - freeing the memory allocated for E2nodeConfigurationUpdate
1459 * @params[in] E2AP_PDU_t *e2apMsg
1460 * @return ROK - success
1463 * ****************************************************************/
1464 void FreeE2NodeConfigUpdate(E2AP_PDU_t *e2apMsg)
1467 E2nodeConfigurationUpdate_t *e2NodeConfigUpdate;
1469 if(e2apMsg != NULLP)
1471 if(e2apMsg->choice.initiatingMessage != NULLP)
1473 e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate;
1474 if(e2NodeConfigUpdate->protocolIEs.list.array != NULLP)
1476 for(arrIdx = 0; arrIdx < e2NodeConfigUpdate->protocolIEs.list.count; arrIdx++)
1478 DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t));
1480 DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size);
1482 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1484 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
1488 /*******************************************************************
1490 * @brief Buld and send the E2 node config update msg
1494 * Function : BuildAndSendE2NodeConfigUpdate
1497 * - Buld and send the E2 node config update msg
1500 * @return ROK - success
1503 * ****************************************************************/
1505 uint8_t BuildAndSendE2NodeConfigUpdate()
1507 uint8_t arrIdx = 0,elementCnt = 1;
1509 E2AP_PDU_t *e2apMsg = NULLP;
1510 E2nodeConfigurationUpdate_t *e2NodeConfigUpdate = NULLP;
1511 asn_enc_rval_t encRetVal; /* Encoder return value */
1513 DU_LOG("\nINFO --> E2AP : Building E2 Node config update\n");
1516 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
1517 if(e2apMsg == NULLP)
1519 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1522 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
1523 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1524 if(e2apMsg->choice.initiatingMessage == NULLP)
1526 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1527 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
1530 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
1531 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2nodeConfigurationUpdate;
1532 e2apMsg->choice.initiatingMessage->value.present = \
1533 InitiatingMessageE2__value_PR_E2nodeConfigurationUpdate;
1534 e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate;
1536 e2NodeConfigUpdate->protocolIEs.list.count = elementCnt;
1537 e2NodeConfigUpdate->protocolIEs.list.size = elementCnt * sizeof(E2nodeConfigurationUpdate_IEs_t*);
1538 /* Initialize the Ric Indication members */
1539 DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array, \
1540 e2NodeConfigUpdate->protocolIEs.list.size);
1541 if(e2NodeConfigUpdate->protocolIEs.list.array == NULLP)
1543 DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed");
1547 for(arrIdx =0; arrIdx<elementCnt; arrIdx++)
1549 DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t));
1550 if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx] == NULLP)
1553 DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed");
1560 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
1561 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
1562 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_TransactionID;
1563 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = TRANS_ID;
1566 /* Prints the Msg formed */
1567 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
1569 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1571 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
1573 if(encRetVal.encoded == ENCODE_FAIL)
1575 DU_LOG("\nERROR --> E2AP : Could not encode E2nodeConfigurationUpdate structure (at %s)\n",\
1576 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1581 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2nodeConfigurationUpdate\n");
1582 #ifdef DEBUG_ASN_PRINT
1583 for(int i=0; i< encBufSize; i++)
1585 printf("%x",encBuf[i]);
1589 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize))
1591 DU_LOG("\nERROR --> E2AP : Sending E2 node config update failed");
1598 FreeE2NodeConfigUpdate(e2apMsg);
1602 /*******************************************************************
1604 * @brief Deallocate the memory allocated for E2ResetRequest msg
1608 * Function : FreeE2ResetRequest
1611 * - freeing the memory allocated for E2ResetRequest
1613 * @params[in] E2AP_PDU_t *e2apMsg
1614 * @return ROK - success
1617 * ****************************************************************/
1618 void FreeE2ResetRequest(E2AP_PDU_t *e2apMsg)
1621 ResetRequestE2_t *resetReq = NULLP;
1623 if(e2apMsg != NULLP)
1625 if(e2apMsg->choice.initiatingMessage != NULLP)
1627 resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2;
1628 if(resetReq->protocolIEs.list.array)
1630 for(ieIdx = 0; ieIdx < resetReq->protocolIEs.list.count; ieIdx++)
1632 DU_FREE(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t));
1634 DU_FREE(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size);
1636 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1638 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
1642 /*******************************************************************
1644 * @brief Build and send the E2 reset request msg
1648 * Function : BuildAndSendE2ResetRequest
1651 * - Buld and send the E2 reset request msg to RIC
1654 * @return ROK - success
1657 * ****************************************************************/
1658 uint8_t BuildAndSendE2ResetRequest(E2CauseType failureType, E2Cause failureCause)
1660 uint8_t ieIdx = 0, elementCnt = 0, transId = 0;
1661 uint8_t ret = RFAILED;
1662 E2AP_PDU_t *e2apMsg = NULLP;
1663 ResetRequestE2_t *resetReq = NULLP;
1664 asn_enc_rval_t encRetVal; /* Encoder return value */
1666 DU_LOG("\nINFO --> E2AP : Building E2 Reset Request\n");
1670 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
1671 if(e2apMsg == NULLP)
1673 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for E2AP-PDU failed");
1677 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
1678 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1679 if(e2apMsg->choice.initiatingMessage == NULLP)
1681 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for initiatingMessage");
1685 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_Reset;
1686 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
1687 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ResetRequestE2;
1688 resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2;
1691 resetReq->protocolIEs.list.count = elementCnt;
1692 resetReq->protocolIEs.list.size = elementCnt * sizeof(ResetRequestIEs_t *);
1694 DU_ALLOC(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size);
1695 if(!resetReq->protocolIEs.list.array)
1697 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \
1698 Reset Request IE array");
1702 for(ieIdx = 0; ieIdx < elementCnt; ieIdx++)
1704 DU_ALLOC(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t));
1705 if(!resetReq->protocolIEs.list.array[ieIdx])
1707 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \
1708 Reset Request IE array element");
1713 /* In case of failure */
1714 if(ieIdx < elementCnt)
1718 resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
1719 resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
1720 resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_TransactionID;
1721 transId = assignTransactionId();
1722 resetReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
1725 resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_CauseE2;
1726 resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_ignore;
1727 resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_CauseE2;
1728 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.present = failureType;
1729 switch(resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.present)
1731 case CauseE2_PR_NOTHING:
1733 case CauseE2_PR_ricRequest:
1734 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.ricRequest = failureCause;
1736 case CauseE2_PR_ricService:
1737 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.ricService = failureCause;
1739 case CauseE2_PR_e2Node:
1740 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.e2Node = failureCause;
1742 case CauseE2_PR_transport:
1743 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.transport = failureCause;
1745 case CauseE2_PR_protocol:
1746 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.protocol = failureCause;
1748 case CauseE2_PR_misc:
1749 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.misc = failureCause;
1753 /* Prints the Msg formed */
1754 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
1756 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1758 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
1760 if(encRetVal.encoded == ENCODE_FAIL)
1762 DU_LOG("\nERROR --> E2AP : Could not encode E2SetupRequest structure (at %s)\n",\
1763 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1768 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SetupRequest\n");
1769 #ifdef DEBUG_ASN_PRINT
1770 for(int i=0; i< encBufSize; i++)
1772 printf("%x",encBuf[i]);
1776 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
1778 DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed");
1782 /* In case the message is sent successfully, store the transaction info to
1783 * be used when response is received */
1784 duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId;
1785 duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
1791 /* Free all memory */
1792 FreeE2ResetRequest(e2apMsg);
1796 /*******************************************************************
1798 * @brief Deallocate the memory allocated for Reset Response msg
1802 * Function : freeAperDecodingOfE2ResetRsp
1805 * - freeing the memory allocated for Reset response
1807 * @params[in] ResetResponseE2_t *resetResponse
1810 * ****************************************************************/
1811 void freeAperDecodingOfE2ResetRsp(ResetResponseE2_t *resetResponse)
1817 if(resetResponse->protocolIEs.list.array)
1819 for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++)
1821 if(resetResponse->protocolIEs.list.array[ieIdx])
1823 switch(resetResponse->protocolIEs.list.array[ieIdx]->id)
1825 case ProtocolIE_IDE2_id_TransactionID:
1828 case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
1831 free(resetResponse->protocolIEs.list.array[ieIdx]);
1834 free(resetResponse->protocolIEs.list.array);
1839 /******************************************************************
1841 * @brief Processes E2 Reset Response sent by RIC
1845 * Function : procResetResponse
1847 * Functionality: Processes E2 Reset Response sent by RIC
1849 * @params[in] E2AP_PDU_t ASN decoded E2AP message
1850 * @return ROK - success
1853 * ****************************************************************/
1854 uint8_t procResetResponse(E2AP_PDU_t *e2apMsg)
1856 uint8_t ieIdx =0, transId;
1857 ResetResponseE2_t *resetResponse;
1859 DU_LOG("\nINFO --> E2AP : E2 Reset Response received");
1860 resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2;;
1862 for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++)
1864 switch(resetResponse->protocolIEs.list.array[ieIdx]->id)
1866 case ProtocolIE_IDE2_id_TransactionID:
1867 transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
1868 if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) && \
1869 (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
1870 memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
1873 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
1877 case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
1878 /* As per ORAN WG3 E2AP spec v3.0, section 9.2.2
1879 Criticality Diagnostics IE is sent by Near-RT RIC when parts of a received message i.e.
1880 Reset Request in this case, have not been comprehended or were missing, or if the message
1881 contained logical errors.
1883 Processing of this ID should be implemented when negative call flows are to be supported.
1887 DU_LOG("\nERROR --> E2AP : Invalid IE received in E2 Reset Response : %ld",
1888 resetResponse->protocolIEs.list.array[ieIdx]->id);
1893 freeAperDecodingOfE2ResetRsp(resetResponse);
1897 /******************************************************************
1899 * @brief Deallocation of memory allocated bu aper decoder for e2 setup Failure
1903 * Function : freeAperDecodingOfE2SetupFailure
1905 * Functionality: Deallocation of memory allocated bu aper decoder for e2
1908 * @params[in] E2setupFailure_t *e2SetupFailure;
1911 * ****************************************************************/
1912 void freeAperDecodingOfE2SetupFailure(E2setupFailure_t *e2SetupFailure)
1918 if(e2SetupFailure->protocolIEs.list.array)
1920 for(arrIdx=0; arrIdx<e2SetupFailure->protocolIEs.list.count; arrIdx++)
1922 if(e2SetupFailure->protocolIEs.list.array[arrIdx])
1924 free(e2SetupFailure->protocolIEs.list.array[arrIdx]);
1927 free(e2SetupFailure->protocolIEs.list.array);
1931 /******************************************************************
1933 * @brief Processes E2 Setup Failure sent by RIC
1937 * Function : procE2SetupFailure
1939 * Functionality: Processes E2 Setup failure sent by RIC
1941 * @params[in] E2AP_PDU_t ASN decoded E2AP message
1942 * @return ROK - success
1945 * ****************************************************************/
1946 void procE2SetupFailure(E2AP_PDU_t *e2apMsg)
1948 uint8_t arrIdx =0, transId =0, timerValue=0;
1949 E2setupFailure_t *e2SetupFailure;
1951 DU_LOG("\nINFO --> E2AP : E2 Setup failure received");
1952 e2SetupFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2setupFailure;
1954 for(arrIdx=0; arrIdx<e2SetupFailure->protocolIEs.list.count; arrIdx++)
1956 switch(e2SetupFailure->protocolIEs.list.array[arrIdx]->id)
1958 case ProtocolIE_IDE2_id_TransactionID:
1960 transId = e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
1961 if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\
1962 (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
1963 memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
1966 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
1971 case ProtocolIE_IDE2_id_TimeToWaitE2:
1973 timerValue = covertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2);
1974 if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR)) == FALSE)
1976 duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR, timerValue);
1980 DU_LOG("\nERROR --> E2AP : EVENT_E2_SETUP_TMR timer is already running");
1988 freeAperDecodingOfE2SetupFailure(e2SetupFailure);
1990 /*******************************************************************
1992 * @brief Handles received E2AP message and sends back response
1996 * Function : E2APMsgHdlr
1999 * - Decodes received E2AP control message
2000 * - Prepares response message, encodes and sends to SCTP
2003 * @return ROK - success
2006 * ****************************************************************/
2007 void E2APMsgHdlr(Buffer *mBuf)
2010 char *recvBuf = NULLP;
2012 MsgLen recvBufLen =0;
2013 E2AP_PDU_t *e2apMsg = NULLP;
2014 asn_dec_rval_t rval ={0}; /* Decoder return value */
2015 E2AP_PDU_t e2apasnmsg={0} ;
2017 DU_LOG("\nDEBUG --> E2AP : Received E2AP message buffer");
2018 ODU_PRINT_MSG(mBuf, 0,0);
2020 /* Copy mBuf into char array to decode it */
2021 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
2022 DU_ALLOC(recvBuf, (Size)recvBufLen);
2024 if(recvBuf == NULLP)
2026 DU_LOG("\nERROR --> E2AP : Memory allocation failed");
2029 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
2031 DU_LOG("\nERROR --> E2AP : Failed while copying %d", copyCnt);
2035 #ifdef DEBUG_ASN_PRINT
2036 printf("\nDEBUG --> E2AP : Received flat buffer to be decoded : ");
2037 for(i=0; i< recvBufLen; i++)
2039 printf("%x",recvBuf[i]);
2043 /* Decoding flat buffer into E2AP messsage */
2044 e2apMsg = &e2apasnmsg;
2045 memset(e2apMsg, 0, sizeof(E2AP_PDU_t));
2047 rval = aper_decode(0, &asn_DEF_E2AP_PDU, (void **)&e2apMsg, recvBuf, recvBufLen, 0, 0);
2048 DU_FREE(recvBuf, (Size)recvBufLen);
2050 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
2052 DU_LOG("\nERROR --> E2AP : ASN decode failed");
2056 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
2058 switch(e2apMsg->present)
2060 case E2AP_PDU_PR_unsuccessfulOutcome:
2062 switch(e2apMsg->choice.unsuccessfulOutcome->value.present)
2064 case UnsuccessfulOutcomeE2__value_PR_E2setupFailure:
2066 procE2SetupFailure(e2apMsg);
2071 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_unsuccessfulOutcome [%d]",\
2072 e2apMsg->choice.unsuccessfulOutcome->value.present);
2078 case E2AP_PDU_PR_successfulOutcome:
2080 switch(e2apMsg->choice.successfulOutcome->value.present)
2082 case SuccessfulOutcomeE2__value_PR_E2setupResponse:
2086 procE2SetupRsp(e2apMsg);
2090 case SuccessfulOutcomeE2__value_PR_E2nodeConfigurationUpdateAcknowledge:
2092 DU_LOG("\nDEBUG --> E2AP : E2 node Config update ack message recevied");
2095 case SuccessfulOutcomeE2__value_PR_ResetResponseE2:
2097 procResetResponse(e2apMsg);
2102 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_successfulOutcome [%d]",\
2103 e2apMsg->choice.successfulOutcome->value.present);
2106 }/* End of switch(successfulOutcome) */
2107 free(e2apMsg->choice.successfulOutcome);
2111 case E2AP_PDU_PR_initiatingMessage:
2113 switch(e2apMsg->choice.initiatingMessage->value.present)
2115 case InitiatingMessageE2__value_PR_RICsubscriptionRequest:
2117 procRicSubsReq(e2apMsg);
2122 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_initiatingMessage [%d]",\
2123 e2apMsg->choice.initiatingMessage->value.present);
2126 }/* End of switch(initiatingMessage) */
2127 free(e2apMsg->choice.initiatingMessage);
2132 DU_LOG("\nERROR --> E2AP : Invalid type of e2apMsg->present [%d]",e2apMsg->present);
2137 }/* End of switch(e2apMsg->present) */
2139 } /* End of E2APMsgHdlr */
2141 /**********************************************************************
2143 **********************************************************************/