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 PUBLIC S16 cmPkTknS16(tknS16, mBuf)
77 TknS16 *tknS16; /* token S16 */
78 Buffer *mBuf; /* message buffer */
86 CMCHKPK(SPkS16, tknS16->val, mBuf);
90 CMCHKPK(SPkU8, tknS16->pres, mBuf);
93 } /* end of cmPkTknS16 */
100 * Desc: This function packs a token bit string of size 32
111 PUBLIC S16 cmPkTknBStr32
113 TknBStr32 *tknStr, /* token string */
114 Buffer *mBuf /* message buffer */
117 PUBLIC S16 cmPkTknBStr32(tknStr, mBuf)
118 TknBStr32 *tknStr; /* token string */
119 Buffer *mBuf; /* message buffer */
124 CMPKTKNBSTR(tknStr, mBuf);
128 } /* end of cmPkTknBStr32 */
134 * Desc: This function packs a token string of size 8
145 PUBLIC S16 cmPkTknStr8
147 TknStr8 *tknStr, /* token string */
148 Buffer *mBuf /* message buffer */
151 PUBLIC S16 cmPkTknStr8(tknStr, mBuf)
152 TknStr8 *tknStr; /* token string */
153 Buffer *mBuf; /* message buffer */
158 CMPKTKNSTR(tknStr, mBuf);
162 } /* end of cmPkTknStr8 */
169 * Desc: This function packs a token string of size 16
180 PUBLIC S16 cmPkTknStr16
182 TknStr16 *tknStr, /* token string */
183 Buffer *mBuf /* message buffer */
186 PUBLIC S16 cmPkTknStr16(tknStr, mBuf)
187 TknStr16 *tknStr; /* token string */
188 Buffer *mBuf; /* message buffer */
193 CMPKTKNSTR(tknStr, mBuf);
197 } /* end of cmPkTknStr16 */
202 * Fun: cmPkTknStrOSXL
204 * Desc: This function packs a Long Octet string
215 PUBLIC S16 cmPkTknStrOSXL
217 TknStrOSXL *tknStr, /* token string */
218 Buffer *mBuf /* message buffer */
221 PUBLIC S16 cmPkTknStrOSXL(tknStr, mBuf)
222 TknStrOSXL *tknStr; /* token string */
223 Buffer *mBuf; /* message buffer */
233 for (ndx = 0; ndx < tknStr->len; ndx++)
235 CMCHKPK(SPkU8, tknStr->val[ndx], mBuf);
238 CMCHKPK(SPkU16, tknStr->len, mBuf);
241 CMCHKPK(SPkU8, tknStr->pres, mBuf);
245 } /* end of cmPkTknStrOSXL */
251 * Fun: cmPkTknStrBSXL
253 * Desc: This function packs a Long bit string
264 PUBLIC S16 cmPkTknStrBSXL
266 TknStrBSXL *tknStr, /* token string */
267 Buffer *mBuf /* message buffer */
270 PUBLIC S16 cmPkTknStrBSXL(tknStr, mBuf)
271 TknStrBSXL *tknStr; /* token string */
272 Buffer *mBuf; /* message buffer */
283 len = (tknStr->len/8) + 1;
285 len = (tknStr->len/8);
288 for (ndx = 0; ndx < len; ndx++)
290 CMCHKPK(SPkU8, tknStr->val[ndx], mBuf);
293 CMCHKPK(SPkU16, tknStr->len, mBuf);
296 CMCHKPK(SPkU8, tknStr->pres, mBuf);
300 } /* end of cmPkTknStrBSXL */
305 * Fun: cmPkTknStrBMP4
307 * Desc: This function packs a BMP token string of size 4
318 PUBLIC S16 cmPkTknStrBMP4
320 TknStrBMP4 *tknStr, /* token string */
321 Buffer *mBuf /* message buffer */
324 PUBLIC S16 cmPkTknStrBMP4(tknStr, mBuf)
325 TknStrBMP4 *tknStr; /* token string */
326 Buffer *mBuf; /* message buffer */
336 for (ndx = 0; ndx < tknStr->len; ndx++)
338 CMCHKPK(SPkU16, tknStr->val[ndx], mBuf);
342 CMCHKPK(SPkU8, tknStr->len, mBuf);
346 CMCHKPK(SPkU8, tknStr->pres, mBuf);
349 } /* end of cmPkTknStrBMP4 */
354 * Fun: cmPkTknStrBMPXL
356 * Desc: This function packs a Long BMP Octet string
367 PUBLIC S16 cmPkTknStrBMPXL
369 TknStrBMPXL *tknStr, /* token string */
370 Buffer *mBuf /* message buffer */
373 PUBLIC S16 cmPkTknStrBMPXL(tknStr, mBuf)
374 TknStrBMPXL *tknStr; /* token string */
375 Buffer *mBuf; /* message buffer */
380 TRC2(cmPkTknStrBMPXL)
385 for (ndx = 0; ndx < tknStr->len; ndx++)
387 CMCHKPK(SPkU16, tknStr->val[ndx], mBuf);
390 CMCHKPK(SPkU16, tknStr->len, mBuf);
393 CMCHKPK(SPkU8, tknStr->pres, mBuf);
396 } /* end of cmPkTknStrBMPXL */
401 * Fun: cmPkTknStrUNI4
403 * Desc: This function packs a UNI token string of size 4
414 PUBLIC S16 cmPkTknStrUNI4
416 TknStrUNI4 *tknStr, /* token string */
417 Buffer *mBuf /* message buffer */
420 PUBLIC S16 cmPkTknStrUNI4(tknStr, mBuf)
421 TknStrUNI4 *tknStr; /* token string */
422 Buffer *mBuf; /* message buffer */
432 for (ndx = 0; ndx < tknStr->len; ndx++)
434 CMCHKPK(SPkU32, tknStr->val[ndx], mBuf);
438 CMCHKPK(SPkU8, tknStr->len, mBuf);
442 CMCHKPK(SPkU8, tknStr->pres, mBuf);
445 } /* end of cmPkTknStrUNI4 */
450 * Fun: cmPkTknStrUNIXL
452 * Desc: This function packs a Long UNI Octet string
463 PUBLIC S16 cmPkTknStrUNIXL
465 TknStrUNIXL *tknStr, /* token string */
466 Buffer *mBuf /* message buffer */
469 PUBLIC S16 cmPkTknStrUNIXL(tknStr, mBuf)
470 TknStrUNIXL *tknStr; /* token string */
471 Buffer *mBuf; /* message buffer */
476 TRC2(cmPkTknStrUNIXL)
481 for (ndx = 0; ndx < tknStr->len; ndx++)
483 CMCHKPK(SPkU32, tknStr->val[ndx], mBuf);
486 CMCHKPK(SPkU16, tknStr->len, mBuf);
489 CMCHKPK(SPkU8, tknStr->pres, mBuf);
492 } /* end of cmPkTknStrUNIXL */
495 * UNPACKING FUNCTIONS
503 * Desc: This function unpacks a token S16
513 PUBLIC S16 cmUnpkTknS16
515 TknS16 *tknS16, /* token S16 */
516 Buffer *mBuf /* message buffer */
519 PUBLIC S16 cmUnpkTknS16(tknS16, mBuf)
520 TknS16 *tknS16; /* token S16 */
521 Buffer *mBuf; /* message buffer */
527 CMCHKUNPK(SUnpkU8, &tknS16->pres, mBuf);
532 CMCHKUNPK(SUnpkS16, &tknS16->val, mBuf);
536 } /* end of cmUnpkTknS16 */
541 * Fun: cmUnpkTknBStr32
543 * Desc: This function packs a token bit string of size 32
554 PUBLIC S16 cmUnpkTknBStr32
556 TknBStr32 *tknStr, /* token string */
557 Buffer *mBuf /* message buffer */
560 PUBLIC S16 cmUnpkTknBStr32(tknStr, mBuf)
561 TknBStr32 *tknStr; /* token string */
562 Buffer *mBuf; /* message buffer */
565 TRC2(cmUnpkTknBStr32)
567 CMUNPKTKNBSTR(tknStr, mBuf);
571 } /* end of cmUnpkTknBStr32 */
578 * Desc: This function packs a token string of size 8
589 PUBLIC S16 cmUnpkTknStr8
591 TknStr8 *tknStr, /* token string */
592 Buffer *mBuf /* message buffer */
595 PUBLIC S16 cmUnpkTknStr8(tknStr, mBuf)
596 TknStr8 *tknStr; /* token string */
597 Buffer *mBuf; /* message buffer */
602 CMUNPKTKNSTR(tknStr, mBuf);
606 } /* end of cmUnpkTknStr8 */
611 * Fun: cmUnpkTknStr16
613 * Desc: This function packs a token string of size 16
624 PUBLIC S16 cmUnpkTknStr16
626 TknStr16 *tknStr, /* token string */
627 Buffer *mBuf /* message buffer */
630 PUBLIC S16 cmUnpkTknStr16(tknStr, mBuf)
631 TknStr16 *tknStr; /* token string */
632 Buffer *mBuf; /* message buffer */
637 CMUNPKTKNSTR(tknStr, mBuf);
641 } /* end of cmUnpkTknStr16 */
646 * Fun: cmUnpkTknStrOSXL
648 * Desc: This function packs a long octet token string
659 PUBLIC S16 cmUnpkTknStrOSXL
661 TknStrOSXL *tknStr, /* token string */
662 Buffer *mBuf, /* message buffer */
663 Ptr ptr /* pointer to memory control block */
666 PUBLIC S16 cmUnpkTknStrOSXL(tknStr, mBuf, ptr)
667 TknStrOSXL *tknStr; /* token string */
668 Buffer *mBuf; /* message buffer */
669 Ptr ptr; /* pointer to control memory block */
674 TRC2(cmUnpkTknStrOSXL)
676 CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf);
681 CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf);
683 if( cmGetMem(ptr, tknStr->len, (Ptr *)&tknStr->val) != ROK)
688 for (ndx = 1; ndx <= tknStr->len; ndx++)
690 CMCHKUNPK(SUnpkU8, &tknStr->val[tknStr->len - ndx], mBuf);
696 } /* end of cmUnpkTknStrOSXL */
702 * Fun: cmUnpkTknStrBSXL
704 * Desc: This function packs a long bit token string
715 PUBLIC S16 cmUnpkTknStrBSXL
717 TknStrBSXL *tknStr, /* token string */
718 Ptr ptr, /* pointer to memory control block */
719 Buffer *mBuf /* message buffer */
722 PUBLIC S16 cmUnpkTknStrBSXL(tknStr, ptr, mBuf)
723 TknStrBSXL *tknStr; /* token string */
724 Ptr ptr; /* pointer to control memory block */
725 Buffer *mBuf; /* message buffer */
731 TRC2(cmUnpkTknStrBSXL)
733 CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf);
738 CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf);
741 len = (tknStr->len/8) + 1;
743 len = (tknStr->len/8);
745 if( cmGetMem(ptr, len, (Ptr *)&tknStr->val) != ROK)
750 for (ndx = 1; ndx <= len; ndx++)
752 CMCHKUNPK(SUnpkU8, &tknStr->val[len - ndx], mBuf);
758 } /* end of cmUnpkTknStrBSXL */
763 * Fun: cmUnpkTknStrBMP4
765 * Desc: This function unpacks a BMP token string of size 4
776 PUBLIC S16 cmUnpkTknStrBMP4
778 TknStrBMP4 *tknStr, /* token string */
779 Buffer *mBuf /* message buffer */
782 PUBLIC S16 cmUnpkTknStrBMP4(tknStr, mBuf)
783 TknStrBMP4 *tknStr; /* token string */
784 Buffer *mBuf; /* message buffer */
789 TRC2(cmUnpkTknStrBMP4)
792 CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf);
797 CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf);
800 for (ndx = 1; ndx <= tknStr->len; ndx++)
802 CMCHKUNPK(SUnpkU16, &tknStr->val[tknStr->len - ndx], mBuf);
807 } /* end of cmUnpkTknStrBMP4 */
812 * Fun: cmUnpkTknStrBMPXL
814 * Desc: This function packs a long octet token string
825 PUBLIC S16 cmUnpkTknStrBMPXL
827 TknStrBMPXL *tknStr, /* token string */
828 Buffer *mBuf, /* message buffer */
829 Ptr ptr /* pointer to memory control block */
832 PUBLIC S16 cmUnpkTknStrBMPXL(tknStr, mBuf, ptr)
833 TknStrBMPXL *tknStr; /* token string */
834 Buffer *mBuf; /* message buffer */
835 Ptr ptr; /* pointer to control memory block */
840 TRC2(cmUnpkTknStrBMPXL)
842 CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf);
847 CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf);
849 /* Each BMP Character is 2 octet long */
850 if( cmGetMem(ptr, 2*(tknStr->len), (Ptr *)&tknStr->val) != ROK)
855 for (ndx = 1; ndx <= tknStr->len; ndx++)
857 CMCHKUNPK(SUnpkU16, &tknStr->val[tknStr->len - ndx], mBuf);
863 } /* end of cmUnpkTknStrBMPXL */
868 * Fun: cmUnpkTknStrUNI4
870 * Desc: This function unpacks a UNI token string of size 4
881 PUBLIC S16 cmUnpkTknStrUNI4
883 TknStrUNI4 *tknStr, /* token string */
884 Buffer *mBuf /* message buffer */
887 PUBLIC S16 cmUnpkTknStrUNI4(tknStr, mBuf)
888 TknStrUNI4 *tknStr; /* token string */
889 Buffer *mBuf; /* message buffer */
894 TRC2(cmUnpkTknStrUNI4)
897 CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf);
902 CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf);
905 for (ndx = 1; ndx <= tknStr->len; ndx++)
907 CMCHKUNPK(SUnpkU32, &tknStr->val[tknStr->len - ndx], mBuf);
912 } /* end of cmUnpkTknStrUNI4 */
917 * Fun: cmUnpkTknStrUNIXL
919 * Desc: This function packs a long octet token string
930 PUBLIC S16 cmUnpkTknStrUNIXL
932 TknStrUNIXL *tknStr, /* token string */
933 Buffer *mBuf, /* message buffer */
934 Ptr ptr /* pointer to memory control block */
937 PUBLIC S16 cmUnpkTknStrUNIXL(tknStr, mBuf, ptr)
938 TknStrUNIXL *tknStr; /* token string */
939 Buffer *mBuf; /* message buffer */
940 Ptr ptr; /* pointer to control memory block */
945 TRC2(cmUnpkTknStrUNIXL)
947 CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf);
952 CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf);
954 /* Each UNI Character is 4 octets long */
955 if( cmGetMem(ptr, 4*tknStr->len, (Ptr *)&tknStr->val) != ROK)
960 for (ndx = 1; ndx <= tknStr->len; ndx++)
962 CMCHKUNPK(SUnpkU32, &tknStr->val[tknStr->len - ndx], mBuf);
968 } /* end of cmUnpkTknStrUNIXL */
970 /**********************************************************************
972 **********************************************************************/