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