[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-528] Optimization in RIC subscription procedure
[o-du/l2.git] / src / du_app / du_e2_conversions.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 file contains functions that maps values received in F1AP message with
20  * its corresponding values used in DU and vice-versa */
21
22 #include "common_def.h"
23 #include "TimeToWaitE2.h"
24 #include "du_app_mac_inf.h"
25 #include "du_e2ap_mgr.h"
26
27 /************************************************************************
28  *
29  * @brief Converts enum values into actual value of E2 wait timer
30  *
31  * @details
32  *
33  *    Function : covertE2WaitTimerEnumToValue
34  *
35  *    Functionality: Converts enum values into actual value of E2 wait timer 
36  *
37  * @params[in] Enum value of e2 wait timer 
38  * @return Actual value of e2 wait timer
39  *
40  * **********************************************************************/
41
42 uint8_t covertE2WaitTimerEnumToValue(uint8_t timerToWait)
43 {
44    switch(timerToWait)
45    {
46       case TimeToWaitE2_v1s:
47          return 1;
48          
49       case TimeToWaitE2_v2s:
50          return 2;
51          
52       case TimeToWaitE2_v5s:
53          return 5;
54          
55       case TimeToWaitE2_v10s:
56          return 10;
57          
58       case TimeToWaitE2_v20s:
59          return 20;
60          
61       case TimeToWaitE2_v60s:
62          return 60;
63          
64       default:
65          DU_LOG("\nERROR  -->  F1AP: Invalid value of E2 Wait timer");
66    }
67    return RFAILED;
68 }
69
70 /*******************************************************************
71  *
72  * @brief Converts DU specific failure cause to E2 interface
73  *        failure cause
74  *
75  * @details
76  *
77  *    Function : convertDuCauseToE2Cause
78  *
79  *    Functionality: Converts DU specific failure cause to E2 
80  *       interface failure cause
81  *
82  * @params[in] DU specific failure cause
83  *             E2 specific failure cause
84  *
85  * @return void
86  *
87  * ****************************************************************/
88 void convertDuCauseToE2Cause(CauseOfResult l2Cause, E2FailureCause *failureCause)
89 {
90    switch(l2Cause)
91    {
92       case PARAM_INVALID:
93          {
94             failureCause->causeType = E2_RIC_REQUEST;
95             failureCause->cause = E2_ACTION_NOT_SUPPORTED;
96             break;
97          }
98       case RESOURCE_UNAVAILABLE:
99          {
100             failureCause->causeType = E2_RIC_REQUEST;
101             failureCause->cause = E2_FUNCTION_RESOURCE_LIMIT;
102             break;
103          }
104       default:
105          {
106             failureCause->causeType = E2_RIC_REQUEST;
107             failureCause->cause = E2_RIC_REQUEST_CAUSE_UNSPECIFIED;
108             break;
109          }
110    }
111 }
112
113 /**********************************************************************
114   End of file
115  **********************************************************************/