1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This functions contains main() for cu_app */
20 #include "common_def.h"
22 #include "cu_stub_sctp.h"
23 #include "cu_stub_egtp.h"
27 #include "CmInterface.h"
31 #define CU_NAME "ORAN_OAM_CU"
33 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
34 #define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
38 #define DU_IP_V4_ADDR "192.168.130.81"
39 #define CU_IP_V4_ADDR "192.168.130.82"
45 #define DU_EGTP_PORT 39001
46 #define CU_EGTP_PORT 39002
58 extern StartupConfig g_cfg;
63 /*******************************************************************
65 * @brief Handles SCTP notification
69 * Function : sctpNtfyInd
72 * Handles SCTP notification
74 * @params[in] sctp notification
77 ******************************************************************/
78 void sctpNtfyInd(CmInetSctpNotification *ntfy)
85 openlog("CU_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
87 /*******************************************************************
89 * @brief Main function of CU APP
96 * - Reads CU related configurations
97 * - Initialize SCTP Parameters
98 * - Start SCTP receiver thread
101 * @return ROK - success
104 * ****************************************************************/
113 DU_LOG("\nINFO --> CU_STUB : Starting CU_STUB\n");
115 /* Start thread to receive console input */
116 pthread_attr_init(&attr);
117 pthread_attr_setstacksize(&attr, (size_t)NULLD);
118 pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
119 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
120 retVal = pthread_create(&conThrdId, &attr, cuConsoleHandler, NULLP);
123 DU_LOG("\nERROR --> CU_STUB : Thread creation failed. Cause %d", retVal);
125 pthread_attr_destroy(&attr);
127 /* Read CU configurations */
134 /* Initializing SCTP global parameters */
137 /* Start CU-SCTP to listen on incoming connection */
144 /*******************************************************************
146 * @brief Read CU related configuration
150 * Function : readCuCfg
153 * - RRead CU related configuration
156 * @return ROK - success
159 * ****************************************************************/
163 uint32_t ipv4_du, ipv4_cu;
165 DU_LOG("\nDEBUG --> CU_STUB : Reading CU configurations");
168 if( getStartupConfigForStub(&g_cfg) != ROK )
170 DU_LOG("\nError --> CU_STUB : Could not fetch startup "\
171 "configurations from Netconf interface\n");
175 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
176 cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
178 cuCfgParams.sctpParams.duPort = g_cfg.DU_Port;
179 cuCfgParams.sctpParams.cuPort = g_cfg.CU_Port;
181 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
182 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
183 cuCfgParams.sctpParams.duPort = DU_PORT;
184 cuCfgParams.sctpParams.cuPort = CU_PORT;
187 cuCfgParams.cuId = CU_ID;
188 strcpy(cuCfgParams.cuName, CU_NAME);
190 /* DU IP Address and Port*/
191 cuCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
192 cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
194 /* CU IP Address and Port*/
195 cuCfgParams.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
196 cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false;
199 cuCfgParams.plmn.mcc[0] = PLMN_MCC0;
200 cuCfgParams.plmn.mcc[1] = PLMN_MCC1;
201 cuCfgParams.plmn.mcc[2] = PLMN_MCC2;
202 cuCfgParams.plmn.mnc[0] = PLMN_MNC0;
203 cuCfgParams.plmn.mnc[1] = PLMN_MNC1;
204 cuCfgParams.plmn.mnc[2] = PLMN_MNC2;
207 cuCfgParams.rrcVersion.rrcVer = RRC_VER;
208 cuCfgParams.rrcVersion.extRrcVer = EXT_RRC_VER;
211 /* EGTP Parameters */
212 cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE;
213 cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu;
214 cuCfgParams.egtpParams.localPort = CU_EGTP_PORT;
215 cuCfgParams.egtpParams.destIp.ipV4Pres = TRUE;
216 cuCfgParams.egtpParams.destIp.ipV4Addr = ipv4_du;
217 cuCfgParams.egtpParams.destPort = DU_EGTP_PORT;
218 cuCfgParams.egtpParams.minTunnelId = MIN_TEID;
219 cuCfgParams.egtpParams.currTunnelId = cuCfgParams.egtpParams.minTunnelId;
220 cuCfgParams.egtpParams.maxTunnelId = MAX_TEID;
222 } /* End of readCuCfg */
224 /*******************************************************************
226 * @brief Handles Console input
230 * Function : cuConsoleHandler
232 * Functionality: Handles Console input
235 * @return ROK - success
238 * ****************************************************************/
239 void *cuConsoleHandler(void *args)
246 /* This variable is taken for sending specific number of downlink data packet.
247 * Presently the code is supporting total 4500 data packets trasfer for 3 UEs only with sleep(1).
248 * If you wants to pump data for 3 UE change the following macro values
249 * NUM_TUNNEL_TO_PUMP_DATA = 9, NUM_DL_PACKETS = 1.
250 * totalDataPacket = totalNumOfTestFlow * NUM_TUNNEL_TO_PUMP_DATA * NUM_DL_PACKETS
251 * totalDataPacket = [500*9*1] */
252 int32_t totalNumOfTestFlow = 500;
256 /* Send DL user data to CU when user enters 'd' on console */
257 if((ch = getchar()) == 'd')
260 /* Change #if 0 to #if 1 to take input from user */
262 DU_LOG("\n EGTP --> : Enter TEID id(1..10) where DL Data to be sent\n");
265 if(teId > MAX_TEID || teId < MIN_TEID)
267 DU_LOG("\nERROR --> EGTP : TEID(%x) OUT Of Range",teId);
271 /* Start Pumping data from CU to DU */
272 DU_LOG("\nDEBUG --> EGTP: Sending DL User Data(teId:%d)\n",teId);
275 while(cnt < NUM_DL_PACKETS)
277 ret = cuEgtpDatReq(teId);
280 DU_LOG("\nERROR --> EGTP: Issue with teid=%d\n",teId);
286 while(totalNumOfTestFlow)
288 for(teId = 1; teId <= NUM_TUNNEL_TO_PUMP_DATA; teId++)
290 DU_LOG("\nDEBUG --> EGTP: Sending DL User Data(teId:%d)\n",teId);
292 while(cnt < NUM_DL_PACKETS)
294 ret = cuEgtpDatReq(teId);
297 DU_LOG("\nERROR --> EGTP: Issue with teid=%d\n",teId);
300 /* TODO : sleep(1) will be removed later once we will be able to
301 * support the continuous data pack transfer */
306 totalNumOfTestFlow--;
313 /**********************************************************************
315 **********************************************************************/