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 */
24 /*******************************************************************
26 * @brief Packs EGTP confirm status
30 * Function : packEgtpCfmStatus
33 * Packs EGTP confirm status
35 * @params[in] Confirm status
37 * @return ROK - success
40 ******************************************************************/
41 S16 packEgtpCfmStatus(CmStatus cfm, Buffer *mBuf)
43 SPkU16(cfm.status, mBuf);
44 SPkU16(cfm.reason, mBuf);
49 /*******************************************************************
51 * @brief Unpacks EGTP confirm status
55 * Function : unpackEgtpCfmStatus
58 * Packs EGTP confirm status
60 * @params[in] Confirm status
62 * @return ROK - success
65 ******************************************************************/
67 S16 unpackEgtpCfmStatus(CmStatus *cfm, Buffer *mBuf)
69 SUnpkU16(&(cfm->reason), mBuf);
70 SUnpkU16(&(cfm->status), mBuf);
75 /*******************************************************************
77 * @brief Packs EGTP configuration
81 * Function : packEgtpCfgReq
84 * Packs EGTP configuration
86 * @params[in] Post structure
88 * @return ROK - success
91 ******************************************************************/
92 S16 packEgtpCfgReq(Pst *pst, EgtpConfig egtpCfg)
96 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
98 printf("\nDU_APP : Failed to allocate memory");
101 if(egtpCfg.localIp.ipV4Pres)
103 SPkU32(egtpCfg.localIp.ipV4Addr, mBuf);
105 cmPkBool(egtpCfg.localIp.ipV4Pres, mBuf);
106 SPkU16(egtpCfg.localPort, mBuf);
108 if(egtpCfg.destIp.ipV4Pres)
110 SPkU32(egtpCfg.destIp.ipV4Addr, mBuf);
112 cmPkBool(egtpCfg.destIp.ipV4Pres, mBuf);
113 SPkU16(egtpCfg.destPort, mBuf);
115 SPkU32(egtpCfg.minTunnelId, mBuf);
116 SPkU32(egtpCfg.maxTunnelId, mBuf);
123 /*******************************************************************
125 * @brief Unpacks EGTP configuration
129 * Function : unpackEgtpCfgReq
132 * Unpacks EGTP configuration
134 * @params[in] Configuration Request handler
137 * @return ROK - success
140 * ****************************************************************/
141 S16 unpackEgtpCfgReq(EgtpCfgReq func, Pst *pst, Buffer *mBuf)
145 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
147 SUnpkU32(&(egtpCfg.maxTunnelId), mBuf);
148 SUnpkU32(&(egtpCfg.minTunnelId), mBuf);
150 SUnpkU16(&(egtpCfg.destPort), mBuf);
151 cmUnpkBool(&(egtpCfg.destIp.ipV4Pres), mBuf);
152 if(egtpCfg.destIp.ipV4Pres)
154 SUnpkU32(&(egtpCfg.destIp.ipV4Addr), mBuf);
157 SUnpkU16(&(egtpCfg.localPort), mBuf);
158 cmUnpkBool(&(egtpCfg.localIp.ipV4Pres), mBuf);
159 if(egtpCfg.localIp.ipV4Pres)
161 SUnpkU32(&(egtpCfg.localIp.ipV4Addr), mBuf);
166 RETVALUE((*func)(pst, egtpCfg));
170 /*******************************************************************
172 * @brief Packs EGTP configuration results
176 * Function : packEgtpCfgCfm
179 * Packs EGTP configuration result
181 * @params[in] Post structure
183 * @return ROK - success
186 ******************************************************************/
188 S16 packEgtpCfgCfm(Pst *pst, CmStatus cfm)
192 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
194 printf("\nEGTP : Failed to allocate memory");
198 packEgtpCfmStatus(cfm, mBuf);
203 /*******************************************************************
205 * @brief Unpacks EGTP configuration results
209 * Function : unpackEgtpCfgCfm
212 * Unpacks EGTP configuration result
214 * @params[in] Config Cfm Hanlder
216 * @return ROK - success
219 ******************************************************************/
221 S16 unpackEgtpCfgCfm(EgtpCfgCfm func, Buffer *mBuf)
225 cmMemset((U8 *)&cfm, 0, sizeof(CmStatus));
226 unpackEgtpCfmStatus(&cfm, mBuf);
228 RETVALUE((*func)(cfm));
231 /*******************************************************************
233 * @brief Packs EGTP server open request
237 * Function : packEgtpSrvOpenReq
240 * Packs EGTP server open request
242 * @params[in] Post structure
243 * @return ROK - success
246 *******************************************************************/
247 S16 packEgtpSrvOpenReq(Pst *pst)
251 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
253 printf("\nDU_APP : Failed to allocate memory");
261 /*******************************************************************
263 * @brief Unpacks EGTP server open req
267 * Function : unpackEgtpSrvOpenReq
270 * Unpacks EGTP server open req
272 * @params[in] Hanlder function pointer
274 * @return ROK - success
277 ******************************************************************/
278 S16 unpackEgtpSrvOpenReq(EgtpSrvOpenReq func, Pst *pst, Buffer *mBuf)
280 RETVALUE((*func)(pst));
284 /*******************************************************************
286 * @brief Packs EGTP server open confirm
290 * Function : packEgtpSrvOpenCfm
293 * Packs EGTP server open confirm
295 * @params[in] Post structure
296 * @return ROK - success
299 *******************************************************************/
300 S16 packEgtpSrvOpenCfm(Pst *pst, CmStatus cfm)
304 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
306 printf("\nEGTP : Failed to allocate memory");
310 packEgtpCfmStatus(cfm, mBuf);
316 /*******************************************************************
318 * @brief Unpacks EGTP server open confirm
322 * Function : unpackEgtpSrvOpenCfm
325 * Unpacks EGTP server open confirm
327 * @params[in] Hanlder function pointer
329 * @return ROK - success
332 *******************************************************************/
333 S16 unpackEgtpSrvOpenCfm(EgtpSrvOpenCfm func, Buffer *mBuf)
337 cmMemset((U8 *)&cfm, 0, sizeof(CmStatus));
338 unpackEgtpCfmStatus(&cfm, mBuf);
340 RETVALUE((*func)(cfm));
343 /*******************************************************************
345 * @brief Packs EGTP tunnel management request
349 * Function : packEgtpTnlMgmtReq
352 * Packs EGTP tunnel management request
354 * @params[in] Post structure
356 * Local tunnel endpoint id
357 * Remote tunnel endpoint id
358 * @return ROK - success
361 *******************************************************************/
362 S16 packEgtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
366 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
368 printf("\nDU_APP : Failed to allocate memory");
372 SPkU8(tnlEvt.action, mBuf);
373 SPkU32(tnlEvt.lclTeid, mBuf);
374 SPkU32(tnlEvt.remTeid, mBuf);
381 /*******************************************************************
383 * @brief Unpacks EGTP tunnel management request
387 * Function : unpackEgtpTnlMgmtReq
390 * Unpacks EGTP tunnel management request
392 * @params[in] Hanlder function pointer
395 * @return ROK - success
398 * *******************************************************************/
399 S16 unpackEgtpTnlMgmtReq(EgtpTnlMgmtReq func, Pst *pst, Buffer *mBuf)
403 cmMemset((U8 *)&tnlEvt, 0, sizeof(EgtpTnlEvt));
405 SUnpkU32(&(tnlEvt.remTeid), mBuf);
406 SUnpkU32(&(tnlEvt.lclTeid), mBuf);
407 SUnpkU8(&(tnlEvt.action), mBuf);
409 RETVALUE((* func)(pst, tnlEvt));
413 /*******************************************************************
415 * @brief Packs EGTP tunnel management confirm
419 * Function : packEgtpTnlMgmtCfm
422 * Packs EGTP tunnel management cfm
424 * @params[in] Post structure
425 * Tunnel Event structure
427 * @return ROK - success
430 ********************************************************************/
432 S16 packEgtpTnlMgmtCfm(Pst *pst, EgtpTnlEvt tnlEvt)
436 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
438 printf("\nEGTP : Failed to allocate memory");
442 SPkU8(tnlEvt.action, mBuf);
443 SPkU32(tnlEvt.lclTeid, mBuf);
444 SPkU32(tnlEvt.remTeid, mBuf);
446 packEgtpCfmStatus(tnlEvt.cfmStatus, mBuf);
453 /*******************************************************************
455 * @brief Unpacks EGTP tunnel management confirm
459 * Function : unpackEgtpTnlMgmtCfm
462 * Unpacks EGTP tunnel management confirm
464 * @params[in] Hanlder function pointer
467 * @return ROK - success
470 * *******************************************************************/
471 S16 unpackEgtpTnlMgmtCfm(EgtpTnlMgmtCfm func, Buffer *mBuf)
475 cmMemset((U8 *)&tnlEvt, 0, sizeof(EgtpTnlEvt));
477 unpackEgtpCfmStatus(&(tnlEvt.cfmStatus), mBuf);
478 SUnpkU32(&(tnlEvt.remTeid), mBuf);
479 SUnpkU32(&(tnlEvt.lclTeid), mBuf);
480 SUnpkU8(&(tnlEvt.action), mBuf);
482 RETVALUE((* func)(tnlEvt));
486 /*******************************************************************
488 * @brief Packs Slot indication and sends to EGTP
492 * Function : packEgtpSlotInd
495 * Packs slot indication and sends tp EGTP
497 * @params[in] Post structure
498 * @return ROK - success
501 *******************************************************************/
502 S16 packEgtpSlotInd(Pst *pst)
506 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
508 printf("\nDU_APP : Failed to allocate memory");
517 /*******************************************************************
519 * @brief Unpacks slot indication
523 * Function : unpackEgtpSlotInd
526 * Unpacks slot indication
529 * @return ROK - success
532 ******************************************************************/
533 S16 unpackEgtpSlotInd(EgtpSlotInd func, Pst *pst, Buffer *mBuf)