X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcu_stub%2Fcu_stub_egtp.c;h=4ccdf511ad72d3f83f7730647571e4620ab96573;hb=d6b8cf5c9afbba0fada62efd626d56cb59c1e839;hp=ba51369906b8c861fb9e622c323cb6024edc499f;hpb=38ebc92a011353b8b2d9401efa4173c79114fa1c;p=o-du%2Fl2.git diff --git a/src/cu_stub/cu_stub_egtp.c b/src/cu_stub/cu_stub_egtp.c index ba5136990..4ccdf511a 100644 --- a/src/cu_stub/cu_stub_egtp.c +++ b/src/cu_stub/cu_stub_egtp.c @@ -123,16 +123,14 @@ S16 cuEgtpCfgReq() memcpy(&egtpCb.egtpCfg, &cuCb.cuCfgParams.egtpParams, sizeof(CuEgtpParams)); + egtpCb.localAddr.address = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.localIp.ipV4Addr); + egtpCb.localAddr.port = egtpCb.egtpCfg.localPort; + for(destIdx=0; destIdx < egtpCb.egtpCfg.numDu; destIdx++) { - egtpCb.recvTptSrvr.addr.address = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.egtpAssoc[destIdx].localIp.ipV4Addr); - egtpCb.recvTptSrvr.addr.port = EGTP_RECVR_PORT; - egtpCb.dstCb[destIdx].duId = destIdx+1; - egtpCb.dstCb[destIdx].dstIp = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.egtpAssoc[destIdx].destIp.ipV4Addr); - egtpCb.dstCb[destIdx].dstPort = egtpCb.egtpCfg.egtpAssoc[destIdx].destPort; - egtpCb.dstCb[destIdx].sendTptSrvr.addr.address = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.egtpAssoc[destIdx].localIp.ipV4Addr); - egtpCb.dstCb[destIdx].sendTptSrvr.addr.port = egtpCb.egtpCfg.egtpAssoc[destIdx].localPort; + egtpCb.dstCb[destIdx].dstAddr.address = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.dstCfg[destIdx].dstIp.ipV4Addr); + egtpCb.dstCb[destIdx].dstAddr.port = egtpCb.egtpCfg.dstCfg[destIdx].dstPort; egtpCb.dstCb[destIdx].numTunn = 0; ret = cmHashListInit(&(egtpCb.dstCb[destIdx].teIdLst), 1024, sizeof(EgtpTeIdCb), FALSE, CM_HASH_KEYTYPE_UINT32_MOD, CU_APP_MEM_REG, CU_POOL); @@ -177,39 +175,20 @@ S16 cuEgtpSrvOpenReq(Pst *pst) DU_LOG("\nINFO --> EGTP : Received open server request"); sockType = CM_INET_DGRAM; - if((ret = (cmInetSocket(sockType, &(egtpCb.recvTptSrvr.sockFd), protType))) != ROK) + if((ret = (cmInetSocket(sockType, &(egtpCb.sockFd), protType))) != ROK) { DU_LOG("\nERROR --> EGTP : Failed to open UDP socket"); return RFAILED; } - ret = cmInetBind(&(egtpCb.recvTptSrvr.sockFd), &(egtpCb.recvTptSrvr.addr)); + ret = cmInetBind(&(egtpCb.sockFd), &(egtpCb.localAddr)); if(ret != ROK) { DU_LOG("\nERROR --> EGTP : Failed to bind socket"); return RFAILED; } - - for(destIdx=0; destIdx < egtpCb.egtpCfg.numDu; destIdx++) - { - if(ret = (cmInetSocket(sockType, &(egtpCb.dstCb[destIdx].sendTptSrvr.sockFd), protType)) != ROK) - { - DU_LOG("\nERROR --> EGTP : Failed to open UDP socket"); - return RFAILED; - } - ret = cmInetBind(&(egtpCb.dstCb[destIdx].sendTptSrvr.sockFd), &(egtpCb.dstCb[destIdx].sendTptSrvr.addr)); - if(ret != ROK) - { - DU_LOG("\nERROR --> EGTP : Failed to bind socket"); - return RFAILED; - } - - /* TODO: set socket options */ - - DU_LOG("\nINFO --> EGTP : Receiver socket[%d] and Sender socket[%d] open", egtpCb.recvTptSrvr.sockFd.fd,\ - egtpCb.dstCb[destIdx].sendTptSrvr.sockFd.fd); - } + DU_LOG("\nINFO --> EGTP : Socket[%d] is open", egtpCb.sockFd.fd); return ROK; } /* cuEgtpSrvOpenReq */ @@ -295,7 +274,6 @@ S16 cuEgtpTnlAdd(uint32_t duId, EgtpTnlEvt tnlEvt) return RFAILED; } - memset(teidCb, 0, sizeof(EgtpTeIdCb)); teidCb->teId = tnlEvt.lclTeid; teidCb->remTeId = tnlEvt.remTeid; @@ -687,9 +665,9 @@ S16 cuEgtpDecodeHdr(Buffer *mBuf) * RFAILED - failure * * ****************************************************************/ -uint16_t cuEgtpDatReq(uint8_t teId) +uint16_t cuEgtpDatReq(uint32_t duId, uint8_t teId) { - uint8_t ret = ROK, cnt = 0, duId =0; + uint8_t ret = ROK, cnt = 0; EgtpMsg egtpMsg; egtpMsg.msgHdr.teId = teId; @@ -699,26 +677,23 @@ uint16_t cuEgtpDatReq(uint8_t teId) DU_LOG("\nERROR --> EGTP : DRB not created"); return RFAILED ; } - for(duId = 1; duId<=egtpCb.numDu; duId++) + /* Build Application message that is supposed to come from app to egtp */ + ret = BuildAppMsg(duId, &egtpMsg); + if(ret != ROK) { - /* Build Application message that is supposed to come from app to egtp */ - ret = BuildAppMsg(duId, &egtpMsg); - if(ret != ROK) - { - DU_LOG("\nERROR --> EGTP : Failed to build App Msg"); - return RFAILED; - } + DU_LOG("\nERROR --> EGTP : Failed to build App Msg"); + return RFAILED; + } - /* Encode EGTP header to build final EGTP message */ - ret = BuildEgtpMsg(duId, &egtpMsg); - if(ret != ROK) - { - DU_LOG("\nERROR --> EGTP : Failed to build EGTP Msg"); - return RFAILED; - } - cuEgtpSendMsg(duId, egtpMsg.msg); - ODU_PUT_MSG_BUF(egtpMsg.msg); + /* Encode EGTP header to build final EGTP message */ + ret = BuildEgtpMsg(duId, &egtpMsg); + if(ret != ROK) + { + DU_LOG("\nERROR --> EGTP : Failed to build EGTP Msg"); + return RFAILED; } + cuEgtpSendMsg(duId, egtpMsg.msg); + ODU_PUT_MSG_BUF(egtpMsg.msg); return ROK; } @@ -784,8 +759,8 @@ S16 BuildAppMsg(uint32_t duId, EgtpMsg *egtpMsg) ipv4Hdr.length = CM_IPV4_HDRLEN + mLen; ipv4Hdr.hdrVer = 0x45; ipv4Hdr.proto = 1; - ipv4Hdr.srcAddr = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.egtpAssoc[duId-1].localIp.ipV4Addr); - ipv4Hdr.destAddr = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.egtpAssoc[duId-1].destIp.ipV4Addr); + ipv4Hdr.srcAddr = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.localIp.ipV4Addr); + ipv4Hdr.destAddr = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.dstCfg[duId-1].dstIp.ipV4Addr); /* Packing IPv4 header into buffer */ S16 ret, cnt, idx; @@ -969,15 +944,11 @@ S16 cuEgtpSendMsg(uint32_t duId, Buffer *mBuf) S16 ret; MsgLen txLen; CmInetMemInfo info; - CmInetAddr dstAddr; info.region = CU_APP_MEM_REG; info.pool = CU_POOL; - dstAddr.port = EGTP_RECVR_PORT; - dstAddr.address = egtpCb.dstCb[duId-1].dstIp; - - ret = cmInetSendMsg(&(egtpCb.dstCb[duId-1].sendTptSrvr.sockFd), &dstAddr, &info, mBuf, &txLen, CM_INET_NO_FLAG); + ret = cmInetSendMsg(&(egtpCb.sockFd), &egtpCb.dstCb[duId-1].dstAddr, &info, mBuf, &txLen, CM_INET_NO_FLAG); if(ret != ROK && ret != RWOULDBLOCK) { DU_LOG("\nERROR --> EGTP : Message send failure");