Adding release file
[o-du/l2.git] / src / du_app / du_app_sctp_intf.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 handler for DU APP and SCTP interface functions */
20
21 #include "du_sctp.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 S16 cmPkSctpNtfy(CmInetSctpNotification *ntfy)
41 {
42    Buffer *mBuf;
43
44    if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
45    {
46       printf("\nFailed to allocate memory");
47       RETVALUE(RFAILED);
48    }
49
50    if(ntfy->header.nType == CM_INET_SCTP_ASSOC_CHANGE)
51    {
52       SPkU16(ntfy->u.assocChange.state, mBuf);
53    }
54    SPkU16(ntfy->header.nType, mBuf);
55
56    sendToDuApp(mBuf, EVTSCTPNTFY);
57    RETVALUE(ROK);
58 }
59
60 /*******************************************************************
61  *
62  * @brief Unpacks SCTP notification 
63  *
64  * @details
65  *
66  *    Function : cmUnpkSctpNtfy 
67  *
68  *    Functionality:
69  *       Unpacks SCTP notification 
70  *
71  * @params[in] 
72  * @return ROK     - success
73  *         RFAILED - failure
74  *
75  * ****************************************************************/
76
77 S16 cmUnpkSctpNtfy(SctpNtfy func, Pst *pst, Buffer *mBuf)
78 {
79    CmInetSctpNotification ntfy;
80    cmMemset((U8*)&ntfy, 0, sizeof(CmInetSctpNotification));
81
82    SUnpkU16(&(ntfy.header.nType), mBuf);
83    if(ntfy.header.nType == CM_INET_SCTP_ASSOC_CHANGE)
84    {
85       SUnpkU16(&(ntfy.u.assocChange.state), mBuf);
86    }
87
88    RETVALUE((*func)(mBuf, &ntfy));
89 }
90
91 /**********************************************************************
92          End of file
93 **********************************************************************/