+/******************************************************************
+ *
+ * @brief Search E2 node component with the help of interface type
+ * and component Id
+ *
+ * @details
+ *
+ * Function : fetchE2NodeComponentInfo
+ *
+ * Functionality: Search E2 node component
+ *
+ * @params[in]
+ * DU databse
+ * Type of interface
+ * Pointer to E2 component node to be searched
+ * @return CmLList
+ *
+ * ****************************************************************/
+
+E2NodeComponent *fetchE2NodeComponentInfo(DuDb *duDb, InterfaceType interfaceType,CmLList **e2ComponentNode)
+{
+ E2NodeComponent *e2NodeComponentInfo=NULLP;
+
+ if(duDb->e2NodeComponent.count)
+ {
+ CM_LLIST_FIRST_NODE(&duDb->e2NodeComponent, *e2ComponentNode);
+ while(*e2ComponentNode)
+ {
+ e2NodeComponentInfo = (E2NodeComponent*)((*e2ComponentNode)->node);
+ if((e2NodeComponentInfo->interfaceType == interfaceType))
+ {
+ break;
+ }
+
+ *e2ComponentNode = (*e2ComponentNode)->next;
+ e2NodeComponentInfo = NULLP;
+ }
+ }
+ return e2NodeComponentInfo;
+}
+
+/*******************************************************************
+ *
+ * @brief update E2 node config list
+ *
+ * @details
+ *
+ * Function : updateE2NodeConfigList
+ *
+ * Functionality:
+ * - update E2 node config list
+ * @params[in]
+ * DU databse
+ * Protocol Id
+ * Configuration which need to update in Database
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t updateE2NodeConfigList(DuDb **duDb, uint8_t protocolId, E2NodeConfigItem *tmpCfg)
+{
+ CmLList *node;
+ E2NodeComponent * e2NodeComponentInfo;
+ bool configFound= false;
+
+ switch(protocolId)
+ {
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition:
+ {
+ /* Adding the new e2 node component in DB*/
+ RIC_ALLOC(e2NodeComponentInfo, sizeof(E2NodeComponent));
+ e2NodeComponentInfo->interfaceType = tmpCfg->componentInfo.interfaceType;
+ e2NodeComponentInfo->componentId =tmpCfg->componentInfo.componentId;
+ RIC_ALLOC(node, sizeof(CmLList));
+ if(node)
+ {
+ node->node = (PTR) e2NodeComponentInfo;
+ cmLListAdd2Tail(&(*duDb)->e2NodeComponent, node);
+ configFound =true;
+ }
+ else
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed for e2NodeComponentList node");
+ RIC_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
+ return RFAILED;
+ }
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate:
+ {
+ /* searching for information in a database */
+ e2NodeComponentInfo = fetchE2NodeComponentInfo((*duDb),tmpCfg->componentInfo.interfaceType, &node);
+ if(!e2NodeComponentInfo)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to find the e2 component node");
+ return RFAILED;
+ }
+ /* If the node is present then update the value */
+ e2NodeComponentInfo->componentId =tmpCfg->componentInfo.componentId;
+ configFound =true;
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval:
+ {
+ /* searching for information in a database */
+ e2NodeComponentInfo = fetchE2NodeComponentInfo((*duDb),tmpCfg->componentInfo.interfaceType, &node);
+ if(!e2NodeComponentInfo)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to find the e2 component node");
+ return RFAILED;
+ }
+ /* Delete the node from the list */
+ e2NodeComponentInfo->componentId = tmpCfg->componentInfo.componentId;
+ cmLListDelFrm(&(*duDb)->e2NodeComponent, node);
+ RIC_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
+ configFound =true;
+ break;
+ }
+ }
+
+ /* If the configuration update was successful, then mark the isSuccessful as
+ * true; otherwise, mark it as false. */
+ if(configFound == true)
+ tmpCfg->isSuccessful = true;
+ else
+ tmpCfg->isSuccessful = false;
+
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Handling the E2 node configuration depending on the add,
+ * update, or remove configuration type
+ *
+ * @details
+ *
+ * Function : handleE2NodeComponentAction
+ *
+ * Functionality:
+ * - Handling the E2 node configuration depending on the add,
+ * update, or remove configuration type
+ * @params[in]
+ * DU database
+ * Pointer to e2NodeCfg which has info
+ * ProtocolId
+ * E2NodeConfigItem to be filled
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t handleE2NodeComponentAction(DuDb *duDb, PTR e2NodeCfg, uint8_t protocolId, E2NodeConfigItem *storeCfg)
+{
+ uint8_t configFound = ROK;
+ E2NodeConfigItem tmpCfg;
+ E2nodeComponentID_t componentId;
+ E2nodeComponentInterfaceType_t interface;
+ E2nodeComponentConfigAddition_Item_t *addCfg=NULL;
+ E2nodeComponentConfigUpdate_Item_t *updateCfg=NULL;
+ E2nodeComponentConfigRemoval_Item_t *removeCfg=NULL;
+
+ /* fetching the interface and component id information from the e2NodeCfg */
+ memset(storeCfg, 0, sizeof(E2NodeConfigItem));
+ storeCfg->isSuccessful=false;
+ memset(&tmpCfg, 0, sizeof(E2NodeConfigItem));
+
+ switch(protocolId)
+ {
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition:
+ {
+ addCfg = (E2nodeComponentConfigAddition_Item_t *)e2NodeCfg;
+ interface = addCfg->e2nodeComponentInterfaceType;
+ componentId = addCfg->e2nodeComponentID;
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate:
+ {
+ updateCfg = (E2nodeComponentConfigUpdate_Item_t *)e2NodeCfg;
+ interface = updateCfg->e2nodeComponentInterfaceType;
+ componentId = updateCfg->e2nodeComponentID;
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval:
+ {
+ removeCfg = (E2nodeComponentConfigRemoval_Item_t*)e2NodeCfg;
+ interface = removeCfg->e2nodeComponentInterfaceType;
+ componentId = removeCfg->e2nodeComponentID;
+ break;
+ }
+ }
+
+ /* Storing the information in temporary structure */
+ tmpCfg.componentInfo.interfaceType = interface;
+
+ switch(componentId.present)
+ {
+ case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1:
+ {
+ if(componentId.choice.e2nodeComponentInterfaceTypeF1)
+ {
+ tmpCfg.componentInfo.componentId = componentId.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf[0];
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ /* Updating the database configuration */
+ configFound = updateE2NodeConfigList(&duDb, protocolId, &tmpCfg);
+
+ memcpy(storeCfg, &tmpCfg,sizeof(E2NodeConfigItem));
+ return configFound;
+
+}
+