Initial commit for Bronze release
[o-du/l2.git] / src / cu_stub / cu_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 cu_app */
20
21 #include "cu_stub.h"
22 #include "cu_stub_sctp.h"
23 #include "cu_stub_egtp.h"
24
25 #define CU_ID 1
26 #define CU_NAME "ORAN_OAM_CU"
27 #define DU_IP_V4_ADDR "10.0.2.20"
28 #define CU_IP_V4_ADDR "10.0.2.25"
29 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
30 #define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
31 #define DU_PORT 38472
32 #define CU_PORT 38472 
33 #define DU_EGTP_PORT 39001
34 #define CU_EGTP_PORT 39002
35 #define RRC_VER 0
36 #define EXT_RRC_VER 5
37 #define PLMN_MCC0 3
38 #define PLMN_MCC1 1
39 #define PLMN_MCC2 1
40 #define PLMN_MNC0 4
41 #define PLMN_MNC1 8
42 #define PLMN_MNC2 0
43
44 /*******************************************************************
45  *
46  * @brief Handles SCTP notification 
47  *
48  * @details
49  *
50  *    Function : sctpNtfyInd
51  *
52  *    Functionality:
53  *         Handles SCTP notification
54  *
55  * @params[in] sctp notification
56  * @return void
57  *
58  ******************************************************************/
59 void sctpNtfyInd(CmInetSctpNotification *ntfy)
60 {
61 //TODO
62 }
63
64 void init_log()
65 {
66         openlog("CU_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
67 }
68 /*******************************************************************
69  *
70  * @brief Main function of CU APP
71  *
72  * @details
73  *
74  *    Function : main
75  *
76  *    Functionality:
77  *         - Reads CU related configurations
78  *         - Initialize SCTP Parameters
79  *         - Start SCTP receiver thread
80  *
81  * @params[in] 
82  * @return ROK     - success
83  *         RFAILED - failure
84  *
85  * ****************************************************************/
86
87 S16 tst()
88 {
89    init_log();   
90    DU_LOG("\nStarting CU_STUB");
91    /* Read CU configurations */
92    readCuCfg();
93
94    /* Start CU-EGTP */
95    egtpActvInit();
96    egtpInitReq();
97
98    /* Initializing SCTP global parameters */
99    sctpActvInit();
100  
101    /* Start CU-SCTP to listen on incoming connection */
102    sctpStartReq(); 
103
104    RETVALUE(ROK);
105 }
106
107 /*******************************************************************
108  *
109  * @brief Read CU related configuration
110  *
111  * @details
112  *
113  *    Function : readCuCfg
114  *
115  *    Functionality:
116  *            - RRead CU related configuration
117  *
118  * @params[in] 
119  * @return ROK     - success
120  *         RFAILED - failure
121  *
122  * ****************************************************************/
123
124 void readCuCfg()
125 {
126    U32 ipv4_du, ipv4_cu;
127
128    DU_LOG("\nReading CU configurations");
129
130    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
131    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
132    //U32 ipv6_int = inet_addr(DU_IP_V6_ADDR);
133  
134    cuCfgParams.cuId = CU_ID;
135    strcpy(cuCfgParams.cuName, CU_NAME);
136  
137    /* DU IP Address and Port*/
138    cuCfgParams.sctpParams.duIpAddr.ipV4Pres = true;
139    cuCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
140    cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
141    //strcpy(cuCfgParams.sctpParams.duIpAddr.ipV6Addr, (char*)DU_IP_V6_ADDR);
142    cuCfgParams.sctpParams.duPort = DU_PORT;
143
144    /* CU IP Address and Port*/
145    cuCfgParams.sctpParams.cuIpAddr.ipV4Pres = true;
146    cuCfgParams.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
147    cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false;
148    //strcpy(cuCfgParams.sctpParams.cuIpAddr.ipV6Addr, DU_IP_V6_ADDR);
149    cuCfgParams.sctpParams.cuPort = CU_PORT;
150
151    /*PLMN*/
152    cuCfgParams.plmn.mcc[0] = PLMN_MCC0;
153    cuCfgParams.plmn.mcc[1] = PLMN_MCC1;
154    cuCfgParams.plmn.mcc[2] = PLMN_MCC2;
155    cuCfgParams.plmn.mnc[0] = PLMN_MNC0;
156    cuCfgParams.plmn.mnc[1] = PLMN_MNC1;
157    cuCfgParams.plmn.mnc[2] = PLMN_MNC2;
158
159    /*RRC Version*/
160    cuCfgParams.rrcVersion.rrcVer = RRC_VER;
161    cuCfgParams.rrcVersion.extRrcVer = EXT_RRC_VER;
162
163
164    /* EGTP Parameters */
165    cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE;
166    cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu;
167    cuCfgParams.egtpParams.localPort = CU_EGTP_PORT;
168    cuCfgParams.egtpParams.destIp.ipV4Pres = TRUE;
169    cuCfgParams.egtpParams.destIp.ipV4Addr = ipv4_du;
170    cuCfgParams.egtpParams.destPort = DU_EGTP_PORT;
171    cuCfgParams.egtpParams.minTunnelId = 0;
172    cuCfgParams.egtpParams.maxTunnelId = 10;
173
174 } /* End of readCuCfg */
175 /**********************************************************************
176          End of file
177 **********************************************************************/