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 uint8_t packEgtpCfmStatus(CmStatus cfm, Buffer *mBuf)
42 oduUnpackUInt16(cfm.status, mBuf);
43 oduUnpackUInt16(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 uint8_t unpackEgtpCfmStatus(CmStatus *cfm, Buffer *mBuf)
68 oduPackUInt16(&(cfm->reason), mBuf);
69 oduPackUInt16(&(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 uint8_t packEgtpCfgReq(Pst *pst, EgtpConfig egtpCfg)
95 if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK)
97 DU_LOG("\nERROR --> DU_APP : Failed to allocate memory");
100 if(egtpCfg.localIp.ipV4Pres)
102 oduUnpackUInt32(egtpCfg.localIp.ipV4Addr, mBuf);
104 oduPackBool(egtpCfg.localIp.ipV4Pres, mBuf);
105 oduUnpackUInt16(egtpCfg.localPort, mBuf);
107 if(egtpCfg.destIp.ipV4Pres)
109 oduUnpackUInt32(egtpCfg.destIp.ipV4Addr, mBuf);
111 oduPackBool(egtpCfg.destIp.ipV4Pres, mBuf);
112 oduUnpackUInt16(egtpCfg.destPort, mBuf);
114 oduUnpackUInt32(egtpCfg.minTunnelId, mBuf);
115 oduUnpackUInt32(egtpCfg.maxTunnelId, mBuf);
117 ODU_POST_TASK(pst, 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 uint8_t unpackEgtpCfgReq(EgtpCfgReq func, Pst *pst, Buffer *mBuf)
144 memset(&egtpCfg, 0, sizeof(EgtpConfig));
146 oduPackUInt32(&(egtpCfg.maxTunnelId), mBuf);
147 oduPackUInt32(&(egtpCfg.minTunnelId), mBuf);
149 oduPackUInt16(&(egtpCfg.destPort), mBuf);
150 oduUnpackBool(&(egtpCfg.destIp.ipV4Pres), mBuf);
151 if(egtpCfg.destIp.ipV4Pres)
153 oduPackUInt32(&(egtpCfg.destIp.ipV4Addr), mBuf);
156 oduPackUInt16(&(egtpCfg.localPort), mBuf);
157 oduUnpackBool(&(egtpCfg.localIp.ipV4Pres), mBuf);
158 if(egtpCfg.localIp.ipV4Pres)
160 oduPackUInt32(&(egtpCfg.localIp.ipV4Addr), mBuf);
163 ODU_PUT_MSG_BUF(mBuf);
165 return ((*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 uint8_t packEgtpCfgCfm(Pst *pst, CmStatus cfm)
191 if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK)
193 DU_LOG("\nERROR --> EGTP : Failed to allocate memory");
197 packEgtpCfmStatus(cfm, mBuf);
198 ODU_POST_TASK(pst, 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 uint8_t unpackEgtpCfgCfm(EgtpCfgCfm func, Buffer *mBuf)
224 memset(&cfm, 0, sizeof(CmStatus));
225 unpackEgtpCfmStatus(&cfm, mBuf);
227 return ((*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 uint8_t packEgtpSrvOpenReq(Pst *pst)
250 if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK)
252 DU_LOG("\nERROR --> DU_APP : Failed to allocate memory");
256 ODU_POST_TASK(pst, mBuf);
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 uint8_t unpackEgtpSrvOpenReq(EgtpSrvOpenReq func, Pst *pst, Buffer *mBuf)
279 return ((*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 uint8_t packEgtpSrvOpenCfm(Pst *pst, CmStatus cfm)
303 if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK)
305 DU_LOG("\nERROR --> EGTP : Failed to allocate memory");
309 packEgtpCfmStatus(cfm, mBuf);
310 ODU_POST_TASK(pst, 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 uint8_t unpackEgtpSrvOpenCfm(EgtpSrvOpenCfm func, Buffer *mBuf)
336 memset(&cfm, 0, sizeof(CmStatus));
337 unpackEgtpCfmStatus(&cfm, mBuf);
339 return ((*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 uint8_t packEgtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
365 if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK)
367 DU_LOG("\nERROR --> DU_APP : Failed to allocate memory");
371 oduUnpackUInt8(tnlEvt.action, mBuf);
372 oduUnpackUInt32(tnlEvt.lclTeid, mBuf);
373 oduUnpackUInt32(tnlEvt.remTeid, mBuf);
375 ODU_POST_TASK(pst, 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 uint8_t unpackEgtpTnlMgmtReq(EgtpTnlMgmtReq func, Pst *pst, Buffer *mBuf)
402 memset(&tnlEvt, 0, sizeof(EgtpTnlEvt));
404 oduPackUInt32(&(tnlEvt.remTeid), mBuf);
405 oduPackUInt32(&(tnlEvt.lclTeid), mBuf);
406 oduPackUInt8(&(tnlEvt.action), mBuf);
408 return ((* 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 uint8_t packEgtpTnlMgmtCfm(Pst *pst, EgtpTnlEvt tnlEvt)
435 if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK)
437 DU_LOG("\nERROR --> EGTP : Failed to allocate memory");
441 oduUnpackUInt8(tnlEvt.action, mBuf);
442 oduUnpackUInt32(tnlEvt.lclTeid, mBuf);
443 oduUnpackUInt32(tnlEvt.remTeid, mBuf);
445 packEgtpCfmStatus(tnlEvt.cfmStatus, mBuf);
447 ODU_POST_TASK(pst, 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 uint8_t unpackEgtpTnlMgmtCfm(EgtpTnlMgmtCfm func, Buffer *mBuf)
474 memset(&tnlEvt, 0, sizeof(EgtpTnlEvt));
476 unpackEgtpCfmStatus(&(tnlEvt.cfmStatus), mBuf);
477 oduPackUInt32(&(tnlEvt.remTeid), mBuf);
478 oduPackUInt32(&(tnlEvt.lclTeid), mBuf);
479 oduPackUInt8(&(tnlEvt.action), mBuf);
481 return ((* func)(tnlEvt));
485 /*******************************************************************
487 * @brief Packs Polling requesting and sends to EGTP
491 * Function : packEgtpStartPollingReq
494 * Packs polling request and sends to EGTP
496 * @params[in] Post structure
497 * @return ROK - success
500 *******************************************************************/
501 uint8_t packEgtpStartPollingReq(Pst *pst)
505 if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK)
507 DU_LOG("\nERROR --> DU_APP : Failed to allocate memory");
511 ODU_POST_TASK(pst, mBuf);
515 /**********************************************************************
517 **********************************************************************/