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 *******************************************************************************/
19 /* This file contains F1AP message handler functions */
20 #include "common_def.h"
26 #include "du_app_mac_inf.h"
28 #include "du_app_rlc_inf.h"
29 #include "du_mgr_main.h"
32 #include "FeatureSetUplinkPerCC.h"
33 #include "FeatureSetDownlinkPerCC.h"
34 #include "FeatureSets.h"
35 #include "UE-NR-Capability.h"
36 #include "UE-CapabilityRAT-Container.h"
37 #include "UE-CapabilityRAT-ContainerListRRC.h"
38 #include "GNB-DU-System-Information.h"
39 #include "CellGroupConfigRrc.h"
40 #include "MAC-CellGroupConfig.h"
41 #include "SchedulingRequestConfig.h"
42 #include "SchedulingRequestToAddMod.h"
43 #include "BSR-Config.h"
44 #include "TAG-Config.h"
46 #include "PHR-Config.h"
47 #include "RLC-Config.h"
48 #include "UL-AM-RLC.h"
49 #include "DL-AM-RLC.h"
50 #include "LogicalChannelConfig.h"
51 #include "RLC-BearerConfig.h"
52 #include "PhysicalCellGroupConfig.h"
53 #include "SpCellConfig.h"
54 #include "TDD-UL-DL-ConfigDedicated.h"
55 #include "ServingCellConfig.h"
56 #include "ControlResourceSet.h"
57 #include "SearchSpace.h"
58 #include "PDCCH-Config.h"
59 #include "PDSCH-TimeDomainResourceAllocation.h"
60 #include "PDSCH-TimeDomainResourceAllocationList.h"
61 #include "PDSCH-CodeBlockGroupTransmission.h"
62 #include "PDSCH-ServingCellConfig.h"
63 #include "DMRS-DownlinkConfig.h"
64 #include "PDSCH-Config.h"
65 #include "BWP-DownlinkDedicated.h"
66 #include "PUSCH-TimeDomainResourceAllocation.h"
67 #include "PUSCH-TimeDomainResourceAllocationList.h"
68 #include "DMRS-UplinkConfig.h"
69 #include "PUSCH-Config.h"
70 #include "SRS-ResourceId.h"
71 #include "SRS-Resource.h"
72 #include "SRS-ResourceSet.h"
73 #include "SRS-Config.h"
74 #include "BWP-UplinkDedicated.h"
75 #include "PUSCH-ServingCellConfig.h"
76 #include "UplinkConfig.h"
77 #include "DUtoCURRCContainer.h"
78 #include "GBR-QoSFlowInformation.h"
79 #include "QoSFlowLevelQoSParameters.h"
80 #include "PUCCH-Config.h"
81 #include "PUCCH-ResourceSet.h"
82 #include "PUCCH-Resource.h"
83 #include "PUCCH-PowerControl.h"
85 #include "PUCCH-PathlossReferenceRS.h"
86 #include "PUCCH-format0.h"
87 #include "PUCCH-format1.h"
88 #include "PUCCH-format2.h"
89 #include "PUCCH-format3.h"
90 #include "PUCCH-format4.h"
91 #include "PUCCH-FormatConfig.h"
92 #include "SchedulingRequestResourceConfig.h"
93 #include<ProtocolIE-Field.h>
94 #include "ProtocolExtensionField.h"
95 #include "odu_common_codec.h"
97 #include "du_cell_mgr.h"
98 #include "du_f1ap_msg_hdl.h"
99 #include "DRBs-Setup-Item.h"
100 #include "DLUPTNLInformation-ToBeSetup-List.h"
101 #include "DLUPTNLInformation-ToBeSetup-Item.h"
102 #include "UPTransportLayerInformation.h"
103 #include "GTPTunnel.h"
106 #include "ConfigInterface.h"
107 extern StartupConfig g_cfg;
110 DuCfgParams duCfgParam;
112 /************************************************************************
114 * @brief Converts enum values into actual value of Poll retransmit timer
118 * Function : getPollPdu
120 * Functionality: Converts enum values into actual value of poll
123 * @params[in] Enum value of pollPdu
124 * @return Actual value of pollPdu
126 * **********************************************************************/
128 uint16_t getPollRetxTmr(uint8_t pollRetxTmrCfg)
130 uint16_t pollRetxTmr;
132 /* All values of poll retx timer are at interval of 5ms.
133 * This is valid upto 250ms
134 * Hence converting the enum value to actual value by multiplying it to 5
136 if(pollRetxTmrCfg <= T_PollRetransmit_ms250)
137 pollRetxTmr = (pollRetxTmrCfg + 1) * 5;
140 switch(pollRetxTmrCfg)
142 case T_PollRetransmit_ms300:
145 case T_PollRetransmit_ms350:
148 case T_PollRetransmit_ms400:
151 case T_PollRetransmit_ms450:
154 case T_PollRetransmit_ms500:
157 case T_PollRetransmit_ms800:
161 DU_LOG("\nERROR --> F1AP: Invalid value of Poll Retransmit timer");
168 /*******************************************************************
170 * @brief Converts enum values into actual value of PollPdu
174 * Function : getPollPdu
176 * Functionality: Converts enum values into actual value of PollPdu
178 * @params[in] Enum value of pollPdu
179 * @return Actual value of pollPdu
181 * ****************************************************************/
182 int32_t getPollPdu(uint8_t pollPduCfg)
256 case PollPDU_infinity:
260 DU_LOG("\nERROR --> F1AP: Invalid value of poll pdu");
267 /*******************************************************************
269 * @brief Converts enum values into actual value of poll bytes
273 * Function : getPollByte
275 * Functionality: Converts enum values into actual value of pollBytes
277 * @params[in] Enum value
278 * @return Actual value
280 * ****************************************************************/
281 int32_t getPollByte(uint16_t pollBytesCfg)
331 case PollByte_kB1000:
334 case PollByte_kB1250:
337 case PollByte_kB1500:
340 case PollByte_kB2000:
343 case PollByte_kB3000:
346 case PollByte_kB4000:
349 case PollByte_kB4500:
352 case PollByte_kB5000:
355 case PollByte_kB5500:
358 case PollByte_kB6000:
361 case PollByte_kB6500:
364 case PollByte_kB7000:
367 case PollByte_kB7500:
377 pollBytes = 10000000;
380 pollBytes = 11000000;
383 pollBytes = 12000000;
386 pollBytes = 13000000;
389 pollBytes = 14000000;
392 pollBytes = 15000000;
395 pollBytes = 16000000;
398 pollBytes = 17000000;
401 pollBytes = 18000000;
404 pollBytes = 20000000;
407 pollBytes = 25000000;
410 pollBytes = 30000000;
413 pollBytes = 40000000;
415 case PollByte_infinity:
419 DU_LOG("\nERROR --> F1AP: Invalid value of poll bytes");
425 /*******************************************************************
427 * @brief Converts enum values into actual value of maxRetx
431 * Function : getMaxRetx
433 * Functionality: Converts enum values into actual value of maxRetx
435 * @params[in] Enum value
436 * @return Actual value
438 * ****************************************************************/
439 uint8_t getMaxRetx(uint8_t maxRetxCfg)
444 case UL_AM_RLC__maxRetxThreshold_t1:
447 case UL_AM_RLC__maxRetxThreshold_t2:
450 case UL_AM_RLC__maxRetxThreshold_t3:
453 case UL_AM_RLC__maxRetxThreshold_t4:
456 case UL_AM_RLC__maxRetxThreshold_t6:
459 case UL_AM_RLC__maxRetxThreshold_t8:
462 case UL_AM_RLC__maxRetxThreshold_t16:
465 case UL_AM_RLC__maxRetxThreshold_t32:
469 DU_LOG("\nERROR --> F1AP: Invalid configuration for Max retransmission threshold");
475 /*******************************************************************
476 * @brief Converts enum values into actual value of reassembly timer
480 * Function : getReAsmblTmr
482 * Functionality: Converts enum values into actual value of reassembly
485 * @params[in] Enum value of reassembly timer
486 * @return Actual value of reassembly timer
488 * **********************************************************************/
490 int8_t getReAsmblTmr(uint8_t reAsmblTmrCfg)
492 int8_t reAsmblTmr = 0;
494 if(reAsmblTmrCfg == T_Reassembly_ms0)
498 else if(reAsmblTmrCfg >= T_Reassembly_ms5 || reAsmblTmrCfg <= T_Reassembly_ms100)
500 /* All values of re assembly timer are at interval of 5ms.
501 * This is valid upto 100ms
502 * Hence converting the enum value to actual value by multiplying it to 5
504 reAsmblTmr = reAsmblTmrCfg * 5;
506 else if(reAsmblTmrCfg >= T_Reassembly_ms110 || reAsmblTmrCfg <= T_Reassembly_ms200)
508 /* All values of re assembly timer are at interval of 10ms.
509 * This is valid upto 200ms
510 * since enum value starts from 20 for 100ms, subtracting 10 and
511 * converting the enum value to actual value by multiplying it to 10
513 reAsmblTmr = ((reAsmblTmrCfg-10) * 10);
517 DU_LOG("\nERROR --> F1AP : Invalid value of Re Assembly timer %d", reAsmblTmrCfg);
523 /************************************************************************
525 * @brief Converts enum values into actual value of status prohibit timer
529 * Function : getStatProhTmr
531 * Functionality: Converts enum values into actual value of status prohibit
534 * @params[in] Enum value of status prohibit timer
535 * @return Actual value of status prohibit timer
537 * **********************************************************************/
539 int16_t getStatProhTmr(uint8_t statProhTmrCfg)
541 int16_t statProhTmr =0;
543 if(statProhTmrCfg == T_StatusProhibit_ms0)
547 else if(statProhTmrCfg >= T_StatusProhibit_ms5 || statProhTmrCfg <= T_StatusProhibit_ms250)
549 /* All values of re assembly timer are at interval of 5ms.
550 * This is valid upto 250ms
551 * Hence converting the enum value to actual value by multiplying it to 5
553 statProhTmr = statProhTmrCfg * 5;
557 switch(statProhTmrCfg)
559 case T_StatusProhibit_ms300:
562 case T_StatusProhibit_ms350:
565 case T_StatusProhibit_ms400:
568 case T_StatusProhibit_ms450:
571 case T_StatusProhibit_ms500:
574 case T_StatusProhibit_ms800:
577 case T_StatusProhibit_ms1000:
580 case T_StatusProhibit_ms1200:
583 case T_StatusProhibit_ms1600:
586 case T_StatusProhibit_ms2000:
589 case T_StatusProhibit_ms2400:
593 DU_LOG("\nInvalid value of Status Prohibit timer %d", statProhTmrCfg);
601 /*******************************************************************
603 * @brief Adding F1AP pdu to reserved pdu list
607 * Function : addToReservedF1apPduList
609 * Functionality: Adding F1AP pdu to reserved pdu list.
610 * These pdu are awaiting aknowledgment from CU
612 * @params[in] uint8_t transId, F1AP_PDU_t *f1apMsg
614 * @return ROK - success
617 * ****************************************************************/
619 void addToReservedF1apPduList(uint8_t transId, F1AP_PDU_t *f1apPdu)
621 CmLList *node = NULLP;
622 ReservedF1apPduInfo *pduInfo = NULLP;
623 DU_ALLOC(pduInfo, sizeof(ReservedF1apPduInfo));
626 DU_ALLOC(node, sizeof(CmLList));
629 pduInfo->transId = transId;
630 pduInfo->f1apMsg = (void*) f1apPdu;
632 node->node = (PTR)pduInfo;
633 cmLListAdd2Tail(&duCb.reservedF1apPduList, node);
638 /*******************************************************************
640 * @brief searching for F1AP pdu from ReservedF1apPduList
644 * Function : searchFromReservedF1apPduList
646 * Functionality: searching for F1AP pdu information
648 * @params[in] uint8_t transId
650 * @return pointer to F1AP_PDU_t
652 * ****************************************************************/
654 CmLList *searchFromReservedF1apPduList(uint8_t transId)
657 ReservedF1apPduInfo *f1apPdu;
658 if(duCb.reservedF1apPduList.count)
660 CM_LLIST_FIRST_NODE(&duCb.reservedF1apPduList, node);
663 f1apPdu = (ReservedF1apPduInfo*)node->node;
664 if(f1apPdu->transId == transId)
674 /*******************************************************************
676 * @brief deleting F1AP pdu information from ReservedF1apPduList
680 * Function : deleteFromReservedF1apPduList
682 * Functionality: deleting pdu information from ReservedF1apPduList
684 * @params[in] CmLList *node
688 * ****************************************************************/
690 void deleteFromReservedF1apPduList(CmLList *node)
692 ReservedF1apPduInfo *f1apPdu;
696 f1apPdu = (ReservedF1apPduInfo *)node->node;
697 cmLListDelFrm(&duCb.reservedF1apPduList, node);
698 DU_FREE(f1apPdu, sizeof(ReservedF1apPduInfo));
699 DU_FREE(node, sizeof(CmLList));
704 /*******************************************************************
706 * @brief Builds Uplink Info for NR
710 * Function : BuildULNRInfo
712 * Functionality: Building NR Uplink Info
714 * @params[in] NRFreqInfo_t *ulnrfreq
715 * @return ROK - success
718 * ****************************************************************/
719 uint8_t BuildULNRInfo(NRFreqInfo_t *ulnrfreq)
722 ulnrfreq->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.\
723 fdd.ulNrFreqInfo.nrArfcn;
724 ulnrfreq->freqBandListNr.list.count = 1;
725 ulnrfreq->freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
726 DU_ALLOC(ulnrfreq->freqBandListNr.list.array,ulnrfreq->freqBandListNr.list.size);
727 if(ulnrfreq->freqBandListNr.list.array == NULLP)
731 for(idx=0;idx<ulnrfreq->freqBandListNr.list.count;idx++)
733 DU_ALLOC(ulnrfreq->freqBandListNr.list.array[idx],sizeof(FreqBandNrItem_t));
734 if(ulnrfreq->freqBandListNr.list.array[idx] == NULLP)
739 ulnrfreq->freqBandListNr.list.array[0]->freqBandIndicatorNr = \
740 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
741 freqBand[0].nrFreqBand;
742 ulnrfreq->freqBandListNr.list.array[0]->supportedSULBandList.list.count = SUL_BAND_COUNT;
745 /*******************************************************************
747 * @brief Builds Downlink NR Info
751 * Function : BuildDLNRInfo
753 * Functionality: Building Downlink NR Info
755 * @params[in] NRFreqInfo_t *dlnrfreq
756 * @return ROK - success
759 * ****************************************************************/
760 uint8_t BuildDLNRInfo(NRFreqInfo_t *dlnrfreq)
763 dlnrfreq->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.\
764 fdd.dlNrFreqInfo.nrArfcn;
765 dlnrfreq->freqBandListNr.list.count = 1;
766 dlnrfreq->freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
767 DU_ALLOC(dlnrfreq->freqBandListNr.list.array,dlnrfreq->freqBandListNr.list.size);
768 if(dlnrfreq->freqBandListNr.list.array == NULLP)
772 for(idx=0;idx< dlnrfreq->freqBandListNr.list.count;idx++)
774 DU_ALLOC(dlnrfreq->freqBandListNr.list.array[idx],sizeof(FreqBandNrItem_t));
775 if(dlnrfreq->freqBandListNr.list.array[idx] == NULLP)
780 dlnrfreq->freqBandListNr.list.array[0]->freqBandIndicatorNr = \
781 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
782 freqBand[0].nrFreqBand;
783 dlnrfreq->freqBandListNr.list.array[0]->supportedSULBandList.list.count = SUL_BAND_COUNT;
788 /*******************************************************************
790 * @brief Builds NRCell ID
794 * Function : BuildNrCellId
796 * Functionality: Building the NR Cell ID
798 * @params[in] BIT_STRING_t *nrcell
799 * @return ROK - success
802 * ****************************************************************/
804 S16 BuildNrCellId(BIT_STRING_t *nrcell)
806 memset(nrcell->buf, 0, nrcell->size);
808 nrcell->bits_unused = 4;
812 /*******************************************************************
814 * @brief Builds Nrcgi
818 * Function : BuildNrcgi
820 * Functionality: Building the PLMN ID and NR Cell id
822 * @params[in] NRCGI_t *nrcgi
823 * @return ROK - success
826 * ****************************************************************/
827 uint8_t BuildNrcgi(NRCGI_t *nrcgi)
830 uint8_t byteSize = 5;
831 /* Allocate Buffer Memory */
832 nrcgi->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
833 DU_ALLOC(nrcgi->pLMN_Identity.buf, nrcgi->pLMN_Identity.size);
834 if(nrcgi->pLMN_Identity.buf == NULLP)
838 ret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
839 nrcgi->pLMN_Identity.buf); // Building PLMN function
845 nrcgi->nRCellIdentity.size = byteSize * sizeof(uint8_t);
846 DU_ALLOC(nrcgi->nRCellIdentity.buf, nrcgi->nRCellIdentity.size);
847 if(nrcgi->nRCellIdentity.buf == NULLP)
851 BuildNrCellId(&nrcgi->nRCellIdentity);
855 /*******************************************************************
857 * @brief Builds FiveGStac
861 * Function : BuildFiveGSTac
863 * Functionality: Building the FiveGSTac
865 * @params[in] OCTET_STRING_t *fivegsTac
866 * @return ROK - success
869 * ****************************************************************/
870 uint8_t BuildFiveGSTac(Served_Cell_Information_t *servcell)
872 DU_ALLOC(servcell->fiveGS_TAC,sizeof(FiveGS_TAC_t));
873 if(servcell->fiveGS_TAC == NULLP)
877 servcell->fiveGS_TAC->size = 3 * sizeof(uint8_t);
878 DU_ALLOC(servcell->fiveGS_TAC->buf,\
879 sizeof(servcell->fiveGS_TAC->size));
880 if(servcell->fiveGS_TAC->buf == NULLP)
884 servcell->fiveGS_TAC->buf[0] = 0;
885 servcell->fiveGS_TAC->buf[1] = 0;
886 servcell->fiveGS_TAC->buf[2] = duCfgParam.srvdCellLst[0].duCellInfo.tac;
889 /*******************************************************************
891 * @brief Builds NR Mode
895 * Function : BuildNrMode
897 * Functionality: Building the NR Mode
899 * @params[in] NR_Mode_Info_t *fdd
900 * @return ROK - success
903 * ****************************************************************/
904 uint8_t BuildNrMode(NR_Mode_Info_t *mode)
906 uint8_t BuildDLNRInforet=0;
907 uint8_t BuildULNRInforet=0;
909 mode->present = NR_Mode_Info_PR_fDD;
910 if(mode->present == NR_Mode_Info_PR_fDD)
912 DU_ALLOC(mode->choice.fDD,sizeof(FDD_Info_t));
913 if(mode->choice.fDD == NULLP)
917 BuildULNRInforet = BuildULNRInfo(&mode->choice.fDD->uL_NRFreqInfo);
918 if(BuildULNRInforet != ROK)
922 BuildDLNRInforet = BuildDLNRInfo(&mode->choice.fDD->dL_NRFreqInfo);
923 if(BuildDLNRInforet != ROK)
928 mode->choice.fDD->uL_Transmission_Bandwidth.nRSCS = \
929 duCfgParam.srvdCellLst[0].duCellInfo.\
930 f1Mode.mode.fdd.ulTxBw.nrScs;
931 mode->choice.fDD->uL_Transmission_Bandwidth.nRNRB = \
932 duCfgParam.srvdCellLst[0].duCellInfo.\
933 f1Mode.mode.fdd.ulTxBw.nrb;
934 mode->choice.fDD->dL_Transmission_Bandwidth.nRSCS = \
935 duCfgParam.srvdCellLst[0].duCellInfo.\
936 f1Mode.mode.fdd.dlTxBw.nrScs;
937 mode->choice.fDD->dL_Transmission_Bandwidth.nRNRB = \
938 duCfgParam.srvdCellLst[0].duCellInfo.\
939 f1Mode.mode.fdd.dlTxBw.nrb;
942 /*******************************************************************
944 * @brief Builds IE Extensions for Served PLMNs
948 * Function : BuildExtensions
950 * Functionality: Building the IE Extensions
952 * @params[in] struct ProtocolExtensionContainer_4624P3 *buildextend
953 * @return ROK - success
956 * ****************************************************************/
957 uint8_t BuildExtensions(ProtocolExtensionContainer_4624P3_t **ieExtend)
959 uint8_t idx=0, plmnidx=0, sliceLstIdx=0;
960 uint8_t elementCnt=0, extensionCnt=0;
962 extensionCnt=IE_EXTENSION_LIST_COUNT;
963 DU_ALLOC(*ieExtend,sizeof(ProtocolExtensionContainer_4624P3_t));
964 if((*ieExtend) == NULLP)
966 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
969 (*ieExtend)->list.count = extensionCnt;
970 (*ieExtend)->list.size = \
971 extensionCnt * sizeof(ServedPLMNs_ItemExtIEs_t *);
972 DU_ALLOC((*ieExtend)->list.array,(*ieExtend)->list.size);
973 if((*ieExtend)->list.array == NULLP)
975 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
978 for(plmnidx=0;plmnidx<extensionCnt;plmnidx++)
980 DU_ALLOC((*ieExtend)->list.array[plmnidx],\
981 sizeof(ServedPLMNs_ItemExtIEs_t));
982 if((*ieExtend)->list.array[plmnidx] == NULLP)
984 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
989 elementCnt = NUM_OF_SUPPORTED_SLICE;
991 (*ieExtend)->list.array[idx]->id = ProtocolIE_ID_id_TAISliceSupportList;
992 (*ieExtend)->list.array[idx]->criticality = Criticality_ignore;
993 (*ieExtend)->list.array[idx]->extensionValue.present = \
994 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
995 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
996 list.count = elementCnt;
997 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
998 list.size = (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
999 list.count * sizeof(SliceSupportItem_t *);
1001 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1002 list.array, elementCnt * sizeof(SliceSupportItem_t *));
1003 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1004 list.array == NULLP)
1006 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1010 for(sliceLstIdx =0; sliceLstIdx<elementCnt; sliceLstIdx++)
1012 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1013 list.array[sliceLstIdx],sizeof(SliceSupportItem_t));
1014 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1015 list.array[sliceLstIdx] == NULLP)
1017 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1020 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1021 list.array[sliceLstIdx]->sNSSAI.sST.size = sizeof(uint8_t);
1022 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
1023 .list.array[sliceLstIdx]->sNSSAI.sST.buf,(*ieExtend)->list.array[idx]->\
1024 extensionValue.choice.SliceSupportList.\
1025 list.array[sliceLstIdx]->sNSSAI.sST.size);
1026 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
1027 .list.array[sliceLstIdx]->sNSSAI.sST.buf == NULLP)
1029 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1032 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1033 list.array[sliceLstIdx]->sNSSAI.sST.buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.\
1034 cellInfo.srvdPlmn[0].taiSliceSuppLst.snssai[sliceLstIdx]->sst;
1036 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1037 list.array[sliceLstIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
1038 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1039 list.array[sliceLstIdx]->sNSSAI.sD == NULLP)
1041 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1044 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1045 list.array[sliceLstIdx]->sNSSAI.sD->size = 3 * sizeof(uint8_t);
1046 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1047 list.array[sliceLstIdx]->sNSSAI.sD->buf, (*ieExtend)->list.array[idx]->extensionValue.choice.\
1048 SliceSupportList.list.array[sliceLstIdx]->sNSSAI.sD->size);
1049 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1050 list.array[sliceLstIdx]->sNSSAI.sD->buf == NULLP)
1052 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1055 memcpy((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1056 list.array[sliceLstIdx]->sNSSAI.sD->buf, duCfgParam.srvdCellLst[0].duCellInfo.\
1057 cellInfo.srvdPlmn[0].taiSliceSuppLst.snssai[sliceLstIdx]->sd, (*ieExtend)->list.array[idx]->\
1058 extensionValue.choice.SliceSupportList.list.array[sliceLstIdx]->sNSSAI.sD->size);
1062 /*******************************************************************
1064 * @brief Builds Served PLMN
1068 * Function : BuildServedPlmn
1070 * Functionality: Building the Served PLMN
1072 * @params[in] GNB_DU_Served_Cells_Item_t *srvCellItem
1073 * @return ROK - success
1076 * ****************************************************************/
1077 uint8_t BuildServedPlmn(ServedPLMNs_List_t *srvplmn)
1080 uint8_t servPlmnCnt=1;
1081 uint8_t buildPlmnIdret=0;
1082 uint8_t BuildExtensionsret=0;
1083 srvplmn->list.count = servPlmnCnt;
1084 srvplmn->list.size = \
1085 servPlmnCnt*sizeof(ServedPLMNs_Item_t *);
1086 DU_ALLOC(srvplmn->list.array,srvplmn->list.size);
1087 if(srvplmn->list.array == NULLP)
1091 for(plmnidx=0; plmnidx<servPlmnCnt; plmnidx++)
1093 DU_ALLOC(srvplmn->list.array[plmnidx],\
1094 sizeof(ServedPLMNs_Item_t));
1095 if(srvplmn->list.array[plmnidx] == NULLP)
1100 srvplmn->list.array[0]->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
1101 DU_ALLOC(srvplmn->list.array[0]->pLMN_Identity.buf, srvplmn->list.array[0]->pLMN_Identity.size);
1102 buildPlmnIdret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
1103 srvplmn->list.array[0]->pLMN_Identity.buf);
1104 if(buildPlmnIdret!= ROK)
1108 BuildExtensionsret = BuildExtensions(&srvplmn->list.array[0]->iE_Extensions);
1109 if(BuildExtensionsret!= ROK)
1115 /*******************************************************************
1117 * @brief Builds Served Cell List
1121 * Function : BuildServedCellList
1123 * Functionality: Building Served Cell List
1125 * @params[in] PLMNID plmn
1126 * @return ROK - success
1129 * ****************************************************************/
1131 uint8_t BuildServedCellList(GNB_DU_Served_Cells_List_t *duServedCell)
1133 uint8_t BuildNrcgiret=0;
1134 uint8_t BuildFiveGSTacret=0;
1135 uint8_t BuildServedPlmnret=0;
1136 uint8_t BuildNrModeret=0;
1140 GNB_DU_Served_Cells_Item_t *srvCellItem;
1141 duServedCell->list.size = plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t *);
1142 duServedCell->list.count = plmnCnt;
1144 DU_ALLOC(duServedCell->list.array, duServedCell->list.size);
1145 if(duServedCell->list.array == NULLP)
1149 for(plmnidx=0; plmnidx<plmnCnt; plmnidx++)
1151 DU_ALLOC(duServedCell->list.array[plmnidx],\
1152 sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1153 if(duServedCell->list.array[plmnidx] == NULLP)
1159 duServedCell->list.array[idx]->id = ProtocolIE_ID_id_GNB_DU_Served_Cells_Item;
1160 duServedCell->list.array[idx]->criticality = Criticality_reject;
1161 duServedCell->list.array[idx]->value.present = \
1162 GNB_DU_Served_Cells_ItemIEs__value_PR_GNB_DU_Served_Cells_Item;
1164 &duServedCell->list.array[idx]->value.choice.GNB_DU_Served_Cells_Item;
1166 BuildNrcgiret = BuildNrcgi(&srvCellItem->served_Cell_Information.nRCGI);
1167 if(BuildNrcgiret != ROK)
1172 srvCellItem->served_Cell_Information.nRPCI = \
1173 duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
1176 BuildFiveGSTacret = BuildFiveGSTac(&srvCellItem->served_Cell_Information);
1177 if(BuildFiveGSTacret != ROK)
1182 BuildServedPlmnret = BuildServedPlmn(&srvCellItem->served_Cell_Information.servedPLMNs);
1183 if(BuildServedPlmnret !=ROK)
1187 /*nR Mode Info with FDD*/
1188 BuildNrModeret = BuildNrMode(&srvCellItem->served_Cell_Information.nR_Mode_Info);
1189 if(BuildNrModeret != ROK)
1193 /*Measurement timing Config*/
1194 srvCellItem->served_Cell_Information.measurementTimingConfiguration.\
1195 size = sizeof(uint8_t);
1196 DU_ALLOC(srvCellItem->served_Cell_Information.\
1197 measurementTimingConfiguration.buf,srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1198 if(srvCellItem->served_Cell_Information.\
1199 measurementTimingConfiguration.buf == NULLP)
1203 srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf[0] = \
1204 duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
1206 /* GNB DU System Information */
1207 DU_ALLOC(srvCellItem->gNB_DU_System_Information,
1208 sizeof(GNB_DU_System_Information_t));
1209 if(!srvCellItem->gNB_DU_System_Information)
1214 srvCellItem->gNB_DU_System_Information->mIB_message.size = duCfgParam.srvdCellLst[0].duSysInfo.mibLen;
1215 DU_ALLOC(srvCellItem->gNB_DU_System_Information->mIB_message.buf,
1216 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1217 if(!srvCellItem->gNB_DU_System_Information->mIB_message.buf)
1221 memcpy(srvCellItem->gNB_DU_System_Information->mIB_message.buf, duCfgParam.srvdCellLst[0].duSysInfo.mibMsg, \
1222 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1225 srvCellItem->gNB_DU_System_Information->sIB1_message.size =\
1226 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
1228 DU_ALLOC(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,
1229 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1230 if(!srvCellItem->gNB_DU_System_Information->sIB1_message.buf)
1234 for(int x=0; x<srvCellItem->gNB_DU_System_Information->sIB1_message.size; x++)
1236 srvCellItem->gNB_DU_System_Information->sIB1_message.buf[x]=\
1237 duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg[x];
1241 /*******************************************************************
1243 * @brief Builds RRC Version
1247 * Function : BuildRrcVer
1249 * Functionality: Building RRC Version
1251 * @params[in] int idx,int elementCnt,RRC_Version_t *rrcver
1252 * @return ROK - success
1255 * ****************************************************************/
1256 uint8_t BuildRrcVer(RRC_Version_t *rrcVer)
1260 rrcVer->latest_RRC_Version.size = sizeof(uint8_t);
1261 DU_ALLOC(rrcVer->latest_RRC_Version.buf,sizeof(uint8_t));
1262 if(rrcVer->latest_RRC_Version.buf == NULLP)
1266 rrcVer->latest_RRC_Version.buf[0] = 0;
1267 rrcVer->latest_RRC_Version.bits_unused = 5;
1268 DU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1269 if(rrcVer->iE_Extensions == NULLP)
1273 rrcVer->iE_Extensions->list.count = 1;
1274 rrcVer->iE_Extensions->list.size = sizeof(RRC_Version_ExtIEs_t *);
1275 DU_ALLOC(rrcVer->iE_Extensions->list.array,rrcVer->iE_Extensions->list.size);
1276 if(rrcVer->iE_Extensions->list.array == NULLP)
1281 DU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
1282 sizeof(RRC_Version_ExtIEs_t));
1283 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
1287 rrcVer->iE_Extensions->list.array[rrcExt]->id = \
1288 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
1289 rrcVer->iE_Extensions->list.array[rrcExt]->criticality = Criticality_reject;
1290 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.present =\
1291 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
1292 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1293 .Latest_RRC_Version_Enhanced.size = 3*sizeof(uint8_t);
1294 DU_ALLOC(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1295 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1296 array[rrcExt]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1297 if(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1298 .Latest_RRC_Version_Enhanced.buf == NULLP)
1303 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1304 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 15;
1306 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1307 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 5;
1309 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1310 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 0;
1313 /*******************************************************************
1315 * @brief Sends F1 msg over SCTP
1319 * Function : sendF1APMsg
1321 * Functionality: Sends F1 msg over SCTP
1323 * @params[in] Region region
1325 * @return ROK - success
1328 * ****************************************************************/
1329 uint8_t sendF1APMsg()
1331 Buffer *mBuf = NULLP;
1333 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1335 if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
1337 ODU_PRINT_MSG(mBuf, 0,0);
1339 if(sctpSend(mBuf, F1_INTERFACE) != ROK)
1341 DU_LOG("\nERROR --> F1AP : SCTP Send failed");
1342 ODU_PUT_MSG_BUF(mBuf);
1348 DU_LOG("\nERROR --> F1AP : ODU_ADD_POST_MSG_MULT failed");
1349 ODU_PUT_MSG_BUF(mBuf);
1352 ODU_PUT_MSG_BUF(mBuf);
1356 DU_LOG("\nERROR --> F1AP : Failed to allocate memory");
1362 /*******************************************************************
1364 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1368 * Function : FreeRrcVer
1370 * Functionality: deallocating the memory of function BuildRrcVer
1372 * @params[in] RRC_Version_t *rrcVer
1376 *****************************************************************/
1377 void FreeRrcVer(RRC_Version_t *rrcVer)
1379 if(rrcVer->latest_RRC_Version.buf != NULLP)
1381 if(rrcVer->iE_Extensions != NULLP)
1383 if(rrcVer->iE_Extensions->list.array != NULLP)
1385 if(rrcVer->iE_Extensions->list.array[0] != NULLP)
1387 if(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf
1390 DU_FREE(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice\
1391 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1392 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1394 DU_FREE(rrcVer->iE_Extensions->list.array[0],sizeof(RRC_Version_ExtIEs_t));
1396 DU_FREE(rrcVer->iE_Extensions->list.array,sizeof(RRC_Version_ExtIEs_t*));
1398 DU_FREE(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1400 DU_FREE(rrcVer->latest_RRC_Version.buf,rrcVer->latest_RRC_Version.size);
1403 /*******************************************************************
1405 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1409 * Function : FreeServedCellList
1411 * Functionality: deallocating the memory of function BuildServedCellList
1414 * @params[in] GNB_DU_Served_Cells_List_t *duServedCell
1418 * ****************************************************************/
1419 void FreeServedCellList( GNB_DU_Served_Cells_List_t *duServedCell)
1421 uint8_t plmnCnt=MAX_PLMN;
1422 uint8_t extensionCnt=IE_EXTENSION_LIST_COUNT;
1423 uint8_t plmnIdx=0, sliceIdx=0;
1424 GNB_DU_Served_Cells_Item_t *srvCellItem;
1425 ServedPLMNs_Item_t *servedPlmnItem;
1426 SliceSupportItem_t *sliceSupportItem;
1428 if(duServedCell->list.array!=NULLP)
1430 if(duServedCell->list.array[0]!=NULLP)
1432 srvCellItem= &duServedCell->list.array[0]->value.choice.GNB_DU_Served_Cells_Item;
1434 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1435 srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.size * sizeof(uint8_t));
1436 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1437 srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.size * sizeof(uint8_t));
1439 if(srvCellItem->served_Cell_Information.fiveGS_TAC!=NULLP)
1441 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC->buf,\
1442 sizeof(srvCellItem->served_Cell_Information.fiveGS_TAC->size));
1443 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC,sizeof(FiveGS_TAC_t));
1446 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array!=NULLP)
1448 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx] != NULLP)
1450 servedPlmnItem = srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx];
1451 DU_FREE(servedPlmnItem->pLMN_Identity.buf, servedPlmnItem->pLMN_Identity.size);
1453 if(servedPlmnItem->iE_Extensions != NULLP)
1455 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1457 if(servedPlmnItem->iE_Extensions->list.array[0] != NULLP)
1459 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1460 SliceSupportList.list.array != NULLP)
1462 for(sliceIdx =0; sliceIdx<servedPlmnItem->iE_Extensions->list.array[0]->\
1463 extensionValue.choice.SliceSupportList.list.count; sliceIdx++)
1465 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1466 SliceSupportList.list.array[sliceIdx] != NULLP)
1468 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[0]->\
1469 extensionValue.choice.SliceSupportList.list.array[sliceIdx];
1471 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sizeof(uint8_t));
1473 if(sliceSupportItem->sNSSAI.sD != NULLP)
1475 DU_FREE(sliceSupportItem->sNSSAI.sD->buf,\
1476 sliceSupportItem->sNSSAI.sD->size);
1477 DU_FREE(sliceSupportItem->sNSSAI.sD, sizeof(OCTET_STRING_t));
1480 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.\
1481 choice.SliceSupportList.list.array[sliceIdx], sizeof(SliceSupportItem_t));
1484 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1485 SliceSupportList.list.array, sizeof(SliceSupportItem_t*));
1487 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0],\
1488 sizeof(ServedPLMNs_ItemExtIEs_t));
1490 DU_FREE(servedPlmnItem->iE_Extensions->list.array,\
1491 extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
1493 DU_FREE(servedPlmnItem->iE_Extensions, sizeof(ProtocolExtensionContainer_4624P3_t));
1495 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx],\
1496 sizeof(ServedPLMNs_Item_t));
1498 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array,\
1499 sizeof(ServedPLMNs_Item_t *));
1502 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
1504 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.\
1505 freqBandListNr.list.array != NULLP)
1507 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->\
1508 uL_NRFreqInfo.freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
1509 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->\
1510 uL_NRFreqInfo.freqBandListNr.list.array,sizeof(FreqBandNrItem_t*));
1513 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1514 freqBandListNr.list.array)
1516 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1517 freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
1518 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1519 freqBandListNr.list.array,sizeof(FreqBandNrItem_t *));
1521 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD, sizeof(FDD_Info_t));
1524 DU_FREE(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1525 srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1527 if(srvCellItem->gNB_DU_System_Information != NULLP)
1529 if(srvCellItem->gNB_DU_System_Information->mIB_message.buf != NULLP)
1531 DU_FREE(srvCellItem->gNB_DU_System_Information->mIB_message.buf,\
1532 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1535 if(srvCellItem->gNB_DU_System_Information->sIB1_message.buf != NULLP)
1537 DU_FREE(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,\
1538 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1541 DU_FREE(srvCellItem->gNB_DU_System_Information, sizeof(GNB_DU_System_Information_t));
1544 DU_FREE(duServedCell->list.array[0], sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1546 DU_FREE(duServedCell->list.array, plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t*));
1550 /*******************************************************************
1552 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1556 * Function : FreeF1SetupReq
1558 * Functionality: deallocating the memory of function BuildAndSendF1SetupReq
1560 * @params[in] F1AP_PDU_t *f1apMsg
1564 * ****************************************************************/
1565 void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
1567 uint8_t ieIdx, ieIdx2;
1568 F1SetupRequest_t *f1SetupReq=NULLP;
1570 if(f1apMsg != NULLP)
1572 if(f1apMsg->choice.initiatingMessage != NULLP)
1574 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1575 if(f1SetupReq->protocolIEs.list.array != NULLP)
1577 for(ieIdx = 0; ieIdx < f1SetupReq->protocolIEs.list.count; ieIdx++)
1579 if(f1SetupReq->protocolIEs.list.array[ieIdx] != NULLP)
1581 switch(f1SetupReq->protocolIEs.list.array[ieIdx]->id)
1583 case ProtocolIE_ID_id_TransactionID:
1585 case ProtocolIE_ID_id_gNB_DU_ID:
1586 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1587 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1589 case ProtocolIE_ID_id_gNB_DU_Name:
1590 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf,\
1591 strlen((char *)duCfgParam.duName));
1593 case ProtocolIE_ID_id_gNB_DU_Served_Cells_List:
1594 FreeServedCellList(&f1SetupReq->protocolIEs.list.\
1595 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List);
1597 case ProtocolIE_ID_id_GNB_DU_RRC_Version:
1598 FreeRrcVer(&f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version);
1601 DU_LOG("\nERROR --> Invalid Event Type %ld", f1SetupReq->protocolIEs.list.array[ieIdx]->id);
1606 for(ieIdx2=0; ieIdx2< ieIdx; ieIdx2++)
1608 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx2],sizeof(F1SetupRequestIEs_t));
1610 DU_FREE(f1SetupReq->protocolIEs.list.array,\
1611 f1SetupReq->protocolIEs.list.size);
1613 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1615 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
1618 /*******************************************************************
1620 * @brief Builds and Send the F1SetupRequest
1624 * Function : BuildAndSendF1SetupReq
1626 * Functionality:Fills the F1SetupRequest
1628 * @return ROK - success
1631 ******************************************************************/
1632 uint8_t BuildAndSendF1SetupReq()
1634 uint8_t ret, ieIdx, elementCnt;
1635 F1AP_PDU_t *f1apMsg = NULLP;
1636 F1SetupRequest_t *f1SetupReq=NULLP;
1637 GNB_DU_Served_Cells_List_t *duServedCell=NULLP;
1638 RRC_Version_t *rrcVer=NULLP;
1639 asn_enc_rval_t encRetVal; /* Encoder return value */
1642 DU_LOG("\nINFO --> F1AP : Building F1 Setup Request\n");
1645 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1646 if(f1apMsg == NULLP)
1650 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
1651 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1652 if(f1apMsg->choice.initiatingMessage == NULLP)
1656 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_F1Setup;
1657 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
1658 f1apMsg->choice.initiatingMessage->value.present = \
1659 InitiatingMessage__value_PR_F1SetupRequest;
1661 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1663 elementCnt = (duCfgParam.duName != NULL) ? 5 : 4;
1665 f1SetupReq->protocolIEs.list.count = elementCnt;
1666 f1SetupReq->protocolIEs.list.size = elementCnt * sizeof(F1SetupRequestIEs_t );
1668 /* Initialize the F1Setup members */
1669 DU_ALLOC(f1SetupReq->protocolIEs.list.array,f1SetupReq->protocolIEs.list.size);
1670 if(f1SetupReq->protocolIEs.list.array == NULLP)
1674 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
1676 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx],\
1677 sizeof(F1SetupRequestIEs_t));
1678 if(f1SetupReq->protocolIEs.list.array[ieIdx] == NULLP)
1686 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_TransactionID;
1687 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1688 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present =\
1689 F1SetupRequestIEs__value_PR_TransactionID;
1690 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = \
1695 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
1696 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1697 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1698 F1SetupRequestIEs__value_PR_GNB_DU_ID;
1699 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size =\
1702 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1703 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1704 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == \
1710 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] =\
1714 if(duCfgParam.duName != NULL)
1717 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_Name;
1718 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore;
1719 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = F1SetupRequestIEs__value_PR_GNB_DU_Name;
1720 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.size =\
1721 strlen((char *)duCfgParam.duName);
1722 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.\
1723 GNB_DU_Name.buf, strlen((char *)duCfgParam.duName));
1724 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.\
1729 strcpy((char*)f1SetupReq->protocolIEs.list.array[ieIdx]->value.\
1730 choice.GNB_DU_Name.buf,
1731 (char*)&duCfgParam.duName);
1735 /*Served Cell list */
1737 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1738 ProtocolIE_ID_id_gNB_DU_Served_Cells_List;
1739 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1740 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1741 F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List;
1742 duServedCell = &f1SetupReq->protocolIEs.list.\
1743 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List;
1744 if(BuildServedCellList(duServedCell))
1750 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1751 ProtocolIE_ID_id_GNB_DU_RRC_Version ;
1752 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1753 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1754 F1SetupRequestIEs__value_PR_RRC_Version;
1755 rrcVer = &f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
1756 if(BuildRrcVer(rrcVer))
1760 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1762 /* Encode the F1SetupRequest type as APER */
1763 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1765 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1768 /* Encode results */
1769 if(encRetVal.encoded == ENCODE_FAIL)
1771 DU_LOG("\nERROR --> F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
1772 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1777 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1SetupRequest\n");
1778 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
1780 printf("%x",encBuf[ieIdx]);
1785 if(sendF1APMsg() != ROK)
1787 DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed");
1795 FreeF1SetupReq(f1apMsg);
1798 }/* End of BuildAndSendF1SetupReq */
1800 /*******************************************************************
1802 * @brief Deallocating memory allocated for Served_Cells_To_Modify_Item_t
1806 * Function : freeCellsToModifyItem
1808 * Functionality: Deallocating memory of variables allocated in
1809 * BuildAndSendDUConfigUpdate function
1811 * @params[in] Served_Cells_To_Modify_Item_t *modifyItem
1813 * @return ROK - void
1815 * ****************************************************************/
1817 void freeCellsToModifyItem(Served_Cells_To_Modify_Item_t *modifyItem)
1819 uint8_t arrIdx=0, servedPlmnIdx=0, sliceLstIdx=0;
1820 ServedPLMNs_Item_t *servedPlmnItem = NULLP;
1821 SliceSupportItem_t *sliceSupportItem = NULLP;
1823 DU_FREE(modifyItem->oldNRCGI.pLMN_Identity.buf, modifyItem->oldNRCGI.pLMN_Identity.size);
1824 DU_FREE(modifyItem->oldNRCGI.nRCellIdentity.buf, modifyItem->oldNRCGI.nRCellIdentity.size);
1826 DU_FREE(modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1827 modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.size);
1828 DU_FREE(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1829 modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.size);
1831 if(modifyItem->served_Cell_Information.servedPLMNs.list.array != NULLP)
1833 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx] != NULLP)
1835 servedPlmnItem = modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx];
1837 DU_FREE(servedPlmnItem->pLMN_Identity.buf,servedPlmnItem->pLMN_Identity.size);
1839 if(servedPlmnItem->iE_Extensions != NULLP)
1841 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1843 if(servedPlmnItem->iE_Extensions->list.array[arrIdx] != NULLP)
1845 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1846 list.array != NULLP)
1848 for(sliceLstIdx =0; sliceLstIdx<servedPlmnItem->iE_Extensions->list.array[arrIdx]->\
1849 extensionValue.choice.SliceSupportList.list.count; sliceLstIdx++)
1851 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1852 list.array[sliceLstIdx] != NULLP)
1855 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1856 SliceSupportList.list.array[sliceLstIdx];
1858 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sliceSupportItem->sNSSAI.sST.size);
1859 if(sliceSupportItem->sNSSAI.sD != NULLP)
1861 DU_FREE(sliceSupportItem->sNSSAI.sD->buf, sliceSupportItem->sNSSAI.sD->size);
1862 DU_FREE(sliceSupportItem->sNSSAI.sD,sizeof(OCTET_STRING_t));
1864 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1865 SliceSupportList.list.array[sliceLstIdx], sizeof(SliceSupportItem_t));
1868 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.\
1869 choice.SliceSupportList.list.array,\
1870 servedPlmnItem->iE_Extensions->list.array[arrIdx]->\
1871 extensionValue.choice.SliceSupportList.list.size);
1874 for(servedPlmnIdx=0; servedPlmnIdx< servedPlmnItem->iE_Extensions->list.count ; servedPlmnIdx++)
1876 DU_FREE(servedPlmnItem->iE_Extensions->list.array[servedPlmnIdx], sizeof(ServedPLMNs_ItemExtIEs_t ));
1878 DU_FREE(servedPlmnItem->iE_Extensions->list.array, servedPlmnItem->iE_Extensions->list.size);
1880 DU_FREE(servedPlmnItem->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1883 for(servedPlmnIdx=0; servedPlmnIdx<modifyItem->served_Cell_Information.servedPLMNs.list.count; servedPlmnIdx++)
1885 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[servedPlmnIdx], sizeof(ServedPLMNs_Item_t));
1887 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array,\
1888 modifyItem->served_Cell_Information.servedPLMNs.list.size);
1891 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
1893 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1895 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
1896 array[arrIdx], sizeof(FreqBandNrItem_t));
1897 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array, \
1898 modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1901 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1903 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.\
1904 array[arrIdx], sizeof(FreqBandNrItem_t));
1905 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
1906 modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
1908 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD,sizeof(FDD_Info_t));
1911 DU_FREE(modifyItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1912 modifyItem->served_Cell_Information.measurementTimingConfiguration.size);
1915 /*******************************************************************
1917 * @brief Deallocating memory of BuildAndSendDUConfigUpdate
1921 * Function : FreeDUConfigUpdate
1923 * Functionality: Deallocating memory of variables allocated in
1924 * BuildAndSendDUConfigUpdate function
1926 * @params[in] F1AP_PDU_t *f1apDuCfg
1928 * @return ROK - void
1930 * ****************************************************************/
1931 void FreeDUConfigUpdate(F1AP_PDU_t *f1apDuCfg)
1933 uint8_t ieIdx=0, cellModifyIdx=0, cellDeleteIdx=0;
1934 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
1935 Served_Cells_To_Modify_List_t *cellsToModify=NULLP;
1936 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
1937 Served_Cells_To_Delete_Item_t *deleteItem = NULLP;
1938 Served_Cells_To_Delete_ItemIEs_t *deleteItemIe = NULLP;
1940 if(f1apDuCfg != NULLP)
1942 if(f1apDuCfg->choice.initiatingMessage != NULLP)
1944 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->\
1945 value.choice.GNBDUConfigurationUpdate;
1946 if(duCfgUpdate->protocolIEs.list.array != NULLP)
1948 for(ieIdx=0; ieIdx<duCfgUpdate->protocolIEs.list.count; ieIdx++)
1950 if(duCfgUpdate->protocolIEs.list.array[ieIdx] != NULLP)
1952 switch(duCfgUpdate->protocolIEs.list.array[ieIdx]->id)
1954 case ProtocolIE_ID_id_Served_Cells_To_Modify_List:
1956 cellsToModify = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1957 value.choice.Served_Cells_To_Modify_List;
1958 if(cellsToModify->list.array != NULLP)
1960 for(cellModifyIdx=0; cellModifyIdx<cellsToModify->list.count ;cellModifyIdx++)
1962 if(cellsToModify->list.array[cellModifyIdx] != NULLP)
1964 freeCellsToModifyItem(&cellsToModify->list.array[cellModifyIdx]->value.choice.\
1965 Served_Cells_To_Modify_Item);
1966 DU_FREE(cellsToModify->list.array[cellModifyIdx],\
1967 sizeof(Served_Cells_To_Modify_ItemIEs_t));
1970 DU_FREE(cellsToModify->list.array,cellsToModify->list.size);
1974 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
1976 cellsToDelete = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1977 value.choice.Served_Cells_To_Delete_List;
1978 if(cellsToDelete->list.array != NULLP)
1980 for(cellDeleteIdx=0; cellDeleteIdx<cellsToDelete->list.count ;cellDeleteIdx++)
1982 if(cellsToDelete->list.array[cellDeleteIdx] != NULLP)
1984 deleteItemIe = ((Served_Cells_To_Delete_ItemIEs_t*)\
1985 cellsToDelete->list.array[cellDeleteIdx]);
1986 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
1987 DU_FREE(deleteItem->oldNRCGI.pLMN_Identity.buf,\
1988 deleteItem->oldNRCGI.pLMN_Identity.size);
1989 DU_FREE(deleteItem->oldNRCGI.nRCellIdentity.buf,\
1990 deleteItem->oldNRCGI.nRCellIdentity.size);
1991 DU_FREE(cellsToDelete->list.array[cellDeleteIdx],\
1992 sizeof(Served_Cells_To_Delete_ItemIEs_t));
1995 DU_FREE(cellsToDelete->list.array,cellsToDelete->list.size);
2000 case ProtocolIE_ID_id_gNB_DU_ID:
2002 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2003 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2007 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx],\
2008 sizeof(GNBDUConfigurationUpdateIEs_t));
2011 DU_FREE(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2013 DU_FREE(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2015 DU_FREE(f1apDuCfg, (Size)sizeof(F1AP_PDU_t));
2019 /*******************************************************************
2021 * @brief Fills Served Plmns required in ServCellInfo IE
2025 * Function : fillServedPlmns
2027 * Functionality: Fills Served Plmns required in ServCellInfo IE
2029 * @params[in] Pointer to ServedPLMNs_List_t *
2031 * @return ROK - success
2034 *****************************************************************/
2036 uint8_t fillServedPlmns(ServedPLMNs_List_t *servedPlmn)
2038 uint8_t ieIdx=0, arrayIdx=0, ieListCnt=0, elementCnt=0, sliceLstIdx=0;
2040 servedPlmn->list.array[arrayIdx]->pLMN_Identity.size = 3*sizeof(uint8_t);
2041 DU_ALLOC(servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf, servedPlmn->list.\
2042 array[arrayIdx]->pLMN_Identity.size);
2043 if(servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf == NULLP)
2045 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2048 buildPlmnId(duCfgParam.srvdCellLst[arrayIdx].duCellInfo.cellInfo.srvdPlmn[arrayIdx].plmn,\
2049 servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf);
2050 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
2051 if(servedPlmn->list.array[arrayIdx]->iE_Extensions == NULLP)
2053 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2058 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.count = ieListCnt;
2059 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.size = ieListCnt *sizeof(ServedPLMNs_ItemExtIEs_t *);
2060 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array,servedPlmn->list.array[arrayIdx]->\
2061 iE_Extensions->list.size);
2062 if(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array == NULLP)
2064 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2067 for(ieIdx=arrayIdx;ieIdx<ieListCnt;ieIdx++)
2069 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx],\
2070 sizeof(ServedPLMNs_ItemExtIEs_t));
2071 if(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx] == NULLP)
2073 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2079 elementCnt = NUM_OF_SUPPORTED_SLICE;
2080 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->id =ProtocolIE_ID_id_TAISliceSupportList;
2081 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->criticality = Criticality_ignore;
2082 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.present = \
2083 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
2084 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2085 list.count = elementCnt;
2086 servedPlmn->list.array[arrayIdx]->\
2087 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2088 list.size = elementCnt * sizeof(SliceSupportItem_t *);
2089 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2090 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2091 list.array,servedPlmn->list.array[arrayIdx]->\
2092 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.list.size);
2093 if(servedPlmn->list.array[arrayIdx]->\
2094 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2095 list.array == NULLP)
2097 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2101 for(sliceLstIdx =0; sliceLstIdx< elementCnt; sliceLstIdx++)
2103 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2104 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2105 list.array[sliceLstIdx],sizeof( SliceSupportItem_t));
2106 if(servedPlmn->list.array[arrayIdx]->\
2107 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2108 list.array[sliceLstIdx] == NULLP)
2110 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2114 servedPlmn->list.array[arrayIdx]->\
2115 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2116 list.array[sliceLstIdx]->sNSSAI.sST.size = sizeof(uint8_t);
2117 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2118 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2119 list.array[sliceLstIdx]->sNSSAI.sST.buf,servedPlmn->list.array[arrayIdx]->\
2120 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.list.array[sliceLstIdx]->\
2123 if(servedPlmn->list.array[arrayIdx]->\
2124 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2125 list.array[sliceLstIdx]->sNSSAI.sST.buf == NULLP)
2127 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2130 servedPlmn->list.array[arrayIdx]->\
2131 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2132 list.array[sliceLstIdx]->sNSSAI.sST.buf[arrayIdx] = duCfgParam.srvdCellLst[arrayIdx].duCellInfo.\
2133 cellInfo.srvdPlmn[arrayIdx].taiSliceSuppLst.snssai[sliceLstIdx]->sst;
2135 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2136 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2137 list.array[sliceLstIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
2138 if(servedPlmn->list.array[arrayIdx]->\
2139 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2140 list.array[sliceLstIdx]->sNSSAI.sD == NULLP)
2142 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2145 servedPlmn->list.array[arrayIdx]->\
2146 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2147 list.array[sliceLstIdx]->sNSSAI.sD->size = 3 * sizeof(uint8_t);
2148 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2149 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2150 list.array[sliceLstIdx]->sNSSAI.sD->buf,servedPlmn->list.array[arrayIdx]->\
2151 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2152 list.array[sliceLstIdx]->sNSSAI.sD->size);
2153 if(servedPlmn->list.array[arrayIdx]->\
2154 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2155 list.array[sliceLstIdx]->sNSSAI.sD->buf == NULLP)
2157 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2160 memcpy(servedPlmn->list.array[arrayIdx]->\
2161 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2162 list.array[sliceLstIdx]->sNSSAI.sD->buf, duCfgParam.srvdCellLst[arrayIdx].duCellInfo.\
2163 cellInfo.srvdPlmn[arrayIdx].taiSliceSuppLst.snssai[sliceLstIdx]->sd,\
2164 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2165 list.array[sliceLstIdx]->sNSSAI.sD->size);
2170 /*******************************************************************
2172 * @brief Fills Nr Fdd Info required in ServCellInfo IE
2176 * Function : fillNrFddInfo
2178 * Functionality: Fills Nr Fdd Info required in ServCellInfo IE
2180 * @params[in] Pointer to NR_Mode_Info_t *
2182 * @return ROK - success
2185 *****************************************************************/
2187 uint8_t fillNrFddInfo(NR_Mode_Info_t *nrFdd)
2189 nrFdd->choice.fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
2190 f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn;
2191 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
2192 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
2193 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
2194 array, nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
2195 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2199 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
2200 sizeof(FreqBandNrItem_t));
2201 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2205 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2206 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
2207 freqBand[0].nrFreqBand;
2208 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2209 nrFdd->choice.fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
2210 dlNrFreqInfo.nrArfcn;
2211 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
2212 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
2213 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,nrFdd->\
2214 choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
2215 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2219 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0],\
2220 sizeof(FreqBandNrItem_t));
2221 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2225 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2226 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
2227 freqBand[0].nrFreqBand;
2228 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2230 /*Transmission Bandwidth*/
2231 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2232 f1Mode.mode.fdd.ulTxBw.nrScs;
2233 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2234 f1Mode.mode.fdd.ulTxBw.nrb;
2235 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2236 f1Mode.mode.fdd.dlTxBw.nrScs;
2237 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2238 f1Mode.mode.fdd.dlTxBw.nrb;
2243 /*******************************************************************
2245 * @brief Fills ServCellInfo IE
2249 * Function : fillServedCellInfo
2251 * Functionality: Fills ServCellInfo
2253 * @params[in] Pointer to Served_Cell_Information_t *
2255 * @return ROK - success
2258 *****************************************************************/
2260 uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
2262 uint8_t tmp, ieIdx, ieListCnt;
2265 srvCellInfo->nRCGI.pLMN_Identity.size =3*sizeof(uint8_t);
2266 DU_ALLOC(srvCellInfo->nRCGI.pLMN_Identity.buf,\
2267 srvCellInfo->nRCGI.pLMN_Identity.size);
2268 if(srvCellInfo->nRCGI.pLMN_Identity.buf == NULLP)
2272 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2273 srvCellInfo->nRCGI.pLMN_Identity.buf);
2274 srvCellInfo->nRCGI.nRCellIdentity.size =5*sizeof(uint8_t);
2275 DU_ALLOC(srvCellInfo->nRCGI.nRCellIdentity.buf,\
2276 srvCellInfo->nRCGI.nRCellIdentity.size);
2277 if(srvCellInfo->nRCGI.nRCellIdentity.buf == NULLP)
2281 for (tmp = 0 ; tmp < srvCellInfo->\
2282 nRCGI.nRCellIdentity.size-1 ; tmp++)
2284 srvCellInfo->nRCGI.nRCellIdentity.buf[tmp] = 0;
2286 srvCellInfo->nRCGI.nRCellIdentity.buf[4] = 16;
2287 srvCellInfo->nRCGI.nRCellIdentity.bits_unused =4;
2290 srvCellInfo->nRPCI = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
2294 srvCellInfo->servedPLMNs.list.count = ieListCnt;
2295 srvCellInfo->servedPLMNs.list.size = ieListCnt*sizeof(ServedPLMNs_Item_t *);
2296 DU_ALLOC(srvCellInfo->servedPLMNs.list.array,\
2297 srvCellInfo->servedPLMNs.list.size);
2298 if(srvCellInfo->servedPLMNs.list.array == NULLP)
2302 for(ieIdx=0; ieIdx < ieListCnt; ieIdx++)
2304 DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx],\
2305 sizeof(ServedPLMNs_Item_t));
2306 if(srvCellInfo->servedPLMNs.list.array[ieIdx]== NULLP)
2311 if(fillServedPlmns(&srvCellInfo->servedPLMNs))
2316 /*nR Mode Info with FDD*/
2317 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_fDD;
2318 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD,\
2319 sizeof(FDD_Info_t));
2320 if(srvCellInfo->nR_Mode_Info.choice.fDD == NULLP)
2324 if(fillNrFddInfo(&srvCellInfo->nR_Mode_Info))
2327 /*Measurement timing Config*/
2328 srvCellInfo->measurementTimingConfiguration.size = sizeof(uint8_t);
2329 DU_ALLOC(srvCellInfo->measurementTimingConfiguration.\
2330 buf,srvCellInfo->measurementTimingConfiguration.size);
2331 if(srvCellInfo->measurementTimingConfiguration.buf == NULLP)
2335 srvCellInfo->measurementTimingConfiguration.\
2336 buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
2341 /*******************************************************************
2343 * @brief Fills ServCellToModItem IE
2347 * Function : fillServCellToModItem
2349 * Functionality: Fills ServCellToModItem IE
2351 * @params[in] Pointer to Served_Cells_To_Modify_Item_t *
2353 * @return ROK - success
2356 *****************************************************************/
2358 uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
2363 modifyItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2364 DU_ALLOC(modifyItem->oldNRCGI.pLMN_Identity.buf,modifyItem->oldNRCGI.pLMN_Identity.size);
2365 if(modifyItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2369 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2370 modifyItem->oldNRCGI.pLMN_Identity.buf);
2373 modifyItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2374 DU_ALLOC(modifyItem->oldNRCGI.nRCellIdentity.buf,\
2375 modifyItem->oldNRCGI.nRCellIdentity.size);
2376 if(modifyItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2380 for(ieIdx = 0; ieIdx < modifyItem->oldNRCGI.nRCellIdentity.size-1; ieIdx++)
2382 modifyItem->oldNRCGI.nRCellIdentity.buf[ieIdx] = 0;
2384 modifyItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2385 modifyItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2387 if(fillServedCellInfo(&modifyItem->served_Cell_Information))
2393 /*******************************************************************
2395 * @brief Builds ServCellToModList
2399 * Function : buildServCellToModList
2401 * Functionality: Builds the serv cell to Mod List
2403 * @params[in] Pointer to Served_Cells_To_Modify_List_t *
2405 * @return ROK - success
2408 *****************************************************************/
2410 uint8_t buildServCellToModList(Served_Cells_To_Modify_List_t *cellsToModify)
2412 uint8_t ieListCnt, ieIdx;
2413 Served_Cells_To_Modify_Item_t *modifyItem = NULLP;
2416 cellsToModify->list.count = ieListCnt;
2417 cellsToModify->list.size = ieListCnt*sizeof(Served_Cells_To_Modify_ItemIEs_t *);
2418 DU_ALLOC(cellsToModify->list.array,cellsToModify->list.size);
2419 if(cellsToModify->list.array == NULLP)
2423 for(ieIdx=0; ieIdx< ieListCnt; ieIdx++)
2425 DU_ALLOC(cellsToModify->list.array[ieIdx],sizeof(Served_Cells_To_Modify_ItemIEs_t));
2426 if(cellsToModify->list.array[ieIdx] == NULLP)
2431 cellsToModify->list.array[0]->id = ProtocolIE_ID_id_Served_Cells_To_Modify_Item;
2432 cellsToModify->list.array[0]->criticality = Criticality_reject;
2433 cellsToModify->list.array[0]->value.present =\
2434 Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item;
2435 modifyItem=&cellsToModify->list.array[0]->value.choice.Served_Cells_To_Modify_Item;
2437 if(fillServCellToModItem(modifyItem))
2442 /*******************************************************************
2444 * @brief filling the DeleteItemList
2448 * Function : fillCellToDeleteItem
2450 * Functionality: Filling the DeleteItemIe
2452 * @params[in] Pointer to Served_Cells_To_Delete_ItemIEs_t
2454 * @return ROK - success
2457 *****************************************************************/
2458 uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe)
2461 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
2463 deleteItemIe->id = ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
2464 deleteItemIe->criticality = Criticality_reject;
2465 deleteItemIe->value.present =\
2466 Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item;
2467 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
2470 deleteItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2471 DU_ALLOC(deleteItem->oldNRCGI.pLMN_Identity.buf,deleteItem->oldNRCGI.pLMN_Identity.size);
2472 if(deleteItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2474 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2477 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2478 deleteItem->oldNRCGI.pLMN_Identity.buf);
2481 deleteItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2482 DU_ALLOC(deleteItem->oldNRCGI.nRCellIdentity.buf,\
2483 deleteItem->oldNRCGI.nRCellIdentity.size);
2484 if(deleteItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2486 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2489 for(arrIdx = 0; arrIdx < deleteItem->oldNRCGI.nRCellIdentity.size-1; arrIdx++)
2491 deleteItem->oldNRCGI.nRCellIdentity.buf[arrIdx] = 0;
2493 deleteItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2494 deleteItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2497 /*******************************************************************
2499 * @brief Builds ServCellToDeleteList
2503 * Function : buildServCellToDeleteList
2505 * Functionality: Builds the serv cell to delete List
2507 * @params[in] Pointer to Served_Cells_To_Delete_List_t *
2509 * @return ROK - success
2512 *****************************************************************/
2514 uint8_t buildServCellToDeleteList(Served_Cells_To_Delete_List_t *cellsToDelete)
2516 uint8_t ieListCnt, arrIdx;
2519 cellsToDelete->list.count = ieListCnt;
2520 cellsToDelete->list.size = ieListCnt*sizeof(Served_Cells_To_Delete_ItemIEs_t *);
2522 DU_ALLOC(cellsToDelete->list.array,cellsToDelete->list.size);
2523 if(cellsToDelete->list.array == NULLP)
2525 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2529 for(arrIdx=0; arrIdx< ieListCnt; arrIdx++)
2531 DU_ALLOC(cellsToDelete->list.array[arrIdx],sizeof(Served_Cells_To_Delete_ItemIEs_t));
2532 if(cellsToDelete->list.array[arrIdx] == NULLP)
2534 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2540 if(fillCellToDeleteItem((Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx]) !=ROK)
2542 DU_LOG("\nERROR --> F1AP: buildServCellToDeleteList(): failed to fill Served_Cells_To_Delete_ItemIEs");
2548 /*******************************************************************
2550 * @brief Builds and sends the DUConfigUpdate
2554 * Function : BuildAndSendDUConfigUpdate
2556 * Functionality: Constructs the DU Update message and sends
2557 * it to the CU through SCTP.
2559 * @params[in] void **buf,Buffer to which encoded pattern is written into
2560 * @params[in] int *size,size of buffer
2562 * @return ROK - success
2565 * ****************************************************************/
2566 uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
2568 uint8_t ret =0, ieIdx=0, elementCnt=0;
2569 bool memAlloctionFailure = false;
2570 F1AP_PDU_t *f1apDuCfg = NULLP;
2571 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
2572 asn_enc_rval_t encRetVal; /* Encoder return value */
2574 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2579 DU_LOG("\nINFO --> F1AP : Building DU config update\n");
2580 /* Allocate the memory for F1DuCfg */
2581 DU_ALLOC(f1apDuCfg, sizeof(F1AP_PDU_t));
2582 if(f1apDuCfg == NULLP)
2584 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2588 f1apDuCfg->present = F1AP_PDU_PR_initiatingMessage;
2589 DU_ALLOC(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2590 if(f1apDuCfg->choice.initiatingMessage == NULLP)
2592 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2596 f1apDuCfg->choice.initiatingMessage->procedureCode = \
2597 ProcedureCode_id_gNBDUConfigurationUpdate;
2598 f1apDuCfg->choice.initiatingMessage->criticality = Criticality_reject;
2599 f1apDuCfg->choice.initiatingMessage->value.present = \
2600 InitiatingMessage__value_PR_GNBDUConfigurationUpdate;
2601 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->value.\
2602 choice.GNBDUConfigurationUpdate;
2604 duCfgUpdate->protocolIEs.list.count = elementCnt;
2605 duCfgUpdate->protocolIEs.list.size = \
2606 elementCnt * sizeof(GNBDUConfigurationUpdateIEs_t*);
2608 /* Initialize the F1Setup members */
2609 DU_ALLOC(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2610 if(duCfgUpdate->protocolIEs.list.array == NULLP)
2612 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2615 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
2617 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx],sizeof(GNBDUConfigurationUpdateIEs_t));
2618 if(duCfgUpdate->protocolIEs.list.array[ieIdx] == NULLP)
2620 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2621 memAlloctionFailure = true;
2626 if(memAlloctionFailure == true)
2632 duCfgUpdate->protocolIEs.list.array[ieIdx]->id=ProtocolIE_ID_id_TransactionID;
2633 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
2634 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2635 GNBDUConfigurationUpdateIEs__value_PR_TransactionID;
2636 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = TRANS_ID;
2639 if(servCellAction == SERV_CELL_TO_MODIFY)
2641 /*Served Cell to Modify */
2642 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2643 ProtocolIE_ID_id_Served_Cells_To_Modify_List;
2644 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2645 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2646 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List;
2647 if(buildServCellToModList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2648 Served_Cells_To_Modify_List))
2650 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToModList");
2656 /*Served Cell to Delete */
2657 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2658 ProtocolIE_ID_id_Served_Cells_To_Delete_List;
2659 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2660 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2661 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List;
2662 if(buildServCellToDeleteList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2663 Served_Cells_To_Delete_List)!=ROK)
2665 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToDeleteList");
2670 // NOTE :GNB DU SYS INFO:MIB AND SIB1 INFORMATION TO BE BUILT AND FILLED HERE
2673 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
2674 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
2675 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2676 GNBDUConfigurationUpdateIEs__value_PR_GNB_DU_ID;
2677 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size = sizeof(uint8_t);
2678 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2679 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2680 if(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == NULLP)
2682 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): Memory allocation failed for GNB_DU_ID");
2685 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] = duCfgParam.duId;
2687 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apDuCfg);
2689 /* Encode the DU Config Update type as APER */
2690 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2692 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apDuCfg, PrepFinalEncBuf, encBuf);
2694 /* Checking encode results */
2695 if(encRetVal.encoded == ENCODE_FAIL)
2697 DU_LOG("ERROR --> F1AP : Could not encode DUConfigUpdate structure (at %s)\n",\
2698 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2703 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DUConfigUpdate\n");
2704 for(ieIdx =0; ieIdx < encBufSize; ieIdx++)
2706 printf("%x",encBuf[ieIdx]);
2710 if(sendF1APMsg() != ROK)
2712 DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed");
2720 addToReservedF1apPduList(TRANS_ID,f1apDuCfg);
2725 /*******************************************************************
2727 * @brief free the ULRRCMessageTransfer
2731 * Function : FreeULRRCMessageTransfer
2733 * Functionality: Deallocating the memory of variable allocated in
2734 * FreeULRRCMessageTransfer
2738 * @return ROK - void
2740 ******************************************************************/
2741 void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
2744 ULRRCMessageTransfer_t *ulRRCMsg;
2746 if(f1apMsg != NULLP)
2748 if(f1apMsg->choice.initiatingMessage != NULLP)
2750 ulRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2751 if(ulRRCMsg->protocolIEs.list.array != NULLP)
2753 for(idx1=0;idx1<ulRRCMsg->protocolIEs.list.count;idx1++)
2755 if(ulRRCMsg->protocolIEs.list.array[idx1] != NULLP)
2757 if(ulRRCMsg->protocolIEs.list.array[idx1]->value.present ==
2758 ULRRCMessageTransferIEs__value_PR_RRCContainer)
2760 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2761 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2763 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1],sizeof(ULRRCMessageTransferIEs_t));
2766 DU_FREE(ulRRCMsg->protocolIEs.list.array,ulRRCMsg->protocolIEs.list.size );
2768 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2770 DU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
2773 /*******************************************************************
2775 * @brief Builds and sends the ULRRCMessageTransfer
2779 * Function : BuildAndSendULRRCMessageTransfer
2781 * Functionality: Constructs the UL RRC Message Transfer and sends
2782 * it to the CU through SCTP.
2786 * @return ROK - success
2789 * ****************************************************************/
2790 uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \
2791 uint16_t msgLen, uint8_t *rrcMsg)
2793 uint8_t elementCnt =0;
2796 F1AP_PDU_t *f1apMsg = NULLP;
2797 ULRRCMessageTransfer_t *ulRRCMsg = NULLP;
2798 asn_enc_rval_t encRetVal; /* Encoder return value */
2799 uint8_t ret =RFAILED;
2801 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2805 DU_LOG("\n INFO --> F1AP : Building UL RRC Message Transfer Message\n");
2807 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
2808 if(f1apMsg == NULLP)
2810 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2813 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
2814 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2815 if(f1apMsg->choice.initiatingMessage == NULLP)
2817 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2820 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_ULRRCMessageTransfer;
2821 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
2822 f1apMsg->choice.initiatingMessage->value.present = \
2823 InitiatingMessage__value_PR_ULRRCMessageTransfer;
2825 &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2827 ulRRCMsg->protocolIEs.list.count = elementCnt;
2828 ulRRCMsg->protocolIEs.list.size = \
2829 elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
2831 /* Initialize the F1Setup members */
2832 DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
2833 if(ulRRCMsg->protocolIEs.list.array == NULLP)
2835 DU_LOG(" ERROR --> F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
2838 for(idx=0; idx<elementCnt; idx++)
2840 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
2841 if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
2849 /*GNB CU UE F1AP ID*/
2850 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
2851 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2852 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2853 ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
2854 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb.gnbCuUeF1apId;
2856 /*GNB DU UE F1AP ID*/
2858 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
2859 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2860 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2861 ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
2862 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb.gnbDuUeF1apId;
2866 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
2867 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2868 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2869 ULRRCMessageTransferIEs__value_PR_SRBID;
2870 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = lcId;
2874 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCContainer;
2875 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2876 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2877 ULRRCMessageTransferIEs__value_PR_RRCContainer;
2878 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = msgLen;
2879 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2880 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
2881 if(!ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
2883 DU_LOG(" ERROR --> F1AP : Memory allocation for BuildAndSendULRRCMessageTransfer failed");
2886 memset(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, 0, msgLen);
2887 memcpy(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, \
2888 rrcMsg, ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2890 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
2892 /* Encode the F1SetupRequest type as APER */
2893 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2895 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
2897 /* Encode results */
2898 if(encRetVal.encoded == ENCODE_FAIL)
2900 DU_LOG( "\nERROR --> F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
2901 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2906 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
2907 for(int i=0; i< encBufSize; i++)
2909 printf("%x",encBuf[i]);
2914 if(sendF1APMsg() != ROK)
2916 DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed");
2922 FreeULRRCMessageTransfer(f1apMsg);
2925 }/* End of BuildAndSendULRRCMessageTransfer*/
2927 /*******************************************************************
2929 * @brief Builds tag config
2933 * Function : BuildTagConfig
2935 * Functionality: Builds tag config in MacCellGroupConfig
2937 * @params[in] TAG_Config *tag_Config
2939 * @return ROK - success
2942 * ****************************************************************/
2943 uint8_t BuildTagConfig(struct TAG_Config *tagConfig)
2945 struct TAG_Config__tag_ToAddModList *tagList;
2946 uint8_t idx, elementCnt;
2948 tagConfig->tag_ToReleaseList = NULLP;
2949 tagConfig->tag_ToAddModList = NULLP;
2950 DU_ALLOC(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
2951 if(!tagConfig->tag_ToAddModList)
2953 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2957 elementCnt = 1; //ODU_VALUE_ONE;
2958 tagList = tagConfig->tag_ToAddModList;
2959 tagList->list.count = elementCnt;
2960 tagList->list.size = elementCnt * sizeof(struct TAG *);
2962 tagList->list.array = NULLP;
2963 DU_ALLOC(tagList->list.array, tagList->list.size);
2964 if(!tagList->list.array)
2966 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2970 for(idx=0; idx<tagList->list.count; idx++)
2972 tagList->list.array[idx] = NULLP;
2973 DU_ALLOC(tagList->list.array[idx], sizeof(struct TAG));
2974 if(!tagList->list.array[idx])
2976 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2982 tagList->list.array[idx]->tag_Id = TAG_ID;
2983 tagList->list.array[idx]->timeAlignmentTimer = TIME_ALIGNMENT_TMR;
2988 /*******************************************************************
2990 * @brief Builds PHR Config
2994 * Function : BuildPhrConfig
2996 * Functionality: Builds phrConfig in MacCellGroupConfig
2998 * @params[in] PHR Config *
3000 * @return ROK - success
3003 * ****************************************************************/
3004 uint8_t BuildPhrConfig(struct MAC_CellGroupConfig__phr_Config *phrConfig)
3007 phrConfig->present = MAC_CellGroupConfig__phr_Config_PR_setup;
3008 phrConfig->choice.setup = NULLP;
3009 DU_ALLOC(phrConfig->choice.setup, sizeof(struct PHR_Config));
3010 if(!phrConfig->choice.setup)
3012 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhrConfig");
3016 phrConfig->choice.setup->phr_PeriodicTimer = PHR_PERIODIC_TMR;
3017 phrConfig->choice.setup->phr_ProhibitTimer = PHR_PROHIBHIT_TMR;
3018 phrConfig->choice.setup->phr_Tx_PowerFactorChange = PHR_PWR_FACTOR_CHANGE;
3019 phrConfig->choice.setup->multiplePHR = false;
3020 phrConfig->choice.setup->dummy = false;
3021 phrConfig->choice.setup->phr_Type2OtherCell = false;
3022 phrConfig->choice.setup->phr_ModeOtherCG = PHR_MODE_OTHER_CG;
3027 /*******************************************************************
3029 * @brief Builds BSR Config
3033 * Function : BuildBsrConfig
3035 * Functionality: Builds BuildBsrConfig in MacCellGroupConfig
3037 * @params[in] BSR_Config *bsrConfig
3039 * @return ROK - success
3042 * ****************************************************************/
3043 uint8_t BuildBsrConfig(struct BSR_Config *bsrConfig)
3045 bsrConfig->periodicBSR_Timer = PERIODIC_BSR_TMR;
3046 bsrConfig->retxBSR_Timer = RETX_BSR_TMR;
3047 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
3052 /*******************************************************************
3054 * @brief Builds scheduling request config
3058 * Function : BuildSchedulingReqConfig
3060 * Functionality: Builds BuildSchedulingReqConfig in MacCellGroupConfig
3062 * @params[in] SchedulingRequestConfig *schedulingRequestConfig
3064 * @return ROK - success
3067 * ****************************************************************/
3068 uint8_t BuildSchedulingReqConfig(struct SchedulingRequestConfig *schedulingRequestConfig)
3070 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList;
3071 uint8_t idx, elementCnt;
3073 schedulingRequestConfig->schedulingRequestToAddModList = NULLP;
3074 DU_ALLOC(schedulingRequestConfig->schedulingRequestToAddModList,
3075 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList));
3076 if(!schedulingRequestConfig->schedulingRequestToAddModList)
3078 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3082 elementCnt = 1; //ODU_VALUE_ONE;
3083 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
3084 schReqList->list.count = elementCnt;
3085 schReqList->list.size = elementCnt * sizeof(struct SchedulingRequestToAddMod *);
3087 schReqList->list.array = NULLP;
3088 DU_ALLOC(schReqList->list.array, schReqList->list.size);
3089 if(!schReqList->list.array)
3091 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3095 for(idx=0;idx<schReqList->list.count; idx++)
3097 schReqList->list.array[idx] = NULLP;
3098 DU_ALLOC(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
3099 if(!schReqList->list.array[idx])
3101 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3107 schReqList->list.array[idx]->schedulingRequestId = SCH_REQ_ID;
3109 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
3110 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
3111 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
3113 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3116 *(schReqList->list.array[idx]->sr_ProhibitTimer) = SR_PROHIBIT_TMR;
3117 schReqList->list.array[idx]->sr_TransMax = SR_TRANS_MAX;
3118 schedulingRequestConfig->schedulingRequestToReleaseList = NULLP;
3123 /*******************************************************************
3125 * @brief Builds RLC Config
3129 * Function : BuildRlcConfig
3131 * Functionality: Builds RLC Config in BuildRlcBearerToAddModList
3133 * @params[in] RLC_Config *rlcConfig
3135 * @return ROK - success
3138 * ****************************************************************/
3139 uint8_t BuildRlcConfig(struct RLC_Config *rlcConfig)
3142 rlcConfig->present = RLC_Config_PR_am;
3144 rlcConfig->choice.am = NULLP;
3145 DU_ALLOC(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
3146 if(!rlcConfig->choice.am)
3148 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3153 rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength = NULLP;
3154 DU_ALLOC(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3155 if(!rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength)
3157 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3160 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3161 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = T_POLL_RETRANSMIT;
3162 rlcConfig->choice.am->ul_AM_RLC.pollPDU = POLL_PDU;
3163 rlcConfig->choice.am->ul_AM_RLC.pollByte = POLL_BYTE;
3164 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = MAX_RETX_THRESHOLD;
3167 rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength = NULLP;
3168 DU_ALLOC(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3169 if(!rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength)
3171 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3174 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3175 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = T_REASSEMBLY;
3176 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = T_STATUS_PROHIBHIT;
3181 /*******************************************************************
3183 * @brief Builds MAC LC Config
3187 * Function : BuildMacLCConfig
3189 * Functionality: Builds MAC LC Config in BuildRlcBearerToAddModList
3191 * @params[in] struct LogicalChannelConfig macLcConfig
3193 * @return ROK - success
3196 * ****************************************************************/
3197 uint8_t BuildMacLCConfig(struct LogicalChannelConfig *macLcConfig)
3200 macLcConfig->ul_SpecificParameters = NULLP;
3201 DU_ALLOC(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
3202 if(!macLcConfig->ul_SpecificParameters)
3204 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3208 macLcConfig->ul_SpecificParameters->priority = MAC_LC_PRIORITY;
3209 macLcConfig->ul_SpecificParameters->prioritisedBitRate = PRIORTISIED_BIT_RATE;
3210 macLcConfig->ul_SpecificParameters->bucketSizeDuration = BUCKET_SIZE_DURATION;
3211 macLcConfig->ul_SpecificParameters->allowedServingCells = NULLP;
3212 macLcConfig->ul_SpecificParameters->allowedSCS_List = NULLP;
3213 macLcConfig->ul_SpecificParameters->maxPUSCH_Duration = NULLP;
3214 macLcConfig->ul_SpecificParameters->configuredGrantType1Allowed = NULLP;
3216 macLcConfig->ul_SpecificParameters->logicalChannelGroup = NULLP;
3217 DU_ALLOC(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
3218 if(!macLcConfig->ul_SpecificParameters->logicalChannelGroup)
3220 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3223 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = LC_GRP;
3225 macLcConfig->ul_SpecificParameters->schedulingRequestID = NULLP;
3226 DU_ALLOC(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
3227 if(!macLcConfig->ul_SpecificParameters->schedulingRequestID)
3229 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3232 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = SCH_REQ_ID;
3234 macLcConfig->ul_SpecificParameters->logicalChannelSR_Mask = false;
3235 macLcConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false;
3236 macLcConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULLP;
3241 /*******************************************************************
3243 * @brief Builds RLC Bearer to Add/Mod list
3247 * Function :BuildRlcBearerToAddModList
3249 * Functionality: Builds RLC Bearer to Add/Mod list in DuToCuRrcContainer
3251 * @params[in] rlc_BearerToAddModList
3253 * @return ROK - success
3256 * ****************************************************************/
3257 uint8_t BuildRlcBearerToAddModList(struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList)
3259 uint8_t idx, elementCnt;
3262 rlcBearerList->list.count = elementCnt;
3263 rlcBearerList->list.size = elementCnt * sizeof(struct RLC_BearerConfig *);
3265 rlcBearerList->list.array = NULLP;
3266 DU_ALLOC(rlcBearerList->list.array, rlcBearerList->list.size);
3267 if(!rlcBearerList->list.array)
3269 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3273 for(idx=0; idx<rlcBearerList->list.count; idx++)
3275 rlcBearerList->list.array[idx] = NULLP;
3276 DU_ALLOC(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
3277 if(!rlcBearerList->list.array[idx])
3279 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3285 rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
3287 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, \
3288 sizeof(struct RLC_BearerConfig__servedRadioBearer));
3289 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3291 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3295 rlcBearerList->list.array[idx]->servedRadioBearer->present = \
3296 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
3297 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = \
3300 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3301 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3302 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3303 if(!rlcBearerList->list.array[idx]->rlc_Config)
3305 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3309 if(BuildRlcConfig(rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3311 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3315 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3316 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, \
3317 sizeof(struct LogicalChannelConfig));
3318 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3320 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3324 if(BuildMacLCConfig(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3326 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3333 /*******************************************************************
3335 * @brief Build Control resource set to add/modify list
3339 * Function : BuildControlRSetToAddModList
3341 * Functionality: Build Control resource set to add/modify list
3344 * struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3346 * @return ROK - success
3349 * ****************************************************************/
3350 uint8_t BuildControlRSetToAddModList
3352 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3357 uint8_t numBytes, bitsUnused;
3358 struct ControlResourceSet *controlRSet;
3359 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
3360 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
3364 controlRSetList->list.count = elementCnt;
3365 controlRSetList->list.size = \
3366 elementCnt * sizeof(struct ControlResourceSet *);
3368 controlRSetList->list.array = NULLP;
3369 DU_ALLOC(controlRSetList->list.array, controlRSetList->list.size);
3370 if(!controlRSetList->list.array)
3372 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3376 for(idx = 0; idx < elementCnt; idx++)
3378 controlRSetList->list.array[idx] = NULLP;
3379 DU_ALLOC(controlRSetList->list.array[idx], sizeof(struct ControlResourceSet));
3380 if(!controlRSetList->list.array[idx])
3382 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3388 controlRSet = controlRSetList->list.array[idx];
3390 controlRSet->controlResourceSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
3394 * Bit string stored ff0000000000
3398 controlRSet->frequencyDomainResources.size = numBytes * sizeof(uint8_t);
3400 controlRSet->frequencyDomainResources.buf = NULLP;
3401 DU_ALLOC(controlRSet->frequencyDomainResources.buf, \
3402 controlRSet->frequencyDomainResources.size);
3403 if(!controlRSet->frequencyDomainResources.buf)
3405 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3409 memset(controlRSet->frequencyDomainResources.buf, 0, FREQ_DOM_RSRC_SIZE);
3410 coreset0EndPrb = CORESET0_END_PRB;
3411 coreset1StartPrb = coreset0EndPrb + 6;
3412 coreset1NumPrb = CORESET1_NUM_PRB;
3413 /* calculate the PRBs */
3414 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
3415 memcpy(controlRSet->frequencyDomainResources.buf, freqDomainResource, FREQ_DOM_RSRC_SIZE);
3416 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3418 controlRSet->duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
3419 controlRSet->cce_REG_MappingType.present = \
3420 ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
3422 controlRSet->precoderGranularity = PDCCH_CTRL_RSRC_SET_ONE_PRECOD_GRANULARITY;
3423 controlRSet->tci_StatesPDCCH_ToAddList = NULLP;
3424 controlRSet->tci_StatesPDCCH_ToReleaseList = NULLP;
3425 controlRSet->tci_PresentInDCI = NULLP;
3427 uint8_t tciStateIdx;
3429 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList, \
3430 sizeof(struct ControlResourceSet__tci_StatesPDCCH_ToAddList));
3431 if(!controlRset->tci_StatesPDCCH_ToAddList)
3433 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3438 controlRset->tci_StatesPDCCH_ToAddList->list.count = elementCnt;
3439 controlRset->tci_StatesPDCCH_ToAddList->list.size = elementCnt * sizeof(TCI_StateId_t *);
3440 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array, \
3441 controlRset->tci_StatesPDCCH_ToAddList->list.size)
3442 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array)
3444 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3448 for(tciStateIdx = 0; tciStateIdx <elementCntl; tciStateIdx++)
3450 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx], sizeof(TCI_StateId_t));
3451 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx])
3453 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3460 *(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx]);
3462 DU_ALLOC(controlRset->tci_PresentInDCI, sizeof(long));
3463 if(!controlRset->tci_PresentInDCI)
3465 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3469 *(controlRset->tci_PresentInDCI);
3472 controlRSet->pdcch_DMRS_ScramblingID = NULLP;
3473 DU_ALLOC(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
3474 if(!controlRSet->pdcch_DMRS_ScramblingID)
3476 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3479 *(controlRSet->pdcch_DMRS_ScramblingID) = SCRAMBLING_ID;
3482 } /* End BuildControlRSetToAddModList */
3484 /*******************************************************************
3486 * @brief Build search space to add/modify list
3490 * Function : BuildSearchSpcToAddModList
3492 * Functionality: Build search space to add/modify list
3495 * @return ROK - success
3498 * ****************************************************************/
3499 uint8_t BuildSearchSpcToAddModList
3501 struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
3509 struct SearchSpace *searchSpc;
3512 searchSpcList->list.count = elementCnt;
3513 searchSpcList->list.size = elementCnt * sizeof(struct SearchSpace *);
3515 searchSpcList->list.array = NULLP;
3516 DU_ALLOC(searchSpcList->list.array, searchSpcList->list.size);
3517 if(!searchSpcList->list.array)
3519 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3523 for(idx = 0; idx < elementCnt; idx++)
3525 searchSpcList->list.array[idx] = NULLP;
3526 DU_ALLOC(searchSpcList->list.array[idx], sizeof(struct SearchSpace));
3527 if(!searchSpcList->list.array[idx])
3529 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3535 searchSpc = searchSpcList->list.array[idx];
3537 searchSpc->searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
3539 searchSpc->controlResourceSetId = NULLP;
3540 DU_ALLOC(searchSpc->controlResourceSetId, sizeof(ControlResourceSetId_t));
3541 if(!searchSpc->controlResourceSetId)
3543 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3546 *(searchSpc->controlResourceSetId) = PDCCH_CTRL_RSRC_SET_ONE_ID;
3548 searchSpc->monitoringSlotPeriodicityAndOffset = NULLP;
3549 DU_ALLOC(searchSpc->monitoringSlotPeriodicityAndOffset, \
3550 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
3551 if(!searchSpc->monitoringSlotPeriodicityAndOffset)
3553 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3556 searchSpc->monitoringSlotPeriodicityAndOffset->present = \
3557 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
3559 searchSpc->duration = NULLP;
3560 searchSpc->monitoringSymbolsWithinSlot = NULLP;
3561 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot, sizeof(BIT_STRING_t));
3562 if(!searchSpc->monitoringSymbolsWithinSlot)
3564 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3568 /* Values taken from reference logs :
3571 * Bit string stores 8000
3576 searchSpc->monitoringSymbolsWithinSlot->size = numBytes * sizeof(uint8_t);
3577 searchSpc->monitoringSymbolsWithinSlot->buf = NULLP;
3578 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot->buf, \
3579 searchSpc->monitoringSymbolsWithinSlot->size);
3580 if(!searchSpc->monitoringSymbolsWithinSlot->buf)
3582 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3587 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = \
3588 PDCCH_SYMBOL_WITHIN_SLOT /* setting MSB to 128 i.e. 0x80 */;
3589 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = 0;
3590 searchSpc->monitoringSymbolsWithinSlot->bits_unused = bitsUnused;
3592 searchSpc->nrofCandidates = NULLP;
3593 DU_ALLOC(searchSpc->nrofCandidates, sizeof(struct SearchSpace__nrofCandidates));
3594 if(!searchSpc->nrofCandidates)
3596 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3600 searchSpc->nrofCandidates->aggregationLevel1 = \
3601 PDCCH_SRCH_SPC_TWO_AGG_LVL1_CANDIDATE;
3602 searchSpc->nrofCandidates->aggregationLevel2 = \
3603 PDCCH_SRCH_SPC_TWO_AGG_LVL2_CANDIDATE;
3604 searchSpc->nrofCandidates->aggregationLevel4 = \
3605 PDCCH_SRCH_SPC_TWO_AGG_LVL4_CANDIDATE;
3606 searchSpc->nrofCandidates->aggregationLevel8 = \
3607 PDCCH_SRCH_SPC_TWO_AGG_LVL8_CANDIDATE;
3608 searchSpc->nrofCandidates->aggregationLevel16 = \
3609 PDCCH_SRCH_SPC_TWO_AGG_LVL16_CANDIDATE;
3611 searchSpc->searchSpaceType = NULLP;
3612 DU_ALLOC(searchSpc->searchSpaceType, sizeof(struct SearchSpace__searchSpaceType));
3613 if(!searchSpc->searchSpaceType)
3615 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3619 searchSpc->searchSpaceType->present = SearchSpace__searchSpaceType_PR_ue_Specific;
3621 searchSpc->searchSpaceType->choice.ue_Specific = NULLP;
3622 DU_ALLOC(searchSpc->searchSpaceType->choice.ue_Specific, \
3623 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
3624 if(!searchSpc->searchSpaceType->choice.ue_Specific)
3626 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3629 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = \
3630 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
3633 }/* End BuildSearchSpcToAddModList */
3635 /*******************************************************************
3637 * @brief Builds BWP DL dedicated PDCCH config
3641 * Function : BuildBWPDlDedPdcchCfg
3643 * Functionality: Builds BWP DL dedicated PDCCH config
3645 * @params[in] struct PDCCH_Config *pdcchCfg
3647 * @return ROK - success
3650 * ****************************************************************/
3651 uint8_t BuildBWPDlDedPdcchCfg(struct PDCCH_Config *pdcchCfg)
3653 pdcchCfg->controlResourceSetToAddModList = NULLP;
3654 DU_ALLOC(pdcchCfg->controlResourceSetToAddModList, \
3655 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
3656 if(!pdcchCfg->controlResourceSetToAddModList)
3658 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3662 if(BuildControlRSetToAddModList(pdcchCfg->controlResourceSetToAddModList) != ROK)
3667 pdcchCfg->controlResourceSetToReleaseList = NULLP;
3669 pdcchCfg->searchSpacesToAddModList = NULLP;
3670 DU_ALLOC(pdcchCfg->searchSpacesToAddModList, \
3671 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
3672 if(!pdcchCfg->searchSpacesToAddModList)
3674 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3678 if(BuildSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList) != ROK)
3683 pdcchCfg->searchSpacesToReleaseList = NULLP;
3684 pdcchCfg->downlinkPreemption = NULLP;
3685 pdcchCfg->tpc_PUSCH = NULLP;
3686 pdcchCfg->tpc_PUCCH = NULLP;
3687 pdcchCfg->tpc_SRS = NULLP;
3692 /*******************************************************************
3694 * @brief Builds DMRS DL PDSCH Mapping type A
3698 * Function : BuildDMRSDLPdschMapTypeA
3700 * Functionality: Builds DMRS DL PDSCH Mapping type A
3703 * struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3704 * @return ROK - success
3707 * ****************************************************************/
3708 uint8_t BuildDMRSDLPdschMapTypeA
3710 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3713 dmrsDlCfg->present = PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup;
3714 dmrsDlCfg->choice.setup = NULLP;
3715 DU_ALLOC(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
3716 if(!dmrsDlCfg->choice.setup)
3718 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3722 dmrsDlCfg->choice.setup->dmrs_Type = NULLP;
3723 dmrsDlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
3724 DU_ALLOC(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
3725 if(!dmrsDlCfg->choice.setup->dmrs_AdditionalPosition)
3727 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3730 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
3732 dmrsDlCfg->choice.setup->maxLength = NULLP;
3733 dmrsDlCfg->choice.setup->scramblingID0 = NULLP;
3734 dmrsDlCfg->choice.setup->scramblingID1 = NULLP;
3735 dmrsDlCfg->choice.setup->phaseTrackingRS = NULLP;
3740 /*******************************************************************
3742 * @brief Builds TCI states to add/modify list
3746 * Function : BuildTCIStatesToAddModList
3748 * Functionality:Builds TCI states to add/modify list
3751 * struct PDSCH_Config__tci_StatesToAddModList *tciStatesList
3753 * @return ROK - success
3756 * ****************************************************************/
3757 uint8_t BuildTCIStatesToAddModList(struct PDSCH_Config__tci_StatesToAddModList *tciStatesList)
3762 /*******************************************************************
3764 * @brief Builds PDSCH time domain allocation list
3768 * Function : BuildPdschTimeDomAllocList
3770 * Functionality: Builds PDSCH time domain allocation list
3773 * struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3775 * @return ROK - success
3778 * ****************************************************************/
3779 uint8_t BuildPdschTimeDomAllocList
3781 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3786 struct PDSCH_TimeDomainResourceAllocation *timeDomAlloc;
3788 timeDomAllocList->present = \
3789 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup;
3791 timeDomAllocList->choice.setup = NULLP;
3792 DU_ALLOC(timeDomAllocList->choice.setup, \
3793 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
3794 if(!timeDomAllocList->choice.setup)
3796 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3801 timeDomAllocList->choice.setup->list.count = elementCnt;
3802 timeDomAllocList->choice.setup->list.size = \
3803 elementCnt * sizeof(struct PDSCH_TimeDomainResourceAllocation *);
3805 timeDomAllocList->choice.setup->list.array = NULLP;
3806 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
3807 timeDomAllocList->choice.setup->list.size);
3808 if(!timeDomAllocList->choice.setup->list.array)
3810 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3814 for(idx = 0; idx < elementCnt; idx++)
3816 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
3817 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], \
3818 sizeof(struct PDSCH_TimeDomainResourceAllocation));
3819 if(!timeDomAllocList->choice.setup->list.array[idx])
3821 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3827 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
3828 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
3829 if(!timeDomAlloc->k0)
3831 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3834 *(timeDomAlloc->k0) = 0;
3835 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
3836 timeDomAlloc->startSymbolAndLength = \
3837 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
3840 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
3841 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
3842 if(!timeDomAlloc->k0)
3844 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3847 *(timeDomAlloc->k0) = 1;
3848 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
3849 timeDomAlloc->startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
3854 /*******************************************************************
3856 * @brief Builds PDSCH PRB Bundling type
3860 * Function : BuildPdschPrbBundlingType
3862 * Functionality: Builds PDSCH PRB Bundling type
3865 * struct PDSCH_Config__prb_BundlingType *prbBndlType
3867 * @return ROK - success
3870 * ****************************************************************/
3871 uint8_t BuildPdschPrbBundlingType
3873 struct PDSCH_Config__prb_BundlingType *prbBndlType
3876 prbBndlType->present = PDSCH_Config__prb_BundlingType_PR_staticBundling;
3878 prbBndlType->choice.staticBundling = NULLP;
3879 DU_ALLOC(prbBndlType->choice.staticBundling, \
3880 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
3881 if(!prbBndlType->choice.staticBundling)
3883 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschPrbBundlingType");
3886 prbBndlType->choice.staticBundling->bundleSize = NULLP;
3891 /*******************************************************************
3893 * @brief Builds BWP DL dedicated PDSCH config
3897 * Function : BuildBWPDlDedPdschCfg
3899 * Functionality: Builds BWP DL dedicated PDSCH config
3901 * @params[in] struct PDSCH_Config *pdschCfg
3903 * @return ROK - success
3906 * ****************************************************************/
3907 uint8_t BuildBWPDlDedPdschCfg(struct PDSCH_Config *pdschCfg)
3909 pdschCfg->dataScramblingIdentityPDSCH = NULLP;
3911 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA = NULLP;
3912 DU_ALLOC(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
3913 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
3914 if(!pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
3916 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3920 if(BuildDMRSDLPdschMapTypeA(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA) != ROK)
3925 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeB = NULLP;
3926 pdschCfg->tci_StatesToAddModList = NULLP;
3927 pdschCfg->tci_StatesToReleaseList = NULLP;
3928 pdschCfg->vrb_ToPRB_Interleaver = NULLP;
3930 DU_ALLOC(pdschCfg->tci_StatesToAddModList, sizeof(struct PDSCH_Config__tci_StatesToAddModList));
3931 if(!pdschCfg->tci_StatesToAddModList)
3933 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3936 if(BuildTCIStatesToAddModList(pdschCfg->tci_StatesToAddModList) != ROK)
3942 pdschCfg->resourceAllocation = RES_ALLOC_TYPE;
3944 pdschCfg->pdsch_TimeDomainAllocationList = NULLP;
3945 DU_ALLOC(pdschCfg->pdsch_TimeDomainAllocationList, \
3946 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
3947 if(!pdschCfg->pdsch_TimeDomainAllocationList)
3949 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3953 if(BuildPdschTimeDomAllocList(pdschCfg->pdsch_TimeDomainAllocationList) != ROK)
3958 pdschCfg->pdsch_AggregationFactor = NULLP;
3959 pdschCfg->rateMatchPatternToAddModList = NULLP;
3960 pdschCfg->rateMatchPatternToReleaseList = NULLP;
3961 pdschCfg->rateMatchPatternGroup1 = NULLP;
3962 pdschCfg->rateMatchPatternGroup2 = NULLP;
3963 pdschCfg->rbg_Size = PDSCH_RBG_SIZE;
3964 pdschCfg->mcs_Table = NULLP;
3966 pdschCfg->maxNrofCodeWordsScheduledByDCI = NULLP;
3967 DU_ALLOC(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
3968 if(!pdschCfg->maxNrofCodeWordsScheduledByDCI)
3970 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3973 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = PDSCH_MAX_CODEWORD_SCH_BY_DCI;
3975 if(BuildPdschPrbBundlingType(&pdschCfg->prb_BundlingType) != ROK)
3980 pdschCfg->zp_CSI_RS_ResourceToAddModList = NULLP;
3981 pdschCfg->zp_CSI_RS_ResourceToReleaseList = NULLP;
3982 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
3983 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
3984 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
3985 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
3986 pdschCfg->p_ZP_CSI_RS_ResourceSet = NULLP;
3991 /*******************************************************************
3993 * @brief Builds intitial DL BWP
3996 * Function : BuildInitialDlBWP
3998 * Functionality: Builds intitial DL BWP in spCellCfgDed
4000 * @params[in] BWP_DownlinkDedicated_t *dlBwp
4002 * @return ROK - success
4005 * ****************************************************************/
4006 uint8_t BuildInitialDlBWP(BWP_DownlinkDedicated_t *dlBwp)
4008 dlBwp->pdcch_Config = NULLP;
4009 DU_ALLOC(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
4010 if(!dlBwp->pdcch_Config)
4012 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4015 dlBwp->pdcch_Config->present = BWP_DownlinkDedicated__pdcch_Config_PR_setup;
4017 dlBwp->pdcch_Config->choice.setup = NULLP;
4018 DU_ALLOC(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
4019 if(!dlBwp->pdcch_Config->choice.setup)
4021 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4024 if(BuildBWPDlDedPdcchCfg(dlBwp->pdcch_Config->choice.setup) != ROK)
4029 dlBwp->pdsch_Config = NULLP;
4030 DU_ALLOC(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
4031 if(!dlBwp->pdsch_Config)
4033 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4036 dlBwp->pdsch_Config->present = BWP_DownlinkDedicated__pdsch_Config_PR_setup;
4038 dlBwp->pdsch_Config->choice.setup = NULLP;
4039 DU_ALLOC(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
4040 if(!dlBwp->pdsch_Config->choice.setup)
4042 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4046 if(BuildBWPDlDedPdschCfg(dlBwp->pdsch_Config->choice.setup) != ROK)
4051 dlBwp->sps_Config = NULLP;
4052 dlBwp->radioLinkMonitoringConfig = NULLP;
4056 /*******************************************************************
4058 * @brief Builds DMRS UL Pusch Mapping type A
4062 * Function : BuildDMRSULPuschMapTypeA
4064 * Functionality: Builds DMRS UL Pusch Mapping type A
4067 * struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4068 * @return ROK - success
4071 * ****************************************************************/
4072 uint8_t BuildDMRSULPuschMapTypeA
4074 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4077 dmrsUlCfg->present = PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup;
4078 dmrsUlCfg->choice.setup= NULLP;
4079 DU_ALLOC(dmrsUlCfg->choice.setup, sizeof(DMRS_UplinkConfig_t));
4080 if(!dmrsUlCfg->choice.setup)
4082 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4086 dmrsUlCfg->choice.setup->dmrs_Type = NULLP;
4087 dmrsUlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
4088 DU_ALLOC(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
4089 if(!dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
4091 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4094 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
4096 dmrsUlCfg->choice.setup->phaseTrackingRS = NULLP;
4097 dmrsUlCfg->choice.setup->maxLength = NULLP;
4098 dmrsUlCfg->choice.setup->transformPrecodingDisabled = NULLP;
4099 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled, \
4100 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
4101 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled)
4103 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4107 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0 = NULLP;
4108 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
4110 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0)
4112 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4115 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = SCRAMBLING_ID;
4117 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID1 = NULLP;
4118 dmrsUlCfg->choice.setup->transformPrecodingEnabled = NULLP;
4122 /*******************************************************************
4124 * @brief Build PUSCH time domain allocation list
4128 * Function : BuildPuschTimeDomAllocList
4130 * Functionality: Build PUSCH time domain allocation list
4133 * struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4135 * @return ROK - success
4138 * ****************************************************************/
4139 uint8_t BuildPuschTimeDomAllocList
4141 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4146 PUSCH_TimeDomainResourceAllocation_t *timeDomAlloc;
4148 timeDomAllocList->present = PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup;
4149 timeDomAllocList->choice.setup = NULLP;
4150 DU_ALLOC(timeDomAllocList->choice.setup, \
4151 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
4152 if(!timeDomAllocList->choice.setup)
4154 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4159 timeDomAllocList->choice.setup->list.count = elementCnt;
4160 timeDomAllocList->choice.setup->list.size = \
4161 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
4162 timeDomAllocList->choice.setup->list.array = NULLP;
4163 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
4164 timeDomAllocList->choice.setup->list.size);
4165 if(!timeDomAllocList->choice.setup->list.array)
4167 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4171 for(idx = 0; idx < elementCnt; idx++)
4173 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
4174 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx],\
4175 sizeof(PUSCH_TimeDomainResourceAllocation_t));
4176 if(!timeDomAllocList->choice.setup->list.array[idx])
4178 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4184 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4185 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4186 if(!timeDomAlloc->k2)
4188 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4191 *(timeDomAlloc->k2) = PUSCH_K2_CFG1;
4192 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4193 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4196 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4197 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4198 if(!timeDomAlloc->k2)
4200 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4203 *(timeDomAlloc->k2) = PUSCH_K2_CFG2;
4204 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4205 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4210 /*******************************************************************
4212 * @brief Builds BWP UL dedicated PUSCH Config
4216 * Function : BuildBWPUlDedPuschCfg
4219 * Builds BWP UL dedicated PUSCH Config
4221 * @params[in] : PUSCH_Config_t *puschCfg
4223 * @return ROK - success
4226 * ****************************************************************/
4227 uint8_t BuildBWPUlDedPuschCfg(PUSCH_Config_t *puschCfg)
4229 puschCfg->dataScramblingIdentityPUSCH = NULLP;
4230 DU_ALLOC(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
4231 if(!puschCfg->dataScramblingIdentityPUSCH)
4233 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4236 *(puschCfg->dataScramblingIdentityPUSCH) = SCRAMBLING_ID;
4238 puschCfg->txConfig = NULLP;
4239 puschCfg->dmrs_UplinkForPUSCH_MappingTypeA = NULLP;
4240 DU_ALLOC(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
4241 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
4242 if(!puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
4244 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4248 if(BuildDMRSULPuschMapTypeA(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA) != ROK)
4253 puschCfg->dmrs_UplinkForPUSCH_MappingTypeB = NULLP;
4254 puschCfg->pusch_PowerControl = NULLP;
4255 puschCfg->frequencyHopping = NULLP;
4256 puschCfg->frequencyHoppingOffsetLists = NULLP;
4257 puschCfg->resourceAllocation = RES_ALLOC_TYPE;
4259 puschCfg->pusch_TimeDomainAllocationList = NULLP;
4260 DU_ALLOC(puschCfg->pusch_TimeDomainAllocationList, \
4261 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
4262 if(!puschCfg->pusch_TimeDomainAllocationList)
4264 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4268 if(BuildPuschTimeDomAllocList(puschCfg->pusch_TimeDomainAllocationList) != ROK)
4273 puschCfg->pusch_AggregationFactor = NULLP;
4274 puschCfg->mcs_Table = NULLP;
4275 puschCfg->mcs_TableTransformPrecoder = NULLP;
4276 puschCfg->transformPrecoder = NULLP;
4277 DU_ALLOC(puschCfg->transformPrecoder, sizeof(long));
4278 if(!puschCfg->transformPrecoder)
4280 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4283 *(puschCfg->transformPrecoder) = PUSCH_TRANSFORM_PRECODER;
4285 puschCfg->codebookSubset = NULLP;
4286 puschCfg->maxRank = NULLP;
4287 puschCfg->rbg_Size = NULLP;
4288 puschCfg->uci_OnPUSCH = NULLP;
4289 puschCfg->tp_pi2BPSK = NULLP;
4294 /*******************************************************************
4296 * @brief Builds BWP UL dedicated PUCCH Config
4300 * Function : BuildBWPUlDedPucchCfg
4303 * Builds BWP UL dedicated PUCCH Config
4305 * @params[in] : PUCCH_Config_t *pucchCfg
4307 * @return ROK - success
4310 * ****************************************************************/
4311 uint8_t BuildBWPUlDedPucchCfg(PUCCH_Config_t *pucchCfg)
4313 uint8_t arrIdx, elementCnt;
4315 DU_ALLOC(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
4316 if(pucchCfg->dl_DataToUL_ACK == NULLP)
4318 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4323 pucchCfg->dl_DataToUL_ACK->list.count = elementCnt;
4324 pucchCfg->dl_DataToUL_ACK->list.size = elementCnt * sizeof(long *);
4325 DU_ALLOC(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
4326 if(pucchCfg->dl_DataToUL_ACK->list.array == NULLP)
4328 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4332 for(arrIdx = 0; arrIdx < pucchCfg->dl_DataToUL_ACK->list.count; arrIdx++)
4334 DU_ALLOC(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx], sizeof(long));
4335 if(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx] == NULLP)
4337 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4343 *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx++]) = 1;
4344 *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx]) = 2;
4348 /*******************************************************************
4350 * @brief Fills SRS resource to add/modify list
4354 * Function : BuildSrsRsrcAddModList
4356 * Functionality: Fills SRS resource to add/modify list
4359 * @return ROK - success
4362 * ****************************************************************/
4363 uint8_t BuildSrsRsrcAddModList(struct SRS_Config__srs_ResourceToAddModList *resourceList)
4369 resourceList->list.count = elementCnt;
4370 resourceList->list.size = elementCnt * sizeof(SRS_Resource_t *);
4371 resourceList->list.array = NULLP;
4372 DU_ALLOC(resourceList->list.array, resourceList->list.size);
4373 if(!resourceList->list.array)
4375 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4379 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
4381 DU_ALLOC(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
4382 if(!resourceList->list.array[rsrcIdx])
4384 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4390 resourceList->list.array[rsrcIdx]->srs_ResourceId = SRS_RSRC_ID;
4391 resourceList->list.array[rsrcIdx]->nrofSRS_Ports = SRS_Resource__nrofSRS_Ports_port1;
4392 resourceList->list.array[rsrcIdx]->transmissionComb.present = SRS_Resource__transmissionComb_PR_n2;
4394 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2 = NULLP;
4395 DU_ALLOC(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2, \
4396 sizeof(struct SRS_Resource__transmissionComb__n2));
4397 if(!resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2)
4399 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4402 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->combOffset_n2\
4403 = SRS_COMB_OFFSET_N2;
4404 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->cyclicShift_n2\
4405 = SRS_CYCLIC_SHIFT_N2;
4407 resourceList->list.array[rsrcIdx]->resourceMapping.startPosition = \
4409 resourceList->list.array[rsrcIdx]->resourceMapping.nrofSymbols = \
4410 SRS_Resource__resourceMapping__nrofSymbols_n1;
4411 resourceList->list.array[rsrcIdx]->resourceMapping.repetitionFactor = \
4412 SRS_Resource__resourceMapping__repetitionFactor_n1;
4414 resourceList->list.array[rsrcIdx]->freqDomainPosition = SRS_FREQ_DOM_POS;
4415 resourceList->list.array[rsrcIdx]->freqDomainShift = SRS_FREQ_DOM_SHIFT;
4416 resourceList->list.array[rsrcIdx]->freqHopping.c_SRS = C_SRS;
4417 resourceList->list.array[rsrcIdx]->freqHopping.b_SRS = B_SRS;
4418 resourceList->list.array[rsrcIdx]->freqHopping.b_hop = B_HOP;
4419 resourceList->list.array[rsrcIdx]->groupOrSequenceHopping = \
4420 SRS_Resource__groupOrSequenceHopping_neither;
4422 /* Setting resource type to aperiodic for intergration purposes */
4423 resourceList->list.array[rsrcIdx]->resourceType.present = \
4424 SRS_Resource__resourceType_PR_aperiodic;
4425 resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic = NULLP;
4426 DU_ALLOC(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,
4427 sizeof(struct SRS_Resource__resourceType__aperiodic));
4428 if(!resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic)
4430 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4433 resourceList->list.array[rsrcIdx]->sequenceId = SRS_SEQ_ID;
4438 /*******************************************************************
4440 * @brief Build SRS resource set Add/mod list
4444 * Function : BuildSrsRsrcSetAddModList
4446 * Functionality: Build SRS resource set Add/mod list
4449 * @return ROK - success
4452 * ****************************************************************/
4453 uint8_t BuildSrsRsrcSetAddModList
4455 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList
4461 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList;
4464 rsrcSetList->list.count = elementCnt;
4465 rsrcSetList->list.size = elementCnt * sizeof(SRS_ResourceSet_t *);
4466 rsrcSetList->list.array = NULLP;
4467 DU_ALLOC(rsrcSetList->list.array, rsrcSetList->list.size);
4468 if(!rsrcSetList->list.array)
4470 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4474 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
4476 DU_ALLOC(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
4477 if(!rsrcSetList->list.array[rSetIdx])
4479 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4485 rsrcSetList->list.array[rSetIdx]->srs_ResourceSetId = SRS_RSET_ID;
4487 /* Fill Resource Id list in resource set */
4488 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList = NULLP;
4489 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
4490 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
4491 if(!rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
4493 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4498 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
4499 rsrcIdList->list.count = elementCnt;
4500 rsrcIdList->list.size = elementCnt * sizeof(SRS_ResourceId_t *);
4501 rsrcIdList->list.array = NULLP;
4502 DU_ALLOC(rsrcIdList->list.array, rsrcIdList->list.size);
4503 if(!rsrcIdList->list.array)
4505 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4509 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
4511 DU_ALLOC(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
4512 if(!rsrcIdList->list.array[rsrcIdx])
4514 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4520 *rsrcIdList->list.array[rsrcIdx] = SRS_RSRC_ID;
4522 /* Fill resource type */
4523 rsrcSetList->list.array[rSetIdx]->resourceType.present = \
4524 SRS_ResourceSet__resourceType_PR_aperiodic;
4526 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic = NULLP;
4527 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
4528 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
4529 if(!rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic)
4531 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4534 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger \
4535 = APERIODIC_SRS_RESRC_TRIGGER;
4537 /* TODO : Fill values for below IEs as expected by Viavi */
4538 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->csi_RS = NULLP;
4539 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->slotOffset = NULLP;
4542 rsrcSetList->list.array[rSetIdx]->usage = SRS_ResourceSet__usage_codebook;
4543 rsrcSetList->list.array[rSetIdx]->alpha = NULLP;
4544 rsrcSetList->list.array[rSetIdx]->p0 = NULLP;
4545 rsrcSetList->list.array[rSetIdx]->pathlossReferenceRS = NULLP;
4546 rsrcSetList->list.array[rSetIdx]->srs_PowerControlAdjustmentStates = NULLP;
4551 /*******************************************************************
4553 * @brief Builds BWP UL dedicated SRS Config
4557 * Function : BuildBWPUlDedSrsCfg
4559 * Functionality: Builds BWP UL dedicated SRS Config
4561 * @params[in] SRS Config
4562 * @return ROK - success
4565 * ****************************************************************/
4566 uint8_t BuildBWPUlDedSrsCfg(SRS_Config_t *srsCfg)
4568 srsCfg->srs_ResourceSetToReleaseList = NULLP;
4569 srsCfg->srs_ResourceSetToAddModList = NULLP;
4570 DU_ALLOC(srsCfg->srs_ResourceSetToAddModList, \
4571 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
4572 if(!srsCfg->srs_ResourceSetToAddModList)
4574 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4577 if(BuildSrsRsrcSetAddModList(srsCfg->srs_ResourceSetToAddModList) != ROK)
4582 srsCfg->srs_ResourceToReleaseList = NULLP;
4584 /* Resource to Add/Modify list */
4585 srsCfg->srs_ResourceToAddModList = NULLP;
4586 DU_ALLOC(srsCfg->srs_ResourceToAddModList, \
4587 sizeof(struct SRS_Config__srs_ResourceToAddModList));
4588 if(!srsCfg->srs_ResourceToAddModList)
4590 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4594 if(BuildSrsRsrcAddModList(srsCfg->srs_ResourceToAddModList) != ROK)
4599 srsCfg->tpc_Accumulation = NULLP;
4606 /*******************************************************************
4608 * @brief Builds Pusch Serving cell Config
4612 * Function : BuildPuschSrvCellCfg
4614 * Functionality: Builds Pusch Serving cell Config
4616 * @params[in] struct UplinkConfig__pusch_ServingCellConfig *puschCfg
4618 * @return ROK - success
4621 * ****************************************************************/
4622 uint8_t BuildPuschSrvCellCfg(struct UplinkConfig__pusch_ServingCellConfig *puschCfg)
4624 puschCfg->present = UplinkConfig__pusch_ServingCellConfig_PR_setup;
4625 puschCfg->choice.setup = NULLP;
4626 DU_ALLOC(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
4627 if(!puschCfg->choice.setup)
4629 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4633 puschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4634 puschCfg->choice.setup->rateMatching = NULLP;
4635 puschCfg->choice.setup->xOverhead = NULLP;
4636 puschCfg->choice.setup->ext1 = NULLP;
4637 DU_ALLOC(puschCfg->choice.setup->ext1, sizeof(struct PUSCH_ServingCellConfig__ext1));
4638 if(!puschCfg->choice.setup->ext1)
4640 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4644 puschCfg->choice.setup->ext1->maxMIMO_Layers = NULLP;
4645 DU_ALLOC(puschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
4646 if(!puschCfg->choice.setup->ext1->maxMIMO_Layers)
4648 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4651 *(puschCfg->choice.setup->ext1->maxMIMO_Layers) = PUSCH_MAX_MIMO_LAYERS;
4653 puschCfg->choice.setup->ext1->processingType2Enabled= NULLP;
4654 DU_ALLOC(puschCfg->choice.setup->ext1->processingType2Enabled,sizeof(BOOLEAN_t));
4655 if(!puschCfg->choice.setup->ext1->processingType2Enabled)
4657 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4660 *(puschCfg->choice.setup->ext1->processingType2Enabled) = PUSCH_PROCESS_TYPE2_ENABLED;
4664 /*******************************************************************
4666 * @brief Builds inital UL BWP
4670 * Function : BuildInitialUlBWP
4672 * Functionality: Builds initial UL BWP
4674 * @params[in] BWP_UplinkDedicated_t *ulBwp
4675 * @return ROK - success
4678 * ****************************************************************/
4679 uint8_t BuildInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
4681 ulBwp->pucch_Config = NULLP;
4682 DU_ALLOC(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
4683 if(!ulBwp->pucch_Config)
4685 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4689 ulBwp->pucch_Config->present = BWP_UplinkDedicated__pucch_Config_PR_setup;
4690 ulBwp->pucch_Config->choice.setup = NULLP;
4691 DU_ALLOC(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
4692 if(!ulBwp->pucch_Config->choice.setup)
4694 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4698 if(BuildBWPUlDedPucchCfg(ulBwp->pucch_Config->choice.setup) != ROK)
4703 /* Fill BWP UL dedicated PUSCH config */
4704 ulBwp->pusch_Config = NULLP;
4705 DU_ALLOC(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
4706 if(!ulBwp->pusch_Config)
4708 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4712 ulBwp->pusch_Config->present = BWP_UplinkDedicated__pusch_Config_PR_setup;
4713 ulBwp->pusch_Config->choice.setup = NULLP;
4714 DU_ALLOC(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
4715 if(!ulBwp->pusch_Config->choice.setup)
4717 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4721 if(BuildBWPUlDedPuschCfg(ulBwp->pusch_Config->choice.setup) != ROK)
4726 ulBwp->configuredGrantConfig = NULLP;
4728 /* Fill BPW UL dedicated SRS config */
4729 ulBwp->srs_Config = NULLP;
4730 DU_ALLOC(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
4731 if(!ulBwp->srs_Config)
4733 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4737 ulBwp->srs_Config->present = BWP_UplinkDedicated__srs_Config_PR_setup;
4738 ulBwp->srs_Config->choice.setup = NULLP;
4739 DU_ALLOC(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
4740 if(!ulBwp->srs_Config->choice.setup)
4742 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4746 if(BuildBWPUlDedSrsCfg(ulBwp->srs_Config->choice.setup) != ROK)
4751 ulBwp->beamFailureRecoveryConfig = NULLP;
4756 /*******************************************************************
4758 * @brief Builds UL config
4761 * Function : BuildUlCfg
4763 * Functionality: Builds UL config in spCellCfgDed
4765 * @params[in] UplinkConfig_t *ulCfg
4767 * @return ROK - success
4770 * ****************************************************************/
4771 uint8_t BuildUlCfg(UplinkConfig_t *ulCfg)
4773 ulCfg->initialUplinkBWP = NULLP;
4774 DU_ALLOC(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
4775 if(!ulCfg->initialUplinkBWP)
4777 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4781 if(BuildInitialUlBWP(ulCfg->initialUplinkBWP) != ROK)
4786 ulCfg->uplinkBWP_ToReleaseList = NULLP;
4787 ulCfg->uplinkBWP_ToAddModList = NULLP;
4788 ulCfg->firstActiveUplinkBWP_Id = NULLP;
4789 DU_ALLOC(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
4790 if(!ulCfg->firstActiveUplinkBWP_Id)
4792 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4795 *(ulCfg->firstActiveUplinkBWP_Id) = ACTIVE_UL_BWP_ID;
4797 ulCfg->pusch_ServingCellConfig = NULLP;
4798 DU_ALLOC(ulCfg->pusch_ServingCellConfig, \
4799 sizeof(struct UplinkConfig__pusch_ServingCellConfig));
4800 if(!ulCfg->pusch_ServingCellConfig)
4802 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4806 if(BuildPuschSrvCellCfg(ulCfg->pusch_ServingCellConfig) != ROK)
4811 ulCfg->carrierSwitching = NULLP;
4812 ulCfg->ext1 = NULLP;
4816 /*******************************************************************
4818 * @brief Builds PDSCH serving cell config
4821 * Function : BuildPdschSrvCellCfg
4823 * Functionality: Builds PDSCH serving cell config in spCellCfgDed
4825 * @params[in] struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg
4827 * @return ROK - success
4830 * ****************************************************************/
4831 uint8_t BuildPdschSrvCellCfg(struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg)
4833 pdschCfg->present = ServingCellConfig__pdsch_ServingCellConfig_PR_setup;
4834 pdschCfg->choice.setup = NULLP;
4835 DU_ALLOC(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
4836 if(!pdschCfg->choice.setup)
4838 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4842 pdschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4843 pdschCfg->choice.setup->xOverhead = NULLP;
4844 pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH = NULLP;
4845 DU_ALLOC(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH, sizeof(long));
4846 if(!pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)
4848 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4851 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)= PDSCH_NUM_HARQ_PROC;
4852 pdschCfg->choice.setup->pucch_Cell = NULLP;
4853 pdschCfg->choice.setup->ext1 = NULLP;
4858 /*******************************************************************
4860 * @brief Builds CSI Meas config
4863 * Function : BuildCsiMeasCfg
4865 * Functionality: Builds CSI Meas config in spCellCfgDed
4867 * @params[in] struct ServingCellConfig__csi_MeasConfig *csiMeasCfg
4869 * @return ROK - success
4872 * ****************************************************************/
4873 uint8_t BuildCsiMeasCfg(struct ServingCellConfig__csi_MeasConfig *csiMeasCfg)
4879 /*******************************************************************
4881 * @brief Builds Spcell config dedicated
4884 * Function : BuildSpCellCfgDed
4886 * Functionality: Builds sp cell config dedicated in spCellCfg
4888 * @params[in] ServingCellConfig_t srvCellCfg
4890 * @return ROK - success
4893 * ****************************************************************/
4894 uint8_t BuildSpCellCfgDed(ServingCellConfig_t *srvCellCfg)
4896 srvCellCfg->tdd_UL_DL_ConfigurationDedicated = NULLP;
4897 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
4898 if(!srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
4900 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4904 srvCellCfg->initialDownlinkBWP = NULLP;
4905 DU_ALLOC(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
4906 if(!srvCellCfg->initialDownlinkBWP)
4908 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4912 if(BuildInitialDlBWP(srvCellCfg->initialDownlinkBWP) != ROK)
4914 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
4917 srvCellCfg->downlinkBWP_ToReleaseList = NULLP;
4918 srvCellCfg->downlinkBWP_ToAddModList = NULLP;
4920 srvCellCfg->firstActiveDownlinkBWP_Id = NULLP;
4921 DU_ALLOC(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
4922 if(!srvCellCfg->firstActiveDownlinkBWP_Id)
4924 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4927 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4929 srvCellCfg->bwp_InactivityTimer = NULLP;
4931 srvCellCfg->defaultDownlinkBWP_Id = NULLP;
4932 DU_ALLOC(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
4933 if(!srvCellCfg->defaultDownlinkBWP_Id)
4935 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4938 *(srvCellCfg->defaultDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4940 srvCellCfg->uplinkConfig = NULLP;
4941 DU_ALLOC(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
4942 if(!srvCellCfg->uplinkConfig)
4944 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4948 if(BuildUlCfg(srvCellCfg->uplinkConfig) != ROK)
4950 DU_LOG("\nERROR --> F1AP : BuildUlCfg failed");
4953 srvCellCfg->supplementaryUplink = NULLP;
4954 srvCellCfg->pdcch_ServingCellConfig = NULLP;
4956 srvCellCfg->pdsch_ServingCellConfig = NULLP;
4957 DU_ALLOC(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
4958 if(!srvCellCfg->pdsch_ServingCellConfig)
4960 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4964 if(BuildPdschSrvCellCfg(srvCellCfg->pdsch_ServingCellConfig) != ROK)
4966 DU_LOG("\nERROR --> F1AP : BuildPdschSrvCellCfg failed");
4970 srvCellCfg->csi_MeasConfig = NULLP;
4972 DU_ALLOC(srvCellCfg->csi_MeasConfig, sizeof(struct ServingCellConfig__csi_MeasConfig))
4973 if(!srvCellCfg->csi_MeasConfig)
4975 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4979 if(BuildCsiMeasCfg(srvCellCfg->csi_MeasConfig) != ROK)
4981 DU_LOG("\nF1AP : BuildCsiMeasCfg failed");
4985 srvCellCfg->sCellDeactivationTimer = NULLP;
4986 srvCellCfg->crossCarrierSchedulingConfig = NULLP;
4987 srvCellCfg->tag_Id = TAG_ID;
4988 srvCellCfg->dummy = NULLP;
4989 srvCellCfg->pathlossReferenceLinking = NULLP;
4990 srvCellCfg->servingCellMO = NULLP;
4991 srvCellCfg->ext1 = NULLP;
4995 /*******************************************************************
4997 * @brief Builds Spcell config
5001 * Function : BuildSpCellCfg
5003 * Functionality: Builds sp cell config in DuToCuRrcContainer
5005 * @params[in] SpCellConfig_t spCellCfg
5007 * @return ROK - success
5010 * ****************************************************************/
5011 uint8_t BuildSpCellCfg(SpCellConfig_t *spCellCfg)
5014 spCellCfg->servCellIndex = NULLP;
5015 DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
5016 if(!spCellCfg->servCellIndex)
5018 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
5021 *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
5023 spCellCfg->reconfigurationWithSync = NULLP;
5024 spCellCfg->rlf_TimersAndConstants = NULLP;
5025 spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
5026 DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5027 if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
5029 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
5032 *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
5034 spCellCfg->spCellConfigDedicated = NULLP;
5035 DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5036 if(!spCellCfg->spCellConfigDedicated)
5038 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
5041 if(BuildSpCellCfgDed(spCellCfg->spCellConfigDedicated) != ROK)
5043 DU_LOG("\nERROR --> F1AP : BuildSpCellCfgDed failed");
5048 /*******************************************************************
5050 * @brief Builds Phy cell group config
5054 * Function : BuildPhyCellGrpCfg
5056 * Functionality: Builds Phy cell group config in DuToCuRrcContainer
5058 * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg
5060 * @return ROK - success
5063 * ****************************************************************/
5064 uint8_t BuildPhyCellGrpCfg(PhysicalCellGroupConfig_t *phyCellGrpCfg)
5066 phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
5067 phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
5069 phyCellGrpCfg->p_NR_FR1 = NULLP;
5070 DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5071 if(!phyCellGrpCfg->p_NR_FR1)
5073 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
5076 *(phyCellGrpCfg->p_NR_FR1) = P_NR_FR1;
5077 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
5078 phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
5079 phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
5080 phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
5081 phyCellGrpCfg->sp_CSI_RNTI = NULLP;
5082 phyCellGrpCfg->cs_RNTI = NULLP;
5083 phyCellGrpCfg->ext1 = NULLP;
5084 phyCellGrpCfg->ext2 = NULLP;
5088 /*******************************************************************
5090 * @brief Builds Mac cell group config
5094 * Function : BuildMacCellGrpCfg
5096 * Functionality: Builds Mac cell group config in DuToCuRrcContainer
5098 * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
5100 * @return ROK - success
5103 * ****************************************************************/
5104 uint8_t BuildMacCellGrpCfg(MAC_CellGroupConfig_t *macCellGrpCfg)
5106 macCellGrpCfg->drx_Config = NULLP;
5107 macCellGrpCfg->schedulingRequestConfig = NULLP;
5108 DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5109 if(!macCellGrpCfg->schedulingRequestConfig)
5111 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5115 if(BuildSchedulingReqConfig(macCellGrpCfg->schedulingRequestConfig) != ROK)
5117 DU_LOG("\nERROR --> F1AP : BuildSchedulingReqConfig failed");
5121 macCellGrpCfg->bsr_Config = NULLP;
5122 DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5123 if(!macCellGrpCfg->bsr_Config)
5125 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5129 if(BuildBsrConfig(macCellGrpCfg->bsr_Config) != ROK)
5131 DU_LOG("\nERROR --> F1AP : BuildBsrConfig failed");
5135 macCellGrpCfg->tag_Config = NULLP;
5136 DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
5137 if(!macCellGrpCfg->tag_Config)
5139 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5143 if(BuildTagConfig(macCellGrpCfg->tag_Config) != ROK)
5145 DU_LOG("\nERROR --> F1AP : BuildTagConfig failed");
5149 macCellGrpCfg->phr_Config = NULLP;
5150 DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
5151 if(!macCellGrpCfg->phr_Config)
5153 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5157 if(BuildPhrConfig(macCellGrpCfg->phr_Config) != ROK)
5159 DU_LOG("\nERROR --> F1AP : BuildPhrConfig failed");
5163 macCellGrpCfg->skipUplinkTxDynamic = false;
5164 macCellGrpCfg->ext1 = NULLP;
5168 /*******************************************************************
5170 * @brief Frees memeory allocated for SearchSpcToAddModList
5174 * Function : FreeSearchSpcToAddModList
5176 * Functionality: Deallocating memory of SearchSpcToAddModList
5178 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
5182 4221 * ****************************************************************/
5183 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
5187 struct SearchSpace *searchSpc=NULLP;
5189 if(searchSpcList->list.array)
5191 if(searchSpcList->list.array[idx2])
5193 searchSpc = searchSpcList->list.array[idx2];
5194 if(searchSpc->controlResourceSetId)
5196 if(searchSpc->monitoringSlotPeriodicityAndOffset)
5198 if(searchSpc->monitoringSymbolsWithinSlot)
5200 if(searchSpc->monitoringSymbolsWithinSlot->buf)
5202 if(searchSpc->nrofCandidates)
5204 if(searchSpc->searchSpaceType)
5206 DU_FREE(searchSpc->searchSpaceType->choice.ue_Specific,\
5207 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
5208 DU_FREE(searchSpc->searchSpaceType, sizeof(struct
5209 SearchSpace__searchSpaceType));
5211 DU_FREE(searchSpc->nrofCandidates,
5212 sizeof(struct SearchSpace__nrofCandidates));
5214 DU_FREE(searchSpc->monitoringSymbolsWithinSlot->buf, \
5215 searchSpc->monitoringSymbolsWithinSlot->size);
5217 DU_FREE(searchSpc->monitoringSymbolsWithinSlot,
5218 sizeof(BIT_STRING_t));
5220 DU_FREE(searchSpc->monitoringSlotPeriodicityAndOffset, \
5221 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
5223 DU_FREE(searchSpc->controlResourceSetId,
5224 sizeof(ControlResourceSetId_t));
5227 for(idx1 = 0; idx1 < searchSpcList->list.count; idx1++)
5229 DU_FREE(searchSpcList->list.array[idx1],
5230 sizeof(struct SearchSpace));
5232 DU_FREE(searchSpcList->list.array,searchSpcList->list.size);
5235 /*******************************************************************
5237 * @brief Frees memory allocated for PdschTimeDomAllocList
5241 * Function : FreePdschTimeDomAllocList
5243 * Functionality: Deallocating memory of PdschTimeDomAllocList
5245 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
5249 * ****************************************************************/
5250 void FreePdschTimeDomAllocList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
5254 if(timeDomAllocList->choice.setup)
5256 if(timeDomAllocList->choice.setup->list.array)
5258 for(idx1 = 0; idx1 <timeDomAllocList->choice.setup->list.count ; idx1++)
5260 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1]->k0, sizeof(long));
5261 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1],
5262 sizeof(struct PDSCH_TimeDomainResourceAllocation));
5264 DU_FREE(timeDomAllocList->choice.setup->list.array, \
5265 timeDomAllocList->choice.setup->list.size);
5267 DU_FREE(timeDomAllocList->choice.setup,\
5268 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
5271 /*******************************************************************
5273 * @brief Frees memory allocated for PuschTimeDomAllocList
5277 * Function : FreePuschTimeDomAllocList
5279 * Functionality: Deallocating memory of PuschTimeDomAllocList
5281 * @params[in] PUSCH_Config_t *puschCfg
5285 * ****************************************************************/
5286 void FreePuschTimeDomAllocList(PUSCH_Config_t *puschCfg)
5288 uint8_t rsrcListIdx=0;
5289 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
5291 if(puschCfg->pusch_TimeDomainAllocationList)
5293 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
5294 if(timeDomAllocList_t->choice.setup)
5296 if(timeDomAllocList_t->choice.setup->list.array)
5298 for(rsrcListIdx = 0; rsrcListIdx<timeDomAllocList_t->choice.setup->list.count; rsrcListIdx++)
5300 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx]->k2, sizeof(long));
5301 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx],\
5302 sizeof(PUSCH_TimeDomainResourceAllocation_t));
5304 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
5305 timeDomAllocList_t->choice.setup->list.size);
5307 DU_FREE(timeDomAllocList_t->choice.setup, \
5308 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
5310 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
5311 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
5312 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
5316 /*******************************************************************
5318 * @brief Frees memory allocated for InitialUlBWP
5322 * Function : FreeInitialUlBWP
5324 * Functionality: Deallocating memory of InitialUlBWP
5326 * @params[in] BWP_UplinkDedicated_t *ulBwp
5330 * ****************************************************************/
5331 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
5333 uint8_t rSetIdx, rsrcIdx, k1Idx;
5334 SRS_Config_t *srsCfg = NULLP;
5335 PUSCH_Config_t *puschCfg = NULLP;
5336 PUCCH_Config_t *pucchCfg = NULLP;
5337 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
5338 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
5339 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
5340 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
5342 if(ulBwp->pucch_Config)
5344 if(ulBwp->pucch_Config->choice.setup)
5346 pucchCfg = ulBwp->pucch_Config->choice.setup;
5347 if(pucchCfg->dl_DataToUL_ACK)
5349 if(pucchCfg->dl_DataToUL_ACK->list.array)
5351 for(k1Idx = 0; k1Idx < pucchCfg->dl_DataToUL_ACK->list.count; k1Idx++)
5353 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array[k1Idx], sizeof(long));
5355 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
5357 DU_FREE(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
5359 DU_FREE(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
5361 DU_FREE(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
5364 if(ulBwp->pusch_Config)
5366 if(ulBwp->pusch_Config->choice.setup)
5368 puschCfg=ulBwp->pusch_Config->choice.setup;
5369 if(puschCfg->dataScramblingIdentityPUSCH)
5371 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
5373 FreePuschTimeDomAllocList(puschCfg);
5374 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
5375 if(dmrsUlCfg->choice.setup)
5377 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
5379 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
5381 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
5383 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
5384 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
5386 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
5389 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
5391 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
5392 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
5394 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
5396 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5398 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5400 /* Free SRS-Config */
5401 if(ulBwp->srs_Config)
5403 if(ulBwp->srs_Config->choice.setup)
5405 srsCfg = ulBwp->srs_Config->choice.setup;
5407 /* Free Resource Set to add/mod list */
5408 if(srsCfg->srs_ResourceSetToAddModList)
5410 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
5411 if(rsrcSetList->list.array)
5415 /* Free SRS resource Id list in this SRS resource set */
5416 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5418 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5420 if(rsrcIdList->list.array)
5422 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5424 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5426 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
5428 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5429 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5432 /* Free resource type info for this SRS resource set */
5433 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5434 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5436 /* Free memory for each resource set */
5437 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5439 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5441 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
5443 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
5444 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5447 /* Free resource to add/modd list */
5448 if(srsCfg->srs_ResourceToAddModList)
5450 resourceList = srsCfg->srs_ResourceToAddModList;
5451 if(resourceList->list.array)
5454 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
5455 sizeof(struct SRS_Resource__transmissionComb__n2));
5456 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
5457 sizeof(struct SRS_Resource__resourceType__aperiodic));
5459 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5461 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5463 DU_FREE(resourceList->list.array, resourceList->list.size);
5465 DU_FREE(srsCfg->srs_ResourceToAddModList, \
5466 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5469 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5471 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5475 /*******************************************************************
5477 * @brief Frees memory allocated for initialUplinkBWP
5481 * Function : FreeinitialUplinkBWP
5483 * Functionality: Deallocating memory of initialUplinkBWP
5485 * @params[in] UplinkConfig_t *ulCfg
5490 * ****************************************************************/
5491 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
5493 BWP_UplinkDedicated_t *ulBwp=NULLP;
5494 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
5496 if(ulCfg->initialUplinkBWP)
5498 ulBwp=ulCfg->initialUplinkBWP;
5499 if(ulCfg->firstActiveUplinkBWP_Id)
5501 if(ulCfg->pusch_ServingCellConfig)
5503 puschCfg=ulCfg->pusch_ServingCellConfig;
5504 if(puschCfg->choice.setup)
5506 if(puschCfg->choice.setup->ext1)
5508 DU_FREE(puschCfg->choice.setup->ext1->\
5509 processingType2Enabled,sizeof(BOOLEAN_t));
5510 DU_FREE(puschCfg->choice.setup->ext1->\
5511 maxMIMO_Layers,sizeof(long));
5512 DU_FREE(puschCfg->choice.setup->ext1, \
5513 sizeof(struct PUSCH_ServingCellConfig__ext1));
5515 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5517 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5519 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5521 FreeInitialUlBWP(ulBwp);
5522 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5525 /*******************************************************************
5527 * @brief Frees emmory allocated for BWPDlDedPdschCfg
5531 * Function : FreeBWPDlDedPdschCfg
5533 * Functionality: Deallocating memory of BWPDlDedPdschCfg
5535 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5540 * ****************************************************************/
5541 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
5543 struct PDSCH_Config *pdschCfg=NULLP;
5544 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
5545 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
5546 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
5548 if(dlBwp->pdsch_Config->choice.setup)
5550 pdschCfg=dlBwp->pdsch_Config->choice.setup;
5551 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
5553 if(pdschCfg->pdsch_TimeDomainAllocationList)
5555 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
5556 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
5558 prbBndlType=&pdschCfg->prb_BundlingType;
5559 DU_FREE(prbBndlType->choice.staticBundling,\
5560 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
5561 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
5563 FreePdschTimeDomAllocList(timeDomAllocList);
5564 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
5565 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
5567 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
5568 if(dmrsDlCfg->choice.setup)
5570 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
5572 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
5574 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
5575 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
5577 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
5580 /*******************************************************************
5582 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
5586 * Function : FreeBWPDlDedPdcchCfg
5588 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
5590 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5595 * ****************************************************************/
5596 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
5600 struct PDCCH_Config *pdcchCfg=NULLP;
5601 struct ControlResourceSet *controlRSet=NULLP;
5602 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
5604 if(dlBwp->pdcch_Config->choice.setup)
5606 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
5607 if(pdcchCfg->controlResourceSetToAddModList)
5609 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
5610 if(controlRSetList->list.array)
5612 controlRSet = controlRSetList->list.array[idx2];
5615 if(controlRSet->frequencyDomainResources.buf)
5617 if(controlRSet->pdcch_DMRS_ScramblingID)
5619 if(pdcchCfg->searchSpacesToAddModList)
5621 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
5622 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
5623 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
5625 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
5627 DU_FREE(controlRSet->frequencyDomainResources.buf, \
5628 controlRSet->frequencyDomainResources.size);
5631 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
5633 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
5635 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
5637 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
5638 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
5640 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
5644 /*******************************************************************
5646 * @brief Frees emmory allocated for DUToCURRCContainer
5650 * Function : FreeMemDuToCuRrcCont
5652 * Functionality: Deallocating memory of DuToCuRrcContainer
5654 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
5656 * @return ROK - success
5659 * ****************************************************************/
5660 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
5663 SpCellConfig_t *spCellCfg=NULLP;
5664 ServingCellConfig_t *srvCellCfg=NULLP;
5665 BWP_DownlinkDedicated_t *dlBwp=NULLP;
5666 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
5667 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
5668 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
5669 struct RLC_Config *rlcConfig=NULLP;
5670 struct LogicalChannelConfig *macLcConfig=NULLP;
5671 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
5672 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
5673 struct TAG_Config *tagConfig=NULLP;
5674 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
5675 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
5676 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
5678 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
5681 if(rlcBearerList->list.array)
5683 for(idx=0; idx<rlcBearerList->list.count; idx++)
5685 if(rlcBearerList->list.array[idx])
5687 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
5688 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
5691 if(rlcConfig->choice.am)
5693 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5694 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5695 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
5697 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
5699 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
5702 if(macLcConfig->ul_SpecificParameters)
5704 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
5705 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
5706 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
5708 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
5710 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
5713 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
5715 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5718 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
5721 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
5722 if(schedulingRequestConfig)
5724 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
5727 if(schReqList->list.array)
5729 for(idx=0;idx<schReqList->list.count; idx++)
5731 if(schReqList->list.array[idx])
5733 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
5734 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
5737 DU_FREE(schReqList->list.array, schReqList->list.size);
5739 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
5740 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
5741 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5743 if(macCellGrpCfg->bsr_Config)
5745 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5747 tagConfig = macCellGrpCfg->tag_Config;
5750 tagList = tagConfig->tag_ToAddModList;
5753 if(tagList->list.array)
5755 for(idx=0; idx<tagList->list.count; idx++)
5757 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
5759 DU_FREE(tagList->list.array, tagList->list.size);
5761 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
5763 DU_FREE(tagConfig, sizeof(struct TAG_Config));
5766 phrConfig = macCellGrpCfg->phr_Config;
5769 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
5770 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
5773 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
5776 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
5779 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5780 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
5783 spCellCfg = cellGrpCfg->spCellConfig;
5786 if(spCellCfg->servCellIndex)
5788 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
5790 if(spCellCfg->spCellConfigDedicated)
5792 srvCellCfg = spCellCfg->spCellConfigDedicated;
5793 if(srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
5795 if(srvCellCfg->initialDownlinkBWP)
5797 dlBwp = srvCellCfg->initialDownlinkBWP;
5798 if(srvCellCfg->firstActiveDownlinkBWP_Id)
5800 if(srvCellCfg->defaultDownlinkBWP_Id)
5802 if(srvCellCfg->uplinkConfig)
5804 if(srvCellCfg->pdsch_ServingCellConfig)
5806 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
5807 if(pdschCfg->choice.setup)
5809 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
5810 DU_FREE(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5812 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct
5813 ServingCellConfig__pdsch_ServingCellConfig));
5815 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
5816 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
5818 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
5820 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
5822 if(dlBwp->pdcch_Config)
5824 if(dlBwp->pdsch_Config)
5826 FreeBWPDlDedPdschCfg(dlBwp);
5827 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
5829 FreeBWPDlDedPdcchCfg(dlBwp);
5830 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
5832 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
5834 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
5836 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5838 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5840 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
5842 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
5846 /*******************************************************************
5848 * @brief Builds DU To CU RRC Container
5852 * Function : BuildDuToCuRrcContainer
5854 * Functionality: Builds DuToCuRrcContainer
5856 * @params[in] idx, index in F1AP msg
5857 * DuToCuRRCContainer, DuToCuRRCContainer
5859 * @return ROK - success
5862 * ****************************************************************/
5863 uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
5866 CellGroupConfigRrc_t cellGrpCfg;
5867 asn_enc_rval_t encRetVal;
5868 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
5869 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
5873 cellGrpCfg.cellGroupId = CELL_GRP_ID;
5875 cellGrpCfg.rlc_BearerToAddModList = NULLP;
5876 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5877 if(!cellGrpCfg.rlc_BearerToAddModList)
5879 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5883 if(BuildRlcBearerToAddModList(cellGrpCfg.rlc_BearerToAddModList) != ROK)
5885 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
5890 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
5891 cellGrpCfg.mac_CellGroupConfig = NULLP;
5892 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
5893 if(!cellGrpCfg.mac_CellGroupConfig)
5895 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5899 if(BuildMacCellGrpCfg(cellGrpCfg.mac_CellGroupConfig) != ROK)
5901 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
5906 cellGrpCfg.physicalCellGroupConfig = NULLP;
5907 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
5908 if(!cellGrpCfg.physicalCellGroupConfig)
5910 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5914 if(BuildPhyCellGrpCfg(cellGrpCfg.physicalCellGroupConfig) != ROK)
5916 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
5921 cellGrpCfg.spCellConfig = NULLP;
5922 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
5923 if(!cellGrpCfg.spCellConfig)
5925 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5929 if(BuildSpCellCfg(cellGrpCfg.spCellConfig) != ROK)
5931 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
5936 cellGrpCfg.sCellToAddModList = NULLP;
5937 cellGrpCfg.sCellToReleaseList = NULLP;
5938 cellGrpCfg.ext1 = NULLP;
5940 /* encode cellGrpCfg into duToCuRrcContainer */
5941 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
5942 memset(encBuf, 0, ENC_BUF_MAX_LEN);
5944 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
5945 /* Encode results */
5946 if(encRetVal.encoded == ENCODE_FAIL)
5948 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
5949 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
5955 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
5956 for(int i=0; i< encBufSize; i++)
5958 printf("%x",encBuf[i]);
5962 duToCuRrcContainer->size = encBufSize;
5963 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
5964 if(!duToCuRrcContainer->buf)
5966 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
5972 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
5976 FreeMemDuToCuRrcCont(&cellGrpCfg);
5980 /*******************************************************************
5982 * @brief Free memory allocated in InitialULRRCMessage
5986 * Function : freeInitUlRrcMsgTransfer
5988 * Functionality: Free memory allocated in InitialULRRCMessage
5990 * @params[in]F1AP_PDU_t *f1apMsg)
5992 * @return ROK - success
5995 * ****************************************************************/
5997 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
5999 uint8_t ieIdx, arrIdx;
6000 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
6004 if(f1apMsg->choice.initiatingMessage)
6006 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
6007 choice.InitialULRRCMessageTransfer;
6008 if(initULRRCMsg->protocolIEs.list.array)
6010 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
6012 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
6014 case ProtocolIE_ID_id_NRCGI:
6016 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
6018 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
6020 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
6021 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
6023 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
6024 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
6028 case ProtocolIE_ID_id_RRCContainer:
6030 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6032 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
6033 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6037 case ProtocolIE_ID_id_DUtoCURRCContainer:
6039 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
6041 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
6042 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
6050 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
6052 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
6054 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
6055 sizeof(InitialULRRCMessageTransferIEs_t));
6058 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
6060 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6062 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
6066 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
6072 /*******************************************************************
6074 * @brief Builds and sends the InitialULRRCMessage
6078 * Function : BuildAndSendInitialRrcMsgTransfer
6080 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
6081 * it to the CU through SCTP.
6085 * @return ROK - success
6088 * ****************************************************************/
6089 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
6090 uint16_t rrcContSize, uint8_t *rrcContainer)
6095 asn_enc_rval_t encRetVal;
6096 F1AP_PDU_t *f1apMsg = NULLP;
6097 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
6098 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
6102 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
6103 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
6104 if(f1apMsg == NULLP)
6106 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6109 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
6110 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6111 if(f1apMsg->choice.initiatingMessage == NULLP)
6113 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6116 f1apMsg->choice.initiatingMessage->procedureCode =\
6117 ProcedureCode_id_InitialULRRCMessageTransfer;
6118 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
6119 f1apMsg->choice.initiatingMessage->value.present = \
6120 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
6122 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
6124 initULRRCMsg->protocolIEs.list.count = elementCnt;
6125 initULRRCMsg->protocolIEs.list.size = \
6126 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
6127 /* Initialize the F1Setup members */
6128 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
6129 if(initULRRCMsg->protocolIEs.list.array == NULLP)
6131 DU_LOG(" ERROR --> F1AP : Memory allocation for\
6132 RRCSetupRequestMessageTransferIEs failed");
6135 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
6137 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
6138 sizeof(InitialULRRCMessageTransferIEs_t));
6139 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
6145 /*GNB DU UE F1AP ID*/
6146 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6147 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
6148 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6149 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6150 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
6151 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
6156 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6157 ProtocolIE_ID_id_NRCGI;
6158 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
6159 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6160 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
6163 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
6171 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6172 ProtocolIE_ID_id_C_RNTI;
6173 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6174 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6175 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
6176 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
6180 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6181 ProtocolIE_ID_id_RRCContainer;
6182 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6183 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6184 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
6186 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
6187 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
6188 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
6189 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6191 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
6195 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
6196 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6199 /*DUtoCURRCContainer*/
6201 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
6202 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6203 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6204 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
6206 ret = BuildDuToCuRrcContainer(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
6212 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
6214 /* Encode the F1SetupRequest type as APER */
6215 memset(encBuf, 0, ENC_BUF_MAX_LEN);
6217 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
6218 /* Encode results */
6219 if(encRetVal.encoded == ENCODE_FAIL)
6221 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
6222 structure (at %s)\n",encRetVal.failed_type ? \
6223 encRetVal.failed_type->name : "unknown");
6230 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
6231 Message transfer\n");
6232 for(int i=0; i< encBufSize; i++)
6234 printf("%x",encBuf[i]);
6238 if(sendF1APMsg() != ROK)
6240 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
6246 freeInitUlRrcMsgTransfer(f1apMsg);
6248 }/* End of BuildAndSendInitialRrcMsgTransfer*/
6250 /***** UE SETUP REQUEST *****/
6252 /*******************************************************************
6254 * @brief Free Qos And Snssai Drb Info
6258 * Function : freeDrbQosAndSnssaiInfo
6260 * Functionality: Free Qos And Snssai Drb Info
6262 * @params[in] LcCfg *lcCfg,
6265 * ****************************************************************/
6266 void freeDrbQosAndSnssaiInfo(LcCfg *lcCfg)
6270 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6274 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6278 /******************************************************************
6280 * @brief Function to delete the RLC Lc cfg from UE APP DB
6284 * Function : freeRlcLcCfg
6286 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
6289 *****************************************************************/
6291 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
6293 switch(lcCfg->rlcMode)
6299 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
6303 case RLC_UM_BI_DIRECTIONAL :
6305 if(lcCfg->u.umBiDirCfg)
6307 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
6311 case RLC_UM_UNI_DIRECTIONAL_UL :
6313 if(lcCfg->u.umUniDirUlCfg)
6315 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
6320 case RLC_UM_UNI_DIRECTIONAL_DL :
6322 if(lcCfg->u.umUniDirDlCfg)
6324 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
6329 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
6334 /*******************************************************************
6336 * @brief Function to free MacLcCfg
6340 * Function : freeMacLcCfg
6342 * Functionality: Function to free MacLcCfg
6344 * @params[in] LcCfg *lcCfg,
6347 * ****************************************************************/
6349 void freeMacLcCfg(LcCfg *lcCfg)
6351 /* Deleting DRBQOS */
6354 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6356 /* Deleting SNSSAI */
6359 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6362 /*******************************************************************
6364 * @brief Free UE NR Capability received in UE Context setup request
6368 * Function : freeAperDecodeUeNrCapability
6371 * Free UE NR Capability received in UE Context setup request
6374 * @return ROK - success
6377 * ****************************************************************/
6378 void freeAperDecodeUeNrCapability(void *ueNrCapability)
6381 FeatureSets_t *featureSets =NULLP;
6382 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
6384 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
6386 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
6388 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
6389 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
6391 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
6394 if(ueNrCap->featureSets)
6396 featureSets = ueNrCap->featureSets;
6397 if(featureSets->featureSetsDownlinkPerCC)
6399 if(featureSets->featureSetsDownlinkPerCC->list.array)
6401 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
6403 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
6405 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
6406 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
6407 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
6410 free(featureSets->featureSetsDownlinkPerCC->list.array);
6412 free(featureSets->featureSetsDownlinkPerCC);
6414 if(featureSets->featureSetsUplinkPerCC)
6416 if(featureSets->featureSetsUplinkPerCC->list.array)
6418 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
6420 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
6422 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
6423 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
6424 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
6427 free(featureSets->featureSetsUplinkPerCC->list.array);
6429 free(featureSets->featureSetsUplinkPerCC);
6431 free(ueNrCap->featureSets);
6435 /*******************************************************************
6437 * @brief Function to free PdcchSearchSpcToAddModList
6438 where memory allocated by aper_decoder
6442 * Function : freeAperDecodePdcchSearchSpcToAddModList
6444 * Functionality: Function to free PdcchSearchSpcToAddModList
6446 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
6449 * ****************************************************************/
6451 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
6453 uint8_t searchSpcArrIdx=0;
6454 uint8_t searchSpcArrIdx1=0;
6455 struct SearchSpace *searchSpc=NULLP;
6458 if(searchSpcList->list.array)
6460 if(searchSpcList->list.array[searchSpcArrIdx1])
6462 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
6463 if(searchSpc->controlResourceSetId)
6465 if(searchSpc->monitoringSlotPeriodicityAndOffset)
6467 if(searchSpc->monitoringSymbolsWithinSlot)
6469 if(searchSpc->monitoringSymbolsWithinSlot->buf)
6471 if(searchSpc->nrofCandidates)
6473 if(searchSpc->searchSpaceType)
6475 free(searchSpc->searchSpaceType->choice.ue_Specific);
6476 free(searchSpc->searchSpaceType);
6478 free(searchSpc->nrofCandidates);
6480 free(searchSpc->monitoringSymbolsWithinSlot->buf);
6482 free(searchSpc->monitoringSymbolsWithinSlot);
6484 free(searchSpc->monitoringSlotPeriodicityAndOffset);
6486 free(searchSpc->controlResourceSetId);
6489 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
6491 free(searchSpcList->list.array[searchSpcArrIdx]);
6493 free(searchSpcList->list.array);
6496 /*******************************************************************
6498 * @brief Function for free part for the memory allocated by aper_decoder
6502 * Function : freeAperDecodeBWPDlDedPdcchConfig
6504 * Functionality: Function to free BWPDlDedPdcchConfig
6509 * ****************************************************************/
6512 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
6516 struct PDCCH_Config *pdcchCfg=NULLP;
6517 struct ControlResourceSet *controlRSet=NULLP;
6518 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
6520 if(dlBwp->pdcch_Config->choice.setup)
6522 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
6523 if(pdcchCfg->controlResourceSetToAddModList)
6525 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
6526 if(controlRSetList->list.array)
6528 controlRSet = controlRSetList->list.array[arrIdx2];
6531 if(controlRSet->frequencyDomainResources.buf)
6533 if(controlRSet->pdcch_DMRS_ScramblingID)
6535 if(pdcchCfg->searchSpacesToAddModList)
6537 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
6538 free(pdcchCfg->searchSpacesToAddModList);
6540 free(controlRSet->pdcch_DMRS_ScramblingID);
6542 free(controlRSet->frequencyDomainResources.buf);
6545 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
6547 free(controlRSetList->list.array[arrIdx1]);
6549 free(controlRSetList->list.array);
6551 free(pdcchCfg->controlResourceSetToAddModList);
6553 free(dlBwp->pdcch_Config->choice.setup);
6556 /*******************************************************************
6558 * @brief Function to free PdschTimeDomAllocationList
6559 * where the memory allocated by aper_decoder
6563 * Function : freeAperDecodePdschTimeDomAllocationList
6565 * Functionality: Function to free PdschTimeDomAllocationList
6567 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
6570 * ****************************************************************/
6573 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
6577 if(timeDomAllocList->choice.setup)
6579 if(timeDomAllocList->choice.setup->list.array)
6581 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
6583 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
6585 free(timeDomAllocList->choice.setup->list.array);
6587 free(timeDomAllocList->choice.setup);
6591 /*******************************************************************
6593 * @brief Function to free BWPDlDedPdschConfig
6594 * where the memory allocated by aper_decoder
6598 * Function : freeAperDecodeBWPDlDedPdschConfig
6600 * Functionality: Function to free BWPDlDedPdschConfig
6602 * @params[in] BWP_DownlinkDedicated_t *dlBwp
6605 * ****************************************************************/
6608 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
6610 struct PDSCH_Config *pdschCfg=NULLP;
6611 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
6612 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
6613 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
6615 if(dlBwp->pdsch_Config->choice.setup)
6617 pdschCfg=dlBwp->pdsch_Config->choice.setup;
6618 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
6620 if(pdschCfg->pdsch_TimeDomainAllocationList)
6622 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
6623 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
6625 prbBndlType=&pdschCfg->prb_BundlingType;
6626 free(prbBndlType->choice.staticBundling);
6627 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
6629 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
6630 free(pdschCfg->pdsch_TimeDomainAllocationList);
6632 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
6633 if(dmrsDlCfg->choice.setup)
6635 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
6636 free(dmrsDlCfg->choice.setup);
6638 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
6640 free(dlBwp->pdsch_Config->choice.setup);
6643 /*******************************************************************
6645 * @brief Function to free PuschTimeDomAllocListCfg
6646 where the memory allocated by aper_decoder
6650 * Function : freeAperDecodePuschTimeDomAllocListCfg
6652 * Functionality: Function to free PuschTimeDomAllocListCfg
6654 * @params[in] PUSCH_Config_t *puschCfg
6657 * ****************************************************************/
6660 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
6664 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
6666 if(puschCfg->pusch_TimeDomainAllocationList)
6668 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
6669 if(timeDomAllocList_t->choice.setup)
6671 if(timeDomAllocList_t->choice.setup->list.array)
6673 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
6674 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
6676 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
6678 free(timeDomAllocList_t->choice.setup->list.array);
6680 free(timeDomAllocList_t->choice.setup);
6682 free(puschCfg->transformPrecoder);
6683 free(puschCfg->pusch_TimeDomainAllocationList);
6686 /*******************************************************************
6688 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
6692 * Function : freeAperDecodeInitialUlBWPConfig
6694 * Functionality: Function to free InitialUlBWPConfig
6696 * @params[in] BWP_UplinkDedicated_t *ulBwp
6699 * ****************************************************************/
6702 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
6706 SRS_Config_t *srsCfg = NULLP;
6707 PUSCH_Config_t *puschCfg = NULLP;
6708 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
6709 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
6710 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
6711 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
6713 if(ulBwp->pusch_Config)
6715 if(ulBwp->pusch_Config->choice.setup)
6717 puschCfg=ulBwp->pusch_Config->choice.setup;
6718 if(puschCfg->dataScramblingIdentityPUSCH)
6720 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
6722 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
6723 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
6724 if(dmrsUlCfg->choice.setup)
6726 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
6728 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
6730 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
6731 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
6733 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
6735 free(dmrsUlCfg->choice.setup);
6737 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
6739 free(puschCfg->dataScramblingIdentityPUSCH);
6741 free(ulBwp->pusch_Config->choice.setup);
6743 free(ulBwp->pusch_Config);
6745 /* Free SRS-Config */
6746 if(ulBwp->srs_Config)
6748 if(ulBwp->srs_Config->choice.setup)
6750 srsCfg = ulBwp->srs_Config->choice.setup;
6752 /* Free Resource Set to add/mod list */
6753 if(srsCfg->srs_ResourceSetToAddModList)
6755 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
6756 if(rsrcSetList->list.array)
6760 /* Free SRS resource Id list in this SRS resource set */
6761 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
6764 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
6766 if(rsrcIdList->list.array)
6768 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
6771 free(rsrcIdList->list.array[rsrcIdx]);
6773 free(rsrcIdList->list.array);
6775 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
6778 /* Free resource type info for this SRS resource set */
6780 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
6782 /* Free memory for each resource set */
6783 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
6785 free(rsrcSetList->list.array[rSetIdx]);
6787 free(rsrcSetList->list.array);
6789 free(srsCfg->srs_ResourceSetToAddModList);
6792 /* Free resource to add/modd list */
6793 if(srsCfg->srs_ResourceToAddModList)
6795 resourceList = srsCfg->srs_ResourceToAddModList;
6796 if(resourceList->list.array)
6800 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
6801 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
6803 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
6805 free(resourceList->list.array[rsrcIdx]);
6807 free(resourceList->list.array);
6809 free(srsCfg->srs_ResourceToAddModList);
6812 free(ulBwp->srs_Config->choice.setup);
6814 free(ulBwp->srs_Config);
6818 /*******************************************************************
6820 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
6824 * Function : freeAperDecodeinitialUplinkBWPConfig
6826 * Functionality: Function to free initialUplinkBWPConfig
6828 * @params[in] UplinkConfig_t *ulCfg
6831 * ****************************************************************/
6834 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
6836 BWP_UplinkDedicated_t *ulBwp=NULLP;
6837 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
6839 if(ulCfg->initialUplinkBWP)
6841 ulBwp=ulCfg->initialUplinkBWP;
6842 if(ulCfg->firstActiveUplinkBWP_Id)
6844 if(ulCfg->pusch_ServingCellConfig)
6846 puschCfg=ulCfg->pusch_ServingCellConfig;
6847 if(puschCfg->choice.setup)
6849 if(puschCfg->choice.setup->ext1)
6851 free(puschCfg->choice.setup->ext1->processingType2Enabled);
6852 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
6853 free(puschCfg->choice.setup->ext1);
6855 free(puschCfg->choice.setup);
6857 free(ulCfg->pusch_ServingCellConfig);
6859 free(ulCfg->firstActiveUplinkBWP_Id);
6861 freeAperDecodeInitialUlBWPConfig(ulBwp);
6862 free(ulCfg->initialUplinkBWP);
6866 /*******************************************************************
6868 * @brief Function to free DuUeCfg
6872 * Function : freeDuUeCfg
6874 * Functionality: Function to free DuUeCfg
6876 * @params[in] DuUeCfg *ueCfg
6879 * ****************************************************************/
6880 void freeDuUeCfg(DuUeCfg *ueCfg)
6884 SpCellConfig_t *spCellCfg = NULLP;
6885 ServingCellConfig_t *srvCellCfg = NULLP;
6886 BWP_DownlinkDedicated_t *dlBwp = NULLP;
6887 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
6888 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
6889 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
6890 struct RLC_Config *rlcConfig = NULLP;
6891 struct LogicalChannelConfig *macLcConfig = NULLP;
6892 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
6893 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
6894 struct TAG_Config *tagConfig = NULLP;
6895 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
6896 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
6897 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
6898 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
6900 if(ueCfg->ueNrCapability)
6902 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
6903 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
6904 ueCfg->ueNrCapability = NULLP;
6907 if(ueCfg->cellGrpCfg)
6910 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
6913 if(rlcBearerList->list.array)
6915 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
6917 if(rlcBearerList->list.array[arrIdx])
6919 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
6920 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
6922 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
6924 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
6928 if(rlcConfig->choice.am)
6930 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
6931 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
6932 free(rlcConfig->choice.am);
6934 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
6938 if(macLcConfig->ul_SpecificParameters)
6940 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
6941 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
6942 free(macLcConfig->ul_SpecificParameters);
6944 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
6946 free(rlcBearerList->list.array[arrIdx]);
6949 free(rlcBearerList->list.array);
6951 free(cellGrpCfg->rlc_BearerToAddModList);
6954 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
6957 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
6958 if(schedulingRequestConfig)
6960 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
6963 if(schReqList->list.array)
6965 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
6967 if(schReqList->list.array[arrIdx])
6969 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
6970 free(schReqList->list.array[arrIdx]);
6973 free(schReqList->list.array);
6975 free(schedulingRequestConfig->schedulingRequestToAddModList);
6977 free(macCellGrpCfg->schedulingRequestConfig);
6979 if(macCellGrpCfg->bsr_Config)
6981 free(macCellGrpCfg->bsr_Config);
6983 tagConfig = macCellGrpCfg->tag_Config;
6986 tagList = tagConfig->tag_ToAddModList;
6989 if(tagList->list.array)
6991 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
6993 free(tagList->list.array[arrIdx]);
6995 free(tagList->list.array);
6997 free(tagConfig->tag_ToAddModList);
7002 phrConfig = macCellGrpCfg->phr_Config;
7005 free(phrConfig->choice.setup);
7009 free(macCellGrpCfg);
7012 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
7015 free(phyCellGrpCfg->p_NR_FR1);
7016 free(phyCellGrpCfg);
7019 spCellCfg = cellGrpCfg->spCellConfig;
7022 if(spCellCfg->servCellIndex)
7024 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
7026 if(spCellCfg->spCellConfigDedicated)
7028 srvCellCfg = spCellCfg->spCellConfigDedicated;
7029 if(srvCellCfg->initialDownlinkBWP)
7031 dlBwp = srvCellCfg->initialDownlinkBWP;
7032 if(srvCellCfg->firstActiveDownlinkBWP_Id)
7034 if(srvCellCfg->defaultDownlinkBWP_Id)
7036 if(srvCellCfg->uplinkConfig)
7039 if(srvCellCfg->pdsch_ServingCellConfig)
7042 srvCellCfg->pdsch_ServingCellConfig;
7043 if(pdschCfg->choice.setup)
7046 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
7047 free(pdschCfg->choice.setup);
7050 free(srvCellCfg->pdsch_ServingCellConfig);
7053 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
7054 free(srvCellCfg->uplinkConfig);
7056 free(srvCellCfg->defaultDownlinkBWP_Id);
7059 free(srvCellCfg->firstActiveDownlinkBWP_Id);
7061 if(dlBwp->pdcch_Config)
7063 if(dlBwp->pdsch_Config)
7065 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
7066 free(dlBwp->pdsch_Config);
7068 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
7069 free(dlBwp->pdcch_Config);
7071 free(srvCellCfg->initialDownlinkBWP);
7074 free(spCellCfg->spCellConfigDedicated);
7076 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
7078 free(spCellCfg->servCellIndex);
7082 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
7083 ueCfg->cellGrpCfg = NULLP;
7087 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
7089 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
7091 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx]);
7093 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
7095 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
7097 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
7099 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
7103 /*******************************************************************
7105 * @brief Function to free UecontextSetupDb
7109 * Function : freeF1UeDb
7111 * Functionality: Function to free UecontextSetupDb
7113 * @params[in] UecontextSetupDb *
7116 * ****************************************************************/
7118 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
7121 if(f1UeDb->dlRrcMsg)
7123 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
7125 //DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
7126 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
7128 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
7130 freeDuUeCfg(&f1UeDb->duUeCfg);
7131 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
7132 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
7135 /*******************************************************************
7137 * @brief Function to build Am cfg Info
7141 * Function : extractRlcAmCfg
7143 * Functionality: Function to build Am cfg Info
7145 * @params[in] AmBearerCfg *
7148 * @return ROK/RFAILED
7150 * ****************************************************************/
7152 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
7157 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
7159 amCfgToSet->ulAmCfg.snLenUl = *(rlcAmCfg->dl_AM_RLC.sn_FieldLength);
7160 /*TODO: Check the timer value when sent by real CU */
7161 amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly;
7162 amCfgToSet->ulAmCfg.statProhTmr = rlcAmCfg->dl_AM_RLC.t_StatusProhibit;
7166 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
7168 amCfgToSet->dlAmCfg.snLenDl = *(rlcAmCfg->ul_AM_RLC.sn_FieldLength);
7169 amCfgToSet->dlAmCfg.pollRetxTmr = rlcAmCfg->ul_AM_RLC.t_PollRetransmit;
7170 amCfgToSet->dlAmCfg.pollPdu = rlcAmCfg->ul_AM_RLC.pollPDU;
7171 amCfgToSet->dlAmCfg.pollByte = rlcAmCfg->ul_AM_RLC.pollByte;
7172 amCfgToSet->dlAmCfg.maxRetxTh = rlcAmCfg->ul_AM_RLC.maxRetxThreshold;
7177 /*******************************************************************
7179 * @brief Function to build Um Bi Info
7183 * Function : extractRlcUmBiCfg
7185 * Functionality: Function to build Um Bi Info
7187 * @params[in] UmBiDirBearerCfg *
7190 * @return ROK/RFAILED
7192 * ****************************************************************/
7194 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
7198 /* UL UM BI DIR Cfg */
7199 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
7201 umBiCfgToSet->ulUmCfg.snLenUlUm = *(rlcBiCfg->dl_UM_RLC.sn_FieldLength);
7202 umBiCfgToSet->ulUmCfg.reAssemTmr = rlcBiCfg->dl_UM_RLC.t_Reassembly;
7205 /* DL UM BI DIR Cfg */
7206 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
7207 umBiCfgToSet->dlUmCfg.snLenDlUm = *(rlcBiCfg->ul_UM_RLC.sn_FieldLength);
7211 /*******************************************************************
7213 * @brief Function to build Um Ul Info
7217 * Function : extractRlcUmUlCfg
7219 * Functionality: Function to build Um Ul Info
7221 * @params[in] UmUniDirUlBearerCfg *
7224 * @return ROK/RFAILED
7226 * ****************************************************************/
7228 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
7232 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
7234 umUlCfgToSet->ulUmCfg.snLenUlUm = *(umUlCfg->dl_UM_RLC.sn_FieldLength);
7235 umUlCfgToSet->ulUmCfg.reAssemTmr = umUlCfg->dl_UM_RLC.t_Reassembly;
7240 /*******************************************************************
7242 * @brief Function to build Um Uni Dl Info
7246 * Function : extractRlcUmDlCfg
7248 * Functionality: Function to build Um Uni Dl Info
7250 * @params[in] UmUniDirDlBearerCfg *
7253 * @return ROK/RFAILED
7255 * ****************************************************************/
7256 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
7260 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
7261 umDlCfgToSet->dlUmCfg.snLenDlUm = *(umDlCfg->ul_UM_RLC.sn_FieldLength);
7265 /*******************************************************************
7267 * @brief Function to extractRlcModeCfg
7271 * Function : extractRlcModeCfg
7273 * Functionality: Function to extractRlcModeCfg
7275 * @params[in] RLC_Config_t *
7278 * @return ROK/RFAILED
7280 * ****************************************************************/
7281 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
7289 if(lcCfg->choice.am)
7291 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
7292 if(rlcDbCfg->u.amCfg)
7293 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
7297 case RLC_UM_BI_DIRECTIONAL :
7299 if(lcCfg->choice.um_Bi_Directional)
7301 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
7302 if(rlcDbCfg->u.umBiDirCfg)
7303 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
7307 case RLC_UM_UNI_DIRECTIONAL_UL :
7309 if(lcCfg->choice.um_Uni_Directional_DL)
7311 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
7312 if(rlcDbCfg->u.umUniDirUlCfg)
7313 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
7317 case RLC_UM_UNI_DIRECTIONAL_DL :
7319 if(lcCfg->choice.um_Uni_Directional_UL)
7321 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
7322 if(rlcDbCfg->u.umUniDirDlCfg)
7323 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
7328 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
7334 /*******************************************************************
7336 * @brief Function to extract extractUlLcCfg
7340 * Function : extractUlLcCfg
7342 * Functionality: Function to extract extractUlLcCfg
7344 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
7347 * ****************************************************************/
7349 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
7353 if(ulLcCfg->ul_SpecificParameters)
7355 f1UlLcCfg->priority = \
7356 ulLcCfg->ul_SpecificParameters->priority;
7357 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
7359 f1UlLcCfg->lcGroup = \
7360 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
7362 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
7364 f1UlLcCfg->schReqId = \
7365 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
7368 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
7370 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
7375 /*******************************************************************
7377 * @brief Function to procRlcLcCfg
7381 * Function : procRlcLcCfg
7383 * Functionality: Function to procRlcLcCfg
7385 * @params[in] rbId, lcId, rbType, rlcMod
7386 * RLC_Config_t *, RlcBearerCfg * ,
7389 * ****************************************************************/
7391 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
7392 uint8_t configType, RLC_Config_t *f1RlcCfg, RlcBearerCfg *lcCfg)
7396 lcCfg->configType = configType;
7398 if(rbType == RB_TYPE_SRB)
7400 lcCfg->rbType = RB_TYPE_SRB;
7402 lcCfg->lcType = LCH_DCCH;
7403 lcCfg->rlcMode = RLC_AM;
7405 else if(rbType == RB_TYPE_DRB)
7407 lcCfg->rbType = RB_TYPE_DRB;
7409 lcCfg->lcType = LCH_DTCH;
7410 lcCfg->rlcMode = rlcMode;
7412 if(f1RlcCfg) /* rlc mode config recived */
7414 extractRlcModeCfg(lcCfg->rlcMode, lcCfg, f1RlcCfg);
7420 /*******************************************************************
7422 * @brief Fills DrbQos Info received by CU
7426 * Function : extractQosInfo
7428 * Functionality: Fills DrbQos Info received by CU
7430 * @params[in] DrbQosInfo *qosToAdd,
7431 * QoSFlowLevelQoSParameters_t *qosFlowCfg
7434 * ****************************************************************/
7436 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
7438 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
7439 qosToAdd->u.nonDyn5Qi.fiveQi =\
7440 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
7441 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
7443 qosToAdd->u.nonDyn5Qi.avgWindow = \
7444 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
7446 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
7447 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
7448 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
7450 qosToAdd->u.nonDyn5Qi.priorLevel = \
7451 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
7453 qosToAdd->ngRanRetPri.priorityLevel = \
7454 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
7455 qosToAdd->ngRanRetPri.preEmptionCap = \
7456 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
7457 qosToAdd->ngRanRetPri.preEmptionVul = \
7458 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
7459 if(qosFlowCfg->gBR_QoS_Flow_Information)
7461 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
7462 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
7463 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
7464 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
7465 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
7466 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
7467 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
7468 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
7469 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
7470 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
7471 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
7472 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
7474 qosToAdd->pduSessionId = 0;
7475 qosToAdd->ulPduSessAggMaxBitRate = 0;
7478 /*******************************************************************
7480 * @brief Function to extract GTP Tunnel Info from CU
7484 * Function : extractUpTnlInfo
7486 * Functionality: Function to extract GTP Tunnel Info from CU
7488 * @params[in] F1AP message
7489 * @return ROK/RFAILED
7491 * ****************************************************************/
7493 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
7494 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
7497 uint32_t ipv4_du = 0;
7498 GTPTunnel_t *gtpTunnel = NULLP;
7500 upTnlInfo->drbId = drbId;
7501 upTnlInfo->configType = configType;
7503 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
7505 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
7508 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
7510 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
7512 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
7514 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
7515 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
7516 if(upTnlInfo->tnlCfg1 == NULLP)
7518 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
7521 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
7522 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
7523 if(gtpTunnel->gTP_TEID.size > 0)
7525 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
7533 /*******************************************************************
7535 * @brief Function to extract Drb Qos Cfg Info from CU
7539 * Function : extractDrbQosCfg
7541 * Functionality: Function to extract Drb Qos Cfg Info from CU
7543 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
7544 * @return ROK/RFAILED
7546 * ****************************************************************/
7548 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
7550 if(!macLcToAdd->drbQos)
7552 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
7553 if(macLcToAdd->drbQos == NULLP)
7555 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbQosCfg()");
7560 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
7562 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
7563 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
7565 if(!macLcToAdd->snssai)
7567 DU_ALLOC_SHRABL_BUF(macLcToAdd->snssai, sizeof(Snssai));
7568 if(macLcToAdd->snssai == NULLP)
7570 DU_LOG("\nERROR --> DUAPP : Memory failed at allocating SNSSAI at extractDrbQosCfg()");
7574 memcpy(&macLcToAdd->snssai->sst, drbInfo->sNSSAI.sST.buf, \
7575 drbInfo->sNSSAI.sST.size);
7576 if(drbInfo->sNSSAI.sD)
7578 memcpy(macLcToAdd->snssai->sd, drbInfo->sNSSAI.sD->buf, \
7579 drbInfo->sNSSAI.sD->size);
7583 /*******************************************************************
7585 * @brief Function to extract DRB info received from CU
7589 * Function : extractDrbCfg
7591 * Functionality: Function to extract DRB info received from CU
7593 * @params[in] F1AP message
7596 * ****************************************************************/
7597 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
7598 DRBs_ToBeModified_Item_t *drbModItem, LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
7600 DRB_Information_t *drbInfo = NULLP;
7602 if(drbItem != NULLP)
7604 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
7606 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7609 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7611 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
7613 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7614 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7616 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7622 else if(drbSetupModItem != NULLP)
7624 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
7627 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7630 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7632 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
7633 QoSInformation_ExtIEs__value_PR_DRB_Information)
7635 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7636 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7638 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7645 else if(drbModItem != NULLP)
7647 if(extractUpTnlInfo(drbModItem->dRBID, CONFIG_MOD, &drbModItem->uLUPTNLInformation_ToBeSetup_List,\
7650 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7653 if(drbModItem->qoSInformation != NULLP)
7655 if(drbModItem->qoSInformation->present == QoSInformation_PR_choice_extension)
7657 if(drbModItem->qoSInformation->choice.choice_extension->value.present ==\
7658 QoSInformation_ExtIEs__value_PR_DRB_Information)
7660 drbInfo = &drbModItem->qoSInformation->choice.choice_extension->value.choice.DRB_Information;
7661 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7663 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7674 /*******************************************************************
7676 * @brief Function to extract RB info received from CU
7680 * Function : extractMacRbCfg
7682 * Functionality: Function to extract RB info received from CU
7684 * @params[in] F1AP message
7685 * @return ROK/RFAILED
7687 * ****************************************************************/
7689 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
7690 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, DRBs_ToBeModified_Item_t *drbModCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7694 if(extractDrbCfg(drbCfg, NULL, NULL, lcCfg, upTnlInfo) != ROK)
7696 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7700 else if(drbSetupModCfg != NULLP)
7702 if(extractDrbCfg(NULL, drbSetupModCfg, NULL, lcCfg, upTnlInfo) != ROK)
7704 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7708 else if(drbModCfg != NULLP)
7710 if(extractDrbCfg(NULL, NULL, drbModCfg, lcCfg, upTnlInfo) != ROK)
7712 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7718 lcCfg->drbQos = NULLP;
7719 lcCfg->snssai = NULLP;
7720 if(lcCfg->lcId == SRB2_LCID)
7721 lcCfg->dlLcCfg.lcp = LC_PRIORITY_3;
7723 lcCfg->dlLcCfg.lcp = LC_PRIORITY_1;
7727 lcCfg->ulLcCfgPres = true;
7728 extractUlLcCfg(&lcCfg->ulLcCfg, ulLcCfg);
7731 lcCfg->ulLcCfgPres = false;
7735 /*******************************************************************
7737 * @brief Function processing LC config info received from CU
7741 * Function : procMacLcCfg
7743 * Functionality: Function processing LC config info received from CU
7745 * @params[in] F1AP message
7746 * @return ROK/RFAILED
7748 * ****************************************************************/
7750 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType, DRBs_ToBeSetup_Item_t *drbItem,\
7751 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem, LogicalChannelConfig_t *ulLcCfg,\
7752 LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7757 lcCfg->configType = configType;
7758 if(rbType == RB_TYPE_SRB)
7760 ret = extractMacRbCfg(lcId, NULL, NULL, NULL, ulLcCfg, lcCfg, NULL);
7762 else if(rbType == RB_TYPE_DRB)
7765 ret = extractMacRbCfg(lcId, drbItem, NULL, NULL, ulLcCfg, lcCfg, upTnlInfo);
7766 else if(drbSetupModItem != NULL)
7767 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
7768 else if(drbModItem != NULL)
7769 ret = extractMacRbCfg(lcId, NULL, NULL, drbModItem, ulLcCfg, lcCfg, upTnlInfo);
7774 /*******************************************************************
7776 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
7780 * Function : extractRlcCfgToAddMod
7782 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
7784 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
7786 * @return ROK/RFAILED
7788 * ****************************************************************/
7790 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
7792 uint8_t idx, rbId, lcId, rlcMode, rbType;
7793 RLC_Config_t *f1RlcCfg = NULLP;
7794 LogicalChannelConfig_t *macUlLcCfg = NULLP;
7796 for(idx = 0; idx < lcCfg->list.count; idx++)
7798 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
7799 if(lcCfg->list.array[idx]->servedRadioBearer)
7801 /* RadioBearer for SRB/DRB */
7802 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7803 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
7805 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
7806 rbType = RB_TYPE_SRB;
7808 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7809 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
7811 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
7812 rbType = RB_TYPE_DRB;
7816 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
7819 /* MAC UL LC Config */
7820 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
7822 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
7827 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
7830 /* RLC Mode Config */
7831 if(lcCfg->list.array[idx]->rlc_Config)
7833 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
7834 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
7837 /* Filling RLC/MAC Config*/
7838 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
7839 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
7840 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]));
7841 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
7843 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
7846 (ueCfgDb->numRlcLcs)++;
7847 (ueCfgDb->numMacLcs)++;
7848 DU_LOG("\nDEBUG -> DUAPP: extractRlcCfgToAddMod:RBType:%d, DrbID: %d,lcId:%d, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
7849 rbType, rbId, lcId, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
7851 //TODO: To send the failure cause in UeContextSetupRsp
7855 /*******************************************************************
7857 * @brief DeAlloc pdsch serv cell config info
7861 * Function : freeMacPdschServCellInfo
7863 * Functionality: DeAlloc pdsch serv cell config info
7865 * @params[in] PdschServCellCfg pointer
7868 * ****************************************************************/
7870 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
7872 if(pdsch->xOverhead)
7874 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
7876 if(pdsch->codeBlkGrpFlushInd)
7878 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
7880 if(pdsch->maxCodeBlkGrpPerTb)
7882 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
7884 if(pdsch->maxMimoLayers)
7886 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
7890 /*******************************************************************
7892 * @brief Free Serving cell Info
7896 * Function : freeMacServingCellInfo
7898 * Functionality: Free Serving cell Info
7900 * @params[in] ServCellCfgInfo *srvCellCfg
7903 * ****************************************************************/
7904 void freeMacServingCellInfo(ServCellCfgInfo *srvCellCfg)
7906 uint8_t timeDomRsrcIdx;
7908 if(srvCellCfg->initDlBwp.pdschPresent)
7910 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < srvCellCfg->initDlBwp.pdschCfg.numTimeDomRsrcAlloc; timeDomRsrcIdx++)
7912 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, \
7913 srvCellCfg->initDlBwp.pdschCfg.timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
7917 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
7918 if(srvCellCfg->bwpInactivityTmr)
7920 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
7923 if(srvCellCfg->initUlBwp.pucchPresent)
7925 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->initUlBwp.pucchCfg.dlDataToUlAck, sizeof(PucchDlDataToUlAck));
7929 /*******************************************************************
7931 * @brief Free cell Grp Cfg Info
7935 * Function : freeUeReCfgCellGrpInfo
7937 * Functionality: Free cell Grp Cfg Info
7939 * @params[in] MacUeCfg* duUeCfg
7942 * ****************************************************************/
7944 void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg)
7946 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
7949 /*******************************************************************
7951 * @brief Fills Reconfig SchReqReConfig
7955 * Function : extractSchReqReConfig
7957 * Functionality: Fills Reconfig SchReqReConfig
7959 * @params[in] SchedulingRequestConfig_t *cuSchedReq
7960 * SchedReqCfg* macSchedReq
7963 * ****************************************************************/
7964 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
7966 uint8_t schReqIdx = 0;
7967 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
7968 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
7970 if(cuSchedReq->schedulingRequestToAddModList)
7972 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
7973 if(schReqListToAdd->list.count)
7975 macSchedReq->addModListCount = schReqListToAdd->list.count;
7976 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
7978 macSchedReq->addModList[schReqIdx].schedReqId = \
7979 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
7980 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
7981 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
7982 macSchedReq->addModList[schReqIdx].srTransMax =\
7983 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
7987 /* Scheduling Req To release */
7988 if(cuSchedReq->schedulingRequestToReleaseList)
7990 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
7991 if(schReqListToRel->list.count)
7993 macSchedReq->relListCount = schReqListToRel->list.count;
7994 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
7996 macSchedReq->relList[schReqIdx] = \
7997 *schReqListToRel->list.array[schReqIdx];
8003 /*******************************************************************
8005 * @brief Fills TagReconfig
8009 * Function : extractTagReconfig
8011 * Functionality: Fills extractTagReconfig
8013 * @params[in] TAG_Config_t *cuTagCfg
8017 * ****************************************************************/
8019 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
8022 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
8023 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
8025 /* Tag config to AddMod */
8026 if(cuTagCfg->tag_ToAddModList)
8028 tagListToAddMod = cuTagCfg->tag_ToAddModList;
8029 if(tagListToAddMod->list.count)
8031 macTagCfg->addModListCount = tagListToAddMod->list.count;
8032 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
8034 macTagCfg->addModList[tagIdx].tagId =\
8035 tagListToAddMod->list.array[tagIdx]->tag_Id;
8036 macTagCfg->addModList[tagIdx].timeAlignTimer = \
8038 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
8042 /* Tag config to release */
8043 if(cuTagCfg->tag_ToReleaseList)
8045 tagListToRel = cuTagCfg->tag_ToReleaseList;
8046 if(tagListToRel->list.count)
8048 macTagCfg->relListCount = tagListToRel->list.count;
8049 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
8051 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
8057 /*******************************************************************
8059 * @brief Fills PdcchCfg received by CU
8063 * Function : extractPdcchCfg
8065 * Functionality: Fills PdcchCfg received by CU
8067 * @params[in] PDCCH_Config_t *cuPdcchCfg,
8068 * PdcchConfig *duPdcchCfg
8071 * ****************************************************************/
8073 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
8075 uint8_t cRsetIdx = 0;
8076 uint8_t srchSpcIdx = 0;
8078 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
8079 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
8080 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
8081 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
8084 /* Control Resource Set To Add/Mod List */
8085 if(cuPdcchCfg->controlResourceSetToAddModList)
8087 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
8088 if(cRsetToAddModList->list.count)
8090 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
8091 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
8093 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
8094 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
8095 bitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
8096 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
8097 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
8098 cRsetToAddModList->list.array[cRsetIdx]->duration;
8100 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
8101 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
8102 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
8104 //TODO: handle the case for Interleaved
8106 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
8107 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
8108 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
8110 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
8111 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
8117 /* Control Resource Set To Release List */
8118 if(cuPdcchCfg->controlResourceSetToReleaseList)
8120 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
8121 if(cRsetToRelList->list.count)
8123 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
8124 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
8126 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
8131 /* Search space To Add/Mod List */
8132 if(cuPdcchCfg->searchSpacesToAddModList)
8134 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
8135 if(srchSpcToAddModList->list.count)
8137 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
8138 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
8140 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
8141 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
8142 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
8143 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
8144 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
8146 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
8147 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
8149 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
8151 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
8152 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
8154 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
8156 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
8157 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
8158 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
8159 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
8160 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
8161 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
8163 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
8164 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
8166 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
8167 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
8169 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
8171 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
8172 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
8173 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
8175 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
8176 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
8183 /* Search space To Rel List */
8184 if(cuPdcchCfg->searchSpacesToReleaseList)
8186 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
8187 if(srchSpcToRelList->list.count)
8189 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
8190 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
8192 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
8193 *(srchSpcToRelList->list.array[srchSpcIdx]);
8199 /*******************************************************************
8201 * @brief Fills PdschCfg received by CU
8205 * Function : extractPdschCfg
8207 * Functionality: Fills PdschCfg received by CU
8209 * @params[in] PDSCH_Config_t *cuPdschCfg = Information which is send by CU,
8210 * which we have stored in F1UeContextSetupDb,
8211 * PdschConfig *macPdschCfg = Used to Store the information which
8212 * needs to send in other layer, as well as this can be the variable
8213 * which stores the information in DuCb,
8214 * PdschConfig *storedPdschCfg = Null in case of sending the
8215 * information to other layer else it will have stored pdsch
8216 * configuration in copyOfmacUeCfg.
8219 * ****************************************************************/
8221 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg, PdschConfig *storedPdschCfg)
8224 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
8226 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
8228 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
8229 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
8231 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
8233 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
8234 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
8238 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
8239 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
8241 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
8242 if(timeDomAlloc->present ==\
8243 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
8245 if(timeDomAlloc->choice.setup)
8247 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
8248 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
8250 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 = NULLP;
8251 if(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0)
8253 if(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 == NULL)
8257 if(storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
8259 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 =\
8260 storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0;
8264 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
8269 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
8271 if(!macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
8273 DU_LOG("\nERROR --> DU APP : Memory allocation failed for k0 at extractPdschCfg()");
8277 *(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0) = \
8278 *(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0);
8280 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
8281 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
8282 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
8283 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8288 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
8289 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
8290 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
8291 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
8293 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8294 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
8296 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
8298 macPdschCfg->bundlingInfo.StaticBundling.size = \
8299 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
8303 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
8305 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8310 /*******************************************************************
8312 * @brief Fills PdschServingCellCfg received by CU
8316 * Function : extractPdschServingCellCfg
8318 * Functionality: Fills PdschCfg received by CU
8320 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
8321 * PdschServCellCfg *macUePdschSrvCellCfg
8322 * @return ROK/RFAILED
8324 * ****************************************************************/
8326 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
8328 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
8330 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
8332 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8334 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8335 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8339 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
8340 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8342 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8343 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8347 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
8351 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8353 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8354 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8358 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
8359 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8361 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8362 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8366 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
8372 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
8374 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
8376 if(cuPdschSrvCellCfg->ext1)
8378 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
8380 if(macUePdschSrvCellCfg->maxMimoLayers)
8382 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8386 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
8387 if(macUePdschSrvCellCfg->maxMimoLayers)
8389 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8393 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
8399 if(cuPdschSrvCellCfg->xOverhead)
8401 if(macUePdschSrvCellCfg->xOverhead)
8403 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8407 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
8408 if(macUePdschSrvCellCfg->xOverhead)
8410 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8414 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
8422 /*******************************************************************
8424 * @brief Fills PuschCfg received by CU
8428 * Function : extractPuschCfg
8430 * Functionality: Fills PuschCfg received by CU
8432 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
8433 * PuschCfg *macPuschCfg
8436 * ****************************************************************/
8438 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
8440 uint8_t timeDomIdx = 0;
8441 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
8442 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
8444 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
8446 if(cuPuschCfg->choice.setup)
8448 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
8450 macPuschCfg->dataScramblingId = \
8451 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
8453 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
8455 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
8457 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
8459 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
8460 if(dmrsUlCfg->dmrs_AdditionalPosition)
8462 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
8463 *(dmrsUlCfg->dmrs_AdditionalPosition);
8465 if(dmrsUlCfg->transformPrecodingDisabled)
8467 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
8469 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
8470 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
8476 /*Res Alloc Type for UL */
8477 if(cuPuschCfg->choice.setup->resourceAllocation)
8479 macPuschCfg->resourceAllocType = \
8480 cuPuschCfg->choice.setup->resourceAllocation;
8482 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
8484 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
8485 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
8487 if(timeDomAllocList->choice.setup)
8489 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
8490 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
8492 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
8493 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
8494 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
8495 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
8496 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
8497 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8502 if(cuPuschCfg->choice.setup->transformPrecoder)
8503 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
8508 /*******************************************************************
8510 * @brief Function to fill pucch Power Control
8514 * Function : extractPucchPowerControl
8516 * Functionality: Function to fill pucch Power Control
8518 * @params[in] PucchPowerControl *pwrCtrl,
8519 * struct PUCCH_PowerControl *cuPwrCtrlCfg
8522 * ****************************************************************/
8524 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
8528 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
8529 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
8530 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
8531 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
8532 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
8533 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
8534 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
8535 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
8536 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
8537 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
8538 if(cuPwrCtrlCfg->p0_Set)
8540 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
8541 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
8543 pwrCtrl->p0Set[arrIdx].p0PucchId =\
8544 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
8545 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
8546 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
8549 if(cuPwrCtrlCfg->pathlossReferenceRSs)
8551 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
8552 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
8554 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
8555 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
8560 /*******************************************************************
8562 * @brief Function to extractResrcSetToAddModList sent by CU
8566 * Function : extractResrcSetToAddModList
8568 * Functionality: Fucntion to extractResrcSetToAddModList
8570 * @params[in] PucchResrcSetCfg pointer,
8571 * struct PUCCH_Config__resourceSetToAddModList pointer
8574 * ****************************************************************/
8576 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
8578 uint8_t arrIdx, rsrcListIdx;
8580 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
8581 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
8583 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
8584 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
8585 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
8586 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
8587 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
8589 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
8590 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
8592 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
8593 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
8595 }/* End of extractResrcSetToAddModList */
8597 /*******************************************************************
8599 * @brief Fills extractResrcToAddModList sent by CU
8603 * Function : extractResrcToAddModList
8605 * Functionality: Fills extractResrcToAddModList
8607 * @params[in] PucchResrcCfg pointer,
8608 * struct PUCCH_Config__resourceToAddModList pointer
8609 * @return ROk/RFAILED
8611 * ****************************************************************/
8613 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
8617 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
8618 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
8620 macResrcList->resrcToAddModList[arrIdx].resrcId =\
8621 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
8622 macResrcList->resrcToAddModList[arrIdx].startPrb =\
8623 cuResrcList->list.array[arrIdx]->startingPRB;
8624 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
8626 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
8627 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
8629 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
8631 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
8632 *cuResrcList->list.array[arrIdx]->secondHopPRB;
8634 /* PUCCH RSRC FORMAT */
8635 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
8637 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
8638 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
8640 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
8641 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
8643 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
8646 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
8647 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
8648 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
8649 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
8650 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
8651 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
8654 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
8656 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
8657 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
8659 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
8660 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
8662 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
8665 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
8666 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
8667 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
8668 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
8669 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
8670 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
8671 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
8672 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
8675 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
8677 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
8678 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
8680 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
8681 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
8683 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
8686 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
8687 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
8688 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
8689 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
8690 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
8691 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
8694 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
8696 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
8697 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
8699 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
8700 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
8702 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
8705 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
8706 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
8707 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
8708 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
8709 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
8710 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
8713 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
8715 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
8716 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
8718 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
8719 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
8721 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
8724 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
8725 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
8726 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
8727 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
8728 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
8729 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
8730 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
8731 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
8737 }/* End of extractResrcToAddModList */
8739 /*******************************************************************
8741 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
8745 * Function : fillPucchSchedReqPeriodAndOffset
8747 * Functionality: To fillPucchSchedReqPeriodAndOffset
8749 * @params[in] macPeriodicty,
8750 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
8753 * ****************************************************************/
8755 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
8756 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
8758 macPeriodicty = cuPeriodicty->present;
8759 switch(macPeriodicty)
8761 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
8763 macOffset = cuPeriodicty->choice.sym2;
8766 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
8768 macOffset = cuPeriodicty->choice.sym6or7;
8771 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
8773 macOffset = cuPeriodicty->choice.sl1;
8776 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
8778 macOffset = cuPeriodicty->choice.sl2;
8781 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
8783 macOffset = cuPeriodicty->choice.sl4;
8786 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
8788 macOffset = cuPeriodicty->choice.sl5;
8791 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
8793 macOffset = cuPeriodicty->choice.sl8;
8796 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
8798 macOffset = cuPeriodicty->choice.sl10;
8801 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
8803 macOffset = cuPeriodicty->choice.sl16;
8806 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
8808 macOffset = cuPeriodicty->choice.sl20;
8811 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
8813 macOffset = cuPeriodicty->choice.sl40;
8816 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
8818 macOffset = cuPeriodicty->choice.sl80;
8821 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
8823 macOffset = cuPeriodicty->choice.sl160;
8826 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
8828 macOffset = cuPeriodicty->choice.sl320;
8831 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
8833 macOffset = cuPeriodicty->choice.sl640;
8837 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
8841 /*******************************************************************
8843 * @brief Function to extractPucchFormatCfg sent by CU
8847 * Function : extractPucchFormatCfg
8849 * Functionality: Function to extractPucchFormatCfg
8851 * @params[in] PucchFormatCfg pointer,
8852 * PUCCH_FormatConfig_t pointer
8855 * ****************************************************************/
8857 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
8859 if(cuFormatCfg->interslotFrequencyHopping)
8860 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
8861 if(cuFormatCfg->additionalDMRS)
8862 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
8863 if(cuFormatCfg->maxCodeRate)
8864 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
8865 if(cuFormatCfg->nrofSlots)
8866 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
8867 if(cuFormatCfg->pi2BPSK)
8868 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
8869 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
8870 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
8871 }/* End of extractPucchFormatCfg */
8873 /*******************************************************************
8875 * @brief Function to extractSchedReqCfgToAddMod sent by CU
8879 * Function : extractSchedReqCfgToAddMod
8881 * Functionality: Function to extractSchedReqCfgToAddMod
8883 * @params[in] PucchSchedReqCfg pointer,
8884 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
8887 * ****************************************************************/
8889 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
8893 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
8894 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
8896 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
8897 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
8898 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
8899 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
8900 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
8902 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
8903 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
8905 if(cuSchedReqList->list.array[arrIdx]->resource)
8907 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
8908 *cuSchedReqList->list.array[arrIdx]->resource;
8912 }/* End of extractSchedReqCfgToAddMod */
8914 /*******************************************************************
8916 * @brief Fills PucchCfg received by CU
8920 * Function : extractPucchCfg
8922 * Functionality: Fills PucchCfg received by CU
8924 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg = Information which
8925 * is send by CU, which we have stored in F1UeContextSetupDb,
8926 * PucchCfg *macPucchCfg = Used to Store the information which
8927 * needs to send in other layer, as well as this can be the variable
8928 * which stores the information in DuCb,
8929 * PucchCfg *storedPucchCfg = Null in case of sending the
8930 * information to other layer else it will have Pucch Cfg which
8931 * we have stored in copyOfmacUeCfg.
8932 * @return ROK/RFAILED
8934 * ****************************************************************/
8936 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg,\
8937 PucchCfg *storedPucchCfg)
8941 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
8943 if(cuPucchCfg->choice.setup)
8945 /* Resource Set Cfg */
8946 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
8948 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
8949 if(macPucchCfg->resrcSet == NULLP)
8951 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
8954 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
8955 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
8959 if(cuPucchCfg->choice.setup->resourceToAddModList)
8961 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
8962 if(macPucchCfg->resrc == NULLP)
8964 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
8967 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
8968 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
8972 if(cuPucchCfg->choice.setup->format1)
8974 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
8975 if(macPucchCfg->format1 == NULLP)
8977 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
8980 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
8981 extractPucchFormatCfg(macPucchCfg->format1,\
8982 cuPucchCfg->choice.setup->format1->choice.setup);
8986 if(cuPucchCfg->choice.setup->format2)
8988 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
8989 if(macPucchCfg->format2 == NULLP)
8991 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
8994 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
8995 extractPucchFormatCfg(macPucchCfg->format2,\
8996 cuPucchCfg->choice.setup->format2->choice.setup);
9000 if(cuPucchCfg->choice.setup->format3)
9002 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
9003 if(macPucchCfg->format3 == NULLP)
9005 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
9008 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
9009 extractPucchFormatCfg(macPucchCfg->format3,\
9010 cuPucchCfg->choice.setup->format3->choice.setup);
9014 if(cuPucchCfg->choice.setup->format4)
9016 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
9017 if(macPucchCfg->format4 == NULLP)
9019 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
9022 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
9023 extractPucchFormatCfg(macPucchCfg->format4,\
9024 cuPucchCfg->choice.setup->format4->choice.setup);
9027 /* Sched Req List */
9028 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
9030 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
9031 if(macPucchCfg->schedReq == NULLP)
9033 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
9036 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
9037 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
9038 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
9041 /*TODO: Add support for Spatial Info */
9044 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
9046 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
9047 if(macPucchCfg->multiCsiCfg == NULLP)
9049 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
9052 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
9053 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
9054 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
9056 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
9057 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
9061 /* Dl_DataToUL_ACK */
9062 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
9066 if(storedPucchCfg->dlDataToUlAck)
9068 macPucchCfg->dlDataToUlAck = storedPucchCfg->dlDataToUlAck;
9072 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
9077 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
9079 if(macPucchCfg->dlDataToUlAck == NULLP)
9081 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
9084 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
9085 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
9086 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
9088 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
9089 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
9094 if(cuPucchCfg->choice.setup->pucch_PowerControl)
9096 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
9097 if(macPucchCfg->powerControl == NULLP)
9099 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
9102 extractPucchPowerControl(macPucchCfg->powerControl,\
9103 cuPucchCfg->choice.setup->pucch_PowerControl);
9110 /*******************************************************************
9112 * @brief Fills ServingCellReconfig received by CU
9116 * Function : extractSpCellDedicatedCfg
9118 * Functionality: Fills ServingCellReconfig received by CU
9120 * @params[in] ServingCellConfig_t *cuSrvCellCfg = Information which is send by
9121 * CU, which we have stored in F1UeContextSetupDb,
9122 * ServCellCfgInfo *macSrvCellCfg = Used to Store the information
9123 * which needs to send in other layer, as well as this can be the
9124 * variable which stores the information in DuCb,
9125 * ServCellCfgInfo *storedSrvCellCfg = Null in case of sending the
9126 * information to other layer else it will have ServCellCfgInfo which
9127 * we have stored in copyOfmacUeCfg.
9128 * @return ROK/RFAILD
9130 * ****************************************************************/
9131 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellCfgInfo *macSrvCellCfg,\
9132 ServCellCfgInfo *storedSrvCellCfg)
9135 BWP_DownlinkDedicated_t *dlBwp = NULLP;
9136 BWP_UplinkDedicated_t *ulBwp = NULLP;
9138 if(cuSrvCellCfg->initialDownlinkBWP)
9140 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
9141 if(dlBwp->pdcch_Config)
9143 if(dlBwp->pdcch_Config->choice.setup)
9145 macSrvCellCfg->initDlBwp.pdcchPresent = true;
9146 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
9149 if(dlBwp->pdsch_Config)
9151 if(dlBwp->pdsch_Config->choice.setup)
9153 macSrvCellCfg->initDlBwp.pdschPresent = true;
9155 if(storedSrvCellCfg)
9157 if(!storedSrvCellCfg->initDlBwp.pdschPresent)
9159 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
9163 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg,\
9164 &storedSrvCellCfg->initDlBwp.pdschCfg);
9169 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
9174 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
9175 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
9176 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
9177 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
9178 if(cuSrvCellCfg->bwp_InactivityTimer)
9180 if(macSrvCellCfg->bwpInactivityTmr)
9182 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9186 macSrvCellCfg->bwpInactivityTmr = NULLP;
9187 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
9188 if(macSrvCellCfg->bwpInactivityTmr)
9190 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9194 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
9199 if(cuSrvCellCfg->pdsch_ServingCellConfig)
9201 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
9203 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
9206 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
9211 if(cuSrvCellCfg->uplinkConfig)
9213 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
9215 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
9216 if(ulBwp->pusch_Config)
9218 macSrvCellCfg->initUlBwp.puschPresent = true;
9219 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
9221 if(ulBwp->pucch_Config)
9223 macSrvCellCfg->initUlBwp.pucchPresent = true;
9224 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
9225 if(storedSrvCellCfg)
9227 if(!storedSrvCellCfg->initUlBwp.pucchPresent)
9228 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
9230 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg,\
9231 &storedSrvCellCfg->initUlBwp.pucchCfg);
9235 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
9239 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
9240 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
9244 /*******************************************************************
9246 * @brief Fills Reconfig Cell group Info received by CU
9250 * Function : extractUeReCfgCellInfo
9252 * Functionality: Fills Reconfig Cell group Info received by CU
9254 * @params[in] CellGroupConfigRrc_t *cellGrp = CellGroupConfigRrc_t information which
9255 * is send by CU, which we have stored in F1UeContextSetupDb
9256 * MacUeCfg *MacUeCfg = Used to Store the information,
9257 * which needs to send in other layer, as well as this can be
9258 * the variable which stores the information in DuCb,
9259 * MacUeCfg *storedMacUeCfg = Null in case of sending the
9260 * information to other layer else it will have copyOfmacUeCfg
9261 * which we have stored in F1UeContextSetupDb.
9263 * @return ROK/RFAILED
9265 * ****************************************************************/
9266 uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg, MacUeCfg *storedMacUeCfg)
9269 MAC_CellGroupConfig_t *macCellGroup = NULLP;
9270 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
9271 SpCellConfig_t *spcellCfg = NULLP;
9272 ServingCellConfig_t *servCellCfg = NULLP;
9276 /* Fill MacCell Group Reconfig */
9277 if(cellGrp->mac_CellGroupConfig)
9279 macUeCfg->macCellGrpCfgPres = true;
9280 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
9281 if(macCellGroup->schedulingRequestConfig)
9283 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
9285 if(macCellGroup->tag_Config)
9287 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
9289 if(macCellGroup->bsr_Config)
9291 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
9292 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
9293 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
9295 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
9296 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
9299 if(macCellGroup->phr_Config)
9301 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
9303 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
9304 if(macCellGroup->phr_Config->choice.setup)
9306 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
9307 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
9308 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
9309 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
9310 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
9311 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
9312 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
9313 macCellGroup->phr_Config->choice.setup->multiplePHR;
9314 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
9315 macCellGroup->phr_Config->choice.setup->dummy;
9316 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
9317 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
9318 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
9319 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
9324 /* Fill Physical Cell Group Reconfig */
9325 if(cellGrp->physicalCellGroupConfig)
9327 macUeCfg->phyCellGrpCfgPres = true;
9328 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
9329 if(phyCellGrpCfg->p_NR_FR1)
9331 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
9332 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
9334 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
9336 /* Fill SpCell Reconfig */
9337 if(cellGrp->spCellConfig)
9339 macUeCfg->spCellCfgPres = true;
9340 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
9341 if(spcellCfg->servCellIndex)
9343 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
9345 /* Fill Serving cell Reconfig info */
9346 if(cellGrp->spCellConfig->spCellConfigDedicated)
9348 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
9351 if(!storedMacUeCfg->spCellCfgPres)
9352 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
9354 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg,\
9355 &storedMacUeCfg->spCellCfg.servCellCfg);
9359 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
9363 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
9370 /*******************************************************************
9372 * @brief free the memory allocated by decoder
9376 * Function : freeAperDecodeNrcgi
9378 * Functionality: Free Nrcgi values
9380 * @params[in] NRCGI_t *nrcgi
9383 * ****************************************************************/
9386 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
9388 if(nrcgi->pLMN_Identity.buf != NULLP)
9390 free(nrcgi->pLMN_Identity.buf);
9392 if(nrcgi->nRCellIdentity.buf != NULLP)
9394 free(nrcgi->nRCellIdentity.buf);
9397 /*******************************************************************
9399 * @brief free the memory allocated by decoder
9403 * Function : freeAperDecodeCuToDuInfo
9405 * Functionality: Free Cu To Du Information
9407 * @params[in] CUtoDURRCInformation_t *rrcMsg
9410 * ****************************************************************/
9413 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
9418 if(rrcMsg->uE_CapabilityRAT_ContainerList)
9420 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
9421 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
9422 free(rrcMsg->uE_CapabilityRAT_ContainerList);
9425 if(rrcMsg->iE_Extensions)
9427 if(rrcMsg->iE_Extensions->list.array)
9429 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
9431 if(rrcMsg->iE_Extensions->list.array[ieIdx])
9433 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
9435 case ProtocolIE_ID_id_CellGroupConfig:
9436 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
9438 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
9442 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
9443 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
9448 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
9450 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
9452 free(rrcMsg->iE_Extensions->list.array);
9456 free(rrcMsg->iE_Extensions);
9459 /*******************************************************************
9461 * @brief free the memory allocated by decoder
9465 * Function : freeAperDecodeSplCellList
9467 * Functionality: Free Spl Cell List
9468 where memory allocated by aper_decoder
9470 * @params[in] SCell_ToBeSetup_List_t *spCellLst
9473 * ****************************************************************/
9476 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
9480 if(spCellLst->list.array != NULLP)
9482 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
9484 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
9486 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
9488 if(spCellLst->list.array[cellIdx]!=NULLP)
9490 free(spCellLst->list.array[cellIdx]);
9493 free(spCellLst->list.array);
9496 /*******************************************************************
9498 * @brief free the memory allocated by decoder
9502 * Function : freeAperDecodeSRBSetup
9504 * Functionality: added free part for the memory allocated by aper_decoder
9506 * @params[in] SRBs_ToBeSetup_List_t *srbSet
9509 ****************************************************************/
9512 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
9515 if(srbSet->list.array != NULLP)
9517 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
9519 if(srbSet->list.array[srbIdx]!=NULLP)
9521 free(srbSet->list.array[srbIdx]);
9524 free(srbSet->list.array);
9528 /*******************************************************************
9530 * @brief free the memory allocated by decoder
9534 * Function : freeAperDecodeULTnlInfo
9536 * Functionality: added free part for the memory allocated by aper_decoder
9538 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
9541 * ****************************************************************/
9544 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
9547 if(ulInfo->list.array != NULLP)
9549 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
9551 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
9553 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
9555 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9556 transportLayerAddress.buf != NULLP)
9558 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
9561 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
9563 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9564 transportLayerAddress.buf);
9566 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
9569 if(ulInfo->list.array[ulIdx]!=NULLP)
9571 free(ulInfo->list.array[ulIdx]);
9574 free(ulInfo->list.array);
9577 /*******************************************************************
9579 * @brief free the memory allocated by decoder
9583 * Function : freeAperDecodeDRBSetup
9585 * Functionality: free DRBSetup which is allocated by decoder
9587 * @params[in] DRBs_ToBeSetup_List_t *drbSet
9590 * ****************************************************************/
9592 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
9594 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
9598 if(drbSet->list.array != NULLP)
9600 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
9602 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
9604 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9605 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
9607 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9608 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
9610 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9611 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9613 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9614 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9617 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
9620 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
9623 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
9627 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
9628 flows_Mapped_To_DRB_List.list.array != NULLP)
9631 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9632 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
9635 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9636 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9638 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9639 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9640 qoSFlowLevelQoSParameters.\
9641 qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
9643 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9644 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9645 qoSFlowLevelQoSParameters.\
9646 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9649 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9650 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9651 qoSFlowLevelQoSParameters.\
9652 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9656 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9657 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9658 qoSFlowLevelQoSParameters.\
9659 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9662 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9663 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9664 qoSFlowLevelQoSParameters.\
9665 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9668 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9670 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9671 qoSFlowLevelQoSParameters.\
9672 qoS_Characteristics.choice.non_Dynamic_5QI);
9675 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9676 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9679 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9680 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
9684 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9685 DRB_Information.flows_Mapped_To_DRB_List.list.array);
9688 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9689 DRB_Information.sNSSAI.sD->buf);
9692 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
9695 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
9699 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9701 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9704 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9705 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9708 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9709 qoS_Characteristics.choice.non_Dynamic_5QI);
9711 free(drbSetItem->qoSInformation.choice.choice_extension);
9713 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
9714 if(drbSetItem->uLConfiguration)
9716 free(drbSetItem->uLConfiguration);
9719 if(drbSet->list.array[drbIdx]!=NULLP)
9721 free(drbSet->list.array[drbIdx]);
9724 free(drbSet->list.array);
9729 /*******************************************************************
9731 * @brief builds Mac Cell Cfg
9735 * Function : procUeReCfgCellInfo
9737 * Functionality: builds Mac Cell Cfg
9739 * @params[in] MacUeCfg *macUeCfgToSend = Used to Store the information which
9740 * needs to send in other layer, as well as this can be
9741 * the variable which stores the information in DuCb.
9742 * MacUeCfg *storedMacUeCfg = Null in case of sending the
9743 * information to other layer else it will have copyOfmacUeCfg
9744 * which we have stored in F1UeContextSetupDb
9745 * void *cellInfo = CellGroupConfigRrc_t information which is send
9746 * by CU, which we have stored in F1UeContextSetupDb
9750 * ****************************************************************/
9751 uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfgToSend,MacUeCfg *storedMacUeCfg, void *cellInfo)
9754 CellGroupConfigRrc_t *cellGrp = NULLP;
9758 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
9759 ret = extractUeReCfgCellInfo(cellGrp, macUeCfgToSend, storedMacUeCfg);
9761 DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
9765 freeUeReCfgCellGrpInfo(macUeCfgToSend);
9770 /*******************************************************************
9772 * @brief Filling modulation info in mac ue cfg
9776 * Function : duFillModulationDetails
9778 * Functionality: Filling modulation info in mac ue cfg
9780 * @params[in] MAC UE Config to be updated
9781 * Current UE configuration
9782 * UE NR capability from CU
9783 * @return ROK - success
9786 * ****************************************************************/
9787 void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
9789 UE_NR_Capability_t *ueNrCap=NULLP;
9793 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9794 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9798 ueNrCap = (UE_NR_Capability_t *)ueCap;
9800 /* Filling DL modulation info */
9801 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
9802 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
9803 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
9805 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
9807 case ModulationOrder_qpsk:
9809 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
9812 case ModulationOrder_qam16:
9814 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
9817 case ModulationOrder_qam64:
9819 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
9820 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
9821 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
9824 case ModulationOrder_qam256:
9826 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
9831 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
9832 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9839 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9842 /* Filling UL modulation info */
9843 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
9844 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
9845 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
9847 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
9849 case ModulationOrder_qpsk:
9851 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
9854 case ModulationOrder_qam16:
9856 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
9857 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
9858 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
9861 case ModulationOrder_qam64:
9863 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
9866 case ModulationOrder_qam256:
9868 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
9873 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
9874 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9881 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9886 /*******************************************************************
9888 * @brief Function to extract cellGrp Info present in cutoDu cont
9892 * Function : extractCellGrpInfo
9894 * Functionality: Function to extract cellGrp Info present
9897 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
9899 * @return CellGroupConfigRrc_t *
9901 * ****************************************************************/
9903 CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
9908 uint16_t recvBufLen =0;
9909 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
9910 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
9911 asn_dec_rval_t rval; /* Decoder return value */
9912 memset(&rval, 0, sizeof(asn_dec_rval_t));
9916 for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
9918 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
9922 case ProtocolIE_ID_id_CellGroupConfig:
9924 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
9925 /* decoding the CellGroup Buf received */
9926 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
9929 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
9930 rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
9931 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
9932 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
9934 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
9937 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
9938 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
9944 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
9952 /*******************************************************************
9954 * @brief Fills Srb List received by CU
9958 * Function : procSrbListToSetup
9960 * Functionality: Fills Srb List received by CU
9962 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
9964 * RlcBearerCfg pointer
9967 * ****************************************************************/
9968 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
9972 /* Filling RLC INFO */
9973 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd);
9975 /* Filling MAC INFO */
9976 ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, NULL, macLcToAdd, NULL);
9979 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
9987 /*******************************************************************
9989 * @brief extract Srb List received by CU
9993 * Function : extractSrbListToSetup
9995 * Functionality: extract Srb List received by CU
9996 * for both MAC and RLC
9998 * @params[in] SRBs_ToBeSetup_Item_t pointer
10000 * @return ROK/RFAIED
10002 * ****************************************************************/
10004 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
10006 uint8_t ret, srbIdx;
10007 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
10011 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
10013 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
10014 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
10016 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
10020 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
10022 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
10026 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
10027 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
10028 ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
10029 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
10030 ueCfgDb->numRlcLcs++;
10031 ueCfgDb->numMacLcs++;
10032 DU_LOG("\nDEBUG --> DUAPP: extractSrbListToSetup: SRBID: %d [RLC,MAC,NumDrb]:[%x,%x,%x]",\
10033 srbItem->sRBID, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
10036 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
10047 /*******************************************************************
10049 * @brief Fills Drb List received by CU
10053 * Function : procDrbListToSetupMod
10055 * Functionality: Fills Drb List received by CU
10056 * for both MAC and RLC
10058 * @params[in] SRBs_ToBeSetup_Item_t pointer
10060 * RlcBearerCfg pointer
10063 * ****************************************************************/
10065 uint8_t procDrbListToSetupMod(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
10066 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo)
10069 if(drbItem != NULLP)
10071 /* Filling RLC INFO */
10072 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
10074 /* Filling MAC INFO */
10075 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
10077 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
10081 else if(drbSetupModItem != NULLP)
10083 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
10085 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
10087 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
10091 else if(drbModItem != NULLP)
10093 /* Drb to Mod IEs doesnot have rlcMode to be modified
10094 * in ASN. Hence no change in RLC configurations */
10095 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_MOD, NULL, NULL, drbModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
10097 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
10104 /*******************************************************************
10106 * @brief extract Drb List received by CU
10110 * Function : extractDrbListToSetupMod
10112 * Functionality: extract Drb List received by CU
10113 * for both MAC and RLC
10115 * @params[in] DRBs_ToBeSetup_Item_t pointer
10117 * @return ROK/RFAIED
10119 * ****************************************************************/
10121 uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
10122 DRBs_ToBeModified_List_t *drbModCfg, uint8_t drbCount, DuUeCfg *ueCfgDb, uint32_t *drbBitMap)
10124 uint8_t ret, drbIdx, lcId = 0;
10125 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
10126 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
10127 DRBs_ToBeModified_ItemIEs_t *drbModItem = NULLP;
10132 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
10134 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
10136 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetupMod()");
10140 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
10142 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetupMod()");
10146 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
10147 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
10149 if(drbModCfg != NULLP)
10151 drbModItem = (DRBs_ToBeModified_ItemIEs_t *) drbModCfg->list.array[drbIdx];
10152 lcId = fetchLcId(drbModItem->value.choice.DRBs_ToBeModified_Item.dRBID);
10153 if(lcId < MIN_DRB_LCID)
10155 DU_LOG("\nERROR --> F1AP : Failed fetching LCID %d in extractDrbListToSetupMod() for Modified List", lcId);
10158 ret = procDrbListToSetupMod(lcId, NULL, NULL, &(drbModItem->value.choice.DRBs_ToBeModified_Item),\
10159 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
10160 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
10163 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for Modified List");
10170 lcId = getDrbLcId(drbBitMap);
10171 if(lcId == RFAILED)
10173 DU_LOG("\nERROR --> F1AP : InCorrect LCID extractDrbListToSetupMod()");
10179 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
10180 ret = procDrbListToSetupMod(lcId, drbItem, NULL, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
10181 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
10184 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetup List");
10188 else if(drbSetupModCfg != NULL)
10190 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
10191 ret = procDrbListToSetupMod(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item), NULL,\
10192 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
10193 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
10196 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetupMod List");
10200 ueCfgDb->numRlcLcs++;
10202 ueCfgDb->numMacLcs++;
10205 DU_LOG("\nDEBUG --> DUAPP: extractDrbListToSetupMod:lcId:%x ,BitMap:%x, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
10206 lcId,*drbBitMap, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
10209 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod()");
10220 /*******************************************************************
10222 * @brief Function to extract Dl RRC Msg received from CU
10226 * Function : extractDlRrcMsg
10228 * Functionality: Function to extract Dl RRC Msg received from CU
10230 * @params[in] F1AP message
10231 * @return ROK - success
10232 * RFAILED - failure
10234 * ****************************************************************/
10236 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
10237 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
10240 dlRrcMsg->rrcMsgSize = rrcContainer->size;
10241 if(dlRrcMsg->rrcMsgSize > 0)
10243 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
10244 if(!dlRrcMsg->rrcMsgPdu)
10246 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
10251 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
10252 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
10253 dlRrcMsg->srbId = SRB1_LCID;
10254 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
10260 /*******************************************************************
10262 * @brief Extract UE capability info
10266 * Function : extractUeCapability
10268 * Functionality: Extract UE capability info and stores in ue Cb
10270 * @params[in] Octet string of UE capability RAT container list
10271 * @return ROK - success
10272 * RFAILED - failure
10274 * ****************************************************************/
10275 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
10278 uint16_t recvBufLen;
10279 asn_dec_rval_t rval;
10280 UE_NR_Capability_t *ueNrCap = NULLP;
10281 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
10283 /* Decoding UE Capability RAT Container List */
10284 recvBufLen = ueCapablityListBuf->size;
10285 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10286 if(!ueCapRatContList)
10288 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10291 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10292 memset(&rval, 0, sizeof(asn_dec_rval_t));
10293 rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
10294 ueCapablityListBuf->buf, recvBufLen, 0, 0);
10295 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10297 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10300 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
10302 /* Free encoded buffer after decoding */
10304 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
10306 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
10308 /* Decoding UE NR Capability */
10309 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
10310 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
10313 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10314 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10317 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
10318 memset(&rval, 0, sizeof(asn_dec_rval_t));
10319 rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
10320 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
10321 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10323 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10326 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
10328 /* Free encoded buffer after decoding */
10329 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
10331 free(ueCapRatContList->list.array[idx]);
10335 free(ueCapRatContList->list.array);
10336 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10340 /*******************************************************************
10342 * @brief free UE context setup request from CU
10346 * Function : freeAperDecodeF1UeContextSetupReq
10348 * Functionality: freeing part for the memory allocated by aper_decoder
10350 * @params[in] F1AP message
10351 * @return ROK - success
10352 * RFAILED - failure
10354 * ****************************************************************/
10355 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
10359 if(ueSetReq->protocolIEs.list.array != NULLP)
10361 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
10363 if(ueSetReq->protocolIEs.list.array[ieIdx])
10365 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10367 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10369 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10371 case ProtocolIE_ID_id_SpCell_ID:
10372 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
10374 case ProtocolIE_ID_id_ServCellIndex:
10376 case ProtocolIE_ID_id_SpCellULConfigured:
10378 case ProtocolIE_ID_id_CUtoDURRCInformation:
10380 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
10382 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10384 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
10386 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10388 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
10390 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10392 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
10394 case ProtocolIE_ID_id_RRCContainer:
10397 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
10400 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
10404 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10406 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10408 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
10410 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
10415 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
10417 free(ueSetReq->protocolIEs.list.array[ieIdx]);
10420 free(ueSetReq->protocolIEs.list.array);
10423 /*******************************************************************
10425 * @brief Process UE context setup request from CU
10429 * Function : procF1UeContextSetupReq
10431 * Functionality: Process UE context setup request from CU
10433 * @params[in] F1AP message
10434 * @return ROK - success
10435 * RFAILED - failure
10437 * ****************************************************************/
10438 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
10440 uint8_t ret=0, ieIdx=0, ueIdx=0, cellIdx=0;
10441 bool ueCbFound = false;
10442 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
10443 DuUeCb *duUeCb = NULL;
10444 UEContextSetupRequest_t *ueSetReq = NULL;
10445 DRBs_ToBeSetup_List_t *drbCfg = NULL;
10449 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
10450 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
10452 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10454 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10456 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
10459 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10461 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
10464 case ProtocolIE_ID_id_ServCellIndex:
10466 cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
10467 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
10469 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
10470 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
10473 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
10474 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
10477 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
10478 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
10479 duUeCb->f1UeDb->cellIdx = cellIdx;
10483 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
10494 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
10499 case ProtocolIE_ID_id_SpCellULConfigured:
10500 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
10501 UL, SUL or UL+SUL for the indicated cell for the UE */
10503 case ProtocolIE_ID_id_CUtoDURRCInformation:
10505 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
10507 duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
10508 extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
10509 uE_CapabilityRAT_ContainerList, duUeCb);
10511 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
10513 duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
10514 value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
10515 if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
10517 DU_LOG("\nERROR --> F1AP: Failed to extract cell Grp Info");
10518 //TODO: Update the failure cause in ue context Setup Response
10524 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10526 DU_LOG("\nINFO --> DU_APP: Received SCell_ToBeSetup_List but Not processing the list");
10529 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10531 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
10532 &duUeCb->f1UeDb->duUeCfg))
10534 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
10535 //TODO: Update the failure cause in ue context Setup Response
10540 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10542 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
10544 if(extractDrbListToSetupMod(drbCfg, NULL, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap))
10546 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod()");
10547 //TODO: Update the failure cause in ue context Setup Response
10552 case ProtocolIE_ID_id_RRCContainer:
10554 /* Filling Dl RRC Msg Info */
10555 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
10556 if(!duUeCb->f1UeDb->dlRrcMsg)
10558 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
10563 duUeCb->f1UeDb->dlRrcMsgPres = true;
10564 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
10565 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
10566 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
10570 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10572 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
10574 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
10578 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
10582 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10584 /* MaximumBitRate Uplink */
10585 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
10586 if(bitRateSize > 0)
10588 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
10589 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
10591 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
10596 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
10597 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
10598 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
10613 /*TODO : Negative case*/
10614 // BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10615 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
10618 ret = duProcUeContextSetupRequest(duUeCb);
10620 freeAperDecodeF1UeContextSetupReq(ueSetReq);
10624 /*******************************************************************
10625 * @brief Free the memory allocated for Dl Tunnel Info
10629 * Function : freeDlTnlInfo
10632 * Free the memory allocated for Dl Tunnel Info
10634 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
10637 * ****************************************************************/
10639 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
10641 uint8_t arrIdx = 0;
10645 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
10647 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf,\
10648 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.size);
10649 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf,\
10650 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.size);
10651 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10652 DU_FREE(tnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10654 DU_FREE(tnlInfo->list.array, tnlInfo->list.size);
10658 /*******************************************************************
10659 * @brief Free the memory allocated for DRB setup List
10663 * Function : freeDrbSetupList
10666 * Free the memory allocated for DRB setup list
10668 * @params[in] DRBs_Setup_List_t *
10671 * ****************************************************************/
10672 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
10674 uint8_t arrIdx = 0;
10675 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10677 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
10679 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10680 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
10681 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10683 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
10686 /*******************************************************************
10687 * @brief Free the memory allocated for UE Setup response
10691 * Function : FreeUeContextSetupRsp
10694 * Free the memory allocated for UE Setup response
10696 * @params[in] F1AP PDU for UE setup response
10697 * @return ROK - success
10698 * RFAILED - failure
10700 * ****************************************************************/
10701 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
10704 UEContextSetupResponse_t *ueSetRsp = NULLP;
10708 if(f1apMsg->choice.successfulOutcome)
10710 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
10711 UEContextSetupResponse;
10712 if(ueSetRsp->protocolIEs.list.array)
10714 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
10716 if(ueSetRsp->protocolIEs.list.array[idx])
10718 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
10720 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10722 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10724 case ProtocolIE_ID_id_DUtoCURRCInformation:
10726 CellGroupConfig_t *cellGrpCfg = NULLP;
10727 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
10728 DUtoCURRCInformation.cellGroupConfig;
10729 if(cellGrpCfg->buf != NULLP)
10731 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
10732 cellGrpCfg = NULLP;
10736 case ProtocolIE_ID_id_DRBs_Setup_List:
10738 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
10742 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
10743 ueSetRsp->protocolIEs.list.array[idx]->id);
10746 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
10747 sizeof(UEContextSetupResponseIEs_t));
10750 DU_FREE(ueSetRsp->protocolIEs.list.array, \
10751 ueSetRsp->protocolIEs.list.size);
10753 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
10755 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10759 /*******************************************************************
10761 * @brief Builds Ue context Setup Rsp DU To CU Info
10765 * Function : EncodeUeCntxtDuToCuInfo
10767 * Functionality: Builds Ue context Setup Rsp DU To CU Info
10769 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
10771 * @return ROK - success
10772 * RFAILED - failure
10774 ******************************************************************/
10776 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
10778 asn_enc_rval_t encRetVal;
10780 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
10781 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10783 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
10784 /* Encode results */
10785 if(encRetVal.encoded == ENCODE_FAIL)
10787 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
10788 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10793 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
10794 for(int i=0; i< encBufSize; i++)
10796 printf("%x",encBuf[i]);
10799 duToCuCellGrp->size = encBufSize;
10800 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
10801 if(!duToCuCellGrp->buf)
10803 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
10805 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
10809 /*******************************************************************
10811 * @brief Fills Dl Gtp tunnel Info
10815 * Function : fillGtpTunnelforDl
10817 * Functionality: Fills Dl Gtp tunnel Info
10821 * @return ROK - success
10822 * RFAILED - failure
10824 * ****************************************************************/
10826 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
10828 uint8_t bufSize = 0;
10830 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
10831 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
10832 if(gtpDl->transportLayerAddress.buf == NULLP)
10836 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
10839 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
10840 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
10841 if(gtpDl->gTP_TEID.buf == NULLP)
10845 bufSize = 3; /*forming an Octect String*/
10846 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
10851 /*******************************************************************
10853 * @brief Fills DL Tunnel Setup List
10857 * Function : fillDlTnlSetupList
10859 * Functionality: Fills the DL Tunnel Setup List
10863 * @return ROK - success
10864 * RFAILED - failure
10866 * ****************************************************************/
10868 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
10870 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10873 dlTnlInfo->list.count = eleCount;
10874 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
10876 /* Initialize the DL Tnl Setup List Members */
10877 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
10878 if(dlTnlInfo->list.array == NULLP)
10880 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
10883 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10885 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10886 if(dlTnlInfo->list.array[arrIdx] == NULLP)
10888 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
10891 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
10892 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10893 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
10895 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
10898 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
10906 /*******************************************************************
10908 * @brief Fills the Drb Setup List for Ue Context Setup Response
10912 * Function : fillDrbSetupList
10914 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
10918 * @return ROK - success
10919 * RFAILED - failure
10921 * ****************************************************************/
10922 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
10924 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10925 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10927 eleCount = ueCfg->numDrb;
10928 drbSetupList->list.count = eleCount;
10929 drbSetupList->list.size = \
10930 (eleCount * sizeof(DRBs_Setup_Item_t *));
10932 /* Initialize the Drb Setup List Members */
10933 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
10934 if(drbSetupList->list.array == NULLP)
10936 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
10940 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10942 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10943 if(drbSetupList->list.array[arrIdx] == NULLP)
10945 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
10948 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10949 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
10950 drbItemIe->criticality = Criticality_reject;
10951 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
10952 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
10953 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
10954 &ueCfg->upTnlInfo[arrIdx]);
10961 /*******************************************************************
10963 * @brief Builds and sends the UE Setup Response
10967 * Function : BuildAndSendUeContextSetupRsp
10969 * Functionality: Constructs the UE Setup Response and sends
10970 * it to the DU through SCTP.
10972 * @params[in] uint8_t cellId,uint8_t ueIdx
10974 * @return ROK - success
10975 * RFAILED - failure
10977 * ****************************************************************/
10978 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
10980 uint8_t idx, ret, cellIdx, elementCnt;
10981 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
10982 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
10983 asn_enc_rval_t encRetVal; /* Encoder return value */
10984 F1AP_PDU_t *f1apMsg = NULLP;
10985 UEContextSetupResponse_t *ueSetRsp = NULLP;
10986 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
10987 DuUeCb *ueCb = NULLP;
10989 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
10993 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
10994 if(f1apMsg == NULLP)
10996 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11001 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11002 DU_ALLOC(f1apMsg->choice.successfulOutcome,
11003 sizeof(SuccessfulOutcome_t));
11004 if(f1apMsg->choice.successfulOutcome == NULLP)
11006 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11011 f1apMsg->choice.successfulOutcome->procedureCode = \
11012 ProcedureCode_id_UEContextSetup;
11013 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11014 f1apMsg->choice.successfulOutcome->value.present = \
11015 SuccessfulOutcome__value_PR_UEContextSetupResponse;
11018 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
11020 ueSetRsp->protocolIEs.list.count = elementCnt;
11021 ueSetRsp->protocolIEs.list.size = \
11022 elementCnt * sizeof(UEContextSetupResponse_t *);
11024 /* Initialize the UESetup members */
11025 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
11026 ueSetRsp->protocolIEs.list.size);
11027 if(ueSetRsp->protocolIEs.list.array == NULLP)
11029 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
11034 for(idx=0; idx<elementCnt; idx++)
11036 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
11037 sizeof(UEContextSetupResponseIEs_t));
11038 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
11040 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
11045 /* Fetching Ue Cb Info*/
11046 GET_CELL_IDX(cellId, cellIdx);
11047 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
11048 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
11049 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
11052 /*GNB CU UE F1AP ID*/
11053 ueSetRsp->protocolIEs.list.array[idx]->id = \
11054 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11055 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11056 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
11057 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
11058 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11060 /*GNB DU UE F1AP ID*/
11062 ueSetRsp->protocolIEs.list.array[idx]->id = \
11063 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11064 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11065 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
11066 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
11067 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11070 /*DUtoCURRC Information */
11072 ueSetRsp->protocolIEs.list.array[idx]->id = \
11073 ProtocolIE_ID_id_DUtoCURRCInformation;
11074 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11075 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
11076 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
11079 if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
11081 cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
11082 ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
11083 choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
11086 DU_LOG("\nERROR --> F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
11087 freeF1UeDb(ueCb->f1UeDb);
11088 ueCb->f1UeDb = NULLP;
11095 DU_LOG("\nERROR --> F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
11100 /* Drb Setup List */
11102 ueSetRsp->protocolIEs.list.array[idx]->id = \
11103 ProtocolIE_ID_id_DRBs_Setup_List;
11104 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11105 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
11106 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
11107 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
11108 &ueCb->f1UeDb->duUeCfg);
11111 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
11112 freeF1UeDb(ueCb->f1UeDb);
11113 ueCb->f1UeDb = NULLP;
11117 /* Free UeContext Db created during Ue context Req */
11118 freeF1UeDb(ueCb->f1UeDb);
11119 ueCb->f1UeDb = NULLP;
11121 /* TODO: To send Drb list */
11122 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11124 /* Encode the UE context setup response type as APER */
11125 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
11127 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11129 /* Encode results */
11130 if(encRetVal.encoded == ENCODE_FAIL)
11132 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
11133 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11139 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
11140 for(int i=0; i< encBufSize; i++)
11142 printf("%x",encBuf[i]);
11147 if(sendF1APMsg() != ROK)
11149 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
11155 FreeUeContextSetupRsp(f1apMsg);
11157 }/* End of BuildAndSendUeContextSetupRsp */
11158 /*******************************************************************
11160 * @brief Build And Send Ue Context Rsp
11164 * Function : BuildAndSendUeCtxtRsp
11166 * Functionality : Build And Send Ue Context Rsp
11169 * @return sucess = ROK
11170 * failure = RFAILED
11172 * ****************************************************************/
11173 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueIdx)
11175 uint8_t cellIdx = 0, actionType = 0;
11177 GET_CELL_IDX(cellId, cellIdx);
11178 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
11182 case UE_CTXT_SETUP:
11184 BuildAndSendUeContextSetupRsp(cellId,ueIdx);
11189 BuildAndSendUeContextModRsp(cellId, ueIdx);
11193 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
11200 /*******************************************************************
11202 * @brief deallocating the memory of F1reset msg
11206 * Function : FreeF1ResetReq
11209 * - freeing memory of F1reset request msg
11215 * ****************************************************************/
11216 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
11219 Reset_t *f1ResetMsg;
11223 if(f1apMsg->choice.initiatingMessage)
11225 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11227 if(f1ResetMsg->protocolIEs.list.array)
11229 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
11231 if(f1ResetMsg->protocolIEs.list.array[idx])
11233 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11236 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11238 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11240 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11243 /*******************************************************************
11245 * @brief Build and Send F1reset request
11249 * Function : BuildAndSendF1ResetReq
11252 * - Build and Send F1reset request msg
11255 * @return ROK - success
11256 * RFAILED - failure
11258 * ****************************************************************/
11259 uint8_t BuildAndSendF1ResetReq()
11261 uint8_t elementCnt=0;
11263 uint8_t ret= RFAILED;
11264 Reset_t *f1ResetMsg = NULLP;
11265 F1AP_PDU_t *f1apMsg = NULLP;
11266 asn_enc_rval_t encRetVal;
11267 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
11270 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11271 if(f1apMsg == NULLP)
11275 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11276 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11277 if(f1apMsg->choice.initiatingMessage == NULLP)
11281 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
11282 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
11283 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
11285 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11288 f1ResetMsg->protocolIEs.list.count = elementCnt;
11289 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
11291 /* Initialize the F1Setup members */
11292 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11293 if(f1ResetMsg->protocolIEs.list.array == NULLP)
11297 for(idx=0; idx<elementCnt; idx++)
11299 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11300 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
11308 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11309 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11310 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
11311 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
11315 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
11316 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
11317 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
11318 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
11319 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
11323 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
11324 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11325 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
11326 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
11327 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
11329 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11331 /* Encode the F1SetupRequest type as APER */
11332 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11334 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11337 /* Encode results */
11338 if(encRetVal.encoded == ENCODE_FAIL)
11340 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
11341 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11346 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
11347 for(idx=0; idx< encBufSize; idx++)
11349 printf("%x",encBuf[idx]);
11353 if(sendF1APMsg() != ROK)
11355 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
11363 FreeF1ResetReq(f1apMsg);
11366 /*******************************************************************
11368 * @brief Build And Send F1ResetAck
11372 * Function : BuildAndSendF1ResetAck
11375 * - Build And Send F1ResetRSP
11377 * @return ROK - success
11378 * RFAILED - failure
11380 * ****************************************************************/
11381 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
11384 ResetAcknowledge_t *f1ResetAck;
11388 if(f1apMsg->choice.successfulOutcome)
11390 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11392 if(f1ResetAck->protocolIEs.list.array)
11394 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
11396 if(f1ResetAck->protocolIEs.list.array[idx])
11398 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11401 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11403 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11405 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11409 /*******************************************************************
11411 * @brief Build And Send F1ResetAck
11415 * Function : BuildAndSendF1ResetAck
11418 * - Build And Send F1ResetRSP
11421 * @return ROK - success
11422 * RFAILED - failure
11424 * ****************************************************************/
11425 uint8_t BuildAndSendF1ResetAck()
11428 uint8_t elementCnt = 0;
11429 uint8_t ret = RFAILED;
11430 F1AP_PDU_t *f1apMsg = NULL;
11431 ResetAcknowledge_t *f1ResetAck = NULLP;
11432 asn_enc_rval_t encRetVal;
11433 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
11436 /* Allocate the memory for F1ResetRequest_t */
11437 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11438 if(f1apMsg == NULLP)
11440 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11444 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11446 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11447 if(f1apMsg->choice.successfulOutcome == NULLP)
11449 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11452 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11453 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
11454 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11458 f1ResetAck->protocolIEs.list.count = elementCnt;
11459 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
11461 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11462 if(f1ResetAck->protocolIEs.list.array == NULLP)
11464 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
11468 for(idx=0; idx<elementCnt; idx++)
11470 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11471 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
11478 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11479 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11480 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
11481 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
11483 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11485 /* Encode the F1SetupRequest type as UPER */
11486 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11488 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
11490 /* Check encode results */
11491 if(encRetVal.encoded == ENCODE_FAIL)
11493 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
11494 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11499 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
11500 for(int i=0; i< encBufSize; i++)
11502 printf("%x",encBuf[i]);
11506 if(sendF1APMsg() != ROK)
11508 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
11516 FreeF1ResetAck(f1apMsg);
11519 /******************************************************************
11521 * @brief free F1 reset msg allocated by aper_decoder
11525 * Function : freeAperDecodeF1ResetMsg
11527 * Functionality: free F1 reset msg allocated by aper_decoder
11529 * @params[in] Reset_t *f1ResetMsg
11532 * ****************************************************************/
11534 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
11537 if(f1ResetMsg->protocolIEs.list.array)
11539 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
11541 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
11543 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
11546 free(f1ResetMsg->protocolIEs.list.array);
11550 /******************************************************************
11552 * @brief Processes DL RRC Message Transfer sent by CU
11556 * Function : procF1ResetReq
11558 * Functionality: Processes DL RRC Message Transfer sent by CU
11560 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11561 * @return ROK - success
11562 * RFAILED - failure
11564 * ****************************************************************/
11565 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
11567 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
11570 Reset_t *f1ResetMsg = NULLP;
11572 DU_LOG("\nINFO --> Processing F1 reset request");
11573 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11575 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
11577 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
11579 case ProtocolIE_ID_id_TransactionID:
11582 case ProtocolIE_ID_id_Cause:
11585 case ProtocolIE_ID_id_ResetType:
11594 ret = BuildAndSendF1ResetAck();
11595 DU_LOG("\nINFO --> UE release is not supported for now");
11597 freeAperDecodeF1ResetMsg(f1ResetMsg);
11602 /*******************************************************************
11604 * @brief free the RRC delivery report
11608 * Function : freeRrcDeliveryReport
11610 * Functionality: free the RRC delivery report
11613 * @return ROK - success
11614 * RFAILED - failure
11616 * ****************************************************************/
11617 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
11620 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11624 if(f1apMsg->choice.initiatingMessage)
11626 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11627 if(rrcDeliveryReport->protocolIEs.list.array)
11629 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
11632 if(rrcDeliveryReport->protocolIEs.list.array[idx])
11634 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
11635 sizeof(RRCDeliveryReportIEs_t));
11638 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
11639 rrcDeliveryReport->protocolIEs.list.size);
11641 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11644 sizeof(F1AP_PDU_t));
11648 /*******************************************************************
11650 * @brief Builds and sends the RRC delivery report
11654 * Function : BuildAndSendRrcDeliveryReport
11656 * Functionality: Builds and sends the RRC delivery report
11660 * @return ROK - success
11661 * RFAILED - failure
11663 * ****************************************************************/
11664 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
11665 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
11667 uint8_t ret = RFAILED;
11670 uint8_t elementCnt = 0;
11671 F1AP_PDU_t *f1apMsg = NULLP;
11672 asn_enc_rval_t encRetVal;
11673 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11677 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
11678 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11679 if(f1apMsg == NULLP)
11681 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11684 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11685 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11686 if(f1apMsg->choice.initiatingMessage == NULLP)
11688 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11691 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
11692 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
11693 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
11695 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11697 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
11698 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
11700 /* Initialize the F1Setup members */
11701 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
11702 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
11704 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
11707 for(idx =0 ;idx <elementCnt; idx++)
11709 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
11710 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
11718 /*GNB CU UE F1AP ID*/
11719 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11720 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11721 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
11722 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11724 /*GNB DU UE F1AP ID*/
11726 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11727 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11728 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
11729 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11731 /*RRC delivery status*/
11733 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
11734 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11735 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
11736 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
11737 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
11738 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
11739 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
11743 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
11744 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11745 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
11746 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
11748 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11750 /* Encode the RRC DELIVERY REPORT type as APER */
11751 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11753 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11756 /* Encode results */
11757 if(encRetVal.encoded == ENCODE_FAIL)
11759 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
11760 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11765 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
11766 for(idx=0; idx< encBufSize; idx++)
11768 printf("%x",encBuf[idx]);
11773 if(sendF1APMsg() != ROK)
11775 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
11783 freeRrcDeliveryReport(f1apMsg);
11787 /*******************************************************************
11789 * @brief Processes cells to be activated
11793 * Function : extractCellsToBeActivated
11796 * - Processes cells to be activated list received in F1SetupRsp
11799 * @return ROK - success
11800 * RFAILED - failure
11802 * ****************************************************************/
11804 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
11807 uint16_t idx, nci, pci = 0;
11808 Cells_to_be_Activated_List_Item_t cell;
11810 for(idx=0; idx<cellsToActivate.list.count; idx++)
11813 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
11814 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
11820 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
11824 /******************************************************************
11826 * @brief Processes F1 Setup Response allocated by aper_decoder
11830 * Function : freeF1SetupRsp
11832 * Functionality: free F1 Setup Response allocated by aper_decoder
11834 * @params[in] F1SetupResponse_t *f1SetRspMsg
11837 * ****************************************************************/
11839 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
11843 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
11844 RRC_Version_t *rrcVer =NULLP;
11846 if(f1SetRspMsg->protocolIEs.list.array)
11848 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
11850 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
11852 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
11854 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11857 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
11858 if(cellToActivate->list.array)
11860 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
11862 if(cellToActivate->list.array[arrIdx])
11865 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
11868 if(cellToActivate->list.array[0]->value.choice.\
11869 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
11871 free(cellToActivate->list.array[0]->value.choice.\
11872 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
11875 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
11876 nRCGI.pLMN_Identity.buf);
11878 free(cellToActivate->list.array[arrIdx]);
11881 free(cellToActivate->list.array);
11885 case ProtocolIE_ID_id_TransactionID:
11889 case ProtocolIE_ID_id_gNB_CU_Name:
11891 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
11894 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11896 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
11897 if(rrcVer->latest_RRC_Version.buf)
11899 if(rrcVer->iE_Extensions)
11901 if(rrcVer->iE_Extensions->list.array)
11903 if(rrcVer->iE_Extensions->list.array[0])
11905 if(rrcVer->iE_Extensions->list.\
11906 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
11908 free(rrcVer->iE_Extensions->list.\
11909 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
11911 free(rrcVer->iE_Extensions->list.array[0]);
11913 free(rrcVer->iE_Extensions->list.array);
11915 free(rrcVer->iE_Extensions);
11917 free(rrcVer->latest_RRC_Version.buf);
11924 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11925 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
11928 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
11931 free(f1SetRspMsg->protocolIEs.list.array);
11934 /******************************************************************
11936 * @brief Processes F1 Setup Response sent by CU
11940 * Function : procF1SetupRsp
11942 * Functionality: Processes F1 Setup Response sent by CU
11944 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11945 * @return ROK - success
11946 * RFAILED - failure
11948 * ****************************************************************/
11949 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
11953 F1SetupResponse_t *f1SetRspMsg = NULLP;
11954 GNB_CU_Name_t *cuName = NULLP;
11955 F1SetupRsp f1SetRspDb;
11956 RRC_Version_t *rrcVer =NULLP;
11958 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
11960 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
11961 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
11963 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
11965 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
11967 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11969 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
11970 value.choice.Cells_to_be_Activated_List);
11973 case ProtocolIE_ID_id_TransactionID:
11975 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
11976 value.choice.TransactionID;
11979 case ProtocolIE_ID_id_gNB_CU_Name:
11981 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
11982 value.choice.GNB_CU_Name;
11983 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
11986 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11988 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
11989 strcpy(f1SetRspDb.rrcVersion.rrcVer,
11990 (const char*)rrcVer->latest_RRC_Version.buf);
11994 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11995 f1SetRspMsg->protocolIEs.list.array[idx]->id);
11997 duProcF1SetupRsp();
12000 freeAperDecodeF1SetupRsp(f1SetRspMsg);
12003 /*******************************************************************
12005 * @brief free GNB DU config update ack
12009 * Function : freeAperDecodeGnbDuAck
12011 * Functionality: Processes GNB DU config update ack And
12012 * added free part for the memory allocated by aper_decoder
12014 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12015 * @return ROK - success
12016 * RFAILED - failure
12018 * ****************************************************************/
12020 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
12024 if(gnbDuAck->protocolIEs.list.array)
12026 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
12028 if(gnbDuAck->protocolIEs.list.array[ieIdx])
12030 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
12033 free(gnbDuAck->protocolIEs.list.array);
12037 /*******************************************************************
12039 * @brief Building result of gnb-du config update ack output
12043 * Function : duProcGnbDuCfgUpdAckMsg
12046 * Building output of gnb-du config update ack
12048 * @params[in] transId
12051 * ****************************************************************/
12053 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
12055 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
12056 uint8_t ueId =0 , ueIdx =0;
12057 uint16_t cellId =0, cellIdx =0, crnti=0;
12058 CmLList *f1apPduNode = NULLP;
12059 ReservedF1apPduInfo *f1apPduInfo =NULLP;
12060 F1AP_PDU_t *f1apMsgPdu = NULLP;
12061 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
12062 BIT_STRING_t *cellIdentity=NULLP;
12063 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
12064 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
12065 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
12067 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
12068 f1apPduNode = searchFromReservedF1apPduList(transId);
12069 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
12070 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
12074 if(f1apMsgPdu->choice.initiatingMessage)
12076 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
12077 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
12079 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
12081 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
12083 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
12084 Served_Cells_To_Delete_List;
12085 if(cellsToDelete->list.array)
12087 if(cellsToDelete->list.array[arrIdx])
12089 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
12090 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
12091 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
12093 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
12094 bitStringToInt(cellIdentity, &cellId);
12099 GET_CELL_IDX(cellId, cellIdx);
12100 if(duCb.actvCellLst[cellIdx] != NULLP)
12102 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
12104 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
12105 ret = duSendCellDeletReq(cellId);
12108 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
12109 request for cellId[%d]", cellId);
12114 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
12116 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
12117 GET_UE_IDX(crnti,ueId);
12118 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
12121 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
12122 request for cellId[%d]", cellId);
12129 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%d] not found", cellId);
12142 FreeDUConfigUpdate(f1apMsgPdu);
12143 deleteFromReservedF1apPduList(f1apPduNode);
12147 /*******************************************************************
12149 * @brief Processes GNB DU config update ack
12153 * Function : procF1GNBDUCfgUpdAck
12155 * Functionality: added free part for the memory allocated by aper_decoder
12157 * @params[in] F1AP_PDU_t *f1apMsg
12160 * ****************************************************************/
12161 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
12163 uint8_t ieIdx=0,transId=0;
12164 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
12166 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
12167 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
12169 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
12171 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
12173 case ProtocolIE_ID_id_TransactionID:
12175 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
12178 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
12184 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
12185 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
12191 duProcGnbDuCfgUpdAckMsg(transId);
12194 /* presently we are not supporting F1 Reset from DU to CU , we are only
12195 * supporting F1 Reset from CU to DU */
12197 if(BuildAndSendF1ResetReq() != ROK)
12203 freeAperDecodeGnbDuAck(gnbDuAck);
12206 /******************************************************************
12208 * @brief free DL RRC Message Transfer allocated by aper_decoder
12212 * Function : freeAperDecodef1DlRrcMsg
12214 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
12216 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
12217 * @return ROK - success
12218 * RFAILED - failure
12220 * ****************************************************************/
12222 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
12225 RRCContainer_t *rrcContainer = NULLP;
12227 if(f1DlRrcMsg->protocolIEs.list.array)
12229 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
12231 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
12233 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
12235 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12237 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12239 case ProtocolIE_ID_id_SRBID:
12241 case ProtocolIE_ID_id_RRCContainer:
12243 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
12244 free(rrcContainer->buf);
12246 case ProtocolIE_ID_id_ExecuteDuplication:
12248 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12252 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
12255 free(f1DlRrcMsg->protocolIEs.list.array);
12258 /******************************************************************
12260 * @brief Processes DL RRC Message Transfer sent by CU
12264 * Function : procF1DlRrcMsgTrans
12266 * Functionality: Processes DL RRC Message Transfer sent by CU
12268 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12269 * @return ROK - success
12270 * RFAILED - failure
12272 * ****************************************************************/
12273 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
12276 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
12278 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
12280 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
12281 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
12285 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
12287 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
12289 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12291 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
12294 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12296 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
12299 case ProtocolIE_ID_id_SRBID:
12301 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
12304 case ProtocolIE_ID_id_ExecuteDuplication:
12305 dlMsg.execDup = true;
12308 case ProtocolIE_ID_id_RRCContainer:
12310 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
12312 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
12313 DU_ALLOC_SHRABL_BUF(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
12314 if(dlMsg.rrcMsgPdu)
12316 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
12321 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
12327 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
12328 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
12333 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12335 dlMsg.deliveryStatRpt = true;
12339 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
12340 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
12344 ret = duProcDlRrcMsg(&dlMsg);
12346 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
12349 /*******************************************************************
12351 * @brief Builds the DRB to be Setup Mod list
12357 * Functionality: Constructs the DRB to be Setup Mod list
12359 * @params[in] DRBs_SetupMod_List_t *drbSet
12361 * @return ROK - success
12362 * RFAILED - failure
12364 * ****************************************************************/
12366 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
12370 struct DRBs_SetupMod_ItemIEs *drbItemIe;
12373 drbSet->list.count = drbCnt;
12374 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
12375 DU_ALLOC(drbSet->list.array, drbSet->list.size);
12376 if(drbSet->list.array == NULLP)
12378 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12381 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
12383 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12384 if(drbSet->list.array[arrIdx] == NULLP)
12386 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12390 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
12391 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
12392 drbItemIe->criticality = Criticality_reject;
12393 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
12394 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
12395 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
12396 &ueCfg->upTnlInfo[arrIdx])!= ROK)
12398 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
12406 /*******************************************************************
12407 * @brief Free the memory allocated for DRB setup List
12411 * Function : FreeDrbSetupModList
12414 * Free the memory allocated for DRB setup list
12416 * @params[in] DRBs_Setup_List_t *
12419 * ****************************************************************/
12420 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
12422 uint8_t arrIdx = 0;
12423 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
12425 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
12427 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
12428 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
12429 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12431 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
12433 /*******************************************************************
12434 * @brief Free the memory allocated for UE Context Mod Response
12438 * Function : FreeUeContextModResp
12441 * Free the memory allocated for UE Context Mod Response
12443 * @params[in] F1AP_PDU_t *f1apMsg
12446 * ****************************************************************/
12448 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
12451 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12454 if(f1apMsg->choice.successfulOutcome)
12456 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12457 if(ueContextModifyRes->protocolIEs.list.array)
12459 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
12461 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
12463 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
12465 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12467 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12469 case ProtocolIE_ID_id_DRBs_SetupMod_List:
12471 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12472 value.choice.DRBs_SetupMod_List));
12476 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12480 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12482 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12484 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12488 /*****************************************************************i
12490 * @brief Creating the ue context modifcation response and sending
12494 * Function : BuildAndSendUeContextModRsp
12497 * - Creating the ue context modifcation response
12499 * @params[in] uint8_t cellId,uint8_t ueIdx
12500 * @return ROK - success
12501 * RFAILED - failure
12503 * ****************************************************************/
12504 uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
12507 uint8_t cellIdx =0;
12508 uint8_t elementCnt = 0;
12509 uint8_t ret = RFAILED;
12510 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
12511 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
12512 F1AP_PDU_t *f1apMsg = NULLP;
12513 asn_enc_rval_t encRetVal;
12514 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12515 DuUeCb *ueCb = NULLP;
12517 DU_LOG("\nINFO --> F1AP : Building Ue context modification response\n");
12521 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12522 if(f1apMsg == NULLP)
12524 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12528 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12530 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12531 if(f1apMsg->choice.successfulOutcome == NULLP)
12533 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12536 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
12537 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12538 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
12540 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12543 ueContextModifyRes->protocolIEs.list.count = elementCnt;
12544 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
12546 /* Initialize the UE context modification members */
12547 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12548 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
12550 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12554 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
12556 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12557 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
12559 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12564 /* Fetching Ue Cb Info*/
12565 GET_CELL_IDX(cellId, cellIdx);
12566 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12567 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12568 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
12571 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12572 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12573 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12574 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
12575 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
12578 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12579 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12580 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
12581 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
12582 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
12585 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
12586 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12587 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12588 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
12591 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12592 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
12595 DU_LOG( "\nERROR --> F1AP : Failed to build drb setupmod List ");
12598 freeF1UeDb(ueCb->f1UeDb);
12599 ueCb->f1UeDb = NULLP;
12601 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12603 /* Encode the F1SetupRequest type as APER */
12604 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12606 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
12608 /* Encode results */
12609 if(encRetVal.encoded == ENCODE_FAIL)
12611 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
12612 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12618 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
12619 for(int i=0; i< encBufSize; i++)
12621 printf("%x",encBuf[i]);
12626 if(sendF1APMsg() != ROK)
12628 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
12634 FreeUeContextModResp(f1apMsg);
12637 /*******************************************************************
12639 * @brief Deallocating the memory allocated by the aper decoder
12644 * Function : freeAperDecodeQosInfo
12646 * Functionality: Deallocating the memory allocated for QOSInfo
12648 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
12652 * ****************************************************************/
12654 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
12656 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
12658 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12660 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12662 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12664 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12666 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
12669 /*******************************************************************
12671 * @brief Deallocating the memory allocated by the aper decoder
12672 * for UlTnlInfoforDrb
12676 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
12678 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
12680 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12684 * ****************************************************************/
12685 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12689 if(ulInfo->list.array)
12691 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
12693 if(ulInfo->list.array[arrIdx])
12695 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
12697 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
12699 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
12701 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12704 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12705 transportLayerAddress.buf);
12707 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
12709 free(ulInfo->list.array[arrIdx]);
12712 free(ulInfo->list.array);
12715 /*******************************************************************
12717 * @brief Deallocating the memory allocated by the aper decoder
12718 * for DrbSetupModItem
12722 * Function : freeAperDecodeDrbSetupModItem
12724 * Functionality: Deallocating memory allocated for DrbSetupModItem
12726 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
12730 * ****************************************************************/
12732 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
12735 SNSSAI_t *snssai =NULLP;
12736 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
12738 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
12739 switch(drbItem->qoSInformation.present)
12741 case QoSInformation_PR_NOTHING:
12743 case QoSInformation_PR_eUTRANQoS:
12745 if(drbItem->qoSInformation.choice.eUTRANQoS)
12747 free(drbItem->qoSInformation.choice.eUTRANQoS);
12751 case QoSInformation_PR_choice_extension:
12753 if(drbItem->qoSInformation.choice.choice_extension)
12755 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
12756 DRB_Information.dRB_QoS);
12757 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
12758 if(snssai->sST.buf)
12760 free(snssai->sST.buf);
12764 if(snssai->sD->buf)
12766 free(snssai->sD->buf);
12771 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
12772 DRB_Information.flows_Mapped_To_DRB_List;
12773 if(flowMap->list.array)
12775 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
12777 if(flowMap->list.array[arrIdx] )
12779 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
12780 free(flowMap->list.array[arrIdx]);
12783 free(flowMap->list.array);
12786 free(drbItem->qoSInformation.choice.choice_extension);
12792 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
12793 if(drbItem->uLConfiguration)
12795 free(drbItem->uLConfiguration);
12799 /*******************************************************************
12801 * @brief Deallocating the memory allocated by the aper decoder
12802 * for DrbToBeSetupModList
12806 * Function : freeAperDecodeDrbToBeSetupModList
12808 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
12810 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
12814 * ****************************************************************/
12816 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
12819 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
12821 if(drbSet->list.array)
12823 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
12825 if(drbSet->list.array[arrIdx] != NULLP)
12829 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
12830 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
12832 free(drbSet->list.array[arrIdx]);
12835 free(drbSet->list.array);
12839 /*******************************************************************
12841 * @brief Deallocating the memory allocated by the aper decoder
12842 * for UeContextModificationReqMsg
12846 * Function : freeAperDecodeUeContextModificationReqMsg
12848 * Functionality: Deallocating memory allocated for
12849 * UeContextModificationReqMsg
12851 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
12855 * ****************************************************************/
12856 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
12858 uint8_t arrIdx, ieId;
12860 if(UeContextModifyReq->protocolIEs.list.array)
12862 for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
12864 if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
12866 ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
12869 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12871 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12873 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12875 freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
12876 value.choice.DRBs_ToBeSetupMod_List);
12880 free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
12883 free(UeContextModifyReq->protocolIEs.list.array);
12886 /*******************************************************************
12888 * @brief processing the F1 UeContextModificationReq
12892 * Function : procF1UeContextModificationReq
12894 * Functionality: processing the F1 UeContextModificationReq
12896 * @params[in] F1AP_PDU_t *f1apMsg
12899 * ****************************************************************/
12900 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
12902 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
12903 uint8_t ret = ROK, ieIdx = 0, cellIdx=0, ueIdx=0;
12904 DuUeCb *duUeCb = NULLP;
12905 DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
12906 DRBs_ToBeModified_List_t *drbModifiedCfg;
12907 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
12909 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
12910 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
12912 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
12914 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12916 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
12919 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12921 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
12924 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12925 case ProtocolIE_ID_id_DRBs_ToBeModified_List:
12927 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
12929 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
12931 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
12932 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
12935 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
12936 if(duUeCb->f1UeDb == NULLP)
12938 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
12942 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
12943 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present ==\
12944 UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List)
12946 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
12947 choice.DRBs_ToBeSetupMod_List;
12949 if(extractDrbListToSetupMod(NULL, drbSetupModCfg, NULL, drbSetupModCfg->list.count,\
12950 &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap))
12952 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbSetupModList");
12957 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present == \
12958 UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List)
12961 drbModifiedCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
12962 choice.DRBs_ToBeModified_List;
12963 if(extractDrbListToSetupMod(NULL, NULL, drbModifiedCfg, drbSetupModCfg->list.count,\
12964 &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap))
12966 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbModifiedList");
12974 if(ueIdx >= duCb.actvCellLst[cellIdx]->numActvUes)
12976 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
12986 ret = duProcUeContextModReq(duUeCb);
12988 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
12991 /*****************************************************************i
12993 * @brief Free memory allocated for UE Context Release Request
12997 * Function : FreeUeContextReleaseReq
13000 * - Free memory allocated for UE Context Release Request
13002 * @params[in] F1AP_PDU_t *f1apMsg
13005 * *************************************************************/
13006 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
13009 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
13013 if(f1apMsg->choice.initiatingMessage)
13015 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
13016 if(ueReleaseReq->protocolIEs.list.array)
13018 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
13020 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
13022 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
13024 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
13026 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
13030 /*****************************************************************i
13032 * @brief Build and Send UE Context Release Request
13036 * Function : BuildAndSendUeContextReleaseReq
13039 * - Build and Send UE Context Release Request
13042 * @return ROK - success
13043 * RFAILED - failure
13045 * *************************************************************/
13046 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
13048 bool memAllocFail = false;
13050 uint8_t ret = RFAILED;
13051 uint16_t cellIdx =0;
13052 uint16_t crnti = 0;
13053 uint8_t elementCnt = 0;
13054 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
13055 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
13056 asn_enc_rval_t encRetVal;
13057 F1AP_PDU_t *f1apMsg = NULLP;
13058 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
13060 DU_LOG("\nINFO --> Building the UE Context Release Request");
13063 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
13064 if(f1apMsg == NULLP)
13066 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
13070 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
13071 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
13072 if(f1apMsg->choice.initiatingMessage == NULLP)
13074 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
13075 initiatingMessage");
13078 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
13079 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
13080 f1apMsg->choice.initiatingMessage->value.present = \
13081 InitiatingMessage__value_PR_UEContextReleaseRequest;
13083 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
13087 ueReleaseReq->protocolIEs.list.count = elementCnt;
13088 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
13090 /* Initialize the F1Setup members */
13091 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
13092 if(ueReleaseReq->protocolIEs.list.array == NULLP)
13094 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
13097 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
13099 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
13100 sizeof(UEContextReleaseRequest_t));
13101 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
13103 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
13104 memAllocFail = true;
13108 if(memAllocFail == true)
13111 /* Fetching Ue Cb Info*/
13112 GET_CELL_IDX(cellId, cellIdx);
13113 if(duCb.actvCellLst[cellIdx] == NULLP)
13115 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
13120 GET_CRNTI(crnti, ueIdx);
13121 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
13123 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
13126 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
13127 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
13131 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
13132 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13133 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
13134 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
13135 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
13138 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
13139 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13140 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
13141 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
13142 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13144 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13146 /* Encode the F1SetupRequest type as APER */
13147 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13149 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13150 /* Encode results */
13151 if(encRetVal.encoded == ENCODE_FAIL)
13153 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
13154 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13159 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
13160 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13162 printf("%x",encBuf[ieIdx]);
13167 if(sendF1APMsg() != ROK)
13169 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
13176 FreeUeContextReleaseReq(f1apMsg);
13179 /*****************************************************************i
13181 * @brief Free memory allocated for UE Context Release Complete
13185 * Function : FreeUeContextReleaseComplete
13188 * - Free memory allocated for UE Context Release Complete
13190 * @params[in] F1AP_PDU_t *f1apMsg
13193 * *************************************************************/
13194 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
13197 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
13201 if(f1apMsg->choice.successfulOutcome)
13203 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
13204 if(ueReleaseComplete->protocolIEs.list.array)
13206 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
13208 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
13210 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
13212 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
13214 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
13218 /*****************************************************************i
13220 * @brief Build and Send UE Context Release Complete
13224 * Function : BuildAndSendUeContextReleaseComplete
13227 * - Build and Send UE Context Release Complete
13229 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
13230 * @return ROK - success
13231 * RFAILED - failure
13233 * *************************************************************/
13234 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
13236 bool memAllocFail = false;
13237 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
13238 asn_enc_rval_t encRetVal;
13239 F1AP_PDU_t *f1apMsg = NULLP;
13240 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
13242 DU_LOG("\nINFO --> Building the UE Context Release Complete");
13245 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
13246 if(f1apMsg == NULLP)
13248 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
13252 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
13253 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
13254 if(f1apMsg->choice.successfulOutcome == NULLP)
13256 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
13257 successfulOutcome");
13260 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
13261 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
13262 f1apMsg->choice.successfulOutcome->value.present = \
13263 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
13265 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
13268 ueReleaseComplete->protocolIEs.list.count = elementCnt;
13269 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
13271 /* Initialize the UE Release Complete members */
13272 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
13273 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
13275 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
13278 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
13280 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
13281 sizeof(UEContextReleaseComplete_t));
13282 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
13284 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
13286 memAllocFail = true;
13290 if(memAllocFail == true)
13295 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
13296 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13297 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
13298 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
13299 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
13302 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
13303 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13304 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
13305 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
13306 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13308 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13310 /* Encode the F1SetupComplete type as APER */
13311 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13313 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13314 /* Encode results */
13315 if(encRetVal.encoded == ENCODE_FAIL)
13317 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
13318 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13323 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
13324 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13326 printf("%x",encBuf[ieIdx]);
13331 if(sendF1APMsg() != ROK)
13333 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
13342 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
13343 ret = duSendCellDeletReq(cellId);
13346 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
13347 Delete req for CellId");
13350 FreeUeContextReleaseComplete(f1apMsg);
13355 /*******************************************************************
13357 * @brief added free part for the memory allocated by aper_decoder
13361 * Function : freeAperDecodeUeContextReleaseCommand
13363 * Functionality: added free part for the memory allocated by aper_decoder
13365 * @params[in] F1AP_PDU_t *f1apMsg
13368 * ****************************************************************/
13369 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13372 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13374 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13376 if(ueContextReleaseCommand->protocolIEs.list.array)
13378 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13380 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13382 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13384 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13386 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13388 case ProtocolIE_ID_id_Cause:
13390 case ProtocolIE_ID_id_RRCContainer:
13392 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
13394 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
13399 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13400 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13404 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
13406 free(ueContextReleaseCommand->protocolIEs.list.array);
13409 /*******************************************************************
13411 * @brief processing of UE Context Release Command
13415 * Function : procF1UeContextReleaseCommand
13417 * Functionality: processing of UE Context Release Command
13419 * @params[in] F1AP_PDU_t *f1apMsg
13422 * ****************************************************************/
13423 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13425 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
13426 uint16_t cellIdx =0;
13428 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
13429 DuUeCb *duUeCb = NULLP;
13430 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13432 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13434 if(ueContextReleaseCommand->protocolIEs.list.array)
13436 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13438 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13440 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13442 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13444 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13445 value.choice.GNB_CU_UE_F1AP_ID;
13449 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13451 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13452 value.choice.GNB_DU_UE_F1AP_ID;
13456 case ProtocolIE_ID_id_Cause:
13461 case ProtocolIE_ID_id_RRCContainer:
13463 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
13465 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
13467 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
13468 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
13470 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13471 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13474 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13475 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
13476 duUeCb->f1UeDb->cellIdx = cellIdx;
13477 /* Filling Dl RRC Msg Info */
13478 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13479 if(!duUeCb->f1UeDb->dlRrcMsg)
13481 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13482 Memory allocation failed ");
13487 duUeCb->f1UeDb->dlRrcMsgPres = true;
13488 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13489 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13490 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13491 value.choice.RRCContainer);
13497 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13498 Memory allocation failed ");
13507 if(ueIdxFound == true)
13514 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13522 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13523 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13531 duProcUeContextReleaseCommand(duUeCb);
13533 freeAperDecodeUeContextReleaseCommand(f1apMsg);
13536 /**************************************************************
13538 * @brief Handles received F1AP message and sends back response
13542 * Function : F1APMsgHdlr
13545 * - Decodes received F1AP control message
13546 * - Prepares response message, encodes and sends to SCTP
13549 * @return ROK - success
13550 * RFAILED - failure
13552 * ****************************************************************/
13553 void F1APMsgHdlr(Buffer *mBuf)
13556 char *recvBuf =NULLP;
13558 MsgLen recvBufLen =0;
13559 F1AP_PDU_t *f1apMsg =NULLP;
13560 asn_dec_rval_t rval; /* Decoder return value */
13561 F1AP_PDU_t f1apasnmsg ;
13562 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
13563 ODU_PRINT_MSG(mBuf, 0,0);
13565 /* Copy mBuf into char array to decode it */
13566 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
13567 DU_ALLOC(recvBuf, (Size)recvBufLen);
13569 if(recvBuf == NULLP)
13571 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
13574 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
13576 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
13580 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
13581 for(i=0; i< recvBufLen; i++)
13583 printf("%x",recvBuf[i]);
13586 /* Decoding flat buffer into F1AP messsage */
13587 f1apMsg = &f1apasnmsg;
13588 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
13590 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
13591 DU_FREE(recvBuf, (Size)recvBufLen);
13593 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13595 DU_LOG("\nERROR --> F1AP : ASN decode failed");
13599 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13601 switch(f1apMsg->present)
13603 case F1AP_PDU_PR_successfulOutcome:
13605 switch(f1apMsg->choice.successfulOutcome->value.present)
13607 case SuccessfulOutcome__value_PR_ResetAcknowledge:
13609 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
13612 case SuccessfulOutcome__value_PR_F1SetupResponse:
13614 #ifndef ODU_TEST_STUB
13615 procF1SetupRsp(f1apMsg);
13620 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
13622 procF1GNBDUCfgUpdAck(f1apMsg);
13628 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
13629 f1apMsg->choice.successfulOutcome->value.present);
13632 }/* End of switch(successfulOutcome) */
13633 free(f1apMsg->choice.successfulOutcome);
13636 case F1AP_PDU_PR_initiatingMessage:
13638 switch(f1apMsg->choice.initiatingMessage->value.present)
13640 case InitiatingMessage__value_PR_Reset:
13642 procF1ResetReq(f1apMsg);
13645 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
13647 procF1DlRrcMsgTrans(f1apMsg);
13650 case InitiatingMessage__value_PR_UEContextSetupRequest:
13652 procF1UeContextSetupReq(f1apMsg);
13655 case InitiatingMessage__value_PR_UEContextModificationRequest:
13657 procF1UeContextModificationReq(f1apMsg);
13660 case InitiatingMessage__value_PR_UEContextReleaseCommand:
13662 procF1UeContextReleaseCommand(f1apMsg);
13667 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
13668 f1apMsg->choice.initiatingMessage->value.present);
13671 }/* End of switch(initiatingMessage) */
13672 free(f1apMsg->choice.initiatingMessage);
13678 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
13683 }/* End of switch(f1apMsg->present) */
13685 } /* End of F1APMsgHdlr */
13687 /**********************************************************************
13689 **********************************************************************/