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