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 *******************************************************************************/
19 /* This file contains DU APP and SCTP interface functions */
20 #include "common_def.h"
23 /*******************************************************************
25 * @brief Packs SCTP notification
29 * Function : cmPkSctpNtfy
32 * Packs SCTP notification
34 * @params[in] Notification
35 * @return ROK - success
38 * ****************************************************************/
40 uint8_t cmPkSctpNtfy(Pst *pst, CmInetSctpNotification *ntfy)
44 if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
46 DU_LOG("\nERROR --> SCTP : Failed to allocate memory");
50 if(ntfy->header.nType == CM_INET_SCTP_ASSOC_CHANGE)
52 oduUnpackUInt16(ntfy->u.assocChange.state, mBuf);
53 oduUnpackUInt32(ntfy->u.assocChange.assocId, mBuf);
55 oduUnpackUInt16(ntfy->header.nType, mBuf);
57 if (ODU_POST_TASK(pst, mBuf) != ROK)
59 DU_LOG("\nERROR --> SCTP : ODU_POST_TASK failed while sending SCTP notification");
66 /*******************************************************************
68 * @brief Unpacks SCTP notification
72 * Function : cmUnpkSctpNtfy
75 * Unpacks SCTP notification
78 * @return ROK - success
81 * ****************************************************************/
83 uint8_t cmUnpkSctpNtfy(SctpNtfy func, Pst *pst, Buffer *mBuf)
85 CmInetSctpNotification ntfy;
86 memset(&ntfy, 0, sizeof(CmInetSctpNotification));
88 oduPackUInt16(&(ntfy.header.nType), mBuf);
89 if(ntfy.header.nType == CM_INET_SCTP_ASSOC_CHANGE)
91 oduPackUInt32(&(ntfy.u.assocChange.assocId), mBuf);
92 oduPackUInt16(&(ntfy.u.assocChange.state), mBuf);
95 return ((*func)(mBuf, &ntfy));
98 /**********************************************************************
100 **********************************************************************/