X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcu_stub%2Fcu_stub_egtp.c;h=65f19a27e0d9711eca8faed668c80baa4fec5c7f;hb=8133a1985d2c53074af88c44edfb9231af64b433;hp=2a0e79c031d4ab933294b3d0957803bebebeb112;hpb=5638504e06269c208f2006868788ebc9a8a626c9;p=o-du%2Fl2.git diff --git a/src/cu_stub/cu_stub_egtp.c b/src/cu_stub/cu_stub_egtp.c index 2a0e79c03..65f19a27e 100644 --- a/src/cu_stub/cu_stub_egtp.c +++ b/src/cu_stub/cu_stub_egtp.c @@ -19,12 +19,12 @@ /* This file contains all EGTP related functionality */ #include "common_def.h" +#include "cu_f1ap_msg_hdl.h" #include "cu_stub_egtp.h" #include "du_log.h" /* Global variable declaration */ EgtpGlobalCb egtpCb; - /************************************************************************** * @brief Task Initiation callback function. * @@ -49,6 +49,9 @@ S16 egtpActvInit() { 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; } @@ -76,7 +79,6 @@ S16 egtpActvInit() uint8_t egtpInitReq() { uint8_t ret = ROK; - EgtpTnlEvt tnlEvt; ret = cuEgtpCfgReq(); if(ret != ROK) @@ -92,16 +94,6 @@ uint8_t egtpInitReq() 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 */ @@ -309,9 +301,11 @@ S16 cuEgtpTnlAdd(EgtpTnlEvt tnlEvt) 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));*/ @@ -503,8 +497,9 @@ S16 cuEgtpEncodeHdr(uint8_t *preEncodedHdr, EgtpMsgHdr *preDefHdr, uint8_t *hdrI S16 cuEgtpHdlRecvMsg(Buffer *mBuf) { /*Decoding of EGTP message header */ + cuEgtpDecodeHdr(mBuf); - + /* Start Pumping data from CU to DU */ //return (cuEgtpDatReq()); @@ -618,32 +613,41 @@ S16 cuEgtpDecodeHdr(Buffer *mBuf) 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); 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; @@ -652,8 +656,19 @@ S16 cuEgtpDatReq() 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; @@ -742,17 +757,22 @@ S16 BuildAppMsg(EgtpMsg *egtpMsg) 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; @@ -809,11 +829,18 @@ S16 BuildEgtpMsg(EgtpMsg *egtpMsg) 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; }