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 #define CU_NAME "ORAN_OAM_CU"
28 #define DU_IP_V4_ADDR "192.168.130.81"
29 #define CU_IP_V4_ADDR "192.168.130.82"
30 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
31 #define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
34 #define DU_EGTP_PORT 39001
35 #define CU_EGTP_PORT 39002
45 /*******************************************************************
47 * @brief Handles SCTP notification
51 * Function : sctpNtfyInd
54 * Handles SCTP notification
56 * @params[in] sctp notification
59 ******************************************************************/
60 void sctpNtfyInd(CmInetSctpNotification *ntfy)
67 openlog("CU_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
69 /*******************************************************************
71 * @brief Main function of CU APP
78 * - Reads CU related configurations
79 * - Initialize SCTP Parameters
80 * - Start SCTP receiver thread
83 * @return ROK - success
86 * ****************************************************************/
95 DU_LOG("\nStarting CU_STUB\n");
97 /* Start thread to receive console input */
98 pthread_attr_init(&attr);
99 pthread_attr_setstacksize(&attr, (size_t)NULLD);
100 pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
101 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
102 retVal = pthread_create(&conThrdId, &attr, cuConsoleHandler, NULLP);
105 DU_LOG("\nCU_STUB: Thread creation failed. Cause %d", retVal);
107 pthread_attr_destroy(&attr);
109 /* Read CU configurations */
116 /* Initializing SCTP global parameters */
119 /* Start CU-SCTP to listen on incoming connection */
126 /*******************************************************************
128 * @brief Read CU related configuration
132 * Function : readCuCfg
135 * - RRead CU related configuration
138 * @return ROK - success
141 * ****************************************************************/
145 uint32_t ipv4_du, ipv4_cu;
147 DU_LOG("\nReading CU configurations");
149 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
150 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
152 cuCfgParams.cuId = CU_ID;
153 strcpy(cuCfgParams.cuName, CU_NAME);
155 /* DU IP Address and Port*/
156 cuCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
157 cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
158 cuCfgParams.sctpParams.duPort = DU_PORT;
160 /* CU IP Address and Port*/
161 cuCfgParams.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
162 cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false;
163 cuCfgParams.sctpParams.cuPort = CU_PORT;
166 cuCfgParams.plmn.mcc[0] = PLMN_MCC0;
167 cuCfgParams.plmn.mcc[1] = PLMN_MCC1;
168 cuCfgParams.plmn.mcc[2] = PLMN_MCC2;
169 cuCfgParams.plmn.mnc[0] = PLMN_MNC0;
170 cuCfgParams.plmn.mnc[1] = PLMN_MNC1;
171 cuCfgParams.plmn.mnc[2] = PLMN_MNC2;
174 cuCfgParams.rrcVersion.rrcVer = RRC_VER;
175 cuCfgParams.rrcVersion.extRrcVer = EXT_RRC_VER;
178 /* EGTP Parameters */
179 cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE;
180 cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu;
181 cuCfgParams.egtpParams.localPort = CU_EGTP_PORT;
182 cuCfgParams.egtpParams.destIp.ipV4Pres = TRUE;
183 cuCfgParams.egtpParams.destIp.ipV4Addr = ipv4_du;
184 cuCfgParams.egtpParams.destPort = DU_EGTP_PORT;
185 cuCfgParams.egtpParams.minTunnelId = 0;
186 cuCfgParams.egtpParams.maxTunnelId = 10;
188 } /* End of readCuCfg */
190 /*******************************************************************
192 * @brief Handles Console input
196 * Function : cuConsoleHandler
198 * Functionality: Handles Console input
201 * @return ROK - success
204 * ****************************************************************/
205 void *cuConsoleHandler(void *args)
210 /* Send DL user data to CU when user enters 'd' on console */
211 if((ch = getchar()) == 'd')
213 /* Start Pumping data from CU to DU */
214 DU_LOG("\nEGTP: Sending DL User Data");
219 /**********************************************************************
221 **********************************************************************/