[ Jira id - ODUHIGH-593 ] Pack and unpack function nomenclature correction
[o-du/l2.git] / src / cm / cm_gen.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 \f
20 /********************************************************************20**
21   
22      Name:     common body 6
23   
24      Type:     C source file
25   
26      Desc:     common functions used to pack and unpack primitives and 
27                structures that are:
28
29                - Common to all interfaces e.g. Addrs, etc.
30                  These functions are always compiled.
31
32                All functions pack/unpack assuming that the most significant 
33                bit is towards the head of the buffer.
34
35      File:     cm_gen.c
36   
37 *********************************************************************21*/
38   
39 \f   
40 /* header include files (.h) */
41   
42 #include "envopt.h"        /* environment options */  
43 #include "envdep.h"        /* environment dependent */
44 #include "envind.h"        /* environment independent */
45
46 #include "gen.h"           /* general layer */
47 #include "ssi.h"           /* system services */
48
49 #ifndef CMFILE_REORG_1
50 #include "cm_gen.h"        /* common pack/unpack functions */
51 #endif
52
53 #include "cm_err.h"        /* common error */
54
55 /* header/extern include files (.x) */
56   
57 #include "gen.x"           /* general layer */
58 #include "ssi.x"           /* system services */
59
60 #ifndef CMFILE_REORG_1
61 #include "cm_gen.x"        /* common pack/unpack functions */
62 #endif
63
64 \f  
65 /* local defines */
66   
67 /* local typedefs */
68
69 /* local externs */
70   
71 /* forward references */
72
73 /* functions in other modules */
74
75 /* public variable declarations */
76 uint16_t gTransId = 0;
77
78 /* private variable declarations */
79
80 \f
81 /* 
82  * common packing functions 
83  */
84
85 \f
86 /*
87 *
88 *       Fun:   cmPkDateTime
89 *
90 *       Desc:  This function packs the Date Time structure
91 *
92 *       Ret:   ROK      - ok
93 *
94 *       Notes: None.
95 *
96 *       File:  cm_gen.c
97 *
98 */
99   
100 S16 cmPkDateTime
101 (
102 DateTime *dateTime,       /* date and time */
103 Buffer *mBuf              /* message buffer */
104 )
105 {
106
107    /*-- cm_gen_c_001.main_36 - added for micro seconds --*/
108 #ifdef SS_DATETIME_USEC
109    CMCHKPK(oduUnpackUInt32, dateTime->usec, mBuf);
110 #endif /*-- SS_DATETIME_USEC --*/
111    CMCHKPK(oduUnpackUInt8, dateTime->tenths, mBuf);
112    CMCHKPK(oduUnpackUInt8, dateTime->sec, mBuf); 
113    CMCHKPK(oduUnpackUInt8, dateTime->min, mBuf); 
114    CMCHKPK(oduUnpackUInt8, dateTime->hour, mBuf);
115    CMCHKPK(oduUnpackUInt8, dateTime->year, mBuf);
116    CMCHKPK(oduUnpackUInt8, dateTime->day, mBuf);
117    CMCHKPK(oduUnpackUInt8, dateTime->month, mBuf);
118
119    return ROK;
120 } /* end of cmPkDateTime */
121
122 \f
123 /*
124 *
125 *       Fun:   cmPkDuration
126 *
127 *       Desc:  This function packs the Duration structure
128 *
129 *       Ret:   ROK      - ok
130 *
131 *       Notes: None.
132 *
133 *       File:  cm_gen.c
134 *
135 */
136   
137 S16 cmPkDuration
138 (
139 Duration *duration,        /* duration */
140 Buffer   *mBuf             /* message buffer */
141 )
142 {
143
144    CMCHKPK(oduUnpackUInt8, duration->tenths, mBuf);
145    CMCHKPK(oduUnpackUInt8, duration->secs,   mBuf);
146    CMCHKPK(oduUnpackUInt8, duration->mins,   mBuf);
147    CMCHKPK(oduUnpackUInt8, duration->hours,  mBuf);
148    CMCHKPK(oduUnpackUInt8, duration->days,   mBuf);
149
150    return ROK;
151 } /* end of cmPkDuration */
152
153 /*
154 *
155 *       Fun:   oduPackPointer
156 *
157 *       Desc:  This function packs the pointer
158 *
159 *       Ret:   ROK      - ok
160 *
161 *       Notes: None.
162 *
163 *       File:  cm_gen.c
164 *
165 */
166  
167 S16 oduPackPointer
168 (
169 PTR      ptr,              /* pointer */
170 Buffer   *mBuf             /* message buffer */
171 )
172 {
173    Data pkArray[PTRSIZE];   /* array for packing */
174    S16 ret;                 /* return code */
175    uint16_t tmp;                 /* temporary value */
176
177 #if (defined(ALPHA) || defined(BIT_64))
178    uint32_t tmp32;
179 #endif
180
181    
182    ret = ROK;
183    switch (PTRSIZE)
184    {
185       case 2:
186 #ifndef FCSPKINT            /* backward compatibility, packing order */
187          pkArray[0] = (Data) GetHiByte(ptr);
188          pkArray[1] = (Data) GetLoByte(ptr);
189 #else                       /* forward compatibility, packing order */
190          pkArray[1] = (Data) GetHiByte(ptr);
191          pkArray[0] = (Data) GetLoByte(ptr);
192 #endif
193          ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
194          break;
195     
196       case 4: 
197 #ifndef FCSPKINT        /* backward compatibility, packing order */
198          tmp = (uint16_t) GetHiWord(ptr);
199          pkArray[0] = (Data) GetHiByte(tmp);
200          pkArray[1] = (Data) GetLoByte(tmp);
201          tmp = (uint16_t) GetLoWord(ptr);
202          pkArray[2] = (Data) GetHiByte(tmp);
203          pkArray[3] = (Data) GetLoByte(tmp);
204 #else                   /* forward compatibility, packing order */
205          tmp = (uint16_t) GetHiWord(ptr);
206          pkArray[3] = (Data) GetHiByte(tmp);
207          pkArray[2] = (Data) GetLoByte(tmp);
208          tmp = (uint16_t) GetLoWord(ptr);
209          pkArray[1] = (Data) GetHiByte(tmp);
210          pkArray[0] = (Data) GetLoByte(tmp);
211 #endif
212          ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
213          break;
214
215       case 8:
216 #if (defined(ALPHA) || defined(BIT_64))
217 #ifndef FCSPKINT        /* backward compatibility, packing order */
218          tmp32 = (uint32_t) GetHi32Bit(ptr);
219          tmp = (uint16_t) GetHiWord(tmp32);
220          pkArray[0] = (Data) GetHiByte(tmp);
221          pkArray[1] = (Data) GetLoByte(tmp);
222          tmp = (uint16_t) GetLoWord(tmp32);
223          pkArray[2] = (Data) GetHiByte(tmp);
224          pkArray[3] = (Data) GetLoByte(tmp);
225          tmp32 = (uint32_t) GetLo32Bit(ptr);
226          tmp = (uint16_t) GetHiWord(tmp32);
227          pkArray[4] = (Data) GetHiByte(tmp);
228          pkArray[5] = (Data) GetLoByte(tmp);
229          tmp = (uint16_t) GetLoWord(tmp32);
230          pkArray[6] = (Data) GetHiByte(tmp);
231          pkArray[7] = (Data) GetLoByte(tmp);
232 #else                   /* forward compatibility, packing order */
233          tmp32 = (uint32_t) GetHi32Bit(ptr);
234          tmp = (uint16_t) GetHiWord(tmp32);
235          pkArray[7] = (Data) GetHiByte(tmp);
236          pkArray[6] = (Data) GetLoByte(tmp);
237          tmp = (uint16_t) GetLoWord(tmp32);
238          pkArray[5] = (Data) GetHiByte(tmp);
239          pkArray[4] = (Data) GetLoByte(tmp);
240          tmp32 = (uint32_t) GetLo32Bit(ptr);
241          tmp = (uint16_t) GetHiWord(tmp32);
242          pkArray[3] = (Data) GetHiByte(tmp);
243          pkArray[2] = (Data) GetLoByte(tmp);
244          tmp = (uint16_t) GetLoWord(tmp32);
245          pkArray[1] = (Data) GetHiByte(tmp);
246          pkArray[0] = (Data) GetLoByte(tmp);
247 #endif
248          ret = SAddPreMsgMult(pkArray, (MsgLen) 8, mBuf);
249          break;
250 #endif
251       default:
252          /* no support for uint64_t */
253          ret = RFAILED;
254    }
255
256    return (ret);
257 } /* end of oduPackPointer */
258
259 \f
260 /*
261 *
262 *       Fun:   cmPkEntityId
263 *
264 *       Desc:  This function packs the EntityId structure
265 *
266 *       Ret:   ROK      - ok
267 *
268 *       Notes: None.
269 *
270 *       File:  cm_gen.c
271 *
272 */
273   
274 S16 cmPkEntityId
275 (
276 EntityId *entityId,        /* entity id */
277 Buffer   *mBuf             /* message buffer */
278 )
279 {
280
281    CMCHKPK(cmPkInst, entityId->inst, mBuf);
282    CMCHKPK(cmPkEnt, entityId->ent, mBuf);
283
284    return ROK;
285 } /* end of cmPkEntityId */
286
287 \f
288 /*
289 *
290 *       Fun:   cmPkElmntId
291 *
292 *       Desc:  This function packs the ElmntId structure
293 *
294 *       Ret:   ROK      - ok
295 *
296 *       Notes: None.
297 *
298 *       File:  cm_gen.c
299 *
300 */
301   
302 S16 cmPkElmntId
303 (
304 ElmntId *elmntId,         /* element id */
305 Buffer  *mBuf             /* message buffer */
306 )
307 {
308
309    CMCHKPK(cmPkElmntInst3, elmntId->elmntInst3, mBuf); 
310    CMCHKPK(cmPkElmntInst2, elmntId->elmntInst2, mBuf); 
311    CMCHKPK(cmPkElmntInst1, elmntId->elmntInst1, mBuf); 
312    CMCHKPK(cmPkElmnt, elmntId->elmnt, mBuf);
313
314    return ROK;
315 } /* end of cmPkElmntId */
316
317 \f
318 /*
319 *
320 *       Fun:   cmPkMemoryId
321 *
322 *       Desc:  This function packs the MemoryId structure
323 *
324 *       Ret:   ROK      - ok
325 *
326 *       Notes: None.
327 *
328 *       File:  cm_gen.c
329 *
330 */
331   
332 S16 cmPkMemoryId
333 (
334 MemoryId *memoryId,        /* memoryId */
335 Buffer   *mBuf             /* message buffer */
336 )
337 {
338
339    CMCHKPK(cmPkPool, memoryId->pool, mBuf); 
340    CMCHKPK(cmPkRegion, memoryId->region, mBuf);
341
342    return ROK;
343 } /* end of cmPkMemoryId */
344
345 \f
346 /*
347 *
348 *       Fun:   cmPkSystemId
349 *
350 *       Desc:  This function packs the System Id structure
351 *
352 *       Ret:   ROK      - ok
353 *
354 *       Notes: None.
355 *
356 *       File:  cm_gen.c
357 *
358 */
359   
360 S16 cmPkSystemId
361 (
362 SystemId *systemId,         /* system id */
363 Buffer   *mBuf              /* message buffer */
364 )
365 {
366    Txt *p;                  /* part number string */
367
368
369    for (p = systemId->ptNmb; *p; p++);
370
371    for (; p != systemId->ptNmb; p--)
372    {
373       CMCHKPK(cmPkTxt, *p, mBuf);
374    }
375    CMCHKPK(cmPkTxt, *p, mBuf);
376    
377    CMCHKPK(SPkS16, systemId->bRev, mBuf);
378    CMCHKPK(SPkS16, systemId->bVer, mBuf);
379    CMCHKPK(SPkS16, systemId->mRev, mBuf);
380    CMCHKPK(SPkS16, systemId->mVer, mBuf);
381
382    return ROK;
383 } /* end of cmPkSystemId */
384
385
386
387 /*
388  *
389  *       Fun:   cmPkProtAddr
390  *
391  *       Desc:  This function will pack protocol address.
392  *
393  *       Ret:   ROK on success
394  *              RFAILED on error
395  *
396  *       Notes: None
397  *
398          File:  cm_gen.c
399  *
400  */
401
402 S16 cmPkProtAddr
403 (
404 ProtAddr     *pAddr,     /* protocol address */
405 Buffer       *mBuf       /* buffer */
406 )
407 {
408    uint8_t              j;                  /* Index */
409
410
411 #ifdef CM_ARI2
412    CMCHKPK(oduUnpackUInt32, pAddr->autoSysId, mBuf);  
413    CMCHKPK(oduPackBool, pAddr->autoSysIdPres, mBuf);  
414 #endif /* CM_ARI2 */
415
416    for (j = pAddr->len; j; j--)
417       CMCHKPK(oduUnpackUInt8, pAddr->address[j - 1], mBuf);  
418
419    CMCHKPK(oduUnpackUInt8,  pAddr->preLen, mBuf);  
420    CMCHKPK(oduUnpackUInt8,  pAddr->len, mBuf);  
421    CMCHKPK(oduUnpackUInt16, pAddr->protType, mBuf);  
422        
423    return ROK;
424
425 } /* end of cmPkProtAddr */
426    
427
428
429 /*
430  *
431  *       Fun:   cmPkProtAddrTbl
432  *
433  *       Desc:  This function will pack protocol addresses.
434  *
435  *       Ret:   ROK on success
436  *              RFAILED on error
437  *
438  *       Notes: None
439  *
440          File:  cm_gen.c
441  *
442  */
443
444 S16 cmPkProtAddrTbl
445 (
446 ProtAddrTbl  *protAddr,      /* protocol address table */
447 Buffer       *mBuf          /* buffer */
448 )
449 {
450    uint8_t              i;                  /* index */
451    uint8_t              j;                  /* Index */
452    ProtAddr        *pAddr;             /* protocol Address */
453
454
455    if (protAddr->count > MAX_PROT_ADDRS)
456       return RFAILED;
457
458    for (i = protAddr->count; i; i--)
459    {
460        pAddr = &(protAddr->addr[i - 1]);
461
462 #ifdef CM_ARI2
463        CMCHKPK(oduUnpackUInt32, pAddr->autoSysId, mBuf);  
464        CMCHKPK(oduPackBool, pAddr->autoSysIdPres, mBuf);  
465 #endif /* CM_ARI2 */
466
467        for (j = pAddr->len; j; j--)
468           CMCHKPK(oduUnpackUInt8, pAddr->address[j - 1], mBuf);  
469         
470        CMCHKPK(oduUnpackUInt8, pAddr->preLen, mBuf);  
471        CMCHKPK(oduUnpackUInt8,  pAddr->len, mBuf);  
472        CMCHKPK(oduUnpackUInt16,  pAddr->protType, mBuf);  
473        
474    }
475    CMCHKPK(oduUnpackUInt8, protAddr->count, mBuf);  
476
477    return ROK;
478 } /* end of cmPkProtAddrTbl */
479    
480
481 /*
482 *
483 *       Fun:   cmPkAddrs
484 *
485 *       Desc:  This function packs the address structure for a loosely 
486 *              coupled interface
487 *
488 *       Ret:   ROK      - ok
489 *
490 *       Notes: None.
491 *
492 *       File:  cm_gen.c
493 *
494 */
495   
496 S16 cmPkAddrs
497 (
498 Addrs *addrs,           /* address */
499 Buffer *mBuf            /* message buffer */
500 )
501 {
502    uint8_t i;                /* loop counter */
503
504
505    if (addrs->length > ADRLEN)
506       return RFAILED;
507
508    for (i = addrs->length; i; i--)
509    {
510       CMCHKPK(oduUnpackUInt8, addrs->strg[i-1], mBuf);
511    }
512
513    CMCHKPK(oduUnpackUInt8, addrs->length, mBuf);
514
515    return ROK;
516 } /* end of cmPkAddrs */
517
518 \f
519 /*
520 *
521 *       Fun:   cmPkShrtAddrs
522 *
523 *       Desc:  This function packs the short address structure for a loosely 
524 *              coupled interface
525 *
526 *       Ret:   ROK      - ok
527 *
528 *       Notes: None.
529 *
530 *       File:  cm_gen.c
531 *
532 */
533   
534 S16 cmPkShrtAddrs
535 (
536 ShrtAddrs *addrs,          /* address */
537 Buffer    *mBuf            /* message buffer */
538 )
539 {
540    uint8_t i;                /* loop counter */
541
542
543    if (addrs->length > SHRTADRLEN)
544       return RFAILED;
545
546    for (i = addrs->length; i; i--)
547    {
548       CMCHKPK(oduUnpackUInt8, addrs->strg[i-1], mBuf);
549    }
550
551    CMCHKPK(oduUnpackUInt8, addrs->length, mBuf);
552
553    return ROK;
554 } /* end of cmPkShrtAddrs */
555
556 \f
557 /*
558 *
559 *       Fun:   cmPkAddrMask
560 *
561 *       Desc:  This function address mask array.
562 *
563 *       Ret:   ROK      - ok
564 *
565 *       Notes: None
566 *
567 *       File:  cm_gen.c
568 *
569 */
570   
571 S16 cmPkAddrMask
572 (
573 uint8_t *mask,             /* pointer to address mask array */
574 Buffer  *mBuf         /* message buffer */
575 )
576 {
577    S16 i;             /* counter */
578
579
580    /* pack address mask */
581    for (i = (ADRLEN - 1); i >= 0; i--)
582    {
583       CMCHKPK(oduUnpackUInt8, mask[i], mBuf);
584    }
585
586    return ROK;
587 } /* end of cmPkAddrMask */
588
589 \f
590 /*
591 *
592 *       Fun:   cmPkBndCfg
593 *
594 *       Desc:  This function packs the BndCfg structure
595 *
596 *       Ret:   ROK      - ok
597 *
598 *       Notes: None.
599 *
600 *       File:  cm_gen.c
601 *
602 */
603   
604 S16 cmPkBndCfg
605 (
606 BndCfg *bndCfg,         /* bndCfg */
607 Buffer *mBuf            /* message buffer */
608 )
609 {
610    Txt *p;              /* temporary */
611
612
613    CMCHKPK(cmPkSelector, bndCfg->selector, mBuf);
614    CMCHKPK(cmPkAddrs, &bndCfg->sapAdr, mBuf);
615    CMCHKPK(cmPkRoute, bndCfg->route, mBuf);
616    CMCHKPK(cmPkPrior, bndCfg->prior, mBuf);
617    CMCHKPK(cmPkPool, bndCfg->pool, mBuf); 
618    CMCHKPK(cmPkRegion, bndCfg->region, mBuf);
619    CMCHKPK(cmPkInst, bndCfg->inst, mBuf);
620    CMCHKPK(cmPkEnt, bndCfg->ent, mBuf);
621    CMCHKPK(oduUnpackUInt8, bndCfg->wdw, mBuf);
622    CMCHKPK(oduUnpackUInt8, bndCfg->flcTyp, mBuf);
623    CMCHKPK(oduUnpackUInt8, bndCfg->bufOwnshp, mBuf);
624
625    for (p = bndCfg->usrId; *p; p++);
626    for (; p != bndCfg->usrId; p--);
627    CMCHKPK(cmPkTxt, *p, mBuf);
628
629    return ROK;
630 } /* end of cmPkBndCfg */
631
632 \f
633 /*
634 *
635 *       Fun:   cmPkPst
636 *
637 *       Desc:  pack post structure 
638 *
639 *       Ret:   ROK
640 *
641 *       Notes: None.
642 *
643 *       File:  cm_gen.c
644 *
645 */
646 S16 cmPkPst
647 (
648 Pst *pst,
649 Buffer *mBuf
650 )
651 {
652    
653    CMCHKPK(cmPkEvent, pst->event, mBuf);
654    CMCHKPK(cmPkInst, pst->srcInst, mBuf);
655    CMCHKPK(cmPkEnt, pst->srcEnt, mBuf); 
656    CMCHKPK(cmPkProcId, pst->srcProcId, mBuf);
657    CMCHKPK(cmPkInst, pst->dstInst, mBuf); 
658    CMCHKPK(cmPkEnt, pst->dstEnt, mBuf); 
659    CMCHKPK(cmPkProcId, pst->dstProcId, mBuf);
660    CMCHKPK(cmPkRoute, pst->route, mBuf);
661    CMCHKPK(cmPkPrior, pst->prior, mBuf);
662    CMCHKPK(cmPkPool, pst->pool, mBuf);
663    CMCHKPK(cmPkRegion, pst->region, mBuf);
664    CMCHKPK(cmPkSelector, pst->selector, mBuf);
665 #ifdef TDS_ROLL_UPGRADE_SUPPORT
666    CMCHKPK(cmPkIntfVer, pst->intfVer, mBuf);
667 #endif
668
669    return ROK;
670 } /* end of cmPkPst */
671
672 /*
673  *
674  *      Fun:    cmPkElmtHdr
675  *
676  *      Desc:   Pack element header
677  *
678  *      Ret:   ROK      - ok
679  *
680  *      Notes:  None
681  *
682         File:   cm_gen.c
683  *
684  */
685   
686 S16 cmPkElmtHdr
687 (
688 ElmtHdr *m,                  /* element header */
689 Buffer  *mBuf                /* message buffer */
690 )
691 {
692  
693 #if (LCAMT || ATM_BISUP)
694       CMCHKPK(oduUnpackUInt16, m->compInd, mBuf);
695 #endif /* LCAMT || ATM_BISUP */
696
697 #if (LCAMT || ATM_BISUP)
698    /* Pack action indicator field */
699    if (m->pres)
700    {
701      CMCHKPK(oduUnpackUInt8, m->actnInd, mBuf);
702    }
703 #endif
704
705    /* Present */
706    CMCHKPK(oduPackBool, m->pres, mBuf);
707
708    return ROK;
709 } /* end of cmPkElmtHdr */
710
711 \f
712 /*
713  *
714  *      Fun:   cmPkTknUInt8
715  *
716  *      Desc:  This function packs a token uint8_t
717  *
718  *      Ret:   ROK      - ok
719  *
720  *      Notes: None
721  *
722         File:  cm_gen.c
723  *
724  */
725   
726 S16 cmPkTknUInt8
727 (
728 TknUInt8  *tknUInt8,              /* token uint8_t */
729 Buffer *mBuf                /* message buffer */
730 )
731 {
732
733    if (tknUInt8->pres)
734    {
735       /* Value */
736       CMCHKPK(oduUnpackUInt8, tknUInt8->val, mBuf);
737    }
738
739    /* Token Header */
740    CMCHKPK(oduUnpackUInt8, tknUInt8->pres, mBuf);
741
742    return ROK;
743 } /* end of cmPkTknUInt8 */
744
745 \f
746 /*
747  *
748  *      Fun:   cmPkTknS8
749  *
750  *      Desc:  This function packs a token S8
751  *
752  *      Ret:   ROK      - ok
753  *
754  *      Notes: None
755  *
756         File:  cm_gen.c
757  *
758  */
759   
760 S16 cmPkTknS8
761 (
762 TknS8  *tknS8,              /* token S8 */
763 Buffer *mBuf                /* message buffer */
764 )
765 {
766  
767    if (tknS8->pres)
768    {
769       /* Value */
770       CMCHKPK(SPkS8, tknS8->val, mBuf);
771    }
772  
773    /* Token Header */
774    CMCHKPK(oduUnpackUInt8, tknS8->pres, mBuf);
775  
776    return ROK;
777 } /* end of cmPkTknS8 */
778
779 \f
780 /*
781  *
782  *      Fun:   cmPkTknUInt16
783  *
784  *      Desc:  This function packs a token uint16_t
785  *
786  *      Ret:   ROK      - ok
787  *
788  *      Notes: None
789  *
790         File:  cm_gen.c
791  *
792  */
793   
794 S16 cmPkTknUInt16
795 (
796 TknUInt16 *tknUInt16,             /* token uint16_t */
797 Buffer *mBuf                /* message buffer */
798 )
799 {
800
801    if (tknUInt16->pres)
802    {
803       /* Value */
804       CMCHKPK(oduUnpackUInt16, tknUInt16->val, mBuf);
805    }
806
807    /* Token Header */
808    CMCHKPK(oduUnpackUInt8, tknUInt16->pres, mBuf);
809
810    return ROK;
811 } /* end of cmPkTknUInt16 */
812
813 \f
814 /*
815  *
816  *      Fun:   cmPkTknUInt32
817  *
818  *      Desc:  This function packs a token uint32_t
819  *
820  *      Ret:   ROK      - ok
821  *
822  *      Notes: None
823  *
824         File:  cm_gen.c
825  *
826  */
827   
828 S16 cmPkTknUInt32
829 (
830 TknUInt32 *tknUInt32,             /* token uint32_t */
831 Buffer *mBuf                /* message buffer */
832 )
833 {
834
835    if (tknUInt32->pres)
836    {
837       /* Value */
838       CMCHKPK(oduUnpackUInt32, tknUInt32->val, mBuf);
839    }
840
841    /* Token Header */
842    CMCHKPK(oduUnpackUInt8, tknUInt32->pres, mBuf);
843
844    return ROK;
845 } /* end of cmPkTknUInt32 */
846
847 \f
848 /*
849  *
850  *      Fun:   cmPkTknStr
851  *
852  *      Desc:  This function packs a token string - regular size
853  *
854  *      Ret:   ROK      - ok
855  *
856  *      Notes: None
857  *
858         File:  cm_gen.c
859  *
860  */
861   
862 S16 cmPkTknStr
863 (
864 TknStr *tknStr,             /* token string */
865 Buffer *mBuf                /* message buffer */
866 )
867 {
868    Cntr i;                    /* counter */
869
870
871    if (tknStr->pres)
872    {
873       /* Value */
874       for (i = 0; i < (S16) tknStr->len; i++)
875       {
876          CMCHKPK(oduUnpackUInt8, tknStr->val[i], mBuf);
877       }
878
879       /* Length */
880       CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);
881    }
882  
883    /* Token Header */
884    CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
885
886    return ROK;
887 } /* end of cmPkTknStr */
888
889 \f
890 /*
891  *
892  *      Fun:   cmPkTknStrM
893  *
894  *      Desc:  This function packs a token string - medium size
895  *
896  *      Ret:   ROK      - ok
897  *
898  *      Notes: None
899  *
900         File:  cm_gen.c
901  *
902  */
903   
904 S16 cmPkTknStrM
905 (
906 TknStrM *tknStr,             /* token string */
907 Buffer *mBuf                /* message buffer */
908 )
909 {
910    Cntr i;                    /* counter */
911
912
913    if(tknStr->pres)
914    {
915       /* Value */
916       for (i = 0; i < (S16) tknStr->len; i++)
917       {
918          CMCHKPK(oduUnpackUInt8, tknStr->val[i], mBuf);
919       }
920
921       /* Length */
922       CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);
923    }
924  
925    /* Token Header */
926    CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
927
928    return ROK;
929 } /* end of cmPkTknStrM */
930
931 \f
932 /*
933  *
934  *      Fun:   cmPkTknStrS
935  *
936  *      Desc:  This function packs a token string - small size
937  *
938  *      Ret:   ROK      - ok
939  *
940  *      Notes: None
941  *
942         File:  cm_gen.c
943  *
944  */
945   
946 S16 cmPkTknStrS
947 (
948 TknStrS *tknStr,             /* token string */
949 Buffer *mBuf                /* message buffer */
950 )
951 {
952    Cntr i;                    /* counter */
953
954
955    if(tknStr->pres)
956    {
957       /* Value */
958       for (i = 0; i < (S16) tknStr->len; i++)
959       {
960          CMCHKPK(oduUnpackUInt8, tknStr->val[i], mBuf);
961       }
962
963       /* Length */
964       CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);
965    }
966  
967    /* Token Header */
968    CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
969
970    return ROK;
971 } /* end of cmPkTknStrS */
972
973 \f
974 /*
975  *
976  *      Fun:   cmPkTknStrE
977  *
978  *      Desc:  This function packs a token string - extended size
979  *
980  *      Ret:   ROK      - ok
981  *
982  *      Notes: None
983  *
984         File:  cm_gen.c
985  *
986  */
987   
988 S16 cmPkTknStrE
989 (
990 TknStrE *tknStr,             /* token string */
991 Buffer *mBuf                /* message buffer */
992 )
993 {
994    Cntr i;                    /* counter */
995
996
997    if(tknStr->pres)
998    {
999       /* Value */
1000       for (i = 0; i < (S16) tknStr->len; i++)
1001       {
1002          CMCHKPK(oduUnpackUInt8, tknStr->val[i], mBuf);
1003       }
1004
1005       /* Length */
1006       CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);
1007    }
1008  
1009    /* Token Header */
1010    CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
1011
1012    return ROK;
1013 } /* end of cmPkTknStrE */
1014
1015 #ifndef CMFILE_REORG_1
1016
1017 \f
1018 /*
1019 *
1020 *       Fun:   cmPkPnNodeId
1021 *
1022 *       Desc:  This function packs a PnNodeId structure into a buffer
1023 *
1024 *       Ret:   Void
1025 *
1026 *       Notes: None
1027 *
1028 *       File:  cm_gen.c
1029 *
1030 */
1031   
1032 S16 cmPkPnNodeId
1033 (
1034 PnNodeId  *src,     /* source PNNI Node Id */
1035 Buffer *mBuf        /* message buffer */
1036 )
1037 {
1038    S16 i;
1039    
1040    
1041    for (i = PN_NODEID_LEN - 1; i >= 0; i--)
1042    {
1043       CMCHKPK(oduUnpackUInt8, src->id[i], mBuf);
1044    }
1045    
1046    return ROK;
1047 } /* cmPkPnNodeId */
1048
1049 #endif /* CMFILE_REORG_1 */
1050
1051 \f
1052 /*
1053  *
1054  *      Fun:   cmPkTknStr4
1055  *
1056  *      Desc:  This function packs a token string of size 4
1057  *
1058  *      Ret:   ROK      - ok
1059  *
1060  *      Notes: None
1061  *
1062         File:  cm_gen.c
1063  *
1064  */
1065   
1066 S16 cmPkTknStr4
1067 (
1068 TknStr4 *tknStr,             /* token string */
1069 Buffer  *mBuf                /* message buffer */
1070 )
1071 {
1072
1073    CMPKTKNSTR(tknStr, mBuf);
1074
1075    return ROK;
1076
1077 } /* end of cmPkTknStr4 */
1078
1079
1080 \f
1081 /*
1082  *
1083  *      Fun:   cmPkTknStr12
1084  *
1085  *      Desc:  This function packs a token string of size 4
1086  *
1087  *      Ret:   ROK      - ok
1088  *
1089  *      Notes: None
1090  *
1091         File:  cm_gen.c
1092  *
1093  */
1094   
1095 S16 cmPkTknStr12
1096 (
1097 TknStr12 *tknStr,             /* token string */
1098 Buffer   *mBuf                /* message buffer */
1099 )
1100 {
1101
1102    CMPKTKNSTR(tknStr, mBuf);
1103
1104    return ROK;
1105
1106 } /* end of cmPkTknStr12 */
1107
1108 \f
1109 /*
1110  *
1111  *      Fun:   cmPkTknStr32
1112  *
1113  *      Desc:  This function packs a token string of size 4
1114  *
1115  *      Ret:   ROK      - ok
1116  *
1117  *      Notes: None
1118  *
1119         File:  cm_gen.c
1120  *
1121  */
1122   
1123 S16 cmPkTknStr32
1124 (
1125 TknStr32 *tknStr,             /* token string */
1126 Buffer   *mBuf                /* message buffer */
1127 )
1128 {
1129
1130    CMPKTKNSTR(tknStr, mBuf);
1131
1132    return ROK;
1133
1134 } /* end of cmPkTknStr32 */
1135
1136 \f
1137 /*
1138  *
1139  *      Fun:   cmPkTknStr64
1140  *
1141  *      Desc:  This function packs a token string of size 4
1142  *
1143  *      Ret:   ROK      - ok
1144  *
1145  *      Notes: None
1146  *
1147         File:  cm_gen.c
1148  *
1149  */
1150   
1151 S16 cmPkTknStr64
1152 (
1153 TknStr64 *tknStr,             /* token string */
1154 Buffer   *mBuf                /* message buffer */
1155 )
1156 {
1157
1158    CMPKTKNSTR(tknStr, mBuf);
1159
1160    return ROK;
1161
1162 } /* end of cmPkTknStr64 */
1163
1164 \f
1165 /*
1166  *
1167  *      Fun:   cmPkTknStr132
1168  *
1169  *      Desc:  This function packs a token string of size 4
1170  *
1171  *      Ret:   ROK      - ok
1172  *
1173  *      Notes: None
1174  *
1175         File:  cm_gen.c
1176  *
1177  */
1178   
1179 S16 cmPkTknStr132
1180 (
1181 TknStr132 *tknStr,             /* token string */
1182 Buffer   *mBuf                /* message buffer */
1183 )
1184 {
1185
1186    CMPKTKNSTR(tknStr, mBuf);
1187
1188    return ROK;
1189
1190 } /* end of cmPkTknStr132 */
1191
1192 \f
1193 /*
1194  *
1195  *      Fun:   cmPkTknStr256
1196  *
1197  *      Desc:  This function packs a token string of size 4
1198  *
1199  *      Ret:   ROK      - ok
1200  *
1201  *      Notes: None
1202  *
1203         File:  cm_gen.c
1204  *
1205  */
1206   
1207 S16 cmPkTknStr256
1208 (
1209 TknStr256 *tknStr,             /* token string */
1210 Buffer    *mBuf                /* message buffer */
1211 )
1212 {
1213
1214    CMPKTKNSTR(tknStr, mBuf);
1215
1216    return ROK;
1217
1218 } /* end of cmPkTknStr256 */
1219
1220 \f
1221 /*
1222  *
1223  *      Fun:   cmPkTknOid
1224  *
1225  *      Desc:  This function packs a Object Identifier token
1226  *
1227  *      Ret:   ROK      - ok
1228  *
1229  *      Notes: None
1230  *
1231         File:  cm_gen.c
1232  *
1233  */
1234   
1235 S16 cmPkTknOid
1236 (
1237 TknOid   *tknOid,             /* Object Identifier token */
1238 Buffer   *mBuf                /* message buffer */
1239 )
1240 {
1241    uint16_t    i;
1242
1243  
1244    if (tknOid->pres == TRUE)
1245    {
1246       /* Pack the value */
1247       for (i = 0; i < (uint16_t)tknOid->len; i++)
1248       {
1249          /* cm_gen_c_001.main_33: changes for TknOid value from uint16_t to uint32_t
1250           * with compilation flag TKNOID_UINT16 */
1251 #ifndef TKNOID_UINT16
1252          CMCHKPK(oduUnpackUInt32, tknOid->val[i], mBuf);
1253 #else
1254          CMCHKPK(oduUnpackUInt16, tknOid->val[i], mBuf);
1255 #endif  /* !TKNOID_UINT16 */
1256       }
1257       /* Pack the length */
1258       CMCHKPK(oduUnpackUInt8, tknOid->len, mBuf);
1259    }
1260    /* Pack the token header */
1261    CMCHKPK(oduUnpackUInt8, tknOid->pres, mBuf);
1262
1263    return ROK;
1264 } /* end of cmPkTknOid */
1265
1266 \f
1267 /*
1268 *
1269 *      Fun:   cmPkTknS32
1270 *
1271 *      Desc:  This function packs a token S32
1272 *
1273 *      Ret:   ROK      - ok
1274 *
1275 *      Notes: None
1276 *
1277 *      File:  cm_gen.c
1278 *
1279 */
1280   
1281 S16 cmPkTknS32
1282 (
1283 TknS32 *tknS32,             /* token S32 */
1284 Buffer *mBuf                /* message buffer */
1285 )
1286 {
1287
1288    if (tknS32->pres)
1289    {
1290       /* Value */
1291       CMCHKPK(SPkS32, tknS32->val, mBuf);
1292    }
1293
1294    /* Token Header */
1295    CMCHKPK(oduUnpackUInt8, tknS32->pres, mBuf);
1296
1297    return ROK;
1298 } /* end of cmPkTknS32 */
1299
1300 \f
1301 /*
1302 *
1303 *       Fun:   cmPkHeader
1304 *
1305 *       Desc:  This function packs the header structure
1306 *
1307 *       Ret:   ROK      - ok
1308 *
1309 *       Notes: None.
1310 *
1311 *       File:  cm_gen.c
1312 *
1313 */
1314   
1315 S16 cmPkHeader
1316 (
1317 Header *header,             /* header */
1318 Buffer *mBuf                /* message buffer */
1319 )
1320 {
1321
1322 #ifdef LMINT3
1323    CMCHKPK(cmPkMemoryId, &header->response.mem, mBuf);
1324    CMCHKPK(cmPkRoute, header->response.route, mBuf);
1325    CMCHKPK(cmPkPriority, header->response.prior, mBuf);
1326    CMCHKPK(cmPkSelector, header->response.selector, mBuf);
1327    CMCHKPK(cmPkTranId, header->transId, mBuf);
1328 #endif /* LMINT3 */
1329    CMCHKPK(cmPkElmntId, &header->elmId, mBuf);
1330    CMCHKPK(cmPkEntityId, &header->entId, mBuf);
1331    CMCHKPK(oduUnpackUInt16, header->seqNmb, mBuf);
1332    CMCHKPK(oduUnpackUInt8, header->version, mBuf);
1333    CMCHKPK(oduUnpackUInt8, header->msgType, mBuf);
1334    CMCHKPK(oduUnpackUInt16, header->msgLen, mBuf);
1335
1336    return ROK;
1337 } /* end of cmPkHeader */
1338
1339 \f
1340 /*
1341 *
1342 *       Fun:   cmPkCmStatus
1343 *
1344 *       Desc:  This function packs common management status structure
1345 *
1346 *       Ret:   ROK      - ok
1347 *
1348 *       Notes: None.
1349 *
1350 *       File:  cm_gen.c
1351 *
1352 */
1353   
1354 S16 cmPkCmStatus
1355 (
1356 CmStatus *sta,              /* status structure */
1357 Buffer *mBuf                /* message buffer */
1358 )
1359 {
1360
1361    CMCHKPK(oduUnpackUInt16, sta->reason, mBuf);
1362    CMCHKPK(oduUnpackUInt16, sta->status, mBuf);
1363
1364    return ROK;
1365 } /* end of cmPkCmStatus */
1366
1367 \f
1368 /*
1369 *
1370 *       Fun:   cmPkCmAlarm
1371 *
1372 *       Desc:  This function packs common management alarm structure
1373 *
1374 *       Ret:   ROK      - ok
1375 *
1376 *       Notes: None.
1377 *
1378 *       File:  cm_gen.c
1379 *
1380 */
1381   
1382 S16 cmPkCmAlarm
1383 (
1384 CmAlarm *alarm,            /* alarm structure */
1385 Buffer  *mBuf              /* message buffer */
1386 )
1387 {
1388
1389    CMCHKPK(oduUnpackUInt16, alarm->cause, mBuf);
1390    CMCHKPK(oduUnpackUInt16, alarm->event, mBuf);
1391    CMCHKPK(oduUnpackUInt16, alarm->category, mBuf);
1392    CMCHKPK(cmPkDateTime, &alarm->dt, mBuf);
1393
1394    return ROK;
1395 } /* end of cmPkCmAlarm */
1396
1397 \f
1398 /*
1399 *
1400 *       Fun:   cmPkSmCfg
1401 *
1402 *       Desc:  This function packs the stack manager structure
1403 *
1404 *       Ret:   ROK      - ok
1405 *
1406 *       Notes: None.
1407 *
1408 *       File:  cm_gen.c
1409 *
1410 */
1411   
1412 S16 cmPkSmCfg
1413 (
1414 SmCfg *smCfg,           /* stack manager */
1415 Buffer *mBuf            /* message buffer */
1416 )
1417 {
1418
1419    CMCHKPK(cmPkSelector, smCfg->selector, mBuf); 
1420    CMCHKPK(cmPkRoute, smCfg->route, mBuf); 
1421    CMCHKPK(cmPkPrior, smCfg->prior, mBuf); 
1422    CMCHKPK(cmPkPool, smCfg->pool, mBuf); 
1423    CMCHKPK(cmPkRegion, smCfg->region, mBuf);
1424    CMCHKPK(cmPkInst, smCfg->inst, mBuf);
1425    CMCHKPK(cmPkEnt, smCfg->ent, mBuf);
1426
1427    return ROK;
1428 } /* end of cmPkSmCfg */
1429
1430 \f
1431 /*
1432 *
1433 *       Fun:   cmPkTmrCfg
1434 *
1435 *       Desc:  This function packs the timer configuration structure
1436 *
1437 *       Ret:   ROK      - ok
1438 *
1439 *       Notes: None.
1440 *
1441 *       File:  cm_gen.c
1442 *
1443 */
1444   
1445 S16 cmPkTmrCfg
1446 (
1447 TmrCfg *tmrCfg,         /* timer configuration */
1448 Buffer *mBuf            /* message buffer */
1449 )
1450 {
1451
1452    CMCHKPK(oduUnpackUInt16, tmrCfg->val, mBuf);
1453    CMCHKPK(oduPackBool, tmrCfg->enb, mBuf);
1454
1455    return ROK;
1456 } /* end of cmPkTmrCfg */
1457
1458 \f
1459 /*
1460  *
1461  *      Fun:   cmPkTknBuf
1462  *
1463  *      Desc:  This function packs a token buffer
1464  *
1465  *      Ret:   ROK      - ok
1466  *
1467  *      Notes: None
1468  *
1469         File:  cm_gen.c
1470  *
1471  */
1472   
1473 S16 cmPkTknBuf
1474 (
1475 TknBuf *tknBuf,                /* token string */
1476 Buffer    *mBuf                /* message buffer */
1477 )
1478 {
1479
1480    if(tknBuf->pres)
1481    {
1482       MsgLen msgLen;
1483
1484       SFndLenMsg(tknBuf->val, &msgLen);
1485       if( SCatMsg(mBuf, tknBuf->val, M2M1) != ROK )
1486       {
1487          return RFAILED;
1488       }
1489       cmPkMsgLen(msgLen, mBuf);
1490       SPutMsg(tknBuf->val);
1491    }
1492   
1493    /* Token Header */
1494    CMCHKPK(oduUnpackUInt8, tknBuf->pres, mBuf);
1495
1496    return ROK;
1497 } /* end of cmPkTknBuf */
1498
1499 #ifdef TDS_ROLL_UPGRADE_SUPPORT
1500 /*
1501 *
1502 *       Fun:   cmPkIntf
1503 *
1504 *       Desc:  This function packs the interface information
1505 *
1506 *       Ret:   ROK      - ok
1507 *
1508 *       Notes: None.
1509 *
1510 *       File:  cm_gen.c
1511 *
1512 */
1513   
1514 S16 cmPkIntf
1515 (
1516 CmIntf *intf,           /* interface info */
1517 Buffer *mBuf            /* message buffer */
1518 )
1519 {
1520
1521    CMCHKPK(cmPkIntfId,  intf->intfId,  mBuf); 
1522    CMCHKPK(cmPkIntfVer, intf->intfVer, mBuf); 
1523
1524    return ROK;
1525 } /* end of cmPkIntf */
1526 #endif /* TDS_ROLL_UPGRADE_SUPPORT */
1527
1528 \f
1529 /*
1530  *   common unpacking functions 
1531  */
1532
1533 \f
1534 /*
1535 *
1536 *       Fun:   cmUnpkDateTime
1537 *
1538 *       Desc:  This function is used to Unpack Pack Date Time structure
1539 *
1540 *       Ret:   ROK      - ok
1541 *
1542 *       Notes: None
1543 *
1544 *       File:  cm_gen.c
1545 *
1546 */
1547   
1548 S16 cmUnpkDateTime
1549 (
1550 DateTime *dateTime,  /* date/time structure */
1551 Buffer *mBuf         /* message buffer */
1552 )
1553 {
1554
1555    CMCHKUNPK(oduPackUInt8, &dateTime->month, mBuf); 
1556    CMCHKUNPK(oduPackUInt8, &dateTime->day, mBuf); 
1557    CMCHKUNPK(oduPackUInt8, &dateTime->year, mBuf); 
1558    CMCHKUNPK(oduPackUInt8, &dateTime->hour, mBuf); 
1559    CMCHKUNPK(oduPackUInt8, &dateTime->min, mBuf); 
1560    CMCHKUNPK(oduPackUInt8, &dateTime->sec, mBuf); 
1561    CMCHKUNPK(oduPackUInt8, &dateTime->tenths, mBuf);
1562
1563    /*-- added for micro seconds --*/
1564 #ifdef SS_DATETIME_USEC
1565    CMCHKUNPK(oduPackUInt32, &dateTime->usec, mBuf);
1566 #endif /*-- SS_DATETIME_USEC --*/
1567
1568    return ROK;
1569 } /* end of cmUnpkDateTime */
1570
1571 \f
1572 /*
1573 *
1574 *       Fun:   cmUnpkDuration
1575 *
1576 *       Desc:  This function is used to Unpack Pack Duration structure
1577 *
1578 *       Ret:   ROK      - ok
1579 *
1580 *       Notes: None
1581 *
1582 *       File:  cm_gen.c
1583 *
1584 */
1585   
1586 S16 cmUnpkDuration
1587 (
1588 Duration *duration,  /* duration structure */
1589 Buffer *mBuf         /* message buffer */
1590 )
1591 {
1592
1593    CMCHKUNPK(oduPackUInt8, &duration->days, mBuf); 
1594    CMCHKUNPK(oduPackUInt8, &duration->hours, mBuf); 
1595    CMCHKUNPK(oduPackUInt8, &duration->mins, mBuf); 
1596    CMCHKUNPK(oduPackUInt8, &duration->secs, mBuf); 
1597    CMCHKUNPK(oduPackUInt8, &duration->tenths, mBuf);
1598
1599    return ROK;
1600 } /* end of cmUnpkDuration */
1601
1602 /*
1603 *
1604 *       Fun:   oduUnpackPointer
1605 *
1606 *       Desc:  This function is used to Unpack Ptr type
1607 *
1608 *       Ret:   ROK      - ok
1609 *
1610 *       Notes: None
1611 *
1612 *       File:  cm_gen.c
1613 *
1614 */
1615   
1616 S16 oduUnpackPointer
1617 (
1618 PTR *ptr,  /* duration structure */
1619 Buffer *mBuf    /* message buffer */
1620 )
1621 {
1622    uint16_t tmp16 =0;               /* temporary value */
1623    uint32_t tmp32 =0;               /* temporary value */
1624    Data unpkArray[PTRSIZE];        /* unpacking array */
1625    S16 ret =ROK;                 /* return code */
1626
1627 #if (defined(ALPHA) || defined(BIT_64))
1628    uint64_t tmp64 =0;
1629 #endif
1630    
1631
1632    switch (PTRSIZE)
1633    {
1634       case 2:
1635          ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf);
1636          if (ret != ROK)
1637             return (ret);
1638
1639          tmp16 = 0; 
1640 #ifndef FCSPKINT            /* backward compatibility, packing order */
1641          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
1642          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
1643 #else                       /* forward compatibility, packing order */
1644          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
1645          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
1646 #endif
1647          *ptr = tmp16;
1648          break;
1649
1650       case 4:
1651          ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf);
1652          if (ret != ROK)
1653             return (ret);
1654
1655          tmp16 = 0;
1656          tmp32 = 0; 
1657 #ifndef FCSPKINT            /* backward compatibility, packing order */
1658          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[3]);
1659          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[2]);
1660          tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
1661          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
1662          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
1663          tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
1664 #else                       /* forward compatibility, packing order */
1665          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
1666          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
1667          tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
1668          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[2]);
1669          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[3]);
1670          tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
1671 #endif
1672          *ptr = tmp32;
1673          break;
1674
1675       case 8:
1676 #if(defined(ALPHA) || defined(BIT_64))
1677          ret = SRemPreMsgMult(unpkArray, (MsgLen) 8, mBuf);
1678          if (ret != ROK)
1679             return (ret);
1680
1681          tmp16 = 0;
1682          tmp32 = 0; 
1683          tmp64 = 0;
1684 #ifndef FCSPKINT            /* backward compatibility, packing order */
1685          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[7]);
1686          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[6]);
1687          tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
1688          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[5]);
1689          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[4]);
1690          tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
1691          tmp64 = (uint64_t) PutHi32Bit(tmp64, tmp32);
1692          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[3]);
1693          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[2]);
1694          tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
1695          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
1696          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
1697          tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
1698          tmp64 = (uint64_t) PutLo32Bit(tmp64, tmp32);
1699 #else                       /* forward compatibility, packing order */
1700          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
1701          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
1702          tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
1703          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[2]);
1704          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[3]);
1705          tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
1706          tmp64 = (uint64_t) PutHi32Bit(tmp64, tmp32);
1707          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[4]);
1708          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[5]);
1709          tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
1710          tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[6]);
1711          tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[7]);
1712          tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
1713          tmp64 = (uint64_t) PutLo32Bit(tmp64, tmp32);
1714 #endif
1715          *ptr = tmp64;
1716          break;
1717 #endif
1718       default:
1719          /* no support for uint64_t */
1720          ret = RFAILED;
1721    }
1722
1723    return (ret);
1724 } /* end of oduUnpackPointer */
1725
1726 \f
1727 /*
1728 *
1729 *       Fun:   cmUnpkEntityId
1730 *
1731 *       Desc:  This function unpacks the EntityId structure
1732 *
1733 *       Ret:   ROK      - ok
1734 *
1735 *       Notes: None.
1736 *
1737 *       File:  cm_gen.c
1738 *
1739 */
1740   
1741 S16 cmUnpkEntityId
1742 (
1743 EntityId *entityId,        /* entity id */
1744 Buffer   *mBuf             /* message buffer */
1745 )
1746 {
1747
1748    CMCHKUNPK(cmUnpkEnt, &entityId->ent, mBuf); 
1749    CMCHKUNPK(cmUnpkInst, &entityId->inst, mBuf);
1750
1751    return ROK;
1752 } /* end of cmUnpkEntityId */
1753
1754 \f
1755 /*
1756 *
1757 *       Fun:   cmUnpkElmntId
1758 *
1759 *       Desc:  This function unpacks the ElmntId structure
1760 *
1761 *       Ret:   ROK      - ok
1762 *
1763 *       Notes: None.
1764 *
1765 *       File:  cm_gen.c
1766 *
1767 */
1768   
1769 S16 cmUnpkElmntId
1770 (
1771 ElmntId *elmntId,         /* element id */
1772 Buffer  *mBuf             /* message buffer */
1773 )
1774 {
1775
1776    CMCHKUNPK(cmUnpkElmnt, &elmntId->elmnt, mBuf); 
1777    CMCHKUNPK(cmUnpkElmntInst1, &elmntId->elmntInst1, mBuf); 
1778    CMCHKUNPK(cmUnpkElmntInst2, &elmntId->elmntInst2, mBuf); 
1779    CMCHKUNPK(cmUnpkElmntInst3, &elmntId->elmntInst3, mBuf);
1780
1781    return ROK;
1782 } /* end of cmUnpkElmntId */
1783
1784 \f
1785 /*
1786 *
1787 *       Fun:   cmUnpkMemoryId
1788 *
1789 *       Desc:  This function unpacks the MemoryId structure
1790 *
1791 *       Ret:   ROK      - ok
1792 *
1793 *       Notes: None.
1794 *
1795 *       File:  cm_gen.c
1796 *
1797 */
1798   
1799 S16 cmUnpkMemoryId
1800 (
1801 MemoryId *memoryId,        /* memoryId */
1802 Buffer   *mBuf             /* message buffer */
1803 )
1804 {
1805
1806    CMCHKUNPK(cmUnpkRegion, &memoryId->region,   mBuf); 
1807    CMCHKUNPK(cmUnpkPool, &memoryId->pool, mBuf);
1808
1809    return ROK;
1810 } /* end of cmUnpkMemoryId */
1811
1812 \f
1813 /*
1814 *
1815 *       Fun:   cmUnpkSystemId
1816 *
1817 *       Desc:  This function packs the System Id structure
1818 *
1819 *       Ret:   ROK      - ok
1820 *
1821 *       Notes: None.
1822 *
1823 *       File:  cm_gen.c
1824 *
1825 */
1826   
1827 S16 cmUnpkSystemId
1828 (
1829 SystemId *systemId,         /* system id */
1830 Buffer   *mBuf              /* message buffer */
1831 )
1832 {
1833    S16 i;               /* loop counter */
1834    MsgLen len;
1835    
1836
1837    CMCHKUNPK(SUnpkS16, &systemId->mVer, mBuf); 
1838    CMCHKUNPK(SUnpkS16, &systemId->mRev, mBuf); 
1839    CMCHKUNPK(SUnpkS16, &systemId->bVer, mBuf); 
1840    CMCHKUNPK(SUnpkS16, &systemId->bRev, mBuf);
1841
1842    SFndLenMsg(mBuf, &len);
1843    
1844    for (i = 0; i < len; i++)
1845    {
1846      CMCHKUNPK(cmUnpkTxt, &systemId->ptNmb[i], mBuf);
1847    }
1848    
1849    return ROK;
1850 } /* end of cmUnpkSystemId */
1851
1852
1853
1854 /*
1855  *
1856  *       Fun:   cmUnpkProtAddr   
1857  *
1858  *       Desc:  This function will unpack protocol address.
1859  *
1860  *       Ret:   ROK on success
1861  *              RFAILED on error
1862  *
1863  *       Notes: None
1864  *
1865          File:  cm_gen.c
1866  *
1867  */
1868
1869 S16 cmUnpkProtAddr
1870 (
1871 ProtAddr     *pAddr,         /* protocol address */
1872 Buffer       *mBuf           /* buffer */
1873 )
1874 {
1875    uint8_t               j;                  /* Index */
1876
1877
1878    CMCHKUNPK(oduPackUInt16,  &(pAddr->protType), mBuf);  
1879    CMCHKUNPK(oduPackUInt8,   &(pAddr->len), mBuf);  
1880    CMCHKUNPK(oduPackUInt8,   &(pAddr->preLen), mBuf);  
1881
1882    for (j =0; j <  pAddr->len; j++)
1883       CMCHKUNPK(oduPackUInt8, &pAddr->address[j], mBuf);  
1884    
1885 #ifdef CM_ARI2
1886    CMCHKUNPK(oduUnpackBool,   &(pAddr->autoSysIdPres), mBuf);  
1887    CMCHKUNPK(oduPackUInt32,  &(pAddr->autoSysId), mBuf);  
1888 #endif /* CM_ARI2 */
1889    return ROK;
1890
1891 } /* end of cmUnpkProtAddr */
1892    
1893
1894 /*
1895  *
1896  *       Fun:   cmUnpkProtAddrTbl
1897  *
1898  *       Desc:  This function will pack protocol addresses.
1899  *
1900  *       Ret:   ROK on success
1901  *              RFAILED on error
1902  *
1903  *       Notes: None
1904  *
1905          File:  cm_gen.c
1906  *
1907  */
1908
1909 S16 cmUnpkProtAddrTbl
1910 (
1911 ProtAddrTbl  *protAddr,      /* protocol address table */
1912 Buffer       *mBuf           /* buffer */
1913 )
1914 {
1915    uint8_t               i;                  /* index */
1916    uint8_t               j;                  /* Index */
1917    ProtAddr         *pAddr;             /* Protocol Address */
1918
1919
1920    CMCHKUNPK(oduPackUInt8, &protAddr->count, mBuf);  
1921    for (i = 0;  i < protAddr->count; i++)
1922    {
1923        pAddr = &(protAddr->addr[i]);
1924
1925        CMCHKUNPK(oduPackUInt16,  &(pAddr->protType), mBuf);  
1926        CMCHKUNPK(oduPackUInt8,  &(pAddr->len), mBuf);  
1927        CMCHKUNPK(oduPackUInt8, &(pAddr->preLen), mBuf);  
1928
1929         
1930        for (j =0; j <  pAddr->len; j++)
1931           CMCHKUNPK(oduPackUInt8, &pAddr->address[j], mBuf);  
1932
1933 #ifdef CM_ARI2
1934        CMCHKUNPK(oduUnpackBool,   &(pAddr->autoSysIdPres), mBuf);
1935        CMCHKUNPK(oduPackUInt32,  &(pAddr->autoSysId), mBuf);
1936 #endif /* CM_ARI2 */
1937    }
1938    return ROK;
1939 } /* end of cmUnpkProtAddrTbl */
1940    
1941
1942 /*
1943 *
1944 *       Fun:   cmUnpkAddrs
1945 *
1946 *       Desc:  This function is used to unpack the Addrs structure
1947 *
1948 *       Ret:   ROK - ok
1949 *
1950 *       Notes: None
1951 *
1952 *       File:  cm_gen.c
1953 *
1954 */
1955   
1956 S16 cmUnpkAddrs
1957 (
1958 Addrs *addrs,     /* address */
1959 Buffer *mBuf      /* message buffer */
1960 )
1961 {
1962    uint8_t i;          /* loop counter */
1963
1964
1965    CMCHKUNPK(oduPackUInt8, &addrs->length, mBuf);
1966
1967    if (addrs->length > ADRLEN)
1968       return RFAILED;
1969    
1970    for(i = 0; i < addrs->length; i++)
1971    {
1972       CMCHKUNPK(oduPackUInt8, &addrs->strg[i], mBuf);
1973    }
1974
1975    return ROK;
1976 } /* end of cmUnpkAddrs */
1977
1978 /*
1979 *
1980 *       Fun:   cmUnpkShrtAddrs
1981 *
1982 *       Desc:  This function is used to unpack the ShrtAddrs structure
1983 *
1984 *       Ret:   ROK - ok
1985 *
1986 *       Notes: None
1987 *
1988 *       File:  cm_gen.c
1989 *
1990 */
1991   
1992 S16 cmUnpkShrtAddrs
1993 (
1994 ShrtAddrs *addrs,    /* address */
1995 Buffer    *mBuf      /* message buffer */
1996 )
1997 {
1998    uint8_t i;          /* loop counter */
1999
2000
2001    CMCHKUNPK(oduPackUInt8, &addrs->length, mBuf);
2002
2003    if (addrs->length > SHRTADRLEN)
2004       return RFAILED;
2005    
2006    for(i = 0; i < addrs->length; i++)
2007    {
2008       CMCHKUNPK(oduPackUInt8, &addrs->strg[i], mBuf);
2009    }
2010    return ROK;
2011 } /* end of cmUnpkShrtAddrs */
2012
2013 \f
2014 /*
2015 *
2016 *       Fun:   cmUnpkAddrMask
2017 *
2018 *       Desc:  This unpacks address mask.
2019 *
2020 *       Ret:   ROK      - ok
2021 *
2022 *       Notes: None
2023 *
2024 *       File:  cm_gen.c
2025 *
2026 */
2027   
2028 S16 cmUnpkAddrMask
2029 (
2030 uint8_t *mask,             /* pointer to address mask */
2031 Buffer  *mBuf         /* message buffer */
2032 )
2033 {
2034    S16 i;             /* counter */
2035
2036
2037    /* unpack address mask */
2038    for (i = 0; i< ADRLEN; i++) 
2039    {
2040       CMCHKUNPK(oduPackUInt8, &mask[i], mBuf);
2041    }
2042    return ROK;
2043 } /* end of cmUnpkAddrMask */
2044
2045 \f
2046 /*
2047 *
2048 *       Fun:   cmUnpkBndCfg
2049 *
2050 *       Desc:  This function unpacks the BndCfg structure
2051 *
2052 *       Ret:   ROK      - ok
2053 *
2054 *       Notes: None.
2055 *
2056 *       File:  cm_gen.c
2057 *
2058 */
2059   
2060 S16 cmUnpkBndCfg
2061 (
2062 BndCfg *bndCfg,         /* bndCfg */
2063 Buffer *mBuf            /* message buffer */
2064 )
2065 {
2066    S16 i;               /* loop counter */
2067
2068
2069    for (i = 0; bndCfg->usrId[i]; i++);
2070    CMCHKUNPK(cmUnpkTxt, bndCfg->usrId+i, mBuf);
2071
2072    CMCHKUNPK(oduPackUInt8, &bndCfg->bufOwnshp, mBuf); 
2073    CMCHKUNPK(oduPackUInt8, &bndCfg->flcTyp, mBuf); 
2074    CMCHKUNPK(oduPackUInt8, &bndCfg->wdw, mBuf); 
2075    CMCHKUNPK(cmUnpkEnt, &bndCfg->ent, mBuf); 
2076    CMCHKUNPK(cmUnpkInst, &bndCfg->inst, mBuf); 
2077    CMCHKUNPK(cmUnpkRegion, &bndCfg->region, mBuf); 
2078    CMCHKUNPK(cmUnpkPool, &bndCfg->pool, mBuf); 
2079    CMCHKUNPK(cmUnpkPrior, &bndCfg->prior, mBuf); 
2080    CMCHKUNPK(cmUnpkRoute, &bndCfg->route, mBuf); 
2081    CMCHKUNPK(cmUnpkAddrs, &bndCfg->sapAdr, mBuf); 
2082    CMCHKUNPK(cmUnpkSelector, &bndCfg->selector, mBuf);
2083
2084    return ROK;
2085 } /* end of cmUnpkBndCfg */
2086
2087 \f
2088 /*
2089 *
2090 *       Fun:   cmUnpkPst
2091 *
2092 *       Desc:  pack post structure 
2093 *
2094 *       Ret:   ROK
2095 *
2096 *       Notes: None.
2097 *
2098 *       File:  cm_gen.c
2099 *
2100 */
2101 S16 cmUnpkPst
2102 (
2103 Pst *pst,
2104 Buffer *mBuf
2105 )
2106 {
2107
2108 #ifdef TDS_ROLL_UPGRADE_SUPPORT
2109    CMCHKUNPK(cmUnpkIntfVer, &pst->intfVer, mBuf);
2110 #endif
2111    CMCHKUNPK(cmUnpkSelector, &pst->selector, mBuf); 
2112    CMCHKUNPK(cmUnpkRegion, &pst->region, mBuf); 
2113    CMCHKUNPK(cmUnpkPool, &pst->pool, mBuf); 
2114    CMCHKUNPK(cmUnpkPrior, &pst->prior, mBuf); 
2115    CMCHKUNPK(cmUnpkRoute, &pst->route, mBuf); 
2116    CMCHKUNPK(cmUnpkProcId, &pst->dstProcId, mBuf); 
2117    CMCHKUNPK(cmUnpkEnt, &pst->dstEnt, mBuf); 
2118    CMCHKUNPK(cmUnpkInst, &pst->dstInst, mBuf); 
2119    CMCHKUNPK(cmUnpkProcId, &pst->srcProcId, mBuf); 
2120    CMCHKUNPK(cmUnpkEnt, &pst->srcEnt, mBuf); 
2121    CMCHKUNPK(cmUnpkInst, &pst->srcInst, mBuf); 
2122    CMCHKUNPK(cmUnpkEvent, &pst->event, mBuf);
2123
2124    return ROK;
2125 } /* end of cmUnpkPst */
2126
2127 /*
2128 *
2129 *       Fun:    cmUnpkElmtHdr
2130 *
2131 *       Desc:   Unpack element header
2132 *
2133 *       Ret:   ROK      - ok
2134 *
2135 *       Notes:  None
2136 *
2137 *       File:   cm_gen.c
2138 *
2139 */
2140   
2141 S16 cmUnpkElmtHdr
2142 (
2143 ElmtHdr *m,                  /* element header */
2144 Buffer  *mBuf                /* message buffer */
2145 )
2146 {
2147  
2148    /* Present */
2149    CMCHKUNPK(oduUnpackBool, &m->pres , mBuf);
2150
2151 #if (LCAMT || ATM_BISUP)
2152    /* Unpack action indicator field */
2153    if (m->pres)
2154    {
2155       CMCHKUNPK(oduPackUInt8, &m->actnInd, mBuf);
2156    }
2157 #endif
2158
2159 #if (LCAMT || ATM_BISUP)
2160       CMCHKUNPK(oduPackUInt16, &m->compInd, mBuf);
2161 #endif /* LCAMT || ATM_BISUP */
2162
2163    return ROK;
2164 } /* end of cmUnpkElmtHdr */
2165
2166 \f
2167 /*
2168 *
2169 *       Fun:   cmUnpkTknUInt8
2170 *
2171 *       Desc:  This function unpacks a token uint8_t
2172 *
2173 *       Ret:   ROK      - ok
2174 *
2175 *       Notes: None
2176 *
2177 *       File:  cm_gen.c
2178 *
2179 */
2180   
2181 S16 cmUnpkTknUInt8
2182 (
2183 TknUInt8 *tknUInt8,               /* token uint8_t */
2184 Buffer *mBuf                /* message buffer */
2185 )
2186 {
2187
2188    /* Token Header */
2189    CMCHKUNPK(oduPackUInt8, &tknUInt8->pres, mBuf);
2190
2191    if (tknUInt8->pres)
2192    {
2193       /* Value */
2194       CMCHKUNPK(oduPackUInt8, &tknUInt8->val, mBuf);
2195    }
2196
2197    return ROK;
2198 } /* end of cmUnpkTknUInt8 */
2199
2200 \f
2201 /*
2202 *
2203 *       Fun:   cmUnpkTknS8
2204 *
2205 *       Desc:  This function unpacks a token S8
2206 *
2207 *       Ret:   ROK      - ok
2208 *
2209 *       Notes: None
2210 *
2211 *       File:  cm_gen.c
2212 *
2213 */
2214   
2215 S16 cmUnpkTknS8
2216 (
2217 TknS8 *tknS8,               /* token S8 */
2218 Buffer *mBuf                /* message buffer */
2219 )
2220 {
2221  
2222    /* Token Header */
2223    CMCHKUNPK(oduPackUInt8, &tknS8->pres, mBuf);
2224  
2225    if (tknS8->pres)
2226    {
2227       /* Value */
2228       CMCHKUNPK(SUnpkS8, &tknS8->val, mBuf);
2229    }
2230  
2231    return ROK;
2232 } /* end of cmUnpkTknS8 */
2233
2234 \f
2235 /*
2236 *
2237 *       Fun:   cmUnpkTknUInt16
2238 *
2239 *       Desc:  This function unpacks a token uint16_t
2240 *
2241 *       Ret:   ROK      - ok
2242 *
2243 *       Notes: None
2244 *
2245 *       File:  cm_gen.c
2246 *
2247 */
2248   
2249 S16 cmUnpkTknUInt16
2250 (
2251 TknUInt16 *tknUInt16,             /* token uint16_t */
2252 Buffer *mBuf                /* message buffer */
2253 )
2254 {
2255
2256    /* Token Header */
2257    CMCHKUNPK(oduPackUInt8, &tknUInt16->pres, mBuf);
2258
2259    if (tknUInt16->pres)
2260    {
2261       /* Value */
2262       CMCHKUNPK(oduPackUInt16, &tknUInt16->val, mBuf);
2263    }
2264
2265    return ROK;
2266 } /* end of cmUnpkTknUInt16 */
2267
2268 \f
2269 /*
2270 *
2271 *       Fun:   cmUnpkTknUInt32
2272 *
2273 *       Desc:  This function unpacks a token uint32_t
2274 *
2275 *       Ret:   ROK      - ok
2276 *
2277 *       Notes: None
2278 *
2279 *       File:  cm_gen.c
2280 *
2281 */
2282   
2283 S16 cmUnpkTknUInt32
2284 (
2285 TknUInt32 *tknUInt32,             /* token uint32_t */
2286 Buffer *mBuf                /* message buffer */
2287 )
2288 {
2289
2290    /* Token Header */
2291    CMCHKUNPK(oduPackUInt8, &tknUInt32->pres, mBuf);
2292
2293    if (tknUInt32->pres)
2294    {
2295       /* Value */
2296       CMCHKUNPK(oduPackUInt32, &tknUInt32->val, mBuf);
2297    }
2298
2299    return ROK;
2300 } /* end of cmUnpkTknUInt32 */
2301
2302 /*
2303 *
2304 *       Fun:   cmUnpkTknStr
2305 *
2306 *       Desc:  This function unpacks a token string - regular size
2307 *
2308 *       Ret:   ROK      - ok
2309 *
2310 *       Notes: None
2311 *
2312 *       File:  cm_gen.c
2313 *
2314 */
2315   
2316 S16 cmUnpkTknStr
2317 (
2318 TknStr *tknStr,             /* token string */
2319 Buffer *mBuf                /* message buffer */
2320 )
2321 {
2322    Cntr i;                     /* counter */
2323
2324
2325    /* Token Header */
2326    CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
2327
2328    if (tknStr->pres)
2329    {
2330       /* Length */
2331       CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);
2332
2333       /* Value */
2334       for (i = (tknStr->len - 1); i >= 0; i--)
2335       {
2336          CMCHKUNPK(oduPackUInt8, &tknStr->val[i], mBuf);
2337       }
2338    }
2339    else
2340       tknStr->len = 0;
2341
2342    return ROK;
2343 } /* end of cmUnpkTknStr */
2344
2345 /*
2346 *
2347 *       Fun:   cmUnpkTknStrM
2348 *
2349 *       Desc:  This function unpacks a token string - medium size
2350 *
2351 *       Ret:   ROK      - ok
2352 *
2353 *       Notes: None
2354 *
2355 *       File:  cm_gen.c
2356 *
2357 */
2358   
2359 S16 cmUnpkTknStrM
2360 (
2361 TknStrM *tknStr,             /* token string */
2362 Buffer *mBuf                /* message buffer */
2363 )
2364 {
2365    Cntr i;                     /* counter */
2366
2367
2368    /* Token Header */
2369    CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
2370
2371    if (tknStr->pres)
2372    {
2373       /* Length */
2374       CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);
2375
2376       /* Value */
2377       for (i = (tknStr->len - 1); i >= 0; i--)
2378       {
2379          CMCHKUNPK(oduPackUInt8, &tknStr->val[i], mBuf);
2380       }
2381    }
2382    else
2383       tknStr->len = 0;
2384
2385    return ROK;
2386 } /* end of cmUnpkTknStrM */
2387
2388 \f
2389 /*
2390 *
2391 *       Fun:   cmUnpkTknStrS
2392 *
2393 *       Desc:  This function unpacks a token string - small size
2394 *
2395 *       Ret:   ROK      - ok
2396 *
2397 *       Notes: None
2398 *
2399 *       File:  cm_gen.c
2400 *
2401 */
2402   
2403 S16 cmUnpkTknStrS
2404 (
2405 TknStrS *tknStr,             /* token string */
2406 Buffer *mBuf                /* message buffer */
2407 )
2408 {
2409    Cntr i;                     /* counter */
2410
2411
2412    /* Token Header */
2413    CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
2414
2415    if (tknStr->pres)
2416    {
2417       /* Length */
2418       CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);
2419
2420       /* Value */
2421       for (i = (tknStr->len - 1); i >= 0; i--)
2422       {
2423          CMCHKUNPK(oduPackUInt8, &tknStr->val[i], mBuf);
2424       }
2425    }
2426    else
2427       tknStr->len = 0;
2428
2429    return ROK;
2430 } /* end of cmUnpkTknStrS */
2431
2432 \f
2433 /*
2434 *
2435 *       Fun:   cmUnpkTknStrE
2436 *
2437 *       Desc:  This function unpacks a token string - extended size
2438 *
2439 *       Ret:   ROK      - ok
2440 *
2441 *       Notes: None
2442 *
2443 *       File:  cm_gen.c
2444 *
2445 */
2446   
2447 S16 cmUnpkTknStrE
2448 (
2449 TknStrE *tknStr,             /* token string */
2450 Buffer *mBuf                /* message buffer */
2451 )
2452 {
2453    Cntr i;                     /* counter */
2454
2455
2456    /* Token Header */
2457    CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
2458
2459    if (tknStr->pres)
2460    {
2461       /* Length */
2462       CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);
2463
2464       /* Value */
2465       for (i = (tknStr->len - 1); i >= 0; i--)
2466       {
2467          CMCHKUNPK(oduPackUInt8, &tknStr->val[i], mBuf);
2468       }
2469    }
2470    else
2471       tknStr->len = 0;
2472
2473    return ROK;
2474 } /* end of cmUnpkTknStrE */
2475
2476 #ifndef CMFILE_REORG_1
2477
2478 \f
2479 /*
2480 *
2481 *       Fun:   cmUnpkPnNodeId
2482 *
2483 *       Desc:  This function unpacks a PnNodeId structure from a buffer
2484 *
2485 *       Ret:   Void
2486 *
2487 *       Notes: None
2488 *
2489 *       File:  cm_gen.c
2490 *
2491 */
2492   
2493 S16 cmUnpkPnNodeId
2494 (
2495 PnNodeId  *dst,     /* source PNNI Node Id */
2496 Buffer *mBuf        /* message buffer */
2497 )
2498 {
2499    S16 i;
2500    
2501    
2502    for (i = 0; i < PN_NODEID_LEN; i++)
2503    {
2504       CMCHKUNPK(oduPackUInt8, &dst->id[i], mBuf);
2505    }
2506    
2507    return ROK;
2508 } /* cmUnpkPnNodeId */
2509
2510 #endif /* CMFILE_REORG_1 */
2511
2512 \f
2513 /*
2514  *
2515  *      Fun:   cmUnpkTknStr4
2516  *
2517  *      Desc:  This function packs a token string of size 4
2518  *
2519  *      Ret:   ROK      - ok
2520  *
2521  *      Notes: None
2522  *
2523         File:  cm_gen.c
2524  *
2525  */
2526   
2527 S16 cmUnpkTknStr4
2528 (
2529 TknStr4 *tknStr,             /* token string */
2530 Buffer  *mBuf                /* message buffer */
2531 )
2532 {
2533
2534    CMUNPKTKNSTR(tknStr, mBuf);
2535
2536    return ROK;
2537
2538 } /* end of cmUnpkTknStr4 */
2539
2540
2541 \f
2542 /*
2543  *
2544  *      Fun:   cmUnpkTknStr12
2545  *
2546  *      Desc:  This function packs a token string of size 4
2547  *
2548  *      Ret:   ROK      - ok
2549  *
2550  *      Notes: None
2551  *
2552         File:  cm_gen.c
2553  *
2554  */
2555   
2556 S16 cmUnpkTknStr12
2557 (
2558 TknStr12 *tknStr,             /* token string */
2559 Buffer   *mBuf                /* message buffer */
2560 )
2561 {
2562
2563    CMUNPKTKNSTR(tknStr, mBuf);
2564
2565    return ROK;
2566
2567 } /* end of cmUnpkTknStr12 */
2568
2569 \f
2570 /*
2571  *
2572  *      Fun:   cmUnpkTknStr32
2573  *
2574  *      Desc:  This function packs a token string of size 4
2575  *
2576  *      Ret:   ROK      - ok
2577  *
2578  *      Notes: None
2579  *
2580         File:  cm_gen.c
2581  *
2582  */
2583   
2584 S16 cmUnpkTknStr32
2585 (
2586 TknStr32 *tknStr,             /* token string */
2587 Buffer   *mBuf                /* message buffer */
2588 )
2589 {
2590
2591    CMUNPKTKNSTR(tknStr, mBuf);
2592
2593    return ROK;
2594
2595 } /* end of cmUnpkTknStr32 */
2596
2597 \f
2598 /*
2599  *
2600  *      Fun:   cmUnpkTknStr64
2601  *
2602  *      Desc:  This function packs a token string of size 4
2603  *
2604  *      Ret:   ROK      - ok
2605  *
2606  *      Notes: None
2607  *
2608         File:  cm_gen.c
2609  *
2610  */
2611   
2612 S16 cmUnpkTknStr64
2613 (
2614 TknStr64 *tknStr,             /* token string */
2615 Buffer   *mBuf                /* message buffer */
2616 )
2617 {
2618
2619    CMUNPKTKNSTR(tknStr, mBuf);
2620
2621    return ROK;
2622
2623 } /* end of cmUnpkTknStr64 */
2624
2625 \f
2626 /*
2627  *
2628  *      Fun:   cmUnpkTknStr132
2629  *
2630  *      Desc:  This function packs a token string of size 4
2631  *
2632  *      Ret:   ROK      - ok
2633  *
2634  *      Notes: None
2635  *
2636         File:  cm_gen.c
2637  *
2638  */
2639   
2640 S16 cmUnpkTknStr132
2641 (
2642 TknStr132 *tknStr,             /* token string */
2643 Buffer   *mBuf                /* message buffer */
2644 )
2645 {
2646
2647    CMUNPKTKNSTR(tknStr, mBuf);
2648
2649    return ROK;
2650
2651 } /* end of cmUnpkTknStr132 */
2652
2653 \f
2654 /*
2655  *
2656  *      Fun:   cmUnpkTknStr256
2657  *
2658  *      Desc:  This function packs a token string of size 4
2659  *
2660  *      Ret:   ROK      - ok
2661  *
2662  *      Notes: None
2663  *
2664         File:  cm_gen.c
2665  *
2666  */
2667   
2668 S16 cmUnpkTknStr256
2669 (
2670 TknStr256 *tknStr,             /* token string */
2671 Buffer    *mBuf                /* message buffer */
2672 )
2673 {
2674
2675    CMUNPKTKNSTR(tknStr, mBuf);
2676
2677    return ROK;
2678
2679 } /* end of cmUnpkTknStr256 */
2680
2681 \f
2682 /*
2683  *
2684  *      Fun:   cmUnpkTknOid
2685  *
2686  *      Desc:  This function packs a Object Identifier token
2687  *
2688  *      Ret:   ROK      - ok
2689  *
2690  *      Notes: None
2691  *
2692         File:  cm_gen.c
2693  *
2694  */
2695   
2696 S16 cmUnpkTknOid
2697 (
2698 TknOid   *tknOid,             /* Object Identifier token */
2699 Buffer   *mBuf                /* message buffer */
2700 )
2701 {
2702    uint16_t    i;
2703
2704  
2705    /* Unpack the token header */
2706    CMCHKUNPK(oduPackUInt8, &tknOid->pres, mBuf);
2707
2708    if (tknOid->pres == TRUE)
2709    {
2710       /* Unpack the length */
2711       CMCHKUNPK(oduPackUInt8, &tknOid->len, mBuf);
2712
2713       /* Pack the value */
2714       for (i = 1; i <= (uint16_t)tknOid->len; i++)
2715       {
2716          /* cm_gen_c_001.main_33: changes for TknOid value from uint16_t to uint32_t
2717           * with compilation flag TKNOID_UINT16 */
2718 #ifndef TKNOID_UINT16
2719          CMCHKUNPK(oduPackUInt32, &tknOid->val[tknOid->len - i], mBuf);
2720 #else
2721          CMCHKUNPK(oduPackUInt16, &tknOid->val[tknOid->len - i], mBuf);
2722 #endif /* !TKNOID_UINT16 */
2723       }
2724    }
2725
2726    return ROK;
2727 } /* end of cmUnpkTknOid */
2728
2729 \f
2730 /*
2731 *
2732 *       Fun:   cmUnpkTknS32
2733 *
2734 *       Desc:  This function unpacks a token S32
2735 *
2736 *       Ret:   ROK      - ok
2737 *
2738 *       Notes: None
2739 *
2740 *       File:  cm_gen.c
2741 *
2742 */
2743   
2744 S16 cmUnpkTknS32
2745 (
2746 TknS32 *tknS32,             /* token S32 */
2747 Buffer *mBuf                /* message buffer */
2748 )
2749 {
2750
2751    /* Token Header */
2752    CMCHKUNPK(oduPackUInt8, &tknS32->pres, mBuf);
2753
2754    if (tknS32->pres)
2755    {
2756       /* Value */
2757       CMCHKUNPK(SUnpkS32, &tknS32->val, mBuf);
2758    }
2759
2760    return ROK;
2761 } /* end of cmUnpkTknS32 */
2762
2763 \f
2764 /*
2765 *
2766 *       Fun:   cmUnpkHeader
2767 *
2768 *       Desc:  This function is used to Unpack Header structure
2769 *
2770 *       Ret:   ROK      - ok
2771 *
2772 *       Notes: None.
2773 *
2774 *       File:  cm_gen.c
2775 *
2776 */
2777   
2778 S16 cmUnpkHeader
2779 (
2780 Header *header,   /* header structure */
2781 Buffer *mBuf      /* message buffer */
2782 )
2783 {
2784
2785    CMCHKUNPK(oduPackUInt16, &header->msgLen, mBuf); 
2786    CMCHKUNPK(oduPackUInt8, &header->msgType, mBuf); 
2787    CMCHKUNPK(oduPackUInt8, &header->version, mBuf); 
2788    CMCHKUNPK(oduPackUInt16, &header->seqNmb, mBuf); 
2789    CMCHKUNPK(cmUnpkEntityId, &header->entId, mBuf);    
2790    CMCHKUNPK(cmUnpkElmntId, &header->elmId, mBuf);
2791 #ifdef LMINT3
2792    CMCHKUNPK(cmUnpkTranId, &header->transId, mBuf);
2793    CMCHKUNPK(cmUnpkSelector, &header->response.selector, mBuf);
2794    CMCHKUNPK(cmUnpkPriority, &header->response.prior, mBuf);
2795    CMCHKUNPK(cmUnpkRoute, &header->response.route, mBuf);
2796    CMCHKUNPK(cmUnpkMemoryId, &header->response.mem, mBuf);
2797 #endif /* LMINT3 */
2798
2799    return ROK;
2800 } /* end of cmUnpkHeader */
2801
2802 \f
2803 /*
2804 *
2805 *       Fun:   cmUnpkCmStatus
2806 *
2807 *       Desc:  This function unpacks common management status structure
2808 *
2809 *       Ret:   ROK      - ok
2810 *
2811 *       Notes: None.
2812 *
2813 *       File:  cm_gen.c
2814 *
2815 */
2816   
2817 S16 cmUnpkCmStatus
2818 (
2819 CmStatus *sta,              /* status structure */
2820 Buffer *mBuf                /* message buffer */
2821 )
2822 {
2823
2824    CMCHKUNPK(oduPackUInt16, &sta->status, mBuf);
2825    CMCHKUNPK(oduPackUInt16, &sta->reason, mBuf);
2826
2827    return ROK;
2828 } /* end of cmUnpkCmStatus */
2829
2830 \f
2831 /*
2832 *
2833 *       Fun:   cmUnpkCmAlarm
2834 *
2835 *       Desc:  This function unpacks common management alarm structure
2836 *
2837 *       Ret:   ROK      - ok
2838 *
2839 *       Notes: None.
2840 *
2841 *       File:  cm_gen.c
2842 *
2843 */
2844   
2845 S16 cmUnpkCmAlarm
2846 (
2847 CmAlarm *alarm,             /* alarm structure */
2848 Buffer *mBuf                /* message buffer */
2849 )
2850 {
2851
2852    CMCHKUNPK(cmUnpkDateTime, &alarm->dt, mBuf);
2853    CMCHKUNPK(oduPackUInt16, &alarm->category, mBuf);
2854    CMCHKUNPK(oduPackUInt16, &alarm->event, mBuf);
2855    CMCHKUNPK(oduPackUInt16, &alarm->cause, mBuf);
2856
2857    return ROK;
2858 } /* end of cmUnpkCmAlarm */
2859
2860 \f
2861 /*
2862 *
2863 *       Fun:   cmUnpkSmCfg
2864 *
2865 *       Desc:  This function unpacks the stack manager structure
2866 *
2867 *       Ret:   ROK      - ok
2868 *
2869 *       Notes: None.
2870 *
2871 *       File:  cm_gen.c
2872 *
2873 */
2874   
2875 S16 cmUnpkSmCfg
2876 (
2877 SmCfg *smCfg,           /* stack manager */
2878 Buffer *mBuf            /* message buffer */
2879 )
2880 {
2881
2882    CMCHKUNPK(cmUnpkEnt, &smCfg->ent, mBuf); 
2883    CMCHKUNPK(cmUnpkInst, &smCfg->inst, mBuf); 
2884    CMCHKUNPK(cmUnpkRegion, &smCfg->region, mBuf); 
2885    CMCHKUNPK(cmUnpkPool, &smCfg->pool, mBuf); 
2886    CMCHKUNPK(cmUnpkPrior, &smCfg->prior, mBuf); 
2887    CMCHKUNPK(cmUnpkRoute, &smCfg->route, mBuf); 
2888    CMCHKUNPK(cmUnpkSelector, &smCfg->selector, mBuf);
2889
2890    return ROK;
2891 } /* end of cmUnpkSmCfg */
2892
2893 \f
2894 /*
2895 *
2896 *       Fun:   cmUnpkTmrCfg
2897 *
2898 *       Desc:  This function unpacks the timer configuration structure
2899 *
2900 *       Ret:   ROK      - ok
2901 *
2902 *       Notes: None.
2903 *
2904 *       File:  cm_gen.c
2905 *
2906 */
2907   
2908 S16 cmUnpkTmrCfg
2909 (
2910 TmrCfg *tmrCfg,         /* timer configuration */
2911 Buffer *mBuf            /* message buffer */
2912 )
2913 {
2914
2915    CMCHKUNPK(oduUnpackBool, &tmrCfg->enb, mBuf); 
2916    CMCHKUNPK(oduPackUInt16, &tmrCfg->val, mBuf);
2917
2918    return ROK;
2919 } /* end of cmUnpkTmrCfg */
2920
2921 /*
2922  *
2923  *      Fun:   cmUnpkTknBuf
2924  *
2925  *      Desc:  This function unpacks a token buffer
2926  *
2927  *      Ret:   ROK      - ok
2928  *
2929  *      Notes: None
2930  *
2931         File:  cm_gen.c
2932  *
2933  */
2934
2935 S16 cmUnpkTknBuf
2936 (
2937 TknBuf *tknBuf,                /* token string */
2938 Buffer    **tBuf                /* message buffer */
2939 )
2940 {
2941    Buffer *mBuf;
2942
2943
2944
2945    mBuf = *tBuf;
2946   
2947    /* Token Header */
2948    CMCHKUNPK(oduPackUInt8, &tknBuf->pres, mBuf);
2949
2950    if(tknBuf->pres)
2951    {
2952       MsgLen msgLen, buflen;
2953       Region region;                 /* region */
2954       Pool   pool;                   /* pool */
2955
2956       cmUnpkMsgLen(&msgLen, mBuf);
2957       SFndLenMsg(mBuf, &buflen);
2958       if (buflen > msgLen)
2959       {
2960          if( SSegMsg(mBuf, msgLen, &tknBuf->val) != ROK )
2961          {
2962             return RFAILED;
2963          }
2964       }
2965       else
2966       {
2967           /* Allocate the buffer for tknbuf->val */
2968           SGetBufRegionPool(mBuf, &region, &pool);
2969           SGetMsg(region, pool, &(tknBuf->val));
2970       }
2971       
2972      /* now Swap the two Buffer pointers */
2973       SSwapMsg(mBuf,tknBuf->val);
2974       
2975    }
2976
2977    *tBuf = mBuf;
2978
2979    return ROK;
2980 } /* end of cmUnpkTknBuf */
2981
2982 #ifdef TDS_ROLL_UPGRADE_SUPPORT
2983 /*
2984 *
2985 *       Fun:   cmUnpkIntf
2986 *
2987 *       Desc:  This function unpacks the interface information
2988 *
2989 *       Ret:   ROK      - ok
2990 *
2991 *       Notes: None.
2992 *
2993 *       File:  cm_gen.c
2994 *
2995 */
2996   
2997 S16 cmUnpkIntf
2998 (
2999 CmIntf *intf,           /* interface info */
3000 Buffer *mBuf            /* message buffer */
3001 )
3002 {
3003
3004    CMCHKUNPK(cmUnpkIntfVer, &intf->intfVer, mBuf); 
3005    CMCHKUNPK(cmUnpkIntfId,  &intf->intfId,  mBuf); 
3006
3007    return ROK;
3008 } /* end of cmUnpkIntf */
3009 #endif /* TDS_ROLL_UPGRADE_SUPPORT */
3010
3011 /*
3012 *
3013 *       Fun:   getTransId
3014 *
3015 *       Desc:  This function return the transaction ID used for interface transactions 
3016 *
3017 *       Ret: gTransId
3018 *
3019 *       File:  cm_gen.c
3020 *
3021 */
3022 uint16_t getTransId()
3023 {
3024    gTransId = (gTransId%65535) + 1;
3025    return gTransId; 
3026 }
3027 /**********************************************************************
3028          End of file
3029 **********************************************************************/