+ }
+
+
+ ieIdx=0;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present = \
+ UEContextModificationRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =CU_ID;
+
+ ieIdx++;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present=\
+ UEContextModificationRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =DU_ID;
+
+ ieIdx++;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_ToBeSetupMod_List;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
+ ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present =\
+ UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List;
+ ret = BuildDrbToBeSetupModList(&(ueContextModifyReq->protocolIEs.list.array[ieIdx]->\
+ value.choice.DRBs_ToBeSetupMod_List));
+ if(ret != ROK)
+ {
+ break;
+ }
+ xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+ /* Encode the F1SetupRequest type as APER */
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
+ encBuf);
+
+ /* Encode results */
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> F1AP : Could not encode ueContextModifyReq structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> F1AP : Created APER encodedbuffer for ueContextModifyReq\n");
+ for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
+ {
+ DU_LOG("%x",encBuf[ieIdx]);
+ }
+ }
+
+ if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Sending Ue context modification request failed");
+ break;
+ }
+
+ ret = ROK;
+ break;
+
+ }
+ FreeUeContextModicationRequest(f1apMsg);
+ return ROK;
+}
+/*******************************************************************
+ *
+ * @brief Handles received F1AP message and sends back response
+ *
+ * @details
+ *
+ * Function : F1APMsgHdlr
+ *
+ * Functionality:
+ * - Decodes received F1AP control message
+ * - Prepares response message, encodes and sends to SCTP
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void F1APMsgHdlr(Buffer *mBuf)
+{
+ int i;
+ char *recvBuf;
+ MsgLen copyCnt;
+ MsgLen recvBufLen;
+ F1AP_PDU_t *f1apMsg = NULLP;
+ asn_dec_rval_t rval; /* Decoder return value */
+ F1AP_PDU_t f1apasnmsg ;
+
+ DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
+ ODU_PRINT_MSG(mBuf, 0,0);
+
+ /* Copy mBuf into char array to decode it */
+ ODU_GET_MSG_LEN(mBuf, &recvBufLen);
+ CU_ALLOC(recvBuf, (Size)recvBufLen);
+
+ if(recvBuf == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation failed");
+ return;
+ }
+ if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
+ return;
+ }
+
+ DU_LOG("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
+ for(i=0; i< recvBufLen; i++)
+ {
+ DU_LOG("%x",recvBuf[i]);
+ }
+
+ /* Decoding flat buffer into F1AP messsage */
+ f1apMsg = &f1apasnmsg;
+ memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
+
+ rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
+ CU_FREE(recvBuf, (Size)recvBufLen);
+
+ if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+ {
+ DU_LOG("\nERROR --> F1AP : ASN decode failed");
+ return;
+ }
+ DU_LOG("\n");
+ xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+ switch(f1apMsg->present)
+ {
+ case F1AP_PDU_PR_initiatingMessage:
+ {
+ switch(f1apMsg->choice.initiatingMessage->value.present)
+ {
+ case InitiatingMessage__value_PR_Reset:
+ {
+ DU_LOG("\nINFO --> F1AP : F1 reset request received ");
+ BuildAndSendF1ResetAck();
+ break;
+ }
+
+ case InitiatingMessage__value_PR_F1SetupRequest:
+ {
+ DU_LOG("\nINFO --> F1AP : F1 setup request received");
+ BuildAndSendF1SetupRsp();
+ break;
+ }
+
+ case InitiatingMessage__value_PR_GNBDUConfigurationUpdate:
+ {
+ DU_LOG("\nINFO --> F1AP : GNB-DU config update received");
+ BuildAndSendDUUpdateAck();
+ DU_LOG("\nINFO --> F1AP : Sending F1 reset request");
+ BuildAndSendF1ResetReq();
+ break;
+ }
+ case InitiatingMessage__value_PR_InitialULRRCMessageTransfer:
+ {
+ DU_LOG("\nINFO --> F1AP : Received InitialULRRCMessageTransfer");
+ procInitULRRCMsg(f1apMsg);
+ break;
+ }
+ case InitiatingMessage__value_PR_ULRRCMessageTransfer:
+ {
+ DU_LOG("\nINFO --> F1AP : Received ULRRCMessageTransfer");
+ procUlRrcMsg(f1apMsg);
+ break;
+ }
+
+ case InitiatingMessage__value_PR_RRCDeliveryReport:
+ {
+ DU_LOG("\nINFO --> F1AP : Received RRC delivery report");
+ break;
+ }
+ case InitiatingMessage__value_PR_UEContextReleaseRequest:
+ {
+ DU_LOG("\nINFO --> F1AP : Received UE Context Release Request");
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> F1AP : Invalid type of intiating message [%d]",\
+ f1apMsg->choice.initiatingMessage->value.present);
+ return;
+ }
+ }/* End of switch(initiatingMessage) */
+ break;
+ }
+
+ case F1AP_PDU_PR_successfulOutcome:
+ {
+ switch(f1apMsg->choice.successfulOutcome->value.present)
+ {
+ case SuccessfulOutcome__value_PR_ResetAcknowledge:
+ {
+ DU_LOG("\nINFO --> F1Reset Acknowledgement is received successfully ");
+ break;
+ }
+ case SuccessfulOutcome__value_PR_UEContextSetupResponse:
+ {
+ DU_LOG("\nINFO --> F1AP : UE ContextSetupResponse received");
+ f1apMsgDb.dlRrcMsgCount++; /* keeping DL RRC Msg Count */
+ break;
+ }
+ case SuccessfulOutcome__value_PR_UEContextModificationResponse:
+ {
+ DU_LOG("\nINFO --> F1AP : UE Context Modification Response received");
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> F1AP : Invalid type of successful outcome message [%d]",\
+ f1apMsg->choice.successfulOutcome->value.present);
+ return;
+ }
+ }/* End of switch(successfulOutcome) */
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
+ return;
+ }