aebf42c55e2f376283dbe03a3ebcf5d283386365
[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 #define RIC_ID 1
26 #define RIC_NAME "ORAN_OAM_RIC"
27 #define DU_IP_V4_ADDR "192.168.130.81"
28 #define RIC_IP_V4_ADDR "192.168.130.80"
29 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
30 #define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
31 #define DU_PORT 36422
32 #define RIC_PORT 36422
33 #define RRC_VER 0
34 #define EXT_RRC_VER 5
35 #define PLMN_MCC0 3
36 #define PLMN_MCC1 1
37 #define PLMN_MCC2 1
38 #define PLMN_MNC0 4
39 #define PLMN_MNC1 8
40 #define PLMN_MNC2 0
41
42 /*******************************************************************
43  *
44  * @brief Handles SCTP notification 
45  *
46  * @details
47  *
48  *    Function : sctpNtfyInd
49  *
50  *    Functionality:
51  *         Handles SCTP notification
52  *
53  * @params[in] sctp notification
54  * @return void
55  *
56  ******************************************************************/
57 void sctpNtfyInd(CmInetSctpNotification *ntfy)
58 {
59 //TODO
60 }
61
62 void init_log()
63 {
64         openlog("RIC_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
65 }
66 /*******************************************************************
67  *
68  * @brief Main function of E2 APP
69  *
70  * @details
71  *
72  *    Function : main
73  *
74  *    Functionality:
75  *         - Reads RIC related configurations
76  *         - Initialize SCTP Parameters
77  *         - Start SCTP receiver thread
78  *
79  * @params[in] 
80  * @return ROK     - success
81  *         RFAILED - failure
82  *
83  * ****************************************************************/
84
85 uint8_t tst()
86 {
87    init_log();   
88  
89    DU_LOG("\nStarting RIC_STUB");
90    /* Read RIC configurations */
91    readRicCfg();
92
93    /* Start RIC-SCTP to listen on incoming connection */
94    sctpCfgReq();
95    sctpStartReq();
96
97    return ROK;
98 }
99 /*******************************************************************
100  *
101  * @brief Read RIC related configuration
102  *
103  * @details
104  *
105  *    Function : readRicCfg
106  *
107  *    Functionality:
108  *            - Read RIC related configuration
109  *
110  * @params[in] 
111  * @return ROK     - success
112  *         RFAILED - failure
113  *
114  * ****************************************************************/
115
116 void readRicCfg()
117 {
118    uint32_t ipv4_du, ipv4_ric;
119
120    DU_LOG("\nReading RIC configurations");
121
122    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
123    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
124  
125    ricCfgParams.ricId = RIC_ID;
126    strcpy(ricCfgParams.ricName, RIC_NAME);
127  
128    /* DU IP Address and Port*/
129    ricCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
130    ricCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
131    ricCfgParams.sctpParams.duPort = DU_PORT;
132
133    /* RIC IP Address and Port*/
134    ricCfgParams.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
135    ricCfgParams.sctpParams.ricIpAddr.ipV6Pres = false;
136    ricCfgParams.sctpParams.ricPort = RIC_PORT;
137
138    /*PLMN*/
139    ricCfgParams.plmn.mcc[0] = PLMN_MCC0;
140    ricCfgParams.plmn.mcc[1] = PLMN_MCC1;
141    ricCfgParams.plmn.mcc[2] = PLMN_MCC2;
142    ricCfgParams.plmn.mnc[0] = PLMN_MNC0;
143    ricCfgParams.plmn.mnc[1] = PLMN_MNC1;
144    ricCfgParams.plmn.mnc[2] = PLMN_MNC2;
145   
146 } /* End of readCuCfg */
147 /**********************************************************************
148          End of file
149 **********************************************************************/