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 EGTP interface functions */
20 #include "common_def.h"
28 /*******************************************************************
30 * @brief Packs EGTP confirm status
34 * Function : packEgtpCfmStatus
37 * Packs EGTP confirm status
39 * @params[in] Confirm status
41 * @return ROK - success
44 ******************************************************************/
45 S16 packEgtpCfmStatus(CmStatus cfm, Buffer *mBuf)
47 SPkU16(cfm.status, mBuf);
48 SPkU16(cfm.reason, mBuf);
53 /*******************************************************************
55 * @brief Unpacks EGTP confirm status
59 * Function : unpackEgtpCfmStatus
62 * Packs EGTP confirm status
64 * @params[in] Confirm status
66 * @return ROK - success
69 ******************************************************************/
71 S16 unpackEgtpCfmStatus(CmStatus *cfm, Buffer *mBuf)
73 SUnpkU16(&(cfm->reason), mBuf);
74 SUnpkU16(&(cfm->status), mBuf);
79 /*******************************************************************
81 * @brief Packs EGTP configuration
85 * Function : packEgtpCfgReq
88 * Packs EGTP configuration
90 * @params[in] Post structure
92 * @return ROK - success
95 ******************************************************************/
96 S16 packEgtpCfgReq(Pst *pst, EgtpConfig egtpCfg)
100 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
102 printf("\nDU_APP : Failed to allocate memory");
105 if(egtpCfg.localIp.ipV4Pres)
107 SPkU32(egtpCfg.localIp.ipV4Addr, mBuf);
109 cmPkBool(egtpCfg.localIp.ipV4Pres, mBuf);
110 SPkU16(egtpCfg.localPort, mBuf);
112 if(egtpCfg.destIp.ipV4Pres)
114 SPkU32(egtpCfg.destIp.ipV4Addr, mBuf);
116 cmPkBool(egtpCfg.destIp.ipV4Pres, mBuf);
117 SPkU16(egtpCfg.destPort, mBuf);
119 SPkU32(egtpCfg.minTunnelId, mBuf);
120 SPkU32(egtpCfg.maxTunnelId, mBuf);
127 /*******************************************************************
129 * @brief Unpacks EGTP configuration
133 * Function : unpackEgtpCfgReq
136 * Unpacks EGTP configuration
138 * @params[in] Configuration Request handler
141 * @return ROK - success
144 * ****************************************************************/
145 S16 unpackEgtpCfgReq(EgtpCfgReq func, Pst *pst, Buffer *mBuf)
149 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
151 SUnpkU32(&(egtpCfg.maxTunnelId), mBuf);
152 SUnpkU32(&(egtpCfg.minTunnelId), mBuf);
154 SUnpkU16(&(egtpCfg.destPort), mBuf);
155 cmUnpkBool(&(egtpCfg.destIp.ipV4Pres), mBuf);
156 if(egtpCfg.destIp.ipV4Pres)
158 SUnpkU32(&(egtpCfg.destIp.ipV4Addr), mBuf);
161 SUnpkU16(&(egtpCfg.localPort), mBuf);
162 cmUnpkBool(&(egtpCfg.localIp.ipV4Pres), mBuf);
163 if(egtpCfg.localIp.ipV4Pres)
165 SUnpkU32(&(egtpCfg.localIp.ipV4Addr), mBuf);
170 RETVALUE((*func)(pst, egtpCfg));
174 /*******************************************************************
176 * @brief Packs EGTP configuration results
180 * Function : packEgtpCfgCfm
183 * Packs EGTP configuration result
185 * @params[in] Post structure
187 * @return ROK - success
190 ******************************************************************/
192 S16 packEgtpCfgCfm(Pst *pst, CmStatus cfm)
196 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
198 printf("\nEGTP : Failed to allocate memory");
202 packEgtpCfmStatus(cfm, mBuf);
207 /*******************************************************************
209 * @brief Unpacks EGTP configuration results
213 * Function : unpackEgtpCfgCfm
216 * Unpacks EGTP configuration result
218 * @params[in] Config Cfm Hanlder
220 * @return ROK - success
223 ******************************************************************/
225 S16 unpackEgtpCfgCfm(EgtpCfgCfm func, Buffer *mBuf)
229 cmMemset((U8 *)&cfm, 0, sizeof(CmStatus));
230 unpackEgtpCfmStatus(&cfm, mBuf);
232 RETVALUE((*func)(cfm));
235 /*******************************************************************
237 * @brief Packs EGTP server open request
241 * Function : packEgtpSrvOpenReq
244 * Packs EGTP server open request
246 * @params[in] Post structure
247 * @return ROK - success
250 *******************************************************************/
251 S16 packEgtpSrvOpenReq(Pst *pst)
255 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
257 printf("\nDU_APP : Failed to allocate memory");
265 /*******************************************************************
267 * @brief Unpacks EGTP server open req
271 * Function : unpackEgtpSrvOpenReq
274 * Unpacks EGTP server open req
276 * @params[in] Hanlder function pointer
278 * @return ROK - success
281 ******************************************************************/
282 S16 unpackEgtpSrvOpenReq(EgtpSrvOpenReq func, Pst *pst, Buffer *mBuf)
284 RETVALUE((*func)(pst));
288 /*******************************************************************
290 * @brief Packs EGTP server open confirm
294 * Function : packEgtpSrvOpenCfm
297 * Packs EGTP server open confirm
299 * @params[in] Post structure
300 * @return ROK - success
303 *******************************************************************/
304 S16 packEgtpSrvOpenCfm(Pst *pst, CmStatus cfm)
308 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
310 printf("\nEGTP : Failed to allocate memory");
314 packEgtpCfmStatus(cfm, mBuf);
320 /*******************************************************************
322 * @brief Unpacks EGTP server open confirm
326 * Function : unpackEgtpSrvOpenCfm
329 * Unpacks EGTP server open confirm
331 * @params[in] Hanlder function pointer
333 * @return ROK - success
336 *******************************************************************/
337 S16 unpackEgtpSrvOpenCfm(EgtpSrvOpenCfm func, Buffer *mBuf)
341 cmMemset((U8 *)&cfm, 0, sizeof(CmStatus));
342 unpackEgtpCfmStatus(&cfm, mBuf);
344 RETVALUE((*func)(cfm));
347 /*******************************************************************
349 * @brief Packs EGTP tunnel management request
353 * Function : packEgtpTnlMgmtReq
356 * Packs EGTP tunnel management request
358 * @params[in] Post structure
360 * Local tunnel endpoint id
361 * Remote tunnel endpoint id
362 * @return ROK - success
365 *******************************************************************/
366 S16 packEgtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
370 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
372 printf("\nDU_APP : Failed to allocate memory");
376 SPkU8(tnlEvt.action, mBuf);
377 SPkU32(tnlEvt.lclTeid, mBuf);
378 SPkU32(tnlEvt.remTeid, mBuf);
385 /*******************************************************************
387 * @brief Unpacks EGTP tunnel management request
391 * Function : unpackEgtpTnlMgmtReq
394 * Unpacks EGTP tunnel management request
396 * @params[in] Hanlder function pointer
399 * @return ROK - success
402 * *******************************************************************/
403 S16 unpackEgtpTnlMgmtReq(EgtpTnlMgmtReq func, Pst *pst, Buffer *mBuf)
407 cmMemset((U8 *)&tnlEvt, 0, sizeof(EgtpTnlEvt));
409 SUnpkU32(&(tnlEvt.remTeid), mBuf);
410 SUnpkU32(&(tnlEvt.lclTeid), mBuf);
411 SUnpkU8(&(tnlEvt.action), mBuf);
413 RETVALUE((* func)(pst, tnlEvt));
417 /*******************************************************************
419 * @brief Packs EGTP tunnel management confirm
423 * Function : packEgtpTnlMgmtCfm
426 * Packs EGTP tunnel management cfm
428 * @params[in] Post structure
429 * Tunnel Event structure
431 * @return ROK - success
434 ********************************************************************/
436 S16 packEgtpTnlMgmtCfm(Pst *pst, EgtpTnlEvt tnlEvt)
440 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
442 printf("\nEGTP : Failed to allocate memory");
446 SPkU8(tnlEvt.action, mBuf);
447 SPkU32(tnlEvt.lclTeid, mBuf);
448 SPkU32(tnlEvt.remTeid, mBuf);
450 packEgtpCfmStatus(tnlEvt.cfmStatus, mBuf);
457 /*******************************************************************
459 * @brief Unpacks EGTP tunnel management confirm
463 * Function : unpackEgtpTnlMgmtCfm
466 * Unpacks EGTP tunnel management confirm
468 * @params[in] Hanlder function pointer
471 * @return ROK - success
474 * *******************************************************************/
475 S16 unpackEgtpTnlMgmtCfm(EgtpTnlMgmtCfm func, Buffer *mBuf)
479 cmMemset((U8 *)&tnlEvt, 0, sizeof(EgtpTnlEvt));
481 unpackEgtpCfmStatus(&(tnlEvt.cfmStatus), mBuf);
482 SUnpkU32(&(tnlEvt.remTeid), mBuf);
483 SUnpkU32(&(tnlEvt.lclTeid), mBuf);
484 SUnpkU8(&(tnlEvt.action), mBuf);
486 RETVALUE((* func)(tnlEvt));
490 /*******************************************************************
492 * @brief Packs Slot indication and sends to EGTP
496 * Function : packEgtpSlotInd
499 * Packs slot indication and sends tp EGTP
501 * @params[in] Post structure
502 * @return ROK - success
505 *******************************************************************/
506 S16 packEgtpSlotInd(Pst *pst)
510 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
512 printf("\nDU_APP : Failed to allocate memory");
521 /*******************************************************************
523 * @brief Unpacks slot indication
527 * Function : unpackEgtpSlotInd
530 * Unpacks slot indication
533 * @return ROK - success
536 ******************************************************************/
537 S16 unpackEgtpSlotInd(EgtpSlotInd func, Pst *pst, Buffer *mBuf)