Updated IP and Port configurations
[o-du/l2.git] / src / du_app / du_egtp.c
index 2fca6e2..a75e7bf 100644 (file)
 *******************************************************************************/
  
 /* This file contains all EGTP related functionality */
-
-#include <stdio.h>
+#include "common_def.h"
+#include "lrg.h"
+#include "lkw.x"
+#include "lrg.x"
+#include "legtp.h"
+#include "du_cfg.h"
 #include "du_egtp.h"
+#include "du_ue_mgr.h"
 
 /* Global variable declaration */
 EgtpGlobalCb egtpCb;
@@ -51,7 +56,7 @@ S16 egtpActvInit(Ent entity, Inst inst, Region region, Reason reason)
   cmMemset ((U8 *)&egtpCb, 0, sizeof(EgtpGlobalCb));
   protType = CM_INET_PROTO_UDP;
 
-  RETVALUE(ROK);
+  return ROK;
 }
 
 
@@ -86,22 +91,22 @@ S16 egtpActvTsk(Pst *pst, Buffer *mBuf)
          {
             case EVTCFGREQ:
             {
-               ret = cmUnpkEgtpCfgReq(egtpCfgReq, pst, mBuf);
+               ret = unpackEgtpCfgReq(egtpCfgReq, pst, mBuf);
                break;
             }
             case EVTSRVOPENREQ:
             {
-               ret = cmUnpkEgtpSrvOpenReq(egtpSrvOpenReq, pst, mBuf);
+               ret = unpackEgtpSrvOpenReq(egtpSrvOpenReq, pst, mBuf);
                break;
             }
             case EVTTNLMGMTREQ:
             {
-               ret = cmUnpkEgtpTnlMgmtReq(egtpTnlMgmtReq, pst, mBuf);
+               ret = unpackEgtpTnlMgmtReq(egtpTnlMgmtReq, pst, mBuf);
                break;
             }
-            case EVTTTIIND:
+            case EVTSLOTIND:
             {
-               ret = cmUnpkEgtpTTIInd(egtpTTIInd, pst, mBuf);
+               ret = unpackEgtpSlotInd(egtpSlotInd, pst, mBuf);
                SPutMsg(mBuf);
                break;
             }
@@ -138,7 +143,7 @@ S16 egtpActvTsk(Pst *pst, Buffer *mBuf)
       }
    }
    SExitTsk();
-   RETVALUE(ret);
+   return ret;
 }
 
 /**************************************************************************
@@ -191,9 +196,9 @@ S16 egtpCfgReq(Pst *pst, EgtpConfig egtpCfg)
    egtpFillRspPst(pst, &rspPst);
    rspPst.event = EVTCFGCFM;
 
-   cmPkEgtpCfgCfm(&rspPst, cfgCfm);
+   packEgtpCfgCfm(&rspPst, cfgCfm);
 
-   RETVALUE(ROK);
+   return ROK;
 }
 
 /**************************************************************************
@@ -221,10 +226,10 @@ S16 egtpFillRspPst(Pst *pst, Pst *rspPst)
    rspPst->dstEnt = pst->srcEnt;
    rspPst->dstInst = pst->srcInst;
    rspPst->dstProcId = pst->srcProcId;
-   rspPst->selector = DU_SELECTOR_LC;
+   rspPst->selector = ODU_SELECTOR_LC;
    rspPst->pool= DU_POOL;
     
-   RETVALUE(ROK);
+   return ROK;
 }
 
 /**************************************************************************
@@ -255,19 +260,19 @@ S16 egtpSrvOpenReq(Pst *pst)
    DU_LOG("\nEGTP : Received EGTP open server request");
  
    sockType = CM_INET_DGRAM;
-  
-   /* Opening and Binding receiver socket */
-   if(ret = egtpSrvOpenPrc(sockType, &(egtpCb.recvTptSrvr)) != ROK)
+   ret = egtpSrvOpenPrc(sockType, &(egtpCb.recvTptSrvr));
+       /* Opening and Binding receiver socket */
+   if(ret != ROK)
    {
       DU_LOG("\nEGTP : Failed while opening receiver transport server");
-      RETVALUE(RFAILED);
+      return ret;
    }
-
    /* Opening and Binding sender socket */
-   if(ret = egtpSrvOpenPrc(sockType, &(egtpCb.dstCb.sendTptSrvr)) != ROK)
+       ret = egtpSrvOpenPrc(sockType, &(egtpCb.dstCb.sendTptSrvr));
+   if(ret != ROK)
    {
       DU_LOG("\nEGTP : Failed while opening sender transport server");
-      RETVALUE(RFAILED);
+      return ret;
    }
 
    DU_LOG("\nEGTP : Receiver socket[%d] and Sender socket[%d] open", egtpCb.recvTptSrvr.sockFd.fd, egtpCb.dstCb.sendTptSrvr.sockFd.fd);
@@ -278,9 +283,9 @@ S16 egtpSrvOpenReq(Pst *pst)
 
    egtpFillRspPst(pst, &rspPst);
    rspPst.event = EVTSRVOPENCFM;
-   cmPkEgtpSrvOpenCfm(&rspPst, cfm);
+   packEgtpSrvOpenCfm(&rspPst, cfm);
 
-   RETVALUE(ROK);
+   return ret;
 }
 
 /*******************************************************************
@@ -302,21 +307,21 @@ S16 egtpSrvOpenReq(Pst *pst)
 
 S16 egtpSrvOpenPrc(U8 sockType, EgtpTptSrvr *server)
 {
-   S8 ret;
-
-   if(ret = (cmInetSocket(sockType, &(server->sockFd), protType)) != ROK)
+   S8 ret=ROK;
+   ret = cmInetSocket(sockType, &(server->sockFd), protType); 
+       if(ret != ROK)
    {  
       DU_LOG("\nEGTP : Failed to open UDP socket");
-      RETVALUE(RFAILED);
+      return ret;
    }
-      
-   if(ret = cmInetBind(&(server->sockFd), &(server->addr)) != ROK)
+   ret = cmInetBind(&(server->sockFd), &(server->addr));  
+   if(ret != ROK)
    {  
       DU_LOG("\nEGTP : Failed to bind socket");
-      RETVALUE(RFAILED);
+      return ret;
    }
    
-   RETVALUE(ROK);
+   return ret;
 }
 
 /**************************************************************************
@@ -380,9 +385,9 @@ S16 egtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
    DU_LOG("\nEGTP : Sending Tunnel management confirmation");
    egtpFillRspPst(pst, &rspPst);
    rspPst.event = EVTTNLMGMTCFM;
-   cmPkEgtpTnlMgmtCfm(&rspPst, tnlEvt);
+   packEgtpTnlMgmtCfm(&rspPst, tnlEvt);
 
-   RETVALUE(ROK);
+   return ROK;
 }
 
 /**************************************************************************
@@ -412,7 +417,7 @@ S16 egtpTnlAdd(EgtpTnlEvt tnlEvt)
    if(ret != ROK)
    {
       DU_LOG("\nEGTP : Memory allocation failed");
-      RETVALUE(LCM_REASON_MEM_NOAVAIL);
+      return LCM_REASON_MEM_NOAVAIL;
    }
 
    cmMemset((U8 *)teidCb, 0, sizeof(EgtpTeIdCb));
@@ -424,7 +429,7 @@ S16 egtpTnlAdd(EgtpTnlEvt tnlEvt)
    {
       DU_LOG("\nEGTP : Failed to insert in hash list");
       SPutSBuf(DU_APP_MEM_REGION, DU_POOL, (Data *)teidCb, (Size)sizeof(EgtpTeIdCb));
-      RETVALUE(LCM_REASON_HASHING_FAILED);
+      return LCM_REASON_HASHING_FAILED;
    }
    egtpCb.dstCb.numTunn++;
 
@@ -438,7 +443,7 @@ S16 egtpTnlAdd(EgtpTnlEvt tnlEvt)
   
    egtpEncodeHdr((U8 *)teidCb->preEncodedHdr.hdr, &preDefHdr, &(teidCb->preEncodedHdr.cnt));
 
-   RETVALUE(ROK);
+   return ROK;
 } /* egtpTnlAdd */
 
 /**************************************************************************
@@ -474,7 +479,7 @@ S16 egtpTnlMod(EgtpTnlEvt tnlEvt)
    teidCb->teId = tnlEvt.lclTeid;
    teidCb->remTeId = tnlEvt.remTeid;
 #endif
-   RETVALUE(ROK);
+   return ROK;
 }
 
 /**************************************************************************
@@ -502,14 +507,14 @@ S16 egtpTnlDel(EgtpTnlEvt tnlEvt)
    if(teidCb == NULLP)
    {
       DU_LOG("\nEGTP : Tunnel id[%d] not configured", tnlEvt.lclTeid);
-      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+      return LCM_REASON_INVALID_PAR_VAL;
    } 
 
    cmHashListDelete(&(egtpCb.dstCb.teIdLst), (PTR)teidCb);
    SPutSBuf(DU_APP_MEM_REGION, DU_POOL, (Data *)teidCb, (Size)sizeof(EgtpTeIdCb));
    egtpCb.dstCb.numTunn--;
 
-   RETVALUE(ROK);
+   return ROK;
 }
 
 /*******************************************************************
@@ -543,7 +548,7 @@ S16 egtpHdlDatInd(EgtpMsg egtpMsg)
    if(teidCb == NULLP)
    {
       DU_LOG("\nEGTP : Tunnel id[%d] not configured", egtpMsg.msgHdr.teId);
-      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+      return LCM_REASON_INVALID_PAR_VAL;
    }
    
    msgHdr = &(egtpMsg.msgHdr);
@@ -587,20 +592,20 @@ S16 egtpHdlDatInd(EgtpMsg egtpMsg)
       teidCb->preEncodedHdr.hdr[EGTP_MAX_HDR_LEN - 1] &= ~(EGTP_MASK_BIT2);
    }
 
-   DU_LOG("\nEGTP : Data buffer before encoding header");
+   DU_LOG("\nEGTP : UL Data buffer before encoding header");
    SPrntMsg(egtpMsg.msg, 0, 0);
 
    SAddPreMsgMult(&teidCb->preEncodedHdr.hdr[hdrLen], (EGTP_MAX_HDR_LEN - hdrLen), egtpMsg.msg);
 
 
-   DU_LOG("\nEGTP : Data buffer after encoding header");
+   DU_LOG("\nEGTP : UL Data buffer after encoding header");
    SPrntMsg(egtpMsg.msg, 0, 0);
 
    /* Send over UDP */
    egtpSendMsg(egtpMsg.msg);
    SPutMsg(egtpMsg.msg);
 
-   RETVALUE(ROK);
+   return ROK;
 }/* EgtpHdlDatInd */
 
 /*******************************************************************
@@ -712,7 +717,7 @@ S16 egtpEncodeHdr(U8 *preEncodedHdr, EgtpMsgHdr *preDefHdr, U8 *hdrIdx)
    }
 
    *hdrIdx = cnt;
-   RETVALUE(ROK);
+   return ROK;
 } /* egtpEncodeHdr */
 
 /*******************************************************************
@@ -748,21 +753,21 @@ S16 egtpSendMsg(Buffer *mBuf)
    if(ret != ROK && ret != RWOULDBLOCK)
    {
       DU_LOG("\nEGTP : Failed sending the message");
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
 
    DU_LOG("\nEGTP : Message Sent");
 
-   RETVALUE(ROK);
+   return ROK;
 }
 
 /*******************************************************************
  *
- * @brief Handles TTI Indication from PHY
+ * @brief Handles Slot Indication from PHY
  *
  * @details
  *
- *    Function : egtpTTIInd
+ *    Function : egtpSlotInd
  *
  *    Functionality:
  *       Handles TTI Indication from PHY
@@ -772,10 +777,10 @@ S16 egtpSendMsg(Buffer *mBuf)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 egtpTTIInd()
+S16 egtpSlotInd()
 {
    egtpRecvMsg();
-   RETVALUE(ROK);
+   return ROK;
 }
 
 /*******************************************************************
@@ -805,7 +810,7 @@ S16 egtpRecvMsg()
    CmInetMemInfo  memInfo;       /* Buffer allocation info */
 
 
-   DU_LOG("\nEGTP : Received TTI Indication");
+   DU_LOG("\nEGTP : Received Slot Indication");
 
    nMsg = 0;
    memInfo.region = DU_APP_MEM_REGION;
@@ -820,14 +825,14 @@ S16 egtpRecvMsg()
       ret = cmInetRecvMsg(&(egtpCb.recvTptSrvr.sockFd), &fromAddr, &memInfo, &recvBuf, &bufLen, CM_INET_NO_FLAG);
       if(ret == ROK && recvBuf != NULLP)
       {  
-         DU_LOG("\nEGTP : Received Message[%d]\n", nMsg+1);
+         DU_LOG("\nEGTP : Received DL Message[%d]\n", nMsg+1);
          SPrntMsg(recvBuf, 0 ,0);
          egtpHdlRecvData(recvBuf);
       }
       nMsg++;
    }
    
-   RETVALUE(ROK);
+   return ROK;
 }
 
 S16 egtpHdlRecvData(Buffer *mBuf)
@@ -838,8 +843,9 @@ S16 egtpHdlRecvData(Buffer *mBuf)
    egtpDecodeHdr(mBuf, &egtpMsg);
 
    /* TODO : Send received message to RLC */
+   duHdlEgtpDlData(&egtpMsg);
 
-   RETVALUE(ROK);
+   return ROK;
 }
 
 S16 egtpDecodeHdr(Buffer *mBuf, EgtpMsg  *egtpMsg)
@@ -994,12 +1000,14 @@ S16 egtpDecodeHdr(Buffer *mBuf, EgtpMsg  *egtpMsg)
    {
       SRemPreMsg(&extHdrType, mBuf);
    }
-   DU_LOG("\nEGTP : Data Buffer after decoding header ");
+
+   egtpMsg->msg = mBuf;
+
+   DU_LOG("\nEGTP : DL Data Buffer after decoding header ");
    SPrntMsg(mBuf, 0, 0);
 
    /* Forward the data to duApp/RLC */
  
-   RETVALUE(ROK);
+   return ROK;
 
 }