duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.formatType = REPORT_ACTION_FORMAT_TYPE;
memcpy(duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.name, ric_report_style_name, sizeof(ric_report_style_name));
- for(measurementInfoIdx =0; measurementInfoIdx<NUM_OF_MEASUREMENT_INFO_SUPPORTED; measurementInfoIdx++)
+ for(measurementInfoIdx =0; measurementInfoIdx<NUM_OF_MEASUREMENT_INFO_SUPPORTED(CONFIG_ADD); measurementInfoIdx++)
{
measurementInfoLen= strlen(MEASUREMENT_TYPE_NAME[measurementInfoIdx]);
MeasurementInfoForAction *measurementInfoForAction;
duCb.e2apDb.ranFunction[ranFuncIdx].ricIndicationHeaderFormat = RIC_INDICATION_HEADER_FORMAT;
duCb.e2apDb.ranFunction[ranFuncIdx].ricIndicationMessageFormat = RIC_INDICATION_MESSAGE_FORMAT;
}
- memset(duCb.e2apDb.e2TransInfo.onGoingTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
+ memset(duCb.e2apDb.e2TransInfo.e2InitTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
+ memset(duCb.e2apDb.e2TransInfo.ricInitTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
/* Mib Params */
mib.sysFrmNum = SYS_FRAME_NUM;
#define DRX_SLOT_OFFSET 0
#endif
+/* In case of initial configuration we are supporting only 2 measurement
+ * information RRU.PrbTotDl and RRU.PrbTotUl.
+ * In case of configuration modification we are supporting 3 measurement
+ * information RRU.PrbTotDl, RRU.PrbTotUl and UECNTX.RelReq */
+#define NUM_OF_MEASUREMENT_INFO_SUPPORTED(_configType) \
+ ((_configType == CONFIG_ADD) ? 2 :3)
+
typedef enum
{
GNBDU,
#define REPORT_STYLE_NAME "E2 Node Measurement"
#define REPORT_STYLE_TYPE 1
#define REPORT_ACTION_FORMAT_TYPE 1
-#define NUM_OF_MEASUREMENT_INFO_SUPPORTED 2
#define MEASUREMENT_TYPE_NAME (char*[]) {"RRU.PrbTotDl", "RRU.PrbTotUl"}
#define RIC_INDICATION_HEADER_FORMAT 1
#define RIC_INDICATION_MESSAGE_FORMAT 1
typedef struct e2Transcation
{
- uint8_t transIdCounter;
- E2TransInfo onGoingTransaction[MAX_NUM_TRANSACTION];
- /* Any new parameter for transaction handling can be added here in future */
+ uint8_t transIdCounter; /* counting the total number of DU initiated transaction */
+ E2TransInfo e2InitTransaction[MAX_NUM_TRANSACTION]; /* Storing DU-initiated transactions information */
+ E2TransInfo ricInitTransaction[MAX_NUM_TRANSACTION]; /* Storing RIC-initiated transactions information */
}E2Transaction;
typedef struct e2Timer
E2TimersInfo e2TimersInfo;
}E2apDb;
+typedef struct
+{
+ uint16_t id;
+ uint16_t revisionCounter;
+}RanFuncInfo;
+
+typedef struct
+{
+ uint8_t addCount;
+ uint8_t addArr[MAX_RAN_FUNCTION];
+ uint8_t modCount;
+ uint8_t modArr[MAX_RAN_FUNCTION];
+ uint8_t delCount;
+ RanFuncInfo delArr[MAX_RAN_FUNCTION];
+}E2TmpRanFunList;
+
uint8_t assignTransactionId();
uint8_t ResetE2Request(E2ProcedureDirection dir, E2CauseType type, E2Cause cause);
uint8_t SendE2APMsg(Region region, Pool pool, char *encBuf, int encBufSize);
/*******************************************************************
*
- * @brief Builds Ran function add list
+ * @brief Builds Ran function item
*
* @details
*
- * Function : BuildRanFunctionAddList
+ * Function : BuildRanFunctionItem
*
- * Functionality: Building RAN addition addition list
+ * Functionality: Building RAN function item
*
- * @params[in] RANfunctions_List_t *RANfunctions_List
+ * @params[in]
+ * RAN function item that has to be filled
+ * Stored RAN Function information
* @return ROK - success
* RFAILED - failure
*
******************************************************************/
-uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList)
+uint8_t BuildRanFunctionItem(RANfunction_Item_t *ranFuncItem, RanFunction *ranFuncDb)
{
- asn_enc_rval_t encRetVal;
- RanFunction *ranFuncDb;
+ uint8_t ret =RFAILED;
+ RANfunctionDefinition_t *ranFunctionDefinition;
RANfunction_Name_t *ranFuncName;
- uint8_t ranFuncIdx;
- RANfunction_ItemIEs_t *ranFuncItemIe;
- RANfunction_Item_t *ranFuncItem;
+ asn_enc_rval_t encRetVal;
E2SM_KPM_RANfunction_Description_t *ranFuncDefinition;
-
- ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction;
- ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*);
- DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size);
- if(ranFunctionsList->list.array == NULLP)
- {
- DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
- return RFAILED;
- }
-
- for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++)
+
+ while(true)
{
- DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
- if(ranFunctionsList->list.array[ranFuncIdx] == NULLP)
- {
- DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
- return RFAILED;
- }
-
- ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx];
- ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item;
- ranFuncItemIe->criticality = CriticalityE2_ignore;
- ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
- ranFuncItem = &ranFuncItemIe->value.choice.RANfunction_Item;
- ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx];
/* RAN function Id*/
ranFuncItem->ranFunctionID = ranFuncDb->id;
-
+
/* RAN Function Revision*/
ranFuncItem->ranFunctionRevision = ranFuncDb->revisionCounter;
-
+
/* RAN function OID*/
ranFuncItem->ranFunctionOID.size = strlen(ranFuncDb->name.serviceModelOID);
DU_ALLOC(ranFuncItem->ranFunctionOID.buf, ranFuncItem->ranFunctionOID.size);
if(!ranFuncItem->ranFunctionOID.buf)
{
DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
- return RFAILED;
+ break;
}
memcpy(ranFuncItem->ranFunctionOID.buf, ranFuncDb->name.serviceModelOID, ranFuncItem->ranFunctionOID.size);
if(!ranFuncDefinition)
{
DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
- return RFAILED;
+ break;
}
-
+
/* RAN function Name */
ranFuncName = &ranFuncDefinition->ranFunction_Name;
-
+
/* RAN function ShortName */
ranFuncName->ranFunction_ShortName.size = strlen(ranFuncDb->name.shortName);
DU_ALLOC(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size);
if(!ranFuncName->ranFunction_ShortName.buf)
{
DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
- return RFAILED;
+ break;
}
memcpy(ranFuncName->ranFunction_ShortName.buf, ranFuncDb->name.shortName, strlen(ranFuncDb->name.shortName));
-
+
/* RAN function E2SM_OID */
ranFuncName->ranFunction_E2SM_OID.size = strlen(ranFuncDb->name.serviceModelOID);
DU_ALLOC(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size);
if(!ranFuncName->ranFunction_E2SM_OID.buf)
{
DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
- return RFAILED;
+ break;
}
memcpy(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncDb->name.serviceModelOID, ranFuncName->ranFunction_E2SM_OID.size);
- /* RAN function Description */
+ /* RAN Function Name Description */
ranFuncName->ranFunction_Description.size = strlen(ranFuncDb->name.description);
DU_ALLOC(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size);
if(!ranFuncName->ranFunction_Description.buf)
{
DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
- return RFAILED;
+ break;
}
memcpy(ranFuncName->ranFunction_Description.buf, ranFuncDb->name.description, ranFuncName->ranFunction_Description.size);
-
+
/* RIC Event Trigger Style List */
DU_ALLOC(ranFuncDefinition->ric_EventTriggerStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List));
if(!ranFuncDefinition->ric_EventTriggerStyle_List)
{
DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
- return RFAILED;
+ break;
}
-
+
if(fillRicEventTriggerStyle(ranFuncDb, ranFuncDefinition->ric_EventTriggerStyle_List)!=ROK)
{
DU_LOG("\nERROR --> E2AP: failed to fill ric event trigger style");
- return RFAILED;
+ break;
}
/* RIC Report Style List */
if(!ranFuncDefinition->ric_ReportStyle_List)
{
DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
- return RFAILED;
+ break;
}
if(fillRicReportStyle(ranFuncDb, ranFuncDefinition->ric_ReportStyle_List) != ROK)
{
DU_LOG("\nERROR --> E2AP: failed to fill ric report style");
- return RFAILED;
+ break;
}
/* Encode the F1SetupRequest type as APER */
{
printf("%x",encBuf[measIeIdx]);
}
-
+ ranFunctionDefinition = &ranFuncItem->ranFunctionDefinition;
+ ranFunctionDefinition->size = encBufSize;
+ DU_ALLOC(ranFunctionDefinition->buf, encBufSize);
+ if(ranFunctionDefinition->buf == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation failed for RAN function definition buffer");
+ break;
+ }
+ memcpy(ranFunctionDefinition->buf, &encBuf, encBufSize);
+ ret = ROK;
+ break;
}
- ranFuncItem->ranFunctionDefinition.size = encBufSize;
- DU_ALLOC(ranFuncItem->ranFunctionDefinition.buf, encBufSize);
- if(ranFuncItem->ranFunctionDefinition.buf == NULLP)
+ }
+ freeE2smKpmRanFunctionDefinition(ranFuncDefinition);
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds Ran function add list based on the procedure code
+ *
+ * @details
+ *
+ * Function : BuildRanFunctionAddList
+ *
+ * Functionality: Building RAN addition addition list
+ * In case of ProcedureCodeE2_id_E2setup we add all the RAN Function list
+ * which is present in E2 database.
+ * In the case of other procedures, we just fill the RAN functions whose ID
+ * is contained in recvList
+ *
+ * @params[in]
+ * RAN Function list
+ * Procedure code
+ * Count of ran functions to be added in the list
+ * Received list of RAN functions
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
+
+uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList, uint8_t procedureCode, uint8_t count, uint8_t *recvList)
+{
+ uint16_t id;
+ RanFunction *ranFuncDb;
+ uint8_t ranFuncIdx;
+ RANfunction_ItemIEs_t *ranFuncItemIe;
+
+ /* For ProcedureCodeE2_id_E2setup, the number of RAN function list items is
+ * equal to the number of ran function entries stored in the database.
+ * For any other procedure, the RAN function list count is equal
+ * to the count of ran functions obtained from the function's caller */
+
+ if(procedureCode == ProcedureCodeE2_id_E2setup)
+ ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction;
+ else
+ ranFunctionsList->list.count = count;
+
+ ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*);
+ DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size);
+ if(ranFunctionsList->list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
+ return RFAILED;
+ }
+
+ for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++)
+ {
+ DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
+ if(ranFunctionsList->list.array[ranFuncIdx] == NULLP)
{
- DU_LOG("\nERROR --> F1AP : Memory allocation failed for RAN function definition buffer");
+ DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
return RFAILED;
}
- memcpy(ranFuncItem->ranFunctionDefinition.buf, &encBuf, encBufSize);
+ if(procedureCode == ProcedureCodeE2_id_E2setup)
+ {
+ /* Getting all of the RAN function's information from DuCb one by one*/
+ ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx];
+ }
+ else
+ {
+ /* Getting only the RAN function information from DuCb whose Id is
+ * present in the received array */
+ id =recvList[ranFuncIdx];
+ ranFuncDb = &duCb.e2apDb.ranFunction[id-1];
+ }
+ ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx];
+ ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item;
+ ranFuncItemIe->criticality = CriticalityE2_ignore;
+ ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
+ BuildRanFunctionItem(&ranFuncItemIe->value.choice.RANfunction_Item, ranFuncDb);
}
- freeE2smKpmRanFunctionDefinition(ranFuncDefinition);
return ROK;
-}
+}
/*******************************************************************
*
e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAdded;
e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_RANfunctions_List;
- if(BuildRanFunctionAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List))!=ROK)
+ if(BuildRanFunctionAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List), ProcedureCodeE2_id_E2setup, 0, NULL)!=ROK)
{
DU_LOG("\nERROR --> E2AP : Failed to create RAN Function");
break;
break;
}while(true);
- duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId;
- duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
+ duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
+ duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
FreeE2SetupReq(e2apMsg);
return ret;
case ProtocolIE_IDE2_id_TransactionID:
{
transId = e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
- if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\
- (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
- memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
+ if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
+ (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
+ {
+ memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+ }
else
{
DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
/* In case the message is sent successfully, store the transaction info to
* be used when response is received */
- duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId;
- duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
+ duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
+ duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
ret = ROK;
break;
{
case ProtocolIE_IDE2_id_TransactionID:
transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
- if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) && \
- (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
- memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
+ if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) && \
+ (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
+ {
+ memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+ }
else
{
DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
case ProtocolIE_IDE2_id_TransactionID:
{
transId = e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
- if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\
- (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
- memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
+ if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
+ (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
+ {
+ memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+ }
else
{
DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
case ProtocolIE_IDE2_id_TimeToWaitE2:
{
timerValue = covertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2);
- if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR)) == FALSE)
+ if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR)) == FALSE)
{
- duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR, timerValue);
+ duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR, timerValue);
}
else
{
{
case EVENT_E2_SETUP_TMR:
{
- if(((E2apDb *)cb)->e2TimersInfo.e2Timers.e2SetupTimer.tmrEvnt == EVENT_E2_SETUP_TMR)
+ if(((CmTimer *)cb)->tmrEvnt == EVENT_E2_SETUP_TMR)
{
DU_LOG("\nERROR --> DU_APP : duChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
return TRUE;
void duStartTmr(PTR cb, int16_t tmrEvnt, uint8_t timerValue)
{
- E2apDb *e2apDb;
CmTmrArg arg;
arg.wait = 0;
{
case EVENT_E2_SETUP_TMR:
{
- e2apDb = ((E2apDb *)cb);
+ CmTimer *e2SetupTimer;
+ e2SetupTimer = ((CmTimer *)cb);
TMR_CALCUATE_WAIT(arg.wait, timerValue, duCb.duTimersInfo.tmrRes);
- arg.timers = &e2apDb->e2TimersInfo.e2Timers.e2SetupTimer;
+ arg.timers = e2SetupTimer;
arg.max = MAX_E2_SETUP_TMR;
break;
}
#include "RIC-ReportStyle-Item.h"
#include "MeasurementInfo-Action-Item.h"
+/*******************************************************************
+ *
+ * @brief Assigns new transaction id to RIC initiated procedure
+ *
+ * @details
+ *
+ * Function : assignTransactionId
+ *
+ * Functionality: Assigns new transaction id to a RIC initiated
+ * procedure
+ *
+ * @params[in] Region region
+ * Pool pool
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t assignTransactionId(DuDb *duDb)
+{
+ uint8_t currTransId = duDb->ricTransIdCounter;
+
+ /* Update to next valid value */
+ duDb->ricTransIdCounter++;
+ if(duDb->ricTransIdCounter == MAX_NUM_TRANSACTION)
+ duDb->ricTransIdCounter = 0;
+
+ return currTransId;
+}
/*******************************************************************
*
{
for(ranFuncIdx=0;ranFuncIdx<ranFuncAddedList->list.count; ranFuncIdx++)
{
- if(ranFuncAddedList->list.array[arrIdx])
+ if(ranFuncAddedList->list.array[ranFuncIdx])
{
- RIC_FREE(ranFuncAddedList->list.array[arrIdx], sizeof(RANfunction_ItemIEs_t));
+ RIC_FREE(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
}
}
RIC_FREE(ranFuncAddedList->list.array, ranFuncAddedList->list.size);
* Function : BuildRanFunctionAddedList
*
* Functionality: Build RAN function added list
- *
- * @params[in] DuDb *duDb, RANfunctionsID_List_t *ranFuncAddedList
+ * ->For ProcedureCodeE2_id_E2setup or ProcedureCodeE2_id_RICserviceQuery
+ * we add all the RAN Function list which is present in RIC database.
+ * ->For any other procedures, we just fill the RAN functions whose ID
+ * is present in the recvList
+ *
+ * @params[in]
+ * Stored DU databse
+ * Count of ran functions to be added in the list
+ * Received list of RAN functions
+ * RAN Function list
+ * Procedure Code
*
* @return ROK - success
* RFAILED - failure
* ****************************************************************/
-uint8_t BuildRanFunctionAddedList(DuDb *duDb, RANfunctionsID_List_t *ranFuncAddedList)
+uint8_t BuildRanFunctionAddedList(DuDb *duDb, uint8_t count, RanFunction *ranFunToBeAdded, RANfunctionsID_List_t *ranFuncAddedList, uint8_t procedureCode)
{
uint8_t ranFuncIdx = 0;
RANfunctionID_ItemIEs_t *ranFuncAddedItemIe;
-
- ranFuncAddedList->list.count = duDb->numOfRanFunction;
+
+ /* For ProcedureCodeE2_id_E2setup and ProcedureCodeE2_id_RICserviceQuery,
+ * the number of RAN function list items is equal to the number of
+ * ran function entries stored in the database.
+ * For any other procedure, the RAN function list count is equal
+ * to the count of ran functions obtained from the function's caller */
+
+ if((procedureCode == ProcedureCodeE2_id_RICserviceQuery)||(procedureCode == ProcedureCodeE2_id_E2setup))
+ ranFuncAddedList->list.count = duDb->numOfRanFunction;
+ else
+ ranFuncAddedList->list.count = count;
+
ranFuncAddedList->list.size = ranFuncAddedList->list.count*sizeof(RANfunctionID_ItemIEs_t*);
RIC_ALLOC(ranFuncAddedList->list.array, ranFuncAddedList->list.size);
if(ranFuncAddedList->list.array)
ranFuncAddedItemIe->id = ProtocolIE_IDE2_id_RANfunctionID_Item;
ranFuncAddedItemIe->criticality= CriticalityE2_ignore;
ranFuncAddedItemIe->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
- ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID =duDb->ranFunction[ranFuncIdx].id;
- ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision=duDb->ranFunction[ranFuncIdx].revisionCounter;
+ if((procedureCode == ProcedureCodeE2_id_RICserviceQuery)||(procedureCode == ProcedureCodeE2_id_E2setup))
+ {
+ /* filling the RAN function information with the help of DuDb */
+ ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = duDb->ranFunction[ranFuncIdx].id;
+ ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= duDb->ranFunction[ranFuncIdx].revisionCounter;
+ }
+ else
+ {
+ /* filling the the RAN function information with the help received list of RAN functions */
+ ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = ranFunToBeAdded[ranFuncIdx].id;
+ ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= ranFunToBeAdded[ranFuncIdx].revisionCounter;
+ }
}
}
else
* RFAILED - failure
*
* ****************************************************************/
+
uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId)
{
E2AP_PDU_t *e2apMsg = NULL;
SuccessfulOutcomeE2__value_PR_E2setupResponse;
e2SetupRsp = &e2apMsg->choice.successfulOutcome->value.choice.E2setupResponse;
- elementCnt = 4;
+ elementCnt = 3;
+ /* Fill Accepted RAN function IE If Ran function information is stored in databse */
+ if(duDb->numOfRanFunction)
+ elementCnt++;
+
e2SetupRsp->protocolIEs.list.count = elementCnt;
e2SetupRsp->protocolIEs.list.size = elementCnt * sizeof(E2setupResponseIEs_t*);
break;
}
- /* Accepted RAN function Id */
- idx++;
- e2SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted;
- e2SetupRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
- e2SetupRsp->protocolIEs.list.array[idx]->value.present = E2setupResponseIEs__value_PR_RANfunctionsID_List;
- if(BuildRanFunctionAddedList(duDb, &e2SetupRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionsID_List)!=ROK)
+ if(duDb->numOfRanFunction)
{
- DU_LOG("\nERROR --> E2AP : Failed to build Ran function added list");
- break;
+ /* Accepted RAN function Id */
+ idx++;
+ e2SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted;
+ e2SetupRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
+ e2SetupRsp->protocolIEs.list.array[idx]->value.present = E2setupResponseIEs__value_PR_RANfunctionsID_List;
+ if(BuildRanFunctionAddedList(duDb, 0, NULL, &e2SetupRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_E2setup)!=ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build Ran function added list");
+ break;
+ }
}
/* E2 Node Component Configuration Addition Acknowledge List*/
{
*duId =e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.GlobalE2node_ID.choice.gNB->gNB_DU_ID->buf[0];
- SEARCH_DU_DB(duIdx, duId, duDb);
+ SEARCH_DU_DB(duIdx, *duId, duDb);
if(duDb == NULLP)
{
duDb = &ricCb.duInfo[ricCb.numDu];
}
case ProtocolIE_IDE2_id_RANfunctionsAdded:
{
+
ranFunctionsList = &e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List;
if(ranFunctionsList->list.array)
{
ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx];
ranFunItem = &ranFuncItemIe->value.choice.RANfunction_Item;
- duDb->ranFunction[duDb->numOfRanFunction].id = ranFunItem->ranFunctionID;
- duDb->ranFunction[ duDb->numOfRanFunction].revisionCounter = ranFunItem->ranFunctionRevision;
+ duDb->ranFunction[ranFunItem->ranFunctionID-1].id = ranFunItem->ranFunctionID;
+ duDb->ranFunction[ranFunItem->ranFunctionID-1].revisionCounter = ranFunItem->ranFunctionRevision;
duDb->numOfRanFunction++;
}
}
}
}
}
+
if(BuildAndSendE2SetupRsp(duDb, transId) !=ROK)
{
DU_LOG("\nERROR --> E2AP : Failed to build and send E2 setup response");
return ROK;
}
+/*******************************************************************
+ *
+ * @brief deallocate the memory allocated in building the
+ * Service Query message
+ *
+ * @details
+ *
+ * Function : FreeRicServiceQuery
+ *
+ * Functionality: deallocate the memory allocated in building
+ * Ric Service Query message
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ *
+ * @return void
+ * ****************************************************************/
+
+void FreeRicServiceQuery(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t arrIdx = 0, ranFuncIdx=0;
+ RANfunctionsID_List_t *ranFuncAddedList;
+ RICserviceQuery_t *ricServiceQuery;
+
+ if(e2apMsg)
+ {
+ if(e2apMsg->choice.initiatingMessage)
+ {
+ ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery;
+ if(ricServiceQuery->protocolIEs.list.array)
+ {
+ for(arrIdx=0; arrIdx<ricServiceQuery->protocolIEs.list.count; arrIdx++)
+ {
+ if(ricServiceQuery->protocolIEs.list.array[arrIdx])
+ {
+ switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_RANfunctionsAccepted:
+ {
+ ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List;
+ if(ranFuncAddedList->list.array)
+ {
+ for(ranFuncIdx=0;ranFuncIdx<ranFuncAddedList->list.count; ranFuncIdx++)
+ {
+ RIC_FREE(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
+ }
+ RIC_FREE(ranFuncAddedList->list.array, ranFuncAddedList->list.size);
+ }
+ break;
+ }
+ case RICserviceQuery_IEs__value_PR_TransactionID:
+ {
+ break;
+ }
+ }
+ RIC_FREE(ricServiceQuery->protocolIEs.list.array[arrIdx], sizeof(RICserviceQuery_IEs_t));
+ }
+ }
+ RIC_FREE(ricServiceQuery->protocolIEs.list.array, ricServiceQuery->protocolIEs.list.size);
+ }
+ RIC_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
+ }
+ RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief build and send the ric service Query
+ *
+ * @details
+ *
+ * Function : BuildAndSendRicServiceQuery
+ *
+ * Functionality: build and send the ric service Query
+ * @return ROK - success
+ * RFAILED - Acknowledge
+ *
+ ******************************************************************/
+
+uint8_t BuildAndSendRicServiceQuery(DuDb *duDb)
+{
+ uint8_t arrIdx;
+ uint8_t elementCnt;
+ uint8_t ret = RFAILED;
+ bool memAllocFailed = false;
+ E2AP_PDU_t *e2apMsg = NULL;
+ asn_enc_rval_t encRetVal;
+ RICserviceQuery_t *ricServiceQuery;
+
+ DU_LOG("\nINFO --> E2AP : Building Ric service Query\n");
+ while(true)
+ {
+ RIC_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
+ break;
+ }
+ e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
+ RIC_ALLOC(e2apMsg->choice.initiatingMessage , sizeof(struct InitiatingMessageE2));
+ if(e2apMsg->choice.initiatingMessage == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed");
+ break;
+ }
+
+ e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICserviceQuery;
+ e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
+ e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICserviceQuery;
+ ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery;
+
+ elementCnt = 1;
+ /* Fill Accepted RAN function IE If Ran function information is stored in databse */
+ if(duDb->numOfRanFunction)
+ elementCnt++;
+
+ ricServiceQuery->protocolIEs.list.count = elementCnt;
+ ricServiceQuery->protocolIEs.list.size = elementCnt * sizeof(RICserviceQuery_IEs_t*);
+
+ RIC_ALLOC(ricServiceQuery->protocolIEs.list.array, ricServiceQuery->protocolIEs.list.size);
+ if(ricServiceQuery->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceQueryIEs failed");
+ break;
+ }
+
+ for(arrIdx=0; arrIdx<elementCnt; arrIdx++)
+ {
+ RIC_ALLOC(ricServiceQuery->protocolIEs.list.array[arrIdx], sizeof(RICserviceQuery_IEs_t));
+ if(ricServiceQuery->protocolIEs.list.array[arrIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceQueryIEs failed");
+ memAllocFailed = true;
+ break;
+ }
+ }
+ if(memAllocFailed == true)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceQueryIEs failed");
+ break;
+ }
+
+ /* Trans Id */
+ arrIdx = 0;
+ ricServiceQuery->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ ricServiceQuery->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
+ ricServiceQuery->protocolIEs.list.array[arrIdx]->value.present = RICserviceQuery_IEs__value_PR_TransactionID;
+ ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = assignTransactionId(duDb);
+
+ if(duDb->numOfRanFunction)
+ {
+ /* Accepted RAN function Id */
+ arrIdx++;
+ ricServiceQuery->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted;
+ ricServiceQuery->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
+ ricServiceQuery->protocolIEs.list.array[arrIdx]->value.present = RICserviceQuery_IEs__value_PR_RANfunctionsID_List;
+ if(BuildRanFunctionAddedList(duDb, 0, NULL, &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_RICserviceQuery)!=ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build Ran function added list");
+ break;
+ }
+ }
+
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
+
+ /* Check encode results */
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode RIC service Query structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC service Query\n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ DU_LOG("%x",encBuf[i]);
+ }
+ }
+
+ if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duDb->duId) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Sending of RIC service Query failed");
+ break;
+ }
+
+ ret =ROK;
+ break;
+ }
+ FreeRicServiceQuery(e2apMsg);
+ return ret;
+}
+
/*******************************************************************
*
* @brief Handles received E2AP message and sends back response
uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId);
uint8_t BuildAndSendRicSubscriptionReq(uint32_t duId);
uint8_t SendE2APMsg(Region region, Pool pool, uint32_t duId);
-
+uint8_t BuildAndSendRicServiceQuery(DuDb *duDb);
/**********************************************************************
End of file
**********************************************************************/
#define RIC_APP_MEM_REG 1
#define RIC_POOL 1
#define MAX_RAN_FUNCTION 256 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofRANfunctionID */
+#define MAX_NUM_TRANSACTION 256 /* As per, O-RAN WG3 E2AP v3.0, section 9.2.33 */
/* allocate and zero out a static buffer */
#define RIC_ALLOC(_datPtr, _size) \
typedef struct duDb
{
uint32_t duId;
+ uint8_t ricTransIdCounter;
uint16_t numOfRanFunction;
RanFunction ranFunction[MAX_RAN_FUNCTION];
E2NodeComponent e2NodeComponent;
RicGlobalCb ricCb;
+typedef struct
+{
+ uint8_t numOfRanFunToBeAdded;
+ RanFunction ranFunToBeAdded[MAX_RAN_FUNCTION];
+ uint8_t numOfRanFunToBeModified;
+ RanFunction ranFunToBeModified[MAX_RAN_FUNCTION];
+ uint8_t numOfRanFunTodeleted;
+ RanFunction ranFunToBeDeleted[MAX_RAN_FUNCTION];
+}RicTmpRanFunList;
+
void readRicCfg();
void cuAppInmsgHdlr(Buffer *mBuf);
void sctpNtfyInd(CmInetSctpNotification *ntfy);