1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /********************************************************************20**
25 Desc: Packing/Unpacking for structures, defined in cm_tkns.x
29 *********************************************************************21*/
31 /* header include files (.h) */
33 #include "envopt.h" /* environment options */
34 #include "envdep.h" /* environment dependent */
35 #include "envind.h" /* environment independent */
37 #include "gen.h" /* general layer */
38 #include "ssi.h" /* system services */
40 #include "cm_tkns.h" /* common tokens */
42 /* header/extern include files (.x) */
44 #include "gen.x" /* general layer */
45 #include "ssi.x" /* system services */
47 #include "cm_tkns.x" /* common tokens */
60 * Desc: This function unpacks a token S16
72 TknS16 *tknS16, /* token S16 */
73 Buffer *mBuf /* message buffer */
76 S16 cmPkTknS16(tknS16, mBuf)
77 TknS16 *tknS16; /* token S16 */
78 Buffer *mBuf; /* message buffer */
85 CMCHKPK(SPkS16, tknS16->val, mBuf);
89 CMCHKPK(oduUnpackUInt8, tknS16->pres, mBuf);
92 } /* end of cmPkTknS16 */
99 * Desc: This function packs a token bit string of size 32
112 TknBStr32 *tknStr, /* token string */
113 Buffer *mBuf /* message buffer */
116 S16 cmPkTknBStr32(tknStr, mBuf)
117 TknBStr32 *tknStr; /* token string */
118 Buffer *mBuf; /* message buffer */
122 CMPKTKNBSTR(tknStr, mBuf);
126 } /* end of cmPkTknBStr32 */
132 * Desc: This function packs a token string of size 8
145 TknStr8 *tknStr, /* token string */
146 Buffer *mBuf /* message buffer */
149 S16 cmPkTknStr8(tknStr, mBuf)
150 TknStr8 *tknStr; /* token string */
151 Buffer *mBuf; /* message buffer */
155 CMPKTKNSTR(tknStr, mBuf);
159 } /* end of cmPkTknStr8 */
166 * Desc: This function packs a token string of size 16
179 TknStr16 *tknStr, /* token string */
180 Buffer *mBuf /* message buffer */
183 S16 cmPkTknStr16(tknStr, mBuf)
184 TknStr16 *tknStr; /* token string */
185 Buffer *mBuf; /* message buffer */
189 CMPKTKNSTR(tknStr, mBuf);
193 } /* end of cmPkTknStr16 */
198 * Fun: cmPkTknStrOSXL
200 * Desc: This function packs a Long Octet string
213 TknStrOSXL *tknStr, /* token string */
214 Buffer *mBuf /* message buffer */
217 S16 cmPkTknStrOSXL(tknStr, mBuf)
218 TknStrOSXL *tknStr; /* token string */
219 Buffer *mBuf; /* message buffer */
228 for (ndx = 0; ndx < tknStr->len; ndx++)
230 CMCHKPK(oduUnpackUInt8, tknStr->val[ndx], mBuf);
233 CMCHKPK(oduUnpackUInt16, tknStr->len, mBuf);
236 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
240 } /* end of cmPkTknStrOSXL */
246 * Fun: cmPkTknStrBSXL
248 * Desc: This function packs a Long bit string
261 TknStrBSXL *tknStr, /* token string */
262 Buffer *mBuf /* message buffer */
265 S16 cmPkTknStrBSXL(tknStr, mBuf)
266 TknStrBSXL *tknStr; /* token string */
267 Buffer *mBuf; /* message buffer */
277 len = (tknStr->len/8) + 1;
279 len = (tknStr->len/8);
282 for (ndx = 0; ndx < len; ndx++)
284 CMCHKPK(oduUnpackUInt8, tknStr->val[ndx], mBuf);
287 CMCHKPK(oduUnpackUInt16, tknStr->len, mBuf);
290 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
294 } /* end of cmPkTknStrBSXL */
299 * Fun: cmPkTknStrBMP4
301 * Desc: This function packs a BMP token string of size 4
314 TknStrBMP4 *tknStr, /* token string */
315 Buffer *mBuf /* message buffer */
318 S16 cmPkTknStrBMP4(tknStr, mBuf)
319 TknStrBMP4 *tknStr; /* token string */
320 Buffer *mBuf; /* message buffer */
329 for (ndx = 0; ndx < tknStr->len; ndx++)
331 CMCHKPK(oduUnpackUInt16, tknStr->val[ndx], mBuf);
335 CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);
339 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
342 } /* end of cmPkTknStrBMP4 */
347 * Fun: cmPkTknStrBMPXL
349 * Desc: This function packs a Long BMP Octet string
362 TknStrBMPXL *tknStr, /* token string */
363 Buffer *mBuf /* message buffer */
366 S16 cmPkTknStrBMPXL(tknStr, mBuf)
367 TknStrBMPXL *tknStr; /* token string */
368 Buffer *mBuf; /* message buffer */
377 for (ndx = 0; ndx < tknStr->len; ndx++)
379 CMCHKPK(oduUnpackUInt16, tknStr->val[ndx], mBuf);
382 CMCHKPK(oduUnpackUInt16, tknStr->len, mBuf);
385 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
388 } /* end of cmPkTknStrBMPXL */
393 * Fun: cmPkTknStrUNI4
395 * Desc: This function packs a UNI token string of size 4
408 TknStrUNI4 *tknStr, /* token string */
409 Buffer *mBuf /* message buffer */
412 S16 cmPkTknStrUNI4(tknStr, mBuf)
413 TknStrUNI4 *tknStr; /* token string */
414 Buffer *mBuf; /* message buffer */
423 for (ndx = 0; ndx < tknStr->len; ndx++)
425 CMCHKPK(oduUnpackUInt32, tknStr->val[ndx], mBuf);
429 CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);
433 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
436 } /* end of cmPkTknStrUNI4 */
441 * Fun: cmPkTknStrUNIXL
443 * Desc: This function packs a Long UNI Octet string
456 TknStrUNIXL *tknStr, /* token string */
457 Buffer *mBuf /* message buffer */
460 S16 cmPkTknStrUNIXL(tknStr, mBuf)
461 TknStrUNIXL *tknStr; /* token string */
462 Buffer *mBuf; /* message buffer */
471 for (ndx = 0; ndx < tknStr->len; ndx++)
473 CMCHKPK(oduUnpackUInt32, tknStr->val[ndx], mBuf);
476 CMCHKPK(oduUnpackUInt16, tknStr->len, mBuf);
479 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
482 } /* end of cmPkTknStrUNIXL */
485 * UNPACKING FUNCTIONS
493 * Desc: This function unpacks a token S16
505 TknS16 *tknS16, /* token S16 */
506 Buffer *mBuf /* message buffer */
509 S16 cmUnpkTknS16(tknS16, mBuf)
510 TknS16 *tknS16; /* token S16 */
511 Buffer *mBuf; /* message buffer */
516 CMCHKUNPK(oduPackUInt8, &tknS16->pres, mBuf);
521 CMCHKUNPK(SUnpkS16, &tknS16->val, mBuf);
525 } /* end of cmUnpkTknS16 */
530 * Fun: cmUnpkTknBStr32
532 * Desc: This function packs a token bit string of size 32
545 TknBStr32 *tknStr, /* token string */
546 Buffer *mBuf /* message buffer */
549 S16 cmUnpkTknBStr32(tknStr, mBuf)
550 TknBStr32 *tknStr; /* token string */
551 Buffer *mBuf; /* message buffer */
555 CMUNPKTKNBSTR(tknStr, mBuf);
559 } /* end of cmUnpkTknBStr32 */
566 * Desc: This function packs a token string of size 8
579 TknStr8 *tknStr, /* token string */
580 Buffer *mBuf /* message buffer */
583 S16 cmUnpkTknStr8(tknStr, mBuf)
584 TknStr8 *tknStr; /* token string */
585 Buffer *mBuf; /* message buffer */
589 CMUNPKTKNSTR(tknStr, mBuf);
593 } /* end of cmUnpkTknStr8 */
598 * Fun: cmUnpkTknStr16
600 * Desc: This function packs a token string of size 16
613 TknStr16 *tknStr, /* token string */
614 Buffer *mBuf /* message buffer */
617 S16 cmUnpkTknStr16(tknStr, mBuf)
618 TknStr16 *tknStr; /* token string */
619 Buffer *mBuf; /* message buffer */
623 CMUNPKTKNSTR(tknStr, mBuf);
627 } /* end of cmUnpkTknStr16 */
632 * Fun: cmUnpkTknStrOSXL
634 * Desc: This function packs a long octet token string
647 TknStrOSXL *tknStr, /* token string */
648 Buffer *mBuf, /* message buffer */
649 Ptr ptr /* pointer to memory control block */
652 S16 cmUnpkTknStrOSXL(tknStr, mBuf, ptr)
653 TknStrOSXL *tknStr; /* token string */
654 Buffer *mBuf; /* message buffer */
655 Ptr ptr; /* pointer to control memory block */
660 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
665 CMCHKUNPK(oduPackUInt16, &tknStr->len, mBuf);
667 if( cmGetMem(ptr, tknStr->len, (Ptr *)&tknStr->val) != ROK)
672 for (ndx = 1; ndx <= tknStr->len; ndx++)
674 CMCHKUNPK(oduPackUInt8, &tknStr->val[tknStr->len - ndx], mBuf);
680 } /* end of cmUnpkTknStrOSXL */
686 * Fun: cmUnpkTknStrBSXL
688 * Desc: This function packs a long bit token string
701 TknStrBSXL *tknStr, /* token string */
702 Ptr ptr, /* pointer to memory control block */
703 Buffer *mBuf /* message buffer */
706 S16 cmUnpkTknStrBSXL(tknStr, ptr, mBuf)
707 TknStrBSXL *tknStr; /* token string */
708 Ptr ptr; /* pointer to control memory block */
709 Buffer *mBuf; /* message buffer */
716 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
721 CMCHKUNPK(oduPackUInt16, &tknStr->len, mBuf);
724 len = (tknStr->len/8) + 1;
726 len = (tknStr->len/8);
728 if( cmGetMem(ptr, len, (Ptr *)&tknStr->val) != ROK)
733 for (ndx = 1; ndx <= len; ndx++)
735 CMCHKUNPK(oduPackUInt8, &tknStr->val[len - ndx], mBuf);
741 } /* end of cmUnpkTknStrBSXL */
746 * Fun: cmUnpkTknStrBMP4
748 * Desc: This function unpacks a BMP token string of size 4
761 TknStrBMP4 *tknStr, /* token string */
762 Buffer *mBuf /* message buffer */
765 S16 cmUnpkTknStrBMP4(tknStr, mBuf)
766 TknStrBMP4 *tknStr; /* token string */
767 Buffer *mBuf; /* message buffer */
774 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
779 CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);
782 for (ndx = 1; ndx <= tknStr->len; ndx++)
784 CMCHKUNPK(oduPackUInt16, &tknStr->val[tknStr->len - ndx], mBuf);
789 } /* end of cmUnpkTknStrBMP4 */
794 * Fun: cmUnpkTknStrBMPXL
796 * Desc: This function packs a long octet token string
807 S16 cmUnpkTknStrBMPXL
809 TknStrBMPXL *tknStr, /* token string */
810 Buffer *mBuf, /* message buffer */
811 Ptr ptr /* pointer to memory control block */
814 S16 cmUnpkTknStrBMPXL(tknStr, mBuf, ptr)
815 TknStrBMPXL *tknStr; /* token string */
816 Buffer *mBuf; /* message buffer */
817 Ptr ptr; /* pointer to control memory block */
823 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
828 CMCHKUNPK(oduPackUInt16, &tknStr->len, mBuf);
830 /* Each BMP Character is 2 octet long */
831 if( cmGetMem(ptr, 2*(tknStr->len), (Ptr *)&tknStr->val) != ROK)
836 for (ndx = 1; ndx <= tknStr->len; ndx++)
838 CMCHKUNPK(oduPackUInt16, &tknStr->val[tknStr->len - ndx], mBuf);
844 } /* end of cmUnpkTknStrBMPXL */
849 * Fun: cmUnpkTknStrUNI4
851 * Desc: This function unpacks a UNI token string of size 4
864 TknStrUNI4 *tknStr, /* token string */
865 Buffer *mBuf /* message buffer */
868 S16 cmUnpkTknStrUNI4(tknStr, mBuf)
869 TknStrUNI4 *tknStr; /* token string */
870 Buffer *mBuf; /* message buffer */
877 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
882 CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);
885 for (ndx = 1; ndx <= tknStr->len; ndx++)
887 CMCHKUNPK(oduPackUInt32, &tknStr->val[tknStr->len - ndx], mBuf);
892 } /* end of cmUnpkTknStrUNI4 */
897 * Fun: cmUnpkTknStrUNIXL
899 * Desc: This function packs a long octet token string
910 S16 cmUnpkTknStrUNIXL
912 TknStrUNIXL *tknStr, /* token string */
913 Buffer *mBuf, /* message buffer */
914 Ptr ptr /* pointer to memory control block */
917 S16 cmUnpkTknStrUNIXL(tknStr, mBuf, ptr)
918 TknStrUNIXL *tknStr; /* token string */
919 Buffer *mBuf; /* message buffer */
920 Ptr ptr; /* pointer to control memory block */
926 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
931 CMCHKUNPK(oduPackUInt16, &tknStr->len, mBuf);
933 /* Each UNI Character is 4 octets long */
934 if( cmGetMem(ptr, 4*tknStr->len, (Ptr *)&tknStr->val) != ROK)
939 for (ndx = 1; ndx <= tknStr->len; ndx++)
941 CMCHKUNPK(oduPackUInt32, &tknStr->val[tknStr->len - ndx], mBuf);
947 } /* end of cmUnpkTknStrUNIXL */
949 /**********************************************************************
951 **********************************************************************/