Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_lib.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /********************************************************************20**
20   
21         Name:    LTE-PDCP Layer - Upper Interface
22     
23         Type:    C file
24   
25         Desc:    C source code for the hook functions of LTE-PDCP
26
27                  This file contains the following functions:
28          
29                  --pjLibCmpInit
30                  --pjLibIntInit
31                  --pjLibCpInit
32                  --pjLibUpInit
33                  --pjLibCmpReset
34                  --pjLibCmpSdu
35                  --pjLibIntProt
36                  --pjLibIntVerify
37                  --pjLibDecipherSdu
38                  --pjLibSndFeedback
39                  --pjLibCmpClose
40                  --pjLibIntClose
41                  --pjLibCpClose
42                  --pjLibUpClose
43
44                  Portable functions for software hooks:
45
46                  --pjLibCmpInitReq
47                  --pjLibIntInitReq
48                  --pjLibCpInitReq
49                  --pjLibUpInitReq
50                  --pjLibCmpResetReq
51                  --pjLibCmpReq
52                  --pjLibIntProtReq
53                  --pjLibCipherReq
54                  --pjLibDecipherReq
55                  --pjLibIntVerReq
56                  --pjLibDeCmpReq
57                  --pjLibCmpCloseReq
58                  --pjLibIntCloseReq
59                  --pjLibCiperCloseReq
60                  --pjLibUpCloseReq 
61
62  
63         File:    pj_lib.c
64   
65 *********************************************************************21*/
66
67 /** @file pj_lib.c
68 @brief PDPC Hook Interface
69 */
70
71 \f
72 /* header (.h) include files */
73 #include "envopt.h"        /* environment options */
74 #include "envdep.h"        /* environment dependent */
75 #include "envind.h"        /* environment independent */
76
77 #include "gen.h"           /* general */
78 #include "ssi.h"           /* system services */
79 #include "cm5.h"           /* common timer defines */
80 #include "cm_tkns.h"       /* common tokens defines */
81 #include "cm_mblk.h"       /* common memory allocation library defines */
82 #include "cm_llist.h"      /* common link list  defines  */
83 #include "cm_hash.h"       /* common hash list  defines */
84 #include "cm_lte.h"        /* common LTE defines */
85 #include "cpj.h"                /* RRC layer */
86 #include "pju.h"                /* PDCP service user */
87 #include "lpj.h"                /* LPJ defines */
88 #include "pj_err.h"
89 #include "pj_env.h"        /* RLC environment options */
90 #include "pj_lib.h"     /* LIB options */
91 #include "pj.h"            /* RLC defines */
92 #include "pj_dl.h"
93
94 /* extern (.x) include files */
95 #include "gen.x"           /* general */
96 #include "ssi.x"           /* system services */
97
98 #include "cm5.x"           /* common timer library */
99 #include "cm_tkns.x"       /* common tokens */
100 #include "cm_mblk.x"       /* common memory allocation */
101 #include "cm_llist.x"      /* common link list */
102 #include "cm_hash.x"       /* common hash list */
103 #include "cm_lte.x"        /* common LTE includes */
104 #include "cm_lib.x"        /* common memory allocation library */
105 #include "cpj.x"           /* CPJ */
106 #include "pju.x"           /* PJU */
107 #include "lpj.x"           /* LPJ */
108
109 #include "pj.x"
110 #include "pj_udx.h"
111 #include "pj_udx.x"
112 #include "pj_dl.x"
113 #include "pj_lib.x"     /* LIB */
114
115 #ifdef __cplusplus
116 EXTERN "C" {
117 #endif /* __cplusplus */
118
119 \f
120 /****************************************************************************
121  *                         Portable hooks for asynchronous 
122  ***************************************************************************/
123
124 #ifdef PJ_CMP_ASYNC
125 #ifdef ANSI
126 PUBLIC S16 cmPkLibObdCmpInitCfm
127 (
128 Pst * pst,
129 PjCmpCxt cmpCxt,
130 PTR ctxId
131 )
132 #else
133 PUBLIC S16 cmPkLibObdCmpInitCfm(pst, cmpCxt, ctxId)
134 Pst * pst;
135 PjCmpCxt cmpCxt;
136 PTR ctxId;
137 #endif
138 {
139    Buffer *mBuf = NULLP;
140    TRC3(cmPkLibObdCmpInitCfm)
141
142    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
143 #if (ERRCLASS & ERRCLS_ADD_RES)
144       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
145          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
146          (ErrVal)ELIB001, (ErrVal)0, "Packing failed");
147 #endif
148       RETVALUE(RFAILED);
149    }
150    if (cmPkPtr(ctxId, mBuf) != ROK) {
151 #if (ERRCLASS & ERRCLS_ADD_RES)
152       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
153          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
154          (ErrVal)ELIB002, (ErrVal)0, "Packing failed");
155 #endif
156       PJ_FREE_BUF(mBuf);
157       RETVALUE(RFAILED);
158    }
159    if (cmPkPjCmpCxt(&cmpCxt, mBuf) != ROK) {
160 #if (ERRCLASS & ERRCLS_ADD_RES)
161       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
162          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
163          (ErrVal)ELIB003, (ErrVal)0, "Packing failed");
164 #endif
165       PJ_FREE_BUF(mBuf);
166       RETVALUE(RFAILED);
167    }
168    pst->event = (Event) OBD_EVT_CMP_INIT_CFM;
169    RETVALUE(SPstTsk(pst,mBuf));
170 }
171
172 #ifdef ANSI
173 PUBLIC S16 cmUnpkLibObdCmpInitCfm
174 (
175 ObdCmpInitCfm func,
176 Pst *pst,
177 Buffer *mBuf
178 )
179 #else
180 PUBLIC S16 cmUnpkLibObdCmpInitCfm(func, pst, mBuf)
181 ObdCmpInitCfm func;
182 Pst *pst;
183 Buffer *mBuf;
184 #endif
185 {
186    PjCmpCxt cmpCxt;
187    PTR ctxId;
188    
189    TRC3(cmUnpkLibObdCmpInitCfm)
190
191    if (cmUnpkPjCmpCxt(&cmpCxt, mBuf) != ROK) {
192       PJ_FREE_BUF(mBuf);
193 #if (ERRCLASS & ERRCLS_ADD_RES)
194       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
195          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
196          (ErrVal)ELIB004, (ErrVal)0, "Packing failed");
197 #endif
198       RETVALUE(RFAILED);
199    }
200    if (cmUnpkPtr(&ctxId, mBuf) != ROK) {
201       PJ_FREE_BUF(mBuf);
202 #if (ERRCLASS & ERRCLS_ADD_RES)
203       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
204          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
205          (ErrVal)ELIB005, (ErrVal)0, "Packing failed");
206 #endif
207       RETVALUE(RFAILED);
208    }
209    PJ_FREE_BUF(mBuf);
210    RETVALUE((*func)(pst, cmpCxt, ctxId));
211 }
212
213 #ifdef ANSI
214 PUBLIC S16 cmPkLibObdCmpCfm
215 (
216 Pst * pst,
217 PTR cmpCxtId,
218 PjLibTrans libTrans,
219 Buffer * opSdu
220 )
221 #else
222 PUBLIC S16 cmPkLibObdCmpCfm(pst, cmpCxtId, libTrans, opSdu)
223 Pst * pst;
224 PTR cmpCxtId;
225 PjLibTrans libTrans;
226 Buffer * opSdu;
227 #endif
228 {
229    Buffer *mBuf = NULLP;
230    MsgLen msgLen = 0;
231    TRC3(cmPkLibObdCmpCfm)
232
233    if (pst->selector == OBD_SEL_LC) {
234       if ( opSdu != NULLP )
235       {
236       if (SFndLenMsg(opSdu, &msgLen) != ROK) {
237 #if (ERRCLASS & ERRCLS_ADD_RES)
238          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
239             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
240             (ErrVal)ELIB022, (ErrVal)0, "Packing failed");
241 #endif
242          PJ_FREE_BUF(opSdu);
243          RETVALUE(RFAILED);
244       }
245       if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) {
246 #if (ERRCLASS & ERRCLS_ADD_RES)
247          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
248             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
249             (ErrVal)ELIB023, (ErrVal)0, "Packing failed");
250 #endif
251          RETVALUE(RFAILED);
252       }
253       }
254       else
255       {
256          msgLen = 0;
257          if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
258 #if (ERRCLASS & ERRCLS_ADD_RES)
259             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
260                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
261                   (ErrVal)ELIB036, (ErrVal)0, "Packing failed");
262 #endif
263             RETVALUE(RFAILED);
264          }
265       }
266       CMCHKPK(cmPkMsgLen, msgLen, mBuf);
267
268    }
269    else
270    {
271    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
272 #if (ERRCLASS & ERRCLS_ADD_RES)
273       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
274          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
275          (ErrVal)ELIB021, (ErrVal)0, "Packing failed");
276 #endif
277       RETVALUE(RFAILED);
278    }
279    }
280
281    if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
282 #if (ERRCLASS & ERRCLS_ADD_RES)
283       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
284          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
285          (ErrVal)ELIB025, (ErrVal)0, "Packing failed");
286 #endif
287       PJ_FREE_BUF(mBuf);
288       RETVALUE(RFAILED);
289    }
290    if (cmPkPtr(cmpCxtId, mBuf) != ROK) {
291 #if (ERRCLASS & ERRCLS_ADD_RES)
292       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
293          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
294          (ErrVal)ELIB026, (ErrVal)0, "Packing failed");
295 #endif
296       PJ_FREE_BUF(mBuf);
297       RETVALUE(RFAILED);
298    }
299    pst->event = (Event) OBD_EVT_CMP_CFM;
300    RETVALUE(SPstTsk(pst,mBuf));
301 }
302
303 #ifdef ANSI
304 PUBLIC S16 cmUnpkLibObdCmpCfm
305 (
306 ObdCmpCfm func,
307 Pst *pst,
308 Buffer *mBuf
309 )
310 #else
311 PUBLIC S16 cmUnpkLibObdCmpCfm(func, pst, mBuf)
312 ObdCmpCfm func;
313 Pst *pst;
314 Buffer *mBuf;
315 #endif
316 {
317    PTR cmpCxtId;
318    PjLibTrans libTrans;
319    Buffer *opSdu;
320    
321    TRC3(cmUnpkLibObdCmpCfm)
322    
323    opSdu = NULLP;
324
325    if (cmUnpkPtr(&cmpCxtId, mBuf) != ROK) {
326       PJ_FREE_BUF(mBuf);
327 #if (ERRCLASS & ERRCLS_ADD_RES)
328       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
329          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
330          (ErrVal)ELIB027, (ErrVal)0, "Packing failed");
331 #endif
332       RETVALUE(RFAILED);
333    }
334    if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
335       PJ_FREE_BUF(mBuf);
336 #if (ERRCLASS & ERRCLS_ADD_RES)
337       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
338          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
339          (ErrVal)ELIB028, (ErrVal)0, "Packing failed");
340 #endif
341       RETVALUE(RFAILED);
342    }
343    if (pst->selector == OBD_SEL_LC) {
344       MsgLen msgLen, totalMsgLen;
345       CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
346       if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
347          RETVALUE(RFAILED);
348       if ( msgLen != 0 )
349       {
350          if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK)
351             RETVALUE(RFAILED);
352       }
353    }
354
355    PJ_FREE_BUF(mBuf);
356    RETVALUE((*func)(pst, cmpCxtId, libTrans, opSdu));
357 }
358
359 #ifdef ANSI
360 PUBLIC S16 cmPkLibObdDecmpCfm
361 (
362 Pst * pst,
363 PTR cmpCxtId,
364 PjLibTrans libTrans,
365 Buffer * opSdu,
366 Buffer * fbPkt
367 )
368 #else
369 PUBLIC S16 cmPkLibObdDecmpCfm(pst, cmpCxtId, libTrans, opSdu, fbPkt)
370 Pst * pst;
371 PTR cmpCxtId;
372 PjLibTrans libTrans;
373 Buffer * opSdu;
374 Buffer * fbPkt;
375 #endif
376 {
377    Buffer *mBuf = NULLP;
378    Buffer *tBuf = NULLP;
379    MsgLen msgLen = 0;
380    TRC3(cmPkLibObdDecmpCfm)
381
382    if (fbPkt != NULLP) {
383       if (SFndLenMsg(fbPkt, &msgLen) != ROK) {
384 #if (ERRCLASS & ERRCLS_ADD_RES)
385          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
386             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
387             (ErrVal)ELIB060, (ErrVal)0, "Packing failed");
388 #endif
389          RETVALUE(RFAILED);
390       }
391       if (SCpyMsgMsg(fbPkt, pst->region, pst->pool, &mBuf) != ROK) {
392 #if (ERRCLASS & ERRCLS_ADD_RES)
393          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
394             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
395             (ErrVal)ELIB061, (ErrVal)0, "Packing failed");
396 #endif
397          RETVALUE(RFAILED);
398       }
399    }else{
400       if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
401 #if (ERRCLASS & ERRCLS_ADD_RES)
402          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
403                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
404                (ErrVal)ELIB059, (ErrVal)0, "Packing failed");
405 #endif
406          RETVALUE(RFAILED);
407       }
408
409       msgLen = 0;
410    }
411    CMCHKPK(cmPkMsgLen, msgLen, mBuf);
412
413    if (opSdu != NULLP) {
414       if (SFndLenMsg(opSdu, &msgLen) != ROK) {
415 #if (ERRCLASS & ERRCLS_ADD_RES)
416          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
417             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
418             (ErrVal)ELIB060, (ErrVal)0, "Packing failed");
419 #endif
420          PJ_FREE_BUF(mBuf);
421          RETVALUE(RFAILED);
422       }
423       if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &tBuf) != ROK) {
424 #if (ERRCLASS & ERRCLS_ADD_RES)
425          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
426             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
427             (ErrVal)ELIB061, (ErrVal)0, "Packing failed");
428 #endif
429          PJ_FREE_BUF(mBuf);
430          RETVALUE(RFAILED);
431       }
432       if (SCatMsg(mBuf, tBuf, M1M2) != ROK) {
433 #if (ERRCLASS & ERRCLS_ADD_RES)
434          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
435             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
436             (ErrVal)ELIB061, (ErrVal)0, "Packing failed");
437 #endif
438          PJ_FREE_BUF(mBuf);
439          PJ_FREE_BUF(tBuf);
440          RETVALUE(RFAILED);
441       }
442
443       if (tBuf != NULLP)
444          PJ_FREE_BUF(tBuf);
445    } else {
446       msgLen = 0;
447    }
448    CMCHKPK(cmPkMsgLen, msgLen, mBuf);
449
450    if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
451 #if (ERRCLASS & ERRCLS_ADD_RES)
452       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
453          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
454          (ErrVal)ELIB063, (ErrVal)0, "Packing failed");
455 #endif
456       PJ_FREE_BUF(mBuf);
457       RETVALUE(RFAILED);
458    }
459    if (cmPkPtr(cmpCxtId, mBuf) != ROK) {
460 #if (ERRCLASS & ERRCLS_ADD_RES)
461       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
462          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
463          (ErrVal)ELIB064, (ErrVal)0, "Packing failed");
464 #endif
465       PJ_FREE_BUF(mBuf);
466       RETVALUE(RFAILED);
467    }
468    pst->event = (Event) OBD_EVT_DECMP_CFM;
469    RETVALUE(SPstTsk(pst,mBuf));
470 }
471
472 #ifdef ANSI
473 PUBLIC S16 cmUnpkLibObdDecmpCfm
474 (
475 ObdDecmpCfm func,
476 Pst *pst,
477 Buffer *mBuf
478 )
479 #else
480 PUBLIC S16 cmUnpkLibObdDecmpCfm(func, pst, mBuf)
481 ObdDecmpCfm func;
482 Pst *pst;
483 Buffer *mBuf;
484 #endif
485 {
486    PTR cmpCxtId;
487    PjLibTrans libTrans;
488    Buffer *opSdu = NULLP;
489    Buffer *fbPkt = NULLP;
490    
491    TRC3(cmUnpkLibObdDecmpCfm)
492
493    if (cmUnpkPtr(&cmpCxtId, mBuf) != ROK) {
494       PJ_FREE_BUF(mBuf);
495 #if (ERRCLASS & ERRCLS_ADD_RES)
496       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
497          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
498          (ErrVal)ELIB065, (ErrVal)0, "Packing failed");
499 #endif
500       RETVALUE(RFAILED);
501    }
502    if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
503       PJ_FREE_BUF(mBuf);
504 #if (ERRCLASS & ERRCLS_ADD_RES)
505       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
506          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
507          (ErrVal)ELIB066, (ErrVal)0, "Packing failed");
508 #endif
509       RETVALUE(RFAILED);
510    }
511    if (pst->selector == OBD_SEL_LC) {
512       MsgLen msgLen, totalMsgLen;
513       CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
514       if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
515          RETVALUE(RFAILED);
516       if(msgLen != 0)
517          if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK)
518             RETVALUE(RFAILED);
519    }
520
521    if (pst->selector == OBD_SEL_LC) {
522       MsgLen msgLen, totalMsgLen;
523       CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
524       if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
525          RETVALUE(RFAILED);
526       if(msgLen != 0)
527          if (SSegMsg(mBuf, totalMsgLen-msgLen, &fbPkt) != ROK)
528             RETVALUE(RFAILED);
529    }
530
531    PJ_FREE_BUF(mBuf);
532    RETVALUE((*func)(pst, cmpCxtId, libTrans, opSdu, fbPkt));
533 }
534
535 \f
536 /***********************************************************
537 *
538 *     Func : cmPkPjRohc
539 *
540 *
541 *     Desc : PjHdrCmp
542   Robust header compression Information
543 *
544 *
545 *     Ret  : S16
546 *
547 *     Notes:
548 *
549 *     File  : 
550 *
551 **********************************************************/
552 #ifdef ANSI
553 PUBLIC S16 cmPkPjRohc
554 (
555 PjRohc *param,
556 Buffer *mBuf
557 )
558 #else
559 PUBLIC S16 cmPkPjRohc(param, mBuf)
560 PjRohc *param;
561 Buffer *mBuf;
562 #endif
563 {
564
565    TRC3(cmPkPjRohc)
566
567    CMCHKPK(SPkU16, param->profId, mBuf);
568    CMCHKPK(SPkU16, param->maxCid, mBuf);
569    CMCHKPK(SPkU8, param->hdrCmpUsed, mBuf);
570    RETVALUE(ROK);
571 }
572
573 \f
574 /***********************************************************
575 *
576 *     Func : cmUnpkPjRohc
577 *
578 *
579 *     Desc : PjHdrCmp
580   Robust header compression Information
581 *
582 *
583 *     Ret  : S16
584 *
585 *     Notes:
586 *
587 *     File  : 
588 *
589 **********************************************************/
590 #ifdef ANSI
591 PUBLIC S16 cmUnpkPjRohc
592 (
593 PjRohc *param,
594 Buffer *mBuf
595 )
596 #else
597 PUBLIC S16 cmUnpkPjRohc(param, mBuf)
598 PjRohc *param;
599 Buffer *mBuf;
600 #endif
601 {
602
603    TRC3(cmUnpkPjRohc)
604
605    CMCHKUNPK(SUnpkU8, &param->hdrCmpUsed, mBuf);
606    CMCHKUNPK(SUnpkU16, &param->maxCid, mBuf);
607    CMCHKUNPK(SUnpkU16, &param->profId, mBuf);
608    RETVALUE(ROK);
609 }
610
611
612 \f
613 /***********************************************************
614 *
615 *     Func : cmPkPjCmpCxt
616 *
617 *
618 *     Desc : PjCmpCxt
619 Context for ROHC
620 *
621 *
622 *     Ret  : S16
623 *
624 *     Notes:
625 *
626 *     File  : 
627 *
628 **********************************************************/
629 #ifdef ANSI
630 PUBLIC S16 cmPkPjCmpCxt
631 (
632 PjCmpCxt *param,
633 Buffer *mBuf
634 )
635 #else
636 PUBLIC S16 cmPkPjCmpCxt(param, mBuf)
637 PjCmpCxt *param;
638 Buffer *mBuf;
639 #endif
640 {
641
642    TRC3(cmPkPjCmpCxt)
643
644    CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
645    CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
646    CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
647    CMCHKPK(SPkU8, param->rbType, mBuf);
648    CMCHKPK(SPkU16, param->cfgTxId, mBuf);
649    RETVALUE(ROK);
650 }
651
652
653 \f
654 /***********************************************************
655 *
656 *     Func : cmUnpkPjCmpCxt
657 *
658 *
659 *     Desc : PjCmpCxt
660 Context for ROHC
661 *
662 *
663 *     Ret  : S16
664 *
665 *     Notes:
666 *
667 *     File  : 
668 *
669 **********************************************************/
670 #ifdef ANSI
671 PUBLIC S16 cmUnpkPjCmpCxt
672 (
673 PjCmpCxt *param,
674 Buffer *mBuf
675 )
676 #else
677 PUBLIC S16 cmUnpkPjCmpCxt(param, mBuf)
678 PjCmpCxt *param;
679 Buffer *mBuf;
680 #endif
681 {
682
683    TRC3(cmUnpkPjCmpCxt)
684
685    CMCHKUNPK(SUnpkU16, &param->cfgTxId, mBuf);
686    CMCHKUNPK(SUnpkU8, &param->rbType, mBuf);
687    CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
688    CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
689    CMCHKUNPK(cmUnpkLteRbId, &param->rbId, mBuf);
690    RETVALUE(ROK);
691 }
692
693 #endif /* PJ_CMP_ASYNC */
694
695 #ifdef PJ_SEC_ASYNC
696 #ifdef ANSI
697 PUBLIC S16 cmPkLibObdIntInitCfm
698 (
699 Pst * pst,
700 PjSecCxt secCtx,
701 PTR ctxId
702 )
703 #else
704 PUBLIC S16 cmPkLibObdIntInitCfm(pst, secCtx, ctxId)
705 Pst * pst;
706 PjSecCxt secCtx;
707 PTR ctxId;
708 #endif
709 {
710    Buffer *mBuf = NULLP;
711    TRC3(cmPkLibObdIntInitCfm)
712
713    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
714 #if (ERRCLASS & ERRCLS_ADD_RES)
715       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
716          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
717          (ErrVal)ELIB006, (ErrVal)0, "Packing failed");
718 #endif
719       RETVALUE(RFAILED);
720    }
721    if (cmPkPtr(ctxId, mBuf) != ROK) {
722 #if (ERRCLASS & ERRCLS_ADD_RES)
723       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
724          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
725          (ErrVal)ELIB007, (ErrVal)0, "Packing failed");
726 #endif
727       PJ_FREE_BUF(mBuf);
728       RETVALUE(RFAILED);
729    }
730    if (cmPkPjSecCxt(&secCtx, mBuf) != ROK) {
731 #if (ERRCLASS & ERRCLS_ADD_RES)
732       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
733          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
734          (ErrVal)ELIB008, (ErrVal)0, "Packing failed");
735 #endif
736       PJ_FREE_BUF(mBuf);
737       RETVALUE(RFAILED);
738    }
739    pst->event = (Event) OBD_EVT_INT_INIT_CFM;
740    RETVALUE(SPstTsk(pst,mBuf));
741 }
742
743 #ifdef ANSI
744 PUBLIC S16 cmUnpkLibObdIntInitCfm
745 (
746 ObdIntInitCfm func,
747 Pst *pst,
748 Buffer *mBuf
749 )
750 #else
751 PUBLIC S16 cmUnpkLibObdIntInitCfm(func, pst, mBuf)
752 ObdIntInitCfm func;
753 Pst *pst;
754 Buffer *mBuf;
755 #endif
756 {
757    PjSecCxt secCtx;
758    PTR ctxId;
759    
760    TRC3(cmUnpkLibObdIntInitCfm)
761
762    if (cmUnpkPjSecCxt(&secCtx, mBuf) != ROK) {
763       PJ_FREE_BUF(mBuf);
764 #if (ERRCLASS & ERRCLS_ADD_RES)
765       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
766          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
767          (ErrVal)ELIB009, (ErrVal)0, "Packing failed");
768 #endif
769       RETVALUE(RFAILED);
770    }
771    if (cmUnpkPtr(&ctxId, mBuf) != ROK) {
772       PJ_FREE_BUF(mBuf);
773 #if (ERRCLASS & ERRCLS_ADD_RES)
774       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
775          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
776          (ErrVal)ELIB010, (ErrVal)0, "Packing failed");
777 #endif
778       RETVALUE(RFAILED);
779    }
780    PJ_FREE_BUF(mBuf);
781    RETVALUE((*func)(pst, secCtx, ctxId));
782 }
783
784 #ifdef ANSI
785 PUBLIC S16 cmPkLibObdCpInitCfm
786 (
787 Pst * pst,
788 PjSecCxt secCxt,
789 PTR ctxId
790 )
791 #else
792 PUBLIC S16 cmPkLibObdCpInitCfm(pst, secCxt, ctxId)
793 Pst * pst;
794 PjSecCxt secCxt;
795 PTR ctxId;
796 #endif
797 {
798    Buffer *mBuf = NULLP;
799    TRC3(cmPkLibObdCpInitCfm)
800
801    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
802 #if (ERRCLASS & ERRCLS_ADD_RES)
803       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
804          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
805          (ErrVal)ELIB011, (ErrVal)0, "Packing failed");
806 #endif
807       RETVALUE(RFAILED);
808    }
809    if (cmPkPtr(ctxId, mBuf) != ROK) {
810 #if (ERRCLASS & ERRCLS_ADD_RES)
811       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
812          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
813          (ErrVal)ELIB012, (ErrVal)0, "Packing failed");
814 #endif
815       PJ_FREE_BUF(mBuf);
816       RETVALUE(RFAILED);
817    }
818    if (cmPkPjSecCxt(&secCxt, mBuf) != ROK) {
819 #if (ERRCLASS & ERRCLS_ADD_RES)
820       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
821          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
822          (ErrVal)ELIB013, (ErrVal)0, "Packing failed");
823 #endif
824       PJ_FREE_BUF(mBuf);
825       RETVALUE(RFAILED);
826    }
827    pst->event = (Event) OBD_EVT_CP_INIT_CFM;
828    RETVALUE(SPstTsk(pst,mBuf));
829 }
830
831 #ifdef ANSI
832 PUBLIC S16 cmUnpkLibObdCpInitCfm
833 (
834 ObdCpInitCfm func,
835 Pst *pst,
836 Buffer *mBuf
837 )
838 #else
839 PUBLIC S16 cmUnpkLibObdCpInitCfm(func, pst, mBuf)
840 ObdCpInitCfm func;
841 Pst *pst;
842 Buffer *mBuf;
843 #endif
844 {
845    PjSecCxt secCxt;
846    PTR ctxId;
847    
848    TRC3(cmUnpkLibObdCpInitCfm)
849
850    if (cmUnpkPjSecCxt(&secCxt, mBuf) != ROK) {
851       PJ_FREE_BUF(mBuf);
852 #if (ERRCLASS & ERRCLS_ADD_RES)
853       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
854          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
855          (ErrVal)ELIB014, (ErrVal)0, "Packing failed");
856 #endif
857       RETVALUE(RFAILED);
858    }
859    if (cmUnpkPtr(&ctxId, mBuf) != ROK) {
860       PJ_FREE_BUF(mBuf);
861 #if (ERRCLASS & ERRCLS_ADD_RES)
862       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
863          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
864          (ErrVal)ELIB015, (ErrVal)0, "Packing failed");
865 #endif
866       RETVALUE(RFAILED);
867    }
868    PJ_FREE_BUF(mBuf);
869    RETVALUE((*func)(pst, secCxt, ctxId));
870 }
871
872 #ifdef ANSI
873 PUBLIC S16 cmPkLibObdUpInitCfm
874 (
875 Pst * pst,
876 PjSecCxt secCxt,
877 PTR ctxId
878 )
879 #else
880 PUBLIC S16 cmPkLibObdUpInitCfm(pst, secCxt, ctxId)
881 Pst * pst;
882 PjSecCxt secCxt;
883 PTR ctxId;
884 #endif
885 {
886    Buffer *mBuf = NULLP;
887    TRC3(cmPkLibObdUpInitCfm)
888
889    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
890 #if (ERRCLASS & ERRCLS_ADD_RES)
891       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
892          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
893          (ErrVal)ELIB016, (ErrVal)0, "Packing failed");
894 #endif
895       RETVALUE(RFAILED);
896    }
897    if (cmPkPtr(ctxId, mBuf) != ROK) {
898 #if (ERRCLASS & ERRCLS_ADD_RES)
899       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
900          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
901          (ErrVal)ELIB017, (ErrVal)0, "Packing failed");
902 #endif
903       PJ_FREE_BUF(mBuf);
904       RETVALUE(RFAILED);
905    }
906    if (cmPkPjSecCxt(&secCxt, mBuf) != ROK) {
907 #if (ERRCLASS & ERRCLS_ADD_RES)
908       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
909          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
910          (ErrVal)ELIB018, (ErrVal)0, "Packing failed");
911 #endif
912       PJ_FREE_BUF(mBuf);
913       RETVALUE(RFAILED);
914    }
915    pst->event = (Event) OBD_EVT_UP_INIT_CFM;
916    RETVALUE(SPstTsk(pst,mBuf));
917 }
918
919 #ifdef ANSI
920 PUBLIC S16 cmUnpkLibObdUpInitCfm
921 (
922 ObdUpInitCfm func,
923 Pst *pst,
924 Buffer *mBuf
925 )
926 #else
927 PUBLIC S16 cmUnpkLibObdUpInitCfm(func, pst, mBuf)
928 ObdUpInitCfm func;
929 Pst *pst;
930 Buffer *mBuf;
931 #endif
932 {
933    PjSecCxt secCxt;
934    PTR ctxId;
935    
936    TRC3(cmUnpkLibObdUpInitCfm)
937
938    if (cmUnpkPjSecCxt(&secCxt, mBuf) != ROK) {
939       PJ_FREE_BUF(mBuf);
940 #if (ERRCLASS & ERRCLS_ADD_RES)
941       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
942          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
943          (ErrVal)ELIB019, (ErrVal)0, "Packing failed");
944 #endif
945       RETVALUE(RFAILED);
946    }
947    if (cmUnpkPtr(&ctxId, mBuf) != ROK) {
948       PJ_FREE_BUF(mBuf);
949 #if (ERRCLASS & ERRCLS_ADD_RES)
950       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
951          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
952          (ErrVal)ELIB020, (ErrVal)0, "Packing failed");
953 #endif
954       RETVALUE(RFAILED);
955    }
956    PJ_FREE_BUF(mBuf);
957    RETVALUE((*func)(pst, secCxt, ctxId));
958 }
959
960 #ifdef ANSI
961 PUBLIC S16 cmPkLibObdIntProtCfm
962 (
963 Pst * pst,
964 PTR cxtId,
965 PjLibTrans libTrans,
966 U32 macI
967 )
968 #else
969 PUBLIC S16 cmPkLibObdIntProtCfm(pst, cxtId, libTrans, macI)
970 Pst * pst;
971 PTR cxtId;
972 PjLibTrans libTrans;
973 U32 macI;
974 #endif
975 {
976    Buffer *mBuf = NULLP;
977    TRC3(cmPkLibObdIntProtCfm)
978
979    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
980 #if (ERRCLASS & ERRCLS_ADD_RES)
981       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
982          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
983          (ErrVal)ELIB029, (ErrVal)0, "Packing failed");
984 #endif
985       RETVALUE(RFAILED);
986    }
987    if (SPkU32(macI, mBuf) != ROK) {
988 #if (ERRCLASS & ERRCLS_ADD_RES)
989       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
990          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
991          (ErrVal)ELIB030, (ErrVal)0, "Packing failed");
992 #endif
993       PJ_FREE_BUF(mBuf);
994       RETVALUE(RFAILED);
995    }
996    if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
997 #if (ERRCLASS & ERRCLS_ADD_RES)
998       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
999          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1000          (ErrVal)ELIB031, (ErrVal)0, "Packing failed");
1001 #endif
1002       PJ_FREE_BUF(mBuf);
1003       RETVALUE(RFAILED);
1004    }
1005    if (cmPkPtr(cxtId, mBuf) != ROK) {
1006 #if (ERRCLASS & ERRCLS_ADD_RES)
1007       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1008          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1009          (ErrVal)ELIB032, (ErrVal)0, "Packing failed");
1010 #endif
1011       PJ_FREE_BUF(mBuf);
1012       RETVALUE(RFAILED);
1013    }
1014    pst->event = (Event) OBD_EVT_INT_PROT_CFM;
1015    RETVALUE(SPstTsk(pst,mBuf));
1016 }
1017
1018 #ifdef ANSI
1019 PUBLIC S16 cmUnpkLibObdIntProtCfm
1020 (
1021 ObdIntProtCfm func,
1022 Pst *pst,
1023 Buffer *mBuf
1024 )
1025 #else
1026 PUBLIC S16 cmUnpkLibObdIntProtCfm(func, pst, mBuf)
1027 ObdIntProtCfm func;
1028 Pst *pst;
1029 Buffer *mBuf;
1030 #endif
1031 {
1032    PTR cxtId;
1033    PjLibTrans libTrans;
1034    U32 macI;
1035    
1036    TRC3(cmUnpkLibObdIntProtCfm)
1037
1038    if (cmUnpkPtr(&cxtId, mBuf) != ROK) {
1039       PJ_FREE_BUF(mBuf);
1040 #if (ERRCLASS & ERRCLS_ADD_RES)
1041       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1042          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1043          (ErrVal)ELIB033, (ErrVal)0, "Packing failed");
1044 #endif
1045       RETVALUE(RFAILED);
1046    }
1047    if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
1048       PJ_FREE_BUF(mBuf);
1049 #if (ERRCLASS & ERRCLS_ADD_RES)
1050       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1051          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1052          (ErrVal)ELIB034, (ErrVal)0, "Packing failed");
1053 #endif
1054       RETVALUE(RFAILED);
1055    }
1056    if (SUnpkU32(&macI, mBuf) != ROK) {
1057       PJ_FREE_BUF(mBuf);
1058 #if (ERRCLASS & ERRCLS_ADD_RES)
1059       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1060          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1061          (ErrVal)ELIB035, (ErrVal)0, "Packing failed");
1062 #endif
1063       RETVALUE(RFAILED);
1064    }
1065    PJ_FREE_BUF(mBuf);
1066    RETVALUE((*func)(pst, cxtId, libTrans, macI));
1067 }
1068
1069 #ifdef ANSI
1070 PUBLIC S16 cmPkLibObdCipherCfm
1071 (
1072 Pst * pst,
1073 PTR cxtId,
1074 PjLibTrans libTrans,
1075 Buffer * opSdu
1076 )
1077 #else
1078 PUBLIC S16 cmPkLibObdCipherCfm(pst, cxtId, libTrans, opSdu)
1079 Pst * pst;
1080 PTR cxtId;
1081 PjLibTrans libTrans;
1082 Buffer * opSdu;
1083 #endif
1084 {
1085    Buffer *mBuf = NULLP;
1086    MsgLen msgLen = 0;
1087    TRC3(cmPkLibObdCipherCfm)
1088
1089    if (pst->selector == OBD_SEL_LC) {
1090       if ( opSdu != NULLP )
1091       {
1092          if (SFndLenMsg(opSdu, &msgLen) != ROK) {
1093 #if (ERRCLASS & ERRCLS_ADD_RES)
1094             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1095                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1096                (ErrVal)ELIB037, (ErrVal)0, "Packing failed");
1097 #endif
1098             PJ_FREE_BUF(opSdu);
1099             RETVALUE(RFAILED);
1100          }
1101          if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) {
1102 #if (ERRCLASS & ERRCLS_ADD_RES)
1103             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1104                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1105                (ErrVal)ELIB038, (ErrVal)0, "Packing failed");
1106 #endif
1107             PJ_FREE_BUF(opSdu);
1108             RETVALUE(RFAILED);
1109          }
1110          /* SPutMsg(opSdu); */
1111       }
1112       else
1113       {
1114          msgLen = 0;
1115          if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1116 #if (ERRCLASS & ERRCLS_ADD_RES)
1117             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1118                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1119                   (ErrVal)ELIB036, (ErrVal)0, "Packing failed");
1120 #endif
1121             RETVALUE(RFAILED);
1122          }
1123       }
1124       CMCHKPK(cmPkMsgLen, msgLen, mBuf);
1125
1126    }
1127    else
1128    {
1129       if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1130 #if (ERRCLASS & ERRCLS_ADD_RES)
1131          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1132                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1133                (ErrVal)ELIB036, (ErrVal)0, "Packing failed");
1134 #endif
1135          PJ_FREE_BUF(opSdu);
1136          RETVALUE(RFAILED);
1137       }
1138    }
1139
1140
1141    if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
1142 #if (ERRCLASS & ERRCLS_ADD_RES)
1143       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1144          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1145          (ErrVal)ELIB040, (ErrVal)0, "Packing failed");
1146 #endif
1147       PJ_FREE_BUF(opSdu);
1148       PJ_FREE_BUF(mBuf);
1149       RETVALUE(RFAILED);
1150    }
1151    if (cmPkPtr(cxtId, mBuf) != ROK) {
1152 #if (ERRCLASS & ERRCLS_ADD_RES)
1153       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1154          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1155          (ErrVal)ELIB041, (ErrVal)0, "Packing failed");
1156 #endif
1157       PJ_FREE_BUF(opSdu);
1158       PJ_FREE_BUF(mBuf);
1159       RETVALUE(RFAILED);
1160    }
1161    pst->event = (Event) OBD_EVT_CIPHER_CFM;
1162    RETVALUE(SPstTsk(pst,mBuf));
1163 }
1164
1165 #ifdef ANSI
1166 PUBLIC S16 cmUnpkLibObdCipherCfm
1167 (
1168 ObdCipherCfm func,
1169 Pst *pst,
1170 Buffer *mBuf
1171 )
1172 #else
1173 PUBLIC S16 cmUnpkLibObdCipherCfm(func, pst, mBuf)
1174 ObdCipherCfm func;
1175 Pst *pst;
1176 Buffer *mBuf;
1177 #endif
1178 {
1179    PTR cxtId;
1180    PjLibTrans libTrans;
1181    Buffer *opSdu;
1182    
1183    TRC3(cmUnpkLibObdCipherCfm)
1184
1185    opSdu = NULLP;
1186
1187    if (cmUnpkPtr(&cxtId, mBuf) != ROK) {
1188       PJ_FREE_BUF(mBuf);
1189 #if (ERRCLASS & ERRCLS_ADD_RES)
1190       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1191          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1192          (ErrVal)ELIB042, (ErrVal)0, "Packing failed");
1193 #endif
1194       RETVALUE(RFAILED);
1195    }
1196    if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
1197       PJ_FREE_BUF(mBuf);
1198 #if (ERRCLASS & ERRCLS_ADD_RES)
1199       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1200          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1201          (ErrVal)ELIB043, (ErrVal)0, "Packing failed");
1202 #endif
1203       RETVALUE(RFAILED);
1204    }
1205
1206    if (pst->selector == OBD_SEL_LC) {
1207       MsgLen msgLen, totalMsgLen;
1208       CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
1209       if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
1210          RETVALUE(RFAILED);
1211       if ( msgLen != 0 )
1212       {
1213          if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK)
1214          {
1215             RETVALUE(RFAILED);
1216          }
1217       }
1218    }
1219
1220    PJ_FREE_BUF(mBuf);
1221    RETVALUE((*func)(pst, cxtId, libTrans, opSdu));
1222 }
1223
1224 #ifdef ANSI
1225 PUBLIC S16 cmPkLibObdDecipherCfm
1226 (
1227 Pst * pst,
1228 PTR cxtId,
1229 PjLibTrans libTrans,
1230 Buffer * opSdu
1231 )
1232 #else
1233 PUBLIC S16 cmPkLibObdDecipherCfm(pst, cxtId, libTrans, opSdu)
1234 Pst * pst;
1235 PTR cxtId;
1236 PjLibTrans libTrans;
1237 Buffer * opSdu;
1238 #endif
1239 {
1240    Buffer *mBuf = NULLP;
1241    MsgLen msgLen = 0;
1242    TRC3(cmPkLibObdDecipherCfm)
1243
1244    if (pst->selector == OBD_SEL_LC) {
1245       if ( opSdu != NULLP)
1246       {
1247          if (SFndLenMsg(opSdu, &msgLen) != ROK) {
1248 #if (ERRCLASS & ERRCLS_ADD_RES)
1249             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1250                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1251                (ErrVal)ELIB045, (ErrVal)0, "Packing failed");
1252 #endif
1253             RETVALUE(RFAILED);
1254          }
1255          if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) {
1256 #if (ERRCLASS & ERRCLS_ADD_RES)
1257             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1258                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1259                (ErrVal)ELIB046, (ErrVal)0, "Packing failed");
1260 #endif
1261             RETVALUE(RFAILED);
1262          }
1263       }
1264       else
1265       {
1266          msgLen = 0;
1267          if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1268 #if (ERRCLASS & ERRCLS_ADD_RES)
1269             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1270                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1271                   (ErrVal)ELIB036, (ErrVal)0, "Packing failed");
1272 #endif
1273             RETVALUE(RFAILED);
1274          }
1275       }
1276       CMCHKPK(cmPkMsgLen, msgLen, mBuf);
1277
1278    }
1279    else
1280    {
1281    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1282 #if (ERRCLASS & ERRCLS_ADD_RES)
1283       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1284          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1285          (ErrVal)ELIB044, (ErrVal)0, "Packing failed");
1286 #endif
1287       RETVALUE(RFAILED);
1288    }
1289    }
1290
1291    if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
1292 #if (ERRCLASS & ERRCLS_ADD_RES)
1293       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1294          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1295          (ErrVal)ELIB048, (ErrVal)0, "Packing failed");
1296 #endif
1297       PJ_FREE_BUF(mBuf);
1298       RETVALUE(RFAILED);
1299    }
1300    if (cmPkPtr(cxtId, mBuf) != ROK) {
1301 #if (ERRCLASS & ERRCLS_ADD_RES)
1302       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1303          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1304          (ErrVal)ELIB049, (ErrVal)0, "Packing failed");
1305 #endif
1306       PJ_FREE_BUF(mBuf);
1307       RETVALUE(RFAILED);
1308    }
1309    pst->event = (Event) OBD_EVT_DECIPHER_CFM;
1310    RETVALUE(SPstTsk(pst,mBuf));
1311 }
1312
1313 #ifdef ANSI
1314 PUBLIC S16 cmUnpkLibObdDecipherCfm
1315 (
1316 ObdDecipherCfm func,
1317 Pst *pst,
1318 Buffer *mBuf
1319 )
1320 #else
1321 PUBLIC S16 cmUnpkLibObdDecipherCfm(func, pst, mBuf)
1322 ObdDecipherCfm func;
1323 Pst *pst;
1324 Buffer *mBuf;
1325 #endif
1326 {
1327    PTR cxtId;
1328    PjLibTrans libTrans;
1329    Buffer *opSdu= NULLP;
1330    
1331    TRC3(cmUnpkLibObdDecipherCfm)
1332
1333    if (cmUnpkPtr(&cxtId, mBuf) != ROK) {
1334       PJ_FREE_BUF(mBuf);
1335 #if (ERRCLASS & ERRCLS_ADD_RES)
1336       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1337          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1338          (ErrVal)ELIB050, (ErrVal)0, "Packing failed");
1339 #endif
1340       RETVALUE(RFAILED);
1341    }
1342    if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
1343       PJ_FREE_BUF(mBuf);
1344 #if (ERRCLASS & ERRCLS_ADD_RES)
1345       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1346          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1347          (ErrVal)ELIB051, (ErrVal)0, "Packing failed");
1348 #endif
1349       RETVALUE(RFAILED);
1350    }
1351    if (pst->selector == OBD_SEL_LC) {
1352       MsgLen msgLen, totalMsgLen;
1353       CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
1354       if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
1355          RETVALUE(RFAILED);
1356       if ( msgLen != 0 )
1357       {
1358          if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK)
1359             RETVALUE(RFAILED);
1360       }
1361    }
1362
1363    PJ_FREE_BUF(mBuf);
1364    RETVALUE((*func)(pst, cxtId, libTrans, opSdu));
1365 }
1366
1367 #ifdef ANSI
1368 PUBLIC S16 cmPkLibObdIntVerCfm
1369 (
1370 Pst * pst,
1371 PTR cxtId,
1372 PjLibTrans libTrans,
1373 Status status
1374 )
1375 #else
1376 PUBLIC S16 cmPkLibObdIntVerCfm(pst, cxtId, libTrans, status)
1377 Pst * pst;
1378 PTR cxtId;
1379 PjLibTrans libTrans;
1380 Status status;
1381 #endif
1382 {
1383    Buffer *mBuf = NULLP;
1384    TRC3(cmPkLibObdIntVerCfm)
1385
1386    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1387 #if (ERRCLASS & ERRCLS_ADD_RES)
1388       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1389          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1390          (ErrVal)ELIB052, (ErrVal)0, "Packing failed");
1391 #endif
1392       RETVALUE(RFAILED);
1393    }
1394    if (SPkS16(status, mBuf) != ROK) {
1395 #if (ERRCLASS & ERRCLS_ADD_RES)
1396       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1397          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1398          (ErrVal)ELIB053, (ErrVal)0, "Packing failed");
1399 #endif
1400       PJ_FREE_BUF(mBuf);
1401       RETVALUE(RFAILED);
1402    }
1403    if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
1404 #if (ERRCLASS & ERRCLS_ADD_RES)
1405       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1406          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1407          (ErrVal)ELIB054, (ErrVal)0, "Packing failed");
1408 #endif
1409       PJ_FREE_BUF(mBuf);
1410       RETVALUE(RFAILED);
1411    }
1412    if (cmPkPtr(cxtId, mBuf) != ROK) {
1413 #if (ERRCLASS & ERRCLS_ADD_RES)
1414       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1415          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1416          (ErrVal)ELIB055, (ErrVal)0, "Packing failed");
1417 #endif
1418       PJ_FREE_BUF(mBuf);
1419       RETVALUE(RFAILED);
1420    }
1421    pst->event = (Event) OBD_EVT_INT_VER_CFM;
1422    RETVALUE(SPstTsk(pst,mBuf));
1423 }
1424
1425 #ifdef ANSI
1426 PUBLIC S16 cmUnpkLibObdIntVerCfm
1427 (
1428 ObdIntVerCfm func,
1429 Pst *pst,
1430 Buffer *mBuf
1431 )
1432 #else
1433 PUBLIC S16 cmUnpkLibObdIntVerCfm(func, pst, mBuf)
1434 ObdIntVerCfm func;
1435 Pst *pst;
1436 Buffer *mBuf;
1437 #endif
1438 {
1439    PTR cxtId;
1440    PjLibTrans libTrans;
1441    Status status;
1442    
1443    TRC3(cmUnpkLibObdIntVerCfm)
1444
1445    if (cmUnpkPtr(&cxtId, mBuf) != ROK) {
1446       PJ_FREE_BUF(mBuf);
1447 #if (ERRCLASS & ERRCLS_ADD_RES)
1448       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1449          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1450          (ErrVal)ELIB056, (ErrVal)0, "Packing failed");
1451 #endif
1452       RETVALUE(RFAILED);
1453    }
1454    if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
1455       PJ_FREE_BUF(mBuf);
1456 #if (ERRCLASS & ERRCLS_ADD_RES)
1457       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1458          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1459          (ErrVal)ELIB057, (ErrVal)0, "Packing failed");
1460 #endif
1461       RETVALUE(RFAILED);
1462    }
1463    if (SUnpkS16(&status, mBuf) != ROK) {
1464       PJ_FREE_BUF(mBuf);
1465 #if (ERRCLASS & ERRCLS_ADD_RES)
1466       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1467          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1468          (ErrVal)ELIB058, (ErrVal)0, "Packing failed");
1469 #endif
1470       RETVALUE(RFAILED);
1471    }
1472    PJ_FREE_BUF(mBuf);
1473    RETVALUE((*func)(pst, cxtId, libTrans, status));
1474 }
1475
1476 \f
1477 /***********************************************************
1478 *
1479 *     Func : cmPkPjSecCxt
1480 *
1481 *
1482 *     Desc : PjSecCxt
1483 Context for Security Algorithm
1484 *
1485 *
1486 *     Ret  : S16
1487 *
1488 *     Notes:
1489 *
1490 *     File  : 
1491 *
1492 **********************************************************/
1493 #ifdef ANSI
1494 PUBLIC S16 cmPkPjSecCxt
1495 (
1496 PjSecCxt *param,
1497 Buffer *mBuf
1498 )
1499 #else
1500 PUBLIC S16 cmPkPjSecCxt(param, mBuf)
1501 PjSecCxt *param;
1502 Buffer *mBuf;
1503 #endif
1504 {
1505
1506    TRC3(cmPkPjSecCxt)
1507
1508    CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
1509    CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
1510    CMCHKPK(SPkU16, param->cfgTxId, mBuf);
1511    RETVALUE(ROK);
1512 }
1513
1514
1515 \f
1516 /***********************************************************
1517 *
1518 *     Func : cmUnpkPjSecCxt
1519 *
1520 *
1521 *     Desc : PjSecCxt
1522 Context for Security Algorithm
1523 *
1524 *
1525 *     Ret  : S16
1526 *
1527 *     Notes:
1528 *
1529 *     File  : 
1530 *
1531 **********************************************************/
1532 #ifdef ANSI
1533 PUBLIC S16 cmUnpkPjSecCxt
1534 (
1535 PjSecCxt *param,
1536 Buffer *mBuf
1537 )
1538 #else
1539 PUBLIC S16 cmUnpkPjSecCxt(param, mBuf)
1540 PjSecCxt *param;
1541 Buffer *mBuf;
1542 #endif
1543 {
1544
1545    TRC3(cmUnpkPjSecCxt)
1546
1547    CMCHKUNPK(SUnpkU16, &param->cfgTxId, mBuf);
1548    CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
1549    CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
1550    RETVALUE(ROK);
1551 }
1552
1553 \f
1554 /***********************************************************
1555 *
1556 *     Func : cmPkPjIntInfo
1557 *
1558 *
1559 *     Desc : PjIntInfo
1560   PDCP Integrity Algo Information
1561 *
1562 *
1563 *     Ret  : S16
1564 *
1565 *     Notes:
1566 *
1567 *     File  : 
1568 *
1569 **********************************************************/
1570 #ifdef ANSI
1571 PUBLIC S16 cmPkPjIntInfo
1572 (
1573 PjIntInfo *param,
1574 Buffer *mBuf
1575 )
1576 #else
1577 PUBLIC S16 cmPkPjIntInfo(param, mBuf)
1578 PjIntInfo *param;
1579 Buffer *mBuf;
1580 #endif
1581 {
1582
1583    S32 i;
1584    TRC3(cmPkPjIntInfo)
1585
1586    for (i=PJ_INTG_KEY_LEN-1; i >= 0; i--) {
1587       CMCHKPK(SPkU8, param->intKey[i], mBuf);
1588    }
1589    CMCHKPK(SPkU8, param->algoType, mBuf);
1590    RETVALUE(ROK);
1591 }
1592
1593
1594 \f
1595 /***********************************************************
1596 *
1597 *     Func : cmUnpkPjIntInfo
1598 *
1599 *
1600 *     Desc : PjIntInfo
1601   PDCP Integrity Algo Information
1602 *
1603 *
1604 *     Ret  : S16
1605 *
1606 *     Notes:
1607 *
1608 *     File  : 
1609 *
1610 **********************************************************/
1611 #ifdef ANSI
1612 PUBLIC S16 cmUnpkPjIntInfo
1613 (
1614 PjIntInfo *param,
1615 Buffer *mBuf
1616 )
1617 #else
1618 PUBLIC S16 cmUnpkPjIntInfo(param, mBuf)
1619 PjIntInfo *param;
1620 Buffer *mBuf;
1621 #endif
1622 {
1623
1624    S32 i;
1625    TRC3(cmUnpkPjIntInfo)
1626
1627    CMCHKUNPK(SUnpkU8, &param->algoType, mBuf);
1628    for (i=0; i<PJ_INTG_KEY_LEN; i++) {
1629       CMCHKUNPK(SUnpkU8, &param->intKey[i], mBuf);
1630    }
1631    RETVALUE(ROK);
1632 }
1633
1634
1635 \f
1636 /***********************************************************
1637 *
1638 *     Func : cmPkPjSecInp
1639 *
1640 *
1641 *     Desc : PjSecInp
1642 Input parameters for security algorithm
1643 *
1644 *
1645 *     Ret  : S16
1646 *
1647 *     Notes:
1648 *
1649 *     File  : 
1650 *
1651 **********************************************************/
1652 #ifdef ANSI
1653 PUBLIC S16 cmPkPjSecInp
1654 (
1655 PjSecInp *param,
1656 Buffer *mBuf
1657 )
1658 #else
1659 PUBLIC S16 cmPkPjSecInp(param, mBuf)
1660 PjSecInp *param;
1661 Buffer *mBuf;
1662 #endif
1663 {
1664
1665    TRC3(cmPkPjSecInp)
1666
1667    CMCHKPK(SPkU8, param->dir, mBuf);
1668    CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
1669    CMCHKPK(SPkU32, param->count, mBuf);
1670    RETVALUE(ROK);
1671 }
1672
1673
1674 \f
1675 /***********************************************************
1676 *
1677 *     Func : cmUnpkPjSecInp
1678 *
1679 *
1680 *     Desc : PjSecInp
1681 Input parameters for security algorithm
1682 *
1683 *
1684 *     Ret  : S16
1685 *
1686 *     Notes:
1687 *
1688 *     File  : 
1689 *
1690 **********************************************************/
1691 #ifdef ANSI
1692 PUBLIC S16 cmUnpkPjSecInp
1693 (
1694 PjSecInp *param,
1695 Buffer *mBuf
1696 )
1697 #else
1698 PUBLIC S16 cmUnpkPjSecInp(param, mBuf)
1699 PjSecInp *param;
1700 Buffer *mBuf;
1701 #endif
1702 {
1703
1704    TRC3(cmUnpkPjSecInp)
1705
1706    CMCHKUNPK(SUnpkU32, &param->count, mBuf);
1707    CMCHKUNPK(cmUnpkLteRbId, &param->rbId, mBuf);
1708    CMCHKUNPK(SUnpkU8, &param->dir, mBuf);
1709    RETVALUE(ROK);
1710 }
1711
1712 #endif /* PJ_SEC_ASYNC */
1713
1714 \f
1715 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
1716 /***********************************************************
1717 *
1718 *     Func : cmPkPjLibTrans
1719 *
1720 *
1721 *     Desc : PjLibTrans
1722   Transaction Id for Security Algorithm
1723 *
1724 *
1725 *     Ret  : S16
1726 *
1727 *     Notes:
1728 *
1729 *     File  : 
1730 *
1731 **********************************************************/
1732 #ifdef ANSI
1733 PUBLIC S16 cmPkPjLibTrans
1734 (
1735 PjLibTrans *param,
1736 Buffer *mBuf
1737 )
1738 #else
1739 PUBLIC S16 cmPkPjLibTrans(param, mBuf)
1740 PjLibTrans *param;
1741 Buffer *mBuf;
1742 #endif
1743 {
1744
1745    TRC3(cmPkPjLibTrans)
1746
1747    CMCHKPK(cmPkPtr, (PTR)param->ueCb, mBuf);
1748    CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
1749    CMCHKPK(SPkU8, param->rbType, mBuf);
1750    CMCHKPK(SPkU32, param->count, mBuf);
1751    RETVALUE(ROK);
1752 }
1753
1754
1755 \f
1756 /***********************************************************
1757 *
1758 *     Func : cmUnpkPjLibTrans
1759 *
1760 *
1761 *     Desc : PjLibTrans
1762   Transaction Id for Security Algorithm
1763 *
1764 *
1765 *     Ret  : S16
1766 *
1767 *     Notes:
1768 *
1769 *     File  : 
1770 *
1771 **********************************************************/
1772 #ifdef ANSI
1773 PUBLIC S16 cmUnpkPjLibTrans
1774 (
1775 PjLibTrans *param,
1776 Buffer *mBuf
1777 )
1778 #else
1779 PUBLIC S16 cmUnpkPjLibTrans(param, mBuf)
1780 PjLibTrans *param;
1781 Buffer *mBuf;
1782 #endif
1783 {
1784
1785    TRC3(cmUnpkPjLibTrans)
1786
1787    CMCHKUNPK(SUnpkU32, &param->count, mBuf);
1788    CMCHKUNPK(SUnpkU8, &param->rbType, mBuf);
1789    CMCHKUNPK(cmUnpkLteRbId, &param->rbId, mBuf);
1790    CMCHKUNPK(cmUnpkPtr, (PTR*)&param->ueCb, mBuf);
1791    RETVALUE(ROK);
1792 }
1793
1794 #endif /*  PJ_SEC_ASYNC || PJ_CMP_ASYNC */
1795
1796 #ifdef __cplusplus
1797 }
1798 #endif /* __cplusplus */
1799 /********************************************************************30**
1800          End of file
1801 **********************************************************************/