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 */
23 /*******************************************************************
25 * @brief Packs SCTP configuration
29 * Function : cmPkSctpAssocReq
32 * Packs SCTP configuration
34 * @params[in] Notification
35 * @return ROK - success
38 ******************************************************************/
39 S16 cmPkSctpAssocReq(Pst *pst, F1SctpParams sctpCfgParam)
43 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
45 printf("\nDU_APP : Failed to allocate memory");
49 if(sctpCfgParam.duIpAddr.ipV4Pres)
51 SPkU32(sctpCfgParam.duIpAddr.ipV4Addr, mBuf);
53 cmPkBool(sctpCfgParam.duIpAddr.ipV4Pres, mBuf);
54 SPkU16(sctpCfgParam.duPort, mBuf);
56 if(sctpCfgParam.cuIpAddr.ipV4Pres)
58 SPkU32(sctpCfgParam.cuIpAddr.ipV4Addr, mBuf);
60 cmPkBool(sctpCfgParam.cuIpAddr.ipV4Pres, mBuf);
61 SPkU16(sctpCfgParam.cuPort, mBuf);
68 /*******************************************************************
70 * @brief Unpacks SCTP configuration
74 * Function : cmUnpkSctpAssocReq
77 * Unpacks SCTP configuration
79 * @params[in] Notification
80 * @return ROK - success
83 ******************************************************************/
84 S16 cmUnpkSctpAssocReq(Buffer *mBuf)
86 cmMemset((U8*)&sctpCfg, 0, sizeof(F1SctpParams));
88 SUnpkU16(&(sctpCfg.cuPort), mBuf);
89 cmUnpkBool(&(sctpCfg.cuIpAddr.ipV4Pres), mBuf);
90 if(sctpCfg.cuIpAddr.ipV4Pres)
92 SUnpkU32(&(sctpCfg.cuIpAddr.ipV4Addr), mBuf);
95 SUnpkU16(&(sctpCfg.duPort), mBuf);
96 cmUnpkBool(&(sctpCfg.duIpAddr.ipV4Pres), mBuf);
97 if(sctpCfg.duIpAddr.ipV4Pres)
99 SUnpkU32(&(sctpCfg.duIpAddr.ipV4Addr), mBuf);
105 /*******************************************************************
107 * @brief Packs SCTP notification
111 * Function : cmPkSctpNtfy
114 * Packs SCTP notification
116 * @params[in] Notification
117 * @return ROK - success
120 * ****************************************************************/
122 S16 cmPkSctpNtfy(Pst *pst, CmInetSctpNotification *ntfy)
126 if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
128 printf("\nSCTP : Failed to allocate memory");
132 if(ntfy->header.nType == CM_INET_SCTP_ASSOC_CHANGE)
134 SPkU16(ntfy->u.assocChange.state, mBuf);
136 SPkU16(ntfy->header.nType, mBuf);
138 if (SPstTsk(pst, mBuf) != ROK)
140 printf("\nSCTP : SPstTsk failed while sending SCTP notification");
147 /*******************************************************************
149 * @brief Unpacks SCTP notification
153 * Function : cmUnpkSctpNtfy
156 * Unpacks SCTP notification
159 * @return ROK - success
162 * ****************************************************************/
164 S16 cmUnpkSctpNtfy(SctpNtfy func, Pst *pst, Buffer *mBuf)
166 CmInetSctpNotification ntfy;
167 cmMemset((U8*)&ntfy, 0, sizeof(CmInetSctpNotification));
169 SUnpkU16(&(ntfy.header.nType), mBuf);
170 if(ntfy.header.nType == CM_INET_SCTP_ASSOC_CHANGE)
172 SUnpkU16(&(ntfy.u.assocChange.state), mBuf);
175 RETVALUE((*func)(mBuf, &ntfy));
178 /**********************************************************************
180 **********************************************************************/