2f9635a656361aae002940c3ea588bcbef24d9ea
[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 S16 SPkS8
92 (
93 S8 val,                     /* value */
94 Buffer *mBuf                /* message buffer */
95 )
96 {
97    S16 ret;                 /* return code */
98    ret = SAddPreMsg((Data) val, mBuf);
99 #if (ERRCLASS & ERRCLS_ADD_RES)
100    if (ret != ROK)
101       SSLOGERROR(ERRCLS_ADD_RES, ESS242, (ErrVal)ret, "SAddPreMsg() failed");
102 #endif
103    return (ret);
104 } /* end of SPkS8 */
105   
106
107 \f  
108 /*
109 *
110 *       Fun:   oduUnpackUInt8
111 *
112 *       Desc:  This function packs an unsigned 8 bit value into a message.
113 *
114 *       Ret:   ROK      - ok
115 *              RFAILED  - failed, general (optional)
116 *              ROUTRES  - failed, out of resources (optional)
117 *
118 *       Notes: None
119 *
120 *       File:  ss_pack.c
121 *
122 */
123   
124 S16 oduUnpackUInt8
125 (
126 uint8_t val,                     /* value */
127 Buffer *mBuf                /* message buffer */
128 )
129 {
130    S16 ret;                 /* return code */
131    ret = SAddPreMsg((Data) val, mBuf);
132 #if (ERRCLASS & ERRCLS_ADD_RES)
133    if (ret != ROK)
134       SSLOGERROR(ERRCLS_ADD_RES, ESS243, (ErrVal)ret, "SAddPreMsg() failed");
135 #endif
136    return (ret);
137 } /* end of oduUnpackUInt8 */
138 \f  
139 /*
140 *
141 *       Fun:   SPkS16
142 *
143 *       Desc:  This function packs a signed 16 bit value into a message.
144 *
145 *       Ret:   ROK      - ok
146 *              RFAILED  - failed, general (optional)
147 *              ROUTRES  - failed, out of resources (optional)
148 *
149 *       Notes: None
150 *
151 *       File:  ss_pack.c
152 *
153 */
154   
155 S16 SPkS16
156 (
157 S16 val,                    /* value */
158 Buffer *mBuf                /* message buffer */
159 )
160 {
161    Data pkArray[2];         /* array for packing */
162    S16 ret;                 /* return code */
163
164 #ifndef FCSPKINT            /* backward compatibility, packing order */
165    pkArray[0] = (Data) GetHiByte(val);
166    pkArray[1] = (Data) GetLoByte(val);
167 #else                   /* forward compatibility, packing order */
168    pkArray[1] = (Data) GetHiByte(val);
169    pkArray[0] = (Data) GetLoByte(val);
170 #endif
171    ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
172 #if (ERRCLASS & ERRCLS_ADD_RES)
173    if (ret != ROK)
174       SSLOGERROR(ERRCLS_ADD_RES, ESS244, (ErrVal)ret, "SAddPreMsgMult() failed");
175 #endif
176    return (ret);
177 } /* end of SPkS16 */
178   
179 \f  
180 /*
181 *
182 *       Fun:   oduUnpackUInt16
183 *
184 *       Desc:  This function packs an unsigned 16 bit value into a message.
185 *
186 *       Ret:   ROK      - ok
187 *              RFAILED  - failed, general (optional)
188 *              ROUTRES  - failed, out of resources (optional)
189 *
190 *       Notes: None
191 *
192 *       File:  ss_pack.c
193 *
194 */
195   
196 S16 oduUnpackUInt16
197 (
198 uint16_t val,                    /* value */
199 Buffer *mBuf                /* message buffer */
200 )
201 {
202    Data pkArray[2];         /* array for packing */
203    S16 ret;                 /* return code */
204
205 #ifndef FCSPKINT            /* backward compatibility, packing order */
206    pkArray[0] = (Data) GetHiByte(val);
207    pkArray[1] = (Data) GetLoByte(val);
208 #else                       /* forward compatibility, packing order */
209    pkArray[1] = (Data) GetHiByte(val);
210    pkArray[0] = (Data) GetLoByte(val);
211 #endif
212    ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
213 #if (ERRCLASS & ERRCLS_ADD_RES)
214    if (ret != ROK)
215       SSLOGERROR(ERRCLS_ADD_RES, ESS245, (ErrVal)ret, "SAddPreMsgMult() failed");
216 #endif
217    return (ret);
218 } /* end of oduUnpackUInt16 */
219   
220 \f  
221 /*
222 *
223 *       Fun:   SPkS32
224 *
225 *       Desc:  This function packs a signed 32 bit value into a message.
226 *
227 *       Ret:   ROK      - ok
228 *              RFAILED  - failed, general (optional)
229 *              ROUTRES  - failed, out of resources (optional)
230 *
231 *       Notes: None
232 *
233 *       File:  ss_pack.c
234 *
235 */
236   
237 S16 SPkS32
238 (
239 S32 val,                    /* value */
240 Buffer *mBuf                /* message buffer */
241 )
242 {
243    uint16_t tmp;                 /* temporary value */
244    Data pkArray[4];         /* packing array */
245    S16 ret;                 /* return code */
246   
247 #ifndef FCSPKINT        /* backward compatibility, packing order */
248    tmp = (uint16_t) GetHiWord(val);
249    pkArray[0] = (Data) GetHiByte(tmp);
250    pkArray[1] = (Data) GetLoByte(tmp);
251    tmp = (uint16_t) GetLoWord(val);
252    pkArray[2] = (Data) GetHiByte(tmp);
253    pkArray[3] = (Data) GetLoByte(tmp);
254 #else                   /* forward compatibility, packing order */
255    tmp = (uint16_t) GetHiWord(val);
256    pkArray[3] = (Data) GetHiByte(tmp);
257    pkArray[2] = (Data) GetLoByte(tmp);
258    tmp = (uint16_t) GetLoWord(val);
259    pkArray[1] = (Data) GetHiByte(tmp);
260    pkArray[0] = (Data) GetLoByte(tmp);
261 #endif
262    ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
263 #if (ERRCLASS & ERRCLS_ADD_RES)
264    if (ret != ROK)
265       SSLOGERROR(ERRCLS_ADD_RES, ESS246, (ErrVal)ret, "SAddPreMsgMult() failed");
266 #endif
267    return (ret);
268 } /* end of SPkS32 */
269   
270 \f  
271 /*
272 *
273 *       Fun:   oduUnpackUInt32
274 *
275 *       Desc:  This function packs an unsigned 32 bit value into a message.
276 *
277 *       Ret:   ROK      - ok
278 *              RFAILED  - failed, general (optional)
279 *              ROUTRES  - failed, out of resources (optional)
280 *
281 *       Notes: None
282 *
283 *       File:  ss_pack.c
284 *
285 */
286   
287 S16 oduUnpackUInt32
288 (
289 uint32_t val,                    /* value */
290 Buffer *mBuf                /* message buffer */
291 )
292 {
293    uint16_t tmp;                 /* temporary value */
294    Data pkArray[4];         /* packing array */
295    S16 ret;                 /* return code */
296   
297 #ifndef FCSPKINT        /* backward compatibility, packing order */
298    tmp = (uint16_t) GetHiWord(val);
299    pkArray[0] = (Data) GetHiByte(tmp);
300    pkArray[1] = (Data) GetLoByte(tmp);
301    tmp = (uint16_t) GetLoWord(val);
302    pkArray[2] = (Data) GetHiByte(tmp);
303    pkArray[3] = (Data) GetLoByte(tmp);
304 #else                   /* forward compatibility, packing order */
305    tmp = (uint16_t) GetHiWord(val);
306    pkArray[3] = (Data) GetHiByte(tmp);
307    pkArray[2] = (Data) GetLoByte(tmp);
308    tmp = (uint16_t) GetLoWord(val);
309    pkArray[1] = (Data) GetHiByte(tmp);
310    pkArray[0] = (Data) GetLoByte(tmp);
311 #endif
312    ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
313 #if (ERRCLASS & ERRCLS_ADD_RES)
314    if (ret != ROK)
315       SSLOGERROR(ERRCLS_ADD_RES, ESS247, (ErrVal)ret, "SAddPreMsgMult() failed");
316 #endif
317    return (ret);
318 } /* end of oduUnpackUInt32 */
319
320 /*ss038.103  1. Added Floating point support*/
321 #ifdef SS_FLOAT
322 /*
323 *
324 *       Fun:   SPkF32
325 *
326 *       Desc:  This function packs an 32 bit ieee-754 format float value into a message.
327 *
328 *       Ret:   ROK      - ok
329 *              RFAILED  - failed, general (optional)
330 *              ROUTRES  - failed, out of resources (optional)
331 *
332 *       Notes: None
333 *
334 *       File:  ss_pack.c
335 *
336 */
337   
338 S16 SPkF32
339 (
340 F32 val,                    /* value */
341 Buffer *mBuf                /* message buffer */
342 )
343 {
344    S16  ret;                /* return code */
345    S8   tmpArray[15];       /* temporary array */
346 #ifdef FCSPKINT             /* backward compatibility, packing order */
347    S32  tIdx = 14;          /* counters */
348    S32  kIdx = 0;           /* counters */
349    S8   pkArray[15];        /* packing array */
350 #endif /*FCSPKINT*/
351   
352    sprintf(tmpArray, "%.7e", val);
353
354 #ifndef FCSPKINT            /* backward compatibility, packing order */
355    ret = SAddPreMsgMult((Data*)tmpArray, (MsgLen) 15, mBuf);
356 #else
357    while(tIdx >= 0)
358    {
359       pkArray[kIdx] = tmpArray[tIdx];
360       tIdx--; kIdx++;
361    }
362    ret = SAddPreMsgMult((Data*)pkArray, (MsgLen) 15, mBuf);
363 #endif
364
365
366 #if (ERRCLASS & ERRCLS_ADD_RES)
367    if (ret != ROK)
368       SSLOGERROR(ERRCLS_ADD_RES, ESS248, (ErrVal)ret, "SAddPreMsgMult() failed");
369 #endif
370    return (ret);
371 } /* end of SPkF32 */
372
373 /*
374 *
375 *       Fun:   SPkF64
376 *
377 *       Desc:  This function packs an 64 bit ieee-754 format float value into a message.
378 *
379 *       Ret:   ROK      - ok
380 *              RFAILED  - failed, general (optional)
381 *              ROUTRES  - failed, out of resources (optional)
382 *
383 *       Notes: None
384 *
385 *       File:  ss_pack.c
386 *
387 */
388   
389 S16 SPkF64
390 (
391 F64 val,                    /* value */
392 Buffer *mBuf                /* message buffer */
393 )
394 {
395
396    S16  ret;                /* return code */
397    S8   tmpArray[25];       /* temporary array */
398 #ifdef FCSPKINT             /* backward compatibility, packing order */
399    S32  tIdx = 24;          /* counters */
400    S32  kIdx = 0;           /* counters */
401    S8   pkArray[25];        /* packing array */
402 #endif /*FCSPKINT*/
403   
404    sprintf(tmpArray, "%.16le", val);
405
406 #ifndef FCSPKINT            /* backward compatibility, packing order */
407    ret = SAddPreMsgMult((Data*)tmpArray, (MsgLen) 25, mBuf);
408 #else
409    while(tIdx >= 0)
410    {
411       pkArray[kIdx] = tmpArray[tIdx];
412       tIdx--; kIdx++;
413    }
414    ret = SAddPreMsgMult((Data*)pkArray, (MsgLen) 25, mBuf);
415 #endif
416
417
418 #if (ERRCLASS & ERRCLS_ADD_RES)
419    if (ret != ROK)
420       SSLOGERROR(ERRCLS_ADD_RES, ESS249, (ErrVal)ret, "SAddPreMsgMult() failed");
421 #endif
422    return (ret);
423
424 } /* end of SPkF64 */
425 #endif /* SS_FLOAT */
426 \f  
427 /*
428 *
429 *       Fun:   SUnpkS8
430 *
431 *       Desc:  This function unpacks a signed 8 bit value from a message.
432 *
433 *       Ret:   ROK      - ok
434 *
435 *       Notes: None
436 *
437 *       File:  ss_pack.c
438 *
439 */
440   
441 S16 SUnpkS8
442 (
443 S8 *val,                    /* pointer to value */
444 Buffer *mBuf                /* message buffer */
445 )
446 {
447    Data tmp;                /* temporary value */
448    S16 ret;                 /* return code */
449
450 /* ss021.103 - Addition of data pointer check */
451 #if (ERRCLASS & ERRCLS_INT_PAR)
452    /* check data pointer */
453    if (!val)
454    {
455       SSLOGERROR(ERRCLS_INT_PAR, ESS250, ERRZERO, "SUnpkS8 : Null value");
456       return RFAILED;
457    }
458 #endif /* ERRCLASS & ERRCLS_INT_PAR */
459
460    ret = SRemPreMsg(&tmp, mBuf);
461 #if (ERRCLASS & ERRCLS_DEBUG)
462    if (ret != ROK)
463       SSLOGERROR(ERRCLS_DEBUG, ESS251, (ErrVal)ret, "SRemPreMsg() failed");
464 #endif
465    *val = (S8) tmp;
466    return (ret);
467 } /* end of SUnpkS8 */
468   
469 \f  
470 /*
471 *
472 *       Fun:   oduPackUInt8
473 *
474 *       Desc:  This function unpacks an unsigned 8 bit value from a message.
475 *
476 *       Ret:   ROK      - ok
477 *
478 *       Notes: None
479 *
480 *       File:  ss_pack.c
481 *
482 */
483   
484 S16 oduPackUInt8
485 (
486 uint8_t *val,                    /* pointer to value */
487 Buffer *mBuf                /* message buffer */
488 )
489 {
490    Data tmp;                /* temporary value */
491    S16 ret;                 /* return code */
492
493 /* ss021.103 - Addition of data pointer check */
494 #if (ERRCLASS & ERRCLS_INT_PAR)
495    /* check data pointer */
496    if (!val)
497    {
498       SSLOGERROR(ERRCLS_INT_PAR, ESS252, ERRZERO, "oduPackUInt8 : Null value");
499       return RFAILED;
500    }
501 #endif /* ERRCLASS & ERRCLS_INT_PAR */
502
503    ret = SRemPreMsg(&tmp, mBuf);
504 #if (ERRCLASS & ERRCLS_DEBUG)
505    if (ret != ROK)
506       SSLOGERROR(ERRCLS_DEBUG, ESS253, (ErrVal)ret, "SRemPreMsg() failed");
507 #endif
508    *val = (uint8_t) tmp;
509    return (ret);
510 } /* end of oduPackUInt8 */
511 \f  
512 /*
513 *
514 *       Fun:   SUnpkS16
515 *
516 *       Desc:  This function unpacks a signed 16 bit value from a message.
517 *
518 *       Ret:   ROK      - ok
519 *
520 *       Notes: None
521 *
522 *       File:  ss_pack.c
523 *
524 */
525   
526 S16 SUnpkS16
527 (
528 S16 *val,                   /* pointer to value */
529 Buffer *mBuf                /* message buffer */
530 )
531 {
532    uint16_t tmp16;               /* temporary value */
533    Data unpkArray[2];       /* unpacking array */
534    S16 ret;                 /* return code */
535
536 /* ss021.103 - Addition of data pointer check */
537 #if (ERRCLASS & ERRCLS_INT_PAR)
538    /* check data pointer */
539    if (!val)
540    {
541       SSLOGERROR(ERRCLS_INT_PAR, ESS254, ERRZERO, "SUnpkS16 : Null value");
542       return RFAILED;
543    }
544 #endif /* ERRCLASS & ERRCLS_INT_PAR */
545
546    ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf);
547 #if (ERRCLASS & ERRCLS_DEBUG)
548    if (ret != ROK)
549       SSLOGERROR(ERRCLS_DEBUG, ESS255, (ErrVal)ret, "SRemPreMsgMult() failed");
550 #endif
551    tmp16 = 0; 
552 #ifndef FCSPKINT            /* backward compatibility, packing order */
553    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
554    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
555 #else                       /* forward compatibility, packing order */
556    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
557    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
558 #endif
559    *val = (S16) tmp16;
560    return (ret);
561 } /* end of SUnpkS16 */
562   
563 \f  
564 /*
565 *
566 *       Fun:   oduPackUInt16
567 *
568 *       Desc:  This function unpacks an unsigned 16 bit value from a message.
569 *
570 *       Ret:   ROK      - ok
571 *
572 *       Notes: None
573 *
574 *       File:  ss_pack.c
575 *
576 */
577   
578 S16 oduPackUInt16
579 (
580 uint16_t *val,                   /* pointer to value */
581 Buffer *mBuf                /* message buffer */
582 )
583 {
584    uint16_t tmp16;               /* temporary value */
585    Data unpkArray[2];       /* unpacking array */
586    S16 ret;                 /* return code */
587
588 /* ss021.103 - Addition of data pointer check */
589 #if (ERRCLASS & ERRCLS_INT_PAR)
590    /* check data pointer */
591    if (!val)
592    {
593       SSLOGERROR(ERRCLS_INT_PAR, ESS256, ERRZERO, "oduPackUInt16 : Null value");
594       return RFAILED;
595    }
596 #endif /* ERRCLASS & ERRCLS_INT_PAR */
597
598    ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf);
599 #if (ERRCLASS & ERRCLS_DEBUG)
600    if (ret != ROK)
601       SSLOGERROR(ERRCLS_DEBUG, ESS257, (ErrVal)ret, "SRemPreMsgMult failed");
602 #endif
603    tmp16 = 0; 
604 #ifndef FCSPKINT            /* backward compatibility, packing order */
605    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
606    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
607 #else                       /* forward compatibility, packing order */
608    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
609    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
610 #endif
611    *val = tmp16;
612    return (ret);
613 } /* end of oduPackUInt16 */
614   
615 \f  
616 /*
617 *
618 *       Fun:   SUnpkS32
619 *
620 *       Desc:  This function unpacks a signed 32 bit value from a message.
621 *
622 *       Ret:   ROK      - ok
623 *
624 *       Notes: None
625 *
626 *       File:  ss_pack.c
627 *
628 */
629   
630 S16 SUnpkS32
631 (
632 S32 *val,                   /* pointer to value */
633 Buffer *mBuf                /* message buffer */
634 )
635 {
636    uint16_t tmp16;               /* temporary value */
637    uint32_t tmp32;               /* temporary value */
638    Data unpkArray[4];       /* unpacking array */
639    S16 ret;                 /* return code */
640
641 /* ss021.103 - Addition of data pointer check */
642 #if (ERRCLASS & ERRCLS_INT_PAR)
643    /* check data pointer */
644    if (!val)
645    {
646       SSLOGERROR(ERRCLS_INT_PAR, ESS258, ERRZERO, "SUnpkS32 : Null value");
647       return RFAILED;
648    }
649 #endif /* ERRCLASS & ERRCLS_INT_PAR */
650
651    ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf);
652 #if (ERRCLASS & ERRCLS_DEBUG)
653    if (ret != ROK)
654       SSLOGERROR(ERRCLS_DEBUG, ESS259, (ErrVal)ret, "SRemPreMsgMult() failed");
655 #endif
656    tmp16 = 0;
657    tmp32 = 0; 
658 #ifndef FCSPKINT            /* backward compatibility, packing order */
659    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[3]);
660    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[2]);
661    tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
662    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
663    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
664    tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
665 #else                       /* forward compatibility, packing order */
666    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
667    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
668    tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
669    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[2]);
670    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[3]);
671    tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
672 #endif
673    *val = (S32) tmp32;
674    return (ret);
675 } /* end of SUnpkS32 */
676   
677 \f  
678 /*
679 *
680 *       Fun:   oduPackUInt32
681 *
682 *       Desc:  This function unpacks an unsigned 32 bit value from a message.
683 *
684 *       Ret:   ROK      - ok
685 *
686 *       Notes: None
687 *
688 *       File:  ss_pack.c
689 *
690 */
691   
692 S16 oduPackUInt32
693 (
694 uint32_t *val,                   /* pointer to value */
695 Buffer *mBuf                /* message buffer */
696 )
697 {
698    uint16_t tmp16;               /* temporary value */
699    uint32_t tmp32;               /* temporary value */
700    Data unpkArray[4];       /* unpacking array */
701 #ifdef ERRCLASS
702    S16 ret;                 /* return code */
703 #endif /* ERRCLASS */
704
705 /* ss021.103 - Addition of data pointer check */
706 #if (ERRCLASS & ERRCLS_INT_PAR)
707    /* check data pointer */
708    if (!val)
709    {
710       SSLOGERROR(ERRCLS_INT_PAR, ESS260, ERRZERO, "oduPackUInt32 : Null value");
711       return RFAILED;
712    }
713 #endif /* ERRCLASS & ERRCLS_INT_PAR */
714
715    ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf);
716 #if (ERRCLASS & ERRCLS_DEBUG)
717    if (ret != ROK)
718       SSLOGERROR(ERRCLS_DEBUG, ESS261, (ErrVal)ret, "SRemPreMsgMult() failed");
719 #endif
720
721    tmp16 = 0;
722    tmp32 = 0; 
723 #ifndef FCSPKINT            /* backward compatibility, packing order */
724    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[3]);
725    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[2]);
726    tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
727    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
728    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
729    tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
730 #else                       /* forward compatibility, packing order */
731    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
732    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
733    tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
734    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[2]);
735    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[3]);
736    tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
737 #endif
738    *val = tmp32;
739    return (ret);
740 } /* end of oduPackUInt32 */
741
742 /*ss038.103  1. Added Floating point support*/
743 #ifdef SS_FLOAT
744 /*
745 *
746 *       Fun:   SUnpkF32
747 *
748 *       Desc:  This function unpacks an 32 bit ieee-754 format float value from a message.
749 *
750 *       Ret:   ROK      - ok
751 *
752 *       Notes: None
753 *
754 *       File:  ss_pack.c
755 *
756 */
757   
758 S16 SUnpkF32
759 (
760 F32 *val,                   /* pointer to value */
761 Buffer *mBuf                /* message buffer */
762 )
763 {
764    S16 ret;                 /* return code */
765    S8 tmpArray[15];         /* temporary array */
766 #ifndef FCSPKINT            /* backward compatibility, packing order */
767    S32 tIdx = 14;           /* temparory array index */
768    S32 kIdx = 0;            /* unpacking array index */
769    S8 unpkArray[15];        /* unpacking array */
770 #endif /* FCSPKINT */
771
772 #if (ERRCLASS & ERRCLS_INT_PAR)
773    /* check data pointer */
774    if (!val)
775    {
776       SSLOGERROR(ERRCLS_INT_PAR, ESS262, ERRZERO, "SUnpkF32 : Null value");
777       return RFAILED;
778    }
779 #endif /* ERRCLASS & ERRCLS_INT_PAR */
780
781    ret = SRemPreMsgMult((Data*)tmpArray, (MsgLen) 15, mBuf);
782 #if (ERRCLASS & ERRCLS_DEBUG)
783    if (ret != ROK)
784       SSLOGERROR(ERRCLS_DEBUG, ESS263, (ErrVal)ret, "SRemPreMsgMult() failed");
785 #endif
786
787 #ifndef FCSPKINT            /* backward compatibility, packing order */
788    while(tIdx >= 0)
789    {
790       unpkArray[kIdx] = tmpArray[tIdx];
791       tIdx--; kIdx++;
792    }
793    sscanf(unpkArray, "%f", val);
794 #else
795    sscanf(tmpArray, "%f", val);
796 #endif
797
798    return (ret);
799
800 } /* end of SUnpkF32 */
801
802 /*
803 *
804 *       Fun:   SUnpkF64
805 *
806 *       Desc:  This function unpacks an 64 bit ieee-754 format float value from a message.
807 *
808 *       Ret:   ROK      - ok
809 *
810 *       Notes: None
811 *
812 *       File:  ss_pack.c
813 *
814 */
815   
816 S16 SUnpkF64
817 (
818 F64 *val,                   /* pointer to value */
819 Buffer *mBuf                /* message buffer */
820 )
821 {
822
823    S16 ret;                 /* return code */
824    S8 tmpArray[25];         /* temporary array */
825 #ifndef FCSPKINT            /* backward compatibility, packing order */
826    S32 tIdx = 24;           /* temparory array index */
827    S32 kIdx = 0;            /* unpacking array index */
828    S8 unpkArray[25];        /* unpacking array */
829 #endif /* FCSPKINT */
830
831 #if (ERRCLASS & ERRCLS_INT_PAR)
832    /* check data pointer */
833    if (!val)
834    {
835       SSLOGERROR(ERRCLS_INT_PAR, ESS264, ERRZERO, "SUnpkF64 : Null value");
836       return RFAILED;
837    }
838 #endif /* ERRCLASS & ERRCLS_INT_PAR */
839
840    ret = SRemPreMsgMult((Data*)tmpArray, (MsgLen) 25, mBuf);
841 #if (ERRCLASS & ERRCLS_DEBUG)
842    if (ret != ROK)
843       SSLOGERROR(ERRCLS_DEBUG, ESS265, (ErrVal)ret, "SRemPreMsgMult() failed");
844 #endif
845
846 #ifndef FCSPKINT            /* backward compatibility, packing order */
847    while(tIdx >= 0)
848    {
849       unpkArray[kIdx] = tmpArray[tIdx];
850       tIdx--; kIdx++;
851    }
852    sscanf(unpkArray, "%lf", val);
853 #else
854    sscanf(tmpArray, "%lf", val);
855 #endif
856
857    return (ret);
858
859 } /* end of SUnpkF64 */
860 #endif /* SS_FLOAT */
861 \f
862 /**********************************************************************
863          End of file
864  **********************************************************************/