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)
961 uint8_t extensionCnt=1;
964 DU_ALLOC(*ieExtend,sizeof(ProtocolExtensionContainer_4624P3_t));
965 if((*ieExtend) == NULLP)
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)
977 for(plmnidx=0;plmnidx<extensionCnt;plmnidx++)
979 DU_ALLOC((*ieExtend)->list.array[plmnidx],\
980 sizeof(ServedPLMNs_ItemExtIEs_t));
981 if((*ieExtend)->list.array[plmnidx] == NULLP)
987 (*ieExtend)->list.array[idx]->id = ProtocolIE_ID_id_TAISliceSupportList;
988 (*ieExtend)->list.array[idx]->criticality = Criticality_ignore;
989 (*ieExtend)->list.array[idx]->extensionValue.present = \
990 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
991 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
993 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
994 list.size = sizeof(SliceSupportItem_t *);
995 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
996 list.array,sizeof(SliceSupportItem_t *));
997 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1002 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1003 list.array[sliceId],sizeof(SliceSupportItem_t));
1004 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1005 list.array[sliceId] == NULLP)
1009 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1010 list.array[sliceId]->sNSSAI.sST.size = sizeof(uint8_t);
1011 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
1012 .list.array[sliceId]->sNSSAI.sST.buf,(*ieExtend)->list.array[idx]->\
1013 extensionValue.choice.SliceSupportList.\
1014 list.array[sliceId]->sNSSAI.sST.size);
1015 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
1016 .list.array[sliceId]->sNSSAI.sST.buf == NULLP)
1020 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1021 list.array[sliceId]->sNSSAI.sST.buf[0] = 3;
1022 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1023 list.array[sliceId]->sNSSAI.sD,sizeof(OCTET_STRING_t));
1024 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1025 list.array[sliceId]->sNSSAI.sD == NULLP)
1029 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1030 list.array[sliceId]->sNSSAI.sD->size = 3*sizeof(uint8_t);
1031 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1032 list.array[sliceId]->sNSSAI.sD->buf,(*ieExtend)->list.array[idx]->extensionValue.choice.\
1033 SliceSupportList.list.array[sliceId]->sNSSAI.sD->size);
1034 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1035 list.array[sliceId]->sNSSAI.sD->buf == NULLP)
1040 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1041 list.array[sliceId]->sNSSAI.sD->buf[sdId] = 3;
1043 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1044 list.array[sliceId]->sNSSAI.sD->buf[sdId] = 6;
1046 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1047 list.array[sliceId]->sNSSAI.sD->buf[sdId] = 9;
1050 /*******************************************************************
1052 * @brief Builds Served PLMN
1056 * Function : BuildServedPlmn
1058 * Functionality: Building the Served PLMN
1060 * @params[in] GNB_DU_Served_Cells_Item_t *srvCellItem
1061 * @return ROK - success
1064 * ****************************************************************/
1065 uint8_t BuildServedPlmn(ServedPLMNs_List_t *srvplmn)
1068 uint8_t servPlmnCnt=1;
1069 uint8_t buildPlmnIdret=0;
1070 uint8_t BuildExtensionsret=0;
1071 srvplmn->list.count = servPlmnCnt;
1072 srvplmn->list.size = \
1073 servPlmnCnt*sizeof(ServedPLMNs_Item_t *);
1074 DU_ALLOC(srvplmn->list.array,srvplmn->list.size);
1075 if(srvplmn->list.array == NULLP)
1079 for(plmnidx=0; plmnidx<servPlmnCnt; plmnidx++)
1081 DU_ALLOC(srvplmn->list.array[plmnidx],\
1082 sizeof(ServedPLMNs_Item_t));
1083 if(srvplmn->list.array[plmnidx] == NULLP)
1088 srvplmn->list.array[0]->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
1089 DU_ALLOC(srvplmn->list.array[0]->pLMN_Identity.buf, srvplmn->list.array[0]->pLMN_Identity.size);
1090 buildPlmnIdret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
1091 srvplmn->list.array[0]->pLMN_Identity.buf);
1092 if(buildPlmnIdret!= ROK)
1096 BuildExtensionsret = BuildExtensions(&srvplmn->list.array[0]->iE_Extensions);
1097 if(BuildExtensionsret!= ROK)
1103 /*******************************************************************
1105 * @brief Builds Served Cell List
1109 * Function : BuildServedCellList
1111 * Functionality: Building Served Cell List
1113 * @params[in] PLMNID plmn
1114 * @return ROK - success
1117 * ****************************************************************/
1119 uint8_t BuildServedCellList(GNB_DU_Served_Cells_List_t *duServedCell)
1121 uint8_t BuildNrcgiret=0;
1122 uint8_t BuildFiveGSTacret=0;
1123 uint8_t BuildServedPlmnret=0;
1124 uint8_t BuildNrModeret=0;
1128 GNB_DU_Served_Cells_Item_t *srvCellItem;
1129 duServedCell->list.size = plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t *);
1130 duServedCell->list.count = plmnCnt;
1132 DU_ALLOC(duServedCell->list.array, duServedCell->list.size);
1133 if(duServedCell->list.array == NULLP)
1137 for(plmnidx=0; plmnidx<plmnCnt; plmnidx++)
1139 DU_ALLOC(duServedCell->list.array[plmnidx],\
1140 sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1141 if(duServedCell->list.array[plmnidx] == NULLP)
1147 duServedCell->list.array[idx]->id = ProtocolIE_ID_id_GNB_DU_Served_Cells_Item;
1148 duServedCell->list.array[idx]->criticality = Criticality_reject;
1149 duServedCell->list.array[idx]->value.present = \
1150 GNB_DU_Served_Cells_ItemIEs__value_PR_GNB_DU_Served_Cells_Item;
1152 &duServedCell->list.array[idx]->value.choice.GNB_DU_Served_Cells_Item;
1154 BuildNrcgiret = BuildNrcgi(&srvCellItem->served_Cell_Information.nRCGI);
1155 if(BuildNrcgiret != ROK)
1160 srvCellItem->served_Cell_Information.nRPCI = \
1161 duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
1164 BuildFiveGSTacret = BuildFiveGSTac(&srvCellItem->served_Cell_Information);
1165 if(BuildFiveGSTacret != ROK)
1170 BuildServedPlmnret = BuildServedPlmn(&srvCellItem->served_Cell_Information.servedPLMNs);
1171 if(BuildServedPlmnret !=ROK)
1175 /*nR Mode Info with FDD*/
1176 BuildNrModeret = BuildNrMode(&srvCellItem->served_Cell_Information.nR_Mode_Info);
1177 if(BuildNrModeret != ROK)
1181 /*Measurement timing Config*/
1182 srvCellItem->served_Cell_Information.measurementTimingConfiguration.\
1183 size = sizeof(uint8_t);
1184 DU_ALLOC(srvCellItem->served_Cell_Information.\
1185 measurementTimingConfiguration.buf,srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1186 if(srvCellItem->served_Cell_Information.\
1187 measurementTimingConfiguration.buf == NULLP)
1191 srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf[0] = \
1192 duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
1194 /* GNB DU System Information */
1195 DU_ALLOC(srvCellItem->gNB_DU_System_Information,
1196 sizeof(GNB_DU_System_Information_t));
1197 if(!srvCellItem->gNB_DU_System_Information)
1202 srvCellItem->gNB_DU_System_Information->mIB_message.size = duCfgParam.srvdCellLst[0].duSysInfo.mibLen;
1203 DU_ALLOC(srvCellItem->gNB_DU_System_Information->mIB_message.buf,
1204 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1205 if(!srvCellItem->gNB_DU_System_Information->mIB_message.buf)
1209 memcpy(srvCellItem->gNB_DU_System_Information->mIB_message.buf, duCfgParam.srvdCellLst[0].duSysInfo.mibMsg, \
1210 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1213 srvCellItem->gNB_DU_System_Information->sIB1_message.size =\
1214 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
1216 DU_ALLOC(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,
1217 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1218 if(!srvCellItem->gNB_DU_System_Information->sIB1_message.buf)
1222 for(int x=0; x<srvCellItem->gNB_DU_System_Information->sIB1_message.size; x++)
1224 srvCellItem->gNB_DU_System_Information->sIB1_message.buf[x]=\
1225 duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg[x];
1229 /*******************************************************************
1231 * @brief Builds RRC Version
1235 * Function : BuildRrcVer
1237 * Functionality: Building RRC Version
1239 * @params[in] int idx,int elementCnt,RRC_Version_t *rrcver
1240 * @return ROK - success
1243 * ****************************************************************/
1244 uint8_t BuildRrcVer(RRC_Version_t *rrcVer)
1248 rrcVer->latest_RRC_Version.size = sizeof(uint8_t);
1249 DU_ALLOC(rrcVer->latest_RRC_Version.buf,sizeof(uint8_t));
1250 if(rrcVer->latest_RRC_Version.buf == NULLP)
1254 rrcVer->latest_RRC_Version.buf[0] = 0;
1255 rrcVer->latest_RRC_Version.bits_unused = 5;
1256 DU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1257 if(rrcVer->iE_Extensions == NULLP)
1261 rrcVer->iE_Extensions->list.count = 1;
1262 rrcVer->iE_Extensions->list.size = sizeof(RRC_Version_ExtIEs_t *);
1263 DU_ALLOC(rrcVer->iE_Extensions->list.array,rrcVer->iE_Extensions->list.size);
1264 if(rrcVer->iE_Extensions->list.array == NULLP)
1269 DU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
1270 sizeof(RRC_Version_ExtIEs_t));
1271 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
1275 rrcVer->iE_Extensions->list.array[rrcExt]->id = \
1276 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
1277 rrcVer->iE_Extensions->list.array[rrcExt]->criticality = Criticality_reject;
1278 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.present =\
1279 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
1280 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1281 .Latest_RRC_Version_Enhanced.size = 3*sizeof(uint8_t);
1282 DU_ALLOC(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1283 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1284 array[rrcExt]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1285 if(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1286 .Latest_RRC_Version_Enhanced.buf == NULLP)
1291 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1292 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 15;
1294 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1295 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 5;
1297 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1298 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 0;
1301 /*******************************************************************
1303 * @brief Sends F1 msg over SCTP
1307 * Function : sendF1APMsg
1309 * Functionality: Sends F1 msg over SCTP
1311 * @params[in] Region region
1313 * @return ROK - success
1316 * ****************************************************************/
1317 uint8_t sendF1APMsg()
1319 Buffer *mBuf = NULLP;
1321 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1323 if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
1325 ODU_PRINT_MSG(mBuf, 0,0);
1327 if(sctpSend(mBuf, F1_INTERFACE) != ROK)
1329 DU_LOG("\nERROR --> F1AP : SCTP Send failed");
1330 ODU_PUT_MSG_BUF(mBuf);
1336 DU_LOG("\nERROR --> F1AP : ODU_ADD_POST_MSG_MULT failed");
1337 ODU_PUT_MSG_BUF(mBuf);
1340 ODU_PUT_MSG_BUF(mBuf);
1344 DU_LOG("\nERROR --> F1AP : Failed to allocate memory");
1350 /*******************************************************************
1352 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1356 * Function : FreeRrcVer
1358 * Functionality: deallocating the memory of function BuildRrcVer
1360 * @params[in] RRC_Version_t *rrcVer
1364 *****************************************************************/
1365 void FreeRrcVer(RRC_Version_t *rrcVer)
1367 if(rrcVer->latest_RRC_Version.buf != NULLP)
1369 if(rrcVer->iE_Extensions != NULLP)
1371 if(rrcVer->iE_Extensions->list.array != NULLP)
1373 if(rrcVer->iE_Extensions->list.array[0] != NULLP)
1375 if(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf
1378 DU_FREE(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice\
1379 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1380 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1382 DU_FREE(rrcVer->iE_Extensions->list.array[0],sizeof(RRC_Version_ExtIEs_t));
1384 DU_FREE(rrcVer->iE_Extensions->list.array,sizeof(RRC_Version_ExtIEs_t*));
1386 DU_FREE(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1388 DU_FREE(rrcVer->latest_RRC_Version.buf,rrcVer->latest_RRC_Version.size);
1391 /*******************************************************************
1393 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1397 * Function : FreeServedCellList
1399 * Functionality: deallocating the memory of function BuildServedCellList
1402 * @params[in] GNB_DU_Served_Cells_List_t *duServedCell
1406 * ****************************************************************/
1407 void FreeServedCellList( GNB_DU_Served_Cells_List_t *duServedCell)
1411 uint8_t extensionCnt=1;
1413 GNB_DU_Served_Cells_Item_t *srvCellItem;
1414 ServedPLMNs_Item_t *servedPlmnItem;
1415 SliceSupportItem_t *sliceSupportItem;
1417 if(duServedCell->list.array!=NULLP)
1419 if(duServedCell->list.array[0]!=NULLP)
1421 srvCellItem= &duServedCell->list.array[0]->value.choice.GNB_DU_Served_Cells_Item;
1423 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1424 srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.size * sizeof(uint8_t));
1425 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1426 srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.size * sizeof(uint8_t));
1428 if(srvCellItem->served_Cell_Information.fiveGS_TAC!=NULLP)
1430 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC->buf,\
1431 sizeof(srvCellItem->served_Cell_Information.fiveGS_TAC->size));
1432 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC,sizeof(FiveGS_TAC_t));
1435 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array!=NULLP)
1437 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx] != NULLP)
1439 servedPlmnItem = srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx];
1440 DU_FREE(servedPlmnItem->pLMN_Identity.buf, servedPlmnItem->pLMN_Identity.size * sizeof(uint8_t));
1442 if(servedPlmnItem->iE_Extensions != NULLP)
1444 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1446 if(servedPlmnItem->iE_Extensions->list.array[0] != NULLP)
1448 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.\
1451 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.\
1452 array[sliceId] != NULLP)
1454 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1455 SliceSupportList.list.array[sliceId];
1457 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sizeof(uint8_t));
1459 if(sliceSupportItem->sNSSAI.sD != NULLP)
1461 DU_FREE(sliceSupportItem->sNSSAI.sD->buf, sliceSupportItem->sNSSAI.sD->size);
1462 DU_FREE(sliceSupportItem->sNSSAI.sD, sizeof(OCTET_STRING_t));
1465 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
1466 list.array[sliceId], sizeof(SliceSupportItem_t));
1468 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
1469 list.array, sizeof(SliceSupportItem_t*));
1471 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0], sizeof(ServedPLMNs_ItemExtIEs_t));
1473 DU_FREE(servedPlmnItem->iE_Extensions->list.array, extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
1475 DU_FREE(servedPlmnItem->iE_Extensions, sizeof(ProtocolExtensionContainer_4624P3_t));
1477 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx], sizeof(ServedPLMNs_Item_t));
1479 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array, sizeof(ServedPLMNs_Item_t *));
1482 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
1484 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.\
1485 freqBandListNr.list.array != NULLP)
1487 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.\
1488 list.array[0],sizeof(FreqBandNrItem_t));
1489 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.\
1490 list.array,sizeof(FreqBandNrItem_t*));
1493 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1494 freqBandListNr.list.array)
1496 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1497 freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
1498 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1499 freqBandListNr.list.array,sizeof(FreqBandNrItem_t *));
1501 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD, sizeof(FDD_Info_t));
1504 DU_FREE(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1505 srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1507 if(srvCellItem->gNB_DU_System_Information != NULLP)
1509 if(srvCellItem->gNB_DU_System_Information->mIB_message.buf != NULLP)
1511 DU_FREE(srvCellItem->gNB_DU_System_Information->mIB_message.buf,\
1512 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1515 if(srvCellItem->gNB_DU_System_Information->sIB1_message.buf != NULLP)
1517 DU_FREE(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,\
1518 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1521 DU_FREE(srvCellItem->gNB_DU_System_Information, sizeof(GNB_DU_System_Information_t));
1524 DU_FREE(duServedCell->list.array[0], sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1526 DU_FREE(duServedCell->list.array, plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t*));
1530 /*******************************************************************
1532 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1536 * Function : FreeF1SetupReq
1538 * Functionality: deallocating the memory of function BuildAndSendF1SetupReq
1540 * @params[in] F1AP_PDU_t *f1apMsg
1544 * ****************************************************************/
1545 void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
1547 uint8_t ieIdx, ieIdx2;
1548 F1SetupRequest_t *f1SetupReq=NULLP;
1550 if(f1apMsg != NULLP)
1552 if(f1apMsg->choice.initiatingMessage != NULLP)
1554 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1555 if(f1SetupReq->protocolIEs.list.array != NULLP)
1557 for(ieIdx = 0; ieIdx < f1SetupReq->protocolIEs.list.count; ieIdx++)
1559 if(f1SetupReq->protocolIEs.list.array[ieIdx] != NULLP)
1561 switch(f1SetupReq->protocolIEs.list.array[ieIdx]->id)
1563 case ProtocolIE_ID_id_TransactionID:
1565 case ProtocolIE_ID_id_gNB_DU_ID:
1566 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1567 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1569 case ProtocolIE_ID_id_gNB_DU_Name:
1570 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf,\
1571 strlen((char *)duCfgParam.duName));
1573 case ProtocolIE_ID_id_gNB_DU_Served_Cells_List:
1574 FreeServedCellList(&f1SetupReq->protocolIEs.list.\
1575 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List);
1577 case ProtocolIE_ID_id_GNB_DU_RRC_Version:
1578 FreeRrcVer(&f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version);
1581 DU_LOG("\nERROR --> Invalid Event Type %ld", f1SetupReq->protocolIEs.list.array[ieIdx]->id);
1586 for(ieIdx2=0; ieIdx2< ieIdx; ieIdx2++)
1588 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx2],sizeof(F1SetupRequestIEs_t));
1590 DU_FREE(f1SetupReq->protocolIEs.list.array,\
1591 f1SetupReq->protocolIEs.list.size);
1593 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1595 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
1598 /*******************************************************************
1600 * @brief Builds and Send the F1SetupRequest
1604 * Function : BuildAndSendF1SetupReq
1606 * Functionality:Fills the F1SetupRequest
1608 * @return ROK - success
1611 ******************************************************************/
1612 uint8_t BuildAndSendF1SetupReq()
1614 uint8_t ret, ieIdx, elementCnt;
1615 F1AP_PDU_t *f1apMsg = NULLP;
1616 F1SetupRequest_t *f1SetupReq=NULLP;
1617 GNB_DU_Served_Cells_List_t *duServedCell=NULLP;
1618 RRC_Version_t *rrcVer=NULLP;
1619 asn_enc_rval_t encRetVal; /* Encoder return value */
1622 DU_LOG("\nINFO --> F1AP : Building F1 Setup Request\n");
1625 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1626 if(f1apMsg == NULLP)
1630 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
1631 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1632 if(f1apMsg->choice.initiatingMessage == NULLP)
1636 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_F1Setup;
1637 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
1638 f1apMsg->choice.initiatingMessage->value.present = \
1639 InitiatingMessage__value_PR_F1SetupRequest;
1641 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1643 elementCnt = (duCfgParam.duName != NULL) ? 5 : 4;
1645 f1SetupReq->protocolIEs.list.count = elementCnt;
1646 f1SetupReq->protocolIEs.list.size = elementCnt * sizeof(F1SetupRequestIEs_t );
1648 /* Initialize the F1Setup members */
1649 DU_ALLOC(f1SetupReq->protocolIEs.list.array,f1SetupReq->protocolIEs.list.size);
1650 if(f1SetupReq->protocolIEs.list.array == NULLP)
1654 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
1656 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx],\
1657 sizeof(F1SetupRequestIEs_t));
1658 if(f1SetupReq->protocolIEs.list.array[ieIdx] == NULLP)
1666 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_TransactionID;
1667 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1668 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present =\
1669 F1SetupRequestIEs__value_PR_TransactionID;
1670 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = \
1675 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
1676 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1677 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1678 F1SetupRequestIEs__value_PR_GNB_DU_ID;
1679 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size =\
1682 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1683 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1684 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == \
1690 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] =\
1694 if(duCfgParam.duName != NULL)
1697 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_Name;
1698 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore;
1699 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = F1SetupRequestIEs__value_PR_GNB_DU_Name;
1700 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.size =\
1701 strlen((char *)duCfgParam.duName);
1702 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.\
1703 GNB_DU_Name.buf, strlen((char *)duCfgParam.duName));
1704 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.\
1709 strcpy((char*)f1SetupReq->protocolIEs.list.array[ieIdx]->value.\
1710 choice.GNB_DU_Name.buf,
1711 (char*)&duCfgParam.duName);
1715 /*Served Cell list */
1717 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1718 ProtocolIE_ID_id_gNB_DU_Served_Cells_List;
1719 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1720 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1721 F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List;
1722 duServedCell = &f1SetupReq->protocolIEs.list.\
1723 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List;
1724 if(BuildServedCellList(duServedCell))
1730 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1731 ProtocolIE_ID_id_GNB_DU_RRC_Version ;
1732 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1733 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1734 F1SetupRequestIEs__value_PR_RRC_Version;
1735 rrcVer = &f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
1736 if(BuildRrcVer(rrcVer))
1740 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1742 /* Encode the F1SetupRequest type as APER */
1743 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1745 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1748 /* Encode results */
1749 if(encRetVal.encoded == ENCODE_FAIL)
1751 DU_LOG("\nERROR --> F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
1752 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1757 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1SetupRequest\n");
1758 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
1760 printf("%x",encBuf[ieIdx]);
1765 if(sendF1APMsg() != ROK)
1767 DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed");
1775 FreeF1SetupReq(f1apMsg);
1778 }/* End of BuildAndSendF1SetupReq */
1780 /*******************************************************************
1782 * @brief Deallocating memory allocated for Served_Cells_To_Modify_Item_t
1786 * Function : freeCellsToModifyItem
1788 * Functionality: Deallocating memory of variables allocated in
1789 * BuildAndSendDUConfigUpdate function
1791 * @params[in] Served_Cells_To_Modify_Item_t *modifyItem
1793 * @return ROK - void
1795 * ****************************************************************/
1797 void freeCellsToModifyItem(Served_Cells_To_Modify_Item_t *modifyItem)
1799 uint8_t arrIdx=0,i=0;
1800 ServedPLMNs_Item_t *servedPlmnItem = NULLP;
1801 SliceSupportItem_t *sliceSupportItem = NULLP;
1803 DU_FREE(modifyItem->oldNRCGI.pLMN_Identity.buf, modifyItem->oldNRCGI.pLMN_Identity.size);
1804 DU_FREE(modifyItem->oldNRCGI.nRCellIdentity.buf, modifyItem->oldNRCGI.nRCellIdentity.size);
1806 DU_FREE(modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1807 modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.size);
1808 DU_FREE(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1809 modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.size);
1811 if(modifyItem->served_Cell_Information.servedPLMNs.list.array != NULLP)
1813 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx] != NULLP)
1815 servedPlmnItem = modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx];
1817 DU_FREE(servedPlmnItem->pLMN_Identity.buf,servedPlmnItem->pLMN_Identity.size);
1819 if(servedPlmnItem->iE_Extensions != NULLP)
1821 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1823 if(servedPlmnItem->iE_Extensions->list.array[arrIdx] != NULLP)
1825 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.array != NULLP)
1827 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.array[arrIdx] != NULLP)
1829 sliceSupportItem = modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->iE_Extensions->\
1830 list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.array[arrIdx];
1832 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sliceSupportItem->sNSSAI.sST.size);
1833 if(sliceSupportItem->sNSSAI.sD != NULLP)
1835 DU_FREE(sliceSupportItem->sNSSAI.sD->buf, sliceSupportItem->sNSSAI.sD->size);
1836 DU_FREE(sliceSupportItem->sNSSAI.sD,sizeof(OCTET_STRING_t));
1838 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1839 list.array[arrIdx], sizeof(SliceSupportItem_t));
1841 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.array,
1842 servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.size);
1845 for(i=0; i < servedPlmnItem->iE_Extensions->list.count ; i++)
1847 DU_FREE(servedPlmnItem->iE_Extensions->list.array[i], sizeof(ServedPLMNs_ItemExtIEs_t ));
1849 DU_FREE(servedPlmnItem->iE_Extensions->list.array, servedPlmnItem->iE_Extensions->list.size);
1851 DU_FREE(servedPlmnItem->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1854 for(i=0;i<modifyItem->served_Cell_Information.servedPLMNs.list.count;i++)
1856 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[i], sizeof(ServedPLMNs_Item_t));
1858 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array,\
1859 modifyItem->served_Cell_Information.servedPLMNs.list.size);
1862 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
1864 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1866 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
1867 array[arrIdx], sizeof(FreqBandNrItem_t));
1868 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array, \
1869 modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1872 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1874 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.\
1875 array[arrIdx], sizeof(FreqBandNrItem_t));
1876 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
1877 modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
1879 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD,sizeof(FDD_Info_t));
1882 DU_FREE(modifyItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1883 modifyItem->served_Cell_Information.measurementTimingConfiguration.size);
1886 /*******************************************************************
1888 * @brief Deallocating memory of BuildAndSendDUConfigUpdate
1892 * Function : FreeDUConfigUpdate
1894 * Functionality: Deallocating memory of variables allocated in
1895 * BuildAndSendDUConfigUpdate function
1897 * @params[in] F1AP_PDU_t *f1apDuCfg
1899 * @return ROK - void
1901 * ****************************************************************/
1902 void FreeDUConfigUpdate(F1AP_PDU_t *f1apDuCfg)
1904 uint8_t ieIdx=0, cellModifyIdx=0, cellDeleteIdx=0;
1905 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
1906 Served_Cells_To_Modify_List_t *cellsToModify=NULLP;
1907 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
1908 Served_Cells_To_Delete_Item_t *deleteItem = NULLP;
1909 Served_Cells_To_Delete_ItemIEs_t *deleteItemIe = NULLP;
1911 if(f1apDuCfg != NULLP)
1913 if(f1apDuCfg->choice.initiatingMessage != NULLP)
1915 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->\
1916 value.choice.GNBDUConfigurationUpdate;
1917 if(duCfgUpdate->protocolIEs.list.array != NULLP)
1919 for(ieIdx=0; ieIdx<duCfgUpdate->protocolIEs.list.count; ieIdx++)
1921 if(duCfgUpdate->protocolIEs.list.array[ieIdx] != NULLP)
1923 switch(duCfgUpdate->protocolIEs.list.array[ieIdx]->id)
1925 case ProtocolIE_ID_id_Served_Cells_To_Modify_List:
1927 cellsToModify = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1928 value.choice.Served_Cells_To_Modify_List;
1929 if(cellsToModify->list.array != NULLP)
1931 for(cellModifyIdx=0; cellModifyIdx<cellsToModify->list.count ;cellModifyIdx++)
1933 if(cellsToModify->list.array[cellModifyIdx] != NULLP)
1935 freeCellsToModifyItem(&cellsToModify->list.array[cellModifyIdx]->value.choice.\
1936 Served_Cells_To_Modify_Item);
1937 DU_FREE(cellsToModify->list.array[cellModifyIdx],\
1938 sizeof(Served_Cells_To_Modify_ItemIEs_t));
1941 DU_FREE(cellsToModify->list.array,cellsToModify->list.size);
1945 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
1947 cellsToDelete = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1948 value.choice.Served_Cells_To_Delete_List;
1949 if(cellsToDelete->list.array != NULLP)
1951 for(cellDeleteIdx=0; cellDeleteIdx<cellsToDelete->list.count ;cellDeleteIdx++)
1953 if(cellsToDelete->list.array[cellDeleteIdx] != NULLP)
1955 deleteItemIe = ((Served_Cells_To_Delete_ItemIEs_t*)\
1956 cellsToDelete->list.array[cellDeleteIdx]);
1957 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
1958 DU_FREE(deleteItem->oldNRCGI.pLMN_Identity.buf,\
1959 deleteItem->oldNRCGI.pLMN_Identity.size);
1960 DU_FREE(deleteItem->oldNRCGI.nRCellIdentity.buf,\
1961 deleteItem->oldNRCGI.nRCellIdentity.size);
1962 DU_FREE(cellsToDelete->list.array[cellDeleteIdx],\
1963 sizeof(Served_Cells_To_Delete_ItemIEs_t));
1966 DU_FREE(cellsToDelete->list.array,cellsToDelete->list.size);
1971 case ProtocolIE_ID_id_gNB_DU_ID:
1973 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1974 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1978 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx],\
1979 sizeof(GNBDUConfigurationUpdateIEs_t));
1982 DU_FREE(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
1984 DU_FREE(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
1986 DU_FREE(f1apDuCfg, (Size)sizeof(F1AP_PDU_t));
1990 /*******************************************************************
1992 * @brief Fills Served Plmns required in ServCellInfo IE
1996 * Function : fillServedPlmns
1998 * Functionality: Fills Served Plmns required in ServCellInfo IE
2000 * @params[in] Pointer to ServedPLMNs_List_t *
2002 * @return ROK - success
2005 *****************************************************************/
2007 uint8_t fillServedPlmns(ServedPLMNs_List_t *servedPlmn)
2009 uint8_t ieIdx, ieListCnt;
2011 servedPlmn->list.array[0]->pLMN_Identity.size = 3*sizeof(uint8_t);
2012 DU_ALLOC(servedPlmn->list.array[0]->pLMN_Identity.buf, servedPlmn->list.\
2013 array[0]->pLMN_Identity.size);
2014 if(servedPlmn->list.array[0]->pLMN_Identity.buf == NULLP)
2018 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.plmn[0],\
2019 servedPlmn->list.array[0]->pLMN_Identity.buf);
2020 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
2021 if(servedPlmn->list.array[0]->iE_Extensions == NULLP)
2027 servedPlmn->list.array[0]->iE_Extensions->list.count = ieListCnt;
2028 servedPlmn->list.array[0]->iE_Extensions->list.size = ieListCnt *sizeof(ServedPLMNs_ItemExtIEs_t *);
2029 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions->list.array,servedPlmn->list.array[0]->\
2030 iE_Extensions->list.size);
2031 if(servedPlmn->list.array[0]->iE_Extensions->list.array == NULLP)
2035 for(ieIdx=0;ieIdx<ieListCnt;ieIdx++)
2037 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions->list.array[ieIdx],\
2038 sizeof(ServedPLMNs_ItemExtIEs_t));
2039 if(servedPlmn->list.array[0]->iE_Extensions->list.array[ieIdx] == NULLP)
2044 //plmnIeExt = servedPlmn->list.array[0]->iE_Extensions;
2045 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->id =ProtocolIE_ID_id_TAISliceSupportList;
2046 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->criticality = Criticality_ignore;
2047 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->extensionValue.present = \
2048 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
2049 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2051 servedPlmn->list.array[0]->\
2052 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2053 list.size = sizeof(SliceSupportItem_t *);
2054 DU_ALLOC(servedPlmn->list.array[0]->\
2055 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2056 list.array,servedPlmn->list.array[0]->\
2057 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.size);
2058 if(servedPlmn->list.array[0]->\
2059 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2060 list.array == NULLP)
2065 DU_ALLOC(servedPlmn->list.array[0]->\
2066 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2067 list.array[0],sizeof( SliceSupportItem_t));
2068 if(servedPlmn->list.array[0]->\
2069 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2070 list.array[0] == NULLP)
2074 servedPlmn->list.array[0]->\
2075 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2076 list.array[0]->sNSSAI.sST.size = sizeof(uint8_t);
2077 DU_ALLOC(servedPlmn->list.array[0]->\
2078 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2079 list.array[0]->sNSSAI.sST.buf,servedPlmn->list.array[0]->\
2080 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.array[0]->sNSSAI.sST.size);
2081 if(servedPlmn->list.array[0]->\
2082 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2083 list.array[0]->sNSSAI.sST.buf == NULLP)
2087 servedPlmn->list.array[0]->\
2088 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2089 list.array[0]->sNSSAI.sST.buf[0] = 3;
2090 DU_ALLOC(servedPlmn->list.array[0]->\
2091 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2092 list.array[0]->sNSSAI.sD,sizeof(OCTET_STRING_t));
2093 if(servedPlmn->list.array[0]->\
2094 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2095 list.array[0]->sNSSAI.sD == NULLP)
2099 servedPlmn->list.array[0]->\
2100 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2101 list.array[0]->sNSSAI.sD->size = 3*sizeof(uint8_t);
2102 DU_ALLOC(servedPlmn->list.array[0]->\
2103 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2104 list.array[0]->sNSSAI.sD->buf,servedPlmn->list.array[0]->\
2105 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2106 list.array[0]->sNSSAI.sD->size);
2107 if(servedPlmn->list.array[0]->\
2108 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2109 list.array[0]->sNSSAI.sD->buf == NULLP)
2113 servedPlmn->list.array[0]->\
2114 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2115 list.array[0]->sNSSAI.sD->buf[0] = 3;
2116 servedPlmn->list.array[0]->\
2117 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2118 list.array[0]->sNSSAI.sD->buf[1] = 6;
2119 servedPlmn->list.array[0]->\
2120 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2121 list.array[0]->sNSSAI.sD->buf[2] = 9;
2125 /*******************************************************************
2127 * @brief Fills Nr Fdd Info required in ServCellInfo IE
2131 * Function : fillNrFddInfo
2133 * Functionality: Fills Nr Fdd Info required in ServCellInfo IE
2135 * @params[in] Pointer to NR_Mode_Info_t *
2137 * @return ROK - success
2140 *****************************************************************/
2142 uint8_t fillNrFddInfo(NR_Mode_Info_t *nrFdd)
2144 nrFdd->choice.fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
2145 f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn;
2146 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
2147 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
2148 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
2149 array, nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
2150 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2154 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
2155 sizeof(FreqBandNrItem_t));
2156 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2160 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2161 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
2162 freqBand[0].nrFreqBand;
2163 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2164 nrFdd->choice.fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
2165 dlNrFreqInfo.nrArfcn;
2166 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
2167 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
2168 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,nrFdd->\
2169 choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
2170 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2174 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0],\
2175 sizeof(FreqBandNrItem_t));
2176 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2180 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2181 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
2182 freqBand[0].nrFreqBand;
2183 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2185 /*Transmission Bandwidth*/
2186 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2187 f1Mode.mode.fdd.ulTxBw.nrScs;
2188 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2189 f1Mode.mode.fdd.ulTxBw.nrb;
2190 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2191 f1Mode.mode.fdd.dlTxBw.nrScs;
2192 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2193 f1Mode.mode.fdd.dlTxBw.nrb;
2198 /*******************************************************************
2200 * @brief Fills ServCellInfo IE
2204 * Function : fillServedCellInfo
2206 * Functionality: Fills ServCellInfo
2208 * @params[in] Pointer to Served_Cell_Information_t *
2210 * @return ROK - success
2213 *****************************************************************/
2215 uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
2217 uint8_t tmp, ieIdx, ieListCnt;
2220 srvCellInfo->nRCGI.pLMN_Identity.size =3*sizeof(uint8_t);
2221 DU_ALLOC(srvCellInfo->nRCGI.pLMN_Identity.buf,\
2222 srvCellInfo->nRCGI.pLMN_Identity.size);
2223 if(srvCellInfo->nRCGI.pLMN_Identity.buf == NULLP)
2227 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2228 srvCellInfo->nRCGI.pLMN_Identity.buf);
2229 srvCellInfo->nRCGI.nRCellIdentity.size =5*sizeof(uint8_t);
2230 DU_ALLOC(srvCellInfo->nRCGI.nRCellIdentity.buf,\
2231 srvCellInfo->nRCGI.nRCellIdentity.size);
2232 if(srvCellInfo->nRCGI.nRCellIdentity.buf == NULLP)
2236 for (tmp = 0 ; tmp < srvCellInfo->\
2237 nRCGI.nRCellIdentity.size-1 ; tmp++)
2239 srvCellInfo->nRCGI.nRCellIdentity.buf[tmp] = 0;
2241 srvCellInfo->nRCGI.nRCellIdentity.buf[4] = 16;
2242 srvCellInfo->nRCGI.nRCellIdentity.bits_unused =4;
2245 srvCellInfo->nRPCI = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
2249 srvCellInfo->servedPLMNs.list.count = ieListCnt;
2250 srvCellInfo->servedPLMNs.list.size = ieListCnt*sizeof(ServedPLMNs_Item_t *);
2251 DU_ALLOC(srvCellInfo->servedPLMNs.list.array,\
2252 srvCellInfo->servedPLMNs.list.size);
2253 if(srvCellInfo->servedPLMNs.list.array == NULLP)
2257 for(ieIdx=0; ieIdx < ieListCnt; ieIdx++)
2259 DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx],\
2260 sizeof(ServedPLMNs_Item_t));
2261 if(srvCellInfo->servedPLMNs.list.array[ieIdx]== NULLP)
2266 if(fillServedPlmns(&srvCellInfo->servedPLMNs))
2271 /*nR Mode Info with FDD*/
2272 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_fDD;
2273 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD,\
2274 sizeof(FDD_Info_t));
2275 if(srvCellInfo->nR_Mode_Info.choice.fDD == NULLP)
2279 if(fillNrFddInfo(&srvCellInfo->nR_Mode_Info))
2282 /*Measurement timing Config*/
2283 srvCellInfo->measurementTimingConfiguration.size = sizeof(uint8_t);
2284 DU_ALLOC(srvCellInfo->measurementTimingConfiguration.\
2285 buf,srvCellInfo->measurementTimingConfiguration.size);
2286 if(srvCellInfo->measurementTimingConfiguration.buf == NULLP)
2290 srvCellInfo->measurementTimingConfiguration.\
2291 buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
2296 /*******************************************************************
2298 * @brief Fills ServCellToModItem IE
2302 * Function : fillServCellToModItem
2304 * Functionality: Fills ServCellToModItem IE
2306 * @params[in] Pointer to Served_Cells_To_Modify_Item_t *
2308 * @return ROK - success
2311 *****************************************************************/
2313 uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
2318 modifyItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2319 DU_ALLOC(modifyItem->oldNRCGI.pLMN_Identity.buf,modifyItem->oldNRCGI.pLMN_Identity.size);
2320 if(modifyItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2324 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2325 modifyItem->oldNRCGI.pLMN_Identity.buf);
2328 modifyItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2329 DU_ALLOC(modifyItem->oldNRCGI.nRCellIdentity.buf,\
2330 modifyItem->oldNRCGI.nRCellIdentity.size);
2331 if(modifyItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2335 for(ieIdx = 0; ieIdx < modifyItem->oldNRCGI.nRCellIdentity.size-1; ieIdx++)
2337 modifyItem->oldNRCGI.nRCellIdentity.buf[ieIdx] = 0;
2339 modifyItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2340 modifyItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2342 if(fillServedCellInfo(&modifyItem->served_Cell_Information))
2348 /*******************************************************************
2350 * @brief Builds ServCellToModList
2354 * Function : buildServCellToModList
2356 * Functionality: Builds the serv cell to Mod List
2358 * @params[in] Pointer to Served_Cells_To_Modify_List_t *
2360 * @return ROK - success
2363 *****************************************************************/
2365 uint8_t buildServCellToModList(Served_Cells_To_Modify_List_t *cellsToModify)
2367 uint8_t ieListCnt, ieIdx;
2368 Served_Cells_To_Modify_Item_t *modifyItem = NULLP;
2371 cellsToModify->list.count = ieListCnt;
2372 cellsToModify->list.size = ieListCnt*sizeof(Served_Cells_To_Modify_ItemIEs_t *);
2373 DU_ALLOC(cellsToModify->list.array,cellsToModify->list.size);
2374 if(cellsToModify->list.array == NULLP)
2378 for(ieIdx=0; ieIdx< ieListCnt; ieIdx++)
2380 DU_ALLOC(cellsToModify->list.array[ieIdx],sizeof(Served_Cells_To_Modify_ItemIEs_t));
2381 if(cellsToModify->list.array[ieIdx] == NULLP)
2386 cellsToModify->list.array[0]->id = ProtocolIE_ID_id_Served_Cells_To_Modify_Item;
2387 cellsToModify->list.array[0]->criticality = Criticality_reject;
2388 cellsToModify->list.array[0]->value.present =\
2389 Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item;
2390 modifyItem=&cellsToModify->list.array[0]->value.choice.Served_Cells_To_Modify_Item;
2392 if(fillServCellToModItem(modifyItem))
2397 /*******************************************************************
2399 * @brief filling the DeleteItemList
2403 * Function : fillCellToDeleteItem
2405 * Functionality: Filling the DeleteItemIe
2407 * @params[in] Pointer to Served_Cells_To_Delete_ItemIEs_t
2409 * @return ROK - success
2412 *****************************************************************/
2413 uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe)
2416 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
2418 deleteItemIe->id = ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
2419 deleteItemIe->criticality = Criticality_reject;
2420 deleteItemIe->value.present =\
2421 Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item;
2422 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
2425 deleteItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2426 DU_ALLOC(deleteItem->oldNRCGI.pLMN_Identity.buf,deleteItem->oldNRCGI.pLMN_Identity.size);
2427 if(deleteItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2429 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2432 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2433 deleteItem->oldNRCGI.pLMN_Identity.buf);
2436 deleteItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2437 DU_ALLOC(deleteItem->oldNRCGI.nRCellIdentity.buf,\
2438 deleteItem->oldNRCGI.nRCellIdentity.size);
2439 if(deleteItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2441 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2444 for(arrIdx = 0; arrIdx < deleteItem->oldNRCGI.nRCellIdentity.size-1; arrIdx++)
2446 deleteItem->oldNRCGI.nRCellIdentity.buf[arrIdx] = 0;
2448 deleteItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2449 deleteItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2452 /*******************************************************************
2454 * @brief Builds ServCellToDeleteList
2458 * Function : buildServCellToDeleteList
2460 * Functionality: Builds the serv cell to delete List
2462 * @params[in] Pointer to Served_Cells_To_Delete_List_t *
2464 * @return ROK - success
2467 *****************************************************************/
2469 uint8_t buildServCellToDeleteList(Served_Cells_To_Delete_List_t *cellsToDelete)
2471 uint8_t ieListCnt, arrIdx;
2474 cellsToDelete->list.count = ieListCnt;
2475 cellsToDelete->list.size = ieListCnt*sizeof(Served_Cells_To_Delete_ItemIEs_t *);
2477 DU_ALLOC(cellsToDelete->list.array,cellsToDelete->list.size);
2478 if(cellsToDelete->list.array == NULLP)
2480 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2484 for(arrIdx=0; arrIdx< ieListCnt; arrIdx++)
2486 DU_ALLOC(cellsToDelete->list.array[arrIdx],sizeof(Served_Cells_To_Delete_ItemIEs_t));
2487 if(cellsToDelete->list.array[arrIdx] == NULLP)
2489 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2495 if(fillCellToDeleteItem((Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx]) !=ROK)
2497 DU_LOG("\nERROR --> F1AP: buildServCellToDeleteList(): failed to fill Served_Cells_To_Delete_ItemIEs");
2503 /*******************************************************************
2505 * @brief Builds and sends the DUConfigUpdate
2509 * Function : BuildAndSendDUConfigUpdate
2511 * Functionality: Constructs the DU Update message and sends
2512 * it to the CU through SCTP.
2514 * @params[in] void **buf,Buffer to which encoded pattern is written into
2515 * @params[in] int *size,size of buffer
2517 * @return ROK - success
2520 * ****************************************************************/
2521 uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
2523 uint8_t ret =0, ieIdx=0, elementCnt=0;
2524 bool memAlloctionFailure = false;
2525 F1AP_PDU_t *f1apDuCfg = NULLP;
2526 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
2527 asn_enc_rval_t encRetVal; /* Encoder return value */
2529 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2534 DU_LOG("\nINFO --> F1AP : Building DU config update\n");
2535 /* Allocate the memory for F1DuCfg */
2536 DU_ALLOC(f1apDuCfg, sizeof(F1AP_PDU_t));
2537 if(f1apDuCfg == NULLP)
2539 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2543 f1apDuCfg->present = F1AP_PDU_PR_initiatingMessage;
2544 DU_ALLOC(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2545 if(f1apDuCfg->choice.initiatingMessage == NULLP)
2547 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2551 f1apDuCfg->choice.initiatingMessage->procedureCode = \
2552 ProcedureCode_id_gNBDUConfigurationUpdate;
2553 f1apDuCfg->choice.initiatingMessage->criticality = Criticality_reject;
2554 f1apDuCfg->choice.initiatingMessage->value.present = \
2555 InitiatingMessage__value_PR_GNBDUConfigurationUpdate;
2556 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->value.\
2557 choice.GNBDUConfigurationUpdate;
2559 duCfgUpdate->protocolIEs.list.count = elementCnt;
2560 duCfgUpdate->protocolIEs.list.size = \
2561 elementCnt * sizeof(GNBDUConfigurationUpdateIEs_t*);
2563 /* Initialize the F1Setup members */
2564 DU_ALLOC(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2565 if(duCfgUpdate->protocolIEs.list.array == NULLP)
2567 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2570 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
2572 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx],sizeof(GNBDUConfigurationUpdateIEs_t));
2573 if(duCfgUpdate->protocolIEs.list.array[ieIdx] == NULLP)
2575 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2576 memAlloctionFailure = true;
2581 if(memAlloctionFailure == true)
2587 duCfgUpdate->protocolIEs.list.array[ieIdx]->id=ProtocolIE_ID_id_TransactionID;
2588 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
2589 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2590 GNBDUConfigurationUpdateIEs__value_PR_TransactionID;
2591 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = TRANS_ID;
2594 if(servCellAction == SERV_CELL_TO_MODIFY)
2596 /*Served Cell to Modify */
2597 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2598 ProtocolIE_ID_id_Served_Cells_To_Modify_List;
2599 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2600 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2601 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List;
2602 if(buildServCellToModList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2603 Served_Cells_To_Modify_List))
2605 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToModList");
2611 /*Served Cell to Delete */
2612 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2613 ProtocolIE_ID_id_Served_Cells_To_Delete_List;
2614 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2615 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2616 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List;
2617 if(buildServCellToDeleteList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2618 Served_Cells_To_Delete_List)!=ROK)
2620 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToDeleteList");
2625 // NOTE :GNB DU SYS INFO:MIB AND SIB1 INFORMATION TO BE BUILT AND FILLED HERE
2628 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
2629 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
2630 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2631 GNBDUConfigurationUpdateIEs__value_PR_GNB_DU_ID;
2632 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size = sizeof(uint8_t);
2633 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2634 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2635 if(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == NULLP)
2637 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): Memory allocation failed for GNB_DU_ID");
2640 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] = duCfgParam.duId;
2642 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apDuCfg);
2644 /* Encode the DU Config Update type as APER */
2645 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2647 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apDuCfg, PrepFinalEncBuf, encBuf);
2649 /* Checking encode results */
2650 if(encRetVal.encoded == ENCODE_FAIL)
2652 DU_LOG("ERROR --> F1AP : Could not encode DUConfigUpdate structure (at %s)\n",\
2653 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2658 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DUConfigUpdate\n");
2659 for(ieIdx =0; ieIdx < encBufSize; ieIdx++)
2661 printf("%x",encBuf[ieIdx]);
2665 if(sendF1APMsg() != ROK)
2667 DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed");
2675 addToReservedF1apPduList(TRANS_ID,f1apDuCfg);
2680 /*******************************************************************
2682 * @brief free the ULRRCMessageTransfer
2686 * Function : FreeULRRCMessageTransfer
2688 * Functionality: Deallocating the memory of variable allocated in
2689 * FreeULRRCMessageTransfer
2693 * @return ROK - void
2695 ******************************************************************/
2696 void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
2699 ULRRCMessageTransfer_t *ulRRCMsg;
2701 if(f1apMsg != NULLP)
2703 if(f1apMsg->choice.initiatingMessage != NULLP)
2705 ulRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2706 if(ulRRCMsg->protocolIEs.list.array != NULLP)
2708 for(idx1=0;idx1<ulRRCMsg->protocolIEs.list.count;idx1++)
2710 if(ulRRCMsg->protocolIEs.list.array[idx1] != NULLP)
2712 if(ulRRCMsg->protocolIEs.list.array[idx1]->value.present ==
2713 ULRRCMessageTransferIEs__value_PR_RRCContainer)
2715 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2716 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2718 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1],sizeof(ULRRCMessageTransferIEs_t));
2721 DU_FREE(ulRRCMsg->protocolIEs.list.array,ulRRCMsg->protocolIEs.list.size );
2723 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2725 DU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
2728 /*******************************************************************
2730 * @brief Builds and sends the ULRRCMessageTransfer
2734 * Function : BuildAndSendULRRCMessageTransfer
2736 * Functionality: Constructs the UL RRC Message Transfer and sends
2737 * it to the CU through SCTP.
2741 * @return ROK - success
2744 * ****************************************************************/
2745 uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \
2746 uint16_t msgLen, uint8_t *rrcMsg)
2748 uint8_t elementCnt =0;
2751 F1AP_PDU_t *f1apMsg = NULLP;
2752 ULRRCMessageTransfer_t *ulRRCMsg = NULLP;
2753 asn_enc_rval_t encRetVal; /* Encoder return value */
2754 uint8_t ret =RFAILED;
2756 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2760 DU_LOG("\n INFO --> F1AP : Building UL RRC Message Transfer Message\n");
2762 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
2763 if(f1apMsg == NULLP)
2765 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2768 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
2769 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2770 if(f1apMsg->choice.initiatingMessage == NULLP)
2772 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2775 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_ULRRCMessageTransfer;
2776 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
2777 f1apMsg->choice.initiatingMessage->value.present = \
2778 InitiatingMessage__value_PR_ULRRCMessageTransfer;
2780 &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2782 ulRRCMsg->protocolIEs.list.count = elementCnt;
2783 ulRRCMsg->protocolIEs.list.size = \
2784 elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
2786 /* Initialize the F1Setup members */
2787 DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
2788 if(ulRRCMsg->protocolIEs.list.array == NULLP)
2790 DU_LOG(" ERROR --> F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
2793 for(idx=0; idx<elementCnt; idx++)
2795 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
2796 if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
2804 /*GNB CU UE F1AP ID*/
2805 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
2806 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2807 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2808 ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
2809 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb.gnbCuUeF1apId;
2811 /*GNB DU UE F1AP ID*/
2813 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
2814 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2815 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2816 ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
2817 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb.gnbDuUeF1apId;
2821 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
2822 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2823 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2824 ULRRCMessageTransferIEs__value_PR_SRBID;
2825 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = lcId;
2829 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCContainer;
2830 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2831 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2832 ULRRCMessageTransferIEs__value_PR_RRCContainer;
2833 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = msgLen;
2834 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2835 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
2836 if(!ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
2838 DU_LOG(" ERROR --> F1AP : Memory allocation for BuildAndSendULRRCMessageTransfer failed");
2841 memset(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, 0, msgLen);
2842 memcpy(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, \
2843 rrcMsg, ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2845 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
2847 /* Encode the F1SetupRequest type as APER */
2848 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2850 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
2852 /* Encode results */
2853 if(encRetVal.encoded == ENCODE_FAIL)
2855 DU_LOG( "\nERROR --> F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
2856 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2861 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
2862 for(int i=0; i< encBufSize; i++)
2864 printf("%x",encBuf[i]);
2869 if(sendF1APMsg() != ROK)
2871 DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed");
2877 FreeULRRCMessageTransfer(f1apMsg);
2880 }/* End of BuildAndSendULRRCMessageTransfer*/
2882 /*******************************************************************
2884 * @brief Builds tag config
2888 * Function : BuildTagConfig
2890 * Functionality: Builds tag config in MacCellGroupConfig
2892 * @params[in] TAG_Config *tag_Config
2894 * @return ROK - success
2897 * ****************************************************************/
2898 uint8_t BuildTagConfig(struct TAG_Config *tagConfig)
2900 struct TAG_Config__tag_ToAddModList *tagList;
2901 uint8_t idx, elementCnt;
2903 tagConfig->tag_ToReleaseList = NULLP;
2904 tagConfig->tag_ToAddModList = NULLP;
2905 DU_ALLOC(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
2906 if(!tagConfig->tag_ToAddModList)
2908 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2912 elementCnt = 1; //ODU_VALUE_ONE;
2913 tagList = tagConfig->tag_ToAddModList;
2914 tagList->list.count = elementCnt;
2915 tagList->list.size = elementCnt * sizeof(struct TAG *);
2917 tagList->list.array = NULLP;
2918 DU_ALLOC(tagList->list.array, tagList->list.size);
2919 if(!tagList->list.array)
2921 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2925 for(idx=0; idx<tagList->list.count; idx++)
2927 tagList->list.array[idx] = NULLP;
2928 DU_ALLOC(tagList->list.array[idx], sizeof(struct TAG));
2929 if(!tagList->list.array[idx])
2931 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2937 tagList->list.array[idx]->tag_Id = TAG_ID;
2938 tagList->list.array[idx]->timeAlignmentTimer = TIME_ALIGNMENT_TMR;
2943 /*******************************************************************
2945 * @brief Builds PHR Config
2949 * Function : BuildPhrConfig
2951 * Functionality: Builds phrConfig in MacCellGroupConfig
2953 * @params[in] PHR Config *
2955 * @return ROK - success
2958 * ****************************************************************/
2959 uint8_t BuildPhrConfig(struct MAC_CellGroupConfig__phr_Config *phrConfig)
2962 phrConfig->present = MAC_CellGroupConfig__phr_Config_PR_setup;
2963 phrConfig->choice.setup = NULLP;
2964 DU_ALLOC(phrConfig->choice.setup, sizeof(struct PHR_Config));
2965 if(!phrConfig->choice.setup)
2967 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhrConfig");
2971 phrConfig->choice.setup->phr_PeriodicTimer = PHR_PERIODIC_TMR;
2972 phrConfig->choice.setup->phr_ProhibitTimer = PHR_PROHIBHIT_TMR;
2973 phrConfig->choice.setup->phr_Tx_PowerFactorChange = PHR_PWR_FACTOR_CHANGE;
2974 phrConfig->choice.setup->multiplePHR = false;
2975 phrConfig->choice.setup->dummy = false;
2976 phrConfig->choice.setup->phr_Type2OtherCell = false;
2977 phrConfig->choice.setup->phr_ModeOtherCG = PHR_MODE_OTHER_CG;
2982 /*******************************************************************
2984 * @brief Builds BSR Config
2988 * Function : BuildBsrConfig
2990 * Functionality: Builds BuildBsrConfig in MacCellGroupConfig
2992 * @params[in] BSR_Config *bsrConfig
2994 * @return ROK - success
2997 * ****************************************************************/
2998 uint8_t BuildBsrConfig(struct BSR_Config *bsrConfig)
3000 bsrConfig->periodicBSR_Timer = PERIODIC_BSR_TMR;
3001 bsrConfig->retxBSR_Timer = RETX_BSR_TMR;
3002 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
3007 /*******************************************************************
3009 * @brief Builds scheduling request config
3013 * Function : BuildSchedulingReqConfig
3015 * Functionality: Builds BuildSchedulingReqConfig in MacCellGroupConfig
3017 * @params[in] SchedulingRequestConfig *schedulingRequestConfig
3019 * @return ROK - success
3022 * ****************************************************************/
3023 uint8_t BuildSchedulingReqConfig(struct SchedulingRequestConfig *schedulingRequestConfig)
3025 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList;
3026 uint8_t idx, elementCnt;
3028 schedulingRequestConfig->schedulingRequestToAddModList = NULLP;
3029 DU_ALLOC(schedulingRequestConfig->schedulingRequestToAddModList,
3030 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList));
3031 if(!schedulingRequestConfig->schedulingRequestToAddModList)
3033 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3037 elementCnt = 1; //ODU_VALUE_ONE;
3038 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
3039 schReqList->list.count = elementCnt;
3040 schReqList->list.size = elementCnt * sizeof(struct SchedulingRequestToAddMod *);
3042 schReqList->list.array = NULLP;
3043 DU_ALLOC(schReqList->list.array, schReqList->list.size);
3044 if(!schReqList->list.array)
3046 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3050 for(idx=0;idx<schReqList->list.count; idx++)
3052 schReqList->list.array[idx] = NULLP;
3053 DU_ALLOC(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
3054 if(!schReqList->list.array[idx])
3056 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3062 schReqList->list.array[idx]->schedulingRequestId = SCH_REQ_ID;
3064 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
3065 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
3066 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
3068 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3071 *(schReqList->list.array[idx]->sr_ProhibitTimer) = SR_PROHIBIT_TMR;
3072 schReqList->list.array[idx]->sr_TransMax = SR_TRANS_MAX;
3073 schedulingRequestConfig->schedulingRequestToReleaseList = NULLP;
3078 /*******************************************************************
3080 * @brief Builds RLC Config
3084 * Function : BuildRlcConfig
3086 * Functionality: Builds RLC Config in BuildRlcBearerToAddModList
3088 * @params[in] RLC_Config *rlcConfig
3090 * @return ROK - success
3093 * ****************************************************************/
3094 uint8_t BuildRlcConfig(struct RLC_Config *rlcConfig)
3097 rlcConfig->present = RLC_Config_PR_am;
3099 rlcConfig->choice.am = NULLP;
3100 DU_ALLOC(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
3101 if(!rlcConfig->choice.am)
3103 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3108 rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength = NULLP;
3109 DU_ALLOC(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3110 if(!rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength)
3112 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3115 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3116 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = T_POLL_RETRANSMIT;
3117 rlcConfig->choice.am->ul_AM_RLC.pollPDU = POLL_PDU;
3118 rlcConfig->choice.am->ul_AM_RLC.pollByte = POLL_BYTE;
3119 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = MAX_RETX_THRESHOLD;
3122 rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength = NULLP;
3123 DU_ALLOC(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3124 if(!rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength)
3126 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3129 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3130 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = T_REASSEMBLY;
3131 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = T_STATUS_PROHIBHIT;
3136 /*******************************************************************
3138 * @brief Builds MAC LC Config
3142 * Function : BuildMacLCConfig
3144 * Functionality: Builds MAC LC Config in BuildRlcBearerToAddModList
3146 * @params[in] struct LogicalChannelConfig macLcConfig
3148 * @return ROK - success
3151 * ****************************************************************/
3152 uint8_t BuildMacLCConfig(struct LogicalChannelConfig *macLcConfig)
3155 macLcConfig->ul_SpecificParameters = NULLP;
3156 DU_ALLOC(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
3157 if(!macLcConfig->ul_SpecificParameters)
3159 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3163 macLcConfig->ul_SpecificParameters->priority = MAC_LC_PRIORITY;
3164 macLcConfig->ul_SpecificParameters->prioritisedBitRate = PRIORTISIED_BIT_RATE;
3165 macLcConfig->ul_SpecificParameters->bucketSizeDuration = BUCKET_SIZE_DURATION;
3166 macLcConfig->ul_SpecificParameters->allowedServingCells = NULLP;
3167 macLcConfig->ul_SpecificParameters->allowedSCS_List = NULLP;
3168 macLcConfig->ul_SpecificParameters->maxPUSCH_Duration = NULLP;
3169 macLcConfig->ul_SpecificParameters->configuredGrantType1Allowed = NULLP;
3171 macLcConfig->ul_SpecificParameters->logicalChannelGroup = NULLP;
3172 DU_ALLOC(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
3173 if(!macLcConfig->ul_SpecificParameters->logicalChannelGroup)
3175 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3178 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = LC_GRP;
3180 macLcConfig->ul_SpecificParameters->schedulingRequestID = NULLP;
3181 DU_ALLOC(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
3182 if(!macLcConfig->ul_SpecificParameters->schedulingRequestID)
3184 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3187 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = SCH_REQ_ID;
3189 macLcConfig->ul_SpecificParameters->logicalChannelSR_Mask = false;
3190 macLcConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false;
3191 macLcConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULLP;
3196 /*******************************************************************
3198 * @brief Builds RLC Bearer to Add/Mod list
3202 * Function :BuildRlcBearerToAddModList
3204 * Functionality: Builds RLC Bearer to Add/Mod list in DuToCuRrcContainer
3206 * @params[in] rlc_BearerToAddModList
3208 * @return ROK - success
3211 * ****************************************************************/
3212 uint8_t BuildRlcBearerToAddModList(struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList)
3214 uint8_t idx, elementCnt;
3217 rlcBearerList->list.count = elementCnt;
3218 rlcBearerList->list.size = elementCnt * sizeof(struct RLC_BearerConfig *);
3220 rlcBearerList->list.array = NULLP;
3221 DU_ALLOC(rlcBearerList->list.array, rlcBearerList->list.size);
3222 if(!rlcBearerList->list.array)
3224 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3228 for(idx=0; idx<rlcBearerList->list.count; idx++)
3230 rlcBearerList->list.array[idx] = NULLP;
3231 DU_ALLOC(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
3232 if(!rlcBearerList->list.array[idx])
3234 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3240 rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
3242 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, \
3243 sizeof(struct RLC_BearerConfig__servedRadioBearer));
3244 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3246 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3250 rlcBearerList->list.array[idx]->servedRadioBearer->present = \
3251 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
3252 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = \
3255 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3256 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3257 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3258 if(!rlcBearerList->list.array[idx]->rlc_Config)
3260 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3264 if(BuildRlcConfig(rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3266 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3270 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3271 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, \
3272 sizeof(struct LogicalChannelConfig));
3273 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3275 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3279 if(BuildMacLCConfig(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3281 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3288 /*******************************************************************
3290 * @brief Build Control resource set to add/modify list
3294 * Function : BuildControlRSetToAddModList
3296 * Functionality: Build Control resource set to add/modify list
3299 * struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3301 * @return ROK - success
3304 * ****************************************************************/
3305 uint8_t BuildControlRSetToAddModList
3307 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3312 uint8_t numBytes, bitsUnused;
3313 struct ControlResourceSet *controlRSet;
3314 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
3315 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
3319 controlRSetList->list.count = elementCnt;
3320 controlRSetList->list.size = \
3321 elementCnt * sizeof(struct ControlResourceSet *);
3323 controlRSetList->list.array = NULLP;
3324 DU_ALLOC(controlRSetList->list.array, controlRSetList->list.size);
3325 if(!controlRSetList->list.array)
3327 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3331 for(idx = 0; idx < elementCnt; idx++)
3333 controlRSetList->list.array[idx] = NULLP;
3334 DU_ALLOC(controlRSetList->list.array[idx], sizeof(struct ControlResourceSet));
3335 if(!controlRSetList->list.array[idx])
3337 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3343 controlRSet = controlRSetList->list.array[idx];
3345 controlRSet->controlResourceSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
3349 * Bit string stored ff0000000000
3353 controlRSet->frequencyDomainResources.size = numBytes * sizeof(uint8_t);
3355 controlRSet->frequencyDomainResources.buf = NULLP;
3356 DU_ALLOC(controlRSet->frequencyDomainResources.buf, \
3357 controlRSet->frequencyDomainResources.size);
3358 if(!controlRSet->frequencyDomainResources.buf)
3360 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3364 memset(controlRSet->frequencyDomainResources.buf, 0, FREQ_DOM_RSRC_SIZE);
3365 coreset0EndPrb = CORESET0_END_PRB;
3366 coreset1StartPrb = coreset0EndPrb + 6;
3367 coreset1NumPrb = CORESET1_NUM_PRB;
3368 /* calculate the PRBs */
3369 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
3370 memcpy(controlRSet->frequencyDomainResources.buf, freqDomainResource, FREQ_DOM_RSRC_SIZE);
3371 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3373 controlRSet->duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
3374 controlRSet->cce_REG_MappingType.present = \
3375 ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
3377 controlRSet->precoderGranularity = PDCCH_CTRL_RSRC_SET_ONE_PRECOD_GRANULARITY;
3378 controlRSet->tci_StatesPDCCH_ToAddList = NULLP;
3379 controlRSet->tci_StatesPDCCH_ToReleaseList = NULLP;
3380 controlRSet->tci_PresentInDCI = NULLP;
3382 uint8_t tciStateIdx;
3384 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList, \
3385 sizeof(struct ControlResourceSet__tci_StatesPDCCH_ToAddList));
3386 if(!controlRset->tci_StatesPDCCH_ToAddList)
3388 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3393 controlRset->tci_StatesPDCCH_ToAddList->list.count = elementCnt;
3394 controlRset->tci_StatesPDCCH_ToAddList->list.size = elementCnt * sizeof(TCI_StateId_t *);
3395 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array, \
3396 controlRset->tci_StatesPDCCH_ToAddList->list.size)
3397 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array)
3399 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3403 for(tciStateIdx = 0; tciStateIdx <elementCntl; tciStateIdx++)
3405 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx], sizeof(TCI_StateId_t));
3406 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx])
3408 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3415 *(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx]);
3417 DU_ALLOC(controlRset->tci_PresentInDCI, sizeof(long));
3418 if(!controlRset->tci_PresentInDCI)
3420 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3424 *(controlRset->tci_PresentInDCI);
3427 controlRSet->pdcch_DMRS_ScramblingID = NULLP;
3428 DU_ALLOC(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
3429 if(!controlRSet->pdcch_DMRS_ScramblingID)
3431 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3434 *(controlRSet->pdcch_DMRS_ScramblingID) = SCRAMBLING_ID;
3437 } /* End BuildControlRSetToAddModList */
3439 /*******************************************************************
3441 * @brief Build search space to add/modify list
3445 * Function : BuildSearchSpcToAddModList
3447 * Functionality: Build search space to add/modify list
3450 * @return ROK - success
3453 * ****************************************************************/
3454 uint8_t BuildSearchSpcToAddModList
3456 struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
3464 struct SearchSpace *searchSpc;
3467 searchSpcList->list.count = elementCnt;
3468 searchSpcList->list.size = elementCnt * sizeof(struct SearchSpace *);
3470 searchSpcList->list.array = NULLP;
3471 DU_ALLOC(searchSpcList->list.array, searchSpcList->list.size);
3472 if(!searchSpcList->list.array)
3474 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3478 for(idx = 0; idx < elementCnt; idx++)
3480 searchSpcList->list.array[idx] = NULLP;
3481 DU_ALLOC(searchSpcList->list.array[idx], sizeof(struct SearchSpace));
3482 if(!searchSpcList->list.array[idx])
3484 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3490 searchSpc = searchSpcList->list.array[idx];
3492 searchSpc->searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
3494 searchSpc->controlResourceSetId = NULLP;
3495 DU_ALLOC(searchSpc->controlResourceSetId, sizeof(ControlResourceSetId_t));
3496 if(!searchSpc->controlResourceSetId)
3498 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3501 *(searchSpc->controlResourceSetId) = PDCCH_CTRL_RSRC_SET_ONE_ID;
3503 searchSpc->monitoringSlotPeriodicityAndOffset = NULLP;
3504 DU_ALLOC(searchSpc->monitoringSlotPeriodicityAndOffset, \
3505 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
3506 if(!searchSpc->monitoringSlotPeriodicityAndOffset)
3508 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3511 searchSpc->monitoringSlotPeriodicityAndOffset->present = \
3512 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
3514 searchSpc->duration = NULLP;
3515 searchSpc->monitoringSymbolsWithinSlot = NULLP;
3516 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot, sizeof(BIT_STRING_t));
3517 if(!searchSpc->monitoringSymbolsWithinSlot)
3519 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3523 /* Values taken from reference logs :
3526 * Bit string stores 8000
3531 searchSpc->monitoringSymbolsWithinSlot->size = numBytes * sizeof(uint8_t);
3532 searchSpc->monitoringSymbolsWithinSlot->buf = NULLP;
3533 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot->buf, \
3534 searchSpc->monitoringSymbolsWithinSlot->size);
3535 if(!searchSpc->monitoringSymbolsWithinSlot->buf)
3537 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3542 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = \
3543 PDCCH_SYMBOL_WITHIN_SLOT /* setting MSB to 128 i.e. 0x80 */;
3544 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = 0;
3545 searchSpc->monitoringSymbolsWithinSlot->bits_unused = bitsUnused;
3547 searchSpc->nrofCandidates = NULLP;
3548 DU_ALLOC(searchSpc->nrofCandidates, sizeof(struct SearchSpace__nrofCandidates));
3549 if(!searchSpc->nrofCandidates)
3551 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3555 searchSpc->nrofCandidates->aggregationLevel1 = \
3556 PDCCH_SRCH_SPC_TWO_AGG_LVL1_CANDIDATE;
3557 searchSpc->nrofCandidates->aggregationLevel2 = \
3558 PDCCH_SRCH_SPC_TWO_AGG_LVL2_CANDIDATE;
3559 searchSpc->nrofCandidates->aggregationLevel4 = \
3560 PDCCH_SRCH_SPC_TWO_AGG_LVL4_CANDIDATE;
3561 searchSpc->nrofCandidates->aggregationLevel8 = \
3562 PDCCH_SRCH_SPC_TWO_AGG_LVL8_CANDIDATE;
3563 searchSpc->nrofCandidates->aggregationLevel16 = \
3564 PDCCH_SRCH_SPC_TWO_AGG_LVL16_CANDIDATE;
3566 searchSpc->searchSpaceType = NULLP;
3567 DU_ALLOC(searchSpc->searchSpaceType, sizeof(struct SearchSpace__searchSpaceType));
3568 if(!searchSpc->searchSpaceType)
3570 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3574 searchSpc->searchSpaceType->present = SearchSpace__searchSpaceType_PR_ue_Specific;
3576 searchSpc->searchSpaceType->choice.ue_Specific = NULLP;
3577 DU_ALLOC(searchSpc->searchSpaceType->choice.ue_Specific, \
3578 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
3579 if(!searchSpc->searchSpaceType->choice.ue_Specific)
3581 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3584 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = \
3585 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
3588 }/* End BuildSearchSpcToAddModList */
3590 /*******************************************************************
3592 * @brief Builds BWP DL dedicated PDCCH config
3596 * Function : BuildBWPDlDedPdcchCfg
3598 * Functionality: Builds BWP DL dedicated PDCCH config
3600 * @params[in] struct PDCCH_Config *pdcchCfg
3602 * @return ROK - success
3605 * ****************************************************************/
3606 uint8_t BuildBWPDlDedPdcchCfg(struct PDCCH_Config *pdcchCfg)
3608 pdcchCfg->controlResourceSetToAddModList = NULLP;
3609 DU_ALLOC(pdcchCfg->controlResourceSetToAddModList, \
3610 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
3611 if(!pdcchCfg->controlResourceSetToAddModList)
3613 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3617 if(BuildControlRSetToAddModList(pdcchCfg->controlResourceSetToAddModList) != ROK)
3622 pdcchCfg->controlResourceSetToReleaseList = NULLP;
3624 pdcchCfg->searchSpacesToAddModList = NULLP;
3625 DU_ALLOC(pdcchCfg->searchSpacesToAddModList, \
3626 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
3627 if(!pdcchCfg->searchSpacesToAddModList)
3629 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3633 if(BuildSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList) != ROK)
3638 pdcchCfg->searchSpacesToReleaseList = NULLP;
3639 pdcchCfg->downlinkPreemption = NULLP;
3640 pdcchCfg->tpc_PUSCH = NULLP;
3641 pdcchCfg->tpc_PUCCH = NULLP;
3642 pdcchCfg->tpc_SRS = NULLP;
3647 /*******************************************************************
3649 * @brief Builds DMRS DL PDSCH Mapping type A
3653 * Function : BuildDMRSDLPdschMapTypeA
3655 * Functionality: Builds DMRS DL PDSCH Mapping type A
3658 * struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3659 * @return ROK - success
3662 * ****************************************************************/
3663 uint8_t BuildDMRSDLPdschMapTypeA
3665 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3668 dmrsDlCfg->present = PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup;
3669 dmrsDlCfg->choice.setup = NULLP;
3670 DU_ALLOC(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
3671 if(!dmrsDlCfg->choice.setup)
3673 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3677 dmrsDlCfg->choice.setup->dmrs_Type = NULLP;
3678 dmrsDlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
3679 DU_ALLOC(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
3680 if(!dmrsDlCfg->choice.setup->dmrs_AdditionalPosition)
3682 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3685 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
3687 dmrsDlCfg->choice.setup->maxLength = NULLP;
3688 dmrsDlCfg->choice.setup->scramblingID0 = NULLP;
3689 dmrsDlCfg->choice.setup->scramblingID1 = NULLP;
3690 dmrsDlCfg->choice.setup->phaseTrackingRS = NULLP;
3695 /*******************************************************************
3697 * @brief Builds TCI states to add/modify list
3701 * Function : BuildTCIStatesToAddModList
3703 * Functionality:Builds TCI states to add/modify list
3706 * struct PDSCH_Config__tci_StatesToAddModList *tciStatesList
3708 * @return ROK - success
3711 * ****************************************************************/
3712 uint8_t BuildTCIStatesToAddModList(struct PDSCH_Config__tci_StatesToAddModList *tciStatesList)
3717 /*******************************************************************
3719 * @brief Builds PDSCH time domain allocation list
3723 * Function : BuildPdschTimeDomAllocList
3725 * Functionality: Builds PDSCH time domain allocation list
3728 * struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3730 * @return ROK - success
3733 * ****************************************************************/
3734 uint8_t BuildPdschTimeDomAllocList
3736 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3741 struct PDSCH_TimeDomainResourceAllocation *timeDomAlloc;
3743 timeDomAllocList->present = \
3744 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup;
3746 timeDomAllocList->choice.setup = NULLP;
3747 DU_ALLOC(timeDomAllocList->choice.setup, \
3748 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
3749 if(!timeDomAllocList->choice.setup)
3751 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3756 timeDomAllocList->choice.setup->list.count = elementCnt;
3757 timeDomAllocList->choice.setup->list.size = \
3758 elementCnt * sizeof(struct PDSCH_TimeDomainResourceAllocation *);
3760 timeDomAllocList->choice.setup->list.array = NULLP;
3761 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
3762 timeDomAllocList->choice.setup->list.size);
3763 if(!timeDomAllocList->choice.setup->list.array)
3765 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3769 for(idx = 0; idx < elementCnt; idx++)
3771 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
3772 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], \
3773 sizeof(struct PDSCH_TimeDomainResourceAllocation));
3774 if(!timeDomAllocList->choice.setup->list.array[idx])
3776 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3782 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
3784 timeDomAlloc->k0 = NULLP;
3785 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
3786 timeDomAlloc->startSymbolAndLength = \
3787 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
3792 /*******************************************************************
3794 * @brief Builds PDSCH PRB Bundling type
3798 * Function : BuildPdschPrbBundlingType
3800 * Functionality: Builds PDSCH PRB Bundling type
3803 * struct PDSCH_Config__prb_BundlingType *prbBndlType
3805 * @return ROK - success
3808 * ****************************************************************/
3809 uint8_t BuildPdschPrbBundlingType
3811 struct PDSCH_Config__prb_BundlingType *prbBndlType
3814 prbBndlType->present = PDSCH_Config__prb_BundlingType_PR_staticBundling;
3816 prbBndlType->choice.staticBundling = NULLP;
3817 DU_ALLOC(prbBndlType->choice.staticBundling, \
3818 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
3819 if(!prbBndlType->choice.staticBundling)
3821 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschPrbBundlingType");
3824 prbBndlType->choice.staticBundling->bundleSize = NULLP;
3829 /*******************************************************************
3831 * @brief Builds BWP DL dedicated PDSCH config
3835 * Function : BuildBWPDlDedPdschCfg
3837 * Functionality: Builds BWP DL dedicated PDSCH config
3839 * @params[in] struct PDSCH_Config *pdschCfg
3841 * @return ROK - success
3844 * ****************************************************************/
3845 uint8_t BuildBWPDlDedPdschCfg(struct PDSCH_Config *pdschCfg)
3847 pdschCfg->dataScramblingIdentityPDSCH = NULLP;
3849 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA = NULLP;
3850 DU_ALLOC(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
3851 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
3852 if(!pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
3854 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3858 if(BuildDMRSDLPdschMapTypeA(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA) != ROK)
3863 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeB = NULLP;
3864 pdschCfg->tci_StatesToAddModList = NULLP;
3865 pdschCfg->tci_StatesToReleaseList = NULLP;
3866 pdschCfg->vrb_ToPRB_Interleaver = NULLP;
3868 DU_ALLOC(pdschCfg->tci_StatesToAddModList, sizeof(struct PDSCH_Config__tci_StatesToAddModList));
3869 if(!pdschCfg->tci_StatesToAddModList)
3871 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3874 if(BuildTCIStatesToAddModList(pdschCfg->tci_StatesToAddModList) != ROK)
3880 pdschCfg->resourceAllocation = RES_ALLOC_TYPE;
3882 pdschCfg->pdsch_TimeDomainAllocationList = NULLP;
3883 DU_ALLOC(pdschCfg->pdsch_TimeDomainAllocationList, \
3884 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
3885 if(!pdschCfg->pdsch_TimeDomainAllocationList)
3887 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3891 if(BuildPdschTimeDomAllocList(pdschCfg->pdsch_TimeDomainAllocationList) != ROK)
3896 pdschCfg->pdsch_AggregationFactor = NULLP;
3897 pdschCfg->rateMatchPatternToAddModList = NULLP;
3898 pdschCfg->rateMatchPatternToReleaseList = NULLP;
3899 pdschCfg->rateMatchPatternGroup1 = NULLP;
3900 pdschCfg->rateMatchPatternGroup2 = NULLP;
3901 pdschCfg->rbg_Size = PDSCH_RBG_SIZE;
3902 pdschCfg->mcs_Table = NULLP;
3904 pdschCfg->maxNrofCodeWordsScheduledByDCI = NULLP;
3905 DU_ALLOC(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
3906 if(!pdschCfg->maxNrofCodeWordsScheduledByDCI)
3908 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3911 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = PDSCH_MAX_CODEWORD_SCH_BY_DCI;
3913 if(BuildPdschPrbBundlingType(&pdschCfg->prb_BundlingType) != ROK)
3918 pdschCfg->zp_CSI_RS_ResourceToAddModList = NULLP;
3919 pdschCfg->zp_CSI_RS_ResourceToReleaseList = NULLP;
3920 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
3921 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
3922 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
3923 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
3924 pdschCfg->p_ZP_CSI_RS_ResourceSet = NULLP;
3929 /*******************************************************************
3931 * @brief Builds intitial DL BWP
3934 * Function : BuildInitialDlBWP
3936 * Functionality: Builds intitial DL BWP in spCellCfgDed
3938 * @params[in] BWP_DownlinkDedicated_t *dlBwp
3940 * @return ROK - success
3943 * ****************************************************************/
3944 uint8_t BuildInitialDlBWP(BWP_DownlinkDedicated_t *dlBwp)
3946 dlBwp->pdcch_Config = NULLP;
3947 DU_ALLOC(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
3948 if(!dlBwp->pdcch_Config)
3950 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
3953 dlBwp->pdcch_Config->present = BWP_DownlinkDedicated__pdcch_Config_PR_setup;
3955 dlBwp->pdcch_Config->choice.setup = NULLP;
3956 DU_ALLOC(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
3957 if(!dlBwp->pdcch_Config->choice.setup)
3959 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
3962 if(BuildBWPDlDedPdcchCfg(dlBwp->pdcch_Config->choice.setup) != ROK)
3967 dlBwp->pdsch_Config = NULLP;
3968 DU_ALLOC(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
3969 if(!dlBwp->pdsch_Config)
3971 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
3974 dlBwp->pdsch_Config->present = BWP_DownlinkDedicated__pdsch_Config_PR_setup;
3976 dlBwp->pdsch_Config->choice.setup = NULLP;
3977 DU_ALLOC(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
3978 if(!dlBwp->pdsch_Config->choice.setup)
3980 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
3984 if(BuildBWPDlDedPdschCfg(dlBwp->pdsch_Config->choice.setup) != ROK)
3989 dlBwp->sps_Config = NULLP;
3990 dlBwp->radioLinkMonitoringConfig = NULLP;
3994 /*******************************************************************
3996 * @brief Builds DMRS UL Pusch Mapping type A
4000 * Function : BuildDMRSULPuschMapTypeA
4002 * Functionality: Builds DMRS UL Pusch Mapping type A
4005 * struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4006 * @return ROK - success
4009 * ****************************************************************/
4010 uint8_t BuildDMRSULPuschMapTypeA
4012 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4015 dmrsUlCfg->present = PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup;
4016 dmrsUlCfg->choice.setup= NULLP;
4017 DU_ALLOC(dmrsUlCfg->choice.setup, sizeof(DMRS_UplinkConfig_t));
4018 if(!dmrsUlCfg->choice.setup)
4020 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4024 dmrsUlCfg->choice.setup->dmrs_Type = NULLP;
4025 dmrsUlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
4026 DU_ALLOC(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
4027 if(!dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
4029 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4032 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
4034 dmrsUlCfg->choice.setup->phaseTrackingRS = NULLP;
4035 dmrsUlCfg->choice.setup->maxLength = NULLP;
4036 dmrsUlCfg->choice.setup->transformPrecodingDisabled = NULLP;
4037 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled, \
4038 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
4039 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled)
4041 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4045 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0 = NULLP;
4046 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
4048 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0)
4050 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4053 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = SCRAMBLING_ID;
4055 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID1 = NULLP;
4056 dmrsUlCfg->choice.setup->transformPrecodingEnabled = NULLP;
4060 /*******************************************************************
4062 * @brief Build PUSCH time domain allocation list
4066 * Function : BuildPuschTimeDomAllocList
4068 * Functionality: Build PUSCH time domain allocation list
4071 * struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4073 * @return ROK - success
4076 * ****************************************************************/
4077 uint8_t BuildPuschTimeDomAllocList
4079 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4084 PUSCH_TimeDomainResourceAllocation_t *timeDomAlloc;
4086 timeDomAllocList->present = PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup;
4087 timeDomAllocList->choice.setup = NULLP;
4088 DU_ALLOC(timeDomAllocList->choice.setup, \
4089 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
4090 if(!timeDomAllocList->choice.setup)
4092 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4097 timeDomAllocList->choice.setup->list.count = elementCnt;
4098 timeDomAllocList->choice.setup->list.size = \
4099 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
4100 timeDomAllocList->choice.setup->list.array = NULLP;
4101 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
4102 timeDomAllocList->choice.setup->list.size);
4103 if(!timeDomAllocList->choice.setup->list.array)
4105 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4109 for(idx = 0; idx < elementCnt; idx++)
4111 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
4112 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx],\
4113 sizeof(PUSCH_TimeDomainResourceAllocation_t));
4114 if(!timeDomAllocList->choice.setup->list.array[idx])
4116 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4122 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4123 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4124 if(!timeDomAlloc->k2)
4126 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4129 *(timeDomAlloc->k2) = PUSCH_K2;
4130 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4131 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4135 /*******************************************************************
4137 * @brief Builds BWP UL dedicated PUSCH Config
4141 * Function : BuildBWPUlDedPuschCfg
4144 * Builds BWP UL dedicated PUSCH Config
4146 * @params[in] : PUSCH_Config_t *puschCfg
4148 * @return ROK - success
4151 * ****************************************************************/
4152 uint8_t BuildBWPUlDedPuschCfg(PUSCH_Config_t *puschCfg)
4154 puschCfg->dataScramblingIdentityPUSCH = NULLP;
4155 DU_ALLOC(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
4156 if(!puschCfg->dataScramblingIdentityPUSCH)
4158 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4161 *(puschCfg->dataScramblingIdentityPUSCH) = SCRAMBLING_ID;
4163 puschCfg->txConfig = NULLP;
4164 puschCfg->dmrs_UplinkForPUSCH_MappingTypeA = NULLP;
4165 DU_ALLOC(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
4166 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
4167 if(!puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
4169 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4173 if(BuildDMRSULPuschMapTypeA(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA) != ROK)
4178 puschCfg->dmrs_UplinkForPUSCH_MappingTypeB = NULLP;
4179 puschCfg->pusch_PowerControl = NULLP;
4180 puschCfg->frequencyHopping = NULLP;
4181 puschCfg->frequencyHoppingOffsetLists = NULLP;
4182 puschCfg->resourceAllocation = RES_ALLOC_TYPE;
4184 puschCfg->pusch_TimeDomainAllocationList = NULLP;
4185 DU_ALLOC(puschCfg->pusch_TimeDomainAllocationList, \
4186 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
4187 if(!puschCfg->pusch_TimeDomainAllocationList)
4189 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4193 if(BuildPuschTimeDomAllocList(puschCfg->pusch_TimeDomainAllocationList) != ROK)
4198 puschCfg->pusch_AggregationFactor = NULLP;
4199 puschCfg->mcs_Table = NULLP;
4200 puschCfg->mcs_TableTransformPrecoder = NULLP;
4201 puschCfg->transformPrecoder = NULLP;
4202 DU_ALLOC(puschCfg->transformPrecoder, sizeof(long));
4203 if(!puschCfg->transformPrecoder)
4205 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4208 *(puschCfg->transformPrecoder) = PUSCH_TRANSFORM_PRECODER;
4210 puschCfg->codebookSubset = NULLP;
4211 puschCfg->maxRank = NULLP;
4212 puschCfg->rbg_Size = NULLP;
4213 puschCfg->uci_OnPUSCH = NULLP;
4214 puschCfg->tp_pi2BPSK = NULLP;
4219 /*******************************************************************
4221 * @brief Fills SRS resource to add/modify list
4225 * Function : BuildSrsRsrcAddModList
4227 * Functionality: Fills SRS resource to add/modify list
4230 * @return ROK - success
4233 * ****************************************************************/
4234 uint8_t BuildSrsRsrcAddModList(struct SRS_Config__srs_ResourceToAddModList *resourceList)
4240 resourceList->list.count = elementCnt;
4241 resourceList->list.size = elementCnt * sizeof(SRS_Resource_t *);
4242 resourceList->list.array = NULLP;
4243 DU_ALLOC(resourceList->list.array, resourceList->list.size);
4244 if(!resourceList->list.array)
4246 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4250 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
4252 DU_ALLOC(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
4253 if(!resourceList->list.array[rsrcIdx])
4255 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4261 resourceList->list.array[rsrcIdx]->srs_ResourceId = SRS_RSRC_ID;
4262 resourceList->list.array[rsrcIdx]->nrofSRS_Ports = SRS_Resource__nrofSRS_Ports_port1;
4263 resourceList->list.array[rsrcIdx]->transmissionComb.present = SRS_Resource__transmissionComb_PR_n2;
4265 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2 = NULLP;
4266 DU_ALLOC(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2, \
4267 sizeof(struct SRS_Resource__transmissionComb__n2));
4268 if(!resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2)
4270 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4273 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->combOffset_n2\
4274 = SRS_COMB_OFFSET_N2;
4275 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->cyclicShift_n2\
4276 = SRS_CYCLIC_SHIFT_N2;
4278 resourceList->list.array[rsrcIdx]->resourceMapping.startPosition = \
4280 resourceList->list.array[rsrcIdx]->resourceMapping.nrofSymbols = \
4281 SRS_Resource__resourceMapping__nrofSymbols_n1;
4282 resourceList->list.array[rsrcIdx]->resourceMapping.repetitionFactor = \
4283 SRS_Resource__resourceMapping__repetitionFactor_n1;
4285 resourceList->list.array[rsrcIdx]->freqDomainPosition = SRS_FREQ_DOM_POS;
4286 resourceList->list.array[rsrcIdx]->freqDomainShift = SRS_FREQ_DOM_SHIFT;
4287 resourceList->list.array[rsrcIdx]->freqHopping.c_SRS = C_SRS;
4288 resourceList->list.array[rsrcIdx]->freqHopping.b_SRS = B_SRS;
4289 resourceList->list.array[rsrcIdx]->freqHopping.b_hop = B_HOP;
4290 resourceList->list.array[rsrcIdx]->groupOrSequenceHopping = \
4291 SRS_Resource__groupOrSequenceHopping_neither;
4293 /* Setting resource type to aperiodic for intergration purposes */
4294 resourceList->list.array[rsrcIdx]->resourceType.present = \
4295 SRS_Resource__resourceType_PR_aperiodic;
4296 resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic = NULLP;
4297 DU_ALLOC(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,
4298 sizeof(struct SRS_Resource__resourceType__aperiodic));
4299 if(!resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic)
4301 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4304 resourceList->list.array[rsrcIdx]->sequenceId = SRS_SEQ_ID;
4309 /*******************************************************************
4311 * @brief Build SRS resource set Add/mod list
4315 * Function : BuildSrsRsrcSetAddModList
4317 * Functionality: Build SRS resource set Add/mod list
4320 * @return ROK - success
4323 * ****************************************************************/
4324 uint8_t BuildSrsRsrcSetAddModList
4326 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList
4332 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList;
4335 rsrcSetList->list.count = elementCnt;
4336 rsrcSetList->list.size = elementCnt * sizeof(SRS_ResourceSet_t *);
4337 rsrcSetList->list.array = NULLP;
4338 DU_ALLOC(rsrcSetList->list.array, rsrcSetList->list.size);
4339 if(!rsrcSetList->list.array)
4341 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4345 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
4347 DU_ALLOC(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
4348 if(!rsrcSetList->list.array[rSetIdx])
4350 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4356 rsrcSetList->list.array[rSetIdx]->srs_ResourceSetId = SRS_RSET_ID;
4358 /* Fill Resource Id list in resource set */
4359 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList = NULLP;
4360 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
4361 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
4362 if(!rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
4364 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4369 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
4370 rsrcIdList->list.count = elementCnt;
4371 rsrcIdList->list.size = elementCnt * sizeof(SRS_ResourceId_t *);
4372 rsrcIdList->list.array = NULLP;
4373 DU_ALLOC(rsrcIdList->list.array, rsrcIdList->list.size);
4374 if(!rsrcIdList->list.array)
4376 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4380 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
4382 DU_ALLOC(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
4383 if(!rsrcIdList->list.array[rsrcIdx])
4385 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4391 *rsrcIdList->list.array[rsrcIdx] = SRS_RSRC_ID;
4393 /* Fill resource type */
4394 rsrcSetList->list.array[rSetIdx]->resourceType.present = \
4395 SRS_ResourceSet__resourceType_PR_aperiodic;
4397 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic = NULLP;
4398 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
4399 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
4400 if(!rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic)
4402 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4405 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger \
4406 = APERIODIC_SRS_RESRC_TRIGGER;
4408 /* TODO : Fill values for below IEs as expected by Viavi */
4409 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->csi_RS = NULLP;
4410 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->slotOffset = NULLP;
4413 rsrcSetList->list.array[rSetIdx]->usage = SRS_ResourceSet__usage_codebook;
4414 rsrcSetList->list.array[rSetIdx]->alpha = NULLP;
4415 rsrcSetList->list.array[rSetIdx]->p0 = NULLP;
4416 rsrcSetList->list.array[rSetIdx]->pathlossReferenceRS = NULLP;
4417 rsrcSetList->list.array[rSetIdx]->srs_PowerControlAdjustmentStates = NULLP;
4422 /*******************************************************************
4424 * @brief Builds BWP UL dedicated SRS Config
4428 * Function : BuildBWPUlDedSrsCfg
4430 * Functionality: Builds BWP UL dedicated SRS Config
4432 * @params[in] SRS Config
4433 * @return ROK - success
4436 * ****************************************************************/
4437 uint8_t BuildBWPUlDedSrsCfg(SRS_Config_t *srsCfg)
4439 srsCfg->srs_ResourceSetToReleaseList = NULLP;
4440 srsCfg->srs_ResourceSetToAddModList = NULLP;
4441 DU_ALLOC(srsCfg->srs_ResourceSetToAddModList, \
4442 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
4443 if(!srsCfg->srs_ResourceSetToAddModList)
4445 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4448 if(BuildSrsRsrcSetAddModList(srsCfg->srs_ResourceSetToAddModList) != ROK)
4453 srsCfg->srs_ResourceToReleaseList = NULLP;
4455 /* Resource to Add/Modify list */
4456 srsCfg->srs_ResourceToAddModList = NULLP;
4457 DU_ALLOC(srsCfg->srs_ResourceToAddModList, \
4458 sizeof(struct SRS_Config__srs_ResourceToAddModList));
4459 if(!srsCfg->srs_ResourceToAddModList)
4461 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4465 if(BuildSrsRsrcAddModList(srsCfg->srs_ResourceToAddModList) != ROK)
4470 srsCfg->tpc_Accumulation = NULLP;
4477 /*******************************************************************
4479 * @brief Builds Pusch Serving cell Config
4483 * Function : BuildPuschSrvCellCfg
4485 * Functionality: Builds Pusch Serving cell Config
4487 * @params[in] struct UplinkConfig__pusch_ServingCellConfig *puschCfg
4489 * @return ROK - success
4492 * ****************************************************************/
4493 uint8_t BuildPuschSrvCellCfg(struct UplinkConfig__pusch_ServingCellConfig *puschCfg)
4495 puschCfg->present = UplinkConfig__pusch_ServingCellConfig_PR_setup;
4496 puschCfg->choice.setup = NULLP;
4497 DU_ALLOC(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
4498 if(!puschCfg->choice.setup)
4500 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4504 puschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4505 puschCfg->choice.setup->rateMatching = NULLP;
4506 puschCfg->choice.setup->xOverhead = NULLP;
4507 puschCfg->choice.setup->ext1 = NULLP;
4508 DU_ALLOC(puschCfg->choice.setup->ext1, sizeof(struct PUSCH_ServingCellConfig__ext1));
4509 if(!puschCfg->choice.setup->ext1)
4511 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4515 puschCfg->choice.setup->ext1->maxMIMO_Layers = NULLP;
4516 DU_ALLOC(puschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
4517 if(!puschCfg->choice.setup->ext1->maxMIMO_Layers)
4519 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4522 *(puschCfg->choice.setup->ext1->maxMIMO_Layers) = PUSCH_MAX_MIMO_LAYERS;
4524 puschCfg->choice.setup->ext1->processingType2Enabled= NULLP;
4525 DU_ALLOC(puschCfg->choice.setup->ext1->processingType2Enabled,sizeof(BOOLEAN_t));
4526 if(!puschCfg->choice.setup->ext1->processingType2Enabled)
4528 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4531 *(puschCfg->choice.setup->ext1->processingType2Enabled) = PUSCH_PROCESS_TYPE2_ENABLED;
4535 /*******************************************************************
4537 * @brief Builds inital UL BWP
4541 * Function : BuildInitialUlBWP
4543 * Functionality: Builds initial UL BWP
4545 * @params[in] BWP_UplinkDedicated_t *ulBwp
4546 * @return ROK - success
4549 * ****************************************************************/
4550 uint8_t BuildInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
4552 ulBwp->pucch_Config = NULLP;
4554 /* Fill BWP UL dedicated PUSCH config */
4555 ulBwp->pusch_Config = NULLP;
4556 DU_ALLOC(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
4557 if(!ulBwp->pusch_Config)
4559 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4563 ulBwp->pusch_Config->present = BWP_UplinkDedicated__pusch_Config_PR_setup;
4564 ulBwp->pusch_Config->choice.setup = NULLP;
4565 DU_ALLOC(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
4566 if(!ulBwp->pusch_Config->choice.setup)
4568 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4572 if(BuildBWPUlDedPuschCfg(ulBwp->pusch_Config->choice.setup) != ROK)
4577 ulBwp->configuredGrantConfig = NULLP;
4579 /* Fill BPW UL dedicated SRS config */
4580 ulBwp->srs_Config = NULLP;
4581 DU_ALLOC(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
4582 if(!ulBwp->srs_Config)
4584 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4588 ulBwp->srs_Config->present = BWP_UplinkDedicated__srs_Config_PR_setup;
4589 ulBwp->srs_Config->choice.setup = NULLP;
4590 DU_ALLOC(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
4591 if(!ulBwp->srs_Config->choice.setup)
4593 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4597 if(BuildBWPUlDedSrsCfg(ulBwp->srs_Config->choice.setup) != ROK)
4602 ulBwp->beamFailureRecoveryConfig = NULLP;
4607 /*******************************************************************
4609 * @brief Builds UL config
4612 * Function : BuildUlCfg
4614 * Functionality: Builds UL config in spCellCfgDed
4616 * @params[in] UplinkConfig_t *ulCfg
4618 * @return ROK - success
4621 * ****************************************************************/
4622 uint8_t BuildUlCfg(UplinkConfig_t *ulCfg)
4624 ulCfg->initialUplinkBWP = NULLP;
4625 DU_ALLOC(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
4626 if(!ulCfg->initialUplinkBWP)
4628 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4632 if(BuildInitialUlBWP(ulCfg->initialUplinkBWP) != ROK)
4637 ulCfg->uplinkBWP_ToReleaseList = NULLP;
4638 ulCfg->uplinkBWP_ToAddModList = NULLP;
4639 ulCfg->firstActiveUplinkBWP_Id = NULLP;
4640 DU_ALLOC(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
4641 if(!ulCfg->firstActiveUplinkBWP_Id)
4643 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4646 *(ulCfg->firstActiveUplinkBWP_Id) = ACTIVE_UL_BWP_ID;
4648 ulCfg->pusch_ServingCellConfig = NULLP;
4649 DU_ALLOC(ulCfg->pusch_ServingCellConfig, \
4650 sizeof(struct UplinkConfig__pusch_ServingCellConfig));
4651 if(!ulCfg->pusch_ServingCellConfig)
4653 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4657 if(BuildPuschSrvCellCfg(ulCfg->pusch_ServingCellConfig) != ROK)
4662 ulCfg->carrierSwitching = NULLP;
4663 ulCfg->ext1 = NULLP;
4667 /*******************************************************************
4669 * @brief Builds PDSCH serving cell config
4672 * Function : BuildPdschSrvCellCfg
4674 * Functionality: Builds PDSCH serving cell config in spCellCfgDed
4676 * @params[in] struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg
4678 * @return ROK - success
4681 * ****************************************************************/
4682 uint8_t BuildPdschSrvCellCfg(struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg)
4684 pdschCfg->present = ServingCellConfig__pdsch_ServingCellConfig_PR_setup;
4685 pdschCfg->choice.setup = NULLP;
4686 DU_ALLOC(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
4687 if(!pdschCfg->choice.setup)
4689 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4693 pdschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4694 pdschCfg->choice.setup->xOverhead = NULLP;
4695 pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH = NULLP;
4696 DU_ALLOC(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH, sizeof(long));
4697 if(!pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)
4699 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4702 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)= PDSCH_NUM_HARQ_PROC;
4703 pdschCfg->choice.setup->pucch_Cell = NULLP;
4704 pdschCfg->choice.setup->ext1 = NULLP;
4709 /*******************************************************************
4711 * @brief Builds CSI Meas config
4714 * Function : BuildCsiMeasCfg
4716 * Functionality: Builds CSI Meas config in spCellCfgDed
4718 * @params[in] struct ServingCellConfig__csi_MeasConfig *csiMeasCfg
4720 * @return ROK - success
4723 * ****************************************************************/
4724 uint8_t BuildCsiMeasCfg(struct ServingCellConfig__csi_MeasConfig *csiMeasCfg)
4730 /*******************************************************************
4732 * @brief Builds Spcell config dedicated
4735 * Function : BuildSpCellCfgDed
4737 * Functionality: Builds sp cell config dedicated in spCellCfg
4739 * @params[in] ServingCellConfig_t srvCellCfg
4741 * @return ROK - success
4744 * ****************************************************************/
4745 uint8_t BuildSpCellCfgDed(ServingCellConfig_t *srvCellCfg)
4747 srvCellCfg->tdd_UL_DL_ConfigurationDedicated = NULLP;
4748 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
4749 if(!srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
4751 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4755 srvCellCfg->initialDownlinkBWP = NULLP;
4756 DU_ALLOC(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
4757 if(!srvCellCfg->initialDownlinkBWP)
4759 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4763 if(BuildInitialDlBWP(srvCellCfg->initialDownlinkBWP) != ROK)
4765 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
4768 srvCellCfg->downlinkBWP_ToReleaseList = NULLP;
4769 srvCellCfg->downlinkBWP_ToAddModList = NULLP;
4771 srvCellCfg->firstActiveDownlinkBWP_Id = NULLP;
4772 DU_ALLOC(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
4773 if(!srvCellCfg->firstActiveDownlinkBWP_Id)
4775 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4778 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4780 srvCellCfg->bwp_InactivityTimer = NULLP;
4782 srvCellCfg->defaultDownlinkBWP_Id = NULLP;
4783 DU_ALLOC(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
4784 if(!srvCellCfg->defaultDownlinkBWP_Id)
4786 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4789 *(srvCellCfg->defaultDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4791 srvCellCfg->uplinkConfig = NULLP;
4792 DU_ALLOC(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
4793 if(!srvCellCfg->uplinkConfig)
4795 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4799 if(BuildUlCfg(srvCellCfg->uplinkConfig) != ROK)
4801 DU_LOG("\nERROR --> F1AP : BuildUlCfg failed");
4804 srvCellCfg->supplementaryUplink = NULLP;
4805 srvCellCfg->pdcch_ServingCellConfig = NULLP;
4807 srvCellCfg->pdsch_ServingCellConfig = NULLP;
4808 DU_ALLOC(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
4809 if(!srvCellCfg->pdsch_ServingCellConfig)
4811 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4815 if(BuildPdschSrvCellCfg(srvCellCfg->pdsch_ServingCellConfig) != ROK)
4817 DU_LOG("\nERROR --> F1AP : BuildPdschSrvCellCfg failed");
4821 srvCellCfg->csi_MeasConfig = NULLP;
4823 DU_ALLOC(srvCellCfg->csi_MeasConfig, sizeof(struct ServingCellConfig__csi_MeasConfig))
4824 if(!srvCellCfg->csi_MeasConfig)
4826 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4830 if(BuildCsiMeasCfg(srvCellCfg->csi_MeasConfig) != ROK)
4832 DU_LOG("\nF1AP : BuildCsiMeasCfg failed");
4836 srvCellCfg->sCellDeactivationTimer = NULLP;
4837 srvCellCfg->crossCarrierSchedulingConfig = NULLP;
4838 srvCellCfg->tag_Id = TAG_ID;
4839 srvCellCfg->dummy = NULLP;
4840 srvCellCfg->pathlossReferenceLinking = NULLP;
4841 srvCellCfg->servingCellMO = NULLP;
4842 srvCellCfg->ext1 = NULLP;
4846 /*******************************************************************
4848 * @brief Builds Spcell config
4852 * Function : BuildSpCellCfg
4854 * Functionality: Builds sp cell config in DuToCuRrcContainer
4856 * @params[in] SpCellConfig_t spCellCfg
4858 * @return ROK - success
4861 * ****************************************************************/
4862 uint8_t BuildSpCellCfg(SpCellConfig_t *spCellCfg)
4865 spCellCfg->servCellIndex = NULLP;
4866 DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
4867 if(!spCellCfg->servCellIndex)
4869 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4872 *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
4874 spCellCfg->reconfigurationWithSync = NULLP;
4875 spCellCfg->rlf_TimersAndConstants = NULLP;
4876 spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
4877 DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
4878 if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
4880 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4883 *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
4885 spCellCfg->spCellConfigDedicated = NULLP;
4886 DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
4887 if(!spCellCfg->spCellConfigDedicated)
4889 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4892 if(BuildSpCellCfgDed(spCellCfg->spCellConfigDedicated) != ROK)
4894 DU_LOG("\nERROR --> F1AP : BuildSpCellCfgDed failed");
4899 /*******************************************************************
4901 * @brief Builds Phy cell group config
4905 * Function : BuildPhyCellGrpCfg
4907 * Functionality: Builds Phy cell group config in DuToCuRrcContainer
4909 * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg
4911 * @return ROK - success
4914 * ****************************************************************/
4915 uint8_t BuildPhyCellGrpCfg(PhysicalCellGroupConfig_t *phyCellGrpCfg)
4917 phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
4918 phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
4920 phyCellGrpCfg->p_NR_FR1 = NULLP;
4921 DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
4922 if(!phyCellGrpCfg->p_NR_FR1)
4924 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
4927 *(phyCellGrpCfg->p_NR_FR1) = P_NR_FR1;
4928 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
4929 phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
4930 phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
4931 phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
4932 phyCellGrpCfg->sp_CSI_RNTI = NULLP;
4933 phyCellGrpCfg->cs_RNTI = NULLP;
4934 phyCellGrpCfg->ext1 = NULLP;
4935 phyCellGrpCfg->ext2 = NULLP;
4939 /*******************************************************************
4941 * @brief Builds Mac cell group config
4945 * Function : BuildMacCellGrpCfg
4947 * Functionality: Builds Mac cell group config in DuToCuRrcContainer
4949 * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
4951 * @return ROK - success
4954 * ****************************************************************/
4955 uint8_t BuildMacCellGrpCfg(MAC_CellGroupConfig_t *macCellGrpCfg)
4957 macCellGrpCfg->drx_Config = NULLP;
4958 macCellGrpCfg->schedulingRequestConfig = NULLP;
4959 DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
4960 if(!macCellGrpCfg->schedulingRequestConfig)
4962 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
4966 if(BuildSchedulingReqConfig(macCellGrpCfg->schedulingRequestConfig) != ROK)
4968 DU_LOG("\nERROR --> F1AP : BuildSchedulingReqConfig failed");
4972 macCellGrpCfg->bsr_Config = NULLP;
4973 DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
4974 if(!macCellGrpCfg->bsr_Config)
4976 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
4980 if(BuildBsrConfig(macCellGrpCfg->bsr_Config) != ROK)
4982 DU_LOG("\nERROR --> F1AP : BuildBsrConfig failed");
4986 macCellGrpCfg->tag_Config = NULLP;
4987 DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
4988 if(!macCellGrpCfg->tag_Config)
4990 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
4994 if(BuildTagConfig(macCellGrpCfg->tag_Config) != ROK)
4996 DU_LOG("\nERROR --> F1AP : BuildTagConfig failed");
5000 macCellGrpCfg->phr_Config = NULLP;
5001 DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
5002 if(!macCellGrpCfg->phr_Config)
5004 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5008 if(BuildPhrConfig(macCellGrpCfg->phr_Config) != ROK)
5010 DU_LOG("\nERROR --> F1AP : BuildPhrConfig failed");
5014 macCellGrpCfg->skipUplinkTxDynamic = false;
5015 macCellGrpCfg->ext1 = NULLP;
5019 /*******************************************************************
5021 * @brief Frees memeory allocated for SearchSpcToAddModList
5025 * Function : FreeSearchSpcToAddModList
5027 * Functionality: Deallocating memory of SearchSpcToAddModList
5029 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
5033 4221 * ****************************************************************/
5034 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
5038 struct SearchSpace *searchSpc=NULLP;
5040 if(searchSpcList->list.array)
5042 if(searchSpcList->list.array[idx2])
5044 searchSpc = searchSpcList->list.array[idx2];
5045 if(searchSpc->controlResourceSetId)
5047 if(searchSpc->monitoringSlotPeriodicityAndOffset)
5049 if(searchSpc->monitoringSymbolsWithinSlot)
5051 if(searchSpc->monitoringSymbolsWithinSlot->buf)
5053 if(searchSpc->nrofCandidates)
5055 if(searchSpc->searchSpaceType)
5057 DU_FREE(searchSpc->searchSpaceType->choice.ue_Specific,\
5058 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
5059 DU_FREE(searchSpc->searchSpaceType, sizeof(struct
5060 SearchSpace__searchSpaceType));
5062 DU_FREE(searchSpc->nrofCandidates,
5063 sizeof(struct SearchSpace__nrofCandidates));
5065 DU_FREE(searchSpc->monitoringSymbolsWithinSlot->buf, \
5066 searchSpc->monitoringSymbolsWithinSlot->size);
5068 DU_FREE(searchSpc->monitoringSymbolsWithinSlot,
5069 sizeof(BIT_STRING_t));
5071 DU_FREE(searchSpc->monitoringSlotPeriodicityAndOffset, \
5072 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
5074 DU_FREE(searchSpc->controlResourceSetId,
5075 sizeof(ControlResourceSetId_t));
5078 for(idx1 = 0; idx1 < searchSpcList->list.count; idx1++)
5080 DU_FREE(searchSpcList->list.array[idx1],
5081 sizeof(struct SearchSpace));
5083 DU_FREE(searchSpcList->list.array,searchSpcList->list.size);
5086 /*******************************************************************
5088 * @brief Frees memory allocated for PdschTimeDomAllocList
5092 * Function : FreePdschTimeDomAllocList
5094 * Functionality: Deallocating memory of PdschTimeDomAllocList
5096 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
5100 4221 * ****************************************************************/
5101 void FreePdschTimeDomAllocList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
5105 if(timeDomAllocList->choice.setup)
5107 if(timeDomAllocList->choice.setup->list.array)
5109 for(idx1 = 0; idx1 <timeDomAllocList->choice.setup->list.count ; idx1++)
5111 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1],
5112 sizeof(struct PDSCH_TimeDomainResourceAllocation));
5114 DU_FREE(timeDomAllocList->choice.setup->list.array, \
5115 timeDomAllocList->choice.setup->list.size);
5117 DU_FREE(timeDomAllocList->choice.setup,\
5118 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
5121 /*******************************************************************
5123 * @brief Frees memory allocated for PuschTimeDomAllocList
5127 * Function : FreePuschTimeDomAllocList
5129 * Functionality: Deallocating memory of PuschTimeDomAllocList
5131 * @params[in] PUSCH_Config_t *puschCfg
5135 * ****************************************************************/
5136 void FreePuschTimeDomAllocList(PUSCH_Config_t *puschCfg)
5140 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
5142 if(puschCfg->pusch_TimeDomainAllocationList)
5144 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
5145 if(timeDomAllocList_t->choice.setup)
5147 if(timeDomAllocList_t->choice.setup->list.array)
5149 DU_FREE(timeDomAllocList_t->choice.setup->list.array[idx2]->k2, sizeof(long));
5150 for(idx1 = 0; idx1<timeDomAllocList_t->choice.setup->list.count; idx1++)
5152 DU_FREE(timeDomAllocList_t->choice.setup->list.array[idx1],\
5153 sizeof(PUSCH_TimeDomainResourceAllocation_t));
5155 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
5156 timeDomAllocList_t->choice.setup->list.size);
5158 DU_FREE(timeDomAllocList_t->choice.setup, \
5159 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
5161 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
5162 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
5163 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
5167 /*******************************************************************
5169 * @brief Frees memory allocated for InitialUlBWP
5173 * Function : FreeInitialUlBWP
5175 * Functionality: Deallocating memory of InitialUlBWP
5177 * @params[in] BWP_UplinkDedicated_t *ulBwp
5181 * ****************************************************************/
5182 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
5184 uint8_t rSetIdx, rsrcIdx;
5185 SRS_Config_t *srsCfg = NULLP;
5186 PUSCH_Config_t *puschCfg = NULLP;
5187 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
5188 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
5189 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
5190 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
5192 if(ulBwp->pusch_Config)
5194 if(ulBwp->pusch_Config->choice.setup)
5196 puschCfg=ulBwp->pusch_Config->choice.setup;
5197 if(puschCfg->dataScramblingIdentityPUSCH)
5199 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
5201 FreePuschTimeDomAllocList(puschCfg);
5202 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
5203 if(dmrsUlCfg->choice.setup)
5205 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
5207 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
5209 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
5211 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
5212 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
5214 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
5217 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
5219 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
5220 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
5222 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
5224 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5226 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5228 /* Free SRS-Config */
5229 if(ulBwp->srs_Config)
5231 if(ulBwp->srs_Config->choice.setup)
5233 srsCfg = ulBwp->srs_Config->choice.setup;
5235 /* Free Resource Set to add/mod list */
5236 if(srsCfg->srs_ResourceSetToAddModList)
5238 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
5239 if(rsrcSetList->list.array)
5243 /* Free SRS resource Id list in this SRS resource set */
5244 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5246 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5248 if(rsrcIdList->list.array)
5250 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5252 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5254 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
5256 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5257 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5260 /* Free resource type info for this SRS resource set */
5261 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5262 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5264 /* Free memory for each resource set */
5265 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5267 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5269 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
5271 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
5272 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5275 /* Free resource to add/modd list */
5276 if(srsCfg->srs_ResourceToAddModList)
5278 resourceList = srsCfg->srs_ResourceToAddModList;
5279 if(resourceList->list.array)
5282 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
5283 sizeof(struct SRS_Resource__transmissionComb__n2));
5284 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
5285 sizeof(struct SRS_Resource__resourceType__aperiodic));
5287 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5289 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5291 DU_FREE(resourceList->list.array, resourceList->list.size);
5293 DU_FREE(srsCfg->srs_ResourceToAddModList, \
5294 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5297 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5299 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5303 /*******************************************************************
5305 * @brief Frees memory allocated for initialUplinkBWP
5309 * Function : FreeinitialUplinkBWP
5311 * Functionality: Deallocating memory of initialUplinkBWP
5313 * @params[in] UplinkConfig_t *ulCfg
5318 * ****************************************************************/
5319 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
5321 BWP_UplinkDedicated_t *ulBwp=NULLP;
5322 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
5324 if(ulCfg->initialUplinkBWP)
5326 ulBwp=ulCfg->initialUplinkBWP;
5327 if(ulCfg->firstActiveUplinkBWP_Id)
5329 if(ulCfg->pusch_ServingCellConfig)
5331 puschCfg=ulCfg->pusch_ServingCellConfig;
5332 if(puschCfg->choice.setup)
5334 if(puschCfg->choice.setup->ext1)
5336 DU_FREE(puschCfg->choice.setup->ext1->\
5337 processingType2Enabled,sizeof(BOOLEAN_t));
5338 DU_FREE(puschCfg->choice.setup->ext1->\
5339 maxMIMO_Layers,sizeof(long));
5340 DU_FREE(puschCfg->choice.setup->ext1, \
5341 sizeof(struct PUSCH_ServingCellConfig__ext1));
5343 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5345 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5347 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5349 FreeInitialUlBWP(ulBwp);
5350 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5353 /*******************************************************************
5355 * @brief Frees emmory allocated for BWPDlDedPdschCfg
5359 * Function : FreeBWPDlDedPdschCfg
5361 * Functionality: Deallocating memory of BWPDlDedPdschCfg
5363 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5368 * ****************************************************************/
5369 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
5371 struct PDSCH_Config *pdschCfg=NULLP;
5372 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
5373 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
5374 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
5376 if(dlBwp->pdsch_Config->choice.setup)
5378 pdschCfg=dlBwp->pdsch_Config->choice.setup;
5379 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
5381 if(pdschCfg->pdsch_TimeDomainAllocationList)
5383 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
5384 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
5386 prbBndlType=&pdschCfg->prb_BundlingType;
5387 DU_FREE(prbBndlType->choice.staticBundling,\
5388 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
5389 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
5391 FreePdschTimeDomAllocList(timeDomAllocList);
5392 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
5393 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
5395 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
5396 if(dmrsDlCfg->choice.setup)
5398 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
5400 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
5402 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
5403 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
5405 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
5408 /*******************************************************************
5410 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
5414 * Function : FreeBWPDlDedPdcchCfg
5416 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
5418 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5423 * ****************************************************************/
5424 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
5428 struct PDCCH_Config *pdcchCfg=NULLP;
5429 struct ControlResourceSet *controlRSet=NULLP;
5430 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
5432 if(dlBwp->pdcch_Config->choice.setup)
5434 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
5435 if(pdcchCfg->controlResourceSetToAddModList)
5437 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
5438 if(controlRSetList->list.array)
5440 controlRSet = controlRSetList->list.array[idx2];
5443 if(controlRSet->frequencyDomainResources.buf)
5445 if(controlRSet->pdcch_DMRS_ScramblingID)
5447 if(pdcchCfg->searchSpacesToAddModList)
5449 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
5450 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
5451 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
5453 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
5455 DU_FREE(controlRSet->frequencyDomainResources.buf, \
5456 controlRSet->frequencyDomainResources.size);
5459 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
5461 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
5463 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
5465 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
5466 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
5468 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
5472 /*******************************************************************
5474 * @brief Frees emmory allocated for DUToCURRCContainer
5478 * Function : FreeMemDuToCuRrcCont
5480 * Functionality: Deallocating memory of DuToCuRrcContainer
5482 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
5484 * @return ROK - success
5487 * ****************************************************************/
5488 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
5491 SpCellConfig_t *spCellCfg=NULLP;
5492 ServingCellConfig_t *srvCellCfg=NULLP;
5493 BWP_DownlinkDedicated_t *dlBwp=NULLP;
5494 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
5495 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
5496 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
5497 struct RLC_Config *rlcConfig=NULLP;
5498 struct LogicalChannelConfig *macLcConfig=NULLP;
5499 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
5500 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
5501 struct TAG_Config *tagConfig=NULLP;
5502 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
5503 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
5504 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
5506 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
5509 if(rlcBearerList->list.array)
5511 for(idx=0; idx<rlcBearerList->list.count; idx++)
5513 if(rlcBearerList->list.array[idx])
5515 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
5516 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
5519 if(rlcConfig->choice.am)
5521 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5522 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5523 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
5525 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
5527 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
5530 if(macLcConfig->ul_SpecificParameters)
5532 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
5533 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
5534 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
5536 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
5538 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
5541 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
5543 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5546 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
5549 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
5550 if(schedulingRequestConfig)
5552 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
5555 if(schReqList->list.array)
5557 for(idx=0;idx<schReqList->list.count; idx++)
5559 if(schReqList->list.array[idx])
5561 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
5562 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
5565 DU_FREE(schReqList->list.array, schReqList->list.size);
5567 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
5568 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
5569 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5571 if(macCellGrpCfg->bsr_Config)
5573 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5575 tagConfig = macCellGrpCfg->tag_Config;
5578 tagList = tagConfig->tag_ToAddModList;
5581 if(tagList->list.array)
5583 for(idx=0; idx<tagList->list.count; idx++)
5585 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
5587 DU_FREE(tagList->list.array, tagList->list.size);
5589 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
5591 DU_FREE(tagConfig, sizeof(struct TAG_Config));
5594 phrConfig = macCellGrpCfg->phr_Config;
5597 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
5598 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
5601 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
5604 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
5607 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5608 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
5611 spCellCfg = cellGrpCfg->spCellConfig;
5614 if(spCellCfg->servCellIndex)
5616 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
5618 if(spCellCfg->spCellConfigDedicated)
5620 srvCellCfg = spCellCfg->spCellConfigDedicated;
5621 if(srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
5623 if(srvCellCfg->initialDownlinkBWP)
5625 dlBwp = srvCellCfg->initialDownlinkBWP;
5626 if(srvCellCfg->firstActiveDownlinkBWP_Id)
5628 if(srvCellCfg->defaultDownlinkBWP_Id)
5630 if(srvCellCfg->uplinkConfig)
5632 if(srvCellCfg->pdsch_ServingCellConfig)
5634 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
5635 if(pdschCfg->choice.setup)
5637 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
5638 DU_FREE(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5640 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct
5641 ServingCellConfig__pdsch_ServingCellConfig));
5643 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
5644 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
5646 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
5648 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
5650 if(dlBwp->pdcch_Config)
5652 if(dlBwp->pdsch_Config)
5654 FreeBWPDlDedPdschCfg(dlBwp);
5655 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
5657 FreeBWPDlDedPdcchCfg(dlBwp);
5658 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
5660 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
5662 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
5664 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5666 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5668 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
5670 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
5674 /*******************************************************************
5676 * @brief Builds DU To CU RRC Container
5680 * Function : BuildDuToCuRrcContainer
5682 * Functionality: Builds DuToCuRrcContainer
5684 * @params[in] idx, index in F1AP msg
5685 * DuToCuRRCContainer, DuToCuRRCContainer
5687 * @return ROK - success
5690 * ****************************************************************/
5691 uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
5694 CellGroupConfigRrc_t cellGrpCfg;
5695 asn_enc_rval_t encRetVal;
5696 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
5697 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
5701 cellGrpCfg.cellGroupId = CELL_GRP_ID;
5703 cellGrpCfg.rlc_BearerToAddModList = NULLP;
5704 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5705 if(!cellGrpCfg.rlc_BearerToAddModList)
5707 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5711 if(BuildRlcBearerToAddModList(cellGrpCfg.rlc_BearerToAddModList) != ROK)
5713 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
5718 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
5719 cellGrpCfg.mac_CellGroupConfig = NULLP;
5720 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
5721 if(!cellGrpCfg.mac_CellGroupConfig)
5723 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5727 if(BuildMacCellGrpCfg(cellGrpCfg.mac_CellGroupConfig) != ROK)
5729 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
5734 cellGrpCfg.physicalCellGroupConfig = NULLP;
5735 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
5736 if(!cellGrpCfg.physicalCellGroupConfig)
5738 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5742 if(BuildPhyCellGrpCfg(cellGrpCfg.physicalCellGroupConfig) != ROK)
5744 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
5749 cellGrpCfg.spCellConfig = NULLP;
5750 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
5751 if(!cellGrpCfg.spCellConfig)
5753 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5757 if(BuildSpCellCfg(cellGrpCfg.spCellConfig) != ROK)
5759 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
5764 cellGrpCfg.sCellToAddModList = NULLP;
5765 cellGrpCfg.sCellToReleaseList = NULLP;
5766 cellGrpCfg.ext1 = NULLP;
5768 /* encode cellGrpCfg into duToCuRrcContainer */
5769 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
5770 memset(encBuf, 0, ENC_BUF_MAX_LEN);
5772 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
5773 /* Encode results */
5774 if(encRetVal.encoded == ENCODE_FAIL)
5776 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
5777 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
5783 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
5784 for(int i=0; i< encBufSize; i++)
5786 printf("%x",encBuf[i]);
5790 duToCuRrcContainer->size = encBufSize;
5791 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
5792 if(!duToCuRrcContainer->buf)
5794 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
5800 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
5804 FreeMemDuToCuRrcCont(&cellGrpCfg);
5808 /*******************************************************************
5810 * @brief Free memory allocated in InitialULRRCMessage
5814 * Function : freeInitUlRrcMsgTransfer
5816 * Functionality: Free memory allocated in InitialULRRCMessage
5818 * @params[in]F1AP_PDU_t *f1apMsg)
5820 * @return ROK - success
5823 * ****************************************************************/
5825 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
5827 uint8_t ieIdx, arrIdx;
5828 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
5832 if(f1apMsg->choice.initiatingMessage)
5834 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
5835 choice.InitialULRRCMessageTransfer;
5836 if(initULRRCMsg->protocolIEs.list.array)
5838 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
5840 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
5842 case ProtocolIE_ID_id_NRCGI:
5844 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
5846 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
5848 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
5849 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
5851 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
5852 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
5856 case ProtocolIE_ID_id_RRCContainer:
5858 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
5860 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
5861 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
5865 case ProtocolIE_ID_id_DUtoCURRCContainer:
5867 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
5869 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
5870 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
5878 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
5880 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
5882 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
5883 sizeof(InitialULRRCMessageTransferIEs_t));
5886 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
5888 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
5890 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
5894 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
5900 /*******************************************************************
5902 * @brief Builds and sends the InitialULRRCMessage
5906 * Function : BuildAndSendInitialRrcMsgTransfer
5908 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
5909 * it to the CU through SCTP.
5913 * @return ROK - success
5916 * ****************************************************************/
5917 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
5918 uint16_t rrcContSize, uint8_t *rrcContainer)
5923 asn_enc_rval_t encRetVal;
5924 F1AP_PDU_t *f1apMsg = NULLP;
5925 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
5926 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
5930 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
5931 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
5932 if(f1apMsg == NULLP)
5934 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
5937 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
5938 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
5939 if(f1apMsg->choice.initiatingMessage == NULLP)
5941 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
5944 f1apMsg->choice.initiatingMessage->procedureCode =\
5945 ProcedureCode_id_InitialULRRCMessageTransfer;
5946 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
5947 f1apMsg->choice.initiatingMessage->value.present = \
5948 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
5950 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
5952 initULRRCMsg->protocolIEs.list.count = elementCnt;
5953 initULRRCMsg->protocolIEs.list.size = \
5954 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
5955 /* Initialize the F1Setup members */
5956 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
5957 if(initULRRCMsg->protocolIEs.list.array == NULLP)
5959 DU_LOG(" ERROR --> F1AP : Memory allocation for\
5960 RRCSetupRequestMessageTransferIEs failed");
5963 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
5965 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
5966 sizeof(InitialULRRCMessageTransferIEs_t));
5967 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
5973 /*GNB DU UE F1AP ID*/
5974 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
5975 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
5976 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
5977 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
5978 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
5979 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
5984 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
5985 ProtocolIE_ID_id_NRCGI;
5986 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
5987 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
5988 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
5991 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
5999 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6000 ProtocolIE_ID_id_C_RNTI;
6001 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6002 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6003 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
6004 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
6008 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6009 ProtocolIE_ID_id_RRCContainer;
6010 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6011 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6012 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
6014 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
6015 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
6016 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
6017 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6019 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
6023 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
6024 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6027 /*DUtoCURRCContainer*/
6029 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
6030 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6031 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6032 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
6034 ret = BuildDuToCuRrcContainer(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
6040 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
6042 /* Encode the F1SetupRequest type as APER */
6043 memset(encBuf, 0, ENC_BUF_MAX_LEN);
6045 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
6046 /* Encode results */
6047 if(encRetVal.encoded == ENCODE_FAIL)
6049 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
6050 structure (at %s)\n",encRetVal.failed_type ? \
6051 encRetVal.failed_type->name : "unknown");
6058 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
6059 Message transfer\n");
6060 for(int i=0; i< encBufSize; i++)
6062 printf("%x",encBuf[i]);
6066 if(sendF1APMsg() != ROK)
6068 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
6074 freeInitUlRrcMsgTransfer(f1apMsg);
6076 }/* End of BuildAndSendInitialRrcMsgTransfer*/
6078 /***** UE SETUP REQUEST *****/
6080 /*******************************************************************
6082 * @brief Free Qos And Snssai Drb Info
6086 * Function : freeDrbQosAndSnssaiInfo
6088 * Functionality: Free Qos And Snssai Drb Info
6090 * @params[in] LcCfg *lcCfg,
6093 * ****************************************************************/
6094 void freeDrbQosAndSnssaiInfo(LcCfg *lcCfg)
6098 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6102 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6106 /******************************************************************
6108 * @brief Function to delete the RLC Lc cfg from UE APP DB
6112 * Function : freeRlcLcCfg
6114 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
6117 *****************************************************************/
6119 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
6121 switch(lcCfg->rlcMode)
6127 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
6131 case RLC_UM_BI_DIRECTIONAL :
6133 if(lcCfg->u.umBiDirCfg)
6135 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
6139 case RLC_UM_UNI_DIRECTIONAL_UL :
6141 if(lcCfg->u.umUniDirUlCfg)
6143 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
6148 case RLC_UM_UNI_DIRECTIONAL_DL :
6150 if(lcCfg->u.umUniDirDlCfg)
6152 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
6157 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
6162 /*******************************************************************
6164 * @brief Function to free MacLcCfg
6168 * Function : freeMacLcCfg
6170 * Functionality: Function to free MacLcCfg
6172 * @params[in] LcCfg *lcCfg,
6175 * ****************************************************************/
6177 void freeMacLcCfg(LcCfg *lcCfg)
6179 /* Deleting DRBQOS */
6182 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6184 /* Deleting SNSSAI */
6187 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6190 /*******************************************************************
6192 * @brief Free UE NR Capability received in UE Context setup request
6196 * Function : freeAperDecodeUeNrCapability
6199 * Free UE NR Capability received in UE Context setup request
6202 * @return ROK - success
6205 * ****************************************************************/
6206 void freeAperDecodeUeNrCapability(void *ueNrCapability)
6209 FeatureSets_t *featureSets =NULLP;
6210 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
6212 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
6214 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
6216 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
6217 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
6219 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
6222 if(ueNrCap->featureSets)
6224 featureSets = ueNrCap->featureSets;
6225 if(featureSets->featureSetsDownlinkPerCC)
6227 if(featureSets->featureSetsDownlinkPerCC->list.array)
6229 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
6231 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
6233 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
6234 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
6235 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
6238 free(featureSets->featureSetsDownlinkPerCC->list.array);
6240 free(featureSets->featureSetsDownlinkPerCC);
6242 if(featureSets->featureSetsUplinkPerCC)
6244 if(featureSets->featureSetsUplinkPerCC->list.array)
6246 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
6248 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
6250 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
6251 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
6252 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
6255 free(featureSets->featureSetsUplinkPerCC->list.array);
6257 free(featureSets->featureSetsUplinkPerCC);
6259 free(ueNrCap->featureSets);
6263 /*******************************************************************
6265 * @brief Function to free PdcchSearchSpcToAddModList
6266 where memory allocated by aper_decoder
6270 * Function : freeAperDecodePdcchSearchSpcToAddModList
6272 * Functionality: Function to free PdcchSearchSpcToAddModList
6274 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
6277 * ****************************************************************/
6279 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
6281 uint8_t searchSpcArrIdx=0;
6282 uint8_t searchSpcArrIdx1=0;
6283 struct SearchSpace *searchSpc=NULLP;
6286 if(searchSpcList->list.array)
6288 if(searchSpcList->list.array[searchSpcArrIdx1])
6290 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
6291 if(searchSpc->controlResourceSetId)
6293 if(searchSpc->monitoringSlotPeriodicityAndOffset)
6295 if(searchSpc->monitoringSymbolsWithinSlot)
6297 if(searchSpc->monitoringSymbolsWithinSlot->buf)
6299 if(searchSpc->nrofCandidates)
6301 if(searchSpc->searchSpaceType)
6303 free(searchSpc->searchSpaceType->choice.ue_Specific);
6304 free(searchSpc->searchSpaceType);
6306 free(searchSpc->nrofCandidates);
6308 free(searchSpc->monitoringSymbolsWithinSlot->buf);
6310 free(searchSpc->monitoringSymbolsWithinSlot);
6312 free(searchSpc->monitoringSlotPeriodicityAndOffset);
6314 free(searchSpc->controlResourceSetId);
6317 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
6319 free(searchSpcList->list.array[searchSpcArrIdx]);
6321 free(searchSpcList->list.array);
6324 /*******************************************************************
6326 * @brief Function for free part for the memory allocated by aper_decoder
6330 * Function : freeAperDecodeBWPDlDedPdcchConfig
6332 * Functionality: Function to free BWPDlDedPdcchConfig
6337 * ****************************************************************/
6340 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
6344 struct PDCCH_Config *pdcchCfg=NULLP;
6345 struct ControlResourceSet *controlRSet=NULLP;
6346 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
6348 if(dlBwp->pdcch_Config->choice.setup)
6350 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
6351 if(pdcchCfg->controlResourceSetToAddModList)
6353 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
6354 if(controlRSetList->list.array)
6356 controlRSet = controlRSetList->list.array[arrIdx2];
6359 if(controlRSet->frequencyDomainResources.buf)
6361 if(controlRSet->pdcch_DMRS_ScramblingID)
6363 if(pdcchCfg->searchSpacesToAddModList)
6365 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
6366 free(pdcchCfg->searchSpacesToAddModList);
6368 free(controlRSet->pdcch_DMRS_ScramblingID);
6370 free(controlRSet->frequencyDomainResources.buf);
6373 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
6375 free(controlRSetList->list.array[arrIdx1]);
6377 free(controlRSetList->list.array);
6379 free(pdcchCfg->controlResourceSetToAddModList);
6381 free(dlBwp->pdcch_Config->choice.setup);
6384 /*******************************************************************
6386 * @brief Function to free PdschTimeDomAllocationList
6387 * where the memory allocated by aper_decoder
6391 * Function : freeAperDecodePdschTimeDomAllocationList
6393 * Functionality: Function to free PdschTimeDomAllocationList
6395 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
6398 * ****************************************************************/
6401 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
6405 if(timeDomAllocList->choice.setup)
6407 if(timeDomAllocList->choice.setup->list.array)
6409 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
6411 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
6413 free(timeDomAllocList->choice.setup->list.array);
6415 free(timeDomAllocList->choice.setup);
6419 /*******************************************************************
6421 * @brief Function to free BWPDlDedPdschConfig
6422 * where the memory allocated by aper_decoder
6426 * Function : freeAperDecodeBWPDlDedPdschConfig
6428 * Functionality: Function to free BWPDlDedPdschConfig
6430 * @params[in] BWP_DownlinkDedicated_t *dlBwp
6433 * ****************************************************************/
6436 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
6438 struct PDSCH_Config *pdschCfg=NULLP;
6439 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
6440 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
6441 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
6443 if(dlBwp->pdsch_Config->choice.setup)
6445 pdschCfg=dlBwp->pdsch_Config->choice.setup;
6446 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
6448 if(pdschCfg->pdsch_TimeDomainAllocationList)
6450 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
6451 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
6453 prbBndlType=&pdschCfg->prb_BundlingType;
6454 free(prbBndlType->choice.staticBundling);
6455 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
6457 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
6458 free(pdschCfg->pdsch_TimeDomainAllocationList);
6460 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
6461 if(dmrsDlCfg->choice.setup)
6463 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
6464 free(dmrsDlCfg->choice.setup);
6466 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
6468 free(dlBwp->pdsch_Config->choice.setup);
6471 /*******************************************************************
6473 * @brief Function to free PuschTimeDomAllocListCfg
6474 where the memory allocated by aper_decoder
6478 * Function : freeAperDecodePuschTimeDomAllocListCfg
6480 * Functionality: Function to free PuschTimeDomAllocListCfg
6482 * @params[in] PUSCH_Config_t *puschCfg
6485 * ****************************************************************/
6488 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
6492 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
6494 if(puschCfg->pusch_TimeDomainAllocationList)
6496 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
6497 if(timeDomAllocList_t->choice.setup)
6499 if(timeDomAllocList_t->choice.setup->list.array)
6501 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
6502 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
6504 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
6506 free(timeDomAllocList_t->choice.setup->list.array);
6508 free(timeDomAllocList_t->choice.setup);
6510 free(puschCfg->transformPrecoder);
6511 free(puschCfg->pusch_TimeDomainAllocationList);
6514 /*******************************************************************
6516 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
6520 * Function : freeAperDecodeInitialUlBWPConfig
6522 * Functionality: Function to free InitialUlBWPConfig
6524 * @params[in] BWP_UplinkDedicated_t *ulBwp
6527 * ****************************************************************/
6530 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
6534 SRS_Config_t *srsCfg = NULLP;
6535 PUSCH_Config_t *puschCfg = NULLP;
6536 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
6537 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
6538 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
6539 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
6541 if(ulBwp->pusch_Config)
6543 if(ulBwp->pusch_Config->choice.setup)
6545 puschCfg=ulBwp->pusch_Config->choice.setup;
6546 if(puschCfg->dataScramblingIdentityPUSCH)
6548 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
6550 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
6551 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
6552 if(dmrsUlCfg->choice.setup)
6554 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
6556 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
6558 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
6559 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
6561 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
6563 free(dmrsUlCfg->choice.setup);
6565 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
6567 free(puschCfg->dataScramblingIdentityPUSCH);
6569 free(ulBwp->pusch_Config->choice.setup);
6571 free(ulBwp->pusch_Config);
6573 /* Free SRS-Config */
6574 if(ulBwp->srs_Config)
6576 if(ulBwp->srs_Config->choice.setup)
6578 srsCfg = ulBwp->srs_Config->choice.setup;
6580 /* Free Resource Set to add/mod list */
6581 if(srsCfg->srs_ResourceSetToAddModList)
6583 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
6584 if(rsrcSetList->list.array)
6588 /* Free SRS resource Id list in this SRS resource set */
6589 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
6592 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
6594 if(rsrcIdList->list.array)
6596 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
6599 free(rsrcIdList->list.array[rsrcIdx]);
6601 free(rsrcIdList->list.array);
6603 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
6606 /* Free resource type info for this SRS resource set */
6608 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
6610 /* Free memory for each resource set */
6611 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
6613 free(rsrcSetList->list.array[rSetIdx]);
6615 free(rsrcSetList->list.array);
6617 free(srsCfg->srs_ResourceSetToAddModList);
6620 /* Free resource to add/modd list */
6621 if(srsCfg->srs_ResourceToAddModList)
6623 resourceList = srsCfg->srs_ResourceToAddModList;
6624 if(resourceList->list.array)
6628 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
6629 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
6631 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
6633 free(resourceList->list.array[rsrcIdx]);
6635 free(resourceList->list.array);
6637 free(srsCfg->srs_ResourceToAddModList);
6640 free(ulBwp->srs_Config->choice.setup);
6642 free(ulBwp->srs_Config);
6646 /*******************************************************************
6648 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
6652 * Function : freeAperDecodeinitialUplinkBWPConfig
6654 * Functionality: Function to free initialUplinkBWPConfig
6656 * @params[in] UplinkConfig_t *ulCfg
6659 * ****************************************************************/
6662 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
6664 BWP_UplinkDedicated_t *ulBwp=NULLP;
6665 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
6667 if(ulCfg->initialUplinkBWP)
6669 ulBwp=ulCfg->initialUplinkBWP;
6670 if(ulCfg->firstActiveUplinkBWP_Id)
6672 if(ulCfg->pusch_ServingCellConfig)
6674 puschCfg=ulCfg->pusch_ServingCellConfig;
6675 if(puschCfg->choice.setup)
6677 if(puschCfg->choice.setup->ext1)
6679 free(puschCfg->choice.setup->ext1->processingType2Enabled);
6680 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
6681 free(puschCfg->choice.setup->ext1);
6683 free(puschCfg->choice.setup);
6685 free(ulCfg->pusch_ServingCellConfig);
6687 free(ulCfg->firstActiveUplinkBWP_Id);
6689 freeAperDecodeInitialUlBWPConfig(ulBwp);
6690 free(ulCfg->initialUplinkBWP);
6694 /*******************************************************************
6696 * @brief Function to free DuUeCfg
6700 * Function : freeDuUeCfg
6702 * Functionality: Function to free DuUeCfg
6704 * @params[in] DuUeCfg *ueCfg
6707 * ****************************************************************/
6708 void freeDuUeCfg(DuUeCfg *ueCfg)
6712 SpCellConfig_t *spCellCfg = NULLP;
6713 ServingCellConfig_t *srvCellCfg = NULLP;
6714 BWP_DownlinkDedicated_t *dlBwp = NULLP;
6715 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
6716 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
6717 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
6718 struct RLC_Config *rlcConfig = NULLP;
6719 struct LogicalChannelConfig *macLcConfig = NULLP;
6720 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
6721 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
6722 struct TAG_Config *tagConfig = NULLP;
6723 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
6724 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
6725 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
6726 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
6728 if(ueCfg->ueNrCapability)
6730 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
6731 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
6732 ueCfg->ueNrCapability = NULLP;
6735 if(ueCfg->cellGrpCfg)
6738 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
6741 if(rlcBearerList->list.array)
6743 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
6745 if(rlcBearerList->list.array[arrIdx])
6747 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
6748 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
6750 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
6752 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
6756 if(rlcConfig->choice.am)
6758 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
6759 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
6760 free(rlcConfig->choice.am);
6762 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
6766 if(macLcConfig->ul_SpecificParameters)
6768 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
6769 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
6770 free(macLcConfig->ul_SpecificParameters);
6772 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
6774 free(rlcBearerList->list.array[arrIdx]);
6777 free(rlcBearerList->list.array);
6779 free(cellGrpCfg->rlc_BearerToAddModList);
6782 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
6785 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
6786 if(schedulingRequestConfig)
6788 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
6791 if(schReqList->list.array)
6793 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
6795 if(schReqList->list.array[arrIdx])
6797 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
6798 free(schReqList->list.array[arrIdx]);
6801 free(schReqList->list.array);
6803 free(schedulingRequestConfig->schedulingRequestToAddModList);
6805 free(macCellGrpCfg->schedulingRequestConfig);
6807 if(macCellGrpCfg->bsr_Config)
6809 free(macCellGrpCfg->bsr_Config);
6811 tagConfig = macCellGrpCfg->tag_Config;
6814 tagList = tagConfig->tag_ToAddModList;
6817 if(tagList->list.array)
6819 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
6821 free(tagList->list.array[arrIdx]);
6823 free(tagList->list.array);
6825 free(tagConfig->tag_ToAddModList);
6830 phrConfig = macCellGrpCfg->phr_Config;
6833 free(phrConfig->choice.setup);
6837 free(macCellGrpCfg);
6840 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
6843 free(phyCellGrpCfg->p_NR_FR1);
6844 free(phyCellGrpCfg);
6847 spCellCfg = cellGrpCfg->spCellConfig;
6850 if(spCellCfg->servCellIndex)
6852 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
6854 if(spCellCfg->spCellConfigDedicated)
6856 srvCellCfg = spCellCfg->spCellConfigDedicated;
6857 if(srvCellCfg->initialDownlinkBWP)
6859 dlBwp = srvCellCfg->initialDownlinkBWP;
6860 if(srvCellCfg->firstActiveDownlinkBWP_Id)
6862 if(srvCellCfg->defaultDownlinkBWP_Id)
6864 if(srvCellCfg->uplinkConfig)
6867 if(srvCellCfg->pdsch_ServingCellConfig)
6870 srvCellCfg->pdsch_ServingCellConfig;
6871 if(pdschCfg->choice.setup)
6874 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
6875 free(pdschCfg->choice.setup);
6878 free(srvCellCfg->pdsch_ServingCellConfig);
6881 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
6882 free(srvCellCfg->uplinkConfig);
6884 free(srvCellCfg->defaultDownlinkBWP_Id);
6887 free(srvCellCfg->firstActiveDownlinkBWP_Id);
6889 if(dlBwp->pdcch_Config)
6891 if(dlBwp->pdsch_Config)
6893 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
6894 free(dlBwp->pdsch_Config);
6896 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
6897 free(dlBwp->pdcch_Config);
6899 free(srvCellCfg->initialDownlinkBWP);
6902 free(spCellCfg->spCellConfigDedicated);
6904 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
6906 free(spCellCfg->servCellIndex);
6910 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
6911 ueCfg->cellGrpCfg = NULLP;
6915 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
6917 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
6919 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx]);
6921 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
6923 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
6925 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
6927 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
6931 /*******************************************************************
6933 * @brief Function to free UecontextSetupDb
6937 * Function : freeF1UeDb
6939 * Functionality: Function to free UecontextSetupDb
6941 * @params[in] UecontextSetupDb *
6944 * ****************************************************************/
6946 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
6949 if(f1UeDb->dlRrcMsg)
6951 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
6953 //DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
6954 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
6956 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
6958 freeDuUeCfg(&f1UeDb->duUeCfg);
6959 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
6960 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
6963 /*******************************************************************
6965 * @brief Function to build Am cfg Info
6969 * Function : extractRlcAmCfg
6971 * Functionality: Function to build Am cfg Info
6973 * @params[in] AmBearerCfg *
6976 * @return ROK/RFAILED
6978 * ****************************************************************/
6980 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
6985 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
6987 amCfgToSet->ulAmCfg.snLenUl = *(rlcAmCfg->dl_AM_RLC.sn_FieldLength);
6988 /*TODO: Check the timer value when sent by real CU */
6989 amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly;
6990 amCfgToSet->ulAmCfg.statProhTmr = rlcAmCfg->dl_AM_RLC.t_StatusProhibit;
6994 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
6996 amCfgToSet->dlAmCfg.snLenDl = *(rlcAmCfg->ul_AM_RLC.sn_FieldLength);
6997 amCfgToSet->dlAmCfg.pollRetxTmr = rlcAmCfg->ul_AM_RLC.t_PollRetransmit;
6998 amCfgToSet->dlAmCfg.pollPdu = rlcAmCfg->ul_AM_RLC.pollPDU;
6999 amCfgToSet->dlAmCfg.pollByte = rlcAmCfg->ul_AM_RLC.pollByte;
7000 amCfgToSet->dlAmCfg.maxRetxTh = rlcAmCfg->ul_AM_RLC.maxRetxThreshold;
7005 /*******************************************************************
7007 * @brief Function to build Um Bi Info
7011 * Function : extractRlcUmBiCfg
7013 * Functionality: Function to build Um Bi Info
7015 * @params[in] UmBiDirBearerCfg *
7018 * @return ROK/RFAILED
7020 * ****************************************************************/
7022 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
7026 /* UL UM BI DIR Cfg */
7027 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
7029 umBiCfgToSet->ulUmCfg.snLenUlUm = *(rlcBiCfg->dl_UM_RLC.sn_FieldLength);
7030 umBiCfgToSet->ulUmCfg.reAssemTmr = rlcBiCfg->dl_UM_RLC.t_Reassembly;
7033 /* DL UM BI DIR Cfg */
7034 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
7035 umBiCfgToSet->dlUmCfg.snLenDlUm = *(rlcBiCfg->ul_UM_RLC.sn_FieldLength);
7039 /*******************************************************************
7041 * @brief Function to build Um Ul Info
7045 * Function : extractRlcUmUlCfg
7047 * Functionality: Function to build Um Ul Info
7049 * @params[in] UmUniDirUlBearerCfg *
7052 * @return ROK/RFAILED
7054 * ****************************************************************/
7056 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
7060 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
7062 umUlCfgToSet->ulUmCfg.snLenUlUm = *(umUlCfg->dl_UM_RLC.sn_FieldLength);
7063 umUlCfgToSet->ulUmCfg.reAssemTmr = umUlCfg->dl_UM_RLC.t_Reassembly;
7068 /*******************************************************************
7070 * @brief Function to build Um Uni Dl Info
7074 * Function : extractRlcUmDlCfg
7076 * Functionality: Function to build Um Uni Dl Info
7078 * @params[in] UmUniDirDlBearerCfg *
7081 * @return ROK/RFAILED
7083 * ****************************************************************/
7084 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
7088 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
7089 umDlCfgToSet->dlUmCfg.snLenDlUm = *(umDlCfg->ul_UM_RLC.sn_FieldLength);
7093 /*******************************************************************
7095 * @brief Function to extractRlcModeCfg
7099 * Function : extractRlcModeCfg
7101 * Functionality: Function to extractRlcModeCfg
7103 * @params[in] RLC_Config_t *
7106 * @return ROK/RFAILED
7108 * ****************************************************************/
7109 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
7117 if(lcCfg->choice.am)
7119 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
7120 if(rlcDbCfg->u.amCfg)
7121 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
7125 case RLC_UM_BI_DIRECTIONAL :
7127 if(lcCfg->choice.um_Bi_Directional)
7129 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
7130 if(rlcDbCfg->u.umBiDirCfg)
7131 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
7135 case RLC_UM_UNI_DIRECTIONAL_UL :
7137 if(lcCfg->choice.um_Uni_Directional_DL)
7139 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
7140 if(rlcDbCfg->u.umUniDirUlCfg)
7141 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
7145 case RLC_UM_UNI_DIRECTIONAL_DL :
7147 if(lcCfg->choice.um_Uni_Directional_UL)
7149 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
7150 if(rlcDbCfg->u.umUniDirDlCfg)
7151 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
7156 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
7162 /*******************************************************************
7164 * @brief Function to extract extractUlLcCfg
7168 * Function : extractUlLcCfg
7170 * Functionality: Function to extract extractUlLcCfg
7172 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
7175 * ****************************************************************/
7177 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
7181 if(ulLcCfg->ul_SpecificParameters)
7183 f1UlLcCfg->priority = \
7184 ulLcCfg->ul_SpecificParameters->priority;
7185 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
7187 f1UlLcCfg->lcGroup = \
7188 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
7190 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
7192 f1UlLcCfg->schReqId = \
7193 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
7196 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
7198 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
7203 /*******************************************************************
7205 * @brief Function to procRlcLcCfg
7209 * Function : procRlcLcCfg
7211 * Functionality: Function to procRlcLcCfg
7213 * @params[in] rbId, lcId, rbType, rlcMod
7214 * RLC_Config_t *, RlcBearerCfg * ,
7217 * ****************************************************************/
7219 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
7220 uint8_t configType, RLC_Config_t *f1RlcCfg, RlcBearerCfg *lcCfg)
7224 lcCfg->configType = configType;
7226 if(rbType == RB_TYPE_SRB)
7228 lcCfg->rbType = RB_TYPE_SRB;
7230 lcCfg->lcType = LCH_DCCH;
7231 lcCfg->rlcMode = RLC_AM;
7233 else if(rbType == RB_TYPE_DRB)
7235 lcCfg->rbType = RB_TYPE_DRB;
7237 lcCfg->lcType = LCH_DTCH;
7238 lcCfg->rlcMode = rlcMode;
7240 if(f1RlcCfg) /* rlc mode config recived */
7242 extractRlcModeCfg(lcCfg->rlcMode, lcCfg, f1RlcCfg);
7248 /*******************************************************************
7250 * @brief Fills DrbQos Info received by CU
7254 * Function : extractQosInfo
7256 * Functionality: Fills DrbQos Info received by CU
7258 * @params[in] DrbQosInfo *qosToAdd,
7259 * QoSFlowLevelQoSParameters_t *qosFlowCfg
7262 * ****************************************************************/
7264 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
7266 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
7267 qosToAdd->u.nonDyn5Qi.fiveQi =\
7268 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
7269 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
7271 qosToAdd->u.nonDyn5Qi.avgWindow = \
7272 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
7274 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
7275 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
7276 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
7278 qosToAdd->u.nonDyn5Qi.priorLevel = \
7279 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
7281 qosToAdd->ngRanRetPri.priorityLevel = \
7282 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
7283 qosToAdd->ngRanRetPri.preEmptionCap = \
7284 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
7285 qosToAdd->ngRanRetPri.preEmptionVul = \
7286 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
7287 if(qosFlowCfg->gBR_QoS_Flow_Information)
7289 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
7290 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
7291 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
7292 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
7293 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
7294 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
7295 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
7296 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
7297 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
7298 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
7299 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
7300 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
7302 qosToAdd->pduSessionId = 0;
7303 qosToAdd->ulPduSessAggMaxBitRate = 0;
7306 /*******************************************************************
7308 * @brief Function to extract GTP Tunnel Info from CU
7312 * Function : extractUpTnlInfo
7314 * Functionality: Function to extract GTP Tunnel Info from CU
7316 * @params[in] F1AP message
7317 * @return ROK/RFAILED
7319 * ****************************************************************/
7321 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
7322 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
7325 uint32_t ipv4_du = 0;
7326 GTPTunnel_t *gtpTunnel = NULLP;
7328 upTnlInfo->drbId = drbId;
7329 upTnlInfo->configType = configType;
7331 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
7333 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
7336 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
7338 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
7340 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
7342 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
7343 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
7344 if(upTnlInfo->tnlCfg1 == NULLP)
7346 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
7349 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
7350 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
7351 if(gtpTunnel->gTP_TEID.size > 0)
7353 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
7361 /*******************************************************************
7363 * @brief Function to extract Drb Qos Cfg Info from CU
7367 * Function : extractDrbQosCfg
7369 * Functionality: Function to extract Drb Qos Cfg Info from CU
7371 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
7372 * @return ROK/RFAILED
7374 * ****************************************************************/
7376 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
7378 if(!macLcToAdd->drbQos)
7380 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
7381 if(macLcToAdd->drbQos == NULLP)
7383 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbCfg()");
7388 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
7390 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
7391 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
7393 if(!macLcToAdd->snssai)
7395 DU_ALLOC_SHRABL_BUF(macLcToAdd->snssai, sizeof(Snssai));
7396 if(macLcToAdd->snssai == NULLP)
7398 DU_LOG("\nERROR --> DUAPP : Memory failed at allocating SNSSAI at extractDrbCfg()");
7402 memcpy(&macLcToAdd->snssai->sst, drbInfo->sNSSAI.sST.buf, \
7403 drbInfo->sNSSAI.sST.size);
7404 if(drbInfo->sNSSAI.sD)
7406 memcpy(macLcToAdd->snssai->sd, drbInfo->sNSSAI.sD->buf, \
7407 drbInfo->sNSSAI.sD->size);
7411 /*******************************************************************
7413 * @brief Function to extract DRB info received from CU
7417 * Function : extractDrbCfg
7419 * Functionality: Function to extract DRB info received from CU
7421 * @params[in] F1AP message
7424 * ****************************************************************/
7425 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem,DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
7426 LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
7428 DRB_Information_t *drbInfo = NULLP;
7430 if(drbItem != NULLP)
7432 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
7434 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7437 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7439 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
7441 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7442 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7444 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7450 else if(drbSetupModItem != NULLP)
7452 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
7455 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7458 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7460 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
7461 QoSInformation_ExtIEs__value_PR_DRB_Information)
7463 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7464 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7466 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7477 /*******************************************************************
7479 * @brief Function to extract RB info received from CU
7483 * Function : extractMacRbCfg
7485 * Functionality: Function to extract RB info received from CU
7487 * @params[in] F1AP message
7488 * @return ROK/RFAILED
7490 * ****************************************************************/
7492 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
7493 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7497 if(extractDrbCfg(drbCfg, NULL, lcCfg, upTnlInfo) != ROK)
7499 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7503 else if(drbSetupModCfg != NULLP)
7505 if(extractDrbCfg(NULL, drbSetupModCfg, lcCfg, upTnlInfo) != ROK)
7507 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7513 lcCfg->drbQos = NULLP;
7514 lcCfg->snssai = NULLP;
7515 if(lcCfg->lcId == SRB2_LCID)
7516 lcCfg->dlLcCfg.lcp = LC_PRIORITY_3;
7518 lcCfg->dlLcCfg.lcp = LC_PRIORITY_1;
7522 lcCfg->ulLcCfgPres = true;
7523 extractUlLcCfg(&lcCfg->ulLcCfg, ulLcCfg);
7526 lcCfg->ulLcCfgPres = false;
7530 /*******************************************************************
7532 * @brief Function processing LC config info received from CU
7536 * Function : procMacLcCfg
7538 * Functionality: Function processing LC config info received from CU
7540 * @params[in] F1AP message
7541 * @return ROK/RFAILED
7543 * ****************************************************************/
7545 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType,\
7546 DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LogicalChannelConfig_t *ulLcCfg,\
7547 LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7552 lcCfg->configType = configType;
7553 if(rbType == RB_TYPE_SRB)
7555 ret = extractMacRbCfg(lcId, NULL,NULL, ulLcCfg, lcCfg, NULL);
7557 else if(rbType == RB_TYPE_DRB)
7560 ret = extractMacRbCfg(lcId, drbItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
7561 else if(drbSetupModItem != NULL)
7562 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, ulLcCfg, lcCfg, upTnlInfo);
7567 /*******************************************************************
7569 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
7573 * Function : extractRlcCfgToAddMod
7575 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
7577 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
7579 * @return ROK/RFAILED
7581 * ****************************************************************/
7583 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
7585 uint8_t idx, rbId, lcId, rlcMode, rbType;
7586 RLC_Config_t *f1RlcCfg = NULLP;
7587 LogicalChannelConfig_t *macUlLcCfg = NULLP;
7589 for(idx = 0; idx < lcCfg->list.count; idx++)
7591 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
7592 if(lcCfg->list.array[idx]->servedRadioBearer)
7594 /* RadioBearer for SRB/DRB */
7595 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7596 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
7598 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
7599 rbType = RB_TYPE_SRB;
7601 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7602 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
7604 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
7605 rbType = RB_TYPE_DRB;
7609 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
7612 /* MAC UL LC Config */
7613 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
7615 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
7620 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
7623 /* RLC Mode Config */
7624 if(lcCfg->list.array[idx]->rlc_Config)
7626 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
7627 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
7630 /* Filling RLC/MAC Config*/
7631 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
7632 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
7633 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]));
7634 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
7636 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
7639 (ueCfgDb->numRlcLcs)++;
7640 (ueCfgDb->numMacLcs)++;
7642 //TODO: To send the failure cause in UeContextSetupRsp
7646 /*******************************************************************
7648 * @brief DeAlloc pdsch serv cell config info
7652 * Function : freeMacPdschServCellInfo
7654 * Functionality: DeAlloc pdsch serv cell config info
7656 * @params[in] PdschServCellCfg pointer
7659 * ****************************************************************/
7661 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
7663 if(pdsch->xOverhead)
7665 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
7667 if(pdsch->codeBlkGrpFlushInd)
7669 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
7671 if(pdsch->maxCodeBlkGrpPerTb)
7673 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
7675 if(pdsch->maxMimoLayers)
7677 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
7681 /*******************************************************************
7683 * @brief Free Serving cell Info
7687 * Function : freeMacServingCellInfo
7689 * Functionality: Free Serving cell Info
7691 * @params[in] ServCellCfgInfo *srvCellCfg
7694 * ****************************************************************/
7695 void freeMacServingCellInfo(ServCellCfgInfo *srvCellCfg)
7697 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
7698 if(srvCellCfg->bwpInactivityTmr)
7700 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
7704 /*******************************************************************
7706 * @brief Free cell Grp Cfg Info
7710 * Function : freeUeReCfgCellGrpInfo
7712 * Functionality: Free cell Grp Cfg Info
7714 * @params[in] MacUeCfg* duUeCfg
7717 * ****************************************************************/
7719 void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg)
7721 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
7724 /*******************************************************************
7726 * @brief Fills Reconfig SchReqReConfig
7730 * Function : extractSchReqReConfig
7732 * Functionality: Fills Reconfig SchReqReConfig
7734 * @params[in] SchedulingRequestConfig_t *cuSchedReq
7735 * SchedReqCfg* macSchedReq
7738 * ****************************************************************/
7739 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
7741 uint8_t schReqIdx = 0;
7742 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
7743 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
7745 if(cuSchedReq->schedulingRequestToAddModList)
7747 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
7748 if(schReqListToAdd->list.count)
7750 macSchedReq->addModListCount = schReqListToAdd->list.count;
7751 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
7753 macSchedReq->addModList[schReqIdx].schedReqId = \
7754 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
7755 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
7756 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
7757 macSchedReq->addModList[schReqIdx].srTransMax =\
7758 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
7762 /* Scheduling Req To release */
7763 if(cuSchedReq->schedulingRequestToReleaseList)
7765 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
7766 if(schReqListToRel->list.count)
7768 macSchedReq->relListCount = schReqListToRel->list.count;
7769 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
7771 macSchedReq->relList[schReqIdx] = \
7772 *schReqListToRel->list.array[schReqIdx];
7778 /*******************************************************************
7780 * @brief Fills TagReconfig
7784 * Function : extractTagReconfig
7786 * Functionality: Fills extractTagReconfig
7788 * @params[in] TAG_Config_t *cuTagCfg
7792 * ****************************************************************/
7794 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
7797 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
7798 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
7800 /* Tag config to AddMod */
7801 if(cuTagCfg->tag_ToAddModList)
7803 tagListToAddMod = cuTagCfg->tag_ToAddModList;
7804 if(tagListToAddMod->list.count)
7806 macTagCfg->addModListCount = tagListToAddMod->list.count;
7807 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
7809 macTagCfg->addModList[tagIdx].tagId =\
7810 tagListToAddMod->list.array[tagIdx]->tag_Id;
7811 macTagCfg->addModList[tagIdx].timeAlignTimer = \
7813 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
7817 /* Tag config to release */
7818 if(cuTagCfg->tag_ToReleaseList)
7820 tagListToRel = cuTagCfg->tag_ToReleaseList;
7821 if(tagListToRel->list.count)
7823 macTagCfg->relListCount = tagListToRel->list.count;
7824 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
7826 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
7832 /*******************************************************************
7834 * @brief Fills PdcchCfg received by CU
7838 * Function : extractPdcchCfg
7840 * Functionality: Fills PdcchCfg received by CU
7842 * @params[in] PDCCH_Config_t *cuPdcchCfg,
7843 * PdcchConfig *duPdcchCfg
7846 * ****************************************************************/
7848 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
7850 uint8_t cRsetIdx = 0;
7851 uint8_t srchSpcIdx = 0;
7853 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
7854 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
7855 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
7856 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
7859 /* Control Resource Set To Add/Mod List */
7860 if(cuPdcchCfg->controlResourceSetToAddModList)
7862 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
7863 if(cRsetToAddModList->list.count)
7865 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
7866 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
7868 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
7869 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
7870 bitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
7871 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
7872 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
7873 cRsetToAddModList->list.array[cRsetIdx]->duration;
7875 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
7876 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
7877 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
7879 //TODO: handle the case for Interleaved
7881 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
7882 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
7883 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
7885 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
7886 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
7892 /* Control Resource Set To Release List */
7893 if(cuPdcchCfg->controlResourceSetToReleaseList)
7895 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
7896 if(cRsetToRelList->list.count)
7898 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
7899 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
7901 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
7906 /* Search space To Add/Mod List */
7907 if(cuPdcchCfg->searchSpacesToAddModList)
7909 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
7910 if(srchSpcToAddModList->list.count)
7912 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
7913 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
7915 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
7916 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
7917 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
7918 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
7919 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
7921 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
7922 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
7924 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
7926 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
7927 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
7929 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
7931 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
7932 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
7933 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
7934 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
7935 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
7936 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
7938 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
7939 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
7941 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
7942 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
7944 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
7946 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
7947 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
7948 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
7950 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
7951 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
7958 /* Search space To Rel List */
7959 if(cuPdcchCfg->searchSpacesToReleaseList)
7961 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
7962 if(srchSpcToRelList->list.count)
7964 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
7965 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
7967 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
7968 *(srchSpcToRelList->list.array[srchSpcIdx]);
7974 /*******************************************************************
7976 * @brief Fills PdschCfg received by CU
7980 * Function : extractPdschCfg
7982 * Functionality: Fills PdschCfg received by CU
7984 * @params[in] PDSCH_Config_t *cuPdschCfg,
7985 * PdschConfig *macPdschCfg
7988 * ****************************************************************/
7990 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg)
7993 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
7995 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
7997 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
7998 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
8000 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
8002 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
8003 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
8007 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
8008 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
8010 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
8011 if(timeDomAlloc->present ==\
8012 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
8014 if(timeDomAlloc->choice.setup)
8016 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
8017 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
8019 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
8020 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
8021 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
8022 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8027 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
8028 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
8029 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
8030 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
8032 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8033 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
8035 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
8037 macPdschCfg->bundlingInfo.StaticBundling.size = \
8038 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
8042 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
8044 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8049 /*******************************************************************
8051 * @brief Fills PdschServingCellCfg received by CU
8055 * Function : extractPdschServingCellCfg
8057 * Functionality: Fills PdschCfg received by CU
8059 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
8060 * PdschServCellCfg *macUePdschSrvCellCfg
8061 * @return ROK/RFAILED
8063 * ****************************************************************/
8065 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
8067 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
8069 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
8071 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8073 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8074 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8078 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
8079 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8081 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8082 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8086 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
8090 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8092 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8093 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8097 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
8098 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8100 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8101 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8105 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
8111 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
8113 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
8115 if(cuPdschSrvCellCfg->ext1)
8117 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
8119 if(macUePdschSrvCellCfg->maxMimoLayers)
8121 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8125 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
8126 if(macUePdschSrvCellCfg->maxMimoLayers)
8128 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8132 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
8138 if(cuPdschSrvCellCfg->xOverhead)
8140 if(macUePdschSrvCellCfg->xOverhead)
8142 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8146 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
8147 if(macUePdschSrvCellCfg->xOverhead)
8149 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8153 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
8161 /*******************************************************************
8163 * @brief Fills PuschCfg received by CU
8167 * Function : extractPuschCfg
8169 * Functionality: Fills PuschCfg received by CU
8171 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
8172 * PuschCfg *macPuschCfg
8175 * ****************************************************************/
8177 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
8179 uint8_t timeDomIdx = 0;
8180 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
8181 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
8183 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
8185 if(cuPuschCfg->choice.setup)
8187 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
8189 macPuschCfg->dataScramblingId = \
8190 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
8192 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
8194 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
8196 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
8198 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
8199 if(dmrsUlCfg->dmrs_AdditionalPosition)
8201 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
8202 *(dmrsUlCfg->dmrs_AdditionalPosition);
8204 if(dmrsUlCfg->transformPrecodingDisabled)
8206 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
8208 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
8209 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
8215 /*Res Alloc Type for UL */
8216 if(cuPuschCfg->choice.setup->resourceAllocation)
8218 macPuschCfg->resourceAllocType = \
8219 cuPuschCfg->choice.setup->resourceAllocation;
8221 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
8223 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
8224 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
8226 if(timeDomAllocList->choice.setup)
8228 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
8229 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
8231 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
8232 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
8233 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
8234 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
8235 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
8236 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8241 if(cuPuschCfg->choice.setup->transformPrecoder)
8242 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
8247 /*******************************************************************
8249 * @brief Function to fill pucch Power Control
8253 * Function : extractPucchPowerControl
8255 * Functionality: Function to fill pucch Power Control
8257 * @params[in] PucchPowerControl *pwrCtrl,
8258 * struct PUCCH_PowerControl *cuPwrCtrlCfg
8261 * ****************************************************************/
8263 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
8267 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
8268 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
8269 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
8270 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
8271 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
8272 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
8273 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
8274 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
8275 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
8276 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
8277 if(cuPwrCtrlCfg->p0_Set)
8279 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
8280 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
8282 pwrCtrl->p0Set[arrIdx].p0PucchId =\
8283 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
8284 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
8285 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
8288 if(cuPwrCtrlCfg->pathlossReferenceRSs)
8290 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
8291 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
8293 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
8294 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
8299 /*******************************************************************
8301 * @brief Function to extractResrcSetToAddModList sent by CU
8305 * Function : extractResrcSetToAddModList
8307 * Functionality: Fucntion to extractResrcSetToAddModList
8309 * @params[in] PucchResrcSetCfg pointer,
8310 * struct PUCCH_Config__resourceSetToAddModList pointer
8313 * ****************************************************************/
8315 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
8317 uint8_t arrIdx, rsrcListIdx;
8319 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
8320 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
8322 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
8323 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
8324 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
8325 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
8326 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
8328 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
8329 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
8331 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
8332 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
8334 }/* End of extractResrcSetToAddModList */
8336 /*******************************************************************
8338 * @brief Fills extractResrcToAddModList sent by CU
8342 * Function : extractResrcToAddModList
8344 * Functionality: Fills extractResrcToAddModList
8346 * @params[in] PucchResrcCfg pointer,
8347 * struct PUCCH_Config__resourceToAddModList pointer
8348 * @return ROk/RFAILED
8350 * ****************************************************************/
8352 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
8356 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
8357 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
8359 macResrcList->resrcToAddModList[arrIdx].resrcId =\
8360 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
8361 macResrcList->resrcToAddModList[arrIdx].startPrb =\
8362 cuResrcList->list.array[arrIdx]->startingPRB;
8363 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
8365 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
8366 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
8368 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
8370 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
8371 *cuResrcList->list.array[arrIdx]->secondHopPRB;
8373 /* PUCCH RSRC FORMAT */
8374 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
8376 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
8377 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
8379 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
8380 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
8382 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
8385 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
8386 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
8387 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
8388 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
8389 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
8390 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
8393 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
8395 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
8396 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
8398 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
8399 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
8401 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
8404 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
8405 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
8406 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
8407 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
8408 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
8409 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
8410 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
8411 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
8414 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
8416 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
8417 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
8419 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
8420 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
8422 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
8425 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
8426 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
8427 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
8428 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
8429 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
8430 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
8433 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
8435 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
8436 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
8438 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
8439 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
8441 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
8444 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
8445 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
8446 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
8447 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
8448 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
8449 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
8452 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
8454 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
8455 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
8457 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
8458 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
8460 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
8463 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
8464 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
8465 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
8466 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
8467 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
8468 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
8469 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
8470 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
8476 }/* End of extractResrcToAddModList */
8478 /*******************************************************************
8480 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
8484 * Function : fillPucchSchedReqPeriodAndOffset
8486 * Functionality: To fillPucchSchedReqPeriodAndOffset
8488 * @params[in] macPeriodicty,
8489 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
8492 * ****************************************************************/
8494 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
8495 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
8497 macPeriodicty = cuPeriodicty->present;
8498 switch(macPeriodicty)
8500 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
8502 macOffset = cuPeriodicty->choice.sym2;
8505 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
8507 macOffset = cuPeriodicty->choice.sym6or7;
8510 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
8512 macOffset = cuPeriodicty->choice.sl1;
8515 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
8517 macOffset = cuPeriodicty->choice.sl2;
8520 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
8522 macOffset = cuPeriodicty->choice.sl4;
8525 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
8527 macOffset = cuPeriodicty->choice.sl5;
8530 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
8532 macOffset = cuPeriodicty->choice.sl8;
8535 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
8537 macOffset = cuPeriodicty->choice.sl10;
8540 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
8542 macOffset = cuPeriodicty->choice.sl16;
8545 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
8547 macOffset = cuPeriodicty->choice.sl20;
8550 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
8552 macOffset = cuPeriodicty->choice.sl40;
8555 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
8557 macOffset = cuPeriodicty->choice.sl80;
8560 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
8562 macOffset = cuPeriodicty->choice.sl160;
8565 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
8567 macOffset = cuPeriodicty->choice.sl320;
8570 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
8572 macOffset = cuPeriodicty->choice.sl640;
8576 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
8580 /*******************************************************************
8582 * @brief Function to extractPucchFormatCfg sent by CU
8586 * Function : extractPucchFormatCfg
8588 * Functionality: Function to extractPucchFormatCfg
8590 * @params[in] PucchFormatCfg pointer,
8591 * PUCCH_FormatConfig_t pointer
8594 * ****************************************************************/
8596 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
8598 if(cuFormatCfg->interslotFrequencyHopping)
8599 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
8600 if(cuFormatCfg->additionalDMRS)
8601 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
8602 if(cuFormatCfg->maxCodeRate)
8603 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
8604 if(cuFormatCfg->nrofSlots)
8605 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
8606 if(cuFormatCfg->pi2BPSK)
8607 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
8608 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
8609 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
8610 }/* End of extractPucchFormatCfg */
8612 /*******************************************************************
8614 * @brief Function to extractSchedReqCfgToAddMod sent by CU
8618 * Function : extractSchedReqCfgToAddMod
8620 * Functionality: Function to extractSchedReqCfgToAddMod
8622 * @params[in] PucchSchedReqCfg pointer,
8623 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
8626 * ****************************************************************/
8628 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
8632 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
8633 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
8635 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
8636 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
8637 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
8638 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
8639 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
8641 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
8642 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
8644 if(cuSchedReqList->list.array[arrIdx]->resource)
8646 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
8647 *cuSchedReqList->list.array[arrIdx]->resource;
8651 }/* End of extractSchedReqCfgToAddMod */
8653 /*******************************************************************
8655 * @brief Fills PucchCfg received by CU
8659 * Function : extractPucchCfg
8661 * Functionality: Fills PucchCfg received by CU
8663 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg,
8664 * PucchCfg *macPucchCfg
8665 * @return ROK/RFAILED
8667 * ****************************************************************/
8669 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg)
8673 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
8675 if(cuPucchCfg->choice.setup)
8677 /* Resource Set Cfg */
8678 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
8680 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
8681 if(macPucchCfg->resrcSet == NULLP)
8683 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
8686 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
8687 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
8691 if(cuPucchCfg->choice.setup->resourceToAddModList)
8693 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
8694 if(macPucchCfg->resrc == NULLP)
8696 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
8699 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
8700 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
8704 if(cuPucchCfg->choice.setup->format1)
8706 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
8707 if(macPucchCfg->format1 == NULLP)
8709 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
8712 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
8713 extractPucchFormatCfg(macPucchCfg->format1,\
8714 cuPucchCfg->choice.setup->format1->choice.setup);
8718 if(cuPucchCfg->choice.setup->format2)
8720 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
8721 if(macPucchCfg->format2 == NULLP)
8723 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
8726 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
8727 extractPucchFormatCfg(macPucchCfg->format2,\
8728 cuPucchCfg->choice.setup->format2->choice.setup);
8732 if(cuPucchCfg->choice.setup->format3)
8734 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
8735 if(macPucchCfg->format3 == NULLP)
8737 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
8740 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
8741 extractPucchFormatCfg(macPucchCfg->format3,\
8742 cuPucchCfg->choice.setup->format3->choice.setup);
8746 if(cuPucchCfg->choice.setup->format4)
8748 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
8749 if(macPucchCfg->format4 == NULLP)
8751 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
8754 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
8755 extractPucchFormatCfg(macPucchCfg->format4,\
8756 cuPucchCfg->choice.setup->format4->choice.setup);
8759 /* Sched Req List */
8760 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
8762 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
8763 if(macPucchCfg->schedReq == NULLP)
8765 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
8768 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
8769 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
8770 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
8773 /*TODO: Add support for Spatial Info */
8776 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
8778 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
8779 if(macPucchCfg->multiCsiCfg == NULLP)
8781 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
8784 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
8785 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
8786 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
8788 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
8789 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
8793 /* Dl_DataToUL_ACK */
8794 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
8796 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
8797 if(macPucchCfg->dlDataToUlAck == NULLP)
8799 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
8802 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
8803 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
8804 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
8806 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
8807 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
8812 if(cuPucchCfg->choice.setup->pucch_PowerControl)
8814 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
8815 if(macPucchCfg->powerControl == NULLP)
8817 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
8820 extractPucchPowerControl(macPucchCfg->powerControl,\
8821 cuPucchCfg->choice.setup->pucch_PowerControl);
8828 /*******************************************************************
8830 * @brief Fills ServingCellReconfig received by CU
8834 * Function : extractSpCellDedicatedCfg
8836 * Functionality: Fills ServingCellReconfig received by CU
8838 * @params[in] ServingCellConfig_t *cuSrvCellCfg
8839 * ServCellCfgInfo *macSrvCellCfg
8840 * @return ROK/RFAILD
8842 * ****************************************************************/
8843 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellCfgInfo *macSrvCellCfg)
8846 BWP_DownlinkDedicated_t *dlBwp = NULLP;
8847 BWP_UplinkDedicated_t *ulBwp = NULLP;
8849 if(cuSrvCellCfg->initialDownlinkBWP)
8851 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
8852 if(dlBwp->pdcch_Config)
8854 if(dlBwp->pdcch_Config->choice.setup)
8856 macSrvCellCfg->initDlBwp.pdcchPresent = true;
8857 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
8860 if(dlBwp->pdsch_Config)
8862 if(dlBwp->pdsch_Config->choice.setup)
8864 macSrvCellCfg->initDlBwp.pdschPresent = true;
8865 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg);
8869 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
8870 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
8871 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
8872 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
8873 if(cuSrvCellCfg->bwp_InactivityTimer)
8875 if(macSrvCellCfg->bwpInactivityTmr)
8877 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
8881 macSrvCellCfg->bwpInactivityTmr = NULLP;
8882 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
8883 if(macSrvCellCfg->bwpInactivityTmr)
8885 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
8889 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
8894 if(cuSrvCellCfg->pdsch_ServingCellConfig)
8896 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
8898 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
8901 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
8906 if(cuSrvCellCfg->uplinkConfig)
8908 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
8910 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
8911 if(ulBwp->pusch_Config)
8913 macSrvCellCfg->initUlBwp.puschPresent = true;
8914 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
8916 if(ulBwp->pucch_Config)
8918 macSrvCellCfg->initUlBwp.pucchPresent = true;
8919 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
8920 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg);
8923 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
8924 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
8928 /*******************************************************************
8930 * @brief Fills Reconfig Cell group Info received by CU
8934 * Function : extractUeReCfgCellInfo
8936 * Functionality: Fills Reconfig Cell group Info received by CU
8938 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
8939 * MacUeCfg* macUeCfg
8940 * @return ROK/RFAILED
8942 * ****************************************************************/
8943 uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg)
8946 MAC_CellGroupConfig_t *macCellGroup = NULLP;
8947 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
8948 SpCellConfig_t *spcellCfg = NULLP;
8949 ServingCellConfig_t *servCellCfg = NULLP;
8953 /* Fill MacCell Group Reconfig */
8954 if(cellGrp->mac_CellGroupConfig)
8956 macUeCfg->macCellGrpCfgPres = true;
8957 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
8958 if(macCellGroup->schedulingRequestConfig)
8960 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
8962 if(macCellGroup->tag_Config)
8964 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
8966 if(macCellGroup->bsr_Config)
8968 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
8969 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
8970 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
8972 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
8973 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
8976 if(macCellGroup->phr_Config)
8978 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
8980 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
8981 if(macCellGroup->phr_Config->choice.setup)
8983 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
8984 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
8985 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
8986 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
8987 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
8988 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
8989 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
8990 macCellGroup->phr_Config->choice.setup->multiplePHR;
8991 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
8992 macCellGroup->phr_Config->choice.setup->dummy;
8993 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
8994 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
8995 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
8996 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
9001 /* Fill Physical Cell Group Reconfig */
9002 if(cellGrp->physicalCellGroupConfig)
9004 macUeCfg->phyCellGrpCfgPres = true;
9005 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
9006 if(phyCellGrpCfg->p_NR_FR1)
9008 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
9009 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
9011 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
9013 /* Fill SpCell Reconfig */
9014 if(cellGrp->spCellConfig)
9016 macUeCfg->spCellCfgPres = true;
9017 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
9018 if(spcellCfg->servCellIndex)
9020 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
9022 /* Fill Serving cell Reconfig info */
9023 if(cellGrp->spCellConfig->spCellConfigDedicated)
9025 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
9026 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg);
9029 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
9036 /*******************************************************************
9038 * @brief free the memory allocated by decoder
9042 * Function : freeAperDecodeNrcgi
9044 * Functionality: Free Nrcgi values
9046 * @params[in] NRCGI_t *nrcgi
9049 * ****************************************************************/
9052 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
9054 if(nrcgi->pLMN_Identity.buf != NULLP)
9056 free(nrcgi->pLMN_Identity.buf);
9058 if(nrcgi->nRCellIdentity.buf != NULLP)
9060 free(nrcgi->nRCellIdentity.buf);
9063 /*******************************************************************
9065 * @brief free the memory allocated by decoder
9069 * Function : freeAperDecodeCuToDuInfo
9071 * Functionality: Free Cu To Du Information
9073 * @params[in] CUtoDURRCInformation_t *rrcMsg
9076 * ****************************************************************/
9079 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
9084 if(rrcMsg->uE_CapabilityRAT_ContainerList)
9086 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
9087 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
9088 free(rrcMsg->uE_CapabilityRAT_ContainerList);
9091 if(rrcMsg->iE_Extensions)
9093 if(rrcMsg->iE_Extensions->list.array)
9095 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
9097 if(rrcMsg->iE_Extensions->list.array[ieIdx])
9099 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
9101 case ProtocolIE_ID_id_CellGroupConfig:
9102 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
9104 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
9108 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
9109 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
9114 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
9116 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
9118 free(rrcMsg->iE_Extensions->list.array);
9122 free(rrcMsg->iE_Extensions);
9125 /*******************************************************************
9127 * @brief free the memory allocated by decoder
9131 * Function : freeAperDecodeSplCellList
9133 * Functionality: Free Spl Cell List
9134 where memory allocated by aper_decoder
9136 * @params[in] SCell_ToBeSetup_List_t *spCellLst
9139 * ****************************************************************/
9142 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
9146 if(spCellLst->list.array != NULLP)
9148 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
9150 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
9152 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
9154 if(spCellLst->list.array[cellIdx]!=NULLP)
9156 free(spCellLst->list.array[cellIdx]);
9159 free(spCellLst->list.array);
9162 /*******************************************************************
9164 * @brief free the memory allocated by decoder
9168 * Function : freeAperDecodeSRBSetup
9170 * Functionality: added free part for the memory allocated by aper_decoder
9172 * @params[in] SRBs_ToBeSetup_List_t *srbSet
9175 ****************************************************************/
9178 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
9181 if(srbSet->list.array != NULLP)
9183 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
9185 if(srbSet->list.array[srbIdx]!=NULLP)
9187 free(srbSet->list.array[srbIdx]);
9190 free(srbSet->list.array);
9194 /*******************************************************************
9196 * @brief free the memory allocated by decoder
9200 * Function : freeAperDecodeULTnlInfo
9202 * Functionality: added free part for the memory allocated by aper_decoder
9204 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
9207 * ****************************************************************/
9210 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
9213 if(ulInfo->list.array != NULLP)
9215 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
9217 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
9219 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
9221 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9222 transportLayerAddress.buf != NULLP)
9224 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
9227 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
9229 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9230 transportLayerAddress.buf);
9232 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
9235 if(ulInfo->list.array[ulIdx]!=NULLP)
9237 free(ulInfo->list.array[ulIdx]);
9240 free(ulInfo->list.array);
9243 /*******************************************************************
9245 * @brief free the memory allocated by decoder
9249 * Function : freeAperDecodeDRBSetup
9251 * Functionality: free DRBSetup which is allocated by decoder
9253 * @params[in] DRBs_ToBeSetup_List_t *drbSet
9256 * ****************************************************************/
9258 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
9260 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
9264 if(drbSet->list.array != NULLP)
9266 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
9268 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
9270 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9271 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
9273 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9274 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
9276 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9277 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9279 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9280 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9283 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
9286 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
9289 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
9293 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
9294 flows_Mapped_To_DRB_List.list.array != NULLP)
9297 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9298 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
9301 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9302 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9304 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9305 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9306 qoSFlowLevelQoSParameters.\
9307 qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
9309 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9310 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9311 qoSFlowLevelQoSParameters.\
9312 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9315 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9316 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9317 qoSFlowLevelQoSParameters.\
9318 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9322 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9323 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9324 qoSFlowLevelQoSParameters.\
9325 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9328 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9329 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9330 qoSFlowLevelQoSParameters.\
9331 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9334 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9336 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9337 qoSFlowLevelQoSParameters.\
9338 qoS_Characteristics.choice.non_Dynamic_5QI);
9341 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9342 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9345 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9346 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
9350 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9351 DRB_Information.flows_Mapped_To_DRB_List.list.array);
9354 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9355 DRB_Information.sNSSAI.sD->buf);
9358 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
9361 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
9365 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9367 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9370 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9371 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9374 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9375 qoS_Characteristics.choice.non_Dynamic_5QI);
9377 free(drbSetItem->qoSInformation.choice.choice_extension);
9379 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
9380 if(drbSetItem->uLConfiguration)
9382 free(drbSetItem->uLConfiguration);
9385 if(drbSet->list.array[drbIdx]!=NULLP)
9387 free(drbSet->list.array[drbIdx]);
9390 free(drbSet->list.array);
9395 /*******************************************************************
9397 * @brief builds Mac Cell Cfg
9401 * Function : procUeReCfgCellInfo
9403 * Functionality: builds Mac Cell Cfg
9405 * @params[in] MacUeCfg pointer
9410 * ****************************************************************/
9411 uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfg, void *cellInfo)
9414 CellGroupConfigRrc_t *cellGrp = NULLP;
9418 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
9419 ret = extractUeReCfgCellInfo(cellGrp, macUeCfg);
9421 DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
9425 freeUeReCfgCellGrpInfo(macUeCfg);
9430 /*******************************************************************
9432 * @brief Filling modulation info in mac ue cfg
9436 * Function : duFillModulationDetails
9438 * Functionality: Filling modulation info in mac ue cfg
9440 * @params[in] MAC UE Config to be updated
9441 * Current UE configuration
9442 * UE NR capability from CU
9443 * @return ROK - success
9446 * ****************************************************************/
9447 void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
9449 UE_NR_Capability_t *ueNrCap=NULLP;
9453 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9454 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9458 ueNrCap = (UE_NR_Capability_t *)ueCap;
9460 /* Filling DL modulation info */
9461 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
9462 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
9463 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
9465 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
9467 case ModulationOrder_qpsk:
9469 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
9472 case ModulationOrder_qam16:
9474 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
9477 case ModulationOrder_qam64:
9479 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
9480 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
9481 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
9484 case ModulationOrder_qam256:
9486 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
9491 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
9492 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9499 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9502 /* Filling UL modulation info */
9503 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
9504 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
9505 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
9507 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
9509 case ModulationOrder_qpsk:
9511 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
9514 case ModulationOrder_qam16:
9516 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
9517 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
9518 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
9521 case ModulationOrder_qam64:
9523 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
9526 case ModulationOrder_qam256:
9528 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
9533 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
9534 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9541 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9546 /*******************************************************************
9548 * @brief Function to extract cellGrp Info present in cutoDu cont
9552 * Function : extractCellGrpInfo
9554 * Functionality: Function to extract cellGrp Info present
9557 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
9559 * @return CellGroupConfigRrc_t *
9561 * ****************************************************************/
9563 CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
9568 uint16_t recvBufLen =0;
9569 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
9570 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
9571 asn_dec_rval_t rval; /* Decoder return value */
9572 memset(&rval, 0, sizeof(asn_dec_rval_t));
9576 for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
9578 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
9582 case ProtocolIE_ID_id_CellGroupConfig:
9584 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
9585 /* decoding the CellGroup Buf received */
9586 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
9589 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
9590 rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
9591 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
9592 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
9594 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
9597 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
9598 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
9604 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
9612 /*******************************************************************
9614 * @brief Fills Srb List received by CU
9618 * Function : procSrbListToSetup
9620 * Functionality: Fills Srb List received by CU
9622 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
9624 * RlcBearerCfg pointer
9627 * ****************************************************************/
9628 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
9632 /* Filling RLC INFO */
9633 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd);
9635 /* Filling MAC INFO */
9636 ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, macLcToAdd, NULL);
9639 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
9647 /*******************************************************************
9649 * @brief extract Srb List received by CU
9653 * Function : extractSrbListToSetup
9655 * Functionality: extract Srb List received by CU
9656 * for both MAC and RLC
9658 * @params[in] SRBs_ToBeSetup_Item_t pointer
9660 * @return ROK/RFAIED
9662 * ****************************************************************/
9664 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
9666 uint8_t ret, srbIdx;
9667 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
9671 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
9673 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
9674 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9676 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
9680 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9682 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
9686 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9687 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9688 ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9689 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
9690 ueCfgDb->numRlcLcs++;
9691 ueCfgDb->numMacLcs++;
9694 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
9705 /*******************************************************************
9707 * @brief Fills Drb List received by CU
9711 * Function : procDrbListToSetup
9713 * Functionality: Fills Drb List received by CU
9714 * for both MAC and RLC
9716 * @params[in] SRBs_ToBeSetup_Item_t pointer
9718 * RlcBearerCfg pointer
9721 * ****************************************************************/
9723 uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
9724 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo)
9727 if(drbItem != NULLP)
9729 /* Filling RLC INFO */
9730 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9732 /* Filling MAC INFO */
9733 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
9735 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9739 else if(drbSetupModItem != NULLP)
9741 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9743 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
9745 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9752 /*******************************************************************
9754 * @brief extract Drb List received by CU
9758 * Function : extractDrbListToSetup
9760 * Functionality: extract Drb List received by CU
9761 * for both MAC and RLC
9763 * @params[in] DRBs_ToBeSetup_Item_t pointer
9765 * @return ROK/RFAIED
9767 * ****************************************************************/
9769 uint8_t extractDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_List_t *drbCfg,DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
9770 uint8_t drbCount, DuUeCfg *ueCfgDb)
9772 uint8_t ret, drbIdx;
9773 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
9774 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
9779 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
9781 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9783 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetup()");
9787 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9789 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetup()");
9793 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9794 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9798 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9799 ret = procDrbListToSetup(lcId, drbItem, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9800 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
9803 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9807 else if(drbSetupModCfg != NULL)
9809 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
9810 ret = procDrbListToSetup(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item) ,\
9811 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
9812 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
9815 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9819 ueCfgDb->numRlcLcs++;
9820 ueCfgDb->numMacLcs++;
9824 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9835 /*******************************************************************
9837 * @brief Function to extract Dl RRC Msg received from CU
9841 * Function : extractDlRrcMsg
9843 * Functionality: Function to extract Dl RRC Msg received from CU
9845 * @params[in] F1AP message
9846 * @return ROK - success
9849 * ****************************************************************/
9851 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
9852 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
9855 dlRrcMsg->rrcMsgSize = rrcContainer->size;
9856 if(dlRrcMsg->rrcMsgSize > 0)
9858 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
9859 if(!dlRrcMsg->rrcMsgPdu)
9861 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
9866 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
9867 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
9868 dlRrcMsg->srbId = SRB1_LCID;
9869 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
9875 /*******************************************************************
9877 * @brief Extract UE capability info
9881 * Function : extractUeCapability
9883 * Functionality: Extract UE capability info and stores in ue Cb
9885 * @params[in] Octet string of UE capability RAT container list
9886 * @return ROK - success
9889 * ****************************************************************/
9890 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
9893 uint16_t recvBufLen;
9894 asn_dec_rval_t rval;
9895 UE_NR_Capability_t *ueNrCap = NULLP;
9896 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
9898 /* Decoding UE Capability RAT Container List */
9899 recvBufLen = ueCapablityListBuf->size;
9900 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
9901 if(!ueCapRatContList)
9903 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
9906 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
9907 memset(&rval, 0, sizeof(asn_dec_rval_t));
9908 rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
9909 ueCapablityListBuf->buf, recvBufLen, 0, 0);
9910 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
9912 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
9915 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
9917 /* Free encoded buffer after decoding */
9919 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
9921 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
9923 /* Decoding UE NR Capability */
9924 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
9925 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
9928 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
9929 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
9932 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
9933 memset(&rval, 0, sizeof(asn_dec_rval_t));
9934 rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
9935 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
9936 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
9938 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
9941 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
9943 /* Free encoded buffer after decoding */
9944 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
9946 free(ueCapRatContList->list.array[idx]);
9950 free(ueCapRatContList->list.array);
9951 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
9955 /*******************************************************************
9957 * @brief free UE context setup request from CU
9961 * Function : freeAperDecodeF1UeContextSetupReq
9963 * Functionality: freeing part for the memory allocated by aper_decoder
9965 * @params[in] F1AP message
9966 * @return ROK - success
9969 * ****************************************************************/
9970 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
9974 if(ueSetReq->protocolIEs.list.array != NULLP)
9976 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
9978 if(ueSetReq->protocolIEs.list.array[ieIdx])
9980 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
9982 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
9984 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
9986 case ProtocolIE_ID_id_SpCell_ID:
9987 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
9989 case ProtocolIE_ID_id_ServCellIndex:
9991 case ProtocolIE_ID_id_SpCellULConfigured:
9993 case ProtocolIE_ID_id_CUtoDURRCInformation:
9995 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
9997 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
9999 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
10001 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10003 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
10005 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10007 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
10009 case ProtocolIE_ID_id_RRCContainer:
10012 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
10015 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
10019 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10021 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10023 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
10025 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
10030 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
10032 free(ueSetReq->protocolIEs.list.array[ieIdx]);
10035 free(ueSetReq->protocolIEs.list.array);
10038 /*******************************************************************
10040 * @brief Process UE context setup request from CU
10044 * Function : procF1UeContextSetupReq
10046 * Functionality: Process UE context setup request from CU
10048 * @params[in] F1AP message
10049 * @return ROK - success
10050 * RFAILED - failure
10052 * ****************************************************************/
10053 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
10055 uint8_t ret=0, ieIdx=0, ueIdx=0, lcId=0, cellIdx=0;
10056 bool ueCbFound = false;
10057 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
10058 DuUeCb *duUeCb = NULL;
10059 UEContextSetupRequest_t *ueSetReq = NULL;
10060 DRBs_ToBeSetup_List_t *drbCfg = NULL;
10064 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
10065 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
10067 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10069 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10071 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
10074 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10076 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
10079 case ProtocolIE_ID_id_ServCellIndex:
10081 cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
10082 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
10084 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
10085 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
10088 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
10089 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
10092 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
10093 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
10094 duUeCb->f1UeDb->cellIdx = cellIdx;
10098 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
10108 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
10113 case ProtocolIE_ID_id_SpCellULConfigured:
10114 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
10115 UL, SUL or UL+SUL for the indicated cell for the UE */
10117 case ProtocolIE_ID_id_CUtoDURRCInformation:
10119 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
10121 duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
10122 extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
10123 uE_CapabilityRAT_ContainerList, duUeCb);
10125 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
10127 duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
10128 value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
10129 if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
10131 DU_LOG("\nERROR --> F1AP: Failed to extract cell Grp Info");
10132 //TODO: Update the failure cause in ue context Setup Response
10138 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10140 DU_LOG("\nINFO --> DU_APP: Received SCell_ToBeSetup_List but Not processing the list");
10143 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10145 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
10146 &duUeCb->f1UeDb->duUeCfg))
10148 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
10149 //TODO: Update the failure cause in ue context Setup Response
10154 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10156 lcId = getDrbLcId(&duUeCb->drbBitMap);
10157 if(lcId != RFAILED)
10159 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
10160 if(extractDrbListToSetup(lcId, drbCfg, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg))
10162 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
10163 //TODO: Update the failure cause in ue context Setup Response
10171 case ProtocolIE_ID_id_RRCContainer:
10173 /* Filling Dl RRC Msg Info */
10174 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
10175 if(!duUeCb->f1UeDb->dlRrcMsg)
10177 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
10182 duUeCb->f1UeDb->dlRrcMsgPres = true;
10183 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
10184 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
10185 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
10189 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10191 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
10193 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
10197 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
10201 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10203 /* MaximumBitRate Uplink */
10204 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
10205 if(bitRateSize > 0)
10207 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
10208 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
10210 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
10215 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
10216 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
10217 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
10232 /*TODO : Negative case*/
10233 // BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10234 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
10237 ret = duProcUeContextSetupRequest(duUeCb);
10239 freeAperDecodeF1UeContextSetupReq(ueSetReq);
10243 /*******************************************************************
10244 * @brief Free the memory allocated for Dl Tunnel Info
10248 * Function : freeDlTnlInfo
10251 * Free the memory allocated for Dl Tunnel Info
10253 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
10256 * ****************************************************************/
10258 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
10260 uint8_t arrIdx = 0;
10264 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
10266 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf,\
10267 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.size);
10268 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf,\
10269 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.size);
10270 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10271 DU_FREE(tnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10273 DU_FREE(tnlInfo->list.array, tnlInfo->list.size);
10277 /*******************************************************************
10278 * @brief Free the memory allocated for DRB setup List
10282 * Function : freeDrbSetupList
10285 * Free the memory allocated for DRB setup list
10287 * @params[in] DRBs_Setup_List_t *
10290 * ****************************************************************/
10291 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
10293 uint8_t arrIdx = 0;
10294 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10296 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
10298 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10299 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
10300 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10302 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
10305 /*******************************************************************
10306 * @brief Free the memory allocated for UE Setup response
10310 * Function : FreeUeContextSetupRsp
10313 * Free the memory allocated for UE Setup response
10315 * @params[in] F1AP PDU for UE setup response
10316 * @return ROK - success
10317 * RFAILED - failure
10319 * ****************************************************************/
10320 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
10323 UEContextSetupResponse_t *ueSetRsp = NULLP;
10327 if(f1apMsg->choice.successfulOutcome)
10329 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
10330 UEContextSetupResponse;
10331 if(ueSetRsp->protocolIEs.list.array)
10333 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
10335 if(ueSetRsp->protocolIEs.list.array[idx])
10337 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
10339 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10341 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10343 case ProtocolIE_ID_id_DUtoCURRCInformation:
10345 CellGroupConfig_t *cellGrpCfg = NULLP;
10346 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
10347 DUtoCURRCInformation.cellGroupConfig;
10348 if(cellGrpCfg->buf != NULLP)
10350 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
10351 cellGrpCfg = NULLP;
10355 case ProtocolIE_ID_id_DRBs_Setup_List:
10357 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
10361 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
10362 ueSetRsp->protocolIEs.list.array[idx]->id);
10365 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
10366 sizeof(UEContextSetupResponseIEs_t));
10369 DU_FREE(ueSetRsp->protocolIEs.list.array, \
10370 ueSetRsp->protocolIEs.list.size);
10372 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
10374 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10378 /*******************************************************************
10380 * @brief Builds Ue context Setup Rsp DU To CU Info
10384 * Function : EncodeUeCntxtDuToCuInfo
10386 * Functionality: Builds Ue context Setup Rsp DU To CU Info
10388 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
10390 * @return ROK - success
10391 * RFAILED - failure
10393 ******************************************************************/
10395 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
10397 asn_enc_rval_t encRetVal;
10399 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
10400 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10402 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
10403 /* Encode results */
10404 if(encRetVal.encoded == ENCODE_FAIL)
10406 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
10407 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10412 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
10413 for(int i=0; i< encBufSize; i++)
10415 printf("%x",encBuf[i]);
10418 duToCuCellGrp->size = encBufSize;
10419 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
10420 if(!duToCuCellGrp->buf)
10422 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
10424 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
10428 /*******************************************************************
10430 * @brief Fills Dl Gtp tunnel Info
10434 * Function : fillGtpTunnelforDl
10436 * Functionality: Fills Dl Gtp tunnel Info
10440 * @return ROK - success
10441 * RFAILED - failure
10443 * ****************************************************************/
10445 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
10447 uint8_t bufSize = 0;
10449 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
10450 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
10451 if(gtpDl->transportLayerAddress.buf == NULLP)
10455 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
10458 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
10459 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
10460 if(gtpDl->gTP_TEID.buf == NULLP)
10464 bufSize = 3; /*forming an Octect String*/
10465 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
10470 /*******************************************************************
10472 * @brief Fills DL Tunnel Setup List
10476 * Function : fillDlTnlSetupList
10478 * Functionality: Fills the DL Tunnel Setup List
10482 * @return ROK - success
10483 * RFAILED - failure
10485 * ****************************************************************/
10487 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
10489 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10492 dlTnlInfo->list.count = eleCount;
10493 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
10495 /* Initialize the DL Tnl Setup List Members */
10496 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
10497 if(dlTnlInfo->list.array == NULLP)
10499 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
10502 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10504 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10505 if(dlTnlInfo->list.array[arrIdx] == NULLP)
10507 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
10510 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
10511 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10512 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
10514 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
10517 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
10525 /*******************************************************************
10527 * @brief Fills the Drb Setup List for Ue Context Setup Response
10531 * Function : fillDrbSetupList
10533 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
10537 * @return ROK - success
10538 * RFAILED - failure
10540 * ****************************************************************/
10541 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
10543 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10544 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10546 eleCount = ueCfg->numDrb;
10547 drbSetupList->list.count = eleCount;
10548 drbSetupList->list.size = \
10549 (eleCount * sizeof(DRBs_Setup_Item_t *));
10551 /* Initialize the Drb Setup List Members */
10552 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
10553 if(drbSetupList->list.array == NULLP)
10555 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
10559 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10561 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10562 if(drbSetupList->list.array[arrIdx] == NULLP)
10564 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
10567 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10568 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
10569 drbItemIe->criticality = Criticality_reject;
10570 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
10571 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
10572 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
10573 &ueCfg->upTnlInfo[arrIdx]);
10580 /*******************************************************************
10582 * @brief Builds and sends the UE Setup Response
10586 * Function : BuildAndSendUeContextSetupRsp
10588 * Functionality: Constructs the UE Setup Response and sends
10589 * it to the DU through SCTP.
10591 * @params[in] uint8_t cellId,uint8_t ueIdx
10593 * @return ROK - success
10594 * RFAILED - failure
10596 * ****************************************************************/
10597 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
10599 uint8_t idx, ret, cellIdx, elementCnt;
10600 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
10601 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
10602 asn_enc_rval_t encRetVal; /* Encoder return value */
10603 F1AP_PDU_t *f1apMsg = NULLP;
10604 UEContextSetupResponse_t *ueSetRsp = NULLP;
10605 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
10606 DuUeCb *ueCb = NULLP;
10608 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
10612 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
10613 if(f1apMsg == NULLP)
10615 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10620 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
10621 DU_ALLOC(f1apMsg->choice.successfulOutcome,
10622 sizeof(SuccessfulOutcome_t));
10623 if(f1apMsg->choice.successfulOutcome == NULLP)
10625 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10630 f1apMsg->choice.successfulOutcome->procedureCode = \
10631 ProcedureCode_id_UEContextSetup;
10632 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
10633 f1apMsg->choice.successfulOutcome->value.present = \
10634 SuccessfulOutcome__value_PR_UEContextSetupResponse;
10637 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
10639 ueSetRsp->protocolIEs.list.count = elementCnt;
10640 ueSetRsp->protocolIEs.list.size = \
10641 elementCnt * sizeof(UEContextSetupResponse_t *);
10643 /* Initialize the UESetup members */
10644 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
10645 ueSetRsp->protocolIEs.list.size);
10646 if(ueSetRsp->protocolIEs.list.array == NULLP)
10648 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10653 for(idx=0; idx<elementCnt; idx++)
10655 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
10656 sizeof(UEContextSetupResponseIEs_t));
10657 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
10659 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10664 /* Fetching Ue Cb Info*/
10665 GET_CELL_IDX(cellId, cellIdx);
10666 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
10667 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
10668 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
10671 /*GNB CU UE F1AP ID*/
10672 ueSetRsp->protocolIEs.list.array[idx]->id = \
10673 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
10674 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10675 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10676 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
10677 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
10679 /*GNB DU UE F1AP ID*/
10681 ueSetRsp->protocolIEs.list.array[idx]->id = \
10682 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
10683 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10684 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10685 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
10686 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
10689 /*DUtoCURRC Information */
10691 ueSetRsp->protocolIEs.list.array[idx]->id = \
10692 ProtocolIE_ID_id_DUtoCURRCInformation;
10693 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10694 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10695 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
10698 if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
10700 cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
10701 ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
10702 choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
10705 DU_LOG("\nERROR --> F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
10706 freeF1UeDb(ueCb->f1UeDb);
10707 ueCb->f1UeDb = NULLP;
10714 DU_LOG("\nERROR --> F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
10719 /* Drb Setup List */
10721 ueSetRsp->protocolIEs.list.array[idx]->id = \
10722 ProtocolIE_ID_id_DRBs_Setup_List;
10723 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10724 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10725 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
10726 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
10727 &ueCb->f1UeDb->duUeCfg);
10730 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
10731 freeF1UeDb(ueCb->f1UeDb);
10732 ueCb->f1UeDb = NULLP;
10736 /* Free UeContext Db created during Ue context Req */
10737 freeF1UeDb(ueCb->f1UeDb);
10738 ueCb->f1UeDb = NULLP;
10740 /* TODO: To send Drb list */
10741 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
10743 /* Encode the UE context setup response type as APER */
10744 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10746 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
10748 /* Encode results */
10749 if(encRetVal.encoded == ENCODE_FAIL)
10751 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
10752 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10758 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
10759 for(int i=0; i< encBufSize; i++)
10761 printf("%x",encBuf[i]);
10766 if(sendF1APMsg() != ROK)
10768 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
10774 FreeUeContextSetupRsp(f1apMsg);
10776 }/* End of BuildAndSendUeContextSetupRsp */
10777 /*******************************************************************
10779 * @brief Build And Send Ue Context Rsp
10783 * Function : BuildAndSendUeCtxtRsp
10785 * Functionality : Build And Send Ue Context Rsp
10788 * @return sucess = ROK
10789 * failure = RFAILED
10791 * ****************************************************************/
10792 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueIdx)
10794 uint8_t cellIdx = 0, actionType = 0;
10796 GET_CELL_IDX(cellId, cellIdx);
10797 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
10801 case UE_CTXT_SETUP:
10803 BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10808 BuildAndSendUeContextModRsp(cellId, ueIdx);
10812 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
10819 /*******************************************************************
10821 * @brief deallocating the memory of F1reset msg
10825 * Function : FreeF1ResetReq
10828 * - freeing memory of F1reset request msg
10834 * ****************************************************************/
10835 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
10838 Reset_t *f1ResetMsg;
10842 if(f1apMsg->choice.initiatingMessage)
10844 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
10846 if(f1ResetMsg->protocolIEs.list.array)
10848 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
10850 if(f1ResetMsg->protocolIEs.list.array[idx])
10852 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
10855 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
10857 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
10859 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10862 /*******************************************************************
10864 * @brief Build and Send F1reset request
10868 * Function : BuildAndSendF1ResetReq
10871 * - Build and Send F1reset request msg
10874 * @return ROK - success
10875 * RFAILED - failure
10877 * ****************************************************************/
10878 uint8_t BuildAndSendF1ResetReq()
10880 uint8_t elementCnt=0;
10882 uint8_t ret= RFAILED;
10883 Reset_t *f1ResetMsg = NULLP;
10884 F1AP_PDU_t *f1apMsg = NULLP;
10885 asn_enc_rval_t encRetVal;
10886 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
10889 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
10890 if(f1apMsg == NULLP)
10894 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
10895 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
10896 if(f1apMsg->choice.initiatingMessage == NULLP)
10900 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
10901 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
10902 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
10904 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
10907 f1ResetMsg->protocolIEs.list.count = elementCnt;
10908 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
10910 /* Initialize the F1Setup members */
10911 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
10912 if(f1ResetMsg->protocolIEs.list.array == NULLP)
10916 for(idx=0; idx<elementCnt; idx++)
10918 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
10919 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
10927 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
10928 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10929 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
10930 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
10934 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
10935 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
10936 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
10937 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
10938 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
10942 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
10943 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10944 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
10945 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
10946 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
10948 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
10950 /* Encode the F1SetupRequest type as APER */
10951 memset(encBuf, 0, ENC_BUF_MAX_LEN);
10953 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
10956 /* Encode results */
10957 if(encRetVal.encoded == ENCODE_FAIL)
10959 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
10960 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10965 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
10966 for(idx=0; idx< encBufSize; idx++)
10968 printf("%x",encBuf[idx]);
10972 if(sendF1APMsg() != ROK)
10974 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
10982 FreeF1ResetReq(f1apMsg);
10985 /*******************************************************************
10987 * @brief Build And Send F1ResetAck
10991 * Function : BuildAndSendF1ResetAck
10994 * - Build And Send F1ResetRSP
10996 * @return ROK - success
10997 * RFAILED - failure
10999 * ****************************************************************/
11000 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
11003 ResetAcknowledge_t *f1ResetAck;
11007 if(f1apMsg->choice.successfulOutcome)
11009 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11011 if(f1ResetAck->protocolIEs.list.array)
11013 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
11015 if(f1ResetAck->protocolIEs.list.array[idx])
11017 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11020 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11022 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11024 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11028 /*******************************************************************
11030 * @brief Build And Send F1ResetAck
11034 * Function : BuildAndSendF1ResetAck
11037 * - Build And Send F1ResetRSP
11040 * @return ROK - success
11041 * RFAILED - failure
11043 * ****************************************************************/
11044 uint8_t BuildAndSendF1ResetAck()
11047 uint8_t elementCnt = 0;
11048 uint8_t ret = RFAILED;
11049 F1AP_PDU_t *f1apMsg = NULL;
11050 ResetAcknowledge_t *f1ResetAck = NULLP;
11051 asn_enc_rval_t encRetVal;
11052 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
11055 /* Allocate the memory for F1ResetRequest_t */
11056 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11057 if(f1apMsg == NULLP)
11059 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11063 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11065 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11066 if(f1apMsg->choice.successfulOutcome == NULLP)
11068 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11071 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11072 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
11073 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11077 f1ResetAck->protocolIEs.list.count = elementCnt;
11078 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
11080 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11081 if(f1ResetAck->protocolIEs.list.array == NULLP)
11083 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
11087 for(idx=0; idx<elementCnt; idx++)
11089 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11090 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
11097 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11098 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11099 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
11100 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
11102 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11104 /* Encode the F1SetupRequest type as UPER */
11105 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11107 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
11109 /* Check encode results */
11110 if(encRetVal.encoded == ENCODE_FAIL)
11112 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
11113 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11118 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
11119 for(int i=0; i< encBufSize; i++)
11121 printf("%x",encBuf[i]);
11125 if(sendF1APMsg() != ROK)
11127 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
11135 FreeF1ResetAck(f1apMsg);
11138 /******************************************************************
11140 * @brief free F1 reset msg allocated by aper_decoder
11144 * Function : freeAperDecodeF1ResetMsg
11146 * Functionality: free F1 reset msg allocated by aper_decoder
11148 * @params[in] Reset_t *f1ResetMsg
11151 * ****************************************************************/
11153 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
11156 if(f1ResetMsg->protocolIEs.list.array)
11158 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
11160 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
11162 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
11165 free(f1ResetMsg->protocolIEs.list.array);
11169 /******************************************************************
11171 * @brief Processes DL RRC Message Transfer sent by CU
11175 * Function : procF1ResetReq
11177 * Functionality: Processes DL RRC Message Transfer sent by CU
11179 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11180 * @return ROK - success
11181 * RFAILED - failure
11183 * ****************************************************************/
11184 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
11186 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
11189 Reset_t *f1ResetMsg = NULLP;
11191 DU_LOG("\nINFO --> Processing F1 reset request");
11192 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11194 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
11196 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
11198 case ProtocolIE_ID_id_TransactionID:
11201 case ProtocolIE_ID_id_Cause:
11204 case ProtocolIE_ID_id_ResetType:
11213 ret = BuildAndSendF1ResetAck();
11214 DU_LOG("\nINFO --> UE release is not supported for now");
11216 freeAperDecodeF1ResetMsg(f1ResetMsg);
11221 /*******************************************************************
11223 * @brief free the RRC delivery report
11227 * Function : freeRrcDeliveryReport
11229 * Functionality: free the RRC delivery report
11232 * @return ROK - success
11233 * RFAILED - failure
11235 * ****************************************************************/
11236 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
11239 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11243 if(f1apMsg->choice.initiatingMessage)
11245 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11246 if(rrcDeliveryReport->protocolIEs.list.array)
11248 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
11251 if(rrcDeliveryReport->protocolIEs.list.array[idx])
11253 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
11254 sizeof(RRCDeliveryReportIEs_t));
11257 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
11258 rrcDeliveryReport->protocolIEs.list.size);
11260 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11263 sizeof(F1AP_PDU_t));
11267 /*******************************************************************
11269 * @brief Builds and sends the RRC delivery report
11273 * Function : BuildAndSendRrcDeliveryReport
11275 * Functionality: Builds and sends the RRC delivery report
11279 * @return ROK - success
11280 * RFAILED - failure
11282 * ****************************************************************/
11283 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
11284 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
11286 uint8_t ret = RFAILED;
11289 uint8_t elementCnt = 0;
11290 F1AP_PDU_t *f1apMsg = NULLP;
11291 asn_enc_rval_t encRetVal;
11292 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11296 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
11297 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11298 if(f1apMsg == NULLP)
11300 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11303 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11304 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11305 if(f1apMsg->choice.initiatingMessage == NULLP)
11307 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11310 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
11311 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
11312 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
11314 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11316 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
11317 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
11319 /* Initialize the F1Setup members */
11320 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
11321 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
11323 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
11326 for(idx =0 ;idx <elementCnt; idx++)
11328 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
11329 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
11337 /*GNB CU UE F1AP ID*/
11338 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11339 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11340 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
11341 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11343 /*GNB DU UE F1AP ID*/
11345 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11346 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11347 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
11348 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11350 /*RRC delivery status*/
11352 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
11353 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11354 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
11355 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
11356 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
11357 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
11358 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
11362 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
11363 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11364 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
11365 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
11367 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11369 /* Encode the RRC DELIVERY REPORT type as APER */
11370 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11372 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11375 /* Encode results */
11376 if(encRetVal.encoded == ENCODE_FAIL)
11378 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
11379 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11384 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
11385 for(idx=0; idx< encBufSize; idx++)
11387 printf("%x",encBuf[idx]);
11392 if(sendF1APMsg() != ROK)
11394 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
11402 freeRrcDeliveryReport(f1apMsg);
11406 /*******************************************************************
11408 * @brief Processes cells to be activated
11412 * Function : extractCellsToBeActivated
11415 * - Processes cells to be activated list received in F1SetupRsp
11418 * @return ROK - success
11419 * RFAILED - failure
11421 * ****************************************************************/
11423 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
11426 uint16_t idx, nci, pci = 0;
11427 Cells_to_be_Activated_List_Item_t cell;
11429 for(idx=0; idx<cellsToActivate.list.count; idx++)
11432 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
11433 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
11439 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
11443 /******************************************************************
11445 * @brief Processes F1 Setup Response allocated by aper_decoder
11449 * Function : freeF1SetupRsp
11451 * Functionality: free F1 Setup Response allocated by aper_decoder
11453 * @params[in] F1SetupResponse_t *f1SetRspMsg
11456 * ****************************************************************/
11458 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
11462 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
11463 RRC_Version_t *rrcVer =NULLP;
11465 if(f1SetRspMsg->protocolIEs.list.array)
11467 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
11469 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
11471 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
11473 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11476 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
11477 if(cellToActivate->list.array)
11479 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
11481 if(cellToActivate->list.array[arrIdx])
11484 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
11487 if(cellToActivate->list.array[0]->value.choice.\
11488 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
11490 free(cellToActivate->list.array[0]->value.choice.\
11491 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
11494 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
11495 nRCGI.pLMN_Identity.buf);
11497 free(cellToActivate->list.array[arrIdx]);
11500 free(cellToActivate->list.array);
11504 case ProtocolIE_ID_id_TransactionID:
11508 case ProtocolIE_ID_id_gNB_CU_Name:
11510 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
11513 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11515 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
11516 if(rrcVer->latest_RRC_Version.buf)
11518 if(rrcVer->iE_Extensions)
11520 if(rrcVer->iE_Extensions->list.array)
11522 if(rrcVer->iE_Extensions->list.array[0])
11524 if(rrcVer->iE_Extensions->list.\
11525 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
11527 free(rrcVer->iE_Extensions->list.\
11528 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
11530 free(rrcVer->iE_Extensions->list.array[0]);
11532 free(rrcVer->iE_Extensions->list.array);
11534 free(rrcVer->iE_Extensions);
11536 free(rrcVer->latest_RRC_Version.buf);
11543 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11544 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
11547 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
11550 free(f1SetRspMsg->protocolIEs.list.array);
11553 /******************************************************************
11555 * @brief Processes F1 Setup Response sent by CU
11559 * Function : procF1SetupRsp
11561 * Functionality: Processes F1 Setup Response sent by CU
11563 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11564 * @return ROK - success
11565 * RFAILED - failure
11567 * ****************************************************************/
11568 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
11572 F1SetupResponse_t *f1SetRspMsg = NULLP;
11573 GNB_CU_Name_t *cuName = NULLP;
11574 F1SetupRsp f1SetRspDb;
11575 RRC_Version_t *rrcVer =NULLP;
11577 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
11579 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
11580 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
11582 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
11584 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
11586 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11588 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
11589 value.choice.Cells_to_be_Activated_List);
11592 case ProtocolIE_ID_id_TransactionID:
11594 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
11595 value.choice.TransactionID;
11598 case ProtocolIE_ID_id_gNB_CU_Name:
11600 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
11601 value.choice.GNB_CU_Name;
11602 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
11605 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11607 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
11608 strcpy(f1SetRspDb.rrcVersion.rrcVer,
11609 (const char*)rrcVer->latest_RRC_Version.buf);
11613 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11614 f1SetRspMsg->protocolIEs.list.array[idx]->id);
11616 duProcF1SetupRsp();
11619 freeAperDecodeF1SetupRsp(f1SetRspMsg);
11622 /*******************************************************************
11624 * @brief free GNB DU config update ack
11628 * Function : freeAperDecodeGnbDuAck
11630 * Functionality: Processes GNB DU config update ack And
11631 * added free part for the memory allocated by aper_decoder
11633 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11634 * @return ROK - success
11635 * RFAILED - failure
11637 * ****************************************************************/
11639 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
11643 if(gnbDuAck->protocolIEs.list.array)
11645 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11647 if(gnbDuAck->protocolIEs.list.array[ieIdx])
11649 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
11652 free(gnbDuAck->protocolIEs.list.array);
11656 /*******************************************************************
11658 * @brief Building result of gnb-du config update ack output
11662 * Function : duProcGnbDuCfgUpdAckMsg
11665 * Building output of gnb-du config update ack
11667 * @params[in] transId
11670 * ****************************************************************/
11672 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
11674 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
11675 uint8_t ueId =0 , ueIdx =0;
11676 uint16_t cellId =0, cellIdx =0, crnti=0;
11677 CmLList *f1apPduNode = NULLP;
11678 ReservedF1apPduInfo *f1apPduInfo =NULLP;
11679 F1AP_PDU_t *f1apMsgPdu = NULLP;
11680 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
11681 BIT_STRING_t *cellIdentity=NULLP;
11682 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
11683 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
11684 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
11686 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
11687 f1apPduNode = searchFromReservedF1apPduList(transId);
11688 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
11689 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
11693 if(f1apMsgPdu->choice.initiatingMessage)
11695 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
11696 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
11698 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
11700 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
11702 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
11703 Served_Cells_To_Delete_List;
11704 if(cellsToDelete->list.array)
11706 if(cellsToDelete->list.array[arrIdx])
11708 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
11709 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
11710 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
11712 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
11713 bitStringToInt(cellIdentity, &cellId);
11718 GET_CELL_IDX(cellId, cellIdx);
11719 if(duCb.actvCellLst[cellIdx] != NULLP)
11721 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
11723 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
11724 ret = duSendCellDeletReq(cellId);
11727 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
11728 request for cellId[%d]", cellId);
11733 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
11735 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
11736 GET_UE_IDX(crnti,ueId);
11737 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
11740 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
11741 request for cellId[%d]", cellId);
11748 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%d] not found", cellId);
11761 FreeDUConfigUpdate(f1apMsgPdu);
11762 deleteFromReservedF1apPduList(f1apPduNode);
11766 /*******************************************************************
11768 * @brief Processes GNB DU config update ack
11772 * Function : procF1GNBDUCfgUpdAck
11774 * Functionality: added free part for the memory allocated by aper_decoder
11776 * @params[in] F1AP_PDU_t *f1apMsg
11779 * ****************************************************************/
11780 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
11782 uint8_t ieIdx=0,transId=0;
11783 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
11785 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
11786 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
11788 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11790 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
11792 case ProtocolIE_ID_id_TransactionID:
11794 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
11797 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11803 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
11804 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
11810 duProcGnbDuCfgUpdAckMsg(transId);
11813 /* presently we are not supporting F1 Reset from DU to CU , we are only
11814 * supporting F1 Reset from CU to DU */
11816 if(BuildAndSendF1ResetReq() != ROK)
11822 freeAperDecodeGnbDuAck(gnbDuAck);
11825 /******************************************************************
11827 * @brief free DL RRC Message Transfer allocated by aper_decoder
11831 * Function : freeAperDecodef1DlRrcMsg
11833 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
11835 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
11836 * @return ROK - success
11837 * RFAILED - failure
11839 * ****************************************************************/
11841 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
11844 RRCContainer_t *rrcContainer = NULLP;
11846 if(f1DlRrcMsg->protocolIEs.list.array)
11848 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
11850 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
11852 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
11854 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
11856 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
11858 case ProtocolIE_ID_id_SRBID:
11860 case ProtocolIE_ID_id_RRCContainer:
11862 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
11863 free(rrcContainer->buf);
11865 case ProtocolIE_ID_id_ExecuteDuplication:
11867 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
11871 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
11874 free(f1DlRrcMsg->protocolIEs.list.array);
11877 /******************************************************************
11879 * @brief Processes DL RRC Message Transfer sent by CU
11883 * Function : procF1DlRrcMsgTrans
11885 * Functionality: Processes DL RRC Message Transfer sent by CU
11887 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11888 * @return ROK - success
11889 * RFAILED - failure
11891 * ****************************************************************/
11892 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
11895 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
11897 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
11899 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
11900 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
11904 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
11906 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
11908 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
11910 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
11913 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
11915 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
11918 case ProtocolIE_ID_id_SRBID:
11920 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
11923 case ProtocolIE_ID_id_ExecuteDuplication:
11924 dlMsg.execDup = true;
11927 case ProtocolIE_ID_id_RRCContainer:
11929 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
11931 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
11932 DU_ALLOC_SHRABL_BUF(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
11933 if(dlMsg.rrcMsgPdu)
11935 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
11940 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
11946 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
11947 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
11952 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
11954 dlMsg.deliveryStatRpt = true;
11958 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
11959 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
11963 ret = duProcDlRrcMsg(&dlMsg);
11965 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
11968 /*******************************************************************
11970 * @brief Builds the DRB to be Setup Mod list
11976 * Functionality: Constructs the DRB to be Setup Mod list
11978 * @params[in] DRBs_SetupMod_List_t *drbSet
11980 * @return ROK - success
11981 * RFAILED - failure
11983 * ****************************************************************/
11985 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
11989 struct DRBs_SetupMod_ItemIEs *drbItemIe;
11992 drbSet->list.count = drbCnt;
11993 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
11994 DU_ALLOC(drbSet->list.array, drbSet->list.size);
11995 if(drbSet->list.array == NULLP)
11997 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12000 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
12002 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12003 if(drbSet->list.array[arrIdx] == NULLP)
12005 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12009 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
12010 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
12011 drbItemIe->criticality = Criticality_reject;
12012 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
12013 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
12014 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
12015 &ueCfg->upTnlInfo[arrIdx])!= ROK)
12017 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
12025 /*******************************************************************
12026 * @brief Free the memory allocated for DRB setup List
12030 * Function : FreeDrbSetupModList
12033 * Free the memory allocated for DRB setup list
12035 * @params[in] DRBs_Setup_List_t *
12038 * ****************************************************************/
12039 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
12041 uint8_t arrIdx = 0;
12042 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
12044 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
12046 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
12047 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
12048 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12050 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
12052 /*******************************************************************
12053 * @brief Free the memory allocated for UE Context Mod Response
12057 * Function : FreeUeContextModResp
12060 * Free the memory allocated for UE Context Mod Response
12062 * @params[in] F1AP_PDU_t *f1apMsg
12065 * ****************************************************************/
12067 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
12070 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12073 if(f1apMsg->choice.successfulOutcome)
12075 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12076 if(ueContextModifyRes->protocolIEs.list.array)
12078 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
12080 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
12082 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
12084 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12086 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12088 case ProtocolIE_ID_id_DRBs_SetupMod_List:
12090 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12091 value.choice.DRBs_SetupMod_List));
12095 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12099 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12101 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12103 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12107 /*****************************************************************i
12109 * @brief Creating the ue context modifcation response and sending
12113 * Function : BuildAndSendUeContextModRsp
12116 * - Creating the ue context modifcation response
12118 * @params[in] uint8_t cellId,uint8_t ueIdx
12119 * @return ROK - success
12120 * RFAILED - failure
12122 * ****************************************************************/
12123 uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
12126 uint8_t cellIdx =0;
12127 uint8_t elementCnt = 0;
12128 uint8_t ret = RFAILED;
12129 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
12130 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
12131 F1AP_PDU_t *f1apMsg = NULLP;
12132 asn_enc_rval_t encRetVal;
12133 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12134 DuUeCb *ueCb = NULLP;
12136 DU_LOG("\nINFO --> F1AP : Building Ue context modification response\n");
12140 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12141 if(f1apMsg == NULLP)
12143 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12147 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12149 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12150 if(f1apMsg->choice.successfulOutcome == NULLP)
12152 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12155 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
12156 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12157 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
12159 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12162 ueContextModifyRes->protocolIEs.list.count = elementCnt;
12163 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
12165 /* Initialize the UE context modification members */
12166 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12167 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
12169 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12173 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
12175 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12176 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
12178 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12183 /* Fetching Ue Cb Info*/
12184 GET_CELL_IDX(cellId, cellIdx);
12185 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12186 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12187 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
12190 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12191 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12192 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12193 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
12194 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
12197 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12198 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12199 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
12200 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
12201 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
12204 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
12205 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12206 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12207 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
12210 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12211 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
12214 DU_LOG( "\nERROR --> F1AP : Failed to build drb setupmod List ");
12217 freeF1UeDb(ueCb->f1UeDb);
12218 ueCb->f1UeDb = NULLP;
12220 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12222 /* Encode the F1SetupRequest type as APER */
12223 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12225 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
12227 /* Encode results */
12228 if(encRetVal.encoded == ENCODE_FAIL)
12230 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
12231 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12237 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
12238 for(int i=0; i< encBufSize; i++)
12240 printf("%x",encBuf[i]);
12245 if(sendF1APMsg() != ROK)
12247 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
12253 FreeUeContextModResp(f1apMsg);
12256 /*******************************************************************
12258 * @brief Deallocating the memory allocated by the aper decoder
12263 * Function : freeAperDecodeQosInfo
12265 * Functionality: Deallocating the memory allocated for QOSInfo
12267 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
12271 * ****************************************************************/
12273 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
12275 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
12277 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12279 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12281 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12283 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12285 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
12288 /*******************************************************************
12290 * @brief Deallocating the memory allocated by the aper decoder
12291 * for UlTnlInfoforDrb
12295 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
12297 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
12299 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12303 * ****************************************************************/
12304 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12308 if(ulInfo->list.array)
12310 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
12312 if(ulInfo->list.array[arrIdx])
12314 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
12316 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
12318 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
12320 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12323 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12324 transportLayerAddress.buf);
12326 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
12328 free(ulInfo->list.array[arrIdx]);
12331 free(ulInfo->list.array);
12334 /*******************************************************************
12336 * @brief Deallocating the memory allocated by the aper decoder
12337 * for DrbSetupModItem
12341 * Function : freeAperDecodeDrbSetupModItem
12343 * Functionality: Deallocating memory allocated for DrbSetupModItem
12345 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
12349 * ****************************************************************/
12351 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
12354 SNSSAI_t *snssai =NULLP;
12355 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
12357 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
12358 switch(drbItem->qoSInformation.present)
12360 case QoSInformation_PR_NOTHING:
12362 case QoSInformation_PR_eUTRANQoS:
12364 if(drbItem->qoSInformation.choice.eUTRANQoS)
12366 free(drbItem->qoSInformation.choice.eUTRANQoS);
12370 case QoSInformation_PR_choice_extension:
12372 if(drbItem->qoSInformation.choice.choice_extension)
12374 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
12375 DRB_Information.dRB_QoS);
12376 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
12377 if(snssai->sST.buf)
12379 free(snssai->sST.buf);
12383 if(snssai->sD->buf)
12385 free(snssai->sD->buf);
12390 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
12391 DRB_Information.flows_Mapped_To_DRB_List;
12392 if(flowMap->list.array)
12394 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
12396 if(flowMap->list.array[arrIdx] )
12398 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
12399 free(flowMap->list.array[arrIdx]);
12402 free(flowMap->list.array);
12405 free(drbItem->qoSInformation.choice.choice_extension);
12411 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
12412 if(drbItem->uLConfiguration)
12414 free(drbItem->uLConfiguration);
12418 /*******************************************************************
12420 * @brief Deallocating the memory allocated by the aper decoder
12421 * for DrbToBeSetupModList
12425 * Function : freeAperDecodeDrbToBeSetupModList
12427 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
12429 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
12433 * ****************************************************************/
12435 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
12438 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
12440 if(drbSet->list.array)
12442 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
12444 if(drbSet->list.array[arrIdx] != NULLP)
12448 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
12449 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
12451 free(drbSet->list.array[arrIdx]);
12454 free(drbSet->list.array);
12458 /*******************************************************************
12460 * @brief Deallocating the memory allocated by the aper decoder
12461 * for UeContextModificationReqMsg
12465 * Function : freeAperDecodeUeContextModificationReqMsg
12467 * Functionality: Deallocating memory allocated for
12468 * UeContextModificationReqMsg
12470 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
12474 * ****************************************************************/
12475 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
12477 uint8_t arrIdx, ieId;
12479 if(UeContextModifyReq->protocolIEs.list.array)
12481 for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
12483 if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
12485 ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
12488 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12490 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12492 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12494 freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
12495 value.choice.DRBs_ToBeSetupMod_List);
12499 free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
12502 free(UeContextModifyReq->protocolIEs.list.array);
12505 /*******************************************************************
12507 * @brief processing the F1 UeContextModificationReq
12511 * Function : procF1UeContextModificationReq
12513 * Functionality: processing the F1 UeContextModificationReq
12515 * @params[in] F1AP_PDU_t *f1apMsg
12518 * ****************************************************************/
12519 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
12521 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
12522 uint8_t ret = ROK, ieIdx = 0, lcId =0,cellIdx=0, ueIdx=0;
12523 DuUeCb *duUeCb = NULLP;
12524 DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
12525 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
12527 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
12528 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
12530 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
12532 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12534 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
12537 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12539 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
12542 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12544 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
12546 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
12548 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
12549 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
12552 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
12553 lcId = getDrbLcId(&duUeCb->drbBitMap);
12554 if(lcId != RFAILED)
12556 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
12559 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
12560 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
12561 choice.DRBs_ToBeSetupMod_List;
12562 if(extractDrbListToSetup(lcId, NULL, drbSetupModCfg ,drbSetupModCfg->list.count, \
12563 &duUeCb->f1UeDb->duUeCfg))
12565 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
12573 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
12584 ret = duProcUeContextModReq(duUeCb);
12586 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
12589 /*****************************************************************i
12591 * @brief Free memory allocated for UE Context Release Request
12595 * Function : FreeUeContextReleaseReq
12598 * - Free memory allocated for UE Context Release Request
12600 * @params[in] F1AP_PDU_t *f1apMsg
12603 * *************************************************************/
12604 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
12607 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12611 if(f1apMsg->choice.initiatingMessage)
12613 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12614 if(ueReleaseReq->protocolIEs.list.array)
12616 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
12618 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
12620 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
12622 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12624 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12628 /*****************************************************************i
12630 * @brief Build and Send UE Context Release Request
12634 * Function : BuildAndSendUeContextReleaseReq
12637 * - Build and Send UE Context Release Request
12640 * @return ROK - success
12641 * RFAILED - failure
12643 * *************************************************************/
12644 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
12646 bool memAllocFail = false;
12648 uint8_t ret = RFAILED;
12649 uint16_t cellIdx =0;
12650 uint16_t crnti = 0;
12651 uint8_t elementCnt = 0;
12652 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
12653 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
12654 asn_enc_rval_t encRetVal;
12655 F1AP_PDU_t *f1apMsg = NULLP;
12656 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12658 DU_LOG("\nINFO --> Building the UE Context Release Request");
12661 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12662 if(f1apMsg == NULLP)
12664 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
12668 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
12669 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12670 if(f1apMsg->choice.initiatingMessage == NULLP)
12672 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
12673 initiatingMessage");
12676 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
12677 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
12678 f1apMsg->choice.initiatingMessage->value.present = \
12679 InitiatingMessage__value_PR_UEContextReleaseRequest;
12681 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12685 ueReleaseReq->protocolIEs.list.count = elementCnt;
12686 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
12688 /* Initialize the F1Setup members */
12689 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
12690 if(ueReleaseReq->protocolIEs.list.array == NULLP)
12692 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
12695 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
12697 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
12698 sizeof(UEContextReleaseRequest_t));
12699 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
12701 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
12702 memAllocFail = true;
12706 if(memAllocFail == true)
12709 /* Fetching Ue Cb Info*/
12710 GET_CELL_IDX(cellId, cellIdx);
12711 if(duCb.actvCellLst[cellIdx] == NULLP)
12713 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
12718 GET_CRNTI(crnti, ueIdx);
12719 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
12721 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
12724 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12725 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12729 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12730 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12731 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
12732 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
12733 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
12736 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12737 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12738 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
12739 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
12740 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
12742 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12744 /* Encode the F1SetupRequest type as APER */
12745 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12747 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
12748 /* Encode results */
12749 if(encRetVal.encoded == ENCODE_FAIL)
12751 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
12752 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12757 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
12758 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
12760 printf("%x",encBuf[ieIdx]);
12765 if(sendF1APMsg() != ROK)
12767 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
12774 FreeUeContextReleaseReq(f1apMsg);
12777 /*****************************************************************i
12779 * @brief Free memory allocated for UE Context Release Complete
12783 * Function : FreeUeContextReleaseComplete
12786 * - Free memory allocated for UE Context Release Complete
12788 * @params[in] F1AP_PDU_t *f1apMsg
12791 * *************************************************************/
12792 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
12795 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
12799 if(f1apMsg->choice.successfulOutcome)
12801 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
12802 if(ueReleaseComplete->protocolIEs.list.array)
12804 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
12806 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
12808 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
12810 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12812 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12816 /*****************************************************************i
12818 * @brief Build and Send UE Context Release Complete
12822 * Function : BuildAndSendUeContextReleaseComplete
12825 * - Build and Send UE Context Release Complete
12827 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
12828 * @return ROK - success
12829 * RFAILED - failure
12831 * *************************************************************/
12832 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
12834 bool memAllocFail = false;
12835 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
12836 asn_enc_rval_t encRetVal;
12837 F1AP_PDU_t *f1apMsg = NULLP;
12838 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
12840 DU_LOG("\nINFO --> Building the UE Context Release Complete");
12843 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12844 if(f1apMsg == NULLP)
12846 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
12850 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12851 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12852 if(f1apMsg->choice.successfulOutcome == NULLP)
12854 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
12855 successfulOutcome");
12858 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
12859 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12860 f1apMsg->choice.successfulOutcome->value.present = \
12861 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
12863 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
12866 ueReleaseComplete->protocolIEs.list.count = elementCnt;
12867 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
12869 /* Initialize the UE Release Complete members */
12870 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
12871 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
12873 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
12876 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
12878 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
12879 sizeof(UEContextReleaseComplete_t));
12880 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
12882 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
12884 memAllocFail = true;
12888 if(memAllocFail == true)
12893 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12894 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12895 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
12896 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
12897 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
12900 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12901 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12902 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
12903 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
12904 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
12906 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12908 /* Encode the F1SetupComplete type as APER */
12909 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12911 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
12912 /* Encode results */
12913 if(encRetVal.encoded == ENCODE_FAIL)
12915 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
12916 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12921 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
12922 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
12924 printf("%x",encBuf[ieIdx]);
12929 if(sendF1APMsg() != ROK)
12931 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
12940 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
12941 ret = duSendCellDeletReq(cellId);
12944 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
12945 Delete req for CellId");
12948 FreeUeContextReleaseComplete(f1apMsg);
12953 /*******************************************************************
12955 * @brief added free part for the memory allocated by aper_decoder
12959 * Function : freeAperDecodeUeContextReleaseCommand
12961 * Functionality: added free part for the memory allocated by aper_decoder
12963 * @params[in] F1AP_PDU_t *f1apMsg
12966 * ****************************************************************/
12967 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
12970 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
12972 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
12974 if(ueContextReleaseCommand->protocolIEs.list.array)
12976 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
12978 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
12980 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
12982 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12984 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12986 case ProtocolIE_ID_id_Cause:
12988 case ProtocolIE_ID_id_RRCContainer:
12990 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
12992 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
12997 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
12998 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13002 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
13004 free(ueContextReleaseCommand->protocolIEs.list.array);
13007 /*******************************************************************
13009 * @brief processing of UE Context Release Command
13013 * Function : procF1UeContextReleaseCommand
13015 * Functionality: processing of UE Context Release Command
13017 * @params[in] F1AP_PDU_t *f1apMsg
13020 * ****************************************************************/
13021 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13023 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
13024 uint16_t cellIdx =0;
13026 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
13027 DuUeCb *duUeCb = NULLP;
13028 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13030 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13032 if(ueContextReleaseCommand->protocolIEs.list.array)
13034 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13036 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13038 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13040 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13042 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13043 value.choice.GNB_CU_UE_F1AP_ID;
13047 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13049 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13050 value.choice.GNB_DU_UE_F1AP_ID;
13054 case ProtocolIE_ID_id_Cause:
13059 case ProtocolIE_ID_id_RRCContainer:
13061 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
13063 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
13065 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
13066 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
13068 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13069 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13072 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13073 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
13074 duUeCb->f1UeDb->cellIdx = cellIdx;
13075 /* Filling Dl RRC Msg Info */
13076 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13077 if(!duUeCb->f1UeDb->dlRrcMsg)
13079 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13080 Memory allocation failed ");
13085 duUeCb->f1UeDb->dlRrcMsgPres = true;
13086 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13087 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13088 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13089 value.choice.RRCContainer);
13095 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13096 Memory allocation failed ");
13105 if(ueIdxFound == true)
13112 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13120 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13121 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13129 duProcUeContextReleaseCommand(duUeCb);
13131 freeAperDecodeUeContextReleaseCommand(f1apMsg);
13134 /**************************************************************
13136 * @brief Handles received F1AP message and sends back response
13140 * Function : F1APMsgHdlr
13143 * - Decodes received F1AP control message
13144 * - Prepares response message, encodes and sends to SCTP
13147 * @return ROK - success
13148 * RFAILED - failure
13150 * ****************************************************************/
13151 void F1APMsgHdlr(Buffer *mBuf)
13154 char *recvBuf =NULLP;
13156 MsgLen recvBufLen =0;
13157 F1AP_PDU_t *f1apMsg =NULLP;
13158 asn_dec_rval_t rval; /* Decoder return value */
13159 F1AP_PDU_t f1apasnmsg ;
13160 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
13161 ODU_PRINT_MSG(mBuf, 0,0);
13163 /* Copy mBuf into char array to decode it */
13164 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
13165 DU_ALLOC(recvBuf, (Size)recvBufLen);
13167 if(recvBuf == NULLP)
13169 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
13172 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
13174 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
13178 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
13179 for(i=0; i< recvBufLen; i++)
13181 printf("%x",recvBuf[i]);
13184 /* Decoding flat buffer into F1AP messsage */
13185 f1apMsg = &f1apasnmsg;
13186 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
13188 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
13189 DU_FREE(recvBuf, (Size)recvBufLen);
13191 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13193 DU_LOG("\nERROR --> F1AP : ASN decode failed");
13197 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13199 switch(f1apMsg->present)
13201 case F1AP_PDU_PR_successfulOutcome:
13203 switch(f1apMsg->choice.successfulOutcome->value.present)
13205 case SuccessfulOutcome__value_PR_ResetAcknowledge:
13207 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
13210 case SuccessfulOutcome__value_PR_F1SetupResponse:
13212 #ifndef ODU_TEST_STUB
13213 procF1SetupRsp(f1apMsg);
13218 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
13220 procF1GNBDUCfgUpdAck(f1apMsg);
13226 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
13227 f1apMsg->choice.successfulOutcome->value.present);
13230 }/* End of switch(successfulOutcome) */
13231 free(f1apMsg->choice.successfulOutcome);
13234 case F1AP_PDU_PR_initiatingMessage:
13236 switch(f1apMsg->choice.initiatingMessage->value.present)
13238 case InitiatingMessage__value_PR_Reset:
13240 procF1ResetReq(f1apMsg);
13243 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
13245 procF1DlRrcMsgTrans(f1apMsg);
13248 case InitiatingMessage__value_PR_UEContextSetupRequest:
13250 procF1UeContextSetupReq(f1apMsg);
13253 case InitiatingMessage__value_PR_UEContextModificationRequest:
13255 procF1UeContextModificationReq(f1apMsg);
13258 case InitiatingMessage__value_PR_UEContextReleaseCommand:
13260 procF1UeContextReleaseCommand(f1apMsg);
13265 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
13266 f1apMsg->choice.initiatingMessage->value.present);
13269 }/* End of switch(initiatingMessage) */
13270 free(f1apMsg->choice.initiatingMessage);
13276 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
13281 }/* End of switch(f1apMsg->present) */
13283 } /* End of F1APMsgHdlr */
13285 /**********************************************************************
13287 **********************************************************************/