58916e4f6963b793cd6757b5b8de82df6e16b595
[o-du/l2.git] / src / cm / cm_tkns.h
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
19 /********************************************************************20**
20   
21      Name:     general layer
22   
23      Type:     C include file
24   
25      Desc:     defines , required by cm_tkns.c and cm_tkns.h
26    
27      File:     cm_tkns.h
28   
29 *********************************************************************21*/
30
31 #ifndef __CMTKNSH
32 #define __CMTKNSH
33
34 \f
35 /* defines */
36 #define cmPkTknPres(x, mBuf)       cmPkTknUInt8(x, mBuf)
37
38 #define cmUnpkTknPres(x, mBuf)     cmUnpkTknUInt8(x, mBuf)
39
40
41 /* packing and unpacking for token bit strings */
42
43 #define CMPKTKNBSTR(tknStr, mBuf)                   \
44 {                                                  \
45    Cntr i;                                         \
46    Cntr len;                                       \
47                                                    \
48    if(tknStr->pres)                                \
49    {                                               \
50       if (tknStr->len % 8)                         \
51          len = (tknStr->len/8 ) + 1;               \
52       else                                         \
53          len = (tknStr->len/8 );                   \
54                                                    \
55       /* Value */                                  \
56       for (i = 0; i < (S16) len; i++)              \
57       {                                            \
58          CMCHKPK(oduUnpackUInt8, tknStr->val[i], mBuf);     \
59       }                                            \
60                                                    \
61       /* Length */                                 \
62       CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf);           \
63    }                                               \
64                                                    \
65    /* Token Header */                              \
66    CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf);             \
67 }
68
69 #define CMUNPKTKNBSTR(tknStr, mBuf)                                 \
70 {                                                                  \
71    Cntr i;                                                         \
72    Cntr len;                                                       \
73                                                                    \
74    /* Token Header */                                              \
75    CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf);                        \
76                                                                    \
77    if(tknStr->pres)                                                \
78    {                                                               \
79      /* Length */                                                  \
80       CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf);                      \
81                                                                    \
82       if (tknStr->len % 8)                                         \
83          len = (tknStr->len/8 ) + 1;                               \
84       else                                                         \
85          len = (tknStr->len/8 );                                   \
86                                                                    \
87       /* Value */                                                  \
88       for (i = 1; i <= (S16) len; i++)                             \
89       {                                                            \
90          CMCHKUNPK(oduPackUInt8, &tknStr->val[len - i], mBuf);          \
91       }                                                            \
92    }                                                               \
93                                                                    \
94 }
95
96 #endif /* __CMTKNSH */
97
98 \f  
99 /********************************************************************30**
100   
101          End of file
102 **********************************************************************/