From: svaidhya Date: Thu, 16 May 2024 05:22:51 +0000 (+0530) Subject: [Epic-Id: ODUHIGH-576][Task-Id: ODUHIGH-594][SubTask-Id: ODUHIGH-598]|[NFAPI_Branch... X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=e4e5d2c34262dc642975a8cd81243104ef459d33;p=o-du%2Fl2.git [Epic-Id: ODUHIGH-576][Task-Id: ODUHIGH-594][SubTask-Id: ODUHIGH-598]|[NFAPI_Branch]| UDP Socket Creation and Initiation Change-Id: Ieabeb69ea6cb92b4630552258cb86279cd51f727 Signed-off-by: svaidhya --- diff --git a/build/config/fdd_odu_config.xml b/build/config/fdd_odu_config.xml index 0732b0315..fa9a6f421 100644 --- a/build/config/fdd_odu_config.xml +++ b/build/config/fdd_odu_config.xml @@ -30,6 +30,10 @@ 2152 1 + + 6789 + 9876 + diff --git a/build/config/tdd_odu_config.xml b/build/config/tdd_odu_config.xml index 798e7bc6d..a2cfab87b 100644 --- a/build/config/tdd_odu_config.xml +++ b/build/config/tdd_odu_config.xml @@ -30,6 +30,10 @@ 2152 1 + + 6789 + 9876 + diff --git a/src/5gnrmac/lwr_mac_ex_ms.c b/src/5gnrmac/lwr_mac_ex_ms.c index 4f2867223..41077f5b7 100644 --- a/src/5gnrmac/lwr_mac_ex_ms.c +++ b/src/5gnrmac/lwr_mac_ex_ms.c @@ -283,6 +283,7 @@ uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf) return RFAILED; } sendEventToNfapiVnfFsm(msgType, &p5Hdr, &msgHdr, mBuf); + ODU_PUT_MSG_BUF(mBuf); break; } #endif diff --git a/src/5gnrmac/nfapi_common.c b/src/5gnrmac/nfapi_common.c index 39dcedff7..1330837ad 100644 --- a/src/5gnrmac/nfapi_common.c +++ b/src/5gnrmac/nfapi_common.c @@ -22,8 +22,8 @@ #include "common_def.h" #include "mac_utils.h" #include "lwr_mac.h" -#include "nfapi_vnf_fsm.h" #include "nfapi_interface.h" +#include "nfapi_vnf_fsm.h" #include "nfapi_common.h" /********************************************************************************* diff --git a/src/5gnrmac/nfapi_common.h b/src/5gnrmac/nfapi_common.h index 0cb816c27..22f843cd2 100644 --- a/src/5gnrmac/nfapi_common.h +++ b/src/5gnrmac/nfapi_common.h @@ -31,6 +31,80 @@ #define NFAPI_MORE_SEG_NUM(_moreField, _segStart) ((_moreField << 7) | (_segStart & 0x07)) +#define NFAPI_UDP_P7_MEM_REGION 5 +#define NFAPI_UDP_P7_POOL 1 +#define NFAPI_UDP_P7_INST 0 +#define NFAPI_UDP_P7_PROC 0 +#define EVTSTARTNFAPIP7POLL 2 + +#ifdef ODU_MEMORY_DEBUG_LOG +#define NFAPI_UDP_P7_MEM_LOG(_macro, _file, _line, _func, _size, _datPtr)\ +{\ + printf("\n%s,=== %s +%d, %s, %lu, %p \n", \ + _macro, _file, _line, _func, (uint64_t)_size, _datPtr); \ +} +#else +#define NFAPI_UDP_P7_MEM_LOG(_macro, _file, _line, _func, _size, _dataPtr) {} +#endif + +/* allocate and zero out a NFAPI_UDP_P7 static buffer */ +#define NFAPI_UDP_P7_ALLOC(_datPtr, _size) \ +{ \ + uint8_t _ret; \ + _ret = SGetSBuf(NFAPI_UDP_P7_MEM_REGION, NFAPI_UDP_P7_POOL, \ + (Data **)&_datPtr, _size); \ + if(_ret == ROK) \ + { \ + memset(_datPtr, 0, _size); \ + NFAPI_UDP_P7_MEM_LOG("NFAPI_UDP_P7,ALLOC", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\ + } \ + else \ + { \ + _datPtr = NULLP; \ + } \ +} + +/* free a static buffer */ +#define NFAPI_UDP_P7_FREE(_datPtr, _size) \ +{ \ + if(_datPtr) \ + { \ + NFAPI_UDP_P7_MEM_LOG("NFAPI_UDP_P7,FREE", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\ + SPutSBuf(NFAPI_UDP_P7_MEM_REGION, NFAPI_UDP_P7_POOL, \ + (Data *)_datPtr, _size); \ + _datPtr = NULLP; \ + } \ +} + +/* Allocate shared memory to be used for LWLC + * during inter-layer communication */ +#define NFAPI_UDP_P7_ALLOC_SHRABL_BUF(_buf, _size) \ +{ \ + if(SGetStaticBuffer(NFAPI_UDP_P7_MEM_REGION, NFAPI_UDP_P7_POOL, \ + (Data **)&_buf, (Size) _size, 0) == ROK) \ + { \ + NFAPI_UDP_P7_MEM_LOG("NFAPI_UDP_P7,ALLOC_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\ + memset((_buf), 0, _size); \ + } \ + else \ + { \ + (_buf) = NULLP; \ + } \ +} + +/* Free shared memory, received through LWLC */ +#define NFAPI_UDP_P7_FREE_SHRABL_BUF(_region, _pool,_buf, _size) \ +{ \ + if (_buf != NULLP) \ + { \ + NFAPI_UDP_P7_MEM_LOG("NFAPI_UDP_P7,FREE_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\ + (Void) SPutStaticBuffer(_region, _pool, \ + (Data *) _buf, (Size) _size, 0); \ + _buf = NULLP; \ + } \ +} + + /*Common Functions*/ void nfapiFillP5Hdr(Buffer *mBuf); void nfapiFillMsgHdr(Buffer *mBuf, uint8_t phyId, uint16_t msgId, uint32_t msglen); @@ -39,4 +113,6 @@ void nFapiExtractP5Hdr(nFapi_p5_hdr *p5Hdr, Buffer *mBuf); void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf); NfapiPnfEvent convertNfapiP5TagValToMsgId(uint16_t tagVal); +uint8_t nfapiP7UdpRecvMsg(); + #endif diff --git a/src/5gnrmac/nfapi_udp_p7.c b/src/5gnrmac/nfapi_udp_p7.c index 13c6b3011..b3f93ed82 100644 --- a/src/5gnrmac/nfapi_udp_p7.c +++ b/src/5gnrmac/nfapi_udp_p7.c @@ -19,6 +19,10 @@ /* This file is the entry point for UDP P7 */ #include "common_def.h" +#include "du_app_p7udp_inf.h" +#include "nfapi_interface.h" +#include "nfapi_vnf_fsm.h" +#include "nfapi_common.h" /************************************************************************** * @brief Task Initiation callback function. @@ -68,5 +72,308 @@ uint8_t udpP7ActvInit(Ent entity, Inst inst, Region region, Reason reason) uint8_t udpP7ActvTsk(Pst *pst, Buffer *mBuf) { uint8_t ret = ROK; + + switch(pst->srcEnt) + { + case ENTDUAPP: + { + switch(pst->event) + { + case EVENT_NFAPI_P7_UDP_CFG: + { + unpackDuNfapiP7UdpCfg(NfapiProcP7UdpCfg, pst, mBuf); + break; + } + default: + { + DU_LOG("\nERROR -> NFAPI_VNF: UDP Act task received Incorrect event:%d",\ + pst->event); + ret = RFAILED; + } + } + break; + } + case ENTUDPP7: + { + switch(pst->event) + { + case EVTSTARTNFAPIP7POLL: + { + nfapiP7UdpRecvMsg(); + ODU_PUT_MSG_BUF(mBuf); + break; + } + default: + { + DU_LOG("\nERROR -> NFAPI_VNF: UDP Act task received Incorrect event:%d",\ + pst->event); + ret = RFAILED; + break; + } + } + break; + } + default: + { + DU_LOG("\nERROR --> NFAPI_VNF: UDP Act task received from wrong Entity:%d",\ + pst->srcEnt); + ret = RFAILED; + break; + } + } + + ODU_EXIT_TASK(); + return ret; +} + +/************************************************************************** + * @brief Handles the NFAPI_UDP_P7 Configuration received from DUAPP + * + * @details + * + * Function : NfapiProcP7UdpCfg + * + * Functionality: UDP P7 Configuration recevied from DUAPP has to be stored + * in Database of NFAPI which will be used during UDP Socket Establishment + * + * @param[in] Pst *pst, Post structure of the primitive. + * @param[in] Buffer *mBuf, Packed primitive parameters in the + * buffer. + * @return ROK - success + * RFAILED - failure + * + ***************************************************************************/ +uint8_t NfapiProcP7UdpCfg(Pst *pst, NfapiP7UdpCfg *nfapiP7UdpCfg) +{ + uint8_t ret = ROK; + + DU_LOG("INFO --> NFAPI_VNF: Received UDP P7 Configuration from DUAPP"); + if(nfapiP7UdpCfg) + { + if(nfapiP7UdpCfg->ipv4P7VnfPres) + { + vnfDb.p7TransInfo.srcIpv4Address = nfapiP7UdpCfg->ipv4P7VnfAddr; + vnfDb.p7TransInfo.srcIpv4Port = nfapiP7UdpCfg->p7VnfPort; + vnfDb.p7TransInfo.destIpv4Address = nfapiP7UdpCfg->ipv4P7PnfAddr; + vnfDb.p7TransInfo.destIpv4Port = nfapiP7UdpCfg->p7PnfPort; + vnfDb.p7TransInfo.srcIpNetAddr.address = CM_INET_NTOH_UINT32(vnfDb.p7TransInfo.srcIpv4Address); + vnfDb.p7TransInfo.srcIpNetAddr.port = vnfDb.p7TransInfo.srcIpv4Port; + vnfDb.p7TransInfo.destIpNetAddr.address = CM_INET_NTOH_UINT32(vnfDb.p7TransInfo.destIpv4Address); + vnfDb.p7TransInfo.destIpNetAddr.port = vnfDb.p7TransInfo.destIpv4Port; + } + + NFAPI_UDP_P7_FREE_SHRABL_BUF(pst->region, pst->pool, nfapiP7UdpCfg, sizeof(NfapiP7UdpCfg)); + } + else + { + DU_LOG("\nINFO --> MAC : Received NfapiP7UdpCfg is NULL"); + ret = RFAILED; + } + return ret; +} + +/******************************************************************* + * + * @brief Processing Client open request + * + * @details + * + * Function : nfapiP7UdpCliOpenPrc + * + * Functionality: Processing UDP P7 Client open request + * + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t nfapiP7UdpCliOpenPrc(uint8_t sockType) +{ + S8 ret=ROK; + ret = cmInetSocket(sockType, &(vnfDb.p7TransInfo.sockFd), CM_INET_PROTO_UDP); + if(ret != ROK) + { + DU_LOG("\nERROR --> NFAPI_VNF : Failed to open UDP socket"); + return ret; + } + ret = cmInetBind(&(vnfDb.p7TransInfo.sockFd), &(vnfDb.p7TransInfo.srcIpNetAddr)); + if(ret != ROK) + { + DU_LOG("\nERROR --> NFAPI_VNF : Failed to bind socket"); + return ret; + } + + return ret; +} + +/******************************************************************* + * + * @brief Packs Polling requesting and sends to NFAPI P7 UDP + * + * @details + * + * Function : packNfapiP7UdpStartPollingReq + * + * Functionality: + * Packs polling request and sends to NFAPI P7 UDP + * + * @params[in] Post structure + * @return ROK - success + * RFAILED - failure + * + *******************************************************************/ +uint8_t packNfapiP7UdpStartPollingReq(Pst *pst) +{ + Buffer *mBuf; + + if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nERROR --> NFAPI_VNF : Failed to allocate memory"); + return RFAILED; + } + + ODU_POST_TASK(pst, mBuf); + return ROK; +} + +/************************************************************************** + * @brief NFAPI P7 Interface's UDP open request + * + * @details + * + * Function : nfapiP7UdpOpenReq + * + * Functionality: + * This function handles NFAPI P7 UDP open request. + * It opens udp socket to receive/send msgs. + * + * @param[in] Pst *pst, post structure + * @return ROK - success + * RFAILED - failure + * + ***************************************************************************/ + +uint8_t nfapiP7UdpOpenReq() +{ + + uint8_t ret = ROK; /* Return value */ + Pst nfapiP7Pst; /* Self post */ + uint8_t sockType; /* Socket type */ + + DU_LOG("\nDEBUG --> NFAPI_VNF : Received NFAPI P7's UDP open Client request"); + + sockType = CM_INET_DGRAM; + ret = nfapiP7UdpCliOpenPrc(sockType); + /* Opening and Binding receiver socket */ + if(ret != ROK) + { + DU_LOG("\nERROR --> NFAPI_VNF : Failed while opening receiver transport server"); + return ret; + } + + DU_LOG("\nDEBUG --> NFAPI_VNF : Socket [%d] is open", vnfDb.p7TransInfo.sockFd.fd); + + /* Start Socket polling */ + memset(&nfapiP7Pst, 0, sizeof(nfapiP7Pst)); + nfapiP7Pst.srcEnt = (Ent)ENTUDPP7; + nfapiP7Pst.srcInst = (Inst)NFAPI_UDP_P7_INST; + nfapiP7Pst.srcProcId = NFAPI_UDP_P7_PROC; + nfapiP7Pst.dstEnt = (Ent)ENTUDPP7; + nfapiP7Pst.dstInst = (Inst)NFAPI_UDP_P7_INST; + nfapiP7Pst.dstProcId = NFAPI_UDP_P7_PROC; + nfapiP7Pst.event = EVTSTARTNFAPIP7POLL; + nfapiP7Pst.selector = ODU_SELECTOR_LC; + nfapiP7Pst.pool= NFAPI_UDP_P7_POOL; + packNfapiP7UdpStartPollingReq(&nfapiP7Pst); + return ret; } + +/******************************************************************* + * + * @brief Receives NFAPI P7 message from UDP socket + * + * @details + * + * Function : nfapiP7UdpRecvMsg + * + * Functionality: + * Receive incoming messages from UDP socket + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t nfapiP7UdpRecvMsg() +{ + uint8_t ret = ROK; /* Return value */ + uint16_t bufLen; /* Length of received buffer */ + Buffer *recvBuf; /* Received buffer */ + CmInetMemInfo memInfo; /* Buffer allocation info */ + memInfo.region = NFAPI_UDP_P7_MEM_REGION; + memInfo.pool = NFAPI_UDP_P7_POOL; + + while(true) + { + bufLen = -1; + ret = RFAILED; + recvBuf = NULLP; + ret = cmInetRecvMsg(&vnfDb.p7TransInfo.sockFd, &vnfDb.p7TransInfo.destIpNetAddr, &memInfo, &recvBuf, (int16_t *)&bufLen, CM_INET_NO_FLAG); + if(ret == ROK && recvBuf != NULLP) + { + DU_LOG("\nDEBUG --> NFAPI_VNF : Received P7 Message\n"); + ODU_PUT_MSG_BUF(recvBuf); + } + } + + return ROK; +} + +/******************************************************************* + * + * @brief Sends message over UDP + * + * @details + * + * Function : nfapiP7UdpSendMsg + * + * Functionality: + * Sends message over UDP + * + * @params[in] Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t nfapiP7UdpSendMsg(Buffer *mBuf) +{ + uint8_t ret; + uint16_t txLen; + CmInetMemInfo info; + static uint64_t numDataSent = 0; + + info.region = NFAPI_UDP_P7_MEM_REGION; + info.pool = NFAPI_UDP_P7_POOL; + + ret = cmInetSendMsg(&vnfDb.p7TransInfo.sockFd, &vnfDb.p7TransInfo.destIpNetAddr, &info, mBuf, (int16_t *)&txLen, CM_INET_NO_FLAG); + if(ret != ROK && ret != RWOULDBLOCK) + { + DU_LOG("\nERROR --> NFAPI_VNF : Failed sending the message"); + return RFAILED; + } + else + { + DU_LOG("\nDEBUG --> NFAPI_VNF : Sent NFAPI P7 Message [%ld]", numDataSent+1); + numDataSent++; + } + + return ROK; +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrmac/nfapi_udp_p7.h b/src/5gnrmac/nfapi_udp_p7.h new file mode 100644 index 000000000..a5739007d --- /dev/null +++ b/src/5gnrmac/nfapi_udp_p7.h @@ -0,0 +1,27 @@ + + /******************************************************************************* + ################################################################################ + # Copyright (c) [2017-2019] [Radisys] # + # # + # Licensed under the Apache License, Version 2.0 (the "License"); # + # you may not use this file except in compliance with the License. # + # You may obtain a copy of the License at # + # # + # http://www.apache.org/licenses/LICENSE-2.0 # + # # + # Unless required by applicable law or agreed to in writing, software # + # distributed under the License is distributed on an "AS IS" BASIS, # + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # + # See the License for the specific language governing permissions and # + # limitations under the License. # + ################################################################################ + *******************************************************************************/ + +/*Reference: SCF225_5G_NFAPI_SPECIFICATION, v225.2.1, Issue Date: 23 Nov 2021*/ + +#ifndef _NFAPI_UDP_P7_H__ +#define _NFAPI_UDP_P7_H__ + +uint8_t nfapiP7UdpOpenReq(); + +#endif diff --git a/src/5gnrmac/nfapi_vnf_fsm.c b/src/5gnrmac/nfapi_vnf_fsm.c index 84b9ea674..0dd85c29a 100644 --- a/src/5gnrmac/nfapi_vnf_fsm.c +++ b/src/5gnrmac/nfapi_vnf_fsm.c @@ -21,13 +21,14 @@ /* header include files -- defines (.h) */ #include "common_def.h" #include "lwr_mac.h" -#include "nfapi_vnf_fsm.h" #include "nfapi_interface.h" +#include "nfapi_vnf_fsm.h" #include "nfapi_common.h" #include "lwr_mac_utils.h" #include "lwr_mac_sctp_inf.h" #include "mac_utils.h" #include "lwr_mac_fsm.h" +#include "nfapi_udp_p7.h" /******************************************************************* * @@ -77,9 +78,12 @@ uint8_t nfapi_vnf_procPnfReadyIndEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgH vnfDb.pnfEvent, vnfDb.pnfStateAtVnf); CMCHKPK(oduUnpackUInt32, &(version), msg); - + DU_LOG("\nINFO --> NFAPI_VNF: PNF_READY_IND version:%d",version); + /*TODO: Need to put it when START.RESPONSE is received.*/ + nfapiP7UdpOpenReq(); + sendEventToNfapiVnfFsm(PNF_PARAM_REQ, NULLP, NULLP, NULLP); return ROK; } diff --git a/src/5gnrmac/nfapi_vnf_fsm.h b/src/5gnrmac/nfapi_vnf_fsm.h index 48002df7e..a20ef3290 100644 --- a/src/5gnrmac/nfapi_vnf_fsm.h +++ b/src/5gnrmac/nfapi_vnf_fsm.h @@ -21,8 +21,6 @@ #ifndef _NFAPI_VNF_FSM_H_ #define _NFAPI_VNF_FSM_H_ -#include "nfapi_interface.h" - typedef enum { PNF_STATE_IDLE = 0, PNF_STATE_CONFIGURED, @@ -46,13 +44,14 @@ typedef enum { typedef struct nfapiTransportInfo { uint32_t assocId; - uint8_t srcIpv4Address[4]; /*Src :: PNF Address Details*/ + uint32_t srcIpv4Address; /*Src :: PNF Address Details*/ uint16_t srcIpv4Port; - uint8_t destIpv4Address[4]; /*Dest :: VNF Address Details*/ + uint32_t destIpv4Address; /*Dest :: VNF Address Details*/ uint16_t destIpv4Port; CmInetFd sockFd; /* Socket file descriptor */ - CmInetNetAddrLst addrLst; /* Refers to the destinaiton Addr Lst in CmInetNetAddrLst format */ - CmInetNetAddr ipNetAddr; /* Refers to the destination Addr in CmInetNet Addr format */ + CmInetAddr srcIpNetAddr; /* Refers to the Source(VNF) Addr in CmInetNet Addr format */ + CmInetAddr destIpNetAddr; /* Refers to the destination(PNF) Addr in CmInetNet Addr format */ + //CmInetNetAddrLst addrLst; /* Refers to the destinaiton Addr Lst in CmInetNetAddrLst format */ /*TODO: Add the IPV6 support*/ diff --git a/src/5gnrmac/rg_lmm.c b/src/5gnrmac/rg_lmm.c index 968d784cf..d21524bb6 100755 --- a/src/5gnrmac/rg_lmm.c +++ b/src/5gnrmac/rg_lmm.c @@ -69,6 +69,7 @@ #include "lwr_mac_phy.h" #ifdef NFAPI_ENABLED +#include "nfapi_interface.h" #include "nfapi_vnf_fsm.h" #endif diff --git a/src/cm/du_app_p7udp_inf.c b/src/cm/du_app_p7udp_inf.c new file mode 100644 index 000000000..4c7d49f6c --- /dev/null +++ b/src/cm/du_app_p7udp_inf.c @@ -0,0 +1,103 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + *******************************************************************************/ + +#include "common_def.h" +#include "du_app_p7udp_inf.h" + +/******************************************************************* +* +* @brief Packs and Sends NFAPI's UDP P7 Interface's Config +* +* @details +* +* Function : packDuNfapiP7UdpCfg +* +* Functionality: +* Packs and Sends NFAPI's UDP P7 Interface's Configuration +* +* +* @params[in] Post structure pointer +* NfapiP7UdpCfg pointer +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t packDuNfapiP7UdpCfg(Pst *pst, NfapiP7UdpCfg *nfapiP7UdpCfg) +{ + Buffer *mBuf = NULLP; + + if(pst->selector == ODU_SELECTOR_LWLC) + { + if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nERROR --> MAC : Memory allocation failed at packDuNfapiP7UdpCfg"); + return RFAILED; + } + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)nfapiP7UdpCfg, mBuf); + } + else + { + DU_LOG("\nERROR --> MAC: Only LWLC supported for packDuNfapiP7UdpCfg"); + return RFAILED; + } + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* +* +* @brief Unpacks NFAPI's UDP P7 Interface's Configuration +* +* @details +* +* Function : unpackDuNfapiP7UdpCfg +* +* Functionality: +* Unpacks NFAPI's UDP P7 Interface's Configuration +* +* @params[in] Pointer to Handler +* Post structure pointer +* Message Buffer +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t unpackDuNfapiP7UdpCfg(DuNfapiP7UdpCfgFunc func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == ODU_SELECTOR_LWLC) + { + NfapiP7UdpCfg *nfapiP7UdpCfg = NULLP; + + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&nfapiP7UdpCfg, mBuf); + ODU_PUT_MSG_BUF(mBuf); + return (*func)(pst, nfapiP7UdpCfg); + } + else + { + /* Nothing to do for other selectors */ + DU_LOG("\nERROR --> DU APP : Only LWLC supported for UDP P7 Config Request "); + ODU_PUT_MSG_BUF(mBuf); + } + + return RFAILED; +} + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cm/du_app_p7udp_inf.h b/src/cm/du_app_p7udp_inf.h new file mode 100644 index 000000000..8f71cbfed --- /dev/null +++ b/src/cm/du_app_p7udp_inf.h @@ -0,0 +1,53 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + *******************************************************************************/ + +/* Defines APIs exchanged between du_app and UDP P7 module */ +#ifndef __DUAPP_P7UDP_INF_H__ +#define __DUAPP_P7UDP_INF_H__ + +#define EVENT_NFAPI_P7_UDP_CFG 1 + +/********************* Global Variable ********************/ + +typedef struct nfapiP7UdpCfg{ + bool ipv4P7VnfPres; + uint32_t ipv4P7VnfAddr; + bool ipv6P7VnfPres; + uint32_t ipv6P7VnfAddr; + bool ipv4P7PnfPres; + uint32_t ipv4P7PnfAddr; + uint16_t p7VnfPort; + uint16_t p7PnfPort; + +}NfapiP7UdpCfg; + +typedef uint8_t (* DuNfapiP7UdpCfgFunc) ARGS(( + Pst *pst, + NfapiP7UdpCfg *nfapiP7UdpCfg)); + + +/******************** FUNCTION DECLARATIONS ********************************/ +uint8_t packDuNfapiP7UdpCfg(Pst *pst, NfapiP7UdpCfg *nfapiP7UdpCfg); +uint8_t NfapiProcP7UdpCfg(Pst *pst, NfapiP7UdpCfg *nfapiP7UdpCfg); +uint8_t unpackDuNfapiP7UdpCfg(DuNfapiP7UdpCfgFunc func, Pst *pst, Buffer *mBuf); + +#endif + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cm/ssi.h b/src/cm/ssi.h index 42a284454..ee2a508c5 100755 --- a/src/cm/ssi.h +++ b/src/cm/ssi.h @@ -1342,7 +1342,7 @@ #define ENTPHYSTUB 0xd4 #else #ifdef NFAPI_ENABLED -#define ENTUDP7 0xd4 /* UDP P7 */ +#define ENTUDPP7 0xd4 /* UDP P7 */ #endif #endif /* ssi_h_001.main_135 : addition of LTE related entities */ diff --git a/src/du_app/du_cfg.c b/src/du_app/du_cfg.c index d6d20face..cc1eb65d1 100644 --- a/src/du_app/du_cfg.c +++ b/src/du_app/du_cfg.c @@ -302,6 +302,43 @@ uint8_t parseEgtpParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, F1EgtpParams return ROK; } +/******************************************************************* + * + * @brief Fill P7 UDP Parameters + * + * @details + * + * Function : parseP7UdpParams + * + * Functionality: Fill P7 UDP Parmeters + * + * @params[in] XML document pointer + * XML namespace + * Current node in XML + * Pointer to structure to be filled + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t parseP7UdpParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, NfapiP7UdpCfg *p7Udp) +{ + memset(p7Udp, 0, sizeof(NfapiP7UdpCfg)); + cur = cur->xmlChildrenNode; + while (cur != NULL) + { + if ((!xmlStrcmp(cur->name, (const xmlChar *)"VNF_P7_UDP_PORT")) && (cur->ns == ns)) + { + p7Udp->p7VnfPort = atoi((char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"PNF_P7_UDP_PORT")) && (cur->ns == ns)) + { + p7Udp->p7PnfPort = atoi((char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); + } + cur = cur -> next; + } + return ROK; +} + /******************************************************************* * * @brief Fill MIB configuration @@ -5190,7 +5227,7 @@ uint8_t parseDuCfgParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) char *ricIpV4Addr; #ifdef NFAPI_ENABLED char *pnfP5IpV4Addr; - CmInetIpAddr pnfP5Ip; + CmInetIpAddr pnfIp; #endif CmInetIpAddr duIp; CmInetIpAddr cuIp; @@ -5268,7 +5305,7 @@ uint8_t parseDuCfgParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) if ((!xmlStrcmp(cur->name, (const xmlChar *)"PNF_P5_IP_V4_ADDR")) && (cur->ns == ns)) { pnfP5IpV4Addr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); - cmInetAddr(pnfP5IpV4Addr, &(pnfP5Ip)); + cmInetAddr(pnfP5IpV4Addr, &(pnfIp)); } #endif if ((!xmlStrcmp(cur->name, (const xmlChar *)"SCTP")) && (cur->ns == ns)) @@ -5286,7 +5323,7 @@ uint8_t parseDuCfgParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ricIp; #ifdef NFAPI_ENABLED duCfgParam.sctpParams.pnfP5IpAddr.ipV4Pres = true; - duCfgParam.sctpParams.pnfP5IpAddr.ipV4Addr = pnfP5Ip; + duCfgParam.sctpParams.pnfP5IpAddr.ipV4Addr = pnfIp; #endif } @@ -5304,6 +5341,21 @@ uint8_t parseDuCfgParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) duCfgParam.egtpParams.maxTunnelId = duCfgParam.maxNumDrb * MAX_NUM_UE; } +#ifdef NFAPI_ENABLED + if ((!xmlStrcmp(cur->name, (const xmlChar *)"P7_UDP")) && (cur->ns == ns)) + { + parseP7UdpParams(doc, ns, cur, &duCfgParam.tempNFapiP7UdpCfg); + if(duCfgParam.sctpParams.duIpAddr.ipV4Pres) + { + duCfgParam.tempNFapiP7UdpCfg.ipv4P7VnfPres = true; + duCfgParam.tempNFapiP7UdpCfg.ipv4P7VnfAddr = duIp; + duCfgParam.tempNFapiP7UdpCfg.ipv6P7VnfPres = false; + duCfgParam.tempNFapiP7UdpCfg.ipv6P7VnfAddr = 0; + duCfgParam.tempNFapiP7UdpCfg.ipv4P7PnfPres = true; + duCfgParam.tempNFapiP7UdpCfg.ipv4P7PnfAddr = pnfIp; + } + } +#endif if ((!xmlStrcmp(cur->name, (const xmlChar *)"MIB_PARAMS")) && (cur->ns == ns)) { if(parseMibParams(doc, ns, cur, &duCfgParam.mibParams) != ROK) diff --git a/src/du_app/du_cfg.h b/src/du_app/du_cfg.h index 63b0d769b..0bb98ca69 100644 --- a/src/du_app/du_cfg.h +++ b/src/du_app/du_cfg.h @@ -22,7 +22,9 @@ #ifdef O1_ENABLE #include "CmInterface.h" #endif - +#ifdef NFAPI_ENABLED +#include "du_app_p7udp_inf.h" +#endif /* MACROS */ #define GNB_ID 1 /* As per 38.423,Sec 9.2.2.1, gnbId range b/w 0 to 4294967295 */ @@ -1179,6 +1181,9 @@ typedef struct duCfgParams MibParams mibParams; /* MIB Params */ Sib1Params sib1Params; /* SIB1 Params */ MacSliceCfgReq tempSliceCfg; +#ifdef NFAPI_ENABLED + NfapiP7UdpCfg tempNFapiP7UdpCfg; +#endif }DuCfgParams; #ifndef O1_ENABLE diff --git a/src/du_app/du_mgr_main.c b/src/du_app/du_mgr_main.c index 56dd91e82..7b71fe772 100644 --- a/src/du_app/du_mgr_main.c +++ b/src/du_app/du_mgr_main.c @@ -580,13 +580,13 @@ uint8_t phyStubInit(SSTskId sysTskId) uint8_t udpP7Init(SSTskId sysTskId) { /* Register UDP P7 TAPA Task */ - if(ODU_REG_TTSK((Ent)ENTUDP7, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0, + if(ODU_REG_TTSK((Ent)ENTUDPP7, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0, udpP7ActvInit, (ActvTsk)udpP7ActvTsk) != ROK) { return RFAILED; } /* Attach UDP P7 TAPA Task */ - if (ODU_ATTACH_TTSK((Ent)ENTUDP7, (Inst)0, sysTskId)!= ROK) + if (ODU_ATTACH_TTSK((Ent)ENTUDPP7, (Inst)0, sysTskId)!= ROK) { return RFAILED; } diff --git a/src/du_app/du_msg_hdl.c b/src/du_app/du_msg_hdl.c index b2ab02818..f572270b6 100644 --- a/src/du_app/du_msg_hdl.c +++ b/src/du_app/du_msg_hdl.c @@ -51,6 +51,10 @@ #endif +#ifdef NFAPI_ENABLED +#include "du_app_p7udp_inf.h" +#endif + uint8_t rlcDlCfg = 0; uint8_t numRlcDlSaps = 0; uint8_t rlcUlCfg = 0; @@ -115,6 +119,15 @@ DuMacStatsModificationReqFunc packMacStatsModificationReqOpts[]= packDuMacStatsModificationReq /* Light weight-loose coupling */ }; +#ifdef NFAPI_ENABLED +DuNfapiP7UdpCfgFunc packNfapiP7UdpCfgOpts[]= +{ + packDuNfapiP7UdpCfg, /*Loose Coupling*/ + NfapiProcP7UdpCfg, /*Tight-Coupling*/ + packDuNfapiP7UdpCfg /*Light weight-loose coupling */ +}; +#endif + /************************************************************************** * @brief Function to fill configs required by RLC * @@ -406,9 +419,13 @@ uint8_t duProcCfgComplete() { //Start layer configs ret = duSendRlcUlCfg(); +#ifdef NFAPI_ENABLED + ret = BuildAndSendNfapiP7UdpConfig(); +#endif } return ret; } + /************************************************************************** * @brief Function to invoke DU Layer Configs * @@ -2578,6 +2595,51 @@ uint8_t DuProcMacStatsModificationRsp(Pst *pst, MacStatsModificationRsp *statsMo return ret; } +#ifdef NFAPI_ENABLED +/******************************************************************* + * + * @brief Fill the NFAPI P7 UDP Socket Config to NFAPI UDP P7 (VNF) + * + * @details + * + * Function : BuildAndSendNfapiP7UdpConfig + * + * Functionality: Fill the NFAPI P7 UDP Socket Config + * + * @params[in] + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t BuildAndSendNfapiP7UdpConfig() +{ + Pst pst; + NfapiP7UdpCfg *p7UdpCfg = NULLP; + + DU_ALLOC_SHRABL_BUF(p7UdpCfg, sizeof(NfapiP7UdpCfg)); + if(p7UdpCfg == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed in BuildAndSendNfapiP7UdpConfig"); + return RFAILED; + } + else + { + memcpy(p7UdpCfg, &duCfgParam.tempNFapiP7UdpCfg, sizeof(NfapiP7UdpCfg)); + FILL_PST_DUAPP_TO_NFAPIUDPP7(pst, EVENT_NFAPI_P7_UDP_CFG); + + DU_LOG("\nDEBUG --> DU_APP : Sending NFAPI P7 UDP Cfg to NFAPI P7 (VNF)"); + if((*packNfapiP7UdpCfgOpts[pst.selector])(&pst, p7UdpCfg) == RFAILED) + { + DU_LOG("\nERROR --> DU_APP : Failed to send NFAPI P7 UDP Cfg to NFAPI P7"); + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, p7UdpCfg, sizeof(NfapiP7UdpCfg)); + return RFAILED; + } + } + return ROK; +} +#endif + /********************************************************************** End of file **********************************************************************/ diff --git a/src/du_app/du_msg_hdl.h b/src/du_app/du_msg_hdl.h index 33a2771a2..d09d683ce 100644 --- a/src/du_app/du_msg_hdl.h +++ b/src/du_app/du_msg_hdl.h @@ -28,7 +28,7 @@ uint8_t sendCellDeleteReqToMac(uint16_t cellId); uint8_t BuildAndSendStatsDeleteReq(RicSubscription *ricSubscriptionInfo, bool deleteAllStats); uint8_t BuildAndSendStatsModificationReqToMac(RicSubscription *ricSubscriptionInfo); uint8_t BuildAndSendStatsModificationReq(RicSubscription *ricSubscriptionInfo); - +uint8_t BuildAndSendNfapiP7UdpConfig(); /********************************************************************** End of file diff --git a/src/du_app/du_utils.h b/src/du_app/du_utils.h index e98aa43ad..282c967ad 100644 --- a/src/du_app/du_utils.h +++ b/src/du_app/du_utils.h @@ -23,6 +23,9 @@ #define RLC_UL_MEM_REGION 1 #define RLC_DL_MEM_REGION 4 #define MAC_MEM_REGION 4 +#ifdef NFAPI_ENABLED +#define NFAPI_UDP_P7_MEM_REGION 5 +#endif #define DU_POOL 1 #define RLC_POOL 1 @@ -107,6 +110,26 @@ } \ } +#ifdef NFAPI_ENABLED +/* Fill Pst structure for sending msg from DU APP to NFAPI UDP P7 */ +#define FILL_PST_DUAPP_TO_NFAPIUDPP7(_pst, _event) \ +{ \ + _pst.selector = ODU_SELECTOR_LWLC; \ + _pst.srcEnt = ENTDUAPP; \ + _pst.dstEnt = ENTUDPP7; \ + _pst.dstInst = 0; \ + _pst.srcInst = 0; \ + _pst.dstProcId = DU_PROC; \ + _pst.srcProcId = DU_PROC; \ + _pst.region = DU_APP_MEM_REGION; \ + _pst.pool = DU_POOL; \ + _pst.event = _event; \ + _pst.route = 0; \ + _pst.prior = 0; \ + _pst.intfVer = 0; \ +} +#endif + /* Fill Pst structure for sending msg from DU APP to MAC */ #define FILL_PST_DUAPP_TO_MAC(_pst, _event) \ { \ diff --git a/src/phy_stub/phy_stub_msg_hdl.c b/src/phy_stub/phy_stub_msg_hdl.c index bc9b51c29..22a12b5d0 100644 --- a/src/phy_stub/phy_stub_msg_hdl.c +++ b/src/phy_stub/phy_stub_msg_hdl.c @@ -180,7 +180,6 @@ S16 l1BldAndSndParamRsp(void *msg) } /******************************************************************* - * * @brief Builds and sends config response to lower mac * * @details diff --git a/src/pnf_stub/pnf_stub.c b/src/pnf_stub/pnf_stub.c index 40acea58d..a62dd0065 100644 --- a/src/pnf_stub/pnf_stub.c +++ b/src/pnf_stub/pnf_stub.c @@ -34,6 +34,7 @@ #include #include "nfapi_interface.h" #include "pnf_stub_sctp.h" +#include "pnf_stub_p7_udp.h" #include "pnf_stub.h" #include "pnf_stub_p5_msg_hdl.h" @@ -100,7 +101,13 @@ void readPnfCfg() } pnfCb.pnfCfgParams.pnfP5SctpParams.numDestNode = cntNumVnf; - + + /*P7 UDP Transport Cfg*/ + pnfCb.pnfCfgParams.pnfP7UdpParams.srcIpv4P7Addr = ipv4_pnf; + pnfCb.pnfCfgParams.pnfP7UdpParams.srcIpv4Port = PNF_P7_UDP_PORT; + pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4P7Addr = ipv4_vnf; + pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4Port = PNF_P7_UDP_PORT; + } /* End of readPnfCfg */ @@ -152,12 +159,16 @@ uint8_t tst() /* Initializing SCTP global parameters */ pnfP5SctpActvInit(); - /* Start PNF-P5-SCTP to listen on incoming connection */ pnfP5SctpCfgReq(); - + + /* Initializing UDP global parameters */ + pnfP7UdpActvInit(); + pnfP7UdpCfgReq(); + /*Sleep is introduced for GDB to increase the waiting time for PNF Configuration from VNF*/ sleep(1); + /* Start PNF-P5-SCTP to listen on incoming connection */ pnfP5SctpStartReq(); return ROK; @@ -264,4 +275,3 @@ void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf) /********************************************************************** End of file **********************************************************************/ - diff --git a/src/pnf_stub/pnf_stub.h b/src/pnf_stub/pnf_stub.h index 2c6baba9a..7551ed916 100644 --- a/src/pnf_stub/pnf_stub.h +++ b/src/pnf_stub/pnf_stub.h @@ -29,6 +29,9 @@ #define NUM_PNF_P5_ASSOC 1 #define REMOTE_IP_DU (char*[]){"192.168.130.81", "192.168.130.83"} +/*P7 UDP Teansport Cfg Details*/ +#define PNF_P7_UDP_PORT 9876 + #define PNF_APP_MEM_REG 1 #define PNF_POOL 1 @@ -45,6 +48,7 @@ typedef struct pnfCfgParams uint32_t pnfId; char pnfName[PNF_NAME_LEN_MAX]; PnfP5SctpParams pnfP5SctpParams; + PnfP7UdpParams pnfP7UdpParams; }PnfCfgParams; typedef struct pnfGlobalCb diff --git a/src/pnf_stub/pnf_stub_p7_udp.c b/src/pnf_stub/pnf_stub_p7_udp.c new file mode 100644 index 000000000..c1b02d048 --- /dev/null +++ b/src/pnf_stub/pnf_stub_p7_udp.c @@ -0,0 +1,165 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains all P7 UDP related functionality */ + +#include "common_def.h" +#include "cm_inet.x" +#include "pnf_stub_p7_udp.h" +#include "pnf_stub_sctp.h" +#include "pnf_stub.h" + +uint8_t sockType; +uint8_t protType; + +/************************************************************************** + * @brief Task Initiation callback function. + * + * @details + * + * Function : pnfP7UdpActvInit + * + * Functionality: + * This function is supplied as one of parameters during UDP P7's + * task registration. SSI will invoke this function once, after + * it creates and attaches this TAPA Task to a system task. + * + * @param[in] + * @return ROK - success + * RFAILED - failure + ***************************************************************************/ +uint8_t pnfP7UdpActvInit() +{ + DU_LOG("\n\nDEBUG --> P7_UDP : Initializing "); + memset (&pnfP7Cb, 0, sizeof(PnfP7UdpGlobalCb)); + + //Initializing with INVALID value + pnfP7Cb.gCntMsg = 0xFFFF; + protType = CM_INET_PROTO_UDP; + return ROK; +} + +/************************************************************************** + * @brief UDP P7 server open request + * + * @details + * + * Function : pnfP7UdpSrvOpenReq + * + * Functionality: + * This function handles P7 UDP open server request. + * It opens udp socket to receive/send msgs. + * + * @return ROK - success + * RFAILED - failure + * + ***************************************************************************/ + +uint8_t pnfP7UdpSrvOpenReq() +{ + uint8_t ret = ROK; + + DU_LOG("\nINFO --> P7_UDP: Received open server request"); + + sockType = CM_INET_DGRAM; + if((ret = (cmInetSocket(sockType, &(pnfP7Cb.sockFd), protType))) != ROK) + { + DU_LOG("\nERROR --> P7_UDP : Failed to open UDP socket"); + return RFAILED; + } + + ret = cmInetBind(&(pnfP7Cb.sockFd), &(pnfP7Cb.srcAddr)); + if(ret != ROK) + { + DU_LOG("\nERROR --> P7_UDP : Failed to bind socket"); + return RFAILED; + } + + DU_LOG("\nINFO --> P7_UDP : Socket[%d] is open", pnfP7Cb.sockFd.fd); + return ROK; +} /* pnfP7UdpSrvOpenReq */ + +/************************************************************************** + * @brief Task Activation callback function. + * + * @details + * + * Function : pnfP7UdpCfgReq + * + * Functionality: Fills the PnfP7 Database with UDP Client/Server Addresses + * + * @return ROK - success + * RFAILED - failure + * + ***************************************************************************/ +uint8_t pnfP7UdpCfgReq() +{ + uint8_t ret = ROK; + + pnfP7Cb.srcAddr.address = CM_INET_NTOH_UINT32(pnfCb.pnfCfgParams.pnfP7UdpParams.srcIpv4P7Addr); + pnfP7Cb.srcAddr.port = pnfCb.pnfCfgParams.pnfP7UdpParams.srcIpv4Port; + pnfP7Cb.destAddr.address = CM_INET_NTOH_UINT32(pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4P7Addr); + pnfP7Cb.destAddr.port = pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4Port; + + ret = pnfP7UdpSrvOpenReq(); + if(ret != ROK) + { + DU_LOG("\nERROR --> P7_UDP : Transport server open request failed"); + return (ret); + } + + return ret; +} /* pnfP7UdpCfgReq */ + +/******************************************************************* + * + * @brief Send the UDP P7 message to the destination VNF + * + * @details + * + * Function : pnfP7UdpSendMsg + * + * Functionality: + * Send the UDP P7 message to the destination DU + * + * @params[in] Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 pnfP7UdpSendMsg(Buffer *mBuf) +{ + S16 ret; + MsgLen txLen; + CmInetMemInfo info; + + info.region = PNF_APP_MEM_REG; + info.pool = PNF_POOL; + + + ret = cmInetSendMsg(&(pnfP7Cb.sockFd), &pnfP7Cb.destAddr, &info, mBuf, &txLen, CM_INET_NO_FLAG); + if(ret != ROK && ret != RWOULDBLOCK) + { + DU_LOG("\nERROR --> P7_UDP : Message send failure"); + return RFAILED; + } + + DU_LOG("\nDEBUG --> P7_UDP : Message Sent"); + + return ROK; +} diff --git a/src/pnf_stub/pnf_stub_p7_udp.h b/src/pnf_stub/pnf_stub_p7_udp.h new file mode 100644 index 000000000..6ebaf49d2 --- /dev/null +++ b/src/pnf_stub/pnf_stub_p7_udp.h @@ -0,0 +1,47 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains all SCTP related functionality */ + +#ifndef __PNF_STUB_P7_UDP_H__ +#define __PNF_STUB_P7_UDP_H__ + +typedef struct pnfP7UdpParams +{ + uint32_t srcIpv4P7Addr; /*PNF P7*/ + uint16_t srcIpv4Port; + uint32_t destIpv4P7Addr; /*VNF P7*/ + uint16_t destIpv4Port; +}PnfP7UdpParams; + +typedef struct pnfP7UdpGlobalCb +{ + CmInetAddr srcAddr; /*PNF IP Address*/ + CmInetAddr destAddr; /*VNF IP Address*/ + CmInetFd sockFd; /* Socket file descriptor */ + uint16_t gCntMsg; +}PnfP7UdpGlobalCb; + +PnfP7UdpGlobalCb pnfP7Cb; + +uint8_t pnfP7UdpActvInit(); +uint8_t pnfP7UdpCfgReq(); +void pnfP7UdpHdlRecvMsg(Buffer *buf); + +#endif + diff --git a/src/pnf_stub/pnf_stub_sctp.c b/src/pnf_stub/pnf_stub_sctp.c index a6ea67b67..f80909770 100644 --- a/src/pnf_stub/pnf_stub_sctp.c +++ b/src/pnf_stub/pnf_stub_sctp.c @@ -22,6 +22,7 @@ #include "nfapi_interface.h" #include "pnf_stub_sctp.h" #include "pnf_stub_p5_msg_hdl.h" +#include "pnf_stub_p7_udp.h" #include "pnf_stub.h" uint8_t socket_type; /* Socket type */ @@ -314,8 +315,14 @@ uint8_t pnfP5SctpSockPoll() uint16_t ret = ROK; uint32_t timeout; uint32_t *timeoutPtr; + uint64_t numMsgRcvd = 0; + Buffer *pnfP7UdpBuf; + MsgLen pnfP7UdpBufLen; + CmInetAddr fromAddr; CmInetMemInfo memInfo; PnfP5SctpSockPollParams pnfP5PollParams; + + char msg[255]; memset(&pnfP5PollParams, 0, sizeof(PnfP5SctpSockPollParams)); @@ -335,9 +342,22 @@ uint8_t pnfP5SctpSockPoll() { if((ret = pnfP5ProcessPolling(&pnfP5PollParams, &pnfP5SctpCb.assocCb[assocIdx], timeoutPtr, &memInfo)) != ROK) { - DU_LOG("\nERROR --> SCTP : Failed to RecvMsg for PNF at P5 Interface \n"); + DU_LOG("\nERROR --> P5_SCTP : Failed to RecvMsg for PNF at P5 Interface \n"); } } + + /* Receiving UDP data */ + pnfP7UdpBufLen = -1; + ret = cmInetRecvMsg(&(pnfP7Cb.sockFd), &fromAddr, &memInfo, &pnfP7UdpBuf, &pnfP7UdpBufLen, CM_INET_NO_FLAG); + if(ret == ROK && pnfP7UdpBuf != NULLP) + { + if((fromAddr.port == pnfP7Cb.srcAddr.port) && (fromAddr.address == pnfP7Cb.srcAddr.address)) + { + DU_LOG("\nINFO --> P7_UDP : Received P7 Message [%ld] \n", numMsgRcvd+1); + numMsgRcvd++; + break; + } + } }; return (ret); }/* End of sctpSockPoll() */