[Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-434] EGTP connection towards multiple DUs...
[o-du/l2.git] / src / du_app / du_egtp.c
index 36d3978..2a486c6 100644 (file)
@@ -29,8 +29,6 @@
 #include "du_egtp.h"
 #include "du_utils.h"
 
-/* Global variable declaration */
-EgtpGlobalCb egtpCb;
 
 /**************************************************************************
  * @brief Task Initiation callback function. 
@@ -54,14 +52,111 @@ EgtpGlobalCb egtpCb;
  ***************************************************************************/
 uint8_t egtpActvInit(Ent entity, Inst inst, Region region, Reason reason)
 {
-  DU_LOG("\n\nEGTP : Initializing");
+  DU_LOG("\n\nDEBUG   -->  EGTP : Initializing");
 
-  memset ((uint8_t *)&egtpCb, 0, sizeof(EgtpGlobalCb));
+  memset (&egtpCb, 0, sizeof(EgtpGlobalCb));
   protType = CM_INET_PROTO_UDP;
+  gDlDataRcvdCnt = 0;
 
   return ROK;
 }
 
+/**************************************************************************
+* @brief Function prints the src dest and msg reached to egtp.
+*
+* @details
+*
+*      Function : callFlowEgtpActvTsk 
+*
+*      Functionality:
+*           Function prints the src dest and msg reached to egtp.
+*
+* @param[in]  Pst     *pst, Post structure of the primitive.
+*
+* @return void 
+*
+***************************************************************************/
+
+void callFlowEgtpActvTsk(Pst *pst)
+{
+
+   char sourceTask[50];
+   char destTask[50]="ENTEGTP";
+   char message[100];
+
+   switch(pst->srcEnt)
+   {
+      case ENTDUAPP:
+         {
+            strcpy(sourceTask,"ENTDUAPP");
+            switch(pst->event)
+            {
+               case EVTCFGREQ:
+                  {
+                     strcpy(message,"EVTCFGREQ");
+                     break;
+                  }
+               case EVTSRVOPENREQ:
+                  {
+                     strcpy(message,"EVTSRVOPENREQ");
+                     break;
+                  }
+               case EVTTNLMGMTREQ:
+                  {
+                     strcpy(message,"EVTTNLMGMTREQ");
+                     break;
+                  }
+               default:
+                  {
+                     strcpy(message,"Invalid Event");
+                     break;
+                  }
+            }
+            break;
+         }
+      case ENTEGTP:
+         {
+            strcpy(sourceTask,"ENTEGTP");
+            switch(pst->event)
+            {
+               case EVTSTARTPOLL:
+                  {
+                     strcpy(message,"EVTSTARTPOLL");
+                     break;
+                  }
+               default:
+                  {
+                     strcpy(message,"Invalid Event");
+                     break;
+                  }
+            }
+            break;
+         }
+      case ENTRLC:
+         {
+            strcpy(sourceTask,"ENTRLC");
+            switch(pst->event)
+            {
+               case EVTDATIND:
+                  {
+                     strcpy(message,"EVTDATIND");
+                     break;
+                  }
+               default:
+                  {
+                     strcpy(message,"Invalid Event");
+                     break;
+                  }
+            }
+            break;
+         }
+      default:
+         {
+             strcpy(sourceTask,"Invalid Source Entity Id");
+         }
+   }
+   DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
+}
 
 /**************************************************************************
  * @brief Task Activation callback function. 
@@ -85,6 +180,10 @@ uint8_t egtpActvInit(Ent entity, Inst inst, Region region, Reason reason)
 uint8_t egtpActvTsk(Pst *pst, Buffer *mBuf)
 {
    uint8_t ret = ROK;
+  
+#ifdef CALL_FLOW_DEBUG_LOG
+   callFlowEgtpActvTsk(pst);
+#endif
 
    switch(pst->srcEnt)
    {
@@ -107,22 +206,36 @@ uint8_t egtpActvTsk(Pst *pst, Buffer *mBuf)
                ret = unpackEgtpTnlMgmtReq(egtpTnlMgmtReq, pst, mBuf);
                break;
             }
-            case EVTSLOTIND:
+            default:
             {
-               ret = unpackEgtpSlotInd(egtpSlotInd, pst, mBuf);
-               ODU_PUT_MSG(mBuf);
+               DU_LOG("\nERROR  -->  EGTP : Invalid event %d", pst->event);
+               ODU_PUT_MSG_BUF(mBuf);
+               ret = RFAILED;
+            }
+         }
+         break;
+      }
+      case ENTEGTP:
+      {
+         switch(pst->event)
+         {
+            case EVTSTARTPOLL:
+            {
+               DU_LOG("\nDEBUG   -->  EGTP : Starting Socket Polling");
+               egtpRecvMsg();
+               ODU_PUT_MSG_BUF(mBuf);
                break;
             }
             default:
             {
-               DU_LOG("\nEGTP : Invalid event %d", pst->event);
-               ODU_PUT_MSG(mBuf);
+               DU_LOG("\nERROR  -->  EGTP : Invalid event %d", pst->event);
+               ODU_PUT_MSG_BUF(mBuf);
                ret = RFAILED;
             }
-         }
-         break;
+        }
+        break;
       }
-      case ENTKW:
+      case ENTRLC:
       {
          switch(pst->event)
          {
@@ -133,7 +246,7 @@ uint8_t egtpActvTsk(Pst *pst, Buffer *mBuf)
             }
             default:
             {
-               DU_LOG("\nEGTP : Invalid event %d", pst->event);
+               DU_LOG("\nERROR  -->  EGTP : Invalid event %d", pst->event);
                ret = RFAILED;
             }
          }
@@ -141,7 +254,7 @@ uint8_t egtpActvTsk(Pst *pst, Buffer *mBuf)
       }
       default:
       {
-         DU_LOG("\nEGTP : Invalid source entity %d", pst->srcEnt);
+         DU_LOG("\nERROR  -->  EGTP : Invalid source entity %d", pst->srcEnt);
          ret = RFAILED;
       }
    }
@@ -165,32 +278,32 @@ uint8_t egtpActvTsk(Pst *pst, Buffer *mBuf)
  * ***********************************************************************/
 uint8_t egtpCfgReq(Pst *pst, EgtpConfig egtpCfg)
 {
-   uint8_t ret;          /* Return value */
-   Pst rspPst;      /* Response Pst structure */
+   uint8_t  ret;          /* Return value */
+   Pst      rspPst;      /* Response Pst structure */
    CmStatus cfgCfm; /* Configuration Confirm */
 
-   memcpy((uint8_t *)&egtpCb.egtpCfg, (uint8_t *)&egtpCfg, (PTR)sizeof(EgtpConfig));
+   memcpy(&egtpCb.egtpCfg, &egtpCfg, sizeof(EgtpConfig));
 
-   egtpCb.recvTptSrvr.addr.address = CM_INET_NTOH_U32(egtpCb.egtpCfg.localIp.ipV4Addr);
-   egtpCb.recvTptSrvr.addr.port = EGTP_DFLT_PORT;
+   egtpCb.recvTptSrvr.addr.address = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.localIp.ipV4Addr);
+   egtpCb.recvTptSrvr.addr.port = EGTP_RECVR_PORT;
 
-   egtpCb.dstCb.dstIp = CM_INET_NTOH_U32(egtpCb.egtpCfg.destIp.ipV4Addr);
+   egtpCb.dstCb.dstIp = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.destIp.ipV4Addr);
    egtpCb.dstCb.dstPort = egtpCb.egtpCfg.destPort;
-   egtpCb.dstCb.sendTptSrvr.addr.address = CM_INET_NTOH_U32(egtpCb.egtpCfg.localIp.ipV4Addr);
+   egtpCb.dstCb.sendTptSrvr.addr.address = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.localIp.ipV4Addr);
    egtpCb.dstCb.sendTptSrvr.addr.port = egtpCb.egtpCfg.localPort;
    egtpCb.dstCb.numTunn = 0;
 
-   ret = cmHashListInit(&(egtpCb.dstCb.teIdLst), 1024, sizeof(EgtpTeIdCb), FALSE, CM_HASH_KEYTYPE_U32MOD, DU_APP_MEM_REGION, DU_POOL);
+   ret = cmHashListInit(&(egtpCb.dstCb.teIdLst), 1024, sizeof(EgtpTeIdCb), FALSE, CM_HASH_KEYTYPE_UINT32_MOD, DU_APP_MEM_REGION, DU_POOL);
 
    if(ret != ROK)
    {
-      DU_LOG("\nEGTP : TeId hash list initialization failed");
+      DU_LOG("\nERROR  -->  EGTP : TeId hash list initialization failed");
       cfgCfm.status = LCM_PRIM_NOK;
       cfgCfm.reason = LCM_REASON_HASHING_FAILED;
    }
    else
    {
-      DU_LOG("\nEGTP : EGTP configuration successful");
+      DU_LOG("\nDEBUG   -->  EGTP : EGTP configuration successful");
       cfgCfm.status = LCM_PRIM_OK;
       cfgCfm.reason = LCM_REASON_NOT_APPL;
    }
@@ -222,7 +335,7 @@ uint8_t egtpCfgReq(Pst *pst, EgtpConfig egtpCfg)
 uint8_t egtpFillRspPst(Pst *pst, Pst *rspPst)
 {
 
-   memset((uint8_t *)rspPst, 0, sizeof(Pst));
+   memset(rspPst, 0, sizeof(Pst));
    rspPst->srcEnt = pst->dstEnt;
    rspPst->srcInst = pst->dstInst;
    rspPst->srcProcId = pst->dstProcId;
@@ -255,32 +368,47 @@ uint8_t egtpFillRspPst(Pst *pst, Pst *rspPst)
 uint8_t egtpSrvOpenReq(Pst *pst)
 {
 
-   uint8_t    ret;       /* Return value */
-   Pst   rspPst;    /* Response Pst structure */ 
-   CmStatus cfm;    /* Confirmation status */
-   uint8_t sockType;     /* Socket type */
+   uint8_t  ret;       /* Return value */
+   Pst      rspPst;    /* Response Pst structure */ 
+   Pst      egtpPst;   /* Self post */
+   CmStatus cfm;       /* Confirmation status */
+   uint8_t  sockType;  /* Socket type */
 
-   DU_LOG("\nEGTP : Received EGTP open server request");
+   DU_LOG("\nDEBUG  -->  EGTP : Received EGTP open server request");
  
    sockType = CM_INET_DGRAM;
    ret = egtpSrvOpenPrc(sockType, &(egtpCb.recvTptSrvr));
        /* Opening and Binding receiver socket */
    if(ret != ROK)
    {
-      DU_LOG("\nEGTP : Failed while opening receiver transport server");
+      DU_LOG("\nERROR  -->  EGTP : Failed while opening receiver transport server");
       return ret;
    }
    /* Opening and Binding sender socket */
        ret = egtpSrvOpenPrc(sockType, &(egtpCb.dstCb.sendTptSrvr));
    if(ret != ROK)
    {
-      DU_LOG("\nEGTP : Failed while opening sender transport server");
+      DU_LOG("\nERROR  -->  EGTP : Failed while opening sender transport server");
       return ret;
    }
 
-   DU_LOG("\nEGTP : Receiver socket[%d] and Sender socket[%d] open", egtpCb.recvTptSrvr.sockFd.fd, egtpCb.dstCb.sendTptSrvr.sockFd.fd);
-
-   /* Filling and seing response */
+   DU_LOG("\nDEBUG   -->  EGTP : Receiver socket[%d] and Sender socket[%d] open", egtpCb.recvTptSrvr.sockFd.fd,\
+   egtpCb.dstCb.sendTptSrvr.sockFd.fd);
+
+   /* Start Socket polling */
+   memset(&egtpPst, 0, sizeof(egtpPst));
+   egtpPst.srcEnt = (Ent)ENTEGTP;
+   egtpPst.srcInst = (Inst)EGTP_INST;
+   egtpPst.srcProcId = DU_PROC;
+   egtpPst.dstEnt = (Ent)ENTEGTP;
+   egtpPst.dstInst = (Inst)EGTP_INST;
+   egtpPst.dstProcId = DU_PROC;
+   egtpPst.event = EVTSTARTPOLL;
+   egtpPst.selector = ODU_SELECTOR_LC;
+   egtpPst.pool= DU_POOL;
+   packEgtpStartPollingReq(&egtpPst);
+
+   /* Filling and sending response */
    cfm.status = LCM_PRIM_OK;
    cfm.reason = LCM_REASON_NOT_APPL;
 
@@ -314,13 +442,13 @@ uint8_t egtpSrvOpenPrc(uint8_t sockType, EgtpTptSrvr *server)
    ret = cmInetSocket(sockType, &(server->sockFd), protType); 
        if(ret != ROK)
    {  
-      DU_LOG("\nEGTP : Failed to open UDP socket");
+      DU_LOG("\nERROR  -->  EGTP : Failed to open UDP socket");
       return ret;
    }
    ret = cmInetBind(&(server->sockFd), &(server->addr));  
    if(ret != ROK)
    {  
-      DU_LOG("\nEGTP : Failed to bind socket");
+      DU_LOG("\nERROR  -->  EGTP : Failed to bind socket");
       return ret;
    }
    
@@ -337,8 +465,7 @@ uint8_t egtpSrvOpenPrc(uint8_t sockType, EgtpTptSrvr *server)
  *      Functionality:
  *           This function handles EGTP tunnel managament request
  *     
- * @param[in]  Pst *pst, post structure
- *             Tunnel Eveny structure
+ * @param[in] Tunnel Eveny structure
  * @return ROK     - success
  *         RFAILED - failure
  *
@@ -346,10 +473,13 @@ uint8_t egtpSrvOpenPrc(uint8_t sockType, EgtpTptSrvr *server)
  * ***************************************************************************/
 uint8_t egtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
 {
-   S8 ret;
-   Pst rspPst;
+   uint8_t ret = ROK;
 
-   DU_LOG("\nEGTP : Received tunnel management request");
+#ifdef CALL_FLOW_DEBUG_LOG
+   DU_LOG("\nCall Flow: ENTDUAPP -> ENTEGTP : TNL_MGMT\n");
+#endif
+
+   DU_LOG("\nDEBUG   -->  EGTP : Received tunnel management request");
    switch(tnlEvt.action)
    {
       case EGTP_TNL_MGMT_ADD:
@@ -369,7 +499,7 @@ uint8_t egtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
       }
       default:
       {
-         DU_LOG("\nEGTP : Invalid tunnel management action[%d]", tnlEvt.action);
+         DU_LOG("\nERROR  -->  EGTP : Invalid tunnel management action[%d]", tnlEvt.action);
          ret = LCM_REASON_INVALID_ACTION;
       }
    }
@@ -385,12 +515,10 @@ uint8_t egtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
       tnlEvt.cfmStatus.reason = ret;
    }
 
-   DU_LOG("\nEGTP : Sending Tunnel management confirmation");
-   egtpFillRspPst(pst, &rspPst);
-   rspPst.event = EVTTNLMGMTCFM;
-   packEgtpTnlMgmtCfm(&rspPst, tnlEvt);
+   DU_LOG("\nDEBUG   -->  EGTP : Sending Tunnel management confirmation");
+   duHdlEgtpTnlMgmtCfm(tnlEvt);
 
-   return ROK;
+   return ret;
 }
 
 /**************************************************************************
@@ -410,34 +538,34 @@ uint8_t egtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
  * ***************************************************************************/
 uint8_t egtpTnlAdd(EgtpTnlEvt tnlEvt)
 {
-   uint8_t   ret;
-   EgtpTeIdCb   *teidCb;    /* Tunnel endpoint control block */
-   EgtpMsgHdr   preDefHdr; /* pre-define header for this tunnel */
+   uint8_t    ret;
+   EgtpTeIdCb *teidCb;    /* Tunnel endpoint control block */
+   EgtpMsgHdr preDefHdr; /* pre-define header for this tunnel */
 
-   DU_LOG("\nEGTP : Tunnel addition : LocalTeid[%d] Remote Teid[%d]", tnlEvt.lclTeid, tnlEvt.remTeid);
+   DU_LOG("\nINFO   -->  EGTP : Tunnel addition : LocalTeid[%d] Remote Teid[%d]", tnlEvt.lclTeid, tnlEvt.remTeid);
 
    DU_ALLOC(teidCb, sizeof(EgtpTeIdCb));
    if(teidCb == NULLP)
    {
-      DU_LOG("\nEGTP : Memory allocation failed");
+      DU_LOG("\nERROR  -->  EGTP : Memory allocation failed");
       return LCM_REASON_MEM_NOAVAIL;
    }
 
-   memset((uint8_t *)teidCb, 0, sizeof(EgtpTeIdCb));
+   memset(teidCb, 0, sizeof(EgtpTeIdCb));
    teidCb->teId = tnlEvt.lclTeid;
    teidCb->remTeId = tnlEvt.remTeid;
 
    ret = cmHashListInsert(&(egtpCb.dstCb.teIdLst), (PTR)teidCb, (uint8_t *)&(teidCb->teId), sizeof(uint32_t));
    if(ret != ROK)
    {
-      DU_LOG("\nEGTP : Failed to insert in hash list");
+      DU_LOG("\nERROR  -->  EGTP : Failed to insert in hash list");
       DU_FREE(teidCb, sizeof(EgtpTeIdCb));
       return LCM_REASON_HASHING_FAILED;
    }
    egtpCb.dstCb.numTunn++;
 
    /* Encoding pre-defined header */
-   memset((uint8_t*)&preDefHdr, 0, sizeof(EgtpMsgHdr));
+   memset(&preDefHdr, 0, sizeof(EgtpMsgHdr));
    preDefHdr.msgType = EGTPU_MSG_GPDU;
    preDefHdr.teId = teidCb->remTeId;
    preDefHdr.extHdr.pdcpNmb.pres = FALSE;
@@ -466,22 +594,18 @@ uint8_t egtpTnlAdd(EgtpTnlEvt tnlEvt)
  * ***************************************************************************/
 uint8_t egtpTnlMod(EgtpTnlEvt tnlEvt)
 {
-#if 0
-   uint8_t   ret;
    EgtpTeIdCb     *teidCb = NULLP;
 
-   printf("\nTunnel modification : LocalTeid[%d] Remote Teid[%d]", tnlEvt.lclTeid, tnlEvt.remTeid);
+   DU_LOG("\nINFO   -->  EGTP : Tunnel modification : LocalTeid[%d] Remote Teid[%d]", tnlEvt.lclTeid, tnlEvt.remTeid);
 
-   cmHashListFind(&(egtpCb.dstCb.teIdLst), (uint8_t *)&(tnlEvt.teId), sizeof(uint32_t), 0, (PTR *)&teidCb);
+   cmHashListFind(&(egtpCb.dstCb.teIdLst), (uint8_t *)&(tnlEvt.lclTeid), sizeof(uint32_t), 0, (PTR *)&teidCb);
    if(teidCb == NULLP)
    {
-      printf("\nTunnel id not found");
+      DU_LOG("\nERROR  -->  EGTP : Tunnel id not found");
       return RFAILED;
    }  
-   
-   teidCb->teId = tnlEvt.lclTeid;
+   teidCb->teId = tnlEvt.remTeid;
    teidCb->remTeId = tnlEvt.remTeid;
-#endif
    return ROK;
 }
 
@@ -504,19 +628,18 @@ uint8_t egtpTnlDel(EgtpTnlEvt tnlEvt)
 {
    EgtpTeIdCb     *teidCb = NULLP;
 
-   DU_LOG("\nEGTP : Tunnel deletion : Local Teid[%d] Remote Teid[%d]", tnlEvt.lclTeid, tnlEvt.remTeid);
+   DU_LOG("\nINFO   -->  EGTP : Tunnel deletion : Local Teid[%d] Remote Teid[%d]", tnlEvt.lclTeid, tnlEvt.remTeid);
    
    cmHashListFind(&(egtpCb.dstCb.teIdLst), (uint8_t *)&(tnlEvt.lclTeid), sizeof(uint32_t), 0, (PTR *)&teidCb);
    if(teidCb == NULLP)
    {
-      DU_LOG("\nEGTP : Tunnel id[%d] not configured", tnlEvt.lclTeid);
+      DU_LOG("\nERROR  -->  EGTP : Tunnel id[%d] not configured", tnlEvt.lclTeid);
       return LCM_REASON_INVALID_PAR_VAL;
    } 
 
    cmHashListDelete(&(egtpCb.dstCb.teIdLst), (PTR)teidCb);
    DU_FREE(teidCb, sizeof(EgtpTeIdCb));
    egtpCb.dstCb.numTunn--;
-
    return ROK;
 }
 
@@ -539,18 +662,22 @@ uint8_t egtpTnlDel(EgtpTnlEvt tnlEvt)
  * ****************************************************************/
 uint8_t egtpHdlDatInd(EgtpMsg egtpMsg)
 {
-   EgtpTeIdCb   *teidCb = NULLP;
-   uint16_t tPduSize;
+   EgtpTeIdCb  *teidCb = NULLP;
+   uint16_t    tPduSize;
    uint8_t     hdrLen;
    uint32_t    msgLen;
-   EgtpMsgHdr   *msgHdr;
+   EgtpMsgHdr  *msgHdr;
 
-   DU_LOG("\nEGTP : Received Data Indication");
+#ifdef CALL_FLOW_DEBUG_LOG
+   DU_LOG("\nCall Flow: ENTDUAPP -> ENTEGTP : DATA_INDICATION\n");
+#endif
+   
+   DU_LOG("\nDEBUG  -->  EGTP : Received Data Indication");
 
    cmHashListFind(&(egtpCb.dstCb.teIdLst), (uint8_t *)&(egtpMsg.msgHdr.teId), sizeof(uint32_t), 0, (PTR *)&teidCb);
    if(teidCb == NULLP)
    {
-      DU_LOG("\nEGTP : Tunnel id[%d] not configured", egtpMsg.msgHdr.teId);
+      DU_LOG("\nERROR  -->  EGTP : Tunnel id[%d] not configured", egtpMsg.msgHdr.teId);
       return LCM_REASON_INVALID_PAR_VAL;
    }
    
@@ -572,7 +699,7 @@ uint8_t egtpHdlDatInd(EgtpMsg egtpMsg)
       teidCb->preEncodedHdr.hdr[EGTP_MAX_HDR_LEN - 1] &= ~(EGTP_MASK_BIT3);
    }
 
-   ODU_FIND_MSG_LEN(egtpMsg.msg, &tPduSize);
+   ODU_GET_MSG_LEN(egtpMsg.msg, (int16_t *)&tPduSize);
 
    /*Adjust the header to fill the correct length*/
    msgLen = tPduSize +  (EGTP_MAX_HDR_LEN - hdrLen) - 0x08;
@@ -595,18 +722,18 @@ uint8_t egtpHdlDatInd(EgtpMsg egtpMsg)
       teidCb->preEncodedHdr.hdr[EGTP_MAX_HDR_LEN - 1] &= ~(EGTP_MASK_BIT2);
    }
 
-   DU_LOG("\nEGTP : UL Data buffer before encoding header");
+   DU_LOG("\nDEBUG  -->  EGTP : UL Data buffer before encoding header");
    ODU_PRINT_MSG(egtpMsg.msg, 0, 0);
 
    ODU_ADD_PRE_MSG_MULT(&teidCb->preEncodedHdr.hdr[hdrLen], (EGTP_MAX_HDR_LEN - hdrLen), egtpMsg.msg);
 
 
-   DU_LOG("\nEGTP : UL Data buffer after encoding header");
+   DU_LOG("\nDEBUG  -->  EGTP : UL Data buffer after encoding header");
    ODU_PRINT_MSG(egtpMsg.msg, 0, 0);
 
    /* Send over UDP */
    egtpSendMsg(egtpMsg.msg);
-   ODU_PUT_MSG(egtpMsg.msg);
+   ODU_PUT_MSG_BUF(egtpMsg.msg);
 
    return ROK;
 }/* EgtpHdlDatInd */
@@ -630,10 +757,10 @@ uint8_t egtpHdlDatInd(EgtpMsg egtpMsg)
  * ****************************************************************/
 uint8_t egtpEncodeHdr(uint8_t *preEncodedHdr, EgtpMsgHdr *preDefHdr, uint8_t *hdrIdx)
 {
-   uint8_t         tmpByte = 0;                 /* Stores one byte of data for enc */
-   uint8_t         cnt     = EGTP_MAX_HDR_LEN;  /* Stores the position */
+   uint8_t    tmpByte = 0;                 /* Stores one byte of data for enc */
+   uint8_t    cnt     = EGTP_MAX_HDR_LEN;  /* Stores the position */
    bool       extPres = FALSE;             /* Flag for indication of S, E or P presense flag */
-   uint16_t        nwWord = 0;
+   uint16_t   nwWord = 0;
    
    /* Encoding header */
    tmpByte |= EGTP_MASK_BIT6;   /* Setting 6th LSB of 1st byte as version */
@@ -741,51 +868,34 @@ uint8_t egtpEncodeHdr(uint8_t *preEncodedHdr, EgtpMsgHdr *preDefHdr, uint8_t *hd
  * ****************************************************************/
 uint8_t egtpSendMsg(Buffer *mBuf)
 {
-   uint8_t            ret;
-   uint16_t         txLen;
+   uint8_t        ret;
+   uint16_t       txLen;
    CmInetMemInfo  info;
    CmInetAddr     dstAddr;
+   static uint64_t numDataSent = 0;
 
    info.region = DU_APP_MEM_REGION;
    info.pool = DU_POOL;
 
-   dstAddr.port = EGTP_DFLT_PORT;
+   dstAddr.port = EGTP_RECVR_PORT;
    dstAddr.address = egtpCb.dstCb.dstIp;
 
-   ret = cmInetSendMsg(&(egtpCb.dstCb.sendTptSrvr.sockFd), &dstAddr, &info, mBuf, &txLen, CM_INET_NO_FLAG);
+   ret = cmInetSendMsg(&(egtpCb.dstCb.sendTptSrvr.sockFd), &dstAddr, &info, \
+      mBuf, (int16_t *)&txLen, CM_INET_NO_FLAG);
    if(ret != ROK && ret != RWOULDBLOCK)
    {
-      DU_LOG("\nEGTP : Failed sending the message");
+      DU_LOG("\nERROR  -->  EGTP : Failed sending the message");
       return RFAILED;
    }
-
-   DU_LOG("\nEGTP : Message Sent");
+   else
+   {
+      DU_LOG("\nDEBUG -->  EGTP : Sent UL Message [%ld]", numDataSent+1);
+      numDataSent++;
+   }
 
    return ROK;
 }
 
-/*******************************************************************
- *
- * @brief Handles Slot Indication from PHY
- *
- * @details
- *
- *    Function : egtpSlotInd
- *
- *    Functionality:
- *       Handles TTI Indication from PHY
- *
- * @params[in] 
- * @return ROK     - success
- *         RFAILED - failure
- *
- * ****************************************************************/
-uint8_t egtpSlotInd()
-{
-   egtpRecvMsg();
-   return ROK;
-}
-
 /*******************************************************************
  *
  * @brief Receives EGTP message from UDP socket 
@@ -805,39 +915,51 @@ uint8_t egtpSlotInd()
 
 uint8_t egtpRecvMsg()
 {
-   uint8_t             ret;           /* Return value */
-   uint8_t             nMsg;          /* Number of messages to read from UDP socked */
-   uint16_t         bufLen;        /* Length of received buffer */
+   uint8_t        ret;           /* Return value */
+   uint16_t       bufLen;        /* Length of received buffer */
    Buffer         *recvBuf;      /* Received buffer */
    CmInetAddr     fromAddr;      /* Egtp data sender address */
    CmInetMemInfo  memInfo;       /* Buffer allocation info */
 
-
-   DU_LOG("\nEGTP : Received Slot Indication");
-
-   nMsg = 0;
    memInfo.region = DU_APP_MEM_REGION;
    memInfo.pool   = DU_POOL;
     
    fromAddr.port = egtpCb.dstCb.dstPort;
    fromAddr.address = egtpCb.dstCb.dstIp;
 
-   while(nMsg < EGTP_MAX_MSG_RECV)
+   while(true)
    {
       bufLen = -1;
-      ret = cmInetRecvMsg(&(egtpCb.recvTptSrvr.sockFd), &fromAddr, &memInfo, &recvBuf, &bufLen, CM_INET_NO_FLAG);
+      ret = cmInetRecvMsg(&(egtpCb.recvTptSrvr.sockFd), &fromAddr, &memInfo, \
+         &recvBuf, (int16_t *)&bufLen, CM_INET_NO_FLAG);
       if(ret == ROK && recvBuf != NULLP)
       {  
-         DU_LOG("\nEGTP : Received DL Message[%d]\n", nMsg+1);
-         ODU_PRINT_MSG(recvBuf, 0 ,0);
+         DU_LOG("\nDEBUG  -->  EGTP : Received DL Message[%ld]\n", gDlDataRcvdCnt + 1);
+         //ODU_PRINT_MSG(recvBuf, 0 ,0);
          egtpHdlRecvData(recvBuf);
+         gDlDataRcvdCnt++;
+         
       }
-      nMsg++;
    }
    
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Handles DL User data received from CU
+ *
+ * @details
+ *
+ *    Function : egtpHdlRecvData
+ *
+ *    Functionality: Handles DL User data received from CU
+ *
+ * @params[in] DL Usre data buffer
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
 uint8_t egtpHdlRecvData(Buffer *mBuf)
 {
    EgtpMsg  egtpMsg;
@@ -851,17 +973,32 @@ uint8_t egtpHdlRecvData(Buffer *mBuf)
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Decodes EGTP header from DL User data
+ *
+ * @details
+ *
+ *    Function : egtpDecodeHdr
+ *
+ *    Functionality: Decodes EGTP header from DL User data
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
 uint8_t egtpDecodeHdr(Buffer *mBuf, EgtpMsg  *egtpMsg)
 {
-   uint8_t       tmpByte[5];         /* Holds 5 byte of data after Decoding */
-   uint8_t       version = 0;         /* Holds the version type, decoded */
+   uint8_t    tmpByte[5];         /* Holds 5 byte of data after Decoding */
+   uint8_t    version = 0;         /* Holds the version type, decoded */
    uint16_t   msgLen  = 0;         /* Holds the msgLen from the Hdr */
    uint16_t   bufLen  = 0;         /* Holds the total buffer length */
-   uint8_t       extHdrType = 0;       /* Holds the Extension hdr type */
-   uint8_t       extHdrLen = 0;        /* Extension hdr length */
-   bool     extPres = FALSE;      /* Flag for indication of S, E or P presense flag */
+   uint8_t    extHdrType = 0;       /* Holds the Extension hdr type */
+   uint8_t    extHdrLen = 0;        /* Extension hdr length */
+   bool       extPres = FALSE;      /* Flag for indication of S, E or P presense flag */
  
-   ODU_FIND_MSG_LEN(mBuf, &bufLen);
+   ODU_GET_MSG_LEN(mBuf, (int16_t *)&bufLen);
  
    /* Decode first byte and storing in temporary variable */
    ODU_REM_PRE_MSG(&tmpByte[0], mBuf);
@@ -869,11 +1006,11 @@ uint8_t egtpDecodeHdr(Buffer *mBuf, EgtpMsg  *egtpMsg)
    /* Extracting version fro 1st byte */
    version = tmpByte[0] >> 5;
    
-   DU_LOG("\nEGTP : Version %d", version);
+   //DU_LOG("\nDEBUG   -->  EGTP : Version %d", version);
  
    /* Decode message type */
    ODU_REM_PRE_MSG((Data*)&(egtpMsg->msgHdr.msgType), mBuf);
-   DU_LOG("\nEGTP : msgType %d", egtpMsg->msgHdr.msgType);
+   //DU_LOG("\nDEBUG   -->  EGTP : msgType %d", egtpMsg->msgHdr.msgType);
 
    /****************************************************************************
     * Message length param is 2 bytes. So decode next 2 bytes from msg hdr and
@@ -882,7 +1019,9 @@ uint8_t egtpDecodeHdr(Buffer *mBuf, EgtpMsg  *egtpMsg)
    ODU_REM_PRE_MSG(&tmpByte[1], mBuf);
    ODU_REM_PRE_MSG(&tmpByte[2], mBuf);
    msgLen = (tmpByte[1] << 8) | tmpByte[2];
-   DU_LOG("\nEGTP : msgLen %d", msgLen);
+   UNUSED(msgLen);
+   UNUSED(version);
+   //DU_LOG("\nDEBUG   -->  EGTP : msgLen %d", msgLen);
 
 
    /****************************************************************************
@@ -894,7 +1033,7 @@ uint8_t egtpDecodeHdr(Buffer *mBuf, EgtpMsg  *egtpMsg)
    ODU_REM_PRE_MSG(&tmpByte[3], mBuf);
    ODU_REM_PRE_MSG(&tmpByte[4], mBuf);
    egtpMsg->msgHdr.teId = (tmpByte[1] << 24) | (tmpByte[2] << 16) | (tmpByte[3] << 8) | tmpByte[4];
-   DU_LOG("\nEGTP : teId %d",egtpMsg->msgHdr.teId);
+   //DU_LOG("\nDEBUG   -->  EGTP : teId %d",egtpMsg->msgHdr.teId);
 
 
    /* If any one of S, E or PN flag is set, set extension present as true. */
@@ -1006,11 +1145,14 @@ uint8_t egtpDecodeHdr(Buffer *mBuf, EgtpMsg  *egtpMsg)
 
    egtpMsg->msg = mBuf;
 
-   DU_LOG("\nEGTP : DL Data Buffer after decoding header ");
-   ODU_PRINT_MSG(mBuf, 0, 0);
+   //DU_LOG("\nDEBUG   -->  EGTP : DL Data Buffer after decoding header ");
+   //ODU_PRINT_MSG(mBuf, 0, 0);
 
    /* Forward the data to duApp/RLC */
  
    return ROK;
 
 }
+/**********************************************************************
+         End of file
+**********************************************************************/