+ DU_LOG("\nF1AP: Memory Alloc failed for RRC Setup Msg at fillDlCcchRrcMsg()");
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Memory Alloc failed for RRC Msg at fillDlCcchRrcMsg()");
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Memory Alloc failed for DL Ccch Msg choice at fillDlCcchRrcMsg()");
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nF1AP: RRC Container is NULLP at fillDlCcchRrcMsg()");
+ ret = RFAILED;
+ }
+}
+
+uint8_t fillQosFlowsToAdd(struct SDAP_Config__mappedQoS_FlowsToAdd *qosFlow)
+{
+ uint8_t idx, ied, elementCnt;
+
+ elementCnt = 1;
+ qosFlow->list.count = elementCnt;
+ qosFlow->list.size = elementCnt * sizeof(QFI_t *);
+ CU_ALLOC(qosFlow->list.array, qosFlow->list.size);
+ if(qosFlow->list.array != NULLP)
+ {
+ for(idx = 0; idx < elementCnt; idx++)
+ {
+ CU_ALLOC(qosFlow->list.array[idx], sizeof(QFI_t));
+ if(qosFlow->list.array[idx] == NULLP)
+ {
+ for(ied = 0; ied < idx; ied++)
+ {
+ CU_FREE(qosFlow->list.array[idx], sizeof(QFI_t));
+ }
+ CU_FREE(qosFlow->list.array, qosFlow->list.size);
+ return RFAILED;
+ }
+ }
+ }
+ idx = 0;
+ *qosFlow->list.array[idx] = 9;
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills CN Assoc for Drb to Add/Mod List
+ *
+ * @details
+ *
+ * Function : fillCnAssoc
+ *
+ * Functionality: Fills CN Assoc for Drb to Add/Mod List
+ *
+ * @params[in] struct DRB_ToAddMod__cnAssociation *
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillCnAssoc(struct DRB_ToAddMod__cnAssociation *cnAssoc)
+{
+ uint8_t ret = ROK;
+
+ cnAssoc->present = DRB_ToAddMod__cnAssociation_PR_sdap_Config;
+ if(cnAssoc->present == DRB_ToAddMod__cnAssociation_PR_eps_BearerIdentity)
+ {
+ cnAssoc->choice.eps_BearerIdentity = 5;
+ }
+ if(cnAssoc->present == DRB_ToAddMod__cnAssociation_PR_sdap_Config)
+ {
+ CU_ALLOC(cnAssoc->choice.sdap_Config, sizeof(SDAP_Config_t));
+ if(cnAssoc->choice.sdap_Config)
+ {
+ cnAssoc->choice.sdap_Config->pdu_Session = 5;
+ cnAssoc->choice.sdap_Config->sdap_HeaderDL = 0;
+ cnAssoc->choice.sdap_Config->sdap_HeaderUL = 0;
+ cnAssoc->choice.sdap_Config->defaultDRB = true;
+ cnAssoc->choice.sdap_Config->mappedQoS_FlowsToAdd = NULLP;
+ cnAssoc->choice.sdap_Config->mappedQoS_FlowsToRelease = NULLP;
+ CU_ALLOC(cnAssoc->choice.sdap_Config->mappedQoS_FlowsToAdd, \
+ sizeof(struct SDAP_Config__mappedQoS_FlowsToAdd));
+ if(cnAssoc->choice.sdap_Config->mappedQoS_FlowsToAdd)
+ {
+ ret = fillQosFlowsToAdd(cnAssoc->choice.sdap_Config->mappedQoS_FlowsToAdd);
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Memory alloc failed at mappedQoS_FlowsToAdd in fillCnAssoc()");
+ CU_FREE(cnAssoc->choice.sdap_Config, sizeof(SDAP_Config_t));
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Mem alloc failed at fillCnAssoc()");
+ ret = RFAILED;
+ }
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Radio Bearer Config for Drb
+ *
+ * @details
+ *
+ * Function : fillDrbCfg
+ *
+ * Functionality: Fills Radio Bearer Config for Drb
+ *
+ * @params[in] drbId, DRB_ToAddModList *
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillDrbCfg(uint8_t drbId, DRB_ToAddModList_t *drbCfg)
+{
+ uint8_t idx, ied, ret, elementCnt;
+
+ ret = ROK;
+ if(drbCfg != NULLP)
+ {
+ elementCnt = 1;
+ drbCfg->list.count = elementCnt;
+ drbCfg->list.size =\
+ elementCnt * sizeof(DRB_ToAddMod_t *);
+ CU_ALLOC(drbCfg->list.array, drbCfg->list.size);
+ if(drbCfg->list.array != NULLP)
+ {
+ for(idx = 0; idx < elementCnt; idx++)
+ {
+ CU_ALLOC(drbCfg->list.array[idx], sizeof(DRB_ToAddMod_t));
+ if(drbCfg->list.array[idx] == NULLP)
+ {
+ for(ied = 0; ied < idx; ied++)
+ {
+ CU_FREE(drbCfg->list.array[idx], sizeof(DRB_ToAddMod_t));
+ }
+ CU_FREE(drbCfg->list.array, drbCfg->list.size);
+ return RFAILED;
+ }
+ }
+ }
+ else
+ {
+ return RFAILED;
+ }
+ idx = 0;
+ /* CN ASSOCIATION */
+ CU_ALLOC(drbCfg->list.array[idx]->cnAssociation, sizeof(struct DRB_ToAddMod__cnAssociation));
+ if(drbCfg->list.array[idx]->cnAssociation)
+ {
+ ret = fillCnAssoc(drbCfg->list.array[idx]->cnAssociation);
+ }
+ /* DRB */
+ drbCfg->list.array[idx]->drb_Identity = drbId;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills RRC Reconfig Message required for DLRRCMessageTransfer
+ *
+ * @details
+ *
+ * Function : fillRrcReconfigIE
+ *
+ * Functionality: Fills RRC Reconfig Message required for
+ * DLRRCMessageTransfer
+ *
+ * @params[in] RRCReconfiguration_IEs_t* rrcReconfig
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillRrcReconfigIE(RRCReconfiguration_IEs_t *rrcReconfigMsg)
+{
+ uint8_t ret = ROK;
+ CU_ALLOC(rrcReconfigMsg->radioBearerConfig, sizeof(RadioBearerConfig_t));
+ if(rrcReconfigMsg->radioBearerConfig)
+ {
+ CU_ALLOC(rrcReconfigMsg->radioBearerConfig->srb_ToAddModList, sizeof(SRB_ToAddModList_t));
+ if(rrcReconfigMsg->radioBearerConfig->srb_ToAddModList != NULLP)
+ {
+ ret = fillSrbCfg(SRB2, rrcReconfigMsg->radioBearerConfig->srb_ToAddModList);
+
+ }
+ if(ret == ROK)
+ {
+ CU_ALLOC(rrcReconfigMsg->radioBearerConfig->drb_ToAddModList, sizeof(DRB_ToAddModList_t));
+ if(rrcReconfigMsg->radioBearerConfig->drb_ToAddModList != NULLP)
+ {
+ ret = fillDrbCfg(DRB1, rrcReconfigMsg->radioBearerConfig->drb_ToAddModList);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\n F1AP: Failed to fill DrbCfg at fillRrcReconfigIE()");
+ CU_FREE(rrcReconfigMsg->radioBearerConfig->srb_ToAddModList, sizeof(SRB_ToAddModList_t));
+ CU_FREE(rrcReconfigMsg->radioBearerConfig->drb_ToAddModList, sizeof(DRB_ToAddModList_t));
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\n F1AP: memory Alloc failed at fillRrcReconfigIE()");
+ CU_FREE(rrcReconfigMsg->radioBearerConfig->srb_ToAddModList, sizeof(SRB_ToAddModList_t));
+ }
+ }
+
+ return ret;
+}
+/*******************************************************************
+ *
+ * @brief Fills DL DCCH Message required for DLRRCMessageTransfer
+ *
+ * @details
+ *
+ * Function : fillDlDcchRrcMsg
+ *
+ * Functionality: Fills DL DCCH Message required for
+ * DLRRCMessageTransfer
+ *
+ * @params[in] RRCContainer_t *rrcContainer
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillDlDcchRrcMsg(RRCContainer_t *rrcContainer)
+{
+ uint8_t ret = ROK;
+ uint16_t idx2;
+ DL_DCCH_Message_t dl_DCCH_Msg;
+ memset(&dl_DCCH_Msg, 0, sizeof(DL_DCCH_Message_t));
+ asn_enc_rval_t encRetVal;
+
+ if(rrcContainer != NULLP)
+ {
+ dl_DCCH_Msg.message.present = DL_DCCH_MessageType_PR_c1;
+
+ CU_ALLOC(dl_DCCH_Msg.message.choice.c1 , sizeof(DL_DCCH_MessageType_t));
+ if(dl_DCCH_Msg.message.choice.c1 != NULLP)
+ {
+ dl_DCCH_Msg.message.choice.c1->present = DL_DCCH_MessageType__c1_PR_rrcReconfiguration;
+ CU_ALLOC(dl_DCCH_Msg.message.choice.c1->choice.rrcReconfiguration, sizeof(RRCReconfiguration_t));
+ if(dl_DCCH_Msg.message.choice.c1->choice.rrcReconfiguration != NULLP)
+ {
+ dl_DCCH_Msg.message.choice.c1->choice.rrcReconfiguration->rrc_TransactionIdentifier = 0;
+ dl_DCCH_Msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.\
+ present = RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration;
+ /* Fill RRC Reconfig IE */
+ CU_ALLOC(dl_DCCH_Msg.message.choice.c1->choice.rrcReconfiguration->\
+ criticalExtensions.choice.rrcReconfiguration, sizeof(RRCReconfiguration_IEs_t));
+ if(dl_DCCH_Msg.message.choice.c1->choice.rrcReconfiguration->\
+ criticalExtensions.choice.rrcReconfiguration != NULLP)
+ {
+ ret = fillRrcReconfigIE(dl_DCCH_Msg.message.choice.c1->choice.rrcReconfiguration->\
+ criticalExtensions.choice.rrcReconfiguration);
+
+ if(ret == ROK)
+ {
+ /* encode DL-DCCH message into RRC Container */
+ xer_fprint(stdout, &asn_DEF_DL_DCCH_MessageType, &dl_DCCH_Msg);
+ cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_DL_DCCH_MessageType, 0, &dl_DCCH_Msg, PrepFinalEncBuf, encBuf);
+ /* Encode results */
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG( "\n F1AP : Could not encode RRCContainer for DL-DCCH Msg (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ return RFAILED;
+ }
+ else
+ {
+ DU_LOG("\n F1AP : Created APER encoded buffer for RRCContainer for DL-DCCH Msg\n");
+ for(int i = 0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+ rrcContainer->size = encBufSize;
+ CU_ALLOC(rrcContainer->buf, rrcContainer->size);
+ if(rrcContainer->buf != NULLP)
+ {
+ memset(rrcContainer->buf, 0, encBufSize);
+ for(idx2 = 0; idx2 < encBufSize; idx2++)
+ {
+ rrcContainer->buf[idx2] = encBuf[idx2];
+ }
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Failed to fill RrcReconfig IE at fillDlDcchRrcMsg()");
+ }
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Memory Alloc failed for RRC Reconfig at fillDlDcchRrcMsg()");