1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 #include "common_def.h"
24 #include "du_e2ap_mgr.h"
25 #include "du_app_mac_inf.h"
26 #include "du_app_rlc_inf.h"
27 #include "du_e2ap_msg_hdl.h"
31 #include "du_mgr_main.h"
34 /*******************************************************************
36 * @brief Assigns new transaction id to DU initiated procedure
40 * Function : assignTransactionId
42 * Functionality: Assigns new transaction id to a DU initiated
45 * @params[in] Region region
47 * @return ROK - success
50 * ****************************************************************/
51 uint8_t assignTransactionId()
53 uint8_t currTransId = duCb.e2apDb.e2TransInfo.transIdCounter;
55 /* Update to next valid value */
56 duCb.e2apDb.e2TransInfo.transIdCounter++;
57 if(duCb.e2apDb.e2TransInfo.transIdCounter == MAX_NUM_TRANSACTION)
58 duCb.e2apDb.e2TransInfo.transIdCounter = 0;
63 /*******************************************************************
65 * @brief Sends E2 msg over SCTP
69 * Function : SendE2APMsg
71 * Functionality: Sends E2 msg over SCTP
73 * @params[in] Region region
75 * @return ROK - success
78 * ****************************************************************/
80 uint8_t SendE2APMsg(Region region, Pool pool, char *encBuf, int encBufSize)
84 if(ODU_GET_MSG_BUF(region, pool, &mBuf) == ROK)
86 if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
88 ODU_PRINT_MSG(mBuf, 0,0);
90 if(sctpSend(mBuf, E2_INTERFACE) != ROK)
92 DU_LOG("\nERROR --> E2AP : SCTP Send for E2 failed");
93 ODU_PUT_MSG_BUF(mBuf);
99 DU_LOG("\nERROR --> E2AP : ODU_ADD_POST_MSG_MULT failed");
100 ODU_PUT_MSG_BUF(mBuf);
103 ODU_PUT_MSG_BUF(mBuf);
107 DU_LOG("\nERROR --> E2AP : Failed to allocate memory");
114 /*******************************************************************
120 * Function : ResetE2Request
122 * Functionality: This function resets E2.
123 * As per ORAN WG3 E2GAP v3.0 Spec, section 5.5.3
124 * If E2 node initates reset procedure then:
125 * a. Send reset request to RIC
126 * b. Delete any pre-established RIC subscriptions
127 * c. Gracefully terminates any ongoing RIC services
128 * If RIC initiates reset procedure then :
129 * a. Delete any pre-established RIC subscriptions
130 * b. Gracefully terminates any ongoing RIC services
131 * c. Send reset response to RIC
134 * @return ROK - success
137 * ****************************************************************/
138 uint8_t ResetE2Request(E2ProcedureDirection dir, E2FailureCause resetCause)
140 /* Send Reset Request to RIC if DU detects any abnormal failure */
141 if(dir == E2_NODE_INITIATED)
143 if(BuildAndSendE2ResetRequest(resetCause) != ROK)
145 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest failed");
150 /* TODO when RIC subscription service model is implemented
151 Process following steps of resetting E2
152 1. Deletes any pre-established RIC subscriptions
153 2. Gracefully terminates any ongoing RIC services
156 /* Send Reset Response if RIC initiated Reset request is received at DU */
157 if(dir == RIC_INITIATED)
159 //BuildAndSendE2ResetResponse();
164 /**********************************************************************
166 **********************************************************************/