[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-527] Modifying DU's E2 node configurations
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index b30f89d..d9b5022 100644 (file)
@@ -1588,91 +1588,6 @@ void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
    }
 }
 
-/*******************************************************************
- *
- * @brief add or modify E2NodeComponent list
- *
- * @details
- *
- *    Function : addOrModifyE2NodeComponent 
- *
- * Functionality: add or modify E2NodeComponent list 
- *
- * @parameter uint8_t componentactiontype, bool reqPart, uint8_t bufSize, char *bufString
- * @return ROK     - success
- *         RFAILED - failure
- *
- ******************************************************************/
-uint8_t addOrModifyE2NodeComponent(uint8_t action, bool reqPart, uint8_t bufSize, char *bufString)
-{
-   E2NodeComponent *e2NodeComponentInfo;
-   CmLList  *node = NULLP;
-   
-   if(action == E2_NODE_COMPONENT_ADD)
-   {
-      if(reqPart == true)
-      {
-         DU_ALLOC(e2NodeComponentInfo, sizeof(E2NodeComponent));
-         if(!e2NodeComponentInfo)
-         {
-            DU_LOG("\nERROR  -->  F1AP : Memory allocation failed for e2NodeComponentInfo in %s",__func__);
-            return RFAILED;
-         }
-         e2NodeComponentInfo->interfaceType =F1;
-         e2NodeComponentInfo->componentId=duCfgParam.duId;
-         e2NodeComponentInfo->componentActionType = action;
-         e2NodeComponentInfo->reqBufSize = bufSize;
-
-         DU_ALLOC(e2NodeComponentInfo->componentRequestPart, bufSize);
-         if(e2NodeComponentInfo->componentRequestPart == NULLP)
-         {
-            DU_LOG("\nERROR  -->  F1AP : Memory allocation failed for componentRequestPart");
-            DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
-            return RFAILED;
-         }
-         memcpy(e2NodeComponentInfo->componentRequestPart, bufString, e2NodeComponentInfo->reqBufSize);
-         DU_ALLOC(node, sizeof(CmLList));
-         if(node)
-         {
-            node->node = (PTR) e2NodeComponentInfo;
-            cmLListAdd2Tail(&duCb.e2apDb.e2NodeComponentList, node);
-         }
-         else
-         {
-            DU_LOG("\nERROR  -->  F1AP : Memory allocation failed for e2NodeComponentList node");
-            DU_FREE(e2NodeComponentInfo->componentRequestPart, bufSize);
-            DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
-            return RFAILED;
-         }
-      }
-      else
-      {
-         if(duCb.e2apDb.e2NodeComponentList.count)
-         {
-            CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node);
-            while(node)
-            {
-               e2NodeComponentInfo = (E2NodeComponent*)node->node;
-               if((e2NodeComponentInfo->interfaceType == F1) && (e2NodeComponentInfo->componentActionType == action))
-               {
-                  e2NodeComponentInfo->rspBufSize = bufSize;
-
-                  DU_ALLOC(e2NodeComponentInfo->componentResponsePart, bufSize);
-                  if(e2NodeComponentInfo->componentResponsePart == NULLP)
-                  {
-                     DU_LOG("\nERROR  -->  F1AP : Memory allocation failed to store the encoding of f1setup rsp");
-                     return RFAILED;
-                  }
-                  memcpy(e2NodeComponentInfo->componentResponsePart, bufString, e2NodeComponentInfo->rspBufSize);
-                  break;
-               }
-               node = node->next;
-            }
-         } 
-      }
-   }
-   return ROK;
-}
 /*******************************************************************
  *
  * @brief Builds and Send the F1SetupRequest
@@ -1844,13 +1759,19 @@ uint8_t BuildAndSendF1SetupReq()
          
 
       }
-      addOrModifyE2NodeComponent(E2_NODE_COMPONENT_ADD, true, encBufSize, encBuf);
+      
       /* Sending msg */
       if(sendF1APMsg() != ROK)
       {
          DU_LOG("\nERROR  -->  F1AP : Sending F1 Setup request failed");
          break;
       }
+      
+      if(fillE2NodeComponentReqInfo(F1, duCfgParam.duId,  E2_NODE_COMPONENT_ADD, encBufSize, encBuf) !=ROK)
+      {
+         DU_LOG("\nERROR  -->  F1AP : Failed to add the e2 node in the list");
+         break;
+      }
 
       ret=ROK;
       break;
@@ -2843,12 +2764,19 @@ uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
          }
 #endif
       }
+      
       /* Sending msg */
       if(sendF1APMsg() != ROK)
       {
          DU_LOG("\nERROR  -->  F1AP : Sending GNB-DU Config Update failed");
          break;
       }
+      
+      if(fillE2NodeComponentReqInfo(F1, duCfgParam.duId, E2_NODE_COMPONENT_UPDATE, encBufSize, encBuf)!=ROK)
+      {
+         DU_LOG("\nERROR  -->  F1AP : Failed to update the e2 node in the list");
+         break;
+      }
 
       ret = ROK;
       break;
@@ -15628,7 +15556,11 @@ uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg, MsgLen recvBufLen, char *recvBuf)
    duProcF1SetupRsp();
    freeAperDecodeF1SetupRsp(f1SetRspMsg);
    
-   addOrModifyE2NodeComponent(E2_NODE_COMPONENT_ADD, false, recvBufLen, recvBuf);
+   if(fillE2NodeComponentRspInfo(F1, duCfgParam.duId, E2_NODE_COMPONENT_ADD, recvBufLen, recvBuf) !=ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Failed to add the e2 node in the list");
+      return RFAILED;
+   }
 
    if(BuildAndSendE2SetupReq() != ROK)
    {
@@ -15806,11 +15738,12 @@ uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
 *
 *    Functionality: added free part for the memory allocated by aper_decoder
 *
-* @params[in] F1AP_PDU_t *f1apMsg 
+* @params[in] F1AP_PDU_t *f1apMsg,  MsgLen recvBufLen, char *recvBuf 
 * @return void 
 *
 * ****************************************************************/
-uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
+
+uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg, MsgLen recvBufLen, char *recvBuf)
 {
    uint8_t ieIdx=0,transId=0;
    GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
@@ -15853,6 +15786,13 @@ uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
 #endif
 
    freeAperDecodeGnbDuAck(gnbDuAck);
+   
+   if(fillE2NodeComponentRspInfo(F1,duCfgParam.duId, E2_NODE_COMPONENT_UPDATE, recvBufLen, recvBuf) !=ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Failed to update the e2 node in the list");
+      return RFAILED;
+   }
+
    return ROK;
 }
 /******************************************************************
@@ -18035,7 +17975,7 @@ void F1APMsgHdlr(Buffer *mBuf)
 
                case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
                   {
-                     procF1GNBDUCfgUpdAck(f1apMsg);
+                     procF1GNBDUCfgUpdAck(f1apMsg, recvBufLen, recvBuf);
                      break;
                   }