Moving all common header file into common_def.h file
[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 "lrg.h"
22 #include "legtp.h"
23 #include "du_cfg.h"
24 #include "lkw.x"
25 #include "lrg.x"
26 #include "du_mgr.h"
27 #include "du_sctp.h"
28
29
30 /*******************************************************************
31  *
32  * @brief Packs SCTP notification 
33  *
34  * @details
35  *
36  *    Function : cmPkSctpNtfy
37  *
38  *    Functionality:
39  *       Packs SCTP notification
40  *
41  * @params[in] Notification 
42  * @return ROK     - success
43  *         RFAILED - failure
44  *
45  * ****************************************************************/
46
47 S16 cmPkSctpNtfy(Pst *pst, CmInetSctpNotification *ntfy)
48 {
49    Buffer *mBuf;
50
51    if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
52    {
53       printf("\nSCTP : Failed to allocate memory");
54       RETVALUE(RFAILED);
55    }
56
57    if(ntfy->header.nType == CM_INET_SCTP_ASSOC_CHANGE)
58    {
59       SPkU16(ntfy->u.assocChange.state, mBuf);
60       SPkU32(ntfy->u.assocChange.assocId, mBuf);
61    }
62    SPkU16(ntfy->header.nType, mBuf);
63
64    if (SPstTsk(pst, mBuf) != ROK)
65    {
66       printf("\nSCTP : SPstTsk failed while sending SCTP notification");
67       RETVALUE(RFAILED);
68    }
69
70    RETVALUE(ROK);
71 }
72
73 /*******************************************************************
74  *
75  * @brief Unpacks SCTP notification 
76  *
77  * @details
78  *
79  *    Function : cmUnpkSctpNtfy 
80  *
81  *    Functionality:
82  *       Unpacks SCTP notification 
83  *
84  * @params[in] 
85  * @return ROK     - success
86  *         RFAILED - failure
87  *
88  * ****************************************************************/
89
90 S16 cmUnpkSctpNtfy(SctpNtfy func, Pst *pst, Buffer *mBuf)
91 {
92    CmInetSctpNotification ntfy;
93    cmMemset((U8*)&ntfy, 0, sizeof(CmInetSctpNotification));
94
95    SUnpkU16(&(ntfy.header.nType), mBuf);
96    if(ntfy.header.nType == CM_INET_SCTP_ASSOC_CHANGE)
97    {
98       SUnpkU32(&(ntfy.u.assocChange.assocId), mBuf);
99       SUnpkU16(&(ntfy.u.assocChange.state), mBuf);
100    }
101
102    RETVALUE((*func)(mBuf, &ntfy));
103 }
104
105 /**********************************************************************
106          End of file
107 **********************************************************************/