Moving all common header file into common_def.h file
[o-du/l2.git] / src / du_app / du_sys_info_hdl.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /* This file contains ASN codec for MIB and SIB1 msgs */
20 #include "common_def.h"
21 #include "lrg.h"
22 #include "lkw.x"
23 #include "lrg.x"
24 #include "legtp.h"
25 #include "du_cfg.h"
26 #include "du_mgr.h"
27 #include "du_log.h"
28 #include "BCCH-BCH-Message.h"
29 #include "MIB.h"
30 #include "PLMN-IdentityInfo.h"
31 #include "PLMN-IdentitY.h"
32 #include "SIB-TypeInfo.h"
33 #include "SchedulingInfo.h"
34 #include "SI-SchedulingInfo.h"
35 #include "ConnEstFailureControl.h"
36 #include "FrequencyInfoDL-SIB.h"
37 #include "SearchSpace.h"
38 #include "SCS-SpecificCarrier.h"
39 #include "NR-MultiBandInfo.h"
40 #include "PDCCH-ConfigCommon.h"
41 #include "PDSCH-TimeDomainResourceAllocation.h"
42 #include "PDSCH-TimeDomainResourceAllocationList.h"
43 #include "PDSCH-ConfigCommon.h"
44 #include "BWP-DownlinkCommon.h"
45 #include "DownlinkConfigCommonSIB.h"
46 #include "RACH-ConfigCommon.h"
47 #include "PUSCH-TimeDomainResourceAllocation.h"
48 #include "PUSCH-TimeDomainResourceAllocationList.h"
49 #include "PUSCH-ConfigCommon.h"
50 #include "PUCCH-ConfigCommon.h"
51 #include "UplinkConfigCommonSIB.h"
52 #include "TDD-UL-DL-ConfigCommon.h"
53 #include "ServingCellConfigCommonSIB.h"
54 #include "MCC.h"
55 #include "SIB1.h"
56 #include "du_sys_info_hdl.h"
57
58 void FreeSib1Msg(SIB1_t *sib1Msg);
59 uint8_t FreqInfoUlret = RFAILED;
60 uint8_t RachCfgCommonret = RFAILED;
61 uint8_t PuschCfgCommonret = RFAILED;
62 uint8_t UlCfgCommSibret = RFAILED;
63 uint8_t FreqInfoDlret = RFAILED;
64 uint8_t DlCfgCommSibret = RFAILED;
65 uint8_t CommonSerachSpaceListret = RFAILED;
66
67 /*******************************************************************
68  *
69  * @brief Builds MIB
70  *
71  * @details
72  *
73  *    Function : BuildMib
74  *
75  *    Functionality: Building MIB
76  *
77  * @return ROK     - success
78  *         RFAILED - failure
79  *
80  * ****************************************************************/
81 uint8_t BuildMib(MIB_t *mib)
82 {
83    mib->systemFrameNumber.size = sizeof(uint8_t);
84         DU_ALLOC(mib->systemFrameNumber.buf, 
85                         mib->systemFrameNumber.size);
86         if(!(mib->systemFrameNumber.buf))
87         {
88                 DU_LOG("DU APP: MIB msg memory allocation failure");
89                 return RFAILED;
90         }
91
92         *(mib->systemFrameNumber.buf) =
93                 duCfgParam.mibParams.sysFrmNum;
94         mib->systemFrameNumber.bits_unused = ODU_VALUE_TWO;
95
96         mib->subCarrierSpacingCommon =\
97                 duCfgParam.mibParams.subCarrierSpacingCommon;
98         mib->ssb_SubcarrierOffset =\
99            duCfgParam.mibParams.ssb_SubcarrierOffset;
100         mib->dmrs_TypeA_Position =\
101                 duCfgParam.mibParams.dmrs_TypeA_Position;
102         mib->pdcch_ConfigSIB1.controlResourceSetZero = \
103            duCfgParam.mibParams.controlResourceSetZero;
104         mib->pdcch_ConfigSIB1.searchSpaceZero = \
105            duCfgParam.mibParams.searchSpaceZero;
106         mib->cellBarred = duCfgParam.mibParams.cellBarred;
107         mib->intraFreqReselection =
108                 duCfgParam.mibParams.intraFreqReselection;
109         mib->spare.size = sizeof(uint8_t);
110         DU_ALLOC(mib->spare.buf, mib->spare.size);
111         if(!mib->spare.buf)
112         {
113                 DU_LOG("DU APP: MIB msg memory allocation failure");
114                 return RFAILED;
115         }
116         *(mib->spare.buf) = SPARE;
117         mib->spare.bits_unused = ODU_VALUE_SEVEN;
118    return ROK;
119 }
120 /*******************************************************************
121  *
122  * @brief Free MIB PDU for broadcast
123  *
124  * @details
125  *
126  *    Function : FreeMibPdu
127  *
128  *    Functionality: Deallocating MIB PDU for system broadcast
129  *
130  * @param[in]: BCCH_BCH_Message_t *bcchMsg
131  *
132  * @return void         
133  *
134  * ****************************************************************/
135  void FreeMibPdu(BCCH_BCH_Message_t *bcchMsg)
136  {
137      if(!bcchMsg)
138           {
139               if(!bcchMsg->message.choice.mib)
140                         {
141                             if(!(bcchMsg->message.choice.mib->systemFrameNumber.buf))
142                                  {
143                                           if(!bcchMsg->message.choice.mib->spare.buf)
144                                           {
145                                               DU_FREE(bcchMsg->message.choice.mib->spare.buf,\
146                                                         bcchMsg->message.choice.mib->spare.size);
147                                           }
148                                      DU_FREE(bcchMsg->message.choice.mib->systemFrameNumber.buf,
149                                           bcchMsg->message.choice.mib->systemFrameNumber.size);
150                                  }
151                             DU_FREE(bcchMsg->message.choice.mib, sizeof(MIB_t));
152                         }
153               DU_FREE(bcchMsg, sizeof(BCCH_BCH_Message_t));
154           }
155  }
156 /*******************************************************************
157  *
158  * @brief Builds MIB PDU for broadcast
159  *
160  * @details
161  *
162  *    Function : BuildMibPdu
163  *
164  *    Functionality: Building MIB PDU for system broadcast
165  *
166  * @return ROK     - success
167  *         RFAILED - failure
168  *
169  * ****************************************************************/
170 uint8_t BuildMibPdu()
171 {
172    uint8_t BuildMibret;
173         uint8_t ret = RFAILED;
174         BCCH_BCH_Message_t *bcchMsg;
175         asn_enc_rval_t encRetVal;        /* Encoder return value */
176    while(1)
177         {
178        DU_ALLOC(bcchMsg, sizeof(BCCH_BCH_Message_t));
179        if(!bcchMsg)
180        {
181           DU_LOG("\nMemory allocation failure in BuildMibPdu");
182           break;
183        }
184
185        bcchMsg->message.present = BCCH_BCH_MessageType_PR_mib;
186        DU_ALLOC(bcchMsg->message.choice.mib, sizeof(MIB_t));
187        if(!bcchMsg->message.choice.mib)
188        {
189            DU_LOG("\nMemory allocation failure in BuildMibPdu");
190            break;
191        }
192        BuildMibret = BuildMib(bcchMsg->message.choice.mib);
193                  if(BuildMibret != ROK)
194                  {
195                      break;
196                  }
197             xer_fprint(stdout, &asn_DEF_BCCH_BCH_Message, bcchMsg);
198             cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
199             encBufSize = 0;
200             encRetVal = aper_encode(&asn_DEF_BCCH_BCH_Message, 0,
201                                    bcchMsg, PrepFinalEncBuf, encBuf);
202             printf("\nencbufSize:%d\n", encBufSize);
203             if(encRetVal.encoded        == -1) 
204             {   
205                 DU_LOG("\nDU APP: Could not encode BCCH BCH Message Type structure(at %s)\n", 
206           encRetVal.failed_type?\
207                           encRetVal.failed_type->name
208                           :"unknown");
209                      break;
210             }    
211
212              /* Print encoded buffer */
213              for(int i=0; i< encBufSize; i++)
214              {
215                      printf("%x\t",encBuf[i]);
216              } 
217              printf("\n");
218
219                   ret = ROK;
220                   break;
221         }
222         /* Free allocated memory */
223     FreeMibPdu(bcchMsg);
224
225          return ret;
226
227 }
228  /*******************************************************************
229  *
230  * @brief free MIB message in Served Cell Info
231  *
232  * @details
233  *
234  *    Function : FreeMibMsg
235  *
236  *    Functionality: deallocating MIB message in Served Cell Info
237  *
238  * @param[in]   MIB_t *mibMsg
239  *
240  * @return void
241  *        
242  *
243  * ****************************************************************/
244 void FreeMibMsg( MIB_t *mibMsg)
245 {
246     if(!mibMsg)
247          {
248               if(!(mibMsg->systemFrameNumber.buf))
249                         {   
250                                  if(!mibMsg->spare.buf)
251                                  {
252                                     DU_FREE(mibMsg->spare.buf, mibMsg->spare.size);
253                                  }
254                             DU_FREE(mibMsg->systemFrameNumber.buf,
255                                  mibMsg->systemFrameNumber.size);
256                         }
257               DU_FREE(mibMsg, sizeof(MIB_t));
258          }
259 }
260 /*******************************************************************
261  *
262  * @brief Builds MIB message in Served Cell Info
263  *
264  * @details
265  *
266  *    Function : BuildMibMsg
267  *
268  *    Functionality: Building MIB message in Served Cell Info
269  *
270  * @return ROK     - success
271  *         RFAILED - failure
272  *
273  * ****************************************************************/
274 uint8_t BuildMibMsg()
275 {
276         MIB_t          *mibMsg;
277         asn_enc_rval_t encRetVal;        /* Encoder return value */
278    uint8_t ret = RFAILED;
279         uint8_t BuildMibret;
280    while(1)
281         {
282             DU_ALLOC(mibMsg, sizeof(MIB_t));
283             if(!mibMsg)
284             {
285                      DU_LOG("DU APP: MIB msg memory allocation failure");
286                      break;
287             }
288             BuildMibret =  BuildMib(mibMsg);
289        if(BuildMibret != ROK)
290                  {
291                     break;
292                  }
293             xer_fprint(stdout, &asn_DEF_MIB, mibMsg);
294             cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
295             encBufSize = 0;
296             encRetVal = aper_encode(&asn_DEF_MIB, 0,
297                                    mibMsg, PrepFinalEncBuf, encBuf);
298             printf("\nencbufSize:%d\n", encBufSize);
299             if(encRetVal.encoded        == -1) 
300             {   
301                   DU_LOG("\nDU APP: Could not encode MIB structure(at %s)\n", 
302                           encRetVal.failed_type?\
303                           encRetVal.failed_type->name
304                           :"unknown");
305                      break;
306                  }  
307
308             /* Print encoded buffer */
309             for(int i=0; i< encBufSize; i++)
310             {
311                      printf("%x\t",encBuf[i]);
312             } 
313             printf("\n");
314
315             /* Free allocated memory */
316        ret = ROK;
317                  break;
318         }
319
320         FreeMibMsg(mibMsg);
321    
322         return ret;
323
324 }
325
326 /*******************************************************************
327  *
328  * @brief Builds CellIdentity  within SIB1 message
329  *
330  * @details
331  *
332  *    Function : BuildCellIdentity
333  *
334  *    Functionality: Building RAN area code in SIB1 message 
335  *
336  * @params[in] RAN_AreaCode_t **ranAreaCode 
337  * @return ROK     - success
338  *         RFAILED - failure
339  *
340  * ****************************************************************/
341 uint8_t BuildCellIdentity(CellIdentity_t  *cellIdentity)
342 {
343    cellIdentity->size = ODU_VALUE_FIVE*sizeof(uint8_t);
344         cellIdentity->bits_unused = ODU_VALUE_FOUR;
345
346         DU_ALLOC(cellIdentity->buf, cellIdentity->size);
347         if(!cellIdentity->buf)
348         {   
349                 DU_LOG("DU APP: CellIdentity memory allocation failure");
350                 return RFAILED;
351         }   
352    *cellIdentity->buf = duCfgParam.sib1Params.cellIdentity;
353
354    return ROK;
355 }
356 /*******************************************************************
357  *
358  * @brief Builds RANAC within SIB1 message
359  *
360  * @details
361  *
362  *    Function : BuildRanac
363  *
364  *    Functionality: Building RAN area code in SIB1 message 
365  *
366  * @params[in] RAN_AreaCode_t **ranAreaCode 
367  * @return ROK     - success
368  *         RFAILED - failure
369  *
370  * ****************************************************************/
371 uint8_t BuildRanac(RAN_AreaCode_t **ranAreaCode)
372 {
373    RAN_AreaCode_t *ranac;
374    DU_ALLOC(ranac, sizeof(RAN_AreaCode_t));
375         if(!ranac)
376         {   
377                 DU_LOG("DU APP: RANAC memory allocation failure");
378                 return RFAILED;
379         }   
380    *ranac = duCfgParam.sib1Params.ranac;
381         *ranAreaCode = ranac;
382    return ROK;
383 }
384 /*******************************************************************
385  *
386  * @brief Builds TAC within SIB1 message
387  *
388  * @details
389  *
390  *    Function : BuildTac
391  *
392  *    Functionality: Building Tracking area code in SIB1 message 
393  *
394  * @params[in] TrackingAreaCode_t **tac 
395  * @return ROK     - success
396  *         RFAILED - failure
397  *
398  * ****************************************************************/
399 uint8_t BuildTac(TrackingAreaCode_t **trackAreaCode)
400 {
401    TrackingAreaCode_t *tac;
402   
403
404    DU_ALLOC(tac, sizeof(TrackingAreaCode_t));
405         if(!tac)
406         {   
407                 DU_LOG("DU APP: TAC memory allocation failure");
408                 return RFAILED;
409         }   
410
411         tac->size = ODU_VALUE_THREE*sizeof(uint8_t);
412         DU_ALLOC(tac->buf, tac->size);
413         if(!tac->buf)
414         {   
415                 DU_LOG("DU APP: TAC memory allocation failure");
416                 return RFAILED;
417         }   
418         *(tac->buf) = duCfgParam.sib1Params.tac;
419         tac->bits_unused = ODU_VALUE_ZERO;
420         *trackAreaCode = tac;
421
422    return ROK;
423 }
424
425 /*******************************************************************
426  *
427  * @brief Builds PLMN list within SIB1 message
428  *
429  * @details
430  *
431  *    Function : BuildPlmnList
432  *
433  *    Functionality: Building PLMN list in SIB1 message 
434  *
435  * @params[in] CellAccessRelatedInfo_t *cellAccessInfo 
436  * @return ROK     - success
437  *         RFAILED - failure
438  *
439  * ****************************************************************/
440 uint8_t BuildPlmnList(CellAccessRelatedInfo_t *cellAccessInfo)
441 {
442    uint8_t                 idx;
443         uint8_t                 idx1;
444         uint8_t                 idx2;
445         uint8_t                 elementCnt;
446         TrackingAreaCode_t **tac;
447         RAN_AreaCode_t     **ranac;
448         CellIdentity_t     *cellIdentity;
449    uint8_t            ret;      
450         struct PLMN_IdentityInfo__plmn_IdentityList
451                 *plmnIdInfo;
452
453         DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array,
454                         cellAccessInfo->plmn_IdentityList.list.size);
455         if(!cellAccessInfo->plmn_IdentityList.list.array)
456         {   
457                 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
458                 return RFAILED;
459         }   
460    elementCnt = cellAccessInfo->plmn_IdentityList.list.count; 
461         for(idx=0; idx<elementCnt; idx++)
462         {   
463                 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array[idx],
464                                 sizeof(PLMN_IdentityInfo_t));
465                 if(!cellAccessInfo->plmn_IdentityList.list.array[idx])
466                 {
467                         DU_LOG("DU APP: BuildPlmnList memory allocation failure");
468                         return RFAILED;
469                 }
470         }
471
472         idx = 0;
473         /* PLMN list */
474         elementCnt = ODU_VALUE_ONE;
475
476         plmnIdInfo = &cellAccessInfo->plmn_IdentityList.list.array[idx]->\
477                                          plmn_IdentityList;
478         plmnIdInfo->list.count = elementCnt;
479         plmnIdInfo->list.size  = elementCnt * sizeof(PLMN_IdentitY_t *);
480         DU_ALLOC(plmnIdInfo->list.array, plmnIdInfo->list.size);
481         if(!plmnIdInfo->list.array)
482         {
483                 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
484                 return RFAILED;
485         }
486
487         for(idx1=0; idx1<elementCnt; idx1++)
488         {
489                 DU_ALLOC(plmnIdInfo->list.array[idx1],
490                                 sizeof(PLMN_IdentitY_t));
491                 if(!(plmnIdInfo->list.array[idx1]))
492                 {
493                         DU_LOG("DU APP: BuildPlmnList memory allocation failure");
494                         return RFAILED;
495                 }
496         }
497         idx1 = 0;
498         DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc,
499                         sizeof(MCC_t));
500         if(!plmnIdInfo->list.array[idx1]->mcc)
501         {
502                 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
503                 return RFAILED;
504         }
505
506    elementCnt = ODU_VALUE_THREE;
507         plmnIdInfo->list.array[idx1]->mcc->list.count = elementCnt;
508         plmnIdInfo->list.array[idx1]->mcc->list.size =\
509                 elementCnt * sizeof(MCC_MNC_Digit_t *);
510         DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array,
511                         plmnIdInfo->list.array[idx1]->mcc->list.size)
512         if(!(plmnIdInfo->list.array[idx1]->mcc->list.array))
513         {
514                 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
515                 return RFAILED;
516         }
517         for(idx2=0; idx2<elementCnt; idx2++)
518         {
519                 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2],
520                                 sizeof(MCC_MNC_Digit_t));
521                 if(!plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])
522                 {
523                         DU_LOG("DU APP: BuildPlmnList memory allocation failure");
524                         return RFAILED;
525                 }
526                 *(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])=\
527                         duCfgParam.sib1Params.plmn.mcc[idx2];
528         }
529         idx2 = 0;
530         plmnIdInfo->list.array[idx1]->mnc.list.count = elementCnt;
531         plmnIdInfo->list.array[idx1]->mnc.list.size =\
532                 elementCnt * sizeof(MCC_MNC_Digit_t *);
533         DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array,
534                         plmnIdInfo->list.array[idx1]->mnc.list.size);
535         if(!plmnIdInfo->list.array[idx1]->mnc.list.array)
536         {
537                 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
538                 return RFAILED;
539         }
540         for(idx2=0; idx2<elementCnt; idx2++)
541         {
542                 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2],
543                                 sizeof(MCC_MNC_Digit_t));
544                 if(!plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])
545                 {
546                         DU_LOG("DU APP: BuildPlmnList memory allocation failure");
547                         return RFAILED;
548                 }
549                 *(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])=\
550                         duCfgParam.sib1Params.plmn.mnc[idx2];
551         }
552
553    /* Tracking Area Code */
554    tac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode;
555    ret =        BuildTac(tac);
556         if(ret != ROK)
557         {
558             return RFAILED;
559         }
560
561    /* RANAC */
562         ranac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac;
563         ret=BuildRanac(ranac);
564         if(ret != ROK)
565         {
566             return RFAILED;
567         }
568
569    /* CellIdentity */
570    cellIdentity =\
571         &cellAccessInfo->plmn_IdentityList.list.array[idx]->cellIdentity;
572         ret=BuildCellIdentity(cellIdentity);
573         if(ret != ROK)
574         {
575             return RFAILED;
576         }
577
578         /* cellReservedForOperatorUse */
579         cellAccessInfo->plmn_IdentityList.list.array[idx]->\
580                 cellReservedForOperatorUse = \
581                 duCfgParam.sib1Params.cellResvdForOpUse;
582
583  
584    return ROK;
585 }
586
587 /*******************************************************************
588  *
589  * @brief  Build SIB Map Info List
590  *
591  * @details
592  *
593  *    Function : BuildSibMapInfoList
594  *
595  *    Functionality:
596  *       Build SIB MapInfo List
597  *
598  * @params[in] SIB_Mapping_t pointer
599  * @return ROK     - success
600  *         RFAILED - failure
601  *
602  * ****************************************************************/
603 uint8_t BuildSibMapInfoList(SIB_Mapping_t *sibMapInfo)
604 {
605    uint8_t   itr;         /* List iterator */
606    uint8_t   elementCnt;  /* Number of elements in list */
607    SIB_TypeInfo_t *sibTypeInfo;  /* Scheduling info */
608
609    /* SI scheduling info list */
610    DU_ALLOC(sibMapInfo->list.array, sibMapInfo->list.size);
611    if(!sibMapInfo->list.array)
612    {
613       DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
614       return RFAILED;
615    }
616
617    elementCnt = sibMapInfo->list.count;
618    for(itr = 0; itr < elementCnt; itr++)
619    {
620       DU_ALLOC(sibMapInfo->list.array[itr], sizeof(SIB_TypeInfo_t));
621       if(!sibMapInfo->list.array[itr])
622       {
623          DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
624          return RFAILED;
625       }
626    }
627  
628    itr = 0;
629    sibTypeInfo = sibMapInfo->list.array[itr];
630    sibTypeInfo->type = duCfgParam.sib1Params.siSchedInfo.sibType;
631    DU_ALLOC(sibTypeInfo->valueTag, sizeof(long));
632    if(!sibTypeInfo->valueTag)
633    {
634       DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
635       return RFAILED;
636    }
637
638    *sibTypeInfo->valueTag = duCfgParam.sib1Params.siSchedInfo.sibValTag;
639
640    return ROK;
641 }
642
643 /*******************************************************************
644  *
645  * @brief Builds SI Scheduling info list within SIB1 message 
646  *
647  * @details
648  *
649  *    Function : BuildSiSchedInfoList 
650  *
651  *    Functionality: 
652  *        Building SI Scheduling info list in SIB1 message
653  *
654  * @params[in] struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfo
655  * @return ROK     - success
656  *         RFAILED - failure
657  *
658  * ****************************************************************/
659 uint8_t BuildSiSchedInfoList(struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfoList)
660 {
661    uint8_t   itr;         /* List iterator */
662    uint8_t   elementCnt;  /* Number of elements in list */
663    uint8_t   ret;
664         SchedulingInfo_t *schedInfo;  /* Scheduling info */
665
666    /* SI scheduling info list */
667    DU_ALLOC(si_SchedulingInfoList->list.array, si_SchedulingInfoList->list.size);
668    if(!si_SchedulingInfoList->list.array)
669    {
670       DU_LOG("DU APP: BuildSiSchedInfoList memory allocation failure");
671       return RFAILED;
672    }
673    
674    elementCnt = si_SchedulingInfoList->list.count;
675    for(itr = 0; itr < elementCnt; itr++)
676    {
677       DU_ALLOC(si_SchedulingInfoList->list.array[itr], sizeof(struct SchedulingInfo));
678       if(!si_SchedulingInfoList->list.array[itr])
679       {
680          DU_LOG("DU APP: BuildSiSchedInfoList memory allocation failure");
681          return RFAILED;
682       }
683    }
684
685    itr = 0;
686    schedInfo = si_SchedulingInfoList->list.array[itr];
687    schedInfo->si_BroadcastStatus = duCfgParam.sib1Params.siSchedInfo.broadcastSta;
688    schedInfo->si_Periodicity = duCfgParam.sib1Params.siSchedInfo.preiodicity;
689
690    elementCnt = ODU_VALUE_ONE; 
691    schedInfo->sib_MappingInfo.list.count = elementCnt;
692    schedInfo->sib_MappingInfo.list.size = elementCnt * sizeof(SIB_TypeInfo_t *);
693    
694    ret = BuildSibMapInfoList(&schedInfo->sib_MappingInfo);
695         if(ret != ROK)
696         {
697             return RFAILED;
698         }
699
700    return ROK;
701 }
702
703 /*******************************************************************
704  *
705  * @brief Builds SCS Specific carrier list for DL 
706  *
707  * @details
708  *
709  *    Function : BuildScsSpecificCarrierListDl
710  *
711  *    Functionality:
712  *       Builds Subcarrier specific carrier list for downlink
713  *
714  * @params[in] FrequencyInfoDL_SIB__scs_SpecificCarrierList pointer
715  * @return ROK     - success
716  *         RFAILED - failure
717  *
718  * ****************************************************************/
719 uint8_t BuildScsSpecificCarrierListDl
720 (
721 struct FrequencyInfoDL_SIB__scs_SpecificCarrierList *scsCarrierList
722 )
723 {
724    uint8_t idx;
725    ScsSpecCarrier   duScsSpecCarrier;
726
727    duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
728
729    DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
730    if(!scsCarrierList->list.array)
731    {
732       DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed"); 
733       return RFAILED;
734    }
735
736    for(idx = 0; idx < scsCarrierList->list.count; idx++)
737    {
738       DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
739       if(!scsCarrierList->list.array[idx])
740       {
741          DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
742          return RFAILED;
743       }
744    }
745
746    idx = 0;
747    scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset; 
748    scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
749    scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
750
751    return ROK;
752 } /* End of BuildScsSpecificCarrierListDl */
753
754 /*******************************************************************
755  *
756  * @brief Builds common search space list 
757  *
758  * @details
759  *
760  *    Function : BuildCommonSerachSpaceList
761  *
762  *    Functionality:
763  *      Builds common search space list
764  *
765  * @params[in] PDCCH_ConfigCommon__commonSearchSpaceList pointer
766  * @return ROK     - success
767  *         RFAILED - failure
768  *
769  * ****************************************************************/
770 uint8_t BuildCommonSerachSpaceList
771 (
772 struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist
773 )
774 {
775    uint8_t idx;
776    SearchSpace_t    *searchSpace;
777    PdcchCfgCommon   duPdcchCfg;
778
779    duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
780
781    DU_ALLOC(searchSpclist->list.array, searchSpclist->list.size)
782    if(!searchSpclist->list.array)
783    {
784       DU_LOG("\nDU APP : Common search space list memory alloc failed");
785       return RFAILED;
786    }
787
788    for(idx = 0; idx < searchSpclist->list.count; idx++)
789    {
790       DU_ALLOC(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
791       if(!searchSpclist->list.array[idx])
792       {
793          DU_LOG("\nDU APP : Common search space list memory alloc failed");
794          return RFAILED;
795       }
796    }
797
798    idx = 0;
799    searchSpace = searchSpclist->list.array[idx];
800
801    /* Search Space id */
802    searchSpace->searchSpaceId = duPdcchCfg.searchSpcId;
803
804    /* Control Resource Set Id */
805    DU_ALLOC(searchSpace->controlResourceSetId, sizeof(ControlResourceSetId_t));
806    if(!searchSpace->controlResourceSetId)
807    {
808       DU_LOG("\nDU APP : Common search space list memory alloc failed");
809       return RFAILED;
810    }
811    *searchSpace->controlResourceSetId = duPdcchCfg.ctrlRsrcSetId;
812
813    /* Monitoring Slot periodicity and offset */
814    DU_ALLOC(searchSpace->monitoringSlotPeriodicityAndOffset,\
815       sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
816    if(!searchSpace->monitoringSlotPeriodicityAndOffset)
817    {
818       DU_LOG("\nDU APP : Common search space list memory alloc failed");
819       return RFAILED;
820    }
821    searchSpace->monitoringSlotPeriodicityAndOffset->present = \
822       duPdcchCfg.monitorSlotPrdAndOffPresent;
823    switch(searchSpace->monitoringSlotPeriodicityAndOffset->present)
824    {
825       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
826       {
827          //searchSpace->monitoringSlotPeriodicityAndOffset->choice.s11 = \
828             duPdcchCfg.monitorSlotPrdAndOff;
829          break;
830       }
831       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
832       {
833          //TODO
834          break;
835       }
836       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
837       {
838          //TODO
839          break;
840       }
841       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
842       {
843          //TODO
844          break;
845       }
846       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
847       {
848          //TODO
849          break;
850       }
851       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
852       {
853          //TODO
854          break;
855       }
856       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
857       {
858          //TODO;
859          break;
860       }
861       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
862       {
863          //TODO
864          break;
865       }
866       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
867       {
868          //TODO
869          break;
870       }
871       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
872       {
873          //TODO
874          break;
875       }
876       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
877       {
878          //TODO
879          break;
880       }
881       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
882       {
883          break;
884       }
885       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
886       {
887          //TODO
888          break;
889       }
890       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
891       {
892          //TODO
893          break;
894       }
895       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
896       {
897          //TODO
898          break;
899       }
900       default:
901       {
902          DU_LOG("\nDU APP : Invalid value:Montoring slot periodicity and offset");
903          return RFAILED;
904       }
905    }
906  
907    /* Monitoring Symbols Within Slot */
908    DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot,\
909       sizeof(BIT_STRING_t));
910    if(!searchSpace->monitoringSymbolsWithinSlot)
911    {
912        DU_LOG("\nDU APP : Common search space list memory alloc failed");
913        return RFAILED;
914    }
915    searchSpace->monitoringSymbolsWithinSlot->size = 2*sizeof(uint8_t);
916    DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot->buf, \
917       searchSpace->monitoringSymbolsWithinSlot->size );
918    if(!searchSpace->monitoringSymbolsWithinSlot->buf)
919    {  
920       DU_LOG("\nDU APP : Common search space list memory alloc failed");
921       return RFAILED;
922    }
923    searchSpace->monitoringSymbolsWithinSlot->buf[0] = duPdcchCfg.monitorSymbolsInSlot[0];
924    searchSpace->monitoringSymbolsWithinSlot->buf[1] = duPdcchCfg.monitorSymbolsInSlot[1];
925    searchSpace->monitoringSymbolsWithinSlot->bits_unused = 2;
926
927    /* Number of candidates per aggregation level */
928    DU_ALLOC(searchSpace->nrofCandidates,\
929       sizeof(struct SearchSpace__nrofCandidates));
930    if(!searchSpace->nrofCandidates)
931    {
932       DU_LOG("\nDU APP : Common search space list memory alloc failed");
933       return RFAILED;
934    }
935    searchSpace->nrofCandidates->aggregationLevel1 = duPdcchCfg.numCandAggLvl1;
936    searchSpace->nrofCandidates->aggregationLevel2 = duPdcchCfg.numCandAggLvl2;
937    searchSpace->nrofCandidates->aggregationLevel4 = duPdcchCfg.numCandAggLvl4;
938    searchSpace->nrofCandidates->aggregationLevel8 = duPdcchCfg.numCandAggLvl8;
939    searchSpace->nrofCandidates->aggregationLevel16 = duPdcchCfg.numCandAggLvl16;
940
941    /* Search Space type and  DCI Format */
942    DU_ALLOC(searchSpace->searchSpaceType,\
943       sizeof( struct SearchSpace__searchSpaceType));
944    if(!searchSpace->searchSpaceType)
945    {
946       DU_LOG("\nDU APP : Common search space list memory alloc failed");
947       return RFAILED;
948    }
949
950    searchSpace->searchSpaceType->present = duPdcchCfg.searchSpcType; 
951    switch(searchSpace->searchSpaceType->present)
952    {
953       case SearchSpace__searchSpaceType_PR_NOTHING:
954       {
955         //TODO
956         break;
957       }
958       case SearchSpace__searchSpaceType_PR_common:
959       {
960          DU_ALLOC(searchSpace->searchSpaceType->choice.common,\
961             sizeof(struct SearchSpace__searchSpaceType__common));
962          if(!searchSpace->searchSpaceType->choice.common)
963          {
964             DU_LOG("\nDU APP : Common search space list memory alloc failed");
965             return RFAILED;
966          }
967
968          DU_ALLOC(searchSpace->searchSpaceType->choice.common->\
969             dci_Format0_0_AndFormat1_0, sizeof(struct \
970             SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
971          if(!searchSpace->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)
972          {
973             DU_LOG("\nDU APP : Common search space list memory alloc failed");
974             return RFAILED;
975          }
976          break;
977       }
978       case SearchSpace__searchSpaceType_PR_ue_Specific:
979       {
980          break;
981       }
982       default:
983       {
984          DU_LOG("\nDU_APP: Invalid Search Space type");
985          return RFAILED;
986       }
987
988    }
989
990    return ROK;
991 }/* BuildCommonSerachSpaceList */
992
993 /*******************************************************************
994  *
995  * @brief Builds PDCCH configuration common 
996  *
997  * @details
998  *
999  *    Function : BuildPdcchCfgCommon
1000  *
1001  *    Functionality:
1002  *      Builds PDCCH configuration common
1003  *
1004  * @params[in] BWP_DownlinkCommon__pdcch_ConfigCommon pointer
1005  * @return ROK     - success
1006  *         RFAILED - failure
1007  *
1008  * ****************************************************************/
1009 uint8_t BuildPdcchCfgCommon(struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg)
1010 {
1011    uint8_t   ret;
1012    uint8_t   elementCnt;
1013    PdcchCfgCommon   duPdcchCfg;
1014    PDCCH_ConfigCommon_t  *pdcchSetup;
1015
1016    duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
1017
1018    pdcchCfg->present = duPdcchCfg.present;
1019
1020    switch(pdcchCfg->present)
1021    {
1022       case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
1023       {
1024          //TODO
1025          break;
1026       }
1027       case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
1028       {
1029          //TODO
1030          break;
1031       }
1032       case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
1033       {
1034          DU_ALLOC(pdcchCfg->choice.setup, sizeof(PDCCH_ConfigCommon_t));
1035          if(!pdcchCfg->choice.setup)
1036          {
1037             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1038             return RFAILED;
1039          }
1040          pdcchSetup = pdcchCfg->choice.setup;
1041          
1042          /* Control Resource Set Zero */
1043          DU_ALLOC(pdcchSetup->controlResourceSetZero, 
1044             sizeof(ControlResourceSetZero_t)); 
1045          if(!pdcchSetup->controlResourceSetZero)
1046          {
1047             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1048             return RFAILED;
1049          }
1050          *pdcchSetup->controlResourceSetZero = duPdcchCfg.ctrlRsrcSetZero;
1051          
1052          /* Search space zero */
1053          DU_ALLOC(pdcchSetup->searchSpaceZero, sizeof(SearchSpaceZero_t));
1054          if(!pdcchSetup->searchSpaceZero)
1055          {
1056             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1057             return RFAILED;
1058          }
1059          *pdcchSetup->searchSpaceZero = duPdcchCfg.searchSpcZero;
1060         
1061          /* Common Search Space List */
1062          DU_ALLOC(pdcchSetup->commonSearchSpaceList,\
1063             sizeof(struct PDCCH_ConfigCommon__commonSearchSpaceList));
1064          if(!pdcchSetup->commonSearchSpaceList)
1065          {
1066             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1067             return RFAILED;
1068          }
1069          elementCnt = ODU_VALUE_ONE;
1070          pdcchSetup->commonSearchSpaceList->list.count = elementCnt;
1071          pdcchSetup->commonSearchSpaceList->list.size = \
1072             elementCnt * sizeof(SearchSpace_t *);
1073          ret = BuildCommonSerachSpaceList(pdcchSetup->commonSearchSpaceList);
1074          if(ret != ROK)
1075                         {
1076                             return RFAILED;
1077                         }
1078                         CommonSerachSpaceListret=ROK;
1079          
1080                         /* Search Space for SIB1 */
1081          DU_ALLOC(pdcchSetup->searchSpaceSIB1, sizeof(SearchSpaceId_t));
1082          if(!pdcchSetup->searchSpaceSIB1)
1083          {
1084             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1085             return RFAILED;
1086          }
1087          *pdcchSetup->searchSpaceSIB1 = duPdcchCfg.searchSpcSib1;
1088
1089          /* Serach Space for Paging */
1090          DU_ALLOC(pdcchSetup->pagingSearchSpace, sizeof(SearchSpaceId_t));
1091          if(!pdcchSetup->pagingSearchSpace)
1092          {
1093             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1094             return RFAILED;
1095          }  
1096          *pdcchSetup->pagingSearchSpace = duPdcchCfg.pagingSearchSpc;
1097
1098          /* Search space for Random Access */
1099          DU_ALLOC(pdcchSetup->ra_SearchSpace, sizeof(SearchSpaceId_t));
1100          if(!pdcchSetup->ra_SearchSpace)
1101          {
1102             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1103             return RFAILED;
1104          }             
1105          *pdcchSetup->ra_SearchSpace = duPdcchCfg.raSearchSpc;
1106
1107          break;
1108       }
1109       default :
1110       {
1111          DU_LOG("\nDU APP : Invalid PDCCH Config type");
1112          return RFAILED;
1113       }
1114    }
1115
1116    return ROK;
1117 } /* BuildPdcchCfgCommon */
1118
1119 /*******************************************************************
1120  *
1121  * @brief Builds PDSCH configuration common 
1122  *
1123  * @details
1124  *
1125  *    Function : BuildPdschCfgCommon
1126  *
1127  *    Functionality:
1128  *       Builds PDSCH configuration common
1129  *
1130  * @params[in] BWP_DownlinkCommon__pdsch_ConfigCommon pointer
1131  * @return ROK     - success
1132  *         RFAILED - failure
1133  *
1134  * ****************************************************************/
1135 uint8_t BuildPdschCfgCommon(struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg)
1136 {
1137    uint8_t   idx;
1138    uint8_t   elementCnt;
1139    PdschCfgCommon   duPdschCfg;
1140    PDSCH_ConfigCommon_t  *pdschSetup;
1141    PDSCH_TimeDomainResourceAllocation_t  *timeDomRsrcAllocInfo;
1142  
1143    duPdschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg;
1144   
1145    pdschCfg->present = duPdschCfg.present;
1146
1147    switch(pdschCfg->present)
1148    {
1149       case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
1150       {
1151          //TODO
1152          break;
1153       }
1154       case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
1155       {
1156          //TODO
1157          break;
1158       }
1159       case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
1160       {
1161          DU_ALLOC(pdschCfg->choice.setup, sizeof(PDSCH_ConfigCommon_t));
1162          if(!pdschCfg->choice.setup)
1163          {
1164             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1165             return RFAILED;
1166          }
1167          pdschSetup = pdschCfg->choice.setup; 
1168          
1169          /* Time Domain Allocation List */
1170          DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList, \
1171             sizeof(PDSCH_TimeDomainResourceAllocationList_t));
1172          if(!pdschSetup->pdsch_TimeDomainAllocationList)
1173          {
1174             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1175             return RFAILED;
1176          }
1177          elementCnt = ODU_VALUE_ONE;
1178          pdschSetup->pdsch_TimeDomainAllocationList->list.count = elementCnt;
1179          pdschSetup->pdsch_TimeDomainAllocationList->list.size = \
1180             elementCnt * sizeof(PDSCH_TimeDomainResourceAllocation_t *);
1181
1182          DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array,\
1183             pdschSetup->pdsch_TimeDomainAllocationList->list.size);
1184          if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array)
1185          {
1186             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1187             return RFAILED;
1188          }
1189           
1190          for(idx=0; idx<elementCnt; idx++)
1191          {
1192             DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx],\
1193                sizeof(PDSCH_TimeDomainResourceAllocation_t));
1194             if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx])
1195             {
1196                DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1197                return RFAILED;
1198             }
1199          }
1200
1201          idx = 0;
1202          timeDomRsrcAllocInfo = pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx];
1203
1204          /* K0 */
1205          DU_ALLOC(timeDomRsrcAllocInfo->k0, sizeof(long));
1206          if(!timeDomRsrcAllocInfo->k0)
1207          {
1208             DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1209             return RFAILED;
1210          }
1211          *timeDomRsrcAllocInfo->k0 = duPdschCfg.k0;
1212   
1213          timeDomRsrcAllocInfo->mappingType = duPdschCfg.mapType;
1214          timeDomRsrcAllocInfo->startSymbolAndLength = duPdschCfg.sliv;
1215
1216          break;
1217       }
1218       default:
1219       {
1220          DU_LOG("\nDU APP: Invalid PDSCH Configuration type");
1221          return RFAILED;
1222       }
1223    }
1224
1225    return ROK;
1226 }/* BuildPdschCfgCommon */
1227
1228 /*******************************************************************
1229  *
1230  * @brief Builds DL BWP common 
1231  *
1232  * @details
1233  *
1234  *    Function : BuildBwpDlCommon
1235  *
1236  *    Functionality:
1237  *      Builds DL BWP common
1238  *
1239  * @params[in] BWP_DownlinkCommon_t pointer
1240  * @return ROK     - success
1241  *         RFAILED - failure
1242  *
1243  * ****************************************************************/
1244 uint8_t BuildBwpDlCommon(BWP_DownlinkCommon_t *bwp)
1245 {
1246    uint8_t ret;
1247    DlCfgCommon duDlCfg;
1248  
1249    duDlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1250
1251    bwp->genericParameters.locationAndBandwidth = duDlCfg.locAndBw;
1252    bwp->genericParameters.subcarrierSpacing = duDlCfg.dlScsCarrier.scs;
1253
1254    /* PDCCH Config Common */
1255    DU_ALLOC(bwp->pdcch_ConfigCommon, \
1256       sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
1257    if(!bwp->pdcch_ConfigCommon)
1258    {
1259       DU_LOG("\nDU APP : DL BWP memory allocation failed");
1260       return RFAILED;
1261    }
1262    ret=BuildPdcchCfgCommon(bwp->pdcch_ConfigCommon);
1263    if(ret != ROK)
1264         {
1265             return RFAILED;
1266         }
1267    /* PDSCH Config Common */
1268    DU_ALLOC(bwp->pdsch_ConfigCommon, \
1269       sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
1270    if(!bwp->pdsch_ConfigCommon)
1271    {
1272       DU_LOG("\nDU APP : DL BWP memory allocation failed");
1273       return RFAILED;
1274    }
1275    ret=BuildPdschCfgCommon(bwp->pdsch_ConfigCommon);
1276    if(ret != ROK)
1277         {
1278            return RFAILED;
1279         }
1280    return ROK;
1281 } /* BuildBwpDlCommon */
1282
1283 /*******************************************************************
1284  *
1285  * @brief Build BCCH configuration 
1286  *
1287  * @details
1288  *
1289  *    Function : BuildBcchConfig
1290  *
1291  *    Functionality:
1292  *      Build BCCH configuration
1293  *
1294  * @params[in] BCCH_Config_t pointer
1295  * @return ROK     - success
1296  *         RFAILED - failure
1297  *
1298  * ****************************************************************/
1299
1300 uint8_t BuildBcchConfig(BCCH_Config_t *bcchCfg)
1301 {
1302    BcchCfg   duBcchCfg;
1303
1304    duBcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.bcchCfg;
1305
1306    bcchCfg->modificationPeriodCoeff = duBcchCfg.modPrdCoeff;
1307    
1308    return ROK;
1309 }/* BuildBcchConfig */
1310
1311 /*******************************************************************
1312  *
1313  * @brief Builds PCCH configuration 
1314  *
1315  * @details
1316  *
1317  *    Function : BuildPcchConfig
1318  *
1319  *    Functionality:
1320  *        Builds PCCH configuration
1321  *
1322  * @params[in] 
1323  * @return ROK     - success
1324  *         RFAILED - failure
1325  *
1326  * ****************************************************************/
1327 uint8_t BuildPcchConfig(PCCH_Config_t *pcchCfg)
1328 {
1329    PcchCfg   duPcchCfg;
1330   
1331    duPcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg;
1332  
1333    pcchCfg->defaultPagingCycle = duPcchCfg.dfltPagingCycle;
1334    pcchCfg->nAndPagingFrameOffset.present =  duPcchCfg.nAndPagingFrmOffPresent;
1335    switch(pcchCfg->nAndPagingFrameOffset.present)
1336    {
1337       case PCCH_Config__nAndPagingFrameOffset_PR_NOTHING:
1338       {
1339          //TODO
1340          break;
1341       }
1342       case PCCH_Config__nAndPagingFrameOffset_PR_oneT:
1343       {
1344          break;
1345       }
1346       case PCCH_Config__nAndPagingFrameOffset_PR_halfT:
1347       {
1348          //TODO
1349          break;
1350       }
1351       case PCCH_Config__nAndPagingFrameOffset_PR_quarterT:
1352       {
1353          //TODO
1354          break;
1355       }
1356       case PCCH_Config__nAndPagingFrameOffset_PR_oneEighthT:
1357       {
1358          //TODO
1359          break;
1360       }
1361       case PCCH_Config__nAndPagingFrameOffset_PR_oneSixteenthT:
1362       {
1363          //TODO
1364          break;
1365       }
1366       default:
1367       {
1368          DU_LOG("\nDU APP : Invalid nAndPagingFrameOffset configuration");
1369          return RFAILED;
1370       }
1371    }
1372    pcchCfg->ns = duPcchCfg.numPagingOcc;
1373
1374    return ROK;
1375 }/* BuildPcchConfig */
1376
1377 /*******************************************************************
1378  *
1379  * @brief Builds Frequency Info for Downlink 
1380  *
1381  * @details
1382  *
1383  *    Function : BuildFreqInfoDl
1384  *
1385  *    Functionality:
1386  *     Builds Frequency Info for Downlink
1387  *
1388  * @params[in] 
1389  * @return ROK     - success
1390  *         RFAILED - failure
1391  *
1392  * ****************************************************************/
1393
1394 uint8_t BuildFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
1395 {
1396    uint8_t     ret;
1397         uint8_t idx;
1398    uint8_t elementCnt;
1399    DlCfgCommon  dlCfg;
1400    NR_MultiBandInfo_t  *multiBandInfo;
1401
1402    dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1403
1404    /* NR Multi-Band Info */
1405    elementCnt = ODU_VALUE_ONE;   
1406    frequencyInfoDL->frequencyBandList.list.count = elementCnt;  
1407    frequencyInfoDL->frequencyBandList.list.size = \
1408      elementCnt * sizeof(NR_MultiBandInfo_t *);
1409
1410    DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, \
1411       frequencyInfoDL->frequencyBandList.list.size);
1412    if(!frequencyInfoDL->frequencyBandList.list.array)
1413    {
1414       DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1415       return RFAILED;
1416    }
1417
1418    for(idx = 0; idx < elementCnt; idx++)
1419    {
1420       DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[idx],\
1421          sizeof(NR_MultiBandInfo_t));
1422       if(!frequencyInfoDL->frequencyBandList.list.array[idx])
1423       {
1424          DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1425          return RFAILED;
1426       }
1427    }
1428
1429    idx = 0;
1430    multiBandInfo = frequencyInfoDL->frequencyBandList.list.array[idx];
1431
1432    /* Frequency band indicator */
1433    DU_ALLOC(multiBandInfo->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
1434    if(!multiBandInfo->freqBandIndicatorNR)
1435    {
1436       DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1437       return RFAILED;
1438    }
1439    *multiBandInfo->freqBandIndicatorNR = dlCfg.freqBandInd;
1440
1441    /* Offset to Point A */
1442    frequencyInfoDL->offsetToPointA = dlCfg.offsetToPointA;
1443
1444    /* Subcarrier Spacing specifc carrier */
1445    elementCnt = ODU_VALUE_ONE;
1446    frequencyInfoDL->scs_SpecificCarrierList.list.count = elementCnt;
1447    frequencyInfoDL->scs_SpecificCarrierList.list.size = \
1448       elementCnt * sizeof(SCS_SpecificCarrier_t *);
1449    ret= BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
1450
1451    if(ret != ROK)
1452         {
1453             return RFAILED;
1454         }
1455    return ROK;
1456 }/* BuildFreqInfoDl */
1457
1458 /*******************************************************************
1459  *
1460  * @brief Builds DL configuration common for SIB
1461  *
1462  * @details
1463  *
1464  *    Function : BuildDlCfgCommSib
1465  *
1466  *    Functionality:
1467  *     Builds DL configuration common for SIB
1468  *
1469  * @params[in] DownlinkConfigCommonSIB_t pointer 
1470  * @return ROK     - success
1471  *         RFAILED - failure
1472  *
1473  * ****************************************************************/
1474
1475 uint8_t BuildDlCfgCommSib(DownlinkConfigCommonSIB_t *dlCfg)
1476 {
1477    /* DL frequency info */
1478         uint8_t ret;
1479    ret = BuildFreqInfoDl(&dlCfg->frequencyInfoDL);
1480    if(ret != ROK)
1481         {
1482              return RFAILED;
1483         }
1484         FreqInfoDlret=ROK;
1485    /* BWP Downlink Common */
1486    ret = BuildBwpDlCommon(&dlCfg->initialDownlinkBWP);
1487    if(ret != ROK)
1488         {
1489             return RFAILED;
1490         }
1491    /* BCCH Config */
1492    ret = BuildBcchConfig(&dlCfg->bcch_Config);
1493    if(ret != ROK)
1494         {
1495             return RFAILED;
1496         }
1497    /* PCCH Config */
1498    ret = BuildPcchConfig(&dlCfg->pcch_Config);
1499    if(ret != ROK)
1500         {
1501             return RFAILED;
1502         }
1503         return ROK;
1504 } /* BuildDlCfgCommSib */
1505
1506 /*******************************************************************
1507  *
1508  * @brief Builds SCS specific carrier list for UL 
1509  *
1510  * @details
1511  *
1512  *    Function : BuildScsSpecificCarrierListUl
1513  *
1514  *    Functionality:
1515  *       Builds SCS specific carrier list for UL
1516  *
1517  * @params[in] 
1518  * @return ROK     - success
1519  *         RFAILED - failure
1520  *
1521  * ****************************************************************/
1522
1523 uint8_t BuildScsSpecificCarrierListUl
1524 (
1525 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList
1526 )
1527 {
1528    uint8_t idx;
1529    ScsSpecCarrier   duScsSpecCarrier;
1530  
1531    duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
1532  
1533    DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
1534    if(!scsCarrierList->list.array)
1535    {
1536        DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
1537        return RFAILED;
1538    }
1539  
1540    for(idx = 0; idx < scsCarrierList->list.count; idx++)
1541    {
1542       DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
1543       if(!scsCarrierList->list.array[idx])
1544       {
1545          DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
1546          return RFAILED;
1547       }
1548    }
1549    idx = 0;
1550    scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
1551    scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
1552    scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
1553  
1554    return ROK;
1555 } /* End of BuildScsSpecificCarrierListUl */
1556
1557 /*******************************************************************
1558  *
1559  * @brief Builds frequency infor for UL 
1560  *
1561  * @details
1562  *
1563  *    Function : BuildFreqInfoUl
1564  *
1565  *    Functionality:
1566  *       Builds frequency infor for UL
1567  *
1568  * @params[in] FrequencyInfoUL_SIB_t pointer
1569  * @return ROK     - success
1570  *         RFAILED - failure
1571  *
1572  * ****************************************************************/
1573
1574 uint8_t BuildFreqInfoUl(FrequencyInfoUL_SIB_t *frequencyInfoUL)
1575 {
1576    uint8_t      elementCnt;
1577    UlCfgCommon  ulCfg;
1578    uint8_t          ret;
1579    ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
1580      
1581    /* Subcarrier Spacing specifc carrier */
1582    elementCnt = ODU_VALUE_ONE;
1583    frequencyInfoUL->scs_SpecificCarrierList.list.count = elementCnt;
1584    frequencyInfoUL->scs_SpecificCarrierList.list.size = \
1585      elementCnt * sizeof(SCS_SpecificCarrier_t *);
1586    ret=BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
1587    if(ret != ROK)
1588         {
1589             return RFAILED;
1590         }
1591    /* P-MAX */
1592    DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
1593    if(!frequencyInfoUL->p_Max)
1594    {
1595       DU_LOG("\nDU APP : UL Frequency Infoo  memory allocation failure");
1596       return RFAILED;
1597    }
1598    *frequencyInfoUL->p_Max = ulCfg.pMax;
1599    FreqInfoUlret=ROK;
1600    return ROK;
1601 }/* BuildFreqInfoUl */
1602
1603 /*******************************************************************
1604  *
1605  * @brief Builds RACH configuration common 
1606  *
1607  * @details
1608  *
1609  *    Function : BuildRachCfgCommon
1610  *
1611  *    Functionality:
1612  *      Builds RACH configuration common
1613  *
1614  * @params[in] BWP_UplinkCommon__rach_ConfigCommon pointer
1615  * @return ROK     - success
1616  *         RFAILED - failure
1617  *
1618  * ****************************************************************/
1619
1620 uint8_t  BuildRachCfgCommon(struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg)
1621 {
1622    RachCfgCommon    duRachCfg;
1623    RACH_ConfigCommon_t  *setup;
1624
1625    duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
1626
1627    rachCfg->present = duRachCfg.present;
1628    switch(rachCfg->present)
1629    {
1630       case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
1631       {
1632          //TODO
1633          break;
1634       }
1635       case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
1636       {
1637          //TODO
1638          break;
1639       }
1640       case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
1641       {
1642          DU_ALLOC(rachCfg->choice.setup, sizeof(RACH_ConfigCommon_t)); 
1643          if(!rachCfg->choice.setup)
1644          {
1645             DU_LOG("\nDU APP : Rach Config memory alloc failed");
1646             return RFAILED;
1647          }
1648          setup = rachCfg->choice.setup;
1649
1650          /* Generic RACH Configuration */
1651          setup->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
1652          setup->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
1653          setup->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
1654          setup->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
1655          setup->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr; 
1656          setup->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
1657          setup->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
1658          setup->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
1659
1660          /* Total number of RA preambles */
1661          DU_ALLOC(setup->totalNumberOfRA_Preambles, sizeof(long));
1662          if(!setup->totalNumberOfRA_Preambles)
1663          {
1664             DU_LOG("\nDU APP : Rach Config memory alloc failed");
1665             return RFAILED;
1666          }
1667          *setup->totalNumberOfRA_Preambles = duRachCfg.numRaPreamble;
1668
1669          /* SSB per RACH occassion and CB Preambles per SSB */
1670          DU_ALLOC(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
1671           sizeof(struct RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
1672          if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
1673          {
1674             DU_LOG("\nDU APP : Rach Config memory alloc failed");
1675             return RFAILED;
1676          }
1677          setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present = \
1678             duRachCfg.ssbPerRachOccPresent;
1679          switch(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present)
1680          {
1681             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_NOTHING:
1682             {
1683                //TODO
1684                break;
1685             }
1686             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth:
1687             {
1688                //TODO
1689                break;
1690             }
1691             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth:
1692             {
1693                //TODO
1694                break;
1695             }
1696             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf:
1697             {
1698                //TODO
1699                break;
1700             }
1701             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one:
1702             {
1703                setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one =\
1704                   duRachCfg.numSsbPerRachOcc;
1705             }
1706             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two:
1707             {
1708                //TODO
1709                break;
1710             }
1711             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four:
1712             {
1713                //TODO
1714                break;
1715             }
1716             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight:
1717             {
1718                //TODO
1719                break;
1720             }
1721             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen:
1722             {
1723                //TODO
1724                break;
1725             }
1726             default:
1727             {
1728                DU_LOG("\nDU APP: Invalid value for \
1729                   ssb_PerRach_OccassionAndCB_PreamblesPerSSB");
1730                return RFAILED;
1731             }
1732          }
1733
1734          /* RA Contention Resolution Timer */
1735          setup->ra_ContentionResolutionTimer = duRachCfg.contResTimer;
1736
1737          /* RSRP Threshold SSB */
1738          DU_ALLOC(setup->rsrp_ThresholdSSB, sizeof(RSRP_Range_t));
1739          if(!setup->rsrp_ThresholdSSB)
1740          {
1741             DU_LOG("\nDU APP : Rach Config memory alloc failed");
1742             return RFAILED;
1743          }
1744          *setup->rsrp_ThresholdSSB = duRachCfg.rsrpThreshSsb;
1745
1746          /* Root Sequence index */
1747          setup->prach_RootSequenceIndex.present = duRachCfg.rootSeqIdxPresent;
1748          switch(setup->prach_RootSequenceIndex.present)
1749          {
1750             case RACH_ConfigCommon__prach_RootSequenceIndex_PR_NOTHING:
1751             {
1752                //TODO
1753                break;
1754             }
1755             case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839:
1756             {
1757                //TODO
1758                break;;
1759             }
1760             case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139:
1761             {
1762                setup->prach_RootSequenceIndex.choice.l139 = duRachCfg.rootSeqIdx;
1763                break;
1764             }
1765             default:
1766             {
1767                DU_LOG("\nDU APP: Inavlid PRACH root sequence index type");
1768                return RFAILED;
1769             }
1770          }
1771          
1772          /* Msg 1 Subcarrier spacing */
1773          DU_ALLOC(setup->msg1_SubcarrierSpacing, sizeof(SubcarrierSpacing_t));
1774          if(!setup->msg1_SubcarrierSpacing)
1775          {
1776             DU_LOG("\nDU APP : Rach Config memory alloc failed");
1777             return RFAILED;
1778          }
1779          *setup->msg1_SubcarrierSpacing = duRachCfg.msg1Scs;
1780
1781          /* Restricted Set Config */
1782          setup->restrictedSetConfig = duRachCfg.restrictedSetCfg;
1783
1784          break;
1785       }
1786       default:
1787       {
1788          DU_LOG("\nDU APP : Invalid RACH Config type ");
1789          return RFAILED;
1790       }
1791    }
1792         return ROK;
1793 }/* BuildRachCfgCommon */
1794
1795 /*******************************************************************
1796  *
1797  * @brief Builds PUSCH configuration for common 
1798  *
1799  * @details
1800  *
1801  *    Function : BuildPuschCfgCommon
1802  *
1803  *    Functionality:
1804  *      Builds PUSCH configuration for common
1805  *
1806  * @params[in] 
1807  * @return ROK     - success
1808  *         RFAILED - failure
1809  *
1810  * ****************************************************************/
1811
1812 uint8_t BuildPuschCfgCommon(struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg)
1813 {
1814    uint8_t           idx;
1815    uint8_t           elementCnt;   
1816    PuschCfgCommon    duPuschCfg;
1817    PUSCH_ConfigCommon_t *setup;
1818    PUSCH_TimeDomainResourceAllocation_t  *timeDomRsrcAllocInfo;
1819   
1820    duPuschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.puschCfg;
1821  
1822    puschCfg->present = duPuschCfg.present;
1823    switch(puschCfg->present)
1824    {
1825       case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
1826       {
1827          //TODO
1828          break;
1829       }
1830       case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
1831       {
1832          //TODO
1833          break;
1834       }
1835       case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
1836       {
1837          DU_ALLOC(puschCfg->choice.setup, sizeof(PUSCH_ConfigCommon_t));
1838          if(!puschCfg->choice.setup)
1839          {
1840             DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1841             return RFAILED;
1842          }
1843          setup = puschCfg->choice.setup;
1844
1845          /* Time Domain Resource Allocation List */
1846          DU_ALLOC(setup->pusch_TimeDomainAllocationList,\
1847             sizeof(PUSCH_TimeDomainResourceAllocationList_t)); 
1848          if(!setup->pusch_TimeDomainAllocationList)
1849          {
1850             DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1851             return RFAILED;
1852          }
1853          elementCnt = ODU_VALUE_ONE;
1854          setup->pusch_TimeDomainAllocationList->list.count = elementCnt;
1855          setup->pusch_TimeDomainAllocationList->list.size = \
1856             elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
1857
1858          DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array, \
1859             setup->pusch_TimeDomainAllocationList->list.size);
1860          if(!setup->pusch_TimeDomainAllocationList->list.array)
1861          {
1862             DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1863             return RFAILED;
1864          }
1865
1866          for(idx=0; idx<elementCnt; idx++)
1867          {
1868             DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array[idx],\
1869                sizeof(PUSCH_TimeDomainResourceAllocation_t));
1870             if(!setup->pusch_TimeDomainAllocationList->list.array[idx])
1871             {
1872                DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1873                return RFAILED;
1874             }
1875          }
1876
1877          idx = 0;
1878          timeDomRsrcAllocInfo = setup->pusch_TimeDomainAllocationList->list.array[idx];
1879
1880          /* K2 */
1881          DU_ALLOC(timeDomRsrcAllocInfo->k2, sizeof(long));
1882          if(!timeDomRsrcAllocInfo->k2)
1883          {
1884             DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1885             return RFAILED;
1886          }
1887          *timeDomRsrcAllocInfo->k2 = duPuschCfg.k2;
1888
1889          timeDomRsrcAllocInfo->mappingType = duPuschCfg.mapType;
1890          timeDomRsrcAllocInfo->startSymbolAndLength = duPuschCfg.sliv;
1891          
1892          /* Msg3 Delta Preamble */
1893          DU_ALLOC(setup->msg3_DeltaPreamble, sizeof(long));
1894          if(!setup->msg3_DeltaPreamble)
1895          {
1896             DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1897             return RFAILED;
1898          }
1899          *setup->msg3_DeltaPreamble = duPuschCfg.msg3DeltaPreamble;
1900
1901          /* P0 Nominal with grnat */
1902          DU_ALLOC(setup->p0_NominalWithGrant, sizeof(long));
1903          if(!setup->p0_NominalWithGrant)
1904          {
1905             DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1906             return RFAILED;
1907          }
1908          *setup->p0_NominalWithGrant = duPuschCfg.p0NominalWithGrant;
1909
1910          break;
1911       }
1912       default:
1913       {
1914          DU_LOG("\nDU APP : Invalid PUSCH configuration type ");
1915          return RFAILED;
1916       }
1917    }
1918
1919    return ROK;
1920 }/* BuildPuschCfgCommon */
1921
1922 /*******************************************************************
1923  *
1924  * @brief  Builds PUCCH configuration common
1925  *
1926  * @details
1927  *
1928  *    Function : BuildPucchCfgCommon
1929  *
1930  *    Functionality:
1931  *      Builds PUCCH configuration common
1932  *
1933  * @params[in] 
1934  * @return ROK     - success
1935  *         RFAILED - failure
1936  *
1937  * ****************************************************************/
1938
1939 uint8_t BuildPucchCfgCommon( struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg)
1940 {
1941    PucchCfgCommon    duPucchCfg;
1942    PUCCH_ConfigCommon_t *setup;
1943
1944    duPucchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.pucchCfg;
1945  
1946    pucchCfg->present = duPucchCfg.present;
1947    switch(pucchCfg->present)
1948    {
1949       case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
1950       {
1951          //TODO
1952          break;
1953       }
1954       case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
1955       {
1956          //TODO
1957          break;
1958       }
1959       case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
1960       {
1961          DU_ALLOC(pucchCfg->choice.setup, sizeof(PUCCH_ConfigCommon_t));
1962          if(!pucchCfg->choice.setup)
1963          {
1964             DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1965             return RFAILED;
1966          }
1967          setup = pucchCfg->choice.setup;
1968          
1969          /* Resource Common */
1970          DU_ALLOC(setup->pucch_ResourceCommon, sizeof(long));
1971          if(!setup->pucch_ResourceCommon)
1972          {
1973             DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1974             return RFAILED;
1975          }
1976          *setup->pucch_ResourceCommon = duPucchCfg.rsrcComm;
1977
1978          /* Group hopping */
1979          setup->pucch_GroupHopping = duPucchCfg.grpHop;
1980
1981          /* P0 nominal */
1982          DU_ALLOC(setup->p0_nominal, sizeof(long));
1983          if(!setup->p0_nominal)
1984          {
1985            DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1986            return RFAILED;
1987          }
1988          *setup->p0_nominal = duPucchCfg.p0Nominal;
1989
1990          break;
1991       }
1992       default:
1993       {
1994          DU_LOG("\nDU APP : Invalid PUCCH Config type");
1995          return RFAILED;
1996       }
1997    }
1998    return ROK;
1999 }/* BuildPucchCfgCommon */
2000
2001 /*******************************************************************
2002  *
2003  * @brief Builds UL BWP Common 
2004  *
2005  * @details
2006  *
2007  *    Function : BuildBwpUlCommon
2008  *
2009  *    Functionality:
2010  *      Builds UL BWP Common 
2011  *
2012  * @params[in] BWP_UplinkCommon_t pointer
2013  * @return ROK     - success
2014  *         RFAILED - failure
2015  *
2016  * ****************************************************************/
2017
2018 uint8_t BuildBwpUlCommon(BWP_UplinkCommon_t *bwp)
2019 {
2020    uint8_t         ret;
2021         UlCfgCommon duUlCfg;
2022  
2023    duUlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
2024  
2025    bwp->genericParameters.locationAndBandwidth = duUlCfg.locAndBw;
2026    bwp->genericParameters.subcarrierSpacing = duUlCfg.ulScsCarrier.scs;
2027  
2028    /* RACH Config Common */
2029    DU_ALLOC(bwp->rach_ConfigCommon,\
2030       sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2031    if(!bwp->rach_ConfigCommon)
2032    {
2033       DU_LOG("\nDU APP : UL BWP memory allocation failed");
2034       return RFAILED;
2035    }
2036    ret = BuildRachCfgCommon(bwp->rach_ConfigCommon);
2037    if(ret != ROK)
2038         {
2039               return RFAILED;
2040         }
2041         RachCfgCommonret=ROK;
2042         
2043         /* PUSCH Config Common */
2044    DU_ALLOC(bwp->pusch_ConfigCommon,\
2045       sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2046    if(!bwp->pusch_ConfigCommon)
2047    {
2048       DU_LOG("\nDU APP : UL BWP memory allocation failed");
2049       return RFAILED;
2050    } 
2051    ret = BuildPuschCfgCommon(bwp->pusch_ConfigCommon);
2052         if(ret != ROK)
2053         {
2054             return RFAILED;
2055         }
2056    PuschCfgCommonret = ROK;
2057    
2058         /* PUCCH Config Common */
2059    DU_ALLOC(bwp->pucch_ConfigCommon,\
2060       sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2061    if(!bwp->pucch_ConfigCommon)
2062    {
2063       DU_LOG("\nDU APP : UL BWP memory allocation failed");
2064       return RFAILED;
2065    } 
2066    ret = BuildPucchCfgCommon(bwp->pucch_ConfigCommon);
2067    if(ret != ROK)
2068         {
2069             return RFAILED;
2070         }
2071    return ROK;
2072 }/* BuildBwpUlCommon */
2073
2074 /*******************************************************************
2075  *
2076  * @brief Builds UL config common for SIB 
2077  *
2078  * @details
2079  *
2080  *    Function : BuildUlCfgCommSib
2081  *
2082  *    Functionality:
2083  *      Builds UL config common for SIB
2084  *
2085  * @params[in] UplinkConfigCommonSIB_t pointer
2086  * @return ROK     - success
2087  *         RFAILED - failure
2088  *
2089  * ****************************************************************/
2090
2091 uint8_t BuildUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2092 {
2093    uint8_t ret;
2094         /* UL frequency info */
2095    ret = BuildFreqInfoUl(&ulCfg->frequencyInfoUL);
2096    if(ret != ROK)
2097         {
2098             return RFAILED;
2099         }
2100    /* BWP Uplink Common */
2101    ret = BuildBwpUlCommon(&ulCfg->initialUplinkBWP);
2102    if(ret != ROK)
2103         {
2104             return RFAILED;
2105         }
2106    /* Time Alignment timer */
2107    ulCfg->timeAlignmentTimerCommon = \
2108      duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
2109
2110    return ROK;
2111 }/* BuildUlCfgCommSib */
2112
2113 /*******************************************************************
2114  *
2115  * @brief Builds TDD UL DL configuration common 
2116  *
2117  * @details
2118  *
2119  *    Function : BuildTddUlDlCfgComm
2120  *
2121  *    Functionality:
2122  *      Builds TDD UL DL configuration common
2123  *
2124  * @params[in] TDD_UL_DL_ConfigCommon_t pointer 
2125  * @return ROK     - success
2126  *         RFAILED - failure
2127  *
2128  * ****************************************************************/
2129
2130 uint8_t BuildTddUlDlCfgComm(TDD_UL_DL_ConfigCommon_t *tddCfg)
2131 {
2132    TddUlDlCfgCommon duTddCfg;
2133
2134    duTddCfg = duCfgParam.sib1Params.srvCellCfgCommSib.tddCfg;
2135
2136    /* Reference Subcarrier spacing */
2137    tddCfg->referenceSubcarrierSpacing = duTddCfg.refScs;
2138
2139    /* Pattern 1*/
2140    tddCfg->pattern1.dl_UL_TransmissionPeriodicity = duTddCfg.txPrd;
2141    tddCfg->pattern1.nrofDownlinkSlots = duTddCfg.numDlSlots;
2142    tddCfg->pattern1.nrofDownlinkSymbols = duTddCfg.numDlSymbols;
2143    tddCfg->pattern1.nrofUplinkSlots = duTddCfg.numUlSlots;
2144    tddCfg->pattern1.nrofUplinkSymbols = duTddCfg.numUlSymbols;
2145    
2146    return ROK;
2147
2148 }/* BuildTddUlDlCfgComm */
2149  
2150 /*******************************************************************
2151  * 
2152  * @brief Builds Serving cell config common in SIB1 message 
2153  * 
2154  * @details
2155  * 
2156  *     Function : BuildServCellCfgCommonSib
2157  * 
2158  *    Functionality: 
2159  *       Building Serving cell config common in SIB1 message
2160  *
2161  * @params[in] ServingCellConfigCommonSIB_t pointer
2162  * @return ROK     - success
2163  *         RFAILED - failure
2164  *
2165  * ****************************************************************/
2166 uint8_t BuildServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2167 {
2168    SrvCellCfgCommSib    duSrvCellCfg;
2169    BIT_STRING_t         *ssbPosInBurst;
2170    uint8_t                  ret;
2171    duSrvCellCfg = duCfgParam.sib1Params.srvCellCfgCommSib;
2172
2173    /* SSB Position in Burst */
2174    ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2175    ssbPosInBurst->size = 1;
2176    DU_ALLOC(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2177    if(!ssbPosInBurst->buf)
2178    {
2179       DU_LOG("\nDU APP : Serving cell config common  memory allocation failure");
2180       return RFAILED;
2181    } 
2182    ssbPosInBurst->buf[0] = duSrvCellCfg.ssbPosInBurst;  
2183    ssbPosInBurst->bits_unused = 0;
2184
2185         switch(duSrvCellCfg.ssbPrdServingCell)
2186         {
2187            case SSB_PERIODICITY_5MS:
2188                    srvCellCfg->ssb_PeriodicityServingCell = \
2189                            ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms5;
2190                         break;
2191            case SSB_PERIODICITY_10MS:
2192                    srvCellCfg->ssb_PeriodicityServingCell = \
2193                            ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms10;
2194                         break;
2195                 case SSB_PERIODICITY_20MS:
2196                    srvCellCfg->ssb_PeriodicityServingCell = \
2197                            ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms20;
2198                         break;
2199                 case SSB_PERIODICITY_40MS:
2200                    srvCellCfg->ssb_PeriodicityServingCell = \
2201                            ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms40;
2202                         break;
2203                 case SSB_PERIODICITY_80MS:
2204                    srvCellCfg->ssb_PeriodicityServingCell = \
2205                            ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms80;
2206                         break;
2207                 case SSB_PERIODICITY_160MS:
2208                    srvCellCfg->ssb_PeriodicityServingCell = \
2209                            ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms160;
2210                         break;
2211         }
2212
2213    srvCellCfg->ss_PBCH_BlockPower = duSrvCellCfg.ssPbchBlockPwr;
2214
2215    /* Downlink config common */
2216    ret = BuildDlCfgCommSib(&srvCellCfg->downlinkConfigCommon);
2217         if(ret != ROK)
2218         {
2219              return RFAILED;
2220         }
2221    DlCfgCommSibret = ROK;
2222
2223    /* Uplink Config Comm */
2224    DU_ALLOC(srvCellCfg->uplinkConfigCommon, sizeof(UplinkConfigCommonSIB_t));
2225    if(!srvCellCfg->uplinkConfigCommon)
2226    {
2227       DU_LOG("\nDU APP : Serving cell config common  memory allocation failure");
2228       return RFAILED;
2229    }
2230    ret = BuildUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2231         if(ret != ROK)
2232         {
2233             return RFAILED;
2234         }
2235    UlCfgCommSibret=ROK;
2236   
2237    /* TDD UL DL Config Comm */
2238    DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
2239    if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2240    {
2241       DU_LOG("\nDU APP : Serving cell config common  memory allocation failure");
2242       return RFAILED;
2243    }
2244    ret = BuildTddUlDlCfgComm(srvCellCfg->tdd_UL_DL_ConfigurationCommon);
2245    if(ret != ROK)
2246         {
2247              return RFAILED;
2248         }
2249    return ROK;
2250 }
2251
2252 /*******************************************************************
2253  *
2254  * @brief Builds SIB message in Served Cell Info
2255  *
2256  * @details
2257  *
2258  *    Function : BuildSib1Msg
2259  *
2260  *    Functionality: Building SIB message in Served Cell Info
2261  *
2262  * @return ROK     - success
2263  *         RFAILED - failure
2264  *
2265  * ****************************************************************/
2266 uint8_t BuildSib1Msg()
2267 {
2268         SIB1_t                   *sib1Msg;
2269         CellAccessRelatedInfo_t  *cellAccessInfo;
2270         uint8_t                       elementCnt;
2271    uint8_t                     ret1;
2272         asn_enc_rval_t           encRetVal; 
2273    uint8_t                  ret = RFAILED;
2274
2275         do
2276         {
2277             DU_ALLOC(sib1Msg, sizeof(SIB1_t));
2278             if(!sib1Msg)
2279             {   
2280                      DU_LOG("DU APP: SIB1 msg memory allocation failure");
2281                      break;
2282             }   
2283    
2284             elementCnt = ODU_VALUE_ONE;
2285
2286        /* PLMN list */
2287             cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2288             cellAccessInfo->plmn_IdentityList.list.count =
2289                     elementCnt;
2290             cellAccessInfo->plmn_IdentityList.list.size
2291                     = elementCnt * sizeof(PLMN_IdentityInfo_t *);
2292
2293        ret1 =  BuildPlmnList(cellAccessInfo);
2294        if(ret1 != ROK)
2295                  {
2296                       break;
2297                  }
2298        /* Connection Establish Failure Control */
2299        DU_ALLOC(sib1Msg->connEstFailureControl, sizeof(ConnEstFailureControl_t));
2300        if(!sib1Msg->connEstFailureControl)
2301        {
2302           DU_LOG("DU APP: sib1Msg->connEstFailureControl memory allocation failure");
2303           break;
2304        }
2305        sib1Msg->connEstFailureControl->connEstFailCount =\
2306           duCfgParam.sib1Params.connEstFailCnt;
2307        sib1Msg->connEstFailureControl->connEstFailOffsetValidity =\
2308           duCfgParam.sib1Params.connEstFailOffValidity;
2309
2310        /* SI Scheduling Info */
2311        DU_ALLOC(sib1Msg->si_SchedulingInfo, sizeof(SI_SchedulingInfo_t));
2312        if(!sib1Msg->si_SchedulingInfo)
2313        {
2314            DU_LOG("DU APP: sib1Msg->si_SchedulingInfo memory allocation failure");
2315            break;
2316        } 
2317        elementCnt = ODU_VALUE_ONE;
2318        sib1Msg->si_SchedulingInfo->schedulingInfoList.list.count = elementCnt;
2319        sib1Msg->si_SchedulingInfo->schedulingInfoList.list.size = elementCnt *
2320                                        sizeof(struct SchedulingInfo *);
2321        ret1 = BuildSiSchedInfoList(&sib1Msg->si_SchedulingInfo->schedulingInfoList);
2322        if(ret1 != ROK)
2323                  {
2324                      break;
2325                  }
2326                  sib1Msg->si_SchedulingInfo->si_WindowLength = duCfgParam.sib1Params.siSchedInfo.winLen;
2327
2328        /* Serving Cell Config Common */
2329        DU_ALLOC(sib1Msg->servingCellConfigCommon, sizeof(ServingCellConfigCommonSIB_t));
2330        if(!sib1Msg->servingCellConfigCommon)
2331        {
2332            DU_LOG("DU APP: sib1Msg->servingCellConfigCommon memory allocation failure");
2333            break;
2334        }
2335        ret1 =  BuildServCellCfgCommonSib(sib1Msg->servingCellConfigCommon);
2336        if(ret1 != ROK)
2337                  {
2338                      break;
2339                  }
2340
2341        xer_fprint(stdout, &asn_DEF_SIB1, sib1Msg);
2342
2343             /* Encode the F1SetupRequest type as APER */
2344             cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2345             encBufSize = 0;
2346             encRetVal = aper_encode(&asn_DEF_SIB1, 0, sib1Msg, PrepFinalEncBuf,\
2347                         encBuf);
2348             printf("\nencbufSize: %d\n", encBufSize);
2349             if(encRetVal.encoded == -1)
2350             {
2351                     DU_LOG("\nDU APP : Could not encode SIB1 structure (at %s)\n",\
2352                                 encRetVal.failed_type ?
2353                                 encRetVal.failed_type->name :
2354                                 "unknown");
2355                     break;
2356             }
2357             for(int i=0; i< encBufSize; i++)
2358             {
2359                      printf("%x\t",encBuf[i]);
2360             }
2361             printf("\n");
2362        
2363                  ret = ROK;
2364        break; 
2365    }while(1);
2366
2367         FreeSib1Msg(sib1Msg);
2368    
2369         return ret;
2370
2371    
2372 }
2373 /*******************************************************************
2374  *
2375  * @brief      :  deallocating the memory of BuildSib1Msg 
2376  *
2377  * @details
2378  *
2379  *     Function : FreeFreqInfoDl
2380  *
2381  *    Functionality: Freeing memory of BuildFreqInfoDl 
2382  *
2383  * @params[in] : FrequencyInfoDL_SIB_t *frequencyInfoDL
2384  * @return     :  void
2385  *
2386  *******************************************************************/
2387 void FreeFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
2388 {
2389      uint8_t idx=0;
2390           uint8_t idx1=0;
2391
2392          /* Free DL frequency info */
2393      if(!frequencyInfoDL->frequencyBandList.list.array)
2394           {
2395                    /*Free Frequency band indicator */
2396                         if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2397                         {
2398                              if(!frequencyInfoDL->frequencyBandList.list.array[idx]->\
2399                              freqBandIndicatorNR)
2400                         { 
2401                                       if(!frequencyInfoDL->scs_SpecificCarrierList.list.array)
2402                                       {
2403                                                 for(idx1 = 0;idx1<frequencyInfoDL->scs_SpecificCarrierList.list.count;idx1++)
2404                                                      {
2405                                                                if(!frequencyInfoDL->scs_SpecificCarrierList.list.array[idx1])
2406                                                                {
2407                                                                     DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.\
2408                                                                          array[idx1], sizeof(SCS_SpecificCarrier_t));
2409                                                                }
2410                                                      }
2411                                                 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.array,
2412                                                           frequencyInfoDL->scs_SpecificCarrierList.list.size);
2413                                        }
2414                                   DU_FREE(frequencyInfoDL->frequencyBandList.list.\
2415                                        array[idx]->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
2416                           }
2417          }
2418                    for(idx = 0; idx <frequencyInfoDL->frequencyBandList.list.count; idx++)
2419                    {
2420                                      if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2421                                           { 
2422                                              DU_FREE(frequencyInfoDL->frequencyBandList.list.array[idx],\
2423                                                   sizeof(NR_MultiBandInfo_t));
2424                                           }
2425                    }
2426                    DU_FREE(frequencyInfoDL->frequencyBandList.list.array,\
2427          frequencyInfoDL->frequencyBandList.list.size);
2428          }
2429 }
2430 /*******************************************************************
2431  *
2432  * @brief  :  deallocating the memory of BuildSib1Msg
2433  *
2434  * @details
2435  *
2436  *     Function :  FreeCommonSerachSpaceList
2437  *
2438  *     Functionality:  deallocating the memory of BuildCommonSerachSpaceList
2439  *
2440  * @params[in] :struct PDCCH_ConfigCommon__commonSearchSpaceList  *searchSpclist
2441  * @return  : void
2442  *
2443  *******************************************************************/
2444 void FreeCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList
2445 *searchSpclist)
2446 {
2447      uint8_t idx=0;
2448           SearchSpace_t *searchSpace= NULLP;
2449
2450      if(!searchSpclist->list.array)
2451           {
2452                          if( searchSpclist->list.array[idx] != NULLP)
2453                          {
2454                              searchSpace= searchSpclist->list.array[idx];
2455                                   if(!searchSpace->controlResourceSetId)
2456                              {
2457                                             if(!searchSpace->monitoringSlotPeriodicityAndOffset)
2458                                             {
2459                                                      if(!searchSpace->monitoringSymbolsWithinSlot)
2460                        {
2461                                                                    if(!searchSpace->monitoringSymbolsWithinSlot->buf)
2462                                                                    {
2463                                                                             if(!searchSpace->nrofCandidates)
2464                                                                             {
2465                                                                                           if(!searchSpace->searchSpaceType)
2466                                                                                           {
2467                                                                                                          switch(searchSpace->searchSpaceType->present)
2468                                                                                                          {
2469                                                                                                                    case SearchSpace__searchSpaceType_PR_NOTHING:
2470                                                                                                                                      break;
2471                                                                                                                         case SearchSpace__searchSpaceType_PR_common:
2472                                                                                                                         {    
2473                                                                                                                                   if(!searchSpace->searchSpaceType->choice.common)
2474                                                                                                                                   {
2475                                                                                                                                                  if(!searchSpace->searchSpaceType->choice.\
2476                                                                                                                                                  common->dci_Format0_0_AndFormat1_0)
2477                                                                                                                                                  {
2478                                                                                                                                                           DU_FREE(searchSpace->searchSpaceType->choice.\
2479                                                                                                                                                           common->dci_Format0_0_AndFormat1_0,sizeof(struct\
2480                                                                                                                                                           SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
2481                                                                                                                                                  }
2482                                                                                                                                                  DU_FREE(searchSpace->searchSpaceType->choice.common,\
2483                                                                                                                                                           sizeof(struct SearchSpace__searchSpaceType__common));
2484                                                                                                                                   }
2485                                                                                                                                   break;
2486                                              }
2487                                                                                                                    case SearchSpace__searchSpaceType_PR_ue_Specific:
2488                                                                                                                                   break;
2489                                                                                                                    default:
2490                                                                                                                                   break;
2491                                                                                                     }
2492                                                                                                     DU_FREE(searchSpace->searchSpaceType,\
2493                                                                                                                  sizeof( struct SearchSpace__searchSpaceType));
2494                                                                                             }
2495                                                                                             DU_FREE(searchSpace->nrofCandidates,\
2496                                                                                                         sizeof(struct SearchSpace__nrofCandidates));
2497                                                                               }
2498                                                                               DU_FREE(searchSpace->monitoringSymbolsWithinSlot->buf,\
2499                                                                                    searchSpace->monitoringSymbolsWithinSlot->size);
2500                                                                    }
2501                                                                    DU_FREE(searchSpace->monitoringSymbolsWithinSlot,\
2502                                                                                  sizeof(BIT_STRING_t));
2503                                                    }
2504                                                 DU_FREE(searchSpace->monitoringSlotPeriodicityAndOffset,\
2505                                                    sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
2506                                     }
2507                                     DU_FREE(searchSpace->controlResourceSetId,sizeof(ControlResourceSetId_t));
2508                            }
2509                   }  
2510                   for(idx = 0; idx < searchSpclist->list.count; idx++)
2511                   {  
2512                                  if(!searchSpclist->list.array[idx])
2513                                  { 
2514                                   DU_FREE(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
2515                                  }
2516                   }
2517              DU_FREE(searchSpclist->list.array, searchSpclist->list.size)
2518          }
2519 }
2520 /*******************************************************************
2521  *
2522  * @brief : deallocating the memory of BuildSib1Msg
2523  *
2524  * @details
2525  *
2526  *     Function : FreeBwpDlCommon
2527  *
2528  *     Functionality :Deallocating memory of BuildBwpDlCommon
2529  *
2530  * @params[in] : BWP_DownlinkCommon_t *bwp
2531  *
2532  * @return      : void
2533  *
2534  *******************************************************************/
2535 void FreeBwpDlCommon(BWP_DownlinkCommon_t *bwp)
2536 {
2537     uint8_t idx =0;
2538     struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg=bwp->pdsch_ConfigCommon;
2539     struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg=bwp->pdcch_ConfigCommon;
2540          pdcchCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg.present; 
2541          pdschCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg.present;
2542
2543          if(!bwp->pdcch_ConfigCommon)
2544          {
2545              if(!bwp->pdsch_ConfigCommon)
2546                   {
2547                       switch( pdschCfg->present)
2548                                 {
2549                                     case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
2550                 {
2551                                             //TODO
2552                                                  break;
2553                                          }
2554                                          case  BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
2555                 { 
2556                                             //TODO
2557                                                  break;
2558                                          }
2559                                          case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
2560                                          {
2561                                              if(!pdschCfg->choice.setup)
2562                                                   {
2563                                                       if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList)
2564                                                                 {
2565                                                                     if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array)
2566                                                                          {
2567                                                                               if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!= NULLP)
2568                                                                                         {
2569                                                                                              if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0)
2570                                                                                              {
2571                                                                                                   DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0,\
2572                                                                                                        sizeof(long)); 
2573                                                                                         }
2574                                                                                         }
2575                                                                               for(idx=0; idx<pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.count ; idx++)
2576                                                                                    {
2577                                                                                              if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!=
2578                                                                                                   NULLP)
2579                                                                                                   {
2580                                                                                             DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx],\
2581                                                                                                       sizeof(PDSCH_TimeDomainResourceAllocation_t));
2582                                                                                                   }
2583                                                                                    }
2584                                                                                    DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array,\
2585                                                                                    pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.size);
2586                                                                          }
2587                                                                          DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList,\
2588                                                                          sizeof(PDSCH_TimeDomainResourceAllocationList_t));
2589                                                                 }
2590                                                       DU_FREE(pdschCfg->choice.setup,
2591                                                                 sizeof(PDSCH_ConfigCommon_t));
2592                                                   }
2593                                          }
2594                                          default:
2595                  break;
2596                                 }
2597                       DU_FREE(bwp->pdsch_ConfigCommon,\
2598                            sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
2599                   }
2600                   
2601                   switch(pdcchCfg->present)
2602                   {
2603                        case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
2604                                  {
2605                                     //TODO
2606                                          break;
2607                                  }
2608                                  case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
2609                                  {
2610                                     //TODO
2611                                          break;
2612                                  }
2613                                   case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
2614                                  {
2615                                      if(!pdcchCfg->choice.setup)
2616                                           {
2617                                                /* Control Resource Set Zero */
2618                                                          if(! pdcchCfg->choice.setup->controlResourceSetZero)
2619                                                          {
2620                            /* Search space zero */
2621                                                              if(! pdcchCfg->choice.setup->searchSpaceZero)
2622                                                                   {
2623                                                                       /* Common Search Space List */
2624                                                                       if(! pdcchCfg->choice.setup->commonSearchSpaceList)
2625                               {
2626                                                                                      if(CommonSerachSpaceListret==ROK)
2627                                                                                           {
2628                                                                                               if(!pdcchCfg->choice.setup->searchSpaceSIB1)
2629                                                                                                         {
2630                                                                                                              if(!pdcchCfg->choice.setup->pagingSearchSpace)
2631                                                                                                                   {
2632                                                                                                                       if(!pdcchCfg->choice.setup->ra_SearchSpace)
2633                                                                                                                                 {
2634                                                                                                                                     DU_FREE(pdcchCfg->choice.setup->ra_SearchSpace,
2635                                                                                                                                          sizeof(SearchSpaceId_t));
2636                                                                                                                                 }
2637                                                                                                                       DU_FREE( pdcchCfg->choice.setup->pagingSearchSpace,
2638                                                                                                                                 sizeof(SearchSpaceId_t));
2639                                                                                                                   }
2640                                                                                                              DU_FREE( pdcchCfg->choice.setup->searchSpaceSIB1,
2641                                                                                                                   sizeof(SearchSpaceId_t));
2642                                                                                                         }
2643                                                                                           }
2644                                                                                       
2645                                                                                           FreeCommonSerachSpaceList(pdcchCfg->choice.setup->commonSearchSpaceList);
2646                                                                                      
2647                                                                                           DU_FREE( pdcchCfg->choice.setup->commonSearchSpaceList,\
2648                                                                                           sizeof(struct
2649                                                                                           PDCCH_ConfigCommon__commonSearchSpaceList));
2650                                                                                 }
2651                                                                       DU_FREE( pdcchCfg->choice.setup->searchSpaceZero,
2652                                                                            sizeof(SearchSpaceZero_t));
2653                                                                   }
2654                                                              DU_FREE( pdcchCfg->choice.setup->controlResourceSetZero,
2655                                                                   sizeof(ControlResourceSetZero_t));
2656                                                          }
2657                                                DU_FREE(pdcchCfg->choice.setup,
2658                                                          sizeof(PDCCH_ConfigCommon_t));
2659                                           }
2660                                           break;
2661                                  }
2662              default:
2663                break;
2664                   }
2665              DU_FREE(bwp->pdcch_ConfigCommon,sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
2666          }
2667 }
2668 /*******************************************************************
2669  *
2670  * @brief  deallocating the memory of BuildSib1Msg
2671  *
2672  * @details
2673  *
2674  *     Function: FreeUlCfgCommSib
2675  *
2676  *     Functionality deallocating the memory of BuildUlCfgCommSib
2677  *
2678  * @params[in] : UplinkConfigCommonSIB_t *ulCfg
2679  *
2680  * @return : void
2681  *
2682  *******************************************************************/
2683 void FreeUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2684 {
2685     uint8_t                 idx=0;
2686     RACH_ConfigCommon_t    *setup;
2687          BWP_UplinkCommon_t     *bwp=&ulCfg->initialUplinkBWP;
2688     struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList;
2689          struct BWP_UplinkCommon__rach_ConfigCommon  *rachCfg;
2690          struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg;
2691          struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg;
2692          puschCfg=ulCfg->initialUplinkBWP.pusch_ConfigCommon;
2693          rachCfg =bwp->rach_ConfigCommon;
2694          scsCarrierList    = &ulCfg->frequencyInfoUL.scs_SpecificCarrierList;
2695
2696          if(!scsCarrierList->list.array)
2697          {
2698          if(!ulCfg->frequencyInfoUL.p_Max)
2699               {
2700                             if(FreqInfoUlret == ROK)
2701                                  {
2702                                       if(!bwp->rach_ConfigCommon)
2703                                                 {
2704                                                          if(RachCfgCommonret== ROK)
2705                                                          {
2706                           if(!bwp->pusch_ConfigCommon)
2707                                                                   {
2708                                                                       
2709                                                                                 if(PuschCfgCommonret==ROK)
2710                                                                                 {
2711                                    if(!bwp->pucch_ConfigCommon)
2712                                                                                           {
2713                                                                                               pucchCfg=bwp->pucch_ConfigCommon;
2714                                                                                                         switch(pucchCfg->present)
2715                                                                                                         {
2716                                                                                                              case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
2717                                                                                                                   break;
2718                                                                                                                   case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
2719                                                                                                                   break;
2720                                                                                                                   case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
2721                                                                                                                   {
2722                                                                                                                       if(!pucchCfg->choice.setup)
2723                                                                                                                                 {
2724                                                                                                                                     
2725                                                                                                                                     if(!pucchCfg->choice.setup->pucch_ResourceCommon)
2726                                                                                                                                          {
2727                                                                                                                                              if(!pucchCfg->choice.setup->p0_nominal)
2728                                                                                                                                                   {
2729                                                                                                                                                       DU_FREE(pucchCfg->choice.setup->p0_nominal,
2730                                                                                                                                                                 sizeof(long));
2731                                                                                                                                                   }
2732                                                                                                                                              DU_FREE(pucchCfg->choice.setup->pucch_ResourceCommon,
2733                                                                                                                                                   sizeof(long));
2734                                                                                                                                          }
2735                                                                                                                                     DU_FREE(pucchCfg->choice.setup,
2736                                                                                                                                          sizeof(PUCCH_ConfigCommon_t));
2737                                                                                                                                 }
2738                                                                                                                   }
2739                                                                                                                   default:
2740                                                                                                                   break;
2741                                                                                                         }
2742                                                                                               DU_FREE(bwp->pucch_ConfigCommon,\
2743                                                                                                    sizeof(struct
2744                                                                                                         BWP_UplinkCommon__pucch_ConfigCommon));
2745                                                                                           }
2746                                                                                 }
2747                                                                                 switch(puschCfg->present)
2748                                                                                 {
2749                                                                                     case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
2750                                                                                             break;
2751                                                                                          case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
2752                                                                                             break;
2753                                                                                          case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
2754                                                                                          {
2755                                                                               if(!puschCfg->choice.setup)
2756                                                                                                   {
2757
2758                                                                                                           if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList)
2759                                                                                                           {
2760                                                                                                                if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array)
2761                                                                                                                          {
2762                                                                                                                              if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2763                                                                                                                                   {
2764                                                                                                                                       if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx]->k2)
2765                                                                                                                                       {
2766                                                                                                                                           if(! puschCfg->choice.setup->msg3_DeltaPreamble)
2767                                                                                                                                                {
2768                                                                                                                                                    if(!puschCfg->choice.setup->p0_NominalWithGrant)
2769                                                                                                                                                         {
2770                                                                                                                                                            DU_FREE(puschCfg->choice.setup->p0_NominalWithGrant,
2771                                                                                                                                                                 sizeof(long));
2772                                                                                                                                                         }
2773                                                                                                                                                    DU_FREE(puschCfg->choice.setup->msg3_DeltaPreamble,
2774                                                                                                                                                         sizeof(long));
2775                                                                                                                                                }
2776                                                                                                                                           DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.\
2777                                                                                                                                                          array[idx]->k2, sizeof(long));
2778                                                                                                                                                 }
2779                                                                                                                                  }
2780                                                                                                                                  for(idx=0;
2781                                                                                                                                  idx<puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.count;
2782                                                                                                                                  idx++)
2783                                                                                                                                  {
2784                                                                                                                                      if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2785                                                                                                                                           {
2786                                                                                                                                               DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx],\
2787                                                                                                                                                         sizeof(PUSCH_TimeDomainResourceAllocation_t));
2788                                                                                                                                           }
2789                                                                                                                                  }
2790                                                                                                                             DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array,\
2791                                                                                                                                  puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.size);
2792                                                                                                                          }
2793                                                                                                                DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList,\
2794                                                                                                                          sizeof(PUSCH_TimeDomainResourceAllocationList_t));
2795                                                                                                           }
2796                                                                                                      DU_FREE(puschCfg->choice.setup,
2797                                                                                                           sizeof(PUSCH_ConfigCommon_t));
2798                                                                                                   }
2799                                                                                          }
2800                                                                                          default :
2801                                                                                            break;
2802                                                                                 }
2803                                                                        
2804                                                                        DU_FREE(bwp->pusch_ConfigCommon,\
2805                                                                                  sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2806                                                                   }
2807                                                          }
2808                                                          switch(rachCfg->present)
2809                                                          {
2810                                                              case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
2811                                                                       break;
2812                                                                   case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
2813                                                                       break;
2814                                                                   case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
2815                                                                   {
2816                                                                       if(!rachCfg->choice.setup)
2817                                                                                 {
2818                                                                                      setup = rachCfg->choice.setup;
2819                                    if(!setup->totalNumberOfRA_Preambles)
2820                                                                                           {
2821                                                                                                if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
2822                                                                                                          {
2823                                                                                                              if(!setup->rsrp_ThresholdSSB)
2824                                                                                                                   {
2825                                                                                                                       if(!setup->msg1_SubcarrierSpacing)
2826                                                                                                                                 {
2827                                                                                                                                      DU_FREE(setup->msg1_SubcarrierSpacing,
2828                                                                                                                                           sizeof(SubcarrierSpacing_t));
2829                                                                                                                                 }
2830                                                                DU_FREE(setup->rsrp_ThresholdSSB,
2831                                                                                                                                 sizeof(RSRP_Range_t));
2832                                                                                                                   }
2833                                                                                                             DU_FREE(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
2834                                                                                                                  sizeof(struct
2835                                                                                                                  RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
2836                                                                                                          }
2837                                                                                               DU_FREE(setup->totalNumberOfRA_Preambles,
2838                                                                                                         sizeof(long));
2839                                                                                           }
2840                                                                                      
2841                                                                                      DU_FREE(rachCfg->choice.setup,
2842                                                                                           sizeof(RACH_ConfigCommon_t));
2843                                                                                 }
2844                                                                   }
2845                                                              default:
2846                              break;
2847                                                         }
2848                                                         DU_FREE(bwp->rach_ConfigCommon,\
2849                                                         sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2850                                                 }
2851                                  }
2852                   DU_FREE(ulCfg->frequencyInfoUL.p_Max, sizeof(P_Max_t));
2853               }    
2854               for(idx = 0; idx < scsCarrierList->list.count; idx++)
2855                         {
2856                             if(!scsCarrierList->list.array[idx])
2857                                  {
2858                                      DU_FREE(scsCarrierList->list.array[idx],
2859                                           sizeof(SCS_SpecificCarrier_t));
2860                                  }
2861                         }
2862               DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
2863          }
2864 }
2865 /*******************************************************************
2866  *
2867  * @brief : Deallocating memory of  SIB1 message
2868  *
2869  * @details
2870  *
2871  *   Function : FreeServCellCfgCommonSib
2872  *
2873  *   Functionality: Deallocating memory of BuildServCellCfgCommonSib
2874  *
2875  * @params[in] : ServingCellConfigCommonSIB_t *srvCellCfg
2876  * @return     : void
2877  *
2878  *******************************************************************/
2879 void FreeServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2880 {
2881      BIT_STRING_t         *ssbPosInBurst;
2882      ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2883           DownlinkConfigCommonSIB_t *dlCfg=&srvCellCfg->downlinkConfigCommon;
2884      
2885           if(!ssbPosInBurst->buf)
2886           {
2887                /* Free DL frequency info */
2888                          if(FreqInfoDlret == ROK)
2889                          {
2890                              if(DlCfgCommSibret == ROK)
2891                                   {
2892                                        /* Uplink Config Comm */
2893                                                 if(!srvCellCfg->uplinkConfigCommon)
2894                                                 {
2895                                                    if(UlCfgCommSibret==ROK)
2896                                                         {
2897                                                              /* TDD UL DL Config Comm */
2898                                                             if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2899                                                                  {
2900                                                                      DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationCommon,
2901                                                                           sizeof(TDD_UL_DL_ConfigCommon_t));
2902                                                                  }
2903                                                         }
2904                                                    FreeUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2905                                                    DU_FREE(srvCellCfg->uplinkConfigCommon,
2906                                                         sizeof(UplinkConfigCommonSIB_t));  
2907                                                 }
2908                                   }
2909                              FreeBwpDlCommon(&dlCfg->initialDownlinkBWP);
2910                          }
2911           FreeFreqInfoDl(&dlCfg->frequencyInfoDL);
2912                DU_FREE(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2913      }
2914 }
2915 /*******************************************************************
2916  *
2917  * @brief   : Deallcating memory of the function BuildSib1Msg
2918  *
2919  * @details
2920  *
2921  *     Function :  FreeSib1Msg
2922  *
2923  *    Functionality: Deallcating memory of the function BuildSib1Msg
2924  *
2925  * @params[in] ServingCellConfigCommonSIB_t pointer
2926  * @return   void
2927  *
2928  *******************************************************************/
2929 void FreeSib1Msg(SIB1_t *sib1Msg)
2930 {
2931         uint8_t idx=0;
2932    uint8_t idx1=0;
2933         uint8_t idx2=0; 
2934    CellIdentity_t           *cellIdentity = NULLP;
2935         CellAccessRelatedInfo_t  *cellAccessInfo ;
2936         struct PLMN_IdentityInfo__plmn_IdentityList     *plmnIdInfo;
2937         
2938          
2939         if(sib1Msg != NULLP)
2940         {
2941             cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2942             if(cellAccessInfo->plmn_IdentityList.list.array !=NULLP)
2943                  {
2944            if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
2945                           {
2946                               plmnIdInfo =
2947                               &cellAccessInfo->plmn_IdentityList.list.array[idx]->plmn_IdentityList;
2948                           
2949                               if(plmnIdInfo->list.array !=NULLP)
2950                               {
2951                                    if(!plmnIdInfo->list.array[idx])
2952                     {
2953                                                       if(!plmnIdInfo->list.array[idx]->mcc)
2954                                                  {
2955                                                       if(!(plmnIdInfo->list.array[idx]->mcc->list.array))
2956                                                            {
2957                                                               if(!plmnIdInfo->list.array[idx]->mnc.list.array)
2958                                                                    {          
2959                                                                                   /*Free Tracking Area Code */
2960                                                                                  if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode)
2961                                                                                  {          
2962                                                                                           /*Free RANAC */
2963                                                                                      if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf)
2964                                                                                      {     
2965                                                                                                   /* Free CellIdentity */
2966                                                                                                    if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac)
2967                                                                                                    {
2968                                                                                                        cellIdentity
2969                                                                                                                  =&cellAccessInfo->plmn_IdentityList.\
2970                                                                                                                  list.array[idx]->cellIdentity;
2971                                                                                                                  if(!cellIdentity->buf)
2972                                                                                                        {
2973                                                                                                                     /*Free Connection Establish Failure Control */
2974                                                                                                                       if(!sib1Msg->connEstFailureControl)
2975                                                                                                                            {
2976                                                                                                                                 /*Free Serving Cell Config Common */
2977                                                                                                                                 if(!sib1Msg->si_SchedulingInfo)
2978                                                                                                                                      {
2979                                                                                                                                                     /* Free Serving Cell Config Common* */
2980                                                                                                                                           if(!sib1Msg->servingCellConfigCommon)
2981                                                                                                                                                     {
2982                                                                                                                                                          /*Free BuildServCellCfgCommonSib*/
2983                                                                                                                                                          FreeServCellCfgCommonSib(\
2984                                                                                                                                                               sib1Msg->servingCellConfigCommon);
2985
2986                                                                                                                                                          DU_FREE(sib1Msg->servingCellConfigCommon,
2987                                                                                                                                                               sizeof(ServingCellConfigCommonSIB_t));
2988                                                                                                                                                     }
2989
2990                                                                                                                                                      DU_FREE(sib1Msg->si_SchedulingInfo,
2991                                                                                                                                                       sizeof(SI_SchedulingInfo_t));
2992                                                                                                                                       }
2993
2994                                                                                                                                  DU_FREE(sib1Msg->connEstFailureControl,
2995                                                                                                                                       sizeof(ConnEstFailureControl_t));
2996                                                                                                                             }
2997                                                                                                                        DU_FREE(cellIdentity->buf,cellIdentity->size);
2998                                                                                                         
2999                                                                                                               }
3000                                                                                                        DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac, sizeof(RAN_AreaCode_t)); 
3001                                                                                           
3002                                                                                                    }
3003                                                                                                    DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf,\
3004                                                                                                    cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->size);
3005                                                                                  
3006                                                                                           }
3007                                                                                       DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode\
3008                                                                                            , sizeof(TrackingAreaCode_t));
3009                                                                                   }
3010                            
3011                                                                         for(idx2=0; idx2<plmnIdInfo->list.array[idx1]->mnc.list.count; idx2++)
3012                                                                                   {
3013                                                                                        if(!plmnIdInfo->list.array[idx2]->mnc.list.array[idx2])
3014                                                                                             {
3015                                                                                                 DU_FREE(plmnIdInfo->list.array[idx2]->mnc.list.array[idx2],
3016                                                                                                         sizeof(MCC_MNC_Digit_t));
3017                                                                                             } 
3018                                                                                   }
3019                                                                         DU_FREE(plmnIdInfo->list.array[idx]->mnc.list.array,
3020                                                                                    plmnIdInfo->list.array[idx1]->mnc.list.size);
3021                                                                   }
3022
3023                                 for(idx1=0; idx1<plmnIdInfo->list.array[idx]->mcc->list.count; idx1++)
3024                                                                    {
3025                                                                         if(plmnIdInfo->list.array[idx]->mcc->list.array[idx1]!=NULLP)
3026                                                                              {
3027                                                                                        DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array[idx1],\
3028                                                                                              sizeof(MCC_MNC_Digit_t));
3029                                                                              }
3030
3031                                                                     }
3032                                                                DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array,\
3033                                  plmnIdInfo->list.array[idx]->mcc->list.size)
3034                                                          }
3035                                                     DU_FREE(plmnIdInfo->list.array[idx]->mcc,sizeof(MCC_t));
3036                                                }
3037                   }
3038                   for(idx1=0; idx1<plmnIdInfo->list.count; idx1++)
3039                                            {
3040                                                if(!(plmnIdInfo->list.array[idx1]))
3041                                                     {
3042                                                        DU_FREE(plmnIdInfo->list.array[idx1],
3043                                                             sizeof(PLMN_IdentitY_t));
3044                                                     }
3045                                            }
3046                                  DU_FREE(plmnIdInfo->list.array, plmnIdInfo->list.size);
3047                               }
3048                           }
3049                           for(idx=0; idx<cellAccessInfo->plmn_IdentityList.list.count; idx++)
3050                           {
3051                               if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
3052                               { 
3053                                             DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx],
3054                                        sizeof(PLMN_IdentityInfo_t));
3055                                         }
3056                           }
3057                           DU_FREE(cellAccessInfo->plmn_IdentityList.list.array,
3058                           cellAccessInfo->plmn_IdentityList.list.size);
3059                  }
3060                  DU_FREE(sib1Msg, sizeof(SIB1_t)); 
3061         }
3062
3063 }
3064
3065 /**********************************************************************
3066   End of file
3067  **********************************************************************/