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"
33 #define CU_NAME "ORAN_OAM_CU"
35 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
36 #define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
40 #define DU_IP_V4_ADDR "192.168.130.81"
41 #define CU_IP_V4_ADDR "192.168.130.82"
47 #define DU_EGTP_PORT 39001
48 #define CU_EGTP_PORT 39002
60 extern StartupConfig g_cfg;
65 /*******************************************************************
67 * @brief Handles SCTP notification
71 * Function : sctpNtfyInd
74 * Handles SCTP notification
76 * @params[in] sctp notification
79 ******************************************************************/
80 void sctpNtfyInd(CmInetSctpNotification *ntfy)
87 openlog("CU_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
89 /*******************************************************************
91 * @brief Main function of CU APP
98 * - Reads CU related configurations
99 * - Initialize SCTP Parameters
100 * - Start SCTP receiver thread
103 * @return ROK - success
106 * ****************************************************************/
115 DU_LOG("\nINFO --> CU_STUB : Starting CU_STUB\n");
117 /* Start thread to receive console input */
118 pthread_attr_init(&attr);
119 pthread_attr_setstacksize(&attr, (size_t)NULLD);
120 pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
121 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
122 retVal = pthread_create(&conThrdId, &attr, cuConsoleHandler, NULLP);
125 DU_LOG("\nERROR --> CU_STUB : Thread creation failed. Cause %d", retVal);
127 pthread_attr_destroy(&attr);
129 /* Read CU configurations */
136 /* Initializing SCTP global parameters */
139 /* Start CU-SCTP to listen on incoming connection */
146 /*******************************************************************
148 * @brief Read CU related configuration
152 * Function : readCuCfg
155 * - RRead CU related configuration
158 * @return ROK - success
161 * ****************************************************************/
165 uint32_t ipv4_du, ipv4_cu;
167 DU_LOG("\nDEBUG --> CU_STUB : Reading CU configurations");
170 if( getStartupConfig(&g_cfg) != ROK )
174 DU_LOG("\nReading CU configurations---");
175 DU_LOG("\nReading CU configurations g_cfg.DU_IPV4_Addr=%s", g_cfg.DU_IPV4_Addr);
176 DU_LOG("\nReading CU configurations g_cfg.CU_IPV4_Addr=%s", g_cfg.CU_IPV4_Addr);
177 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
178 cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
180 cuCfgParams.sctpParams.duPort = g_cfg.DU_Port;
181 cuCfgParams.sctpParams.cuPort = g_cfg.CU_Port;
183 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
184 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
185 cuCfgParams.sctpParams.duPort = DU_PORT;
186 cuCfgParams.sctpParams.cuPort = CU_PORT;
189 cuCfgParams.cuId = CU_ID;
190 strcpy(cuCfgParams.cuName, CU_NAME);
192 /* DU IP Address and Port*/
193 cuCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
194 cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
196 /* CU IP Address and Port*/
197 cuCfgParams.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
198 cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false;
201 cuCfgParams.plmn.mcc[0] = PLMN_MCC0;
202 cuCfgParams.plmn.mcc[1] = PLMN_MCC1;
203 cuCfgParams.plmn.mcc[2] = PLMN_MCC2;
204 cuCfgParams.plmn.mnc[0] = PLMN_MNC0;
205 cuCfgParams.plmn.mnc[1] = PLMN_MNC1;
206 cuCfgParams.plmn.mnc[2] = PLMN_MNC2;
209 cuCfgParams.rrcVersion.rrcVer = RRC_VER;
210 cuCfgParams.rrcVersion.extRrcVer = EXT_RRC_VER;
213 /* EGTP Parameters */
214 cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE;
215 cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu;
216 cuCfgParams.egtpParams.localPort = CU_EGTP_PORT;
217 cuCfgParams.egtpParams.destIp.ipV4Pres = TRUE;
218 cuCfgParams.egtpParams.destIp.ipV4Addr = ipv4_du;
219 cuCfgParams.egtpParams.destPort = DU_EGTP_PORT;
220 cuCfgParams.egtpParams.minTunnelId = 0;
221 cuCfgParams.egtpParams.maxTunnelId = 10;
223 } /* End of readCuCfg */
225 /*******************************************************************
227 * @brief Handles Console input
231 * Function : cuConsoleHandler
233 * Functionality: Handles Console input
236 * @return ROK - success
239 * ****************************************************************/
240 void *cuConsoleHandler(void *args)
245 /* Send DL user data to CU when user enters 'd' on console */
246 if((ch = getchar()) == 'd')
248 /* Start Pumping data from CU to DU */
249 DU_LOG("\nDEBUG --> EGTP: Sending DL User Data");
254 /**********************************************************************
256 **********************************************************************/