+/*******************************************************************
+*
+* @brief deallocating the memory of F1reset msg
+*
+* @details
+*
+* Function : FreeF1ResetReq
+*
+* Functionality :
+* - freeing memory of F1reset request msg
+*
+* @params[in]
+* @return void
+*
+*
+* ****************************************************************/
+void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t idx = 0;
+ Reset_t *f1ResetMsg = NULLP;
+
+ if(f1apMsg)
+ {
+ if(f1apMsg->choice.initiatingMessage)
+ {
+ f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
+ if(f1ResetMsg->protocolIEs.list.array)
+ {
+ for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
+ {
+ if(f1ResetMsg->protocolIEs.list.array[idx])
+ {
+ CU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
+ }
+ }
+ CU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
+ }
+ CU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
+ }
+ CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
+ }
+}
+/*******************************************************************
+*
+* @brief build ansld ans send f1reset msg
+*
+* @details
+*
+* Function : BuildAndSendF1ResetReq
+*
+* Functionality: build and send f1reset msg
+*
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t BuildAndSendF1ResetReq()
+{
+ uint8_t elementCnt=0;
+ uint8_t idx=0;
+ uint8_t ret= RFAILED;
+ Reset_t *f1ResetMsg = NULLP;
+ F1AP_PDU_t *f1apMsg = NULLP;
+ asn_enc_rval_t encRetVal;
+ DU_LOG("\nF1AP : Building F1 Reset request \n");
+ do
+ {
+ CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+ if(f1apMsg == NULLP)
+ {
+ DU_LOG("\nF1AP : Memory allocation for the BuildAndSendF1ResetReq's F1AP-PDU failed");
+ break;
+ }
+ f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
+ CU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
+ if(f1apMsg->choice.initiatingMessage == NULLP)
+ {
+ DU_LOG("\nF1AP : Memory allocation for BuildAndSendF1ResetReq failed");
+ break;
+ }
+ f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
+ f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
+ f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
+
+ f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
+
+ elementCnt = 3;
+ f1ResetMsg->protocolIEs.list.count = elementCnt;
+ f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
+
+ /* Initialize the F1Reset members */
+ CU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
+ if(f1ResetMsg->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nF1AP : Memory allocation failed for BuildAndSendF1ResetReq");
+ break;
+ }
+ for(idx=0; idx<elementCnt; idx++)
+ {
+ CU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
+ if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
+ {
+ DU_LOG("\nF1AP : Memory allocation failed for BuildAndSendF1ResetReq msg array");
+ break;
+ }
+ }
+
+ /*TransactionID*/
+ idx=0;
+ f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
+ f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
+
+ /*Cause*/
+ idx++;
+ f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
+ f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
+
+ /*Reset Type*/
+ idx++;
+ f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
+ f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
+
+ xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+ /* Encode the F1SetupRequest type as APER */
+ memset((uint8_t *)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("\nF1AP : Could not encode F1Reset structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nF1AP : Created APER encoded buffer for F1Reset\n");
+ for(idx=0; idx< encBufSize; idx++)
+ {
+ printf("%x",encBuf[idx]);
+ }
+ }
+
+ if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
+ {
+ DU_LOG("\nF1AP : Sending F1 Reset request failed");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeF1ResetReq(f1apMsg);
+ return ret;
+ }