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 ric_app */
20 #include "common_def.h"
21 #include "ric_stub_sctp.h"
25 #include "CmInterface.h"
29 extern StartupConfig g_cfg;
32 /*******************************************************************
34 * @brief Handles SCTP notification
38 * Function : sctpNtfyInd
41 * Handles SCTP notification
43 * @params[in] sctp notification
46 ******************************************************************/
47 void sctpNtfyInd(CmInetSctpNotification *ntfy)
54 openlog("RIC_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
56 /*******************************************************************
58 * @brief Main function of E2 APP
65 * - Reads RIC related configurations
66 * - Initialize SCTP Parameters
67 * - Start SCTP receiver thread
70 * @return ROK - success
73 * ****************************************************************/
79 DU_LOG("\nINFO --> RIC : Starting RIC_STUB");
80 /* Read RIC configurations */
83 /* Start RIC-SCTP to listen on incoming connection */
85 /*Sleep is introduced for GDB to increase the waiting time for RIC Configuration from DUAPP*/
91 /*******************************************************************
93 * @brief Read RIC related configuration
97 * Function : readRicCfg
100 * - Read RIC related configuration
103 * @return ROK - success
106 * ****************************************************************/
111 uint32_t ipv4_du, ipv4_ric;
113 DU_LOG("\nINFO --> RIC : Reading RIC configurations");
115 ricCb.ricCfgParams.ricId = RIC_ID;
116 strcpy(ricCb.ricCfgParams.ricName, RIC_NAME);
118 if( getStartupConfigForStub(&g_cfg) != ROK )
120 DU_LOG("\nError --> RIC : Could not fetch startup "\
121 "configurations from Netconf interface\n");
125 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
126 cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
128 ricCb.ricCfgParams.sctpParams.destCb[0].destIpAddr.ipV4Addr = ipv4_du;
129 ricCb.ricCfgParams.sctpParams.destCb[0].destIpAddr.ipV6Pres = false;
130 ricCb.ricCfgParams.sctpParams.destCb[0].destPort = g_cfg.RIC_Port;
132 ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_ric;
133 ricCb.ricCfgParams.sctpParams.localIpAddr.ipV6Pres = false;
134 ricCb.ricCfgParams.sctpParams.e2SctpPort = g_cfg.RIC_Port;
136 ricCb.ricCfgParams.sctpParams.numDestNode = 1;
139 /* RIC IP Address and Port*/
140 memset(&ipv4_du, 0, sizeof(uint32_t));
141 cmInetAddr((S8*)LOCAL_IP_RIC, &ipv4_ric);
142 ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_ric;
143 ricCb.ricCfgParams.sctpParams.localIpAddr.ipV6Pres = false;
144 ricCb.ricCfgParams.sctpParams.e2SctpPort = E2_SCTP_PORT;
146 ricCb.ricCfgParams.sctpParams.numDestNode = 0;
147 numDu = &ricCb.ricCfgParams.sctpParams.numDestNode;
148 while(*numDu < NUM_E2_ASSOC)
150 /* DU IP Address and Port*/
151 memset(&ipv4_du, 0, sizeof(uint32_t));
152 cmInetAddr((S8*)REMOTE_IP_DU[*numDu], &ipv4_du);
153 ricCb.ricCfgParams.sctpParams.destCb[*numDu].destIpAddr.ipV4Addr = ipv4_du;
154 ricCb.ricCfgParams.sctpParams.destCb[*numDu].destIpAddr.ipV6Pres = false;
155 ricCb.ricCfgParams.sctpParams.destCb[*numDu].destPort = E2_SCTP_PORT;
162 ricCb.ricCfgParams.plmn.mcc[0] = PLMN_MCC0;
163 ricCb.ricCfgParams.plmn.mcc[1] = PLMN_MCC1;
164 ricCb.ricCfgParams.plmn.mcc[2] = PLMN_MCC2;
165 ricCb.ricCfgParams.plmn.mnc[0] = PLMN_MNC0;
166 ricCb.ricCfgParams.plmn.mnc[1] = PLMN_MNC1;
167 ricCb.ricCfgParams.plmn.mnc[2] = PLMN_MNC2;
169 } /* End of readCuCfg */
170 /**********************************************************************
172 **********************************************************************/