CI: Add silent cmake SonarCloud scan
[o-du/l2.git] / src / cm / lsctp.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 DU APP and SCTP interface functions */
20 #include "common_def.h"
21 #include "lsctp.h"
22
23 /*******************************************************************
24  *
25  * @brief Packs SCTP notification 
26  *
27  * @details
28  *
29  *    Function : cmPkSctpNtfy
30  *
31  *    Functionality:
32  *       Packs SCTP notification
33  *
34  * @params[in] Notification 
35  * @return ROK     - success
36  *         RFAILED - failure
37  *
38  * ****************************************************************/
39
40 uint8_t cmPkSctpNtfy(Pst *pst, CmInetSctpNotification *ntfy)
41 {
42    Buffer *mBuf;
43
44    if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
45    {
46       DU_LOG("\nERROR  -->  SCTP : Failed to allocate memory");
47       return RFAILED;
48    }
49
50    if(ntfy->header.nType == CM_INET_SCTP_ASSOC_CHANGE)
51    {
52       oduUnpackUInt16(ntfy->u.assocChange.state, mBuf);
53       oduUnpackUInt32(ntfy->u.assocChange.assocId, mBuf);
54    }
55    oduUnpackUInt16(ntfy->header.nType, mBuf);
56
57    if (ODU_POST_TASK(pst, mBuf) != ROK)
58    {
59       DU_LOG("\nERROR  -->  SCTP : ODU_POST_TASK failed while sending SCTP notification");
60       return RFAILED;
61    }
62
63    return ROK;
64 }
65
66 /*******************************************************************
67  *
68  * @brief Unpacks SCTP notification 
69  *
70  * @details
71  *
72  *    Function : cmUnpkSctpNtfy 
73  *
74  *    Functionality:
75  *       Unpacks SCTP notification 
76  *
77  * @params[in] 
78  * @return ROK     - success
79  *         RFAILED - failure
80  *
81  * ****************************************************************/
82
83 uint8_t cmUnpkSctpNtfy(SctpNtfy func, Pst *pst, Buffer *mBuf)
84 {
85    CmInetSctpNotification ntfy;
86    memset(&ntfy, 0, sizeof(CmInetSctpNotification));
87
88    oduPackUInt16(&(ntfy.header.nType), mBuf);
89    if(ntfy.header.nType == CM_INET_SCTP_ASSOC_CHANGE)
90    {
91       oduPackUInt32(&(ntfy.u.assocChange.assocId), mBuf);
92       oduPackUInt16(&(ntfy.u.assocChange.state), mBuf);
93    }
94
95    return ((*func)(mBuf, &ntfy));
96 }
97
98 /**********************************************************************
99          End of file
100 **********************************************************************/