/* This file contains all EGTP related functionality */
#include "common_def.h"
+#include "OCTET_STRING.h"
+#include "cu_stub_sctp.h"
+#include "cu_f1ap_msg_hdl.h"
#include "cu_stub_egtp.h"
-#include "du_log.h"
-
-/* Global variable declaration */
-EgtpGlobalCb egtpCb;
+#include "cu_stub.h"
+#include "cm_inet.h"
+#include "cm_tpt.h"
+
+#include "cm_inet.x"
+#include "cm_tpt.x"
/**************************************************************************
* @brief Task Initiation callback function.
{
DU_LOG("\n\nDEBUG --> EGTP : Initializing");
memset (&egtpCb, 0, sizeof(EgtpGlobalCb));
+
+ //Initializing with INVALID value
+ memset(egtpCb.gCntPdu, 0xFF , sizeof(uint8_t)*(MAX_TEID+1));
protType = CM_INET_PROTO_UDP;
return ROK;
}
uint8_t egtpInitReq()
{
uint8_t ret = ROK;
- EgtpTnlEvt tnlEvt;
ret = cuEgtpCfgReq();
if(ret != ROK)
return (ret);
}
- tnlEvt.action = EGTP_TNL_MGMT_ADD;
- tnlEvt.lclTeid = 10;
- tnlEvt.remTeid = 1;
- ret = cuEgtpTnlMgmtReq(tnlEvt);
- if(ret != ROK)
- {
- DU_LOG("\nERROR --> EGTP : Tunnel management request failed");
- return RFAILED;
- }
-
return ret;
} /* egtpInitReq */
{
uint8_t ret;
- memcpy(&egtpCb.egtpCfg, &cuCfgParams.egtpParams, sizeof(EgtpParams));
+ memcpy(&egtpCb.egtpCfg, &cuCb.cuCfgParams.egtpParams, sizeof(EgtpParams));
egtpCb.recvTptSrvr.addr.address = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.localIp.ipV4Addr);
egtpCb.recvTptSrvr.addr.port = EGTP_DFLT_PORT;
preDefHdr.teId = teidCb->remTeId;
preDefHdr.extHdr.pdcpNmb.pres = FALSE;
preDefHdr.extHdr.udpPort.pres = FALSE;
- preDefHdr.nPdu.pres = FALSE;
-
+ preDefHdr.nPdu.pres = TRUE; //Including nPdu when sending data
+ preDefHdr.nPdu.val = 0;
+
cuEgtpEncodeHdr((uint8_t *)teidCb->preEncodedHdr.hdr, &preDefHdr, &(teidCb->preEncodedHdr.cnt));
+ egtpCb.gCntPdu[teidCb->remTeId] = 0;//Resetting the Cnt Value for this DRB which indicates its creation
/* SPutSBuf(CU_APP_MEM_REG, CU_POOL, (Data *)teidCb, (Size)sizeof(EgtpTeIdCb));*/
S16 cuEgtpHdlRecvMsg(Buffer *mBuf)
{
/*Decoding of EGTP message header */
+
cuEgtpDecodeHdr(mBuf);
-
+
/* Start Pumping data from CU to DU */
//return (cuEgtpDatReq());
ODU_REM_PRE_MSG(&extHdrType, mBuf);
}
- DU_LOG("\nDEBUG --> EGTP : Message Buffer after decoding header ");
+ DU_LOG("\nDEBUG --> EGTP : Message Buffer after decoding header [TEID:%d]",egtpMsg.msgHdr.teId);
ODU_PRINT_MSG(mBuf, 0, 0);
+ SPutMsg(mBuf);
+
return ROK;
} /* End of cuEgtpDecodeHdr */
-S16 cuEgtpDatReq()
+uint16_t cuEgtpDatReq(uint8_t teId)
{
- uint8_t cnt = 0;
+ uint8_t ret = ROK, cnt = 0;
EgtpMsg egtpMsg;
+ egtpMsg.msgHdr.teId = teId;
+
+ if(egtpCb.gCntPdu[teId] == 0xFF) //DRB not created
+ {
+ DU_LOG("\nERROR --> EGTP : DRB not created");
+ return RFAILED ;
+ }
/* Build Application message that is supposed to come from app to egtp */
- BuildAppMsg(&egtpMsg);
+ ret = BuildAppMsg(&egtpMsg);
+ if(ret != ROK)
+ {
+ DU_LOG("\nERROR --> EGTP : Failed to build App Msg");
+ return RFAILED;
+ }
/* Encode EGTP header to build final EGTP message */
- BuildEgtpMsg(&egtpMsg);
-
- /* Send Message to peer */
- while(cnt < 200)
+ ret = BuildEgtpMsg(&egtpMsg);
+ if(ret != ROK)
{
- DU_LOG("\nDEBUG --> EGTP : Sending message[%d]", cnt+1);
- cuEgtpSendMsg(egtpMsg.msg);
- cnt++;
+ DU_LOG("\nERROR --> EGTP : Failed to build EGTP Msg");
+ return RFAILED;
}
-
+ cuEgtpSendMsg(egtpMsg.msg);
ODU_PUT_MSG_BUF(egtpMsg.msg);
return ROK;
S16 BuildAppMsg(EgtpMsg *egtpMsg)
{
- char data[30] = "This is EGTP data from CU";
- int datSize = 30;
+ char data[1215] = "In telecommunications, 5G is the fifth generation technology standard for broadband cellular"
+ " networks, which cellular phone companies began deploying worldwide in 2019, and is the planned successor to the 4G "
+ " networks which provide connectivity to most current cellphones. 5G networks are predicted to have more than 1.7"
+ " billion subscribers worldwide by 2025, according to the GSM Association.Like its predecessors, 5G networks are"
+ " cellular networks,in which the service area is divided into small geographical areas called cells.All 5G wireless"
+ " devices in a cell are connected to the Internet and telephone network by radio waves through local antenna in the"
+ " cell. The main advantage of the new networks is that they will have greater bandwidth, giving higher download"
+ " speeds, eventually up to 10 gigabits per second(Gbit/s). Due to the increased bandwidth, it is expected the"
+ " networks will not exclusively serve cellphones like existing cellular networks, but also be used as general"
+ " internet service providers for laptops and desktop computers, competing with existing ISPs such as cable"
+ " internet, and also will make possible new applications in internet of things (IoT) and machine to machine areas.";
+
+ int datSize = 1215;
Buffer *mBuf;
ret = ODU_ADD_PRE_MSG_MULT(revPkArray, (MsgLen)cnt, mBuf);
egtpMsg->msgHdr.msgType = EGTPU_MSG_GPDU;
- egtpMsg->msgHdr.nPdu.pres = FALSE;
+ egtpMsg->msgHdr.nPdu.pres = TRUE;
+
+ if(egtpCb.gCntPdu[egtpMsg->msgHdr.teId] != NUM_DL_PACKETS)
+ egtpCb.gCntPdu[egtpMsg->msgHdr.teId]++;
+ else
+ egtpCb.gCntPdu[egtpMsg->msgHdr.teId] = 1;
+
+ egtpMsg->msgHdr.nPdu.val = egtpCb.gCntPdu[egtpMsg->msgHdr.teId];
egtpMsg->msgHdr.seqNum.pres = FALSE;
egtpMsg->msgHdr.extHdr.udpPort.pres = FALSE;
egtpMsg->msgHdr.extHdr.pdcpNmb.pres = FALSE;
- egtpMsg->msgHdr.teId = 10;
egtpMsg->msg = mBuf;
return ret;
}
-
S16 BuildEgtpMsg(EgtpMsg *egtpMsg)
{
EgtpTeIdCb *teidCb = NULLP;
teidCb->preEncodedHdr.hdr[EGTP_MAX_HDR_LEN - 1] &= ~(EGTP_MASK_BIT2);
}
- ODU_ADD_PRE_MSG_MULT(&teidCb->preEncodedHdr.hdr[hdrLen], (EGTP_MAX_HDR_LEN - hdrLen), egtpMsg->msg);
-
- DU_LOG("\nDEBUG --> EGTP : Sending message buffer");
- ODU_PRINT_MSG(egtpMsg->msg, 0, 0);
+ /*Update the nPdU number*/
+ if(egtpMsg->msgHdr.nPdu.pres)
+ {
+ teidCb->preEncodedHdr.hdr[EGTP_MAX_HDR_LEN - 1] |= (EGTP_MASK_BIT1);
+ teidCb->preEncodedHdr.hdr[EGTP_MAX_HDR_LEN - 11] = egtpMsg->msgHdr.nPdu.val;
+ }
+ else
+ {
+ teidCb->preEncodedHdr.hdr[EGTP_MAX_HDR_LEN - 1] &= ~(EGTP_MASK_BIT1);
+ }
+ ODU_ADD_PRE_MSG_MULT(&teidCb->preEncodedHdr.hdr[hdrLen], (EGTP_MAX_HDR_LEN - hdrLen), egtpMsg->msg);
return ROK;
}