Updated E2AP ports
[o-du/l2.git] / src / ric_stub / ric_stub.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /* This functions contains main() for ric_app */
20 #include "common_def.h"
21 #include "ric_stub.h"
22 #include "ric_stub_sctp.h"
23 #include "du_log.h"
24
25 #ifdef O1_ENABLE
26 #include "Config.h"
27 #endif
28
29 #define RIC_ID 1
30 #define RIC_NAME "ORAN_OAM_RIC"
31
32 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
33 #define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
34
35 #ifndef O1_ENABLE
36
37 #define DU_IP_V4_ADDR "192.168.130.81"
38 #define RIC_IP_V4_ADDR "192.168.130.80"
39 #define DU_PORT 36421
40 #define RIC_PORT 36421
41
42 #endif
43
44 #define RRC_VER 0
45 #define EXT_RRC_VER 5
46 #define PLMN_MCC0 3
47 #define PLMN_MCC1 1
48 #define PLMN_MCC2 1
49 #define PLMN_MNC0 4
50 #define PLMN_MNC1 8
51 #define PLMN_MNC2 0
52
53 #ifdef O1_ENABLE
54
55 extern StartupConfig g_cfg;
56
57 #endif
58
59 /*******************************************************************
60  *
61  * @brief Handles SCTP notification 
62  *
63  * @details
64  *
65  *    Function : sctpNtfyInd
66  *
67  *    Functionality:
68  *         Handles SCTP notification
69  *
70  * @params[in] sctp notification
71  * @return void
72  *
73  ******************************************************************/
74 void sctpNtfyInd(CmInetSctpNotification *ntfy)
75 {
76 //TODO
77 }
78
79 void init_log()
80 {
81         openlog("RIC_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
82 }
83 /*******************************************************************
84  *
85  * @brief Main function of E2 APP
86  *
87  * @details
88  *
89  *    Function : main
90  *
91  *    Functionality:
92  *         - Reads RIC related configurations
93  *         - Initialize SCTP Parameters
94  *         - Start SCTP receiver thread
95  *
96  * @params[in] 
97  * @return ROK     - success
98  *         RFAILED - failure
99  *
100  * ****************************************************************/
101
102 uint8_t tst()
103 {
104    init_log();   
105  
106    DU_LOG("\nINFO  --> RIC : Starting RIC_STUB");
107    /* Read RIC configurations */
108    readRicCfg();
109
110    /* Start RIC-SCTP to listen on incoming connection */
111    sctpCfgReq();
112    sctpStartReq();
113
114    return ROK;
115 }
116 /*******************************************************************
117  *
118  * @brief Read RIC related configuration
119  *
120  * @details
121  *
122  *    Function : readRicCfg
123  *
124  *    Functionality:
125  *            - Read RIC related configuration
126  *
127  * @params[in] 
128  * @return ROK     - success
129  *         RFAILED - failure
130  *
131  * ****************************************************************/
132
133 void readRicCfg()
134 {
135    uint32_t ipv4_du, ipv4_ric;
136
137    DU_LOG("\nINFO  --> RIC : Reading RIC configurations");
138
139 #ifdef O1_ENABLE
140    if( getStartupConfig(&g_cfg) != ROK )
141    {
142       RETVALUE(RFAILED);
143    }
144    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr,  &ipv4_du);
145    cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
146
147    ricCfgParams.sctpParams.duPort = g_cfg.RIC_Port;
148    ricCfgParams.sctpParams.ricPort = g_cfg.RIC_Port;
149 #else
150    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
151    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
152
153    ricCfgParams.sctpParams.duPort = DU_PORT;
154    ricCfgParams.sctpParams.ricPort = RIC_PORT;
155 #endif
156     
157    ricCfgParams.ricId = RIC_ID;
158    strcpy(ricCfgParams.ricName, RIC_NAME);
159  
160    /* DU IP Address and Port*/
161    ricCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
162    ricCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
163
164    /* RIC IP Address and Port*/
165    ricCfgParams.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
166    ricCfgParams.sctpParams.ricIpAddr.ipV6Pres = false;
167
168    /*PLMN*/
169    ricCfgParams.plmn.mcc[0] = PLMN_MCC0;
170    ricCfgParams.plmn.mcc[1] = PLMN_MCC1;
171    ricCfgParams.plmn.mcc[2] = PLMN_MCC2;
172    ricCfgParams.plmn.mnc[0] = PLMN_MNC0;
173    ricCfgParams.plmn.mnc[1] = PLMN_MNC1;
174    ricCfgParams.plmn.mnc[2] = PLMN_MNC2;
175   
176 } /* End of readCuCfg */
177 /**********************************************************************
178          End of file
179 **********************************************************************/