X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcu_stub%2Fcu_f1ap_msg_hdl.c;h=3751ae2341c1a9e6cec8ced50a559468f9a571d8;hb=287632f09119435e0bf1ea16e4e11fc6447c1eee;hp=8ede3eff3612a90fb6cea6541447149e9f43b903;hpb=7268ff58ebfed5c837ed02ae3dbc2970937d6336;p=o-du%2Fl2.git diff --git a/src/cu_stub/cu_f1ap_msg_hdl.c b/src/cu_stub/cu_f1ap_msg_hdl.c index 8ede3eff3..3751ae234 100644 --- a/src/cu_stub/cu_f1ap_msg_hdl.c +++ b/src/cu_stub/cu_f1ap_msg_hdl.c @@ -172,23 +172,22 @@ #define DMRS_ADDITIONAL_POS 0 /* DMRS Additional poistion */ #define RES_ALLOC_TYPE 1 /* Resource allocation type */ #define FIVE_QI_VALUE 9 /*spec 23.501, Table 5.7.4-1*/ - /******************************************************************* -* -* @brief Sends F1 msg over SCTP -* -* @details -* -* Function : SendF1APMsg -* -* Functionality: Sends F1 msg over SCTP -* -* @params[in] Region region -* Pool pool -* @return ROK - success -* RFAILED - failure -* -* ****************************************************************/ + * + * @brief Sends F1 msg over SCTP + * + * @details + * + * Function : SendF1APMsg + * + * Functionality: Sends F1 msg over SCTP + * + * @params[in] Region region + * Pool pool + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ S16 SendF1APMsg(Region region, Pool pool) { Buffer *mBuf = NULLP; @@ -197,20 +196,20 @@ S16 SendF1APMsg(Region region, Pool pool) { if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK) { - ODU_PRINT_MSG(mBuf, 0,0); + ODU_PRINT_MSG(mBuf, 0,0); - if(sctpSend(mBuf) != ROK) - { - DU_LOG("\nERROR --> F1AP : SCTP Send failed"); - ODU_PUT_MSG_BUF(mBuf); - return RFAILED; - } + if(sctpSend(mBuf) != ROK) + { + DU_LOG("\nERROR --> F1AP : SCTP Send failed"); + ODU_PUT_MSG_BUF(mBuf); + return RFAILED; + } } else { - DU_LOG("\nERROR --> F1AP : ODU_ADD_POST_MSG_MULT failed"); - ODU_PUT_MSG_BUF(mBuf); - return RFAILED; + DU_LOG("\nERROR --> F1AP : ODU_ADD_POST_MSG_MULT failed"); + ODU_PUT_MSG_BUF(mBuf); + return RFAILED; } ODU_PUT_MSG_BUF(mBuf); } @@ -298,7 +297,7 @@ S16 BuildAndSendF1SetupRsp() f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_F1Setup; f1apMsg->choice.successfulOutcome->criticality = Criticality_reject; f1apMsg->choice.successfulOutcome->value.present = \ - SuccessfulOutcome__value_PR_F1SetupResponse; + SuccessfulOutcome__value_PR_F1SetupResponse; f1SetupRsp = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse; elementCnt = 4; @@ -306,7 +305,7 @@ S16 BuildAndSendF1SetupRsp() f1SetupRsp->protocolIEs.list.size = elementCnt*sizeof(F1SetupResponseIEs_t *); CU_ALLOC(f1SetupRsp->protocolIEs.list.array, \ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); if(f1SetupRsp->protocolIEs.list.array == NULLP) { DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResponseIEs failed"); @@ -318,15 +317,15 @@ S16 BuildAndSendF1SetupRsp() for(idx=0; idxprotocolIEs.list.array[idx], \ - sizeof(F1SetupResponseIEs_t)); + sizeof(F1SetupResponseIEs_t)); if(f1SetupRsp->protocolIEs.list.array[idx] == NULLP) { - CU_FREE(f1SetupRsp->protocolIEs.list.array,\ - elementCnt * sizeof(F1SetupResponseIEs_t *)); - CU_FREE(f1apMsg->choice.successfulOutcome, \ - sizeof(SuccessfulOutcome_t)); - CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); - return RFAILED; + CU_FREE(f1SetupRsp->protocolIEs.list.array,\ + elementCnt * sizeof(F1SetupResponseIEs_t *)); + CU_FREE(f1apMsg->choice.successfulOutcome, \ + sizeof(SuccessfulOutcome_t)); + CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); + return RFAILED; } } @@ -335,16 +334,16 @@ S16 BuildAndSendF1SetupRsp() f1SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID; f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject; f1SetupRsp->protocolIEs.list.array[idx]->value.present = \ - F1SetupResponseIEs__value_PR_TransactionID; + F1SetupResponseIEs__value_PR_TransactionID; f1SetupRsp->protocolIEs.list.array[idx]->value.choice.TransactionID =\ - TRANS_ID; + TRANS_ID; /*CU Name*/ idx++; f1SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_Name; f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_ignore; f1SetupRsp->protocolIEs.list.array[idx]->value.present = \ - F1SetupResponseIEs__value_PR_GNB_CU_Name; + F1SetupResponseIEs__value_PR_GNB_CU_Name; cuName = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_Name; cuName->size = sizeof(cuCfgParams.cuName); @@ -353,13 +352,13 @@ S16 BuildAndSendF1SetupRsp() { for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx],\ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx],\ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array,\ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome,\ - sizeof(SuccessfulOutcome_t)); + sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; } @@ -368,28 +367,28 @@ S16 BuildAndSendF1SetupRsp() /*Cells to be activated list*/ idx++; f1SetupRsp->protocolIEs.list.array[idx]->id = \ - ProtocolIE_ID_id_Cells_to_be_Activated_List ; + ProtocolIE_ID_id_Cells_to_be_Activated_List ; f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject; f1SetupRsp->protocolIEs.list.array[idx]->value.present = \ - F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List; + F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List; cellToActivate = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.\ - Cells_to_be_Activated_List; + Cells_to_be_Activated_List; cellCnt=1; cellToActivate->list.count = cellCnt; cellToActivate->list.size = \ - cellCnt*sizeof(struct Cells_to_be_Activated_List_ItemIEs *); + cellCnt*sizeof(struct Cells_to_be_Activated_List_ItemIEs *); CU_ALLOC(cellToActivate->list.array,\ - sizeof(struct Cells_to_be_Activated_List_ItemIEs *)); + sizeof(struct Cells_to_be_Activated_List_ItemIEs *)); if(cellToActivate->list.array == NULLP) { CU_FREE(cuName->buf, sizeof(cuName->size)); for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx],\ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx],\ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array,\ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; @@ -399,88 +398,88 @@ S16 BuildAndSendF1SetupRsp() CU_ALLOC(cellToActivate->list.array[ieIdx],sizeof(struct Cells_to_be_Activated_List_ItemIEs )); if(cellToActivate->list.array[ieIdx] == NULLP) { - CU_FREE(cellToActivate->list.array,\ - sizeof(struct Cells_to_be_Activated_List_ItemIEs *)); - CU_FREE(cuName->buf, sizeof(cuName->size)); - for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ - sizeof(F1SetupResponseIEs_t)); - } - CU_FREE(f1SetupRsp->protocolIEs.list.array, \ - elementCnt * sizeof(F1SetupResponseIEs_t *)); - CU_FREE(f1apMsg->choice.successfulOutcome, \ - sizeof(SuccessfulOutcome_t)); - CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); - return RFAILED; + CU_FREE(cellToActivate->list.array,\ + sizeof(struct Cells_to_be_Activated_List_ItemIEs *)); + CU_FREE(cuName->buf, sizeof(cuName->size)); + for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ + sizeof(F1SetupResponseIEs_t)); + } + CU_FREE(f1SetupRsp->protocolIEs.list.array, \ + elementCnt * sizeof(F1SetupResponseIEs_t *)); + CU_FREE(f1apMsg->choice.successfulOutcome, \ + sizeof(SuccessfulOutcome_t)); + CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); + return RFAILED; } } cellToActivate->list.array[0]->id = \ - ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; + ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; cellToActivate->list.array[0]->criticality = Criticality_ignore; cellToActivate->list.array[0]->value.present = \ - Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item; + Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item; cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\ nRCGI.pLMN_Identity.size = 3*sizeof(uint8_t); CU_ALLOC(cellToActivate->list.array[0]->\ - value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\ - 3*sizeof(uint8_t)); + value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\ + 3*sizeof(uint8_t)); if(cellToActivate->list.array[0]->value.choice.\ - Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf == NULLP) + Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf == NULLP) { for(ieIdx=0; ieIdxlist.array[ieIdx],\ - sizeof(struct Cells_to_be_Activated_List_ItemIEs )); + CU_FREE(cellToActivate->list.array[ieIdx],\ + sizeof(struct Cells_to_be_Activated_List_ItemIEs )); } CU_FREE(cellToActivate->list.array,\ - sizeof(struct Cells_to_be_Activated_List_ItemIEs *)); + sizeof(struct Cells_to_be_Activated_List_ItemIEs *)); CU_FREE(cuName->buf, sizeof(cuName->size)); for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx], \ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array, \ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome, \ - sizeof(SuccessfulOutcome_t)); + sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; } buildPlmnId(cuCfgParams.plmn , cellToActivate->list.array[0]->value.choice.\ - Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf); + Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf); cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\ nRCGI.nRCellIdentity.size = 5; CU_ALLOC(cellToActivate->list.array[0]->value.choice.\ - Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf,\ - 5*sizeof(uint8_t)); + Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf,\ + 5*sizeof(uint8_t)); if(cellToActivate->list.array[0]->value.choice.\ - Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf == NULLP) + Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf == NULLP) { CU_FREE(cellToActivate->list.array[0]->\ - value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\ - 3*sizeof(uint8_t)); + value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\ + 3*sizeof(uint8_t)); for(ieIdx=0; ieIdxlist.array[ieIdx],\ - sizeof(struct Cells_to_be_Activated_List_ItemIEs )); + CU_FREE(cellToActivate->list.array[ieIdx],\ + sizeof(struct Cells_to_be_Activated_List_ItemIEs )); } CU_FREE(cellToActivate->list.array,\ - sizeof(struct Cells_to_be_Activated_List_ItemIEs *)); + sizeof(struct Cells_to_be_Activated_List_ItemIEs *)); CU_FREE(cuName->buf, sizeof(cuName->size)); for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx], \ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array, \ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome, \ - sizeof(SuccessfulOutcome_t)); + sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; } @@ -488,10 +487,10 @@ S16 BuildAndSendF1SetupRsp() /* RRC Version */ idx++; f1SetupRsp->protocolIEs.list.array[idx]->id = \ - ProtocolIE_ID_id_GNB_CU_RRC_Version; + ProtocolIE_ID_id_GNB_CU_RRC_Version; f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject; f1SetupRsp->protocolIEs.list.array[idx]->value.present = \ - F1SetupResponseIEs__value_PR_RRC_Version; + F1SetupResponseIEs__value_PR_RRC_Version; rrcVer = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.RRC_Version; rrcVer->latest_RRC_Version.size = RRC_SIZE; @@ -501,11 +500,11 @@ S16 BuildAndSendF1SetupRsp() CU_FREE(cuName->buf, sizeof(cuName->size)); for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx], \ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array,\ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; @@ -521,11 +520,11 @@ S16 BuildAndSendF1SetupRsp() CU_FREE(cuName->buf, sizeof(cuName->size)); for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx], \ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array,\ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; @@ -533,73 +532,73 @@ S16 BuildAndSendF1SetupRsp() rrcVer->iE_Extensions->list.count = 1; rrcVer->iE_Extensions->list.size = sizeof(struct RRC_Version_ExtIEs *); CU_ALLOC(rrcVer->iE_Extensions->list.array,\ - sizeof(struct RRC_Version_ExtIEs *)); + sizeof(struct RRC_Version_ExtIEs *)); if(rrcVer->iE_Extensions->list.array == NULLP) { CU_FREE(rrcVer->iE_Extensions,\ - sizeof(ProtocolExtensionContainer_4624P81_t)); + sizeof(ProtocolExtensionContainer_4624P81_t)); CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(uint8_t)); CU_FREE(cuName->buf, sizeof(cuName->size)); for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx], \ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array,\ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; } CU_ALLOC(rrcVer->iE_Extensions->list.array[0],\ - sizeof(struct RRC_Version_ExtIEs)); + sizeof(struct RRC_Version_ExtIEs)); if(rrcVer->iE_Extensions->list.array[0] == NULLP) { CU_FREE(rrcVer->iE_Extensions->list.array,\ - sizeof(struct RRC_Version_ExtIEs *)); + sizeof(struct RRC_Version_ExtIEs *)); CU_FREE(rrcVer->iE_Extensions,\ - sizeof(ProtocolExtensionContainer_4624P81_t)); + sizeof(ProtocolExtensionContainer_4624P81_t)); CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(uint8_t)); CU_FREE(cuName->buf, sizeof(cuName->size)); for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx], \ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array,\ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; } rrcVer->iE_Extensions->list.array[0]->id = \ - ProtocolIE_ID_id_latest_RRC_Version_Enhanced; + ProtocolIE_ID_id_latest_RRC_Version_Enhanced; rrcVer->iE_Extensions->list.array[0]->criticality = Criticality_reject; rrcVer->iE_Extensions->list.array[0]->extensionValue.present = \ - RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced; + RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced; rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\ Latest_RRC_Version_Enhanced.size = 3*sizeof(uint8_t); CU_ALLOC(rrcVer->iE_Extensions->list.\ - array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf,\ - 3*sizeof(uint8_t)); + array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf,\ + 3*sizeof(uint8_t)); if(rrcVer->iE_Extensions->list.\ - array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf == NULLP) + array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf == NULLP) { CU_FREE(rrcVer->iE_Extensions->list.array[0],\ - sizeof(struct RRC_Version_ExtIEs)); + sizeof(struct RRC_Version_ExtIEs)); CU_FREE(rrcVer->iE_Extensions->list.array,\ - sizeof(struct RRC_Version_ExtIEs *)); + sizeof(struct RRC_Version_ExtIEs *)); CU_FREE(rrcVer->iE_Extensions,\ - sizeof(ProtocolExtensionContainer_4624P81_t)); + sizeof(ProtocolExtensionContainer_4624P81_t)); CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(uint8_t)); CU_FREE(cuName->buf, sizeof(cuName->size)); for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx], \ - sizeof(F1SetupResponseIEs_t)); + CU_FREE(f1SetupRsp->protocolIEs.list.array[ieIdx], \ + sizeof(F1SetupResponseIEs_t)); } CU_FREE(f1SetupRsp->protocolIEs.list.array,\ - elementCnt * sizeof(F1SetupResponseIEs_t *)); + elementCnt * sizeof(F1SetupResponseIEs_t *)); CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t)); CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); return RFAILED; @@ -633,7 +632,7 @@ S16 BuildAndSendF1SetupRsp() if(encRetVal.encoded == ENCODE_FAIL) { DU_LOG("\nERROR --> F1AP : Could not encode F1SetupResponse structure (at %s)\n",\ - encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); return RFAILED; } else @@ -641,7 +640,7 @@ S16 BuildAndSendF1SetupRsp() DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1SetupResponse\n"); for(int i=0; i< encBufSize; i++) { - DU_LOG("%x",encBuf[i]); + DU_LOG("%x",encBuf[i]); } } @@ -666,8 +665,7 @@ S16 BuildAndSendF1SetupRsp() * Functionality: Constructs the DU Update Acknowledge message and sends * it to the DU through SCTP. * - * @params[in] void **buf,Buffer to which encoded pattern is written into - * @params[in] int *size,size of buffer + * @params[in] * * @return ROK - success * RFAILED - failure @@ -726,10 +724,10 @@ S16 BuildAndSendDUUpdateAck() CU_ALLOC(gNBDuCfgAck->protocolIEs.list.array[idx], sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t)); if(gNBDuCfgAck->protocolIEs.list.array[idx] == NULLP) { - CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *)); - CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t)); - CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); - return RFAILED; + CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *)); + CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t)); + CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); + return RFAILED; } } @@ -737,7 +735,8 @@ S16 BuildAndSendDUUpdateAck() idx = 0; gNBDuCfgAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID ; gNBDuCfgAck->protocolIEs.list.array[idx]->criticality = Criticality_reject; - gNBDuCfgAck->protocolIEs.list.array[idx]->value.present = GNBDUConfigurationUpdateAcknowledgeIEs__value_PR_TransactionID; + gNBDuCfgAck->protocolIEs.list.array[idx]->value.present =\ + GNBDUConfigurationUpdateAcknowledgeIEs__value_PR_TransactionID; gNBDuCfgAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID; xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg); @@ -759,7 +758,8 @@ S16 BuildAndSendDUUpdateAck() /* Checking encode results */ if(enRetVal.encoded == ENCODE_FAIL) { - DU_LOG("\nERROR --> F1AP : Could not encode DUConfigUpdateAcknowledge structure (at %s)",enRetVal.failed_type ? enRetVal.failed_type->name : "unknown"); + DU_LOG("\nERROR --> F1AP : Could not encode DUConfigUpdateAcknowledge structure (at %s)",\ + enRetVal.failed_type ? enRetVal.failed_type->name : "unknown"); return RFAILED; } else @@ -767,7 +767,7 @@ S16 BuildAndSendDUUpdateAck() DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuConfigUpdateAcknowledge\n"); for(int i=0; i< encBufSize; i++) { - DU_LOG("%x",encBuf[i]); + DU_LOG("%x",encBuf[i]); } } @@ -1019,18 +1019,18 @@ uint8_t fillSrbCfg(uint8_t srbId, SRB_ToAddModList_t *bearerCfg) * * ****************************************************************/ -uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup) +uint8_t fillMasterCellGroup(uint8_t ueId, OCTET_STRING_t *masterCellGroup) { uint8_t ret = ROK; masterCellGroup->buf = NULLP; - if(f1apMsgDb.duToCuContainer.buf) + if(ueCb[ueId-1].f1apMsgDb.duToCuContainer.buf) { - masterCellGroup->size = f1apMsgDb.duToCuContainer.size; + masterCellGroup->size = ueCb[ueId-1].f1apMsgDb.duToCuContainer.size; CU_ALLOC(masterCellGroup->buf, masterCellGroup->size); if(masterCellGroup->buf != NULLP) { - memcpy(masterCellGroup->buf, f1apMsgDb.duToCuContainer.buf,\ - masterCellGroup->size); + memcpy(masterCellGroup->buf, ueCb[ueId-1].f1apMsgDb.duToCuContainer.buf,\ + masterCellGroup->size); } else { @@ -1061,7 +1061,7 @@ uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup) * * ****************************************************************/ -uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE) +uint8_t fillRRCSetupIE(uint8_t ueId, RRCSetup_IEs_t *rrcSetupIE) { uint8_t ret = ROK; if(rrcSetupIE) @@ -1073,7 +1073,7 @@ uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE) } if(ret == ROK) { - ret = fillMasterCellGroup(&rrcSetupIE->masterCellGroup); + ret = fillMasterCellGroup(ueId, &rrcSetupIE->masterCellGroup); } else { @@ -1101,7 +1101,7 @@ uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE) * * ****************************************************************/ -uint8_t fillDlCcchRrcMsg(RRCContainer_t *rrcContainer) +uint8_t fillDlCcchRrcMsg(uint8_t ueId, RRCContainer_t *rrcContainer) { uint8_t ret = ROK; uint16_t idx2; @@ -1115,71 +1115,71 @@ uint8_t fillDlCcchRrcMsg(RRCContainer_t *rrcContainer) CU_ALLOC(dl_CCCH_Msg.message.choice.c1 , sizeof(DL_CCCH_MessageType_t)); if(dl_CCCH_Msg.message.choice.c1 != NULLP) { - dl_CCCH_Msg.message.choice.c1->present = DL_CCCH_MessageType__c1_PR_rrcSetup; - CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup, sizeof(RRCSetup_t)); - if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup != NULLP) - { - dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier = 0; - dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->criticalExtensions.\ - present = RRCSetup__criticalExtensions_PR_rrcSetup; - /* Fill RRC Setup IE */ - CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ - criticalExtensions.choice.rrcSetup, sizeof(RRCSetup_IEs_t)); - if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ - criticalExtensions.choice.rrcSetup != NULLP) - { - ret = fillRRCSetupIE(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ - criticalExtensions.choice.rrcSetup); + dl_CCCH_Msg.message.choice.c1->present = DL_CCCH_MessageType__c1_PR_rrcSetup; + CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup, sizeof(RRCSetup_t)); + if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup != NULLP) + { + dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier = 0; + dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->criticalExtensions.\ + present = RRCSetup__criticalExtensions_PR_rrcSetup; + /* Fill RRC Setup IE */ + CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ + criticalExtensions.choice.rrcSetup, sizeof(RRCSetup_IEs_t)); + if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ + criticalExtensions.choice.rrcSetup != NULLP) + { + ret = fillRRCSetupIE(ueId, dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ + criticalExtensions.choice.rrcSetup); - if(ret == ROK) - { - /* encode DL-CCCH message into RRC Container */ - xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg); - memset(encBuf, 0, ENC_BUF_MAX_LEN); - encBufSize = 0; - encRetVal = aper_encode(&asn_DEF_DL_CCCH_MessageType, 0, &dl_CCCH_Msg, PrepFinalEncBuf, encBuf); - /* Encode results */ - if(encRetVal.encoded == ENCODE_FAIL) - { - DU_LOG( "\nERROR --> F1AP : Could not encode RRCContainer for DL-CCCH Msg(at %s)\n",\ - encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - return RFAILED; - } - else - { - DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRCContainer for DL-CCCH Msg\n"); - for(int i = 0; i< encBufSize; i++) - { - DU_LOG("%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 - { - ret = RFAILED; - } - } - else - { - DU_LOG("\nERROR --> F1AP: Memory Alloc failed for RRC Setup Msg at fillDlCcchRrcMsg()"); - ret = RFAILED; - } - } - else - { - DU_LOG("\nERROR --> F1AP: Memory Alloc failed for RRC Msg at fillDlCcchRrcMsg()"); - ret = RFAILED; - } + if(ret == ROK) + { + /* encode DL-CCCH message into RRC Container */ + xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg); + memset(encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + encRetVal = aper_encode(&asn_DEF_DL_CCCH_MessageType, 0, &dl_CCCH_Msg, PrepFinalEncBuf, encBuf); + /* Encode results */ + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG( "\nERROR --> F1AP : Could not encode RRCContainer for DL-CCCH Msg(at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + return RFAILED; + } + else + { + DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRCContainer for DL-CCCH Msg\n"); + for(int i = 0; i< encBufSize; i++) + { + DU_LOG("%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 + { + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> F1AP: Memory Alloc failed for RRC Setup Msg at fillDlCcchRrcMsg()"); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> F1AP: Memory Alloc failed for RRC Msg at fillDlCcchRrcMsg()"); + ret = RFAILED; + } } else { @@ -1527,14 +1527,14 @@ uint8_t fillDlDcchRrcMsg(RRCContainer_t *rrcContainer) * * ****************************************************************/ -uint8_t BuildDLRRCContainer(uint8_t rrcMsgType, RRCContainer_t *rrcContainer) +uint8_t BuildDLRRCContainer(uint8_t ueId, uint8_t rrcMsgType, RRCContainer_t *rrcContainer) { uint8_t ret, bufLen; ret =ROK; if(rrcMsgType == RRC_SETUP) { - ret = fillDlCcchRrcMsg(rrcContainer); + ret = fillDlCcchRrcMsg(ueId, rrcContainer); if(ret == RFAILED) DU_LOG("\nERROR --> F1AP: Failed to fill DL-CCCH Msg at RRC SETUP"); } @@ -1598,7 +1598,7 @@ uint8_t BuildDLRRCContainer(uint8_t rrcMsgType, RRCContainer_t *rrcContainer) * RFAILED - failure * * ****************************************************************/ -uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) +uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t ueId, uint8_t srbId, uint8_t rrcMsgType) { uint8_t elementCnt = 0; uint8_t ieId; @@ -1669,8 +1669,8 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ - DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; - dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID; + DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; + dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = ueId; /* GNB DU UE F1AP ID */ idx++; @@ -1678,8 +1678,8 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ - DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; - dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID; + DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; + dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = ueId; /* SRBID */ idx++; @@ -1694,8 +1694,8 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_RRCContainer; dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ - DLRRCMessageTransferIEs__value_PR_RRCContainer; - BuildDLRRCContainer(rrcMsgType, &dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer); + DLRRCMessageTransferIEs__value_PR_RRCContainer; + BuildDLRRCContainer(ueId, rrcMsgType, &dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer); xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg); @@ -1748,10 +1748,10 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) * * ****************************************************************/ -uint8_t setDlRRCMsgType() +uint8_t setDlRRCMsgType(uint8_t ueId) { uint8_t rrcMsgType = 0; - switch(f1apMsgDb.dlRrcMsgCount) + switch(ueCb[ueId -1].f1apMsgDb.dlRrcMsgCount) { case RRC_SETUP: rrcMsgType = RRC_SETUP; @@ -1796,7 +1796,7 @@ uint8_t setDlRRCMsgType() uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg) { - uint8_t idx, rrcMsgType; + uint8_t idx, rrcMsgType, gnbDuUeF1apId; uint8_t ret =ROK; InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP; DU_LOG("\nINFO --> F1AP : filling the required values in DB in procInitULRRCMsg"); @@ -1807,49 +1807,51 @@ uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg) { switch(initULRRCMsg->protocolIEs.list.array[idx]->id) { - case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID: - break; - case ProtocolIE_ID_id_NRCGI: - break; - case ProtocolIE_ID_id_C_RNTI: - break; - case ProtocolIE_ID_id_RRCContainer: - break; - case ProtocolIE_ID_id_DUtoCURRCContainer: - { - if((initULRRCMsg->protocolIEs.list.array[idx]->value.choice\ - .DUtoCURRCContainer.size > 0) && (initULRRCMsg->protocolIEs\ - .list.array[idx]->value.choice.DUtoCURRCContainer.buf != NULLP)) - { - DU_LOG("\nINFO --> Received Du to Cu RRC Container "); - f1apMsgDb.duToCuContainer.size = initULRRCMsg->protocolIEs\ - .list.array[idx]->value.choice.DUtoCURRCContainer.size; - CU_ALLOC(f1apMsgDb.duToCuContainer.buf, \ - f1apMsgDb.duToCuContainer.size); - if(f1apMsgDb.duToCuContainer.buf != NULLP) - { - memcpy(f1apMsgDb.duToCuContainer.buf, initULRRCMsg->protocolIEs\ - .list.array[idx]->value.choice.DUtoCURRCContainer.buf, f1apMsgDb\ - .duToCuContainer.size); - } - } - else - { - DU_LOG("\nERROR --> Failed to receive Du to Cu RRC Container "); - ret = RFAILED; - } - break; - } - default: - DU_LOG("\nERROR --> Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id); - break; + case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID: + gnbDuUeF1apId = initULRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID; + break; + case ProtocolIE_ID_id_NRCGI: + break; + case ProtocolIE_ID_id_C_RNTI: + break; + case ProtocolIE_ID_id_RRCContainer: + break; + case ProtocolIE_ID_id_DUtoCURRCContainer: + { + if((initULRRCMsg->protocolIEs.list.array[idx]->value.choice\ + .DUtoCURRCContainer.size > 0) && (initULRRCMsg->protocolIEs\ + .list.array[idx]->value.choice.DUtoCURRCContainer.buf != NULLP)) + { + DU_LOG("\nINFO --> Received Du to Cu RRC Container "); + ueCb[gnbDuUeF1apId-1].ueId = gnbDuUeF1apId; + ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.size = initULRRCMsg->protocolIEs\ + .list.array[idx]->value.choice.DUtoCURRCContainer.size; + CU_ALLOC(ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.buf, \ + ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.size); + if(ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.buf != NULLP) + { + memcpy(ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.buf, initULRRCMsg->protocolIEs\ + .list.array[idx]->value.choice.DUtoCURRCContainer.buf, ueCb[gnbDuUeF1apId-1].f1apMsgDb\ + .duToCuContainer.size); + } + } + else + { + DU_LOG("\nERROR --> Failed to receive Du to Cu RRC Container "); + ret = RFAILED; + } + break; + } + default: + DU_LOG("\nERROR --> Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id); + break; } } if(ret == ROK) { - f1apMsgDb.dlRrcMsgCount++; - rrcMsgType = setDlRRCMsgType(); - ret = BuildAndSendDLRRCMessageTransfer(SRB0, rrcMsgType); + ueCb[gnbDuUeF1apId-1].f1apMsgDb.dlRrcMsgCount++; + rrcMsgType = setDlRRCMsgType(gnbDuUeF1apId); + ret = BuildAndSendDLRRCMessageTransfer(gnbDuUeF1apId, SRB0, rrcMsgType); } return ret; } @@ -2236,7 +2238,7 @@ uint8_t BuildULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo) ulInfo->list.array[idx]->uLUPTNLInformation.choice.gTPTunnel->\ gTP_TEID.buf[2] = 0; ulInfo->list.array[idx]->uLUPTNLInformation.choice.gTPTunnel->\ - gTP_TEID.buf[3] = 1; + gTP_TEID.buf[3] = cuCfgParams.egtpParams.currTunnelId++; return ROK; }/*End of BuildULTnlInfo*/ @@ -3226,7 +3228,7 @@ uint8_t BuildTCIStatesToAddModList(struct PDSCH_Config__tci_StatesToAddModList * timeDomAlloc->k0 = NULLP; timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A; - timeDomAlloc->startSymbolAndLength = 53; + timeDomAlloc->startSymbolAndLength = 66; return ROK; } @@ -3568,7 +3570,7 @@ uint8_t BuildInitialDlBWP(BWP_DownlinkDedicated_t *dlBwp) } *(timeDomAlloc->k2) = PUSCH_K2; timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A; - timeDomAlloc->startSymbolAndLength = 27; + timeDomAlloc->startSymbolAndLength = 66; return ROK; } @@ -6465,6 +6467,27 @@ uint8_t BuildAndSendUeContextSetupReq(uint8_t cuUeF1apId, uint8_t duUeF1apId, \ return ret; }/* End of BuildAndSendUeContextSetupReq*/ + +uint8_t procUeContextSetupResponse(F1AP_PDU_t *f1apMsg) +{ + uint8_t idx, duUeF1apId; + UEContextSetupResponse_t *ueCtxtSetupRsp; + ueCtxtSetupRsp = &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse; + + for(idx=0; idx < ueCtxtSetupRsp->protocolIEs.list.count; idx++) + { + switch(ueCtxtSetupRsp->protocolIEs.list.array[idx]->id) + { + case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID: + { + duUeF1apId = ueCtxtSetupRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID; + break; + } + } + } + ueCb[duUeF1apId-1].f1apMsgDb.dlRrcMsgCount++; /* keeping DL RRC Msg Count */ +} + /**************************************************************** * @brief Function to process Ul Rrc Msg received from DU * @@ -6530,12 +6553,12 @@ uint8_t procUlRrcMsg(F1AP_PDU_t *f1apMsg) } if(srbId == 1) { - f1apMsgDb.dlRrcMsgCount++; - rrcMsgType = setDlRRCMsgType(); + ueCb[duUeF1apId-1].f1apMsgDb.dlRrcMsgCount++; + rrcMsgType = setDlRRCMsgType(duUeF1apId); if(rrcMsgType == REGISTRATION_ACCEPT) { - DU_LOG("\nINFO --> F1AP: Sending DL RRC MSG for RRC Registration Accept"); - ret = BuildAndSendDLRRCMessageTransfer(srbId, rrcMsgType); + DU_LOG("\nINFO --> F1AP: Sending DL RRC MSG for RRC Registration Accept"); + ret = BuildAndSendDLRRCMessageTransfer(duUeF1apId, srbId, rrcMsgType); } if(rrcMsgType == UE_CONTEXT_SETUP_REQ) { @@ -6545,19 +6568,19 @@ uint8_t procUlRrcMsg(F1AP_PDU_t *f1apMsg) } if(rrcMsgType == SECURITY_MODE_COMPLETE) { - /* To trigger the DL RRC Msg for RRC Reconfig */ - f1apMsgDb.dlRrcMsgCount++; - rrcMsgType = setDlRRCMsgType(); - if(rrcMsgType == RRC_RECONFIG) - { - DU_LOG("\nINFO --> F1AP: Sending DL RRC MSG for RRC Reconfig"); - BuildAndSendDLRRCMessageTransfer(srbId, rrcMsgType); - } + /* To trigger the DL RRC Msg for RRC Reconfig */ + ueCb[duUeF1apId-1].f1apMsgDb.dlRrcMsgCount++; + rrcMsgType = setDlRRCMsgType(duUeF1apId); + if(rrcMsgType == RRC_RECONFIG) + { + DU_LOG("\nINFO --> F1AP: Sending DL RRC MSG for RRC Reconfig"); + BuildAndSendDLRRCMessageTransfer(duUeF1apId, srbId, rrcMsgType); + } } if(rrcMsgType == UE_CONTEXT_MOD_REQ) { DU_LOG("\nINFO --> F1AP: Sending UE Context Modification Request"); - BuildAndSendUeContextModificationReq(); + BuildAndSendUeContextModificationReq(duUeF1apId); } } return ret; @@ -6845,7 +6868,7 @@ uint8_t BuildUlTnlInfoforDrb2(ULUPTNLInformation_ToBeSetup_List_t *ulInfo) ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\ gTP_TEID.buf[2] = 0; ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\ - gTP_TEID.buf[3] = 2; + gTP_TEID.buf[3] = cuCfgParams.egtpParams.currTunnelId++; return ROK; }/*End of BuildULTnlInfo*/ @@ -7239,7 +7262,7 @@ void FreeUeContextModicationRequest(F1AP_PDU_t *f1apMsg) * RFAILED - failure * * ****************************************************************/ -uint8_t BuildAndSendUeContextModificationReq() +uint8_t BuildAndSendUeContextModificationReq(uint8_t ueId) { uint8_t ieIdx = 0; uint8_t elementCnt = 0; @@ -7300,16 +7323,16 @@ uint8_t BuildAndSendUeContextModificationReq() 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; + UEContextModificationRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; + ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = ueId; 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; - + UEContextModificationRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; + ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = ueId; + ieIdx++; ueContextModifyReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_ToBeSetupMod_List; ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject; @@ -7356,6 +7379,314 @@ uint8_t BuildAndSendUeContextModificationReq() } FreeUeContextModicationRequest(f1apMsg); + return ret; +} +/*****************************************************************i +* +* @brief Free memory allocated for UE Context Release Command +* +* @details +* +* Function : FreeUeContextReleaseCommand +* +* Functionality: +* - Free memory allocated for UE Context Release Command +* +* @params[in] F1AP_PDU_t *f1apMsg +* @return void +* +* *************************************************************/ +void FreeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg) +{ + uint8_t ieIdx; + UEContextReleaseCommand_t *ueReleaseCommand = NULLP; + + if(f1apMsg) + { + if(f1apMsg->choice.initiatingMessage) + { + ueReleaseCommand =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand; + if(ueReleaseCommand->protocolIEs.list.array) + { + for(ieIdx=0 ; ieIdxprotocolIEs.list.count; ieIdx++) + { + CU_FREE(ueReleaseCommand->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseCommand_t)); + } + CU_FREE(ueReleaseCommand->protocolIEs.list.array, ueReleaseCommand->protocolIEs.list.size); + } + CU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t)); + } + CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); + } +} +/******************************************************************* + * + * @brief Builds the Ue Context Release Command + * + * @details +* +* Function : BuildAndSendUeContextReleaseCommand +* +* Functionality: Constructs the Ue Context Release Command +* +* @params[in] +* +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t BuildAndSendUeContextReleaseCommand(uint8_t cuUeF1apId, uint8_t duUeF1apId) +{ + bool memAllocFailed = false; + uint8_t ieIdx = 0,elementCnt = 0, ret = RFAILED, bufLen=0; + F1AP_PDU_t *f1apMsg = NULLP; + UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP; + + asn_enc_rval_t encRetVal; + DU_LOG("\nINFO --> F1AP : Building Ue context release command\n"); + + while(true) + { + CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t)); + if(f1apMsg == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseCommand(): Memory allocation for F1AP-PDU"); + break; + } + + f1apMsg->present = F1AP_PDU_PR_initiatingMessage; + + CU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t)); + if(f1apMsg->choice.initiatingMessage == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseCommand(): Memory allocation for F1AP-PDU failed "); + break; + } + f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextRelease; + f1apMsg->choice.initiatingMessage->criticality = Criticality_reject; + f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_UEContextReleaseCommand; + + ueContextReleaseCommand =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand; + + elementCnt = 4; + ueContextReleaseCommand->protocolIEs.list.count = elementCnt; + ueContextReleaseCommand->protocolIEs.list.size = elementCnt*sizeof(UEContextReleaseCommand_t*); + + /* Initialize the UE context modification members */ + CU_ALLOC(ueContextReleaseCommand->protocolIEs.list.array, ueContextReleaseCommand->protocolIEs.list.size); + if(ueContextReleaseCommand->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseCommand():Memory allocation failed"); + break; + } + + for(ieIdx=0 ; ieIdxprotocolIEs.list.array[ieIdx], sizeof(UEContextReleaseCommand_t)); + if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx] == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseCommand(): Memory allocation failed "); + memAllocFailed = true; + break; + } + } + + if(memAllocFailed == true) + { + break; + } + ieIdx=0; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.present = \ + UEContextReleaseCommandIEs__value_PR_GNB_CU_UE_F1AP_ID; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =cuUeF1apId; + + ieIdx++; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.present=\ + UEContextReleaseCommandIEs__value_PR_GNB_DU_UE_F1AP_ID; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =duUeF1apId; + + ieIdx++; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_Cause; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.present=\ + UEContextReleaseCommandIEs__value_PR_Cause; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.Cause.present = Cause_PR_radioNetwork; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.Cause.choice.radioNetwork=\ + CauseRadioNetwork_normal_release; + + /* RRC Container for RRC release */ + ieIdx++; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_RRCContainer; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.present = \ + UEContextReleaseCommandIEs__value_PR_RRCContainer; + char secModeBuf[7]={ 0x00, 0x05, 0x13, 0x00, 0x00, 0x00, 0x00}; + bufLen =7; + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = bufLen; + CU_ALLOC(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, + ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size); + if(!ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf) + { + DU_LOG("\nERROR --> F1AP : Memory allocation for BuildAndSendUeContextSetupReq failed"); + break; + } + memset(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, 0, bufLen); + memcpy(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, secModeBuf, bufLen); + + xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg); + + /* Encode the UE Context Release Command 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 Release Command structure (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Ue Context Release Command\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 Release Command failed"); + break; + } + + ret = ROK; + break; + + } + FreeUeContextReleaseCommand(f1apMsg); + return ret; +} +/******************************************************************* +* +* @brief process Ue context release request +* +* @details +* +* Function : procUeContextReleaseReq +* +* Functionality: +* - process Ue context release request +* +* @params[in] F1AP_PDU_t *f1apMsg +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t procUeContextReleaseReq(F1AP_PDU_t *f1apMsg) +{ + uint8_t ieIdx=0, duUeF1apId=0,cuUeF1apId=0; + + UEContextReleaseRequest_t *ueReleaseReq = NULLP; + ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest; + + for(ieIdx=0; ieIdx < ueReleaseReq->protocolIEs.list.count; ieIdx++) + { + switch(ueReleaseReq->protocolIEs.list.array[ieIdx]->id) + { + case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID: + { + cuUeF1apId = ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID; + break; + } + case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID: + { + duUeF1apId = ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID; + break; + } + default: + break; + } + } + if(BuildAndSendUeContextReleaseCommand(cuUeF1apId, duUeF1apId) != ROK) + { + DU_LOG("\nERROR --> F1AP : procUeContextReleaseReq(): Failed to build Ue Context Release Command "); + return RFAILED; + } + return ROK; +} +/******************************************************************* +* +* @brief processing of Gnb-DU config update +* +* @details +* +* Function : procGnbDuUpdate +* +* Functionality: +* - processing of Gnb-DU config update +* +* @params[in] F1AP_PDU_t *f1apMsg +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t procGnbDuUpdate(F1AP_PDU_t *f1apMsg) +{ + bool cellToBeDelete = false; + uint8_t ieIdx = 0, ueIdx = 0; + GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP; + + duCfgUpdate = &f1apMsg->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate; + + for(ieIdx=0; ieIdx < duCfgUpdate->protocolIEs.list.count; ieIdx++) + { + switch(duCfgUpdate->protocolIEs.list.array[ieIdx]->id) + { + case ProtocolIE_ID_id_TransactionID: + break; + case ProtocolIE_ID_id_Served_Cells_To_Modify_List: + break; + case ProtocolIE_ID_id_Served_Cells_To_Delete_List: + { + cellToBeDelete = true; + break; + } + case ProtocolIE_ID_id_gNB_DU_ID: + break; + } + } + if(BuildAndSendDUUpdateAck() != ROK) + { + DU_LOG("ERROR --> F1AP : Failed to build and send DUUpdateAck"); + return RFAILED; + } + + if(cellToBeDelete == false) + { + DU_LOG("\nINFO --> F1AP : Sending F1 reset request"); + if(BuildAndSendF1ResetReq() != ROK) + { + DU_LOG("ERROR --> F1AP : Failed to build and send F1 reset request"); + return RFAILED; + } + } + else + { + for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++) + { + CU_FREE(ueCb[ueIdx].f1apMsgDb.duToCuContainer.buf, ueCb[ueIdx].f1apMsgDb.duToCuContainer.size); + memset(&ueCb[ueIdx], 0, sizeof(UeCb)); + } + } + return ROK; } /******************************************************************* @@ -7427,93 +7758,102 @@ void F1APMsgHdlr(Buffer *mBuf) 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; - } - default: - { - DU_LOG("\nERROR --> F1AP : Invalid type of intiating message [%d]",\ - f1apMsg->choice.initiatingMessage->value.present); - return; - } - }/* End of switch(initiatingMessage) */ - break; - } + { + 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"); + procGnbDuUpdate(f1apMsg); + 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"); + procUeContextReleaseReq(f1apMsg); + 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; - } + { + 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"); + procUeContextSetupResponse(f1apMsg); + break; + } + case SuccessfulOutcome__value_PR_UEContextModificationResponse: + { + DU_LOG("\nINFO --> F1AP : UE Context Modification Response received"); + break; + } + case SuccessfulOutcome__value_PR_UEContextReleaseComplete: + { + DU_LOG("\nINFO --> F1AP : UE Context release complete 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; - } + { + DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present); + return; + } }/* End of switch(f1apMsg->present) */ } /* End of F1APMsgHdlr */