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"
23 /*******************************************************************
25 * @brief Packs EGTP confirm status
29 * Function : packEgtpCfmStatus
32 * Packs EGTP confirm status
34 * @params[in] Confirm status
36 * @return ROK - success
39 ******************************************************************/
40 S16 packEgtpCfmStatus(CmStatus cfm, Buffer *mBuf)
42 SPkU16(cfm.status, mBuf);
43 SPkU16(cfm.reason, mBuf);
48 /*******************************************************************
50 * @brief Unpacks EGTP confirm status
54 * Function : unpackEgtpCfmStatus
57 * Packs EGTP confirm status
59 * @params[in] Confirm status
61 * @return ROK - success
64 ******************************************************************/
66 S16 unpackEgtpCfmStatus(CmStatus *cfm, Buffer *mBuf)
68 SUnpkU16(&(cfm->reason), mBuf);
69 SUnpkU16(&(cfm->status), mBuf);
74 /*******************************************************************
76 * @brief Packs EGTP configuration
80 * Function : packEgtpCfgReq
83 * Packs EGTP configuration
85 * @params[in] Post structure
87 * @return ROK - success
90 ******************************************************************/
91 S16 packEgtpCfgReq(Pst *pst, EgtpConfig egtpCfg)
95 if(SGetMsg(DFLT_REGION, pst->pool, &mBuf) != ROK)
97 printf("\nDU_APP : Failed to allocate memory");
100 if(egtpCfg.localIp.ipV4Pres)
102 SPkU32(egtpCfg.localIp.ipV4Addr, mBuf);
104 cmPkBool(egtpCfg.localIp.ipV4Pres, mBuf);
105 SPkU16(egtpCfg.localPort, mBuf);
107 if(egtpCfg.destIp.ipV4Pres)
109 SPkU32(egtpCfg.destIp.ipV4Addr, mBuf);
111 cmPkBool(egtpCfg.destIp.ipV4Pres, mBuf);
112 SPkU16(egtpCfg.destPort, mBuf);
114 SPkU32(egtpCfg.minTunnelId, mBuf);
115 SPkU32(egtpCfg.maxTunnelId, mBuf);
122 /*******************************************************************
124 * @brief Unpacks EGTP configuration
128 * Function : unpackEgtpCfgReq
131 * Unpacks EGTP configuration
133 * @params[in] Configuration Request handler
136 * @return ROK - success
139 * ****************************************************************/
140 S16 unpackEgtpCfgReq(EgtpCfgReq func, Pst *pst, Buffer *mBuf)
144 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
146 SUnpkU32(&(egtpCfg.maxTunnelId), mBuf);
147 SUnpkU32(&(egtpCfg.minTunnelId), mBuf);
149 SUnpkU16(&(egtpCfg.destPort), mBuf);
150 cmUnpkBool(&(egtpCfg.destIp.ipV4Pres), mBuf);
151 if(egtpCfg.destIp.ipV4Pres)
153 SUnpkU32(&(egtpCfg.destIp.ipV4Addr), mBuf);
156 SUnpkU16(&(egtpCfg.localPort), mBuf);
157 cmUnpkBool(&(egtpCfg.localIp.ipV4Pres), mBuf);
158 if(egtpCfg.localIp.ipV4Pres)
160 SUnpkU32(&(egtpCfg.localIp.ipV4Addr), mBuf);
165 RETVALUE((*func)(pst, egtpCfg));
169 /*******************************************************************
171 * @brief Packs EGTP configuration results
175 * Function : packEgtpCfgCfm
178 * Packs EGTP configuration result
180 * @params[in] Post structure
182 * @return ROK - success
185 ******************************************************************/
187 S16 packEgtpCfgCfm(Pst *pst, CmStatus cfm)
191 if(SGetMsg(DFLT_REGION, pst->pool, &mBuf) != ROK)
193 printf("\nEGTP : Failed to allocate memory");
197 packEgtpCfmStatus(cfm, mBuf);
202 /*******************************************************************
204 * @brief Unpacks EGTP configuration results
208 * Function : unpackEgtpCfgCfm
211 * Unpacks EGTP configuration result
213 * @params[in] Config Cfm Hanlder
215 * @return ROK - success
218 ******************************************************************/
220 S16 unpackEgtpCfgCfm(EgtpCfgCfm func, Buffer *mBuf)
224 cmMemset((U8 *)&cfm, 0, sizeof(CmStatus));
225 unpackEgtpCfmStatus(&cfm, mBuf);
227 RETVALUE((*func)(cfm));
230 /*******************************************************************
232 * @brief Packs EGTP server open request
236 * Function : packEgtpSrvOpenReq
239 * Packs EGTP server open request
241 * @params[in] Post structure
242 * @return ROK - success
245 *******************************************************************/
246 S16 packEgtpSrvOpenReq(Pst *pst)
250 if(SGetMsg(DFLT_REGION, pst->pool, &mBuf) != ROK)
252 printf("\nDU_APP : Failed to allocate memory");
260 /*******************************************************************
262 * @brief Unpacks EGTP server open req
266 * Function : unpackEgtpSrvOpenReq
269 * Unpacks EGTP server open req
271 * @params[in] Hanlder function pointer
273 * @return ROK - success
276 ******************************************************************/
277 S16 unpackEgtpSrvOpenReq(EgtpSrvOpenReq func, Pst *pst, Buffer *mBuf)
279 RETVALUE((*func)(pst));
283 /*******************************************************************
285 * @brief Packs EGTP server open confirm
289 * Function : packEgtpSrvOpenCfm
292 * Packs EGTP server open confirm
294 * @params[in] Post structure
295 * @return ROK - success
298 *******************************************************************/
299 S16 packEgtpSrvOpenCfm(Pst *pst, CmStatus cfm)
303 if(SGetMsg(DFLT_REGION, pst->pool, &mBuf) != ROK)
305 printf("\nEGTP : Failed to allocate memory");
309 packEgtpCfmStatus(cfm, mBuf);
315 /*******************************************************************
317 * @brief Unpacks EGTP server open confirm
321 * Function : unpackEgtpSrvOpenCfm
324 * Unpacks EGTP server open confirm
326 * @params[in] Hanlder function pointer
328 * @return ROK - success
331 *******************************************************************/
332 S16 unpackEgtpSrvOpenCfm(EgtpSrvOpenCfm func, Buffer *mBuf)
336 cmMemset((U8 *)&cfm, 0, sizeof(CmStatus));
337 unpackEgtpCfmStatus(&cfm, mBuf);
339 RETVALUE((*func)(cfm));
342 /*******************************************************************
344 * @brief Packs EGTP tunnel management request
348 * Function : packEgtpTnlMgmtReq
351 * Packs EGTP tunnel management request
353 * @params[in] Post structure
355 * Local tunnel endpoint id
356 * Remote tunnel endpoint id
357 * @return ROK - success
360 *******************************************************************/
361 S16 packEgtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
365 if(SGetMsg(DFLT_REGION, pst->pool, &mBuf) != ROK)
367 printf("\nDU_APP : Failed to allocate memory");
371 SPkU8(tnlEvt.action, mBuf);
372 SPkU32(tnlEvt.lclTeid, mBuf);
373 SPkU32(tnlEvt.remTeid, mBuf);
380 /*******************************************************************
382 * @brief Unpacks EGTP tunnel management request
386 * Function : unpackEgtpTnlMgmtReq
389 * Unpacks EGTP tunnel management request
391 * @params[in] Hanlder function pointer
394 * @return ROK - success
397 * *******************************************************************/
398 S16 unpackEgtpTnlMgmtReq(EgtpTnlMgmtReq func, Pst *pst, Buffer *mBuf)
402 cmMemset((U8 *)&tnlEvt, 0, sizeof(EgtpTnlEvt));
404 SUnpkU32(&(tnlEvt.remTeid), mBuf);
405 SUnpkU32(&(tnlEvt.lclTeid), mBuf);
406 SUnpkU8(&(tnlEvt.action), mBuf);
408 RETVALUE((* func)(pst, tnlEvt));
412 /*******************************************************************
414 * @brief Packs EGTP tunnel management confirm
418 * Function : packEgtpTnlMgmtCfm
421 * Packs EGTP tunnel management cfm
423 * @params[in] Post structure
424 * Tunnel Event structure
426 * @return ROK - success
429 ********************************************************************/
431 S16 packEgtpTnlMgmtCfm(Pst *pst, EgtpTnlEvt tnlEvt)
435 if(SGetMsg(DFLT_REGION, pst->pool, &mBuf) != ROK)
437 printf("\nEGTP : Failed to allocate memory");
441 SPkU8(tnlEvt.action, mBuf);
442 SPkU32(tnlEvt.lclTeid, mBuf);
443 SPkU32(tnlEvt.remTeid, mBuf);
445 packEgtpCfmStatus(tnlEvt.cfmStatus, mBuf);
452 /*******************************************************************
454 * @brief Unpacks EGTP tunnel management confirm
458 * Function : unpackEgtpTnlMgmtCfm
461 * Unpacks EGTP tunnel management confirm
463 * @params[in] Hanlder function pointer
466 * @return ROK - success
469 * *******************************************************************/
470 S16 unpackEgtpTnlMgmtCfm(EgtpTnlMgmtCfm func, Buffer *mBuf)
474 cmMemset((U8 *)&tnlEvt, 0, sizeof(EgtpTnlEvt));
476 unpackEgtpCfmStatus(&(tnlEvt.cfmStatus), mBuf);
477 SUnpkU32(&(tnlEvt.remTeid), mBuf);
478 SUnpkU32(&(tnlEvt.lclTeid), mBuf);
479 SUnpkU8(&(tnlEvt.action), mBuf);
481 RETVALUE((* func)(tnlEvt));
485 /*******************************************************************
487 * @brief Packs Slot indication and sends to EGTP
491 * Function : packEgtpSlotInd
494 * Packs slot indication and sends tp EGTP
496 * @params[in] Post structure
497 * @return ROK - success
500 *******************************************************************/
501 S16 packEgtpSlotInd(Pst *pst)
505 if(SGetMsg(DFLT_REGION, pst->pool, &mBuf) != ROK)
507 printf("\nDU_APP : Failed to allocate memory");
516 /*******************************************************************
518 * @brief Unpacks slot indication
522 * Function : unpackEgtpSlotInd
525 * Unpacks slot indication
528 * @return ROK - success
531 ******************************************************************/
532 S16 unpackEgtpSlotInd(EgtpSlotInd func, Pst *pst, Buffer *mBuf)