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