Added code for MAC-PHY interface, DU_APP, F1AP, SCTP and CU stub
[o-du/l2.git] / src / mt / ss_pack.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 \f
19 /********************************************************************20**
20  
21      Name:     System Services -- packing
22  
23      Type:     C source file
24  
25      Desc:     Source code for System Services packing functions.
26  
27      File:     ss_pack.c
28  
29 *********************************************************************21*/
30
31 \f
32 /* header include files (.h) */
33
34 #include "envopt.h"        /* environment options */
35 #include "envdep.h"        /* environment dependent */
36 #include "envind.h"        /* environment independent */
37   
38 #include "gen.h"           /* general layer */
39 #include "ssi.h"           /* system services */
40
41 #include "ss_err.h"        /* errors */
42 #include "ss_dep.h"        /* implementation-specific */
43 #include "ss_queue.h"      /* queues */
44 #include "ss_msg.h"        /* messaging */
45 #include "ss_mem.h"        /* memory management interface */
46 #include "ss_gen.h"        /* general */
47 #include "cm_mem.h"        /* memory management */
48
49
50
51 /* header/extern include files (.x) */
52
53 #include "gen.x"           /* general layer */
54 #include "ssi.x"           /* system services */
55
56 #include "ss_dep.x"        /* implementation-specific */
57 #include "ss_queue.x"      /* queues */
58 #include "ss_task.x"       /* tasking */
59 #include "ss_timer.x"      /* timers */
60 #include "ss_strm.x"       /* STREAMS */
61 #include "ss_msg.x"        /* messaging */
62 #include "ss_mem.x"        /* memory management interface */
63 #include "ss_drvr.x"       /* driver tasks */
64 #ifdef SS_LOCKLESS_MEMORY
65 #include "cm_llist.x"
66 #include "cm_hash.x"
67 #include "cm_mem_wl.x"        /* common memory manager */
68 #else
69 #include "cm_mem.x"        /* common memory manager */
70 #endif /* SS_LOCKLESS_MEMORY */
71 #include "ss_gen.x"        /* general */
72
73
74 \f  
75 /*
76 *
77 *       Fun:   SPkS8
78 *
79 *       Desc:  This function packs a signed 8 bit value into a message.
80 *
81 *       Ret:   ROK      - ok
82 *              RFAILED  - failed, general (optional)
83 *              ROUTRES  - failed, out of resources (optional)
84 *
85 *       Notes: None
86 *
87 *       File:  ss_pack.c
88 *
89 */
90
91 #ifdef ANSI
92 PUBLIC S16 SPkS8
93 (
94 S8 val,                     /* value */
95 Buffer *mBuf                /* message buffer */
96 )
97 #else
98 PUBLIC S16 SPkS8(val, mBuf)
99 S8 val;                     /* value */
100 Buffer *mBuf;               /* message buffer */
101 #endif
102 {
103    S16 ret;                 /* return code */
104    TRC1(SPkS8)
105    ret = SAddPreMsg((Data) val, mBuf);
106 #if (ERRCLASS & ERRCLS_ADD_RES)
107    if (ret != ROK)
108       SSLOGERROR(ERRCLS_ADD_RES, ESS242, (ErrVal)ret, "SAddPreMsg() failed");
109 #endif
110    RETVALUE(ret);
111 } /* end of SPkS8 */
112   
113
114 \f  
115 /*
116 *
117 *       Fun:   SPkU8
118 *
119 *       Desc:  This function packs an unsigned 8 bit value into a message.
120 *
121 *       Ret:   ROK      - ok
122 *              RFAILED  - failed, general (optional)
123 *              ROUTRES  - failed, out of resources (optional)
124 *
125 *       Notes: None
126 *
127 *       File:  ss_pack.c
128 *
129 */
130   
131 #ifdef ANSI
132 PUBLIC S16 SPkU8
133 (
134 U8 val,                     /* value */
135 Buffer *mBuf                /* message buffer */
136 )
137 #else
138 PUBLIC S16 SPkU8(val, mBuf)
139 U8 val;                     /* value */
140 Buffer *mBuf;               /* message buffer */
141 #endif
142 {
143    S16 ret;                 /* return code */
144    TRC1(SPkU8)
145    ret = SAddPreMsg((Data) val, mBuf);
146 #if (ERRCLASS & ERRCLS_ADD_RES)
147    if (ret != ROK)
148       SSLOGERROR(ERRCLS_ADD_RES, ESS243, (ErrVal)ret, "SAddPreMsg() failed");
149 #endif
150    RETVALUE(ret);
151 } /* end of SPkU8 */
152 \f  
153 /*
154 *
155 *       Fun:   SPkS16
156 *
157 *       Desc:  This function packs a signed 16 bit value into a message.
158 *
159 *       Ret:   ROK      - ok
160 *              RFAILED  - failed, general (optional)
161 *              ROUTRES  - failed, out of resources (optional)
162 *
163 *       Notes: None
164 *
165 *       File:  ss_pack.c
166 *
167 */
168   
169 #ifdef ANSI
170 PUBLIC S16 SPkS16
171 (
172 S16 val,                    /* value */
173 Buffer *mBuf                /* message buffer */
174 )
175 #else
176 PUBLIC S16 SPkS16(val, mBuf)
177 S16 val;                    /* value */
178 Buffer *mBuf;               /* message buffer */
179 #endif
180 {
181    Data pkArray[2];         /* array for packing */
182    S16 ret;                 /* return code */
183
184    TRC1(SPkS16)
185 #ifndef FCSPKINT            /* backward compatibility, packing order */
186    pkArray[0] = (Data) GetHiByte(val);
187    pkArray[1] = (Data) GetLoByte(val);
188 #else                   /* forward compatibility, packing order */
189    pkArray[1] = (Data) GetHiByte(val);
190    pkArray[0] = (Data) GetLoByte(val);
191 #endif
192    ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
193 #if (ERRCLASS & ERRCLS_ADD_RES)
194    if (ret != ROK)
195       SSLOGERROR(ERRCLS_ADD_RES, ESS244, (ErrVal)ret, "SAddPreMsgMult() failed");
196 #endif
197    RETVALUE(ret);
198 } /* end of SPkS16 */
199   
200 \f  
201 /*
202 *
203 *       Fun:   SPkU16
204 *
205 *       Desc:  This function packs an unsigned 16 bit value into a message.
206 *
207 *       Ret:   ROK      - ok
208 *              RFAILED  - failed, general (optional)
209 *              ROUTRES  - failed, out of resources (optional)
210 *
211 *       Notes: None
212 *
213 *       File:  ss_pack.c
214 *
215 */
216   
217 #ifdef ANSI
218 PUBLIC S16 SPkU16
219 (
220 U16 val,                    /* value */
221 Buffer *mBuf                /* message buffer */
222 )
223 #else
224 PUBLIC S16 SPkU16(val, mBuf)
225 U16 val;                    /* value */
226 Buffer *mBuf;               /* message buffer */
227 #endif
228 {
229    Data pkArray[2];         /* array for packing */
230    S16 ret;                 /* return code */
231
232    TRC1(SPkU16)
233 #ifndef FCSPKINT            /* backward compatibility, packing order */
234    pkArray[0] = (Data) GetHiByte(val);
235    pkArray[1] = (Data) GetLoByte(val);
236 #else                       /* forward compatibility, packing order */
237    pkArray[1] = (Data) GetHiByte(val);
238    pkArray[0] = (Data) GetLoByte(val);
239 #endif
240    ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
241 #if (ERRCLASS & ERRCLS_ADD_RES)
242    if (ret != ROK)
243       SSLOGERROR(ERRCLS_ADD_RES, ESS245, (ErrVal)ret, "SAddPreMsgMult() failed");
244 #endif
245    RETVALUE(ret);
246 } /* end of SPkU16 */
247   
248 \f  
249 /*
250 *
251 *       Fun:   SPkS32
252 *
253 *       Desc:  This function packs a signed 32 bit value into a message.
254 *
255 *       Ret:   ROK      - ok
256 *              RFAILED  - failed, general (optional)
257 *              ROUTRES  - failed, out of resources (optional)
258 *
259 *       Notes: None
260 *
261 *       File:  ss_pack.c
262 *
263 */
264   
265 #ifdef ANSI
266 PUBLIC S16 SPkS32
267 (
268 S32 val,                    /* value */
269 Buffer *mBuf                /* message buffer */
270 )
271 #else
272 PUBLIC S16 SPkS32(val, mBuf)
273 S32 val;                    /* value */
274 Buffer *mBuf;               /* message buffer */
275 #endif
276 {
277    U16 tmp;                 /* temporary value */
278    Data pkArray[4];         /* packing array */
279    S16 ret;                 /* return code */
280   
281    TRC1(SPkS32)
282 #ifndef FCSPKINT        /* backward compatibility, packing order */
283    tmp = (U16) GetHiWord(val);
284    pkArray[0] = (Data) GetHiByte(tmp);
285    pkArray[1] = (Data) GetLoByte(tmp);
286    tmp = (U16) GetLoWord(val);
287    pkArray[2] = (Data) GetHiByte(tmp);
288    pkArray[3] = (Data) GetLoByte(tmp);
289 #else                   /* forward compatibility, packing order */
290    tmp = (U16) GetHiWord(val);
291    pkArray[3] = (Data) GetHiByte(tmp);
292    pkArray[2] = (Data) GetLoByte(tmp);
293    tmp = (U16) GetLoWord(val);
294    pkArray[1] = (Data) GetHiByte(tmp);
295    pkArray[0] = (Data) GetLoByte(tmp);
296 #endif
297    ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
298 #if (ERRCLASS & ERRCLS_ADD_RES)
299    if (ret != ROK)
300       SSLOGERROR(ERRCLS_ADD_RES, ESS246, (ErrVal)ret, "SAddPreMsgMult() failed");
301 #endif
302    RETVALUE(ret);
303 } /* end of SPkS32 */
304   
305 \f  
306 /*
307 *
308 *       Fun:   SPkU32
309 *
310 *       Desc:  This function packs an unsigned 32 bit value into a message.
311 *
312 *       Ret:   ROK      - ok
313 *              RFAILED  - failed, general (optional)
314 *              ROUTRES  - failed, out of resources (optional)
315 *
316 *       Notes: None
317 *
318 *       File:  ss_pack.c
319 *
320 */
321   
322 #ifdef ANSI
323 PUBLIC S16 SPkU32
324 (
325 U32 val,                    /* value */
326 Buffer *mBuf                /* message buffer */
327 )
328 #else
329 PUBLIC S16 SPkU32(val, mBuf)
330 U32 val;                    /* value */
331 Buffer *mBuf;               /* message buffer */
332 #endif
333 {
334    U16 tmp;                 /* temporary value */
335    Data pkArray[4];         /* packing array */
336    S16 ret;                 /* return code */
337   
338    TRC1(SPkU32)
339 #ifndef FCSPKINT        /* backward compatibility, packing order */
340    tmp = (U16) GetHiWord(val);
341    pkArray[0] = (Data) GetHiByte(tmp);
342    pkArray[1] = (Data) GetLoByte(tmp);
343    tmp = (U16) GetLoWord(val);
344    pkArray[2] = (Data) GetHiByte(tmp);
345    pkArray[3] = (Data) GetLoByte(tmp);
346 #else                   /* forward compatibility, packing order */
347    tmp = (U16) GetHiWord(val);
348    pkArray[3] = (Data) GetHiByte(tmp);
349    pkArray[2] = (Data) GetLoByte(tmp);
350    tmp = (U16) GetLoWord(val);
351    pkArray[1] = (Data) GetHiByte(tmp);
352    pkArray[0] = (Data) GetLoByte(tmp);
353 #endif
354    ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
355 #if (ERRCLASS & ERRCLS_ADD_RES)
356    if (ret != ROK)
357       SSLOGERROR(ERRCLS_ADD_RES, ESS247, (ErrVal)ret, "SAddPreMsgMult() failed");
358 #endif
359    RETVALUE(ret);
360 } /* end of SPkU32 */
361
362 /*ss038.103  1. Added Floating point support*/
363 #ifdef SS_FLOAT
364 /*
365 *
366 *       Fun:   SPkF32
367 *
368 *       Desc:  This function packs an 32 bit ieee-754 format float value into a message.
369 *
370 *       Ret:   ROK      - ok
371 *              RFAILED  - failed, general (optional)
372 *              ROUTRES  - failed, out of resources (optional)
373 *
374 *       Notes: None
375 *
376 *       File:  ss_pack.c
377 *
378 */
379   
380 #ifdef ANSI
381 PUBLIC S16 SPkF32
382 (
383 F32 val,                    /* value */
384 Buffer *mBuf                /* message buffer */
385 )
386 #else
387 PUBLIC S16 SPkF32(val, mBuf)
388 F32 val;                    /* value */
389 Buffer *mBuf;               /* message buffer */
390 #endif
391 {
392    S16  ret;                /* return code */
393    S8   tmpArray[15];       /* temporary array */
394 #ifdef FCSPKINT             /* backward compatibility, packing order */
395    S32  tIdx = 14;          /* counters */
396    S32  kIdx = 0;           /* counters */
397    S8   pkArray[15];        /* packing array */
398 #endif /*FCSPKINT*/
399   
400    TRC1(SPkF32)
401
402    sprintf(tmpArray, "%.7e", val);
403
404 #ifndef FCSPKINT            /* backward compatibility, packing order */
405    ret = SAddPreMsgMult((Data*)tmpArray, (MsgLen) 15, mBuf);
406 #else
407    while(tIdx >= 0)
408    {
409       pkArray[kIdx] = tmpArray[tIdx];
410       tIdx--; kIdx++;
411    }
412    ret = SAddPreMsgMult((Data*)pkArray, (MsgLen) 15, mBuf);
413 #endif
414
415
416 #if (ERRCLASS & ERRCLS_ADD_RES)
417    if (ret != ROK)
418       SSLOGERROR(ERRCLS_ADD_RES, ESS248, (ErrVal)ret, "SAddPreMsgMult() failed");
419 #endif
420    RETVALUE(ret);
421 } /* end of SPkF32 */
422
423 /*
424 *
425 *       Fun:   SPkF64
426 *
427 *       Desc:  This function packs an 64 bit ieee-754 format float value into a message.
428 *
429 *       Ret:   ROK      - ok
430 *              RFAILED  - failed, general (optional)
431 *              ROUTRES  - failed, out of resources (optional)
432 *
433 *       Notes: None
434 *
435 *       File:  ss_pack.c
436 *
437 */
438   
439 #ifdef ANSI
440 PUBLIC S16 SPkF64
441 (
442 F64 val,                    /* value */
443 Buffer *mBuf                /* message buffer */
444 )
445 #else
446 PUBLIC S16 SPkF64(val, mBuf)
447 F64 val;                    /* value */
448 Buffer *mBuf;               /* message buffer */
449 #endif
450 {
451
452    S16  ret;                /* return code */
453    S8   tmpArray[25];       /* temporary array */
454 #ifdef FCSPKINT             /* backward compatibility, packing order */
455    S32  tIdx = 24;          /* counters */
456    S32  kIdx = 0;           /* counters */
457    S8   pkArray[25];        /* packing array */
458 #endif /*FCSPKINT*/
459   
460    TRC1(SPkF64)
461
462    sprintf(tmpArray, "%.16le", val);
463
464 #ifndef FCSPKINT            /* backward compatibility, packing order */
465    ret = SAddPreMsgMult((Data*)tmpArray, (MsgLen) 25, mBuf);
466 #else
467    while(tIdx >= 0)
468    {
469       pkArray[kIdx] = tmpArray[tIdx];
470       tIdx--; kIdx++;
471    }
472    ret = SAddPreMsgMult((Data*)pkArray, (MsgLen) 25, mBuf);
473 #endif
474
475
476 #if (ERRCLASS & ERRCLS_ADD_RES)
477    if (ret != ROK)
478       SSLOGERROR(ERRCLS_ADD_RES, ESS249, (ErrVal)ret, "SAddPreMsgMult() failed");
479 #endif
480    RETVALUE(ret);
481
482 } /* end of SPkF64 */
483 #endif /* SS_FLOAT */
484 \f  
485 /*
486 *
487 *       Fun:   SUnpkS8
488 *
489 *       Desc:  This function unpacks a signed 8 bit value from a message.
490 *
491 *       Ret:   ROK      - ok
492 *
493 *       Notes: None
494 *
495 *       File:  ss_pack.c
496 *
497 */
498   
499 #ifdef ANSI
500 PUBLIC S16 SUnpkS8
501 (
502 S8 *val,                    /* pointer to value */
503 Buffer *mBuf                /* message buffer */
504 )
505 #else
506 PUBLIC S16 SUnpkS8(val, mBuf)
507 S8 *val;                    /* pointer to value */
508 Buffer *mBuf;               /* message buffer */
509 #endif
510 {
511    Data tmp;                /* temporary value */
512    S16 ret;                 /* return code */
513    TRC1(SUnpkS8)
514
515 /* ss021.103 - Addition of data pointer check */
516 #if (ERRCLASS & ERRCLS_INT_PAR)
517    /* check data pointer */
518    if (!val)
519    {
520       SSLOGERROR(ERRCLS_INT_PAR, ESS250, ERRZERO, "SUnpkS8 : Null value");
521       RETVALUE(RFAILED);
522    }
523 #endif /* ERRCLASS & ERRCLS_INT_PAR */
524
525    ret = SRemPreMsg(&tmp, mBuf);
526 #if (ERRCLASS & ERRCLS_DEBUG)
527    if (ret != ROK)
528       SSLOGERROR(ERRCLS_DEBUG, ESS251, (ErrVal)ret, "SRemPreMsg() failed");
529 #endif
530    *val = (S8) tmp;
531    RETVALUE(ret);
532 } /* end of SUnpkS8 */
533   
534 \f  
535 /*
536 *
537 *       Fun:   SUnpkU8
538 *
539 *       Desc:  This function unpacks an unsigned 8 bit value from a message.
540 *
541 *       Ret:   ROK      - ok
542 *
543 *       Notes: None
544 *
545 *       File:  ss_pack.c
546 *
547 */
548   
549 #ifdef ANSI
550 PUBLIC S16 SUnpkU8
551 (
552 U8 *val,                    /* pointer to value */
553 Buffer *mBuf                /* message buffer */
554 )
555 #else
556 PUBLIC S16 SUnpkU8(val, mBuf)
557 U8 *val;                    /* pointer to value */
558 Buffer *mBuf;               /* message buffer */
559 #endif
560 {
561    Data tmp;                /* temporary value */
562    S16 ret;                 /* return code */
563    TRC1(SUnpkU8)
564
565 /* ss021.103 - Addition of data pointer check */
566 #if (ERRCLASS & ERRCLS_INT_PAR)
567    /* check data pointer */
568    if (!val)
569    {
570       SSLOGERROR(ERRCLS_INT_PAR, ESS252, ERRZERO, "SUnpkU8 : Null value");
571       RETVALUE(RFAILED);
572    }
573 #endif /* ERRCLASS & ERRCLS_INT_PAR */
574
575    ret = SRemPreMsg(&tmp, mBuf);
576 #if (ERRCLASS & ERRCLS_DEBUG)
577    if (ret != ROK)
578       SSLOGERROR(ERRCLS_DEBUG, ESS253, (ErrVal)ret, "SRemPreMsg() failed");
579 #endif
580    *val = (U8) tmp;
581    RETVALUE(ret);
582 } /* end of SUnpkU8 */
583 \f  
584 /*
585 *
586 *       Fun:   SUnpkS16
587 *
588 *       Desc:  This function unpacks a signed 16 bit value from a message.
589 *
590 *       Ret:   ROK      - ok
591 *
592 *       Notes: None
593 *
594 *       File:  ss_pack.c
595 *
596 */
597   
598 #ifdef ANSI
599 PUBLIC S16 SUnpkS16
600 (
601 S16 *val,                   /* pointer to value */
602 Buffer *mBuf                /* message buffer */
603 )
604 #else
605 PUBLIC S16 SUnpkS16(val, mBuf)
606 S16 *val;                   /* pointer to value */
607 Buffer *mBuf;               /* message buffer */
608 #endif
609 {
610    U16 tmp16;               /* temporary value */
611    Data unpkArray[2];       /* unpacking array */
612    S16 ret;                 /* return code */
613    TRC1(SUnpkS16)
614
615 /* ss021.103 - Addition of data pointer check */
616 #if (ERRCLASS & ERRCLS_INT_PAR)
617    /* check data pointer */
618    if (!val)
619    {
620       SSLOGERROR(ERRCLS_INT_PAR, ESS254, ERRZERO, "SUnpkS16 : Null value");
621       RETVALUE(RFAILED);
622    }
623 #endif /* ERRCLASS & ERRCLS_INT_PAR */
624
625    ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf);
626 #if (ERRCLASS & ERRCLS_DEBUG)
627    if (ret != ROK)
628       SSLOGERROR(ERRCLS_DEBUG, ESS255, (ErrVal)ret, "SRemPreMsgMult() failed");
629 #endif
630    tmp16 = 0; 
631 #ifndef FCSPKINT            /* backward compatibility, packing order */
632    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]);
633    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]);
634 #else                       /* forward compatibility, packing order */
635    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]);
636    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]);
637 #endif
638    *val = (S16) tmp16;
639    RETVALUE(ret);
640 } /* end of SUnpkS16 */
641   
642 \f  
643 /*
644 *
645 *       Fun:   SUnpkU16
646 *
647 *       Desc:  This function unpacks an unsigned 16 bit value from a message.
648 *
649 *       Ret:   ROK      - ok
650 *
651 *       Notes: None
652 *
653 *       File:  ss_pack.c
654 *
655 */
656   
657 #ifdef ANSI
658 PUBLIC S16 SUnpkU16
659 (
660 U16 *val,                   /* pointer to value */
661 Buffer *mBuf                /* message buffer */
662 )
663 #else
664 PUBLIC S16 SUnpkU16(val, mBuf)
665 U16 *val;                   /* pointer to value */
666 Buffer *mBuf;               /* message buffer */
667 #endif
668 {
669    U16 tmp16;               /* temporary value */
670    Data unpkArray[2];       /* unpacking array */
671    S16 ret;                 /* return code */
672    TRC1(SUnpkU16)
673
674 /* ss021.103 - Addition of data pointer check */
675 #if (ERRCLASS & ERRCLS_INT_PAR)
676    /* check data pointer */
677    if (!val)
678    {
679       SSLOGERROR(ERRCLS_INT_PAR, ESS256, ERRZERO, "SUnpkU16 : Null value");
680       RETVALUE(RFAILED);
681    }
682 #endif /* ERRCLASS & ERRCLS_INT_PAR */
683
684    ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf);
685 #if (ERRCLASS & ERRCLS_DEBUG)
686    if (ret != ROK)
687       SSLOGERROR(ERRCLS_DEBUG, ESS257, (ErrVal)ret, "SRemPreMsgMult failed");
688 #endif
689    tmp16 = 0; 
690 #ifndef FCSPKINT            /* backward compatibility, packing order */
691    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]);
692    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]);
693 #else                       /* forward compatibility, packing order */
694    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]);
695    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]);
696 #endif
697    *val = tmp16;
698    RETVALUE(ret);
699 } /* end of SUnpkU16 */
700   
701 \f  
702 /*
703 *
704 *       Fun:   SUnpkS32
705 *
706 *       Desc:  This function unpacks a signed 32 bit value from a message.
707 *
708 *       Ret:   ROK      - ok
709 *
710 *       Notes: None
711 *
712 *       File:  ss_pack.c
713 *
714 */
715   
716 #ifdef ANSI
717 PUBLIC S16 SUnpkS32
718 (
719 S32 *val,                   /* pointer to value */
720 Buffer *mBuf                /* message buffer */
721 )
722 #else
723 PUBLIC S16 SUnpkS32(val, mBuf)
724 S32 *val;                   /* pointer to value */
725 Buffer *mBuf;               /* message buffer */
726 #endif
727 {
728    U16 tmp16;               /* temporary value */
729    U32 tmp32;               /* temporary value */
730    Data unpkArray[4];       /* unpacking array */
731    S16 ret;                 /* return code */
732    TRC1(SUnpkS32)
733
734 /* ss021.103 - Addition of data pointer check */
735 #if (ERRCLASS & ERRCLS_INT_PAR)
736    /* check data pointer */
737    if (!val)
738    {
739       SSLOGERROR(ERRCLS_INT_PAR, ESS258, ERRZERO, "SUnpkS32 : Null value");
740       RETVALUE(RFAILED);
741    }
742 #endif /* ERRCLASS & ERRCLS_INT_PAR */
743
744    ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf);
745 #if (ERRCLASS & ERRCLS_DEBUG)
746    if (ret != ROK)
747       SSLOGERROR(ERRCLS_DEBUG, ESS259, (ErrVal)ret, "SRemPreMsgMult() failed");
748 #endif
749    tmp16 = 0;
750    tmp32 = 0; 
751 #ifndef FCSPKINT            /* backward compatibility, packing order */
752    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[3]);
753    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[2]);
754    tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16);
755    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]);
756    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]);
757    tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16);
758 #else                       /* forward compatibility, packing order */
759    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]);
760    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]);
761    tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16);
762    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[2]);
763    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[3]);
764    tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16);
765 #endif
766    *val = (S32) tmp32;
767    RETVALUE(ret);
768 } /* end of SUnpkS32 */
769   
770 \f  
771 /*
772 *
773 *       Fun:   SUnpkU32
774 *
775 *       Desc:  This function unpacks an unsigned 32 bit value from a message.
776 *
777 *       Ret:   ROK      - ok
778 *
779 *       Notes: None
780 *
781 *       File:  ss_pack.c
782 *
783 */
784   
785 #ifdef ANSI
786 PUBLIC S16 SUnpkU32
787 (
788 U32 *val,                   /* pointer to value */
789 Buffer *mBuf                /* message buffer */
790 )
791 #else
792 PUBLIC S16 SUnpkU32(val, mBuf)
793 U32 *val;                   /* pointer to value */
794 Buffer *mBuf;               /* message buffer */
795 #endif
796 {
797    U16 tmp16;               /* temporary value */
798    U32 tmp32;               /* temporary value */
799    Data unpkArray[4];       /* unpacking array */
800 #ifdef ERRCLASS
801    S16 ret;                 /* return code */
802 #endif /* ERRCLASS */
803    TRC1(SUnpkU32)
804
805 /* ss021.103 - Addition of data pointer check */
806 #if (ERRCLASS & ERRCLS_INT_PAR)
807    /* check data pointer */
808    if (!val)
809    {
810       SSLOGERROR(ERRCLS_INT_PAR, ESS260, ERRZERO, "SUnpkU32 : Null value");
811       RETVALUE(RFAILED);
812    }
813 #endif /* ERRCLASS & ERRCLS_INT_PAR */
814
815    ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf);
816 #if (ERRCLASS & ERRCLS_DEBUG)
817    if (ret != ROK)
818       SSLOGERROR(ERRCLS_DEBUG, ESS261, (ErrVal)ret, "SRemPreMsgMult() failed");
819 #endif
820
821    tmp16 = 0;
822    tmp32 = 0; 
823 #ifndef FCSPKINT            /* backward compatibility, packing order */
824    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[3]);
825    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[2]);
826    tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16);
827    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]);
828    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]);
829    tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16);
830 #else                       /* forward compatibility, packing order */
831    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]);
832    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]);
833    tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16);
834    tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[2]);
835    tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[3]);
836    tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16);
837 #endif
838    *val = tmp32;
839    RETVALUE(ret);
840 } /* end of SUnpkU32 */
841
842 /*ss038.103  1. Added Floating point support*/
843 #ifdef SS_FLOAT
844 /*
845 *
846 *       Fun:   SUnpkF32
847 *
848 *       Desc:  This function unpacks an 32 bit ieee-754 format float value from a message.
849 *
850 *       Ret:   ROK      - ok
851 *
852 *       Notes: None
853 *
854 *       File:  ss_pack.c
855 *
856 */
857   
858 #ifdef ANSI
859 PUBLIC S16 SUnpkF32
860 (
861 F32 *val,                   /* pointer to value */
862 Buffer *mBuf                /* message buffer */
863 )
864 #else
865 PUBLIC S16 SUnpkF32(val, mBuf)
866 F32 *val;                   /* pointer to value */
867 Buffer *mBuf;               /* message buffer */
868 #endif
869 {
870    S16 ret;                 /* return code */
871    S8 tmpArray[15];         /* temporary array */
872 #ifndef FCSPKINT            /* backward compatibility, packing order */
873    S32 tIdx = 14;           /* temparory array index */
874    S32 kIdx = 0;            /* unpacking array index */
875    S8 unpkArray[15];        /* unpacking array */
876 #endif /* FCSPKINT */
877
878    TRC1(SUnpkF32)
879
880 #if (ERRCLASS & ERRCLS_INT_PAR)
881    /* check data pointer */
882    if (!val)
883    {
884       SSLOGERROR(ERRCLS_INT_PAR, ESS262, ERRZERO, "SUnpkF32 : Null value");
885       RETVALUE(RFAILED);
886    }
887 #endif /* ERRCLASS & ERRCLS_INT_PAR */
888
889    ret = SRemPreMsgMult((Data*)tmpArray, (MsgLen) 15, mBuf);
890 #if (ERRCLASS & ERRCLS_DEBUG)
891    if (ret != ROK)
892       SSLOGERROR(ERRCLS_DEBUG, ESS263, (ErrVal)ret, "SRemPreMsgMult() failed");
893 #endif
894
895 #ifndef FCSPKINT            /* backward compatibility, packing order */
896    while(tIdx >= 0)
897    {
898       unpkArray[kIdx] = tmpArray[tIdx];
899       tIdx--; kIdx++;
900    }
901    sscanf(unpkArray, "%f", val);
902 #else
903    sscanf(tmpArray, "%f", val);
904 #endif
905
906    RETVALUE(ret);
907
908 } /* end of SUnpkF32 */
909
910 /*
911 *
912 *       Fun:   SUnpkF64
913 *
914 *       Desc:  This function unpacks an 64 bit ieee-754 format float value from a message.
915 *
916 *       Ret:   ROK      - ok
917 *
918 *       Notes: None
919 *
920 *       File:  ss_pack.c
921 *
922 */
923   
924 #ifdef ANSI
925 PUBLIC S16 SUnpkF64
926 (
927 F64 *val,                   /* pointer to value */
928 Buffer *mBuf                /* message buffer */
929 )
930 #else
931 PUBLIC S16 SUnpkF64(val, mBuf)
932 F64 *val;                   /* pointer to value */
933 Buffer *mBuf;               /* message buffer */
934 #endif
935 {
936
937    S16 ret;                 /* return code */
938    S8 tmpArray[25];         /* temporary array */
939 #ifndef FCSPKINT            /* backward compatibility, packing order */
940    S32 tIdx = 24;           /* temparory array index */
941    S32 kIdx = 0;            /* unpacking array index */
942    S8 unpkArray[25];        /* unpacking array */
943 #endif /* FCSPKINT */
944
945    TRC1(SUnpkF64)
946
947 #if (ERRCLASS & ERRCLS_INT_PAR)
948    /* check data pointer */
949    if (!val)
950    {
951       SSLOGERROR(ERRCLS_INT_PAR, ESS264, ERRZERO, "SUnpkF64 : Null value");
952       RETVALUE(RFAILED);
953    }
954 #endif /* ERRCLASS & ERRCLS_INT_PAR */
955
956    ret = SRemPreMsgMult((Data*)tmpArray, (MsgLen) 25, mBuf);
957 #if (ERRCLASS & ERRCLS_DEBUG)
958    if (ret != ROK)
959       SSLOGERROR(ERRCLS_DEBUG, ESS265, (ErrVal)ret, "SRemPreMsgMult() failed");
960 #endif
961
962 #ifndef FCSPKINT            /* backward compatibility, packing order */
963    while(tIdx >= 0)
964    {
965       unpkArray[kIdx] = tmpArray[tIdx];
966       tIdx--; kIdx++;
967    }
968    sscanf(unpkArray, "%lf", val);
969 #else
970    sscanf(tmpArray, "%lf", val);
971 #endif
972
973    RETVALUE(ret);
974
975 } /* end of SUnpkF64 */
976 #endif /* SS_FLOAT */
977 \f
978 /**********************************************************************
979          End of file
980  **********************************************************************/