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"
49 /*******************************************************************
51 * @brief Builds Global gNodeB Params
55 * Function : BuildGlobalgNBId
57 * Functionality: Building the Plmn and gNB id
59 * @params[in] GlobalE2node_gNB_ID_t *gNbId
60 * @return ROK - success
63 ******************************************************************/
65 uint8_t BuildGlobalgNBId(GlobalE2node_gNB_ID_t *gNbId)
69 uint8_t gnbId = duCb.gnbId;
72 /* fill Global gNB ID Id */
73 gNbId->global_gNB_ID.plmn_id.size = 3 * sizeof(uint8_t);
74 gNbId->global_gNB_ID.plmn_id.buf = NULLP;
75 DU_ALLOC(gNbId->global_gNB_ID.plmn_id.buf , gNbId->global_gNB_ID.plmn_id.size);
76 if(gNbId->global_gNB_ID.plmn_id.buf == NULLP)
78 DU_LOG("\nERROR --> E2AP: Memory allocation failed for Plmn buffer");
83 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
84 gNbId->global_gNB_ID.plmn_id.buf);
85 gNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID;
86 /* Allocate Buffer size */
87 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = byteSize * sizeof(uint8_t);
88 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf = NULLP;
89 DU_ALLOC(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf, \
90 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size);
91 if(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf == NULLP)
93 DU_LOG("\nERROR --> E2AP: Memory allocation failed for gnb buffer");
98 fillBitString(&gNbId->global_gNB_ID.gnb_id.choice.gnb_ID, unused, byteSize, gnbId);
103 DU_ALLOC( gNbId->gNB_DU_ID, sizeof(GNB_DU_ID_t));
104 if(gNbId->gNB_DU_ID == NULLP)
106 DU_LOG("\nERROR --> E2AP: Memory allocation failed for gNB_DU_ID ");
111 gNbId->gNB_DU_ID->size = sizeof(uint8_t);
112 DU_ALLOC( gNbId->gNB_DU_ID->buf, sizeof(uint8_t));
113 if(gNbId->gNB_DU_ID->buf)
115 gNbId->gNB_DU_ID->buf[0] =duCb.e2apDb.e2NodeId;
119 DU_LOG("\nERROR --> E2AP: Memory allocation failed for gNB_DU_ID buffer");
127 /******************************************************************
129 * @brief Search E2 node component with the help of action type
133 * Function : searchE2NodeComponentInfo
135 * Functionality: Search E2 node component with the help of action type
137 * @params[in] uint8_t componentActionType
140 * ****************************************************************/
142 CmLList *searchE2NodeComponentInfo(InterfaceType interfaceType, uint8_t componentActionType)
144 E2NodeComponent *e2NodeComponentInfo;
147 if(duCb.e2apDb.e2NodeComponentList.count)
149 CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node);
152 e2NodeComponentInfo = (E2NodeComponent*)node->node;
153 if((e2NodeComponentInfo->interfaceType == interfaceType) && (e2NodeComponentInfo->componentActionType == componentActionType))
162 /*******************************************************************
164 * @brief Builds E2 node config addition list
168 * Function : BuildE2NodeConfigAddList
170 * Functionality: Building E2 node config addition list
172 * @params[in] E2nodeComponentConfigAddition_List_t *e2NodeAddList
173 * @return ROK - success
176 ******************************************************************/
178 uint8_t BuildE2NodeConfigAddList(E2nodeComponentConfigAddition_List_t *e2NodeAddList)
182 E2NodeComponent *e2NodeComponentInfo;
183 E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItemIe;
184 E2nodeComponentConfigAddition_Item_t *e2NodeAddItem;
186 e2NodeAddList->list.count = 1;
187 e2NodeAddList->list.size = e2NodeAddList->list.count * sizeof(E2nodeComponentConfigAddition_ItemIEs_t *);
188 DU_ALLOC(e2NodeAddList->list.array, e2NodeAddList->list.size);
189 if(e2NodeAddList->list.array == NULLP)
191 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
195 for(arrIdx = 0; arrIdx< e2NodeAddList->list.count; arrIdx++)
197 DU_ALLOC(e2NodeAddList->list.array[arrIdx], sizeof(E2nodeComponentConfigAddition_ItemIEs_t));
198 if(e2NodeAddList->list.array[arrIdx] == NULLP)
200 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
205 node = searchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD);
208 DU_LOG("\nERROR --> E2AP : Received e2NodeComponentInfo is null");
211 e2NodeComponentInfo = (E2NodeComponent*)node->node;
214 e2NodeAddItemIe = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[arrIdx];
215 e2NodeAddItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition_Item;
216 e2NodeAddItemIe->criticality = CriticalityE2_reject;
217 e2NodeAddItemIe->value.present = E2nodeComponentConfigAddition_ItemIEs__value_PR_E2nodeComponentConfigAddition_Item;
218 e2NodeAddItem = &e2NodeAddItemIe->value.choice.E2nodeComponentConfigAddition_Item;
220 /* E2nodeComponentInterfaceType */
221 e2NodeAddItem->e2nodeComponentInterfaceType = E2nodeComponentInterfaceType_f1;
223 /* E2 Node Component Request Part */
224 if(e2NodeComponentInfo->componentRequestPart)
226 e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.size = e2NodeComponentInfo->reqBufSize ;
227 DU_ALLOC(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\
228 e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.size);
229 if(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf == NULLP)
231 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
235 memcpy(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\
236 e2NodeComponentInfo->componentRequestPart, e2NodeAddItem->e2nodeComponentConfiguration.\
237 e2nodeComponentRequestPart.size);
241 DU_LOG("\nERROR --> E2AP: componentRequestPart is null ");
246 /* E2 Node Component Response Part */
247 if(e2NodeComponentInfo->componentResponsePart)
249 e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.size = e2NodeComponentInfo->rspBufSize;
250 DU_ALLOC(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf, \
251 e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.size);
252 if(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf == NULLP)
254 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
257 memcpy(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf, \
258 e2NodeComponentInfo->componentResponsePart, e2NodeAddItem->e2nodeComponentConfiguration.\
259 e2nodeComponentResponsePart.size);
263 DU_LOG("\nERROR --> E2AP: componentResponsePart is null");
267 /* E2 Node Component ID */
268 e2NodeAddItem->e2nodeComponentID.present = E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1;
269 DU_ALLOC(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1,\
270 sizeof(E2nodeComponentInterfaceF1_t));
271 if(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1 == NULLP)
273 DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
276 e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size = sizeof(uint8_t);
277 DU_ALLOC(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\
278 e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size);
280 if(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf == NULLP)
282 DU_LOG("\nERROR -->list. E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__);
285 e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf[arrIdx] = e2NodeComponentInfo->componentId;
290 /*******************************************************************
292 * @brief deallocation of E2SM_KPM_RANfunction_Description_t
296 * Function : freeE2smKpmRanFunctionDefinition
298 * Functionality: deallocation of E2SM_KPM_RANfunction_Description_t
300 * @params[in] E2SM_KPM_RANfunction_Description_t *ranFunctionDefinition
303 ******************************************************************/
305 void freeE2smKpmRanFunctionDefinition(E2SM_KPM_RANfunction_Description_t *ranFunctionDefinition)
307 MeasurementInfo_Action_Item_t *measInfoList;
308 uint8_t eventTriggerIdx, reportStyleIdx, measInfoIdx;
309 RANfunction_Name_t *ranFuncName;
310 struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle;
311 struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *eventTriggerStyle;
312 if(ranFunctionDefinition)
314 ranFuncName = &ranFunctionDefinition->ranFunction_Name;
315 /* Free RAN function Name */
316 DU_FREE(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size);
317 DU_FREE(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size);
318 DU_FREE(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size);
320 /* Sequence of Event Trigger styles */
321 eventTriggerStyle = ranFunctionDefinition->ric_EventTriggerStyle_List;
322 if(eventTriggerStyle)
324 if(eventTriggerStyle->list.array)
326 for(eventTriggerIdx =0;eventTriggerIdx<eventTriggerStyle->list.count; eventTriggerIdx++)
328 if(eventTriggerStyle->list.array[eventTriggerIdx])
330 DU_FREE(eventTriggerStyle->list.array[eventTriggerIdx]->ric_EventTriggerStyle_Name.buf,\
331 eventTriggerStyle->list.array[eventTriggerIdx]->ric_EventTriggerStyle_Name.size);
332 DU_FREE(eventTriggerStyle->list.array[eventTriggerIdx], sizeof(RIC_EventTriggerStyle_Item_t ));
335 DU_FREE(eventTriggerStyle->list.array, eventTriggerStyle->list.size)
337 DU_FREE(eventTriggerStyle, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List));
340 /* Sequence of Report styles */
341 ricReportStyle = ranFunctionDefinition->ric_ReportStyle_List;
344 if(ricReportStyle->list.array)
346 for(reportStyleIdx =0;reportStyleIdx<ricReportStyle->list.count; reportStyleIdx++)
348 if(ricReportStyle->list.array[reportStyleIdx])
350 if(ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.buf)
352 DU_FREE(ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.buf,\
353 ricReportStyle->list.array[reportStyleIdx]->ric_ReportStyle_Name.size);
355 if(ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.array)
357 for(measInfoIdx=0; measInfoIdx<ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.count; \
360 measInfoList = ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.array[measInfoIdx];
363 DU_FREE(measInfoList->measID, sizeof(long));
364 DU_FREE(measInfoList->measName.buf, measInfoList->measName.size);
365 DU_FREE(measInfoList,sizeof(MeasurementInfo_Action_Item_t));
368 DU_FREE(measInfoList,ricReportStyle->list.array[reportStyleIdx]->measInfo_Action_List.list.size);
370 DU_FREE(ricReportStyle->list.array[reportStyleIdx], sizeof(RIC_ReportStyle_Item_t));
373 DU_FREE(ricReportStyle->list.array, ricReportStyle->list.size);
375 DU_FREE(ricReportStyle, sizeof(struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List));
377 DU_FREE(ranFunctionDefinition, sizeof(E2SM_KPM_RANfunction_Description_t));
381 /*******************************************************************
383 * @brief fill the e2sm ric report style
387 * Function : fillRicReportStyle
389 * Functionality: fill the report style
391 * @params[in] RanFunction *ranFuncDb, struct
392 * E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle
393 * @return ROK - success
396 ******************************************************************/
397 uint8_t fillRicReportStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *ricReportStyle)
399 uint8_t styleIdx, measInfoIdx;
400 MeasurementInfo_Action_List_t *measInfo;
403 ricReportStyle->list.count = ranFuncDb->numOfReportStyleSupported;
404 ricReportStyle->list.size = ricReportStyle->list.count * sizeof(RIC_ReportStyle_Item_t*);
405 DU_ALLOC(ricReportStyle->list.array, ricReportStyle->list.size);
406 if(!ricReportStyle->list.array)
408 DU_LOG("\nERROR --> E2AP: Memory allocation failed for ranFuncDefinition %d",__LINE__);
412 for(styleIdx =0;styleIdx<ricReportStyle->list.count; styleIdx++)
414 DU_ALLOC(ricReportStyle->list.array[styleIdx], sizeof(RIC_ReportStyle_Item_t));
415 if(!ricReportStyle->list.array[styleIdx])
417 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
421 /* RIC Report Style Type */
422 ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Type = ranFuncDb->reportStyleList[styleIdx].reportStyle.styleType;
424 /* RIC Report Style Format Type */
425 ricReportStyle->list.array[styleIdx]->ric_ActionFormat_Type = ranFuncDb->reportStyleList[styleIdx].reportStyle.formatType;
427 /* RIC Report Style Name */
428 ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size = strlen(ranFuncDb->reportStyleList[styleIdx].reportStyle.name);
429 DU_ALLOC(ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf,\
430 ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size);
431 if(!ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf)
433 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
436 memcpy(ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.buf, ranFuncDb->reportStyleList[styleIdx].reportStyle.name,\
437 ricReportStyle->list.array[styleIdx]->ric_ReportStyle_Name.size);
439 /* RIC Indication Header Format Type*/
440 ricReportStyle->list.array[styleIdx]->ric_IndicationHeaderFormat_Type = ranFuncDb->ricIndicationHeaderFormat;
442 /* RIC Indication Message Format Type*/
443 ricReportStyle->list.array[styleIdx]->ric_IndicationMessageFormat_Type = ranFuncDb->ricIndicationMessageFormat;
445 /* Measurement Info Action List */
446 CmLListCp measInfoList =ranFuncDb->reportStyleList[styleIdx].measurementInfoList;
447 if(!measInfoList.count)
452 CM_LLIST_FIRST_NODE(&ranFuncDb->reportStyleList[styleIdx].measurementInfoList, node);
453 measInfo = &ricReportStyle->list.array[styleIdx]->measInfo_Action_List;
455 measInfo->list.count = measInfoList.count;
456 measInfo->list.size = measInfoList.count*sizeof(MeasurementInfo_Action_Item_t*);
457 DU_ALLOC(measInfo->list.array, measInfo->list.size);
458 if(!measInfo->list.array)
460 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
464 for(measInfoIdx=0; measInfoIdx<measInfo->list.count; measInfoIdx++)
468 DU_LOG("\nERROR --> E2AP: Measurement info node is null");
472 DU_ALLOC(measInfo->list.array[measInfoIdx],sizeof(MeasurementInfo_Action_Item_t));
473 if(!measInfo->list.array[measInfoIdx])
475 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
478 MeasurementInfoForAction *measInfoForAction= (MeasurementInfoForAction*)node->node;
479 DU_ALLOC(measInfo->list.array[measInfoIdx]->measID, sizeof(long));
480 if(!measInfo->list.array[measInfoIdx]->measID)
482 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
486 memcpy(measInfo->list.array[measInfoIdx]->measID, &measInfoForAction->measurementTypeId,sizeof(long));
487 measInfo->list.array[measInfoIdx]->measName.size= strlen(measInfoForAction->measurementTypeName);
488 DU_ALLOC(measInfo->list.array[measInfoIdx]->measName.buf, measInfo->list.array[measInfoIdx]->measName.size);
489 if(!measInfo->list.array[measInfoIdx]->measName.size)
491 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
495 memcpy(measInfo->list.array[measInfoIdx]->measName.buf, \
496 measInfoForAction->measurementTypeName,\
497 measInfo->list.array[measInfoIdx]->measName.size);
504 /*******************************************************************
506 * @brief fill the ric event trigger style
510 * Function : fillRicEventTriggerStyle
512 * Functionality: fill the ric event trigger style
515 * @return ROK - success
518 ******************************************************************/
519 uint8_t fillRicEventTriggerStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *ricEventTriggerStyle)
523 ricEventTriggerStyle->list.count = ranFuncDb->numOfEventTriggerStyleSupported;
524 ricEventTriggerStyle->list.size = ricEventTriggerStyle->list.count* sizeof(RIC_EventTriggerStyle_Item_t *);
525 DU_ALLOC(ricEventTriggerStyle->list.array, ricEventTriggerStyle->list.size);
526 if(!ricEventTriggerStyle->list.array)
528 DU_LOG("\nERROR --> E2AP: Memory allocation failed for ric_EventTriggerStyle_List %d",__LINE__);
532 for(styleIdx =0;styleIdx<ricEventTriggerStyle->list.count; styleIdx++)
534 DU_ALLOC(ricEventTriggerStyle->list.array[styleIdx], sizeof(RIC_EventTriggerStyle_Item_t ));
535 if(!ricEventTriggerStyle->list.array[styleIdx])
537 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
540 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Type = ranFuncDb->eventTriggerStyleList[styleIdx].styleType;
542 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerFormat_Type = ranFuncDb->eventTriggerStyleList[styleIdx].formatType;
544 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size = strlen(ranFuncDb->eventTriggerStyleList[styleIdx].name);
545 DU_ALLOC(ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf,\
546 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size);
547 if(!ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf)
549 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
552 memcpy(ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.buf,ranFuncDb->eventTriggerStyleList[styleIdx].name,\
553 ricEventTriggerStyle->list.array[styleIdx]->ric_EventTriggerStyle_Name.size);
559 /*******************************************************************
561 * @brief Builds Ran function add list
565 * Function : BuildRanFunctionAddList
567 * Functionality: Building RAN addition addition list
569 * @params[in] RANfunctions_List_t *RANfunctions_List
570 * @return ROK - success
573 ******************************************************************/
575 uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList)
577 asn_enc_rval_t encRetVal;
578 RanFunction *ranFuncDb;
579 RANfunction_Name_t *ranFuncName;
581 RANfunction_ItemIEs_t *ranFuncItemIe;
582 RANfunction_Item_t *ranFuncItem;
583 E2SM_KPM_RANfunction_Description_t *ranFuncDefinition;
585 ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction;
586 ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*);
587 DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size);
588 if(ranFunctionsList->list.array == NULLP)
590 DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
594 for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++)
596 DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
597 if(ranFunctionsList->list.array[ranFuncIdx] == NULLP)
599 DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
603 ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx];
604 ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item;
605 ranFuncItemIe->criticality = CriticalityE2_ignore;
606 ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
607 ranFuncItem = &ranFuncItemIe->value.choice.RANfunction_Item;
608 ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx];
610 ranFuncItem->ranFunctionID = ranFuncDb->id;
612 /* RAN Function Revision*/
613 ranFuncItem->ranFunctionRevision = ranFuncDb->revisionCounter;
615 /* RAN function OID*/
616 ranFuncItem->ranFunctionOID.size = strlen(ranFuncDb->name.serviceModelOID);
617 DU_ALLOC(ranFuncItem->ranFunctionOID.buf, ranFuncItem->ranFunctionOID.size);
618 if(!ranFuncItem->ranFunctionOID.buf)
620 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
623 memcpy(ranFuncItem->ranFunctionOID.buf, ranFuncDb->name.serviceModelOID, ranFuncItem->ranFunctionOID.size);
625 /* RAN function Definition */
626 DU_ALLOC(ranFuncDefinition, sizeof(E2SM_KPM_RANfunction_Description_t));
627 if(!ranFuncDefinition)
629 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
633 /* RAN function Name */
634 ranFuncName = &ranFuncDefinition->ranFunction_Name;
636 /* RAN function ShortName */
637 ranFuncName->ranFunction_ShortName.size = strlen(ranFuncDb->name.shortName);
638 DU_ALLOC(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size);
639 if(!ranFuncName->ranFunction_ShortName.buf)
641 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
644 memcpy(ranFuncName->ranFunction_ShortName.buf, ranFuncDb->name.shortName, strlen(ranFuncDb->name.shortName));
646 /* RAN function E2SM_OID */
647 ranFuncName->ranFunction_E2SM_OID.size = strlen(ranFuncDb->name.serviceModelOID);
648 DU_ALLOC(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size);
649 if(!ranFuncName->ranFunction_E2SM_OID.buf)
651 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
654 memcpy(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncDb->name.serviceModelOID, ranFuncName->ranFunction_E2SM_OID.size);
656 /* RAN function Description */
657 ranFuncName->ranFunction_Description.size = strlen(ranFuncDb->name.description);
658 DU_ALLOC(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size);
659 if(!ranFuncName->ranFunction_Description.buf)
661 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
664 memcpy(ranFuncName->ranFunction_Description.buf, ranFuncDb->name.description, ranFuncName->ranFunction_Description.size);
666 /* RIC Event Trigger Style List */
667 DU_ALLOC(ranFuncDefinition->ric_EventTriggerStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List));
668 if(!ranFuncDefinition->ric_EventTriggerStyle_List)
670 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
674 if(fillRicEventTriggerStyle(ranFuncDb, ranFuncDefinition->ric_EventTriggerStyle_List)!=ROK)
676 DU_LOG("\nERROR --> E2AP: failed to fill ric event trigger style");
680 /* RIC Report Style List */
681 DU_ALLOC(ranFuncDefinition->ric_ReportStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_ReportStyle_List));
682 if(!ranFuncDefinition->ric_ReportStyle_List)
684 DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
687 if(fillRicReportStyle(ranFuncDb, ranFuncDefinition->ric_ReportStyle_List) != ROK)
689 DU_LOG("\nERROR --> E2AP: failed to fill ric report style");
693 /* Encode the F1SetupRequest type as APER */
694 xer_fprint(stdout, &asn_DEF_E2SM_KPM_RANfunction_Description, ranFuncDefinition);
696 memset(encBuf, 0, ENC_BUF_MAX_LEN);
698 encRetVal = aper_encode(&asn_DEF_E2SM_KPM_RANfunction_Description, 0, ranFuncDefinition, PrepFinalEncBuf, encBuf);
701 if(encRetVal.encoded == ENCODE_FAIL)
703 DU_LOG("\nERROR --> F1AP : Could not encode RAN function definition (at %s)\n",\
704 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
709 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RAN function definition \n");
710 for(uint8_t measIeIdx=0; measIeIdx< encBufSize; measIeIdx++)
712 printf("%x",encBuf[measIeIdx]);
716 ranFuncItem->ranFunctionDefinition.size = encBufSize;
717 DU_ALLOC(ranFuncItem->ranFunctionDefinition.buf, encBufSize);
718 if(ranFuncItem->ranFunctionDefinition.buf == NULLP)
720 DU_LOG("\nERROR --> F1AP : Memory allocation failed for RAN function definition buffer");
723 memcpy(ranFuncItem->ranFunctionDefinition.buf, &encBuf, encBufSize);
725 freeE2smKpmRanFunctionDefinition(ranFuncDefinition);
729 /*******************************************************************
731 * @brief De Allocate E2 Setup Request Message
735 * Function : FreeE2SetupReq
737 * Functionality: De-Allocating E2 Setup request Message
739 * @params[in] E2AP_PDU_t *e2apMsg
743 * ****************************************************************/
745 void FreeE2SetupReq(E2AP_PDU_t *e2apMsg)
748 uint8_t e2NodeAddListIdx =0, ranFuncAddListIdx;
749 E2setupRequest_t *e2SetupReq;
750 E2nodeComponentConfigAddition_List_t *e2NodeAddList;
751 E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem;
752 RANfunctions_List_t *ranFunctionsList;
753 RANfunction_ItemIEs_t *ranFuncItemIe;
754 RANfunction_Item_t *ranFunItem;
756 /* De-allocating Memory */
759 if(e2apMsg->choice.initiatingMessage != NULLP)
761 e2SetupReq = &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest;
762 if(e2SetupReq->protocolIEs.list.array != NULLP)
764 for(arrIdx = 0; arrIdx < e2SetupReq->protocolIEs.list.count; arrIdx++)
766 if(e2SetupReq->protocolIEs.list.array[arrIdx] != NULLP)
768 switch(e2SetupReq->protocolIEs.list.array[arrIdx]->id)
770 case ProtocolIE_IDE2_id_TransactionID:
772 case ProtocolIE_IDE2_id_GlobalE2node_ID:
774 if(e2SetupReq->protocolIEs.list.array[arrIdx]->\
775 value.choice.GlobalE2node_ID.choice.gNB != NULLP)
777 GlobalE2node_gNB_ID_t *gNbId = NULLP;
778 gNbId = e2SetupReq->protocolIEs.list.array[arrIdx]->\
779 value.choice.GlobalE2node_ID.choice.gNB;
780 if(gNbId->global_gNB_ID.plmn_id.buf != NULLP)
782 DU_FREE(gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf,\
783 gNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size);
784 DU_FREE(gNbId->global_gNB_ID.plmn_id.buf,\
785 gNbId->global_gNB_ID.plmn_id.size);
788 if(gNbId->gNB_DU_ID != NULLP)
790 DU_FREE( gNbId->gNB_DU_ID->buf, gNbId->gNB_DU_ID->size);
791 DU_FREE(gNbId->gNB_DU_ID, sizeof(GNB_DU_ID_t));
793 DU_FREE(e2SetupReq->protocolIEs.list.array[arrIdx]->value.\
794 choice.GlobalE2node_ID.choice.gNB, sizeof(GlobalE2node_gNB_ID_t));
798 case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition:
800 e2NodeAddList = &e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List;
801 if(e2NodeAddList->list.array)
803 for(e2NodeAddListIdx = 0; e2NodeAddListIdx< e2NodeAddList->list.count; e2NodeAddListIdx++)
805 e2NodeAddItem = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[e2NodeAddListIdx];
807 /* Free E2 Node Component Request Part */
808 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\
809 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentRequestPart.size);
811 /* Free E2 Node Component Response Part */
812 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.\
813 e2nodeComponentResponsePart.buf, \
814 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration.e2nodeComponentResponsePart.size);
816 /* Free E2 Node Component ID */
817 if(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1)
819 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
820 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\
821 e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
822 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size);
823 DU_FREE(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1,\
824 sizeof(E2nodeComponentInterfaceF1_t));
826 DU_FREE(e2NodeAddList->list.array[e2NodeAddListIdx], sizeof(E2nodeComponentConfigAddition_ItemIEs_t));
828 DU_FREE(e2NodeAddList->list.array, e2NodeAddList->list.size);
832 case ProtocolIE_IDE2_id_RANfunctionsAdded:
834 ranFunctionsList = &(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List);
835 if(ranFunctionsList->list.array)
837 for(ranFuncAddListIdx= 0; ranFuncAddListIdx< ranFunctionsList->list.count; ranFuncAddListIdx++)
839 if(ranFunctionsList->list.array[ranFuncAddListIdx])
841 ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncAddListIdx];
842 ranFunItem = &ranFuncItemIe->value.choice.RANfunction_Item;
843 DU_FREE(ranFunItem->ranFunctionOID.buf, ranFunItem->ranFunctionOID.size);
844 DU_FREE(ranFunItem->ranFunctionDefinition.buf, ranFunItem->ranFunctionDefinition.size);
845 DU_FREE(ranFunctionsList->list.array[ranFuncAddListIdx], sizeof(RANfunction_ItemIEs_t));
848 DU_FREE(ranFunctionsList->list.array, ranFunctionsList->list.size);
854 DU_LOG("\nERROR --> E2AP: Invalid event at e2SetupRequet %ld ",\
855 (e2SetupReq->protocolIEs.list.array[arrIdx]->id));
858 DU_FREE(e2SetupReq->protocolIEs.list.array[arrIdx], sizeof(E2setupRequestIEs_t));
861 DU_FREE(e2SetupReq->protocolIEs.list.array, e2SetupReq->protocolIEs.list.size);
863 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
865 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
869 /*******************************************************************
871 * @brief Builds and Send the E2SetupRequest
875 * Function : BuildAndSendE2SetupReq
877 * Functionality:Fills the E2SetupRequest
879 * @return ROK - success
882 ******************************************************************/
884 uint8_t BuildAndSendE2SetupReq()
886 uint8_t arrIdx = 0, elementCnt=0;
887 uint8_t transId = 0, ret = ROK;
889 E2AP_PDU_t *e2apMsg = NULLP;
890 E2setupRequest_t *e2SetupReq = NULLP;
891 asn_enc_rval_t encRetVal; /* Encoder return value */
893 DU_LOG("\nINFO --> E2AP : Building E2 Setup Request\n");
896 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
899 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
902 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
903 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
904 if(e2apMsg->choice.initiatingMessage == NULLP)
906 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
909 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
910 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2setup;
911 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_E2setupRequest;
912 e2SetupReq = &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest;
915 e2SetupReq->protocolIEs.list.count = elementCnt;
916 e2SetupReq->protocolIEs.list.size = elementCnt * sizeof(E2setupRequestIEs_t*);
918 /* Initialize the E2Setup members */
919 DU_ALLOC(e2SetupReq->protocolIEs.list.array, \
920 e2SetupReq->protocolIEs.list.size);
921 if(e2SetupReq->protocolIEs.list.array == NULLP)
923 DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements");
926 for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++)
928 DU_ALLOC(e2SetupReq->protocolIEs.list.array[arrIdx],\
929 sizeof(E2setupRequestIEs_t));
930 if(e2SetupReq->protocolIEs.list.array[arrIdx] == NULLP)
932 memAllocFailed = true;
933 DU_LOG("\nERROR --> E2AP : Memory allocation failed for arrayarrIdx [%d]", arrIdx);
937 if(memAllocFailed == true)
943 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
944 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
945 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_TransactionID;
946 transId = assignTransactionId();
947 e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId;
950 /* GlobalE2node_gNB_ID */
951 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_GlobalE2node_ID;
952 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
953 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_GlobalE2node_ID;
954 e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.GlobalE2node_ID.present = GlobalE2node_ID_PR_gNB;
956 DU_ALLOC(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.\
957 GlobalE2node_ID.choice.gNB, sizeof(GlobalE2node_gNB_ID_t));
958 if(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.\
959 GlobalE2node_ID.choice.gNB == NULLP)
961 DU_LOG("\nERROR --> E2AP : Memory allocation failed for gNbId");
966 ret = BuildGlobalgNBId(e2SetupReq->protocolIEs.list.array[arrIdx]->value.\
967 choice.GlobalE2node_ID.choice.gNB);
970 DU_LOG("\nERROR --> E2AP : Failed to build Global Gnb Id");
975 /* RAN Functions Added List */
977 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAdded;
978 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
979 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_RANfunctions_List;
980 if(BuildRanFunctionAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List))!=ROK)
982 DU_LOG("\nERROR --> E2AP : Failed to create RAN Function");
986 /* E2 Node Component Configuration Addition List */
988 e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition;
989 e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
990 e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_E2nodeComponentConfigAddition_List;
991 if(BuildE2NodeConfigAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List))!=ROK)
993 DU_LOG("\nERROR --> E2AP : Failed to create E2 Node config list");
999 /* Prints the Msg formed */
1000 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
1002 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1004 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
1006 if(encRetVal.encoded == ENCODE_FAIL)
1008 DU_LOG("\nERROR --> E2AP : Could not encode E2SetupRequest structure (at %s)\n",\
1009 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1014 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SetupRequest\n");
1015 #ifdef DEBUG_ASN_PRINT
1016 for(int i=0; i< encBufSize; i++)
1018 printf("%x",encBuf[i]);
1022 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
1024 DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed");
1029 duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId;
1030 duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
1032 FreeE2SetupReq(e2apMsg);
1034 }/* End of BuildAndSendE2SetupReq */
1036 /*******************************************************************
1038 * @brief Builds Ric Request Id
1042 * Function : BuildRicRequestId
1044 * Functionality: Building the Ric Request Id
1046 * @params[in] RICrequestID_t *ricReqId
1047 * @return ROK - success
1050 * ****************************************************************/
1052 uint8_t BuildRicRequestId(RICrequestID_t *ricReqId)
1054 if(ricReqId == NULLP)
1059 ricReqId->ricRequestorID = 1;
1060 ricReqId->ricInstanceID = 1;
1064 /*******************************************************************
1066 * @brief Fills the mandatory RicAdmitted List Items
1070 * Function : fillRicAdmitList
1072 * Functionality: Fills the mandatory Ric Admitted List Items
1074 * @params[in] RICaction_Admitted_ItemIEs_t *ricAdmitItems
1075 * @return ROK - success
1078 * ****************************************************************/
1080 uint8_t fillRicAdmitList(RICaction_Admitted_ItemIEs_t *ricAdmitItems)
1083 if(ricAdmitItems != NULLP)
1085 ricAdmitItems->id = ProtocolIE_IDE2_id_RICaction_Admitted_Item;
1086 ricAdmitItems->criticality = CriticalityE2_reject;
1087 ricAdmitItems->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item;
1088 ricAdmitItems->value.choice.RICaction_Admitted_Item.ricActionID = 1;
1096 /*******************************************************************
1098 * @brief Builds the mandatory RicAdmitted List Params
1102 * Function : BuildRicAdmitList
1104 * Functionality: Builds the mandatory Ric Admitted List Params
1106 * @params[in] RICaction_Admitted_List_t *admitListPtr
1107 * @return ROK - success
1110 * ****************************************************************/
1112 uint8_t BuildRicAdmitList(RICaction_Admitted_List_t *admitListPtr)
1119 if(admitListPtr == NULLP)
1121 DU_LOG("\nERROR --> E2AP : Memory allocation for RIC Admit List failed");
1126 admitListPtr->list.count = elementCnt;
1127 admitListPtr->list.size = elementCnt * sizeof(RICaction_Admitted_ItemIEs_t);
1128 DU_ALLOC(admitListPtr->list.array, admitListPtr->list.size);
1129 if(admitListPtr->list.array == NULLP)
1131 DU_LOG("\nERROR --> E2AP : Memory allocation for RIC Admit List failed");
1136 for(idx=0 ; idx<elementCnt ; idx++ )
1138 DU_ALLOC(admitListPtr->list.array[idx], sizeof(RICaction_Admitted_ItemIEs_t));
1139 if(admitListPtr->list.array[idx] == NULLP)
1147 fillRicAdmitList((RICaction_Admitted_ItemIEs_t *)admitListPtr->list.array[idx]);
1153 /*******************************************************************
1155 * @breif Deallocation of BuildAndSendRicSubscriptionRsp memory
1159 * Function : FreeRicSubscriptionRsp
1161 * Functionality:Free the RicSubscriptionRsp
1163 * @param[in] E2AP_PDU_t *e2apRicMsg
1168 ******************************************************************/
1169 void FreeRicSubscriptionRsp(E2AP_PDU_t *e2apRicMsg)
1171 RICsubscriptionResponse_t *ricSubscriptionRsp= NULLP;
1174 RICaction_Admitted_List_t *admitListPtr;
1176 if(e2apRicMsg != NULLP)
1178 if(e2apRicMsg->choice.successfulOutcome != NULLP)
1180 ricSubscriptionRsp = &e2apRicMsg->choice.successfulOutcome->value.choice.RICsubscriptionResponse;
1181 if(ricSubscriptionRsp)
1183 if(ricSubscriptionRsp->protocolIEs.list.array != NULLP)
1185 for(idx=0; idx<ricSubscriptionRsp->protocolIEs.list.count; idx++)
1187 if(ricSubscriptionRsp->protocolIEs.list.array[idx] != NULLP)
1189 switch(ricSubscriptionRsp->protocolIEs.list.array[idx]->id)
1191 case ProtocolIE_IDE2_id_RICrequestID:
1194 case ProtocolIE_IDE2_id_RANfunctionID:
1197 case ProtocolIE_IDE2_id_RICactions_Admitted:
1199 admitListPtr = &ricSubscriptionRsp->protocolIEs.list.\
1200 array[idx]->value.choice.RICaction_Admitted_List;
1201 if(admitListPtr->list.array != NULLP)
1203 for(idx1=0 ; idx1<admitListPtr->list.count; idx1++ )
1205 if(admitListPtr->list.array[idx1] != NULLP)
1207 DU_FREE(admitListPtr->list.array[idx1],
1208 sizeof(RICaction_Admitted_ItemIEs_t));
1211 DU_FREE(admitListPtr->list.array, admitListPtr->list.size);
1218 DU_FREE(ricSubscriptionRsp->protocolIEs.list.array[idx], \
1219 sizeof(RICsubscriptionResponse_IEs_t));
1222 DU_FREE(ricSubscriptionRsp->protocolIEs.list.array, \
1223 ricSubscriptionRsp->protocolIEs.list.size);
1226 DU_FREE(e2apRicMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
1228 DU_FREE(e2apRicMsg, sizeof(E2AP_PDU_t));
1231 /*******************************************************************
1233 * @brief Builds and Send the RicSubscriptionRsp
1237 * Function : BuildAndSendRicSubscriptionRsp
1239 * functionality:Fills the RicSubscriptionRsp
1241 * @return ROK - success
1244 ******************************************************************/
1245 uint8_t FillRicSubscriptionRsp(RICsubscriptionResponse_t *ricSubscriptionRsp )
1249 uint8_t elementCnt = 0;
1250 uint8_t BuildRicRequestIdret=ROK;
1251 uint8_t BuildRicAdmitListret=ROK;
1254 ricSubscriptionRsp->protocolIEs.list.count = elementCnt;
1255 ricSubscriptionRsp->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionResponse_IEs_t);
1256 DU_ALLOC(ricSubscriptionRsp->protocolIEs.list.array, \
1257 ricSubscriptionRsp->protocolIEs.list.size);
1258 if(ricSubscriptionRsp->protocolIEs.list.array == NULLP)
1260 DU_LOG("\nERROR --> E2AP : Memory allocation for FillRicSubscriptionRsp failed");
1265 for(idx=0; idx<ricSubscriptionRsp->protocolIEs.list.count; idx++)
1267 DU_ALLOC(ricSubscriptionRsp->protocolIEs.list.array[idx], \
1268 sizeof(RICsubscriptionResponse_IEs_t));
1269 if(ricSubscriptionRsp->protocolIEs.list.array[idx] == NULLP)
1278 ricSubscriptionRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICrequestID;
1279 ricSubscriptionRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1280 ricSubscriptionRsp->protocolIEs.list.array[idx]->value.present =\
1281 RICsubscriptionRequest_IEs__value_PR_RICrequestID;
1282 BuildRicRequestIdret =
1283 BuildRicRequestId(&ricSubscriptionRsp->protocolIEs.list.array[idx]->value.choice.RICrequestID);
1284 if(BuildRicRequestIdret != ROK)
1291 ricSubscriptionRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionID;
1292 ricSubscriptionRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1293 ricSubscriptionRsp->protocolIEs.list.array[idx]->value.present =\
1294 RICsubscriptionRequest_IEs__value_PR_RANfunctionID;
1295 ricSubscriptionRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionID = 1;
1298 ricSubscriptionRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICactions_Admitted;
1299 ricSubscriptionRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1300 ricSubscriptionRsp->protocolIEs.list.array[idx]->value.present =\
1301 RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List;
1302 BuildRicAdmitListret =
1303 BuildRicAdmitList(&ricSubscriptionRsp->protocolIEs.list.array[idx]->value.choice.RICaction_Admitted_List);
1304 if(BuildRicAdmitListret != ROK)
1313 /*******************************************************************
1315 * @brief Builds and Send the RicSubscriptionRsp
1319 * Function : BuildAndSendRicSubscriptionRsp
1321 * Functionality:Fills the RicSubscriptionRsp
1323 * @return ROK - success
1326 ******************************************************************/
1328 uint8_t BuildAndSendRicSubscriptionRsp()
1331 E2AP_PDU_t *e2apRicMsg = NULLP;
1332 RICsubscriptionResponse_t *ricSubscriptionRsp=NULLP;
1333 asn_enc_rval_t encRetVal;
1334 uint8_t ret = RFAILED;
1335 uint8_t FillRicricSubscriptionRspret;
1339 DU_LOG("\nINFO --> E2AP : Building RIC Subscription Response\n");
1341 DU_ALLOC(e2apRicMsg, sizeof(E2AP_PDU_t));
1342 if(e2apRicMsg == NULLP)
1344 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1347 e2apRicMsg->present = E2AP_PDU_PR_successfulOutcome;
1348 DU_ALLOC(e2apRicMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
1349 if(e2apRicMsg->choice.successfulOutcome == NULLP)
1351 DU_LOG("\nERROR --> E2AP : Memory allocation for RIC subscription Response failed");
1355 e2apRicMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_RICsubscription;
1356 e2apRicMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
1357 e2apRicMsg->choice.successfulOutcome->value.present = \
1358 SuccessfulOutcomeE2__value_PR_RICsubscriptionResponse;
1359 ricSubscriptionRsp = &e2apRicMsg->choice.successfulOutcome->value.choice.RICsubscriptionResponse;
1361 FillRicricSubscriptionRspret = FillRicSubscriptionRsp(ricSubscriptionRsp);
1362 if(FillRicricSubscriptionRspret != ROK)
1364 DU_LOG("\nERROR --> E2AP : Memory allocation for RICsubscriptionResponseIE failed");
1368 /* Prints the Msg formed */
1369 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apRicMsg);
1371 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1373 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apRicMsg, PrepFinalEncBuf,\
1375 if(encRetVal.encoded == ENCODE_FAIL)
1377 DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Response structure (at %s)\n",\
1378 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1383 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC subscription response \n");
1384 #ifdef DEBUG_ASN_PRINT
1385 for(int i=0; i< encBufSize; i++)
1387 printf("%x",encBuf[i]);
1392 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
1394 DU_LOG("\nERROR --> E2AP : Sending RIC Subscription Response failed");
1402 FreeRicSubscriptionRsp(e2apRicMsg);
1407 /******************************************************************
1409 * @brief Deallocation of memory allocated bu aper decoder for e2 setup response
1413 * Function : freeAperDecodingOfE2SetupRsp
1415 * Functionality: Deallocation of memory allocated bu aper decoder for e2
1418 * @params[in] E2setupResponse_t *e2SetRspMsg;
1421 * ****************************************************************/
1422 void freeAperDecodingOfE2SetupRsp(E2setupResponse_t *e2SetRspMsg)
1424 uint8_t arrIdx, e2NodeConfigAddAckListIdx;
1425 E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAddAckItem;
1426 E2nodeComponentConfigAdditionAck_List_t *e2NodeConfigAddAckList;
1430 if(e2SetRspMsg->protocolIEs.list.array)
1432 for(arrIdx=0; arrIdx<e2SetRspMsg->protocolIEs.list.count; arrIdx++)
1434 if(e2SetRspMsg->protocolIEs.list.array[arrIdx])
1436 switch(e2SetRspMsg->protocolIEs.list.array[arrIdx]->id)
1438 case ProtocolIE_IDE2_id_TransactionID:
1441 case ProtocolIE_IDE2_id_GlobalRIC_ID:
1443 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.pLMN_Identity.buf);
1444 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.ric_ID.buf);
1448 case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
1450 e2NodeConfigAddAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List;
1451 if(e2NodeConfigAddAckList->list.array )
1453 for(e2NodeConfigAddAckListIdx = 0; e2NodeConfigAddAckListIdx< e2NodeConfigAddAckList->list.count; e2NodeConfigAddAckListIdx++)
1455 if(e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx])
1457 e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx];
1458 free(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.choice.\
1459 e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf);
1460 free(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.choice.\
1461 e2nodeComponentInterfaceTypeF1);
1462 free(e2NodeConfigAddAckList->list.array[e2NodeConfigAddAckListIdx]);
1465 free(e2NodeConfigAddAckList->list.array);
1470 free(e2SetRspMsg->protocolIEs.list.array[arrIdx]);
1473 free(e2SetRspMsg->protocolIEs.list.array);
1477 /******************************************************************
1479 * @brief Processes E2 Setup Response sent by RIC
1483 * Function : procE2SetupRsp
1485 * Functionality: Processes E2 Setup Response sent by RIC
1487 * @params[in] E2AP_PDU_t ASN decoded E2AP message
1488 * @return ROK - success
1491 * ****************************************************************/
1492 uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg)
1494 uint8_t arrIdx =0, transId=0;
1495 uint32_t recvBufLen;
1496 E2setupResponse_t *e2SetRspMsg;
1498 E2NodeComponent *e2NodeComponentInfo;
1500 DU_LOG("\nINFO --> E2AP : E2 Setup Response received");
1501 duCb.e2Status = TRUE; //Set E2 status as true
1502 e2SetRspMsg = &e2apMsg->choice.successfulOutcome->value.choice.E2setupResponse;
1504 for(arrIdx=0; arrIdx<e2SetRspMsg->protocolIEs.list.count; arrIdx++)
1506 switch(e2SetRspMsg->protocolIEs.list.array[arrIdx]->id)
1508 case ProtocolIE_IDE2_id_TransactionID:
1510 transId = e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
1511 if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\
1512 (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
1513 memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
1516 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
1522 case ProtocolIE_IDE2_id_GlobalRIC_ID:
1524 /* To store the Ric Id Params */
1525 recvBufLen = sizeof(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value\
1526 .choice.GlobalRIC_ID.pLMN_Identity.size);
1527 memcpy(&duCb.e2apDb.ricId.plmnId, e2SetRspMsg->protocolIEs.list.array[arrIdx]\
1528 ->value.choice.GlobalRIC_ID.pLMN_Identity.buf, recvBufLen);
1529 bitStringToInt(&e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.ric_ID, &duCb.e2apDb.ricId);
1530 /*TODO : duCb.e2apDb.ricId.plmnId memory to be deallocated after the usage */
1534 case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
1538 DU_LOG("\nERROR --> E2AP : Invalid IE received in E2SetupRsp:%ld",
1539 e2SetRspMsg->protocolIEs.list.array[arrIdx]->id);
1543 freeAperDecodingOfE2SetupRsp(e2SetRspMsg);
1545 node = searchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD);
1548 DU_LOG("\nERROR --> E2AP : Received e2NodeComponentInfo is null");
1553 e2NodeComponentInfo = (E2NodeComponent*)node->node;
1554 cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node);
1555 DU_FREE(e2NodeComponentInfo->componentRequestPart, e2NodeComponentInfo->reqBufSize);
1556 DU_FREE(e2NodeComponentInfo->componentResponsePart, e2NodeComponentInfo->rspBufSize);
1557 DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
1558 DU_FREE(node, sizeof(CmLList));
1561 BuildAndSendE2NodeConfigUpdate();
1565 /******************************************************************
1567 * @brief Processes RIC Subscription Req sent by RIC
1571 * Function : procRicSubsReq
1573 * Functionality: Processes E2 Setup Response sent by CU
1575 * @params[in] E2AP_PDU_t ASN decoded E2AP message
1576 * @return ROK - success
1579 * ****************************************************************/
1581 uint8_t procRicSubsReq(E2AP_PDU_t *e2apMsg)
1586 CmLList *ricSubscriptionNode = NULLP;
1587 RICsubscriptionRequest_t *ricSubsReq;
1588 RicSubscription *ricSubscriptionInfo;
1589 RICaction_ToBeSetup_ItemIEs_t *actionItem;
1591 DU_LOG("\nINFO --> E2AP : RIC Subscription request received");
1592 ricSubsReq = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionRequest;
1594 for(idx=0; idx<ricSubsReq->protocolIEs.list.count; idx++)
1596 if(ricSubsReq->protocolIEs.list.array[idx])
1598 switch(ricSubsReq->protocolIEs.list.array[idx]->id)
1600 case ProtocolIE_IDE2_id_RICrequestID:
1602 /* TODO :- ricSubscriptionInfo details will be stored based on
1603 * RAN function id, so first we need to search RAN function and then add
1604 * subscription details to that ran function */
1605 DU_ALLOC(ricSubscriptionInfo, sizeof(RicSubscription));
1606 if(!ricSubscriptionInfo)
1608 DU_LOG("\nERROR --> E2AP : Memory allocation failed for ricSubscriptionInfo");
1611 ricSubscriptionInfo->requestId.requestorId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID;
1612 ricSubscriptionInfo->requestId.instanceId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID;
1613 DU_ALLOC(ricSubscriptionNode, sizeof(CmLList));
1614 if(ricSubscriptionNode)
1616 ricSubscriptionNode->node = (PTR) ricSubscriptionInfo;
1617 cmLListAdd2Tail(&duCb.e2apDb.ranFunction[0].subscriptionList,ricSubscriptionNode);
1621 case ProtocolIE_IDE2_id_RANfunctionID:
1623 duCb.e2apDb.ranFunction[0].id = ricSubsReq->protocolIEs.list.array[idx]-> \
1624 value.choice.RANfunctionID;
1627 case ProtocolIE_IDE2_id_RICsubscriptionDetails:
1629 if(ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.\
1632 actionItem =(RICaction_ToBeSetup_ItemIEs_t *)ricSubsReq->protocolIEs.list\
1633 .array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List\
1636 for(ied = 0; ied < ricSubsReq->protocolIEs.list.array[idx]->value.choice.\
1637 RICsubscriptionDetails.ricAction_ToBeSetup_List.list.count; ied++)
1639 switch(actionItem->id)
1641 case ProtocolIE_IDE2_id_RICaction_ToBeSetup_Item:
1643 ricSubscriptionInfo->actionSequence[0].id = actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionID;
1644 ricSubscriptionInfo->actionSequence[0].type = actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionType;
1648 DU_LOG("\nERROR --> E2AP : Invalid IE received in RicSetupLst:%ld",actionItem->id);
1653 free(ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.\
1660 DU_LOG("\nERROR --> E2AP : Invalid IE received in RIC SubsReq:%ld",
1661 ricSubsReq->protocolIEs.list.array[idx]->id);
1664 free(ricSubsReq->protocolIEs.list.array[idx]);
1667 free(ricSubsReq->protocolIEs.list.array);
1668 ret = BuildAndSendRicSubscriptionRsp();
1670 BuildAndSendRicIndication(ricSubscriptionInfo);
1676 /*******************************************************************
1678 * @brief Free the RicIndication Message
1682 * Function : FreeRicIndication
1684 * Functionality: Free the RicIndication Message
1689 ******************************************************************/
1690 void FreeRicIndication(E2AP_PDU_t *e2apMsg)
1693 RICindication_t *ricIndicationMsg= NULLP;
1696 if(e2apMsg != NULLP)
1698 if(e2apMsg->choice.initiatingMessage != NULLP)
1700 ricIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.RICindication;
1701 if(ricIndicationMsg!= NULLP)
1703 if(ricIndicationMsg->protocolIEs.list.array != NULLP)
1705 for(idx=0; idx<ricIndicationMsg->protocolIEs.list.count; idx++)
1707 if(ricIndicationMsg->protocolIEs.list.array[idx] != NULLP)
1709 switch(ricIndicationMsg->protocolIEs.list.array[idx]->id)
1711 case ProtocolIE_IDE2_id_RICrequestID:
1714 case ProtocolIE_IDE2_id_RANfunctionID:
1717 case ProtocolIE_IDE2_id_RICactionID:
1720 case ProtocolIE_IDE2_id_RICindicationType:
1723 case ProtocolIE_IDE2_id_RICindicationHeader:
1725 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf,\
1726 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size);
1729 case ProtocolIE_IDE2_id_RICindicationMessage:
1731 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf,\
1732 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size);
1738 DU_FREE(ricIndicationMsg->protocolIEs.list.array[idx],sizeof(RICindication_IEs_t));
1741 DU_FREE(ricIndicationMsg->protocolIEs.list.array,ricIndicationMsg->protocolIEs.list.size);
1744 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1746 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
1749 /*******************************************************************
1751 * brief Fill the RicIndication Message
1755 * Function : FillRicIndication
1757 * Functionality:Fills the RicIndication Message
1759 * @return ROK - success
1762 ******************************************************************/
1763 uint8_t FillRicIndication(RICindication_t *ricIndicationMsg, RicSubscription *ricSubscriptionInfo)
1765 uint8_t elementCnt=0;
1770 ricIndicationMsg->protocolIEs.list.count = elementCnt;
1771 ricIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(RICindication_t);
1772 /* Initialize the Ric Indication members */
1773 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array, \
1774 ricIndicationMsg->protocolIEs.list.size);
1775 if(ricIndicationMsg->protocolIEs.list.array == NULLP)
1777 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
1782 for(idx=0; idx<elementCnt; idx++)
1784 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx],\
1785 sizeof(RICindication_IEs_t));
1786 if(ricIndicationMsg->protocolIEs.list.array[idx] == NULLP)
1788 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
1796 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICrequestID;
1797 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1798 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1799 RICindication_IEs__value_PR_RICrequestID;
1800 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID =ricSubscriptionInfo->requestId.requestorId;
1801 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID = ricSubscriptionInfo->requestId.instanceId;
1804 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionID;
1805 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1806 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1807 RICindication_IEs__value_PR_RANfunctionID;
1808 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RANfunctionID = duCb.e2apDb.ranFunction[0].id;
1811 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICactionID;
1812 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1813 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1814 RICindication_IEs__value_PR_RICactionID;
1815 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICactionID = ricSubscriptionInfo->actionSequence[0].id;
1818 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationType;
1819 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1820 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1821 RICindication_IEs__value_PR_RICindicationType;
1822 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationType = ricSubscriptionInfo->actionSequence[0].type;
1825 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationHeader;
1826 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1827 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1828 RICindication_IEs__value_PR_RICindicationHeader;
1829 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size = 3 *
1831 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf ,\
1832 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.size);
1833 if(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf == NULLP)
1835 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
1840 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
1841 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationHeader.buf);
1843 /* TO BE CHANGED: RIC INDICATION DATA */
1844 /* For now filling a dummy octect data, need to tested with PRBs*/
1845 ricIndicationMsg->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RICindicationMessage;
1846 ricIndicationMsg->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
1847 ricIndicationMsg->protocolIEs.list.array[idx]->value.present = \
1848 RICindication_IEs__value_PR_RICindicationMessage;
1849 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size = 3 *
1851 DU_ALLOC(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf ,\
1852 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.size);
1853 if(ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf == NULLP)
1855 DU_LOG("\nERROR --> E2AP : Memory allocation for RICindicationIEs failed");
1860 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn, \
1861 ricIndicationMsg->protocolIEs.list.array[idx]->value.choice.RICindicationMessage.buf);
1869 /*******************************************************************
1871 * @brief Builds and Send the RicIndication Message
1875 * Function : BuildAndSendRicIndication
1877 * Functionality:Fills the RicIndication Message
1879 * @return ROK - success
1882 ******************************************************************/
1884 uint8_t BuildAndSendRicIndication(RicSubscription *ricSubscriptionInfo)
1886 E2AP_PDU_t *e2apMsg = NULLP;
1887 RICindication_t *ricIndicationMsg=NULLP;
1888 asn_enc_rval_t encRetVal; /* Encoder return value */
1889 uint8_t ret = RFAILED;
1890 uint8_t FillRicIndicationret = ROK;
1894 DU_LOG("\nINFO --> E2AP : Building RIC Indication Message\n");
1896 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
1897 if(e2apMsg == NULLP)
1899 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1903 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
1904 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1905 if(e2apMsg->choice.initiatingMessage == NULLP)
1907 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
1910 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICindication;
1911 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
1912 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICindication;
1914 ricIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.RICindication;
1916 FillRicIndicationret = FillRicIndication(ricIndicationMsg, ricSubscriptionInfo);
1917 if(FillRicIndicationret != ROK)
1921 /* Prints the Msg formed */
1922 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
1923 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1925 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
1927 if(encRetVal.encoded == ENCODE_FAIL)
1929 DU_LOG("\nERROR --> E2AP : Could not encode RIC Indication Message (at %s)\n",\
1930 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1935 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Indication Message \n");
1936 #ifdef DEBUG_ASN_PRINT
1937 for(int i=0; i< encBufSize; i++)
1939 printf("%x",encBuf[i]);
1944 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
1946 DU_LOG("\nINFO --> E2AP : Sending RIC Indication Message");
1952 FreeRicIndication(e2apMsg);
1956 /*******************************************************************
1958 * @brief Deallocate the memory allocated for E2nodeConfigurationUpdate msg
1962 * Function : FreeE2NodeConfigUpdate
1965 * - freeing the memory allocated for E2nodeConfigurationUpdate
1967 * @params[in] E2AP_PDU_t *e2apMsg
1968 * @return ROK - success
1971 * ****************************************************************/
1972 void FreeE2NodeConfigUpdate(E2AP_PDU_t *e2apMsg)
1975 E2nodeConfigurationUpdate_t *e2NodeConfigUpdate;
1977 if(e2apMsg != NULLP)
1979 if(e2apMsg->choice.initiatingMessage != NULLP)
1981 e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate;
1982 if(e2NodeConfigUpdate->protocolIEs.list.array != NULLP)
1984 for(arrIdx = 0; arrIdx < e2NodeConfigUpdate->protocolIEs.list.count; arrIdx++)
1986 DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t));
1988 DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size);
1990 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
1992 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
1996 /*******************************************************************
1998 * @brief Buld and send the E2 node config update msg
2002 * Function : BuildAndSendE2NodeConfigUpdate
2005 * - Buld and send the E2 node config update msg
2008 * @return ROK - success
2011 * ****************************************************************/
2013 uint8_t BuildAndSendE2NodeConfigUpdate()
2015 uint8_t arrIdx = 0,elementCnt = 1;
2017 E2AP_PDU_t *e2apMsg = NULLP;
2018 E2nodeConfigurationUpdate_t *e2NodeConfigUpdate = NULLP;
2019 asn_enc_rval_t encRetVal; /* Encoder return value */
2021 DU_LOG("\nINFO --> E2AP : Building E2 Node config update\n");
2024 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
2025 if(e2apMsg == NULLP)
2027 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
2030 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
2031 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
2032 if(e2apMsg->choice.initiatingMessage == NULLP)
2034 DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
2035 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
2038 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
2039 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2nodeConfigurationUpdate;
2040 e2apMsg->choice.initiatingMessage->value.present = \
2041 InitiatingMessageE2__value_PR_E2nodeConfigurationUpdate;
2042 e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate;
2044 e2NodeConfigUpdate->protocolIEs.list.count = elementCnt;
2045 e2NodeConfigUpdate->protocolIEs.list.size = elementCnt * sizeof(E2nodeConfigurationUpdate_IEs_t*);
2046 /* Initialize the Ric Indication members */
2047 DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array, \
2048 e2NodeConfigUpdate->protocolIEs.list.size);
2049 if(e2NodeConfigUpdate->protocolIEs.list.array == NULLP)
2051 DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed");
2055 for(arrIdx =0; arrIdx<elementCnt; arrIdx++)
2057 DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t));
2058 if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx] == NULLP)
2061 DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed");
2068 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
2069 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
2070 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_TransactionID;
2071 e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = TRANS_ID;
2074 /* Prints the Msg formed */
2075 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
2077 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2079 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
2081 if(encRetVal.encoded == ENCODE_FAIL)
2083 DU_LOG("\nERROR --> E2AP : Could not encode E2nodeConfigurationUpdate structure (at %s)\n",\
2084 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2089 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2nodeConfigurationUpdate\n");
2090 #ifdef DEBUG_ASN_PRINT
2091 for(int i=0; i< encBufSize; i++)
2093 printf("%x",encBuf[i]);
2097 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize))
2099 DU_LOG("\nERROR --> E2AP : Sending E2 node config update failed");
2106 FreeE2NodeConfigUpdate(e2apMsg);
2110 /*******************************************************************
2112 * @brief Deallocate the memory allocated for E2ResetRequest msg
2116 * Function : FreeE2ResetRequest
2119 * - freeing the memory allocated for E2ResetRequest
2121 * @params[in] E2AP_PDU_t *e2apMsg
2122 * @return ROK - success
2125 * ****************************************************************/
2126 void FreeE2ResetRequest(E2AP_PDU_t *e2apMsg)
2129 ResetRequestE2_t *resetReq = NULLP;
2131 if(e2apMsg != NULLP)
2133 if(e2apMsg->choice.initiatingMessage != NULLP)
2135 resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2;
2136 if(resetReq->protocolIEs.list.array)
2138 for(ieIdx = 0; ieIdx < resetReq->protocolIEs.list.count; ieIdx++)
2140 DU_FREE(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t));
2142 DU_FREE(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size);
2144 DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
2146 DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
2150 /*******************************************************************
2152 * @brief Build and send the E2 reset request msg
2156 * Function : BuildAndSendE2ResetRequest
2159 * - Buld and send the E2 reset request msg to RIC
2162 * @return ROK - success
2165 * ****************************************************************/
2166 uint8_t BuildAndSendE2ResetRequest(E2CauseType failureType, E2Cause failureCause)
2168 uint8_t ieIdx = 0, elementCnt = 0, transId = 0;
2169 uint8_t ret = RFAILED;
2170 E2AP_PDU_t *e2apMsg = NULLP;
2171 ResetRequestE2_t *resetReq = NULLP;
2172 asn_enc_rval_t encRetVal; /* Encoder return value */
2174 DU_LOG("\nINFO --> E2AP : Building E2 Reset Request\n");
2178 DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
2179 if(e2apMsg == NULLP)
2181 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for E2AP-PDU failed");
2185 e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
2186 DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
2187 if(e2apMsg->choice.initiatingMessage == NULLP)
2189 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation for initiatingMessage");
2193 e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_Reset;
2194 e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
2195 e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ResetRequestE2;
2196 resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2;
2199 resetReq->protocolIEs.list.count = elementCnt;
2200 resetReq->protocolIEs.list.size = elementCnt * sizeof(ResetRequestIEs_t *);
2202 DU_ALLOC(resetReq->protocolIEs.list.array, resetReq->protocolIEs.list.size);
2203 if(!resetReq->protocolIEs.list.array)
2205 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \
2206 Reset Request IE array");
2210 for(ieIdx = 0; ieIdx < elementCnt; ieIdx++)
2212 DU_ALLOC(resetReq->protocolIEs.list.array[ieIdx], sizeof(ResetRequestIEs_t));
2213 if(!resetReq->protocolIEs.list.array[ieIdx])
2215 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest(): Memory allocation failed for \
2216 Reset Request IE array element");
2221 /* In case of failure */
2222 if(ieIdx < elementCnt)
2226 resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
2227 resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
2228 resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_TransactionID;
2229 transId = assignTransactionId();
2230 resetReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
2233 resetReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_CauseE2;
2234 resetReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_ignore;
2235 resetReq->protocolIEs.list.array[ieIdx]->value.present = ResetRequestIEs__value_PR_CauseE2;
2236 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.present = failureType;
2237 switch(resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.present)
2239 case CauseE2_PR_NOTHING:
2241 case CauseE2_PR_ricRequest:
2242 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.ricRequest = failureCause;
2244 case CauseE2_PR_ricService:
2245 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.ricService = failureCause;
2247 case CauseE2_PR_e2Node:
2248 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.e2Node = failureCause;
2250 case CauseE2_PR_transport:
2251 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.transport = failureCause;
2253 case CauseE2_PR_protocol:
2254 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.protocol = failureCause;
2256 case CauseE2_PR_misc:
2257 resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.misc = failureCause;
2261 /* Prints the Msg formed */
2262 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
2264 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2266 encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
2268 if(encRetVal.encoded == ENCODE_FAIL)
2270 DU_LOG("\nERROR --> E2AP : Could not encode E2SetupRequest structure (at %s)\n",\
2271 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2276 DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2SetupRequest\n");
2277 #ifdef DEBUG_ASN_PRINT
2278 for(int i=0; i< encBufSize; i++)
2280 printf("%x",encBuf[i]);
2284 if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
2286 DU_LOG("\nERROR --> E2AP : Sending E2 Setup request failed");
2290 /* In case the message is sent successfully, store the transaction info to
2291 * be used when response is received */
2292 duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId;
2293 duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
2299 /* Free all memory */
2300 FreeE2ResetRequest(e2apMsg);
2304 /*******************************************************************
2306 * @brief Deallocate the memory allocated for Reset Response msg
2310 * Function : freeAperDecodingOfE2ResetRsp
2313 * - freeing the memory allocated for Reset response
2315 * @params[in] ResetResponseE2_t *resetResponse
2318 * ****************************************************************/
2319 void freeAperDecodingOfE2ResetRsp(ResetResponseE2_t *resetResponse)
2325 if(resetResponse->protocolIEs.list.array)
2327 for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++)
2329 if(resetResponse->protocolIEs.list.array[ieIdx])
2331 switch(resetResponse->protocolIEs.list.array[ieIdx]->id)
2333 case ProtocolIE_IDE2_id_TransactionID:
2336 case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
2339 free(resetResponse->protocolIEs.list.array[ieIdx]);
2342 free(resetResponse->protocolIEs.list.array);
2347 /******************************************************************
2349 * @brief Processes E2 Reset Response sent by RIC
2353 * Function : procResetResponse
2355 * Functionality: Processes E2 Reset Response sent by RIC
2357 * @params[in] E2AP_PDU_t ASN decoded E2AP message
2358 * @return ROK - success
2361 * ****************************************************************/
2362 uint8_t procResetResponse(E2AP_PDU_t *e2apMsg)
2364 uint8_t ieIdx =0, transId;
2365 ResetResponseE2_t *resetResponse;
2367 DU_LOG("\nINFO --> E2AP : E2 Reset Response received");
2368 resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2;;
2370 for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++)
2372 switch(resetResponse->protocolIEs.list.array[ieIdx]->id)
2374 case ProtocolIE_IDE2_id_TransactionID:
2375 transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
2376 if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) && \
2377 (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
2378 memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
2381 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
2385 case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
2386 /* As per ORAN WG3 E2AP spec v3.0, section 9.2.2
2387 Criticality Diagnostics IE is sent by Near-RT RIC when parts of a received message i.e.
2388 Reset Request in this case, have not been comprehended or were missing, or if the message
2389 contained logical errors.
2391 Processing of this ID should be implemented when negative call flows are to be supported.
2395 DU_LOG("\nERROR --> E2AP : Invalid IE received in E2 Reset Response : %ld",
2396 resetResponse->protocolIEs.list.array[ieIdx]->id);
2401 freeAperDecodingOfE2ResetRsp(resetResponse);
2405 /******************************************************************
2407 * @brief Deallocation of memory allocated bu aper decoder for e2 setup Failure
2411 * Function : freeAperDecodingOfE2SetupFailure
2413 * Functionality: Deallocation of memory allocated bu aper decoder for e2
2416 * @params[in] E2setupFailure_t *e2SetupFailure;
2419 * ****************************************************************/
2420 void freeAperDecodingOfE2SetupFailure(E2setupFailure_t *e2SetupFailure)
2426 if(e2SetupFailure->protocolIEs.list.array)
2428 for(arrIdx=0; arrIdx<e2SetupFailure->protocolIEs.list.count; arrIdx++)
2430 if(e2SetupFailure->protocolIEs.list.array[arrIdx])
2432 free(e2SetupFailure->protocolIEs.list.array[arrIdx]);
2435 free(e2SetupFailure->protocolIEs.list.array);
2439 /******************************************************************
2441 * @brief Processes E2 Setup Failure sent by RIC
2445 * Function : procE2SetupFailure
2447 * Functionality: Processes E2 Setup failure sent by RIC
2449 * @params[in] E2AP_PDU_t ASN decoded E2AP message
2450 * @return ROK - success
2453 * ****************************************************************/
2454 void procE2SetupFailure(E2AP_PDU_t *e2apMsg)
2456 uint8_t arrIdx =0, transId =0, timerValue=0;
2457 E2setupFailure_t *e2SetupFailure;
2459 DU_LOG("\nINFO --> E2AP : E2 Setup failure received");
2460 e2SetupFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2setupFailure;
2462 for(arrIdx=0; arrIdx<e2SetupFailure->protocolIEs.list.count; arrIdx++)
2464 switch(e2SetupFailure->protocolIEs.list.array[arrIdx]->id)
2466 case ProtocolIE_IDE2_id_TransactionID:
2468 transId = e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
2469 if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\
2470 (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
2471 memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
2474 DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
2479 case ProtocolIE_IDE2_id_TimeToWaitE2:
2481 timerValue = covertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2);
2482 if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR)) == FALSE)
2484 duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR, timerValue);
2488 DU_LOG("\nERROR --> E2AP : EVENT_E2_SETUP_TMR timer is already running");
2496 freeAperDecodingOfE2SetupFailure(e2SetupFailure);
2498 /*******************************************************************
2500 * @brief Handles received E2AP message and sends back response
2504 * Function : E2APMsgHdlr
2507 * - Decodes received E2AP control message
2508 * - Prepares response message, encodes and sends to SCTP
2511 * @return ROK - success
2514 * ****************************************************************/
2515 void E2APMsgHdlr(Buffer *mBuf)
2518 char *recvBuf = NULLP;
2520 MsgLen recvBufLen =0;
2521 E2AP_PDU_t *e2apMsg = NULLP;
2522 asn_dec_rval_t rval ={0}; /* Decoder return value */
2523 E2AP_PDU_t e2apasnmsg={0} ;
2525 DU_LOG("\nDEBUG --> E2AP : Received E2AP message buffer");
2526 ODU_PRINT_MSG(mBuf, 0,0);
2528 /* Copy mBuf into char array to decode it */
2529 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
2530 DU_ALLOC(recvBuf, (Size)recvBufLen);
2532 if(recvBuf == NULLP)
2534 DU_LOG("\nERROR --> E2AP : Memory allocation failed");
2537 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
2539 DU_LOG("\nERROR --> E2AP : Failed while copying %d", copyCnt);
2543 #ifdef DEBUG_ASN_PRINT
2544 printf("\nDEBUG --> E2AP : Received flat buffer to be decoded : ");
2545 for(i=0; i< recvBufLen; i++)
2547 printf("%x",recvBuf[i]);
2551 /* Decoding flat buffer into E2AP messsage */
2552 e2apMsg = &e2apasnmsg;
2553 memset(e2apMsg, 0, sizeof(E2AP_PDU_t));
2555 rval = aper_decode(0, &asn_DEF_E2AP_PDU, (void **)&e2apMsg, recvBuf, recvBufLen, 0, 0);
2556 DU_FREE(recvBuf, (Size)recvBufLen);
2558 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
2560 DU_LOG("\nERROR --> E2AP : ASN decode failed");
2564 xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
2566 switch(e2apMsg->present)
2568 case E2AP_PDU_PR_unsuccessfulOutcome:
2570 switch(e2apMsg->choice.unsuccessfulOutcome->value.present)
2572 case UnsuccessfulOutcomeE2__value_PR_E2setupFailure:
2574 procE2SetupFailure(e2apMsg);
2579 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_unsuccessfulOutcome [%d]",\
2580 e2apMsg->choice.unsuccessfulOutcome->value.present);
2586 case E2AP_PDU_PR_successfulOutcome:
2588 switch(e2apMsg->choice.successfulOutcome->value.present)
2590 case SuccessfulOutcomeE2__value_PR_E2setupResponse:
2594 procE2SetupRsp(e2apMsg);
2598 case SuccessfulOutcomeE2__value_PR_E2nodeConfigurationUpdateAcknowledge:
2600 DU_LOG("\nDEBUG --> E2AP : E2 node Config update ack message recevied");
2603 case SuccessfulOutcomeE2__value_PR_ResetResponseE2:
2605 procResetResponse(e2apMsg);
2610 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_successfulOutcome [%d]",\
2611 e2apMsg->choice.successfulOutcome->value.present);
2614 }/* End of switch(successfulOutcome) */
2615 free(e2apMsg->choice.successfulOutcome);
2619 case E2AP_PDU_PR_initiatingMessage:
2621 switch(e2apMsg->choice.initiatingMessage->value.present)
2623 case InitiatingMessageE2__value_PR_RICsubscriptionRequest:
2625 procRicSubsReq(e2apMsg);
2630 DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_initiatingMessage [%d]",\
2631 e2apMsg->choice.initiatingMessage->value.present);
2634 }/* End of switch(initiatingMessage) */
2635 free(e2apMsg->choice.initiatingMessage);
2640 DU_LOG("\nERROR --> E2AP : Invalid type of e2apMsg->present [%d]",e2apMsg->present);
2645 }/* End of switch(e2apMsg->present) */
2647 } /* End of E2APMsgHdlr */
2649 /**********************************************************************
2651 **********************************************************************/