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
71 TknS16 *tknS16, /* token S16 */
72 Buffer *mBuf /* message buffer */
79 CMCHKPK(SPkS16, tknS16->val, mBuf);
83 CMCHKPK(oduUnpackUInt8, tknS16->pres, mBuf);
86 } /* end of cmPkTknS16 */
93 * Desc: This function packs a token bit string of size 32
105 TknBStr32 *tknStr, /* token string */
106 Buffer *mBuf /* message buffer */
110 CMPKTKNBSTR(tknStr, mBuf);
114 } /* end of cmPkTknBStr32 */
120 * Desc: This function packs a token string of size 8
132 TknStr8 *tknStr, /* token string */
133 Buffer *mBuf /* message buffer */
137 CMPKTKNSTR(tknStr, mBuf);
141 } /* end of cmPkTknStr8 */
148 * Desc: This function packs a token string of size 16
160 TknStr16 *tknStr, /* token string */
161 Buffer *mBuf /* message buffer */
165 CMPKTKNSTR(tknStr, mBuf);
169 } /* end of cmPkTknStr16 */
174 * Fun: cmPkTknStrOSXL
176 * Desc: This function packs a Long Octet string
188 TknStrOSXL *tknStr, /* token string */
189 Buffer *mBuf /* message buffer */
198 for (ndx = 0; ndx < tknStr->len; ndx++)
200 CMCHKPK(oduUnpackUInt8, tknStr->val[ndx], mBuf);
203 CMCHKPK(oduUnpackUInt16, tknStr->len, mBuf);
206 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
210 } /* end of cmPkTknStrOSXL */
216 * Fun: cmPkTknStrBSXL
218 * Desc: This function packs a Long bit string
230 TknStrBSXL *tknStr, /* token string */
231 Buffer *mBuf /* message buffer */
241 len = (tknStr->len/8) + 1;
243 len = (tknStr->len/8);
246 for (ndx = 0; ndx < len; ndx++)
248 CMCHKPK(oduUnpackUInt8, tknStr->val[ndx], mBuf);
251 CMCHKPK(oduUnpackUInt16, tknStr->len, mBuf);
254 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
258 } /* end of cmPkTknStrBSXL */
263 * Fun: cmPkTknStrBMP4
265 * Desc: This function packs a BMP token string of size 4
277 TknStrBMP4 *tknStr, /* token string */
278 Buffer *mBuf /* message buffer */
287 for (ndx = 0; ndx < tknStr->len; ndx++)
289 CMCHKPK(oduUnpackUInt16, tknStr->val[ndx], mBuf);
293 CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);
297 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
300 } /* end of cmPkTknStrBMP4 */
305 * Fun: cmPkTknStrBMPXL
307 * Desc: This function packs a Long BMP Octet string
319 TknStrBMPXL *tknStr, /* token string */
320 Buffer *mBuf /* message buffer */
329 for (ndx = 0; ndx < tknStr->len; ndx++)
331 CMCHKPK(oduUnpackUInt16, tknStr->val[ndx], mBuf);
334 CMCHKPK(oduUnpackUInt16, tknStr->len, mBuf);
337 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
340 } /* end of cmPkTknStrBMPXL */
345 * Fun: cmPkTknStrUNI4
347 * Desc: This function packs a UNI token string of size 4
359 TknStrUNI4 *tknStr, /* token string */
360 Buffer *mBuf /* message buffer */
369 for (ndx = 0; ndx < tknStr->len; ndx++)
371 CMCHKPK(oduUnpackUInt32, tknStr->val[ndx], mBuf);
375 CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);
379 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
382 } /* end of cmPkTknStrUNI4 */
387 * Fun: cmPkTknStrUNIXL
389 * Desc: This function packs a Long UNI Octet string
401 TknStrUNIXL *tknStr, /* token string */
402 Buffer *mBuf /* message buffer */
411 for (ndx = 0; ndx < tknStr->len; ndx++)
413 CMCHKPK(oduUnpackUInt32, tknStr->val[ndx], mBuf);
416 CMCHKPK(oduUnpackUInt16, tknStr->len, mBuf);
419 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);
422 } /* end of cmPkTknStrUNIXL */
425 * UNPACKING FUNCTIONS
433 * Desc: This function unpacks a token S16
444 TknS16 *tknS16, /* token S16 */
445 Buffer *mBuf /* message buffer */
450 CMCHKUNPK(oduPackUInt8, &tknS16->pres, mBuf);
455 CMCHKUNPK(SUnpkS16, &tknS16->val, mBuf);
459 } /* end of cmUnpkTknS16 */
464 * Fun: cmUnpkTknBStr32
466 * Desc: This function packs a token bit string of size 32
478 TknBStr32 *tknStr, /* token string */
479 Buffer *mBuf /* message buffer */
483 CMUNPKTKNBSTR(tknStr, mBuf);
487 } /* end of cmUnpkTknBStr32 */
494 * Desc: This function packs a token string of size 8
506 TknStr8 *tknStr, /* token string */
507 Buffer *mBuf /* message buffer */
511 CMUNPKTKNSTR(tknStr, mBuf);
515 } /* end of cmUnpkTknStr8 */
520 * Fun: cmUnpkTknStr16
522 * Desc: This function packs a token string of size 16
534 TknStr16 *tknStr, /* token string */
535 Buffer *mBuf /* message buffer */
539 CMUNPKTKNSTR(tknStr, mBuf);
543 } /* end of cmUnpkTknStr16 */
548 * Fun: cmUnpkTknStrOSXL
550 * Desc: This function packs a long octet token string
562 TknStrOSXL *tknStr, /* token string */
563 Buffer *mBuf, /* message buffer */
564 Ptr ptr /* pointer to memory control block */
569 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
574 CMCHKUNPK(oduPackUInt16, &tknStr->len, mBuf);
576 if( cmGetMem(ptr, tknStr->len, (Ptr *)&tknStr->val) != ROK)
581 for (ndx = 1; ndx <= tknStr->len; ndx++)
583 CMCHKUNPK(oduPackUInt8, &tknStr->val[tknStr->len - ndx], mBuf);
589 } /* end of cmUnpkTknStrOSXL */
595 * Fun: cmUnpkTknStrBSXL
597 * Desc: This function packs a long bit token string
609 TknStrBSXL *tknStr, /* token string */
610 Ptr ptr, /* pointer to memory control block */
611 Buffer *mBuf /* message buffer */
618 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
623 CMCHKUNPK(oduPackUInt16, &tknStr->len, mBuf);
626 len = (tknStr->len/8) + 1;
628 len = (tknStr->len/8);
630 if( cmGetMem(ptr, len, (Ptr *)&tknStr->val) != ROK)
635 for (ndx = 1; ndx <= len; ndx++)
637 CMCHKUNPK(oduPackUInt8, &tknStr->val[len - ndx], mBuf);
643 } /* end of cmUnpkTknStrBSXL */
648 * Fun: cmUnpkTknStrBMP4
650 * Desc: This function unpacks a BMP token string of size 4
662 TknStrBMP4 *tknStr, /* token string */
663 Buffer *mBuf /* message buffer */
670 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
675 CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);
678 for (ndx = 1; ndx <= tknStr->len; ndx++)
680 CMCHKUNPK(oduPackUInt16, &tknStr->val[tknStr->len - ndx], mBuf);
685 } /* end of cmUnpkTknStrBMP4 */
690 * Fun: cmUnpkTknStrBMPXL
692 * Desc: This function packs a long octet token string
702 S16 cmUnpkTknStrBMPXL
704 TknStrBMPXL *tknStr, /* token string */
705 Buffer *mBuf, /* message buffer */
706 Ptr ptr /* pointer to memory control block */
712 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
717 CMCHKUNPK(oduPackUInt16, &tknStr->len, mBuf);
719 /* Each BMP Character is 2 octet long */
720 if( cmGetMem(ptr, 2*(tknStr->len), (Ptr *)&tknStr->val) != ROK)
725 for (ndx = 1; ndx <= tknStr->len; ndx++)
727 CMCHKUNPK(oduPackUInt16, &tknStr->val[tknStr->len - ndx], mBuf);
733 } /* end of cmUnpkTknStrBMPXL */
738 * Fun: cmUnpkTknStrUNI4
740 * Desc: This function unpacks a UNI token string of size 4
752 TknStrUNI4 *tknStr, /* token string */
753 Buffer *mBuf /* message buffer */
760 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
765 CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);
768 for (ndx = 1; ndx <= tknStr->len; ndx++)
770 CMCHKUNPK(oduPackUInt32, &tknStr->val[tknStr->len - ndx], mBuf);
775 } /* end of cmUnpkTknStrUNI4 */
780 * Fun: cmUnpkTknStrUNIXL
782 * Desc: This function packs a long octet token string
792 S16 cmUnpkTknStrUNIXL
794 TknStrUNIXL *tknStr, /* token string */
795 Buffer *mBuf, /* message buffer */
796 Ptr ptr /* pointer to memory control block */
802 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);
807 CMCHKUNPK(oduPackUInt16, &tknStr->len, mBuf);
809 /* Each UNI Character is 4 octets long */
810 if( cmGetMem(ptr, 4*tknStr->len, (Ptr *)&tknStr->val) != ROK)
815 for (ndx = 1; ndx <= tknStr->len; ndx++)
817 CMCHKUNPK(oduPackUInt32, &tknStr->val[tknStr->len - ndx], mBuf);
823 } /* end of cmUnpkTknStrUNIXL */
825 /**********************************************************************
827 **********************************************************************/