MIH_C_Types.h 144 KB
Newer Older
hrizi's avatar
   
hrizi committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*******************************************************************************
    OpenAirInterface 
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is 
   included in this distribution in the file called "COPYING". If not, 
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr
  
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE

 *******************************************************************************/
29
30
31
32
33
34
35
36
37
38
39
40
41
/*! \file MIH_C_Types.h
 * \brief This file defines the 802.21 types or constants defined in Std 802.21-2008 Table F1, F2, F3,
 *         F4, F5, F6, F7, F8, F9, F12, F13, F19, F20, F22, L2. Some tables may be not implemented at all.
 * \author BRIZZOLA Davide, GAUTHIER Lionel, MAUREL Frederic, WETTERWALD Michelle
 * \date 2012
 * \version
 * \note
 * \bug
 * \warning
 */
#ifndef __MIH_C_LINK_TYPES_H__
#define __MIH_C_LINK_TYPES_H__
#include <sys/types.h>
42
#include <linux/types.h>
43

Cedric Roux's avatar
Cedric Roux committed
44
45
46
47
#ifndef USER_MODE
# define USER_MODE
# warning "Hack USER_MODE"
#endif
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//-----------------------------------------------------------------------------
#include "MIH_C_Link_Constants.h"
#include "MIH_C_bit_buffer.h"
//-----------------------------------------------------------------------------
#define MIH_C_DEBUG_SERIALIZATION 1
#define MIH_C_DEBUG_DESERIALIZATION 1
//-----------------------------------------------------------------------------
#define STR(x)        #x

/** \defgroup MIH_C_INTERFACE 802.21 interface
 *
 */


//-----------------------------------------------------------------------------
// STD 802.21-2008 Table F.1 Basic data types
//-----------------------------------------------------------------------------


//----------------------- BITMAP(size) ----------------------------------------
/*! \var typedef u_int8_t                             MIH_C_BITMAP8_T;
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A type definition for u_int8_t.
 */
typedef u_int8_t                                                              MIH_C_BITMAP8_T;
/*! \var typedef u_int16_t                             MIH_C_BITMAP16_T;
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A type definition for u_int16_t.
 */
typedef u_int16_t                                                             MIH_C_BITMAP16_T;
/*! \struct  MIH_C_BITMAP24_T
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 */
typedef struct MIH_C_BITMAP24 {u_int8_t val[3];}__attribute__((__packed__))   MIH_C_BITMAP24_T;
/*! \var typedef u_int32_t                             MIH_C_BITMAP32_T;
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A type definition for u_int32_t.
 */
typedef u_int32_t                                                             MIH_C_BITMAP32_T;
/*! \var typedef u_int64_t                             MIH_C_BITMAP64_T;
 * \brief A type definition for u_int64_t.
 */
typedef u_int64_t                                                             MIH_C_BITMAP64_T;
/*! \struct  MIH_C_BITMAP128_T
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 */
typedef struct MIH_C_BITMAP128 {u_int64_t val[2];}__attribute__((__packed__)) MIH_C_BITMAP128_T;
/*! \struct  MIH_C_BITMAP256_T
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 */
typedef struct MIH_C_BITMAP256 {u_int64_t val[4];}__attribute__((__packed__)) MIH_C_BITMAP256_T;

#ifdef MIH_C_F1_BASIC_DATA_TYPES_CODEC_C
    /*! \def TYPEDEF_BITMAP6(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_BITMAP8_T.
     */
    #define TYPEDEF_BITMAP6(DATA_TYPE_NAME)             typedef MIH_C_BITMAP8_T  DATA_TYPE_NAME  ## _T;\
106
107
        void MIH_C_BITMAP8_encode(Bit_Buffer_t* bbP, MIH_C_BITMAP8_T* dataP);\
        void MIH_C_BITMAP8_decode(Bit_Buffer_t* bbP, MIH_C_BITMAP8_T* dataP);\
108
109
110
        inline unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP) {\
            return sprintf(buffP, "0x%02X", *bitmapP);\
        };\
111
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {\
112
            MIH_C_BITMAP8_encode(bbP, bitmapP);};\
113
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP8_decode(bbP, bitmapP);};
114
115
116
117
118
119

    /*! \def TYPEDEF_BITMAP8(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_BITMAP8_T.
     */
    #define TYPEDEF_BITMAP8(DATA_TYPE_NAME)             typedef MIH_C_BITMAP8_T  DATA_TYPE_NAME  ## _T;\
120
121
        void MIH_C_BITMAP8_encode(Bit_Buffer_t* bbP, MIH_C_BITMAP8_T* dataP);\
        void MIH_C_BITMAP8_decode(Bit_Buffer_t* bbP, MIH_C_BITMAP8_T* dataP);\
122
123
124
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP) {\
            return sprintf(buffP, "0x%02X", *bitmapP);\
        };\
125
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {\
126
            MIH_C_BITMAP8_encode(bbP, bitmapP);};\
127
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP8_decode(bbP, bitmapP);};
128
129
130
131
132
133

    /*! \def TYPEDEF_BITMAP16(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_BITMAP16_T.
     */
    #define TYPEDEF_BITMAP16(DATA_TYPE_NAME)            typedef MIH_C_BITMAP16_T DATA_TYPE_NAME  ## _T;\
134
135
        void MIH_C_BITMAP16_encode(Bit_Buffer_t* bbP, MIH_C_BITMAP16_T* dataP);\
        void MIH_C_BITMAP16_decode(Bit_Buffer_t* bbP, MIH_C_BITMAP16_T* dataP);\
136
137
138
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP) {\
            return sprintf(buffP, "0x%04X", *bitmapP);\
        };\
139
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {\
140
            MIH_C_BITMAP16_encode(bbP, bitmapP);};\
141
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP16_decode(bbP, bitmapP);};
142
143
144
145
146
147

    /*! \def TYPEDEF_BITMAP20(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_BITMAP24_T.
     */
    #define TYPEDEF_BITMAP20(DATA_TYPE_NAME)            typedef MIH_C_BITMAP24_T DATA_TYPE_NAME  ## _T;\
148
149
        void MIH_C_BITMAP24_encode(Bit_Buffer_t* bbP, MIH_C_BITMAP24_T* dataP);\
        void MIH_C_BITMAP24_decode(Bit_Buffer_t* bbP, MIH_C_BITMAP24_T* dataP);\
150
151
152
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP) {\
            return sprintf(buffP, "0x%02X%02X%02X", bitmapP->val[0], bitmapP->val[1], bitmapP->val[2]);\
        };\
153
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {\
154
            MIH_C_BITMAP24_encode(bbP, bitmapP);};\
155
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP24_decode(bbP, bitmapP);};
156
157
158
159
160
161

    /*! \def TYPEDEF_BITMAP32(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_BITMAP32_T.
     */
    #define TYPEDEF_BITMAP32(DATA_TYPE_NAME)            typedef MIH_C_BITMAP32_T DATA_TYPE_NAME  ## _T;\
162
163
        void MIH_C_BITMAP32_encode(Bit_Buffer_t* bbP, MIH_C_BITMAP32_T* dataP);\
        void MIH_C_BITMAP32_decode(Bit_Buffer_t* bbP, MIH_C_BITMAP32_T* dataP);\
164
165
166
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP) {\
            return sprintf(buffP, "0x%08X", *bitmapP);\
        };\
167
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {\
168
            MIH_C_BITMAP32_encode(bbP, bitmapP);};\
169
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP32_decode(bbP, bitmapP);};
170
171
172
173
174
175

    /*! \def TYPEDEF_BITMAP64(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_BITMAP64_T.
     */
    #define TYPEDEF_BITMAP64(DATA_TYPE_NAME)            typedef MIH_C_BITMAP64_T DATA_TYPE_NAME  ## _T;\
176
177
        void MIH_C_BITMAP64_encode(Bit_Buffer_t* bbP, MIH_C_BITMAP64_T* dataP);\
        void MIH_C_BITMAP64_decode(Bit_Buffer_t* bbP, MIH_C_BITMAP64_T* dataP);\
178
179
180
181
182
183
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP) {\
            unsigned int buffer_index = 0;\
            buffer_index = sprintf(buffP, "0x%08x", (MIH_C_UNSIGNED_INT4_T)(*bitmapP>>32));\
            buffer_index = sprintf(&buffP[buffer_index], "%08x", (MIH_C_UNSIGNED_INT4_T)(*bitmapP));\
            return buffer_index;\
        };\
184
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {\
185
            MIH_C_BITMAP64_encode(bbP, bitmapP);};\
186
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP64_decode(bbP, bitmapP);};
187
188
189
190
191
192

    /*! \def TYPEDEF_BITMAP128(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_BITMAP128_T.
     */
    #define TYPEDEF_BITMAP128(DATA_TYPE_NAME)           typedef MIH_C_BITMAP128_T DATA_TYPE_NAME  ## _T;\
193
194
195
196
        void MIH_C_BITMAP128_encode(Bit_Buffer_t* bbP, MIH_C_BITMAP128_T* dataP);\
        void MIH_C_BITMAP128_decode(Bit_Buffer_t* bbP, MIH_C_BITMAP128_T* dataP);\
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP128_encode(bbP, bitmapP);};\
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP128_decode(bbP, bitmapP);};
197
198
199
200
201
202

    /*! \def TYPEDEF_BITMAP256(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_BITMAP256_T.
     */
    #define TYPEDEF_BITMAP256(DATA_TYPE_NAME)           typedef MIH_C_BITMAP256_T DATA_TYPE_NAME  ## _T;\
203
204
205
206
        void MIH_C_BITMAP256_encode(Bit_Buffer_t* bbP, MIH_C_BITMAP256_T* dataP);\
        void MIH_C_BITMAP256_decode(Bit_Buffer_t* bbP, MIH_C_BITMAP256_T* dataP);\
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP256_encode(bbP, bitmapP);};\
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *bitmapP) {MIH_C_BITMAP256_decode(bbP, bitmapP);};
207
208
209
210

#else
    #define TYPEDEF_BITMAP6(DATA_TYPE_NAME)             typedef MIH_C_BITMAP8_T  DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP);\
211
212
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);
213
214
215

    #define TYPEDEF_BITMAP8(DATA_TYPE_NAME)             typedef MIH_C_BITMAP8_T  DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP);\
216
217
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);
218
219
220

    #define TYPEDEF_BITMAP16(DATA_TYPE_NAME)            typedef MIH_C_BITMAP16_T DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP);\
221
222
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);
223
224
225

    #define TYPEDEF_BITMAP20(DATA_TYPE_NAME)            typedef MIH_C_BITMAP24_T DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP);\
226
227
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);
228
229
230

    #define TYPEDEF_BITMAP32(DATA_TYPE_NAME)            typedef MIH_C_BITMAP32_T DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP);\
231
232
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);
233
234
235

    #define TYPEDEF_BITMAP64(DATA_TYPE_NAME)            typedef MIH_C_BITMAP64_T DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *bitmapP, char* buffP);\
236
237
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);
238
239

    #define TYPEDEF_BITMAP128(DATA_TYPE_NAME)           typedef MIH_C_BITMAP128_T DATA_TYPE_NAME  ## _T;\
240
241
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);\
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);
242
243

    #define TYPEDEF_BITMAP256(DATA_TYPE_NAME)           typedef MIH_C_BITMAP256_T DATA_TYPE_NAME  ## _T;\
244
245
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);\
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T* bitmapP);
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#endif

#define BITMAP6(VAR_NAME)                                   MIH_C_BITMAP8_T   VAR_NAME;
#define BITMAP8(VAR_NAME)                                   MIH_C_BITMAP8_T   VAR_NAME;
#define BITMAP16(VAR_NAME)                                  MIH_C_BITMAP16_T  VAR_NAME;
#define BITMAP20(VAR_NAME)                                  MIH_C_BITMAP24_T  VAR_NAME;
#define BITMAP24(VAR_NAME)                                  MIH_C_BITMAP24_T  VAR_NAME;
#define BITMAP32(VAR_NAME)                                  MIH_C_BITMAP32_T  VAR_NAME;
#define BITMAP64(VAR_NAME)                                  MIH_C_BITMAP64_T  VAR_NAME;
#define BITMAP128(VAR_NAME)                                 MIH_C_BITMAP128_T VAR_NAME;
#define BITMAP256(VAR_NAME)                                 MIH_C_BITMAP256_T VAR_NAME;

//----------------------- CHOICE(DATATYPE1, DATATYPE2[,...]) ------------------
/*! \var typedef u_int8_t                             MIH_C_CHOICE_T;
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A type definition for u_int8_t.
 */
typedef u_int8_t                           MIH_C_CHOICE_T;

//----------------------- INTEGER(size) ---------------------------------------
/*! \var typedef int8_t                             MIH_C_INTEGER1_T;
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A type definition for int8_t.
 */
typedef int8_t                             MIH_C_INTEGER1_T;
/*! \var typedef int16_t                             MIH_C_INTEGER2_T;
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A type definition for int16_t.
 */
typedef int16_t                            MIH_C_INTEGER2_T;
/*! \var typedef int32_t                             MIH_C_INTEGER4_T;
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A type definition for int32_t.
 */
typedef int32_t                            MIH_C_INTEGER4_T;
/*! \var typedef int64_t                             MIH_C_INTEGER8_T;
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A type definition for int64_t.
 */
typedef int64_t                            MIH_C_INTEGER8_T;

#ifdef MIH_C_F1_BASIC_DATA_TYPES_CODEC_C
    /*! \def TYPEDEF_INTEGER1(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_INTEGER1_T.
     */
    #define TYPEDEF_INTEGER1(DATA_TYPE_NAME)            typedef MIH_C_INTEGER1_T   DATA_TYPE_NAME  ## _T;\
293
294
        void MIH_C_INTEGER1_encode(Bit_Buffer_t* bbP, MIH_C_INTEGER1_T* dataP);\
        void MIH_C_INTEGER1_decode(Bit_Buffer_t* bbP, MIH_C_INTEGER1_T* dataP);\
295
296
297
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP) {\
            return sprintf(buffP, "0x%02X", *dataP);\
        };\
298
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
299
            MIH_C_INTEGER1_encode(bbP, (MIH_C_INTEGER1_T*)dataP);};\
300
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
301
302
303
304
305
306
307
308
            MIH_C_INTEGER1_decode(bbP, (MIH_C_INTEGER1_T*)dataP);\
        };

    /*! \def TYPEDEF_INTEGER2(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_INTEGER2_T.
     */
    #define TYPEDEF_INTEGER2(DATA_TYPE_NAME)            typedef MIH_C_INTEGER2_T   DATA_TYPE_NAME  ## _T;\
309
310
        void MIH_C_INTEGER2_encode(Bit_Buffer_t* bbP, MIH_C_INTEGER2_T* dataP);\
        void MIH_C_INTEGER2_decode(Bit_Buffer_t* bbP, MIH_C_INTEGER2_T* dataP);\
311
312
313
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP) {\
            return sprintf(buffP, "0x%04X", *dataP);\
        };\
314
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
315
            MIH_C_INTEGER2_encode(bbP, (MIH_C_INTEGER2_T*)dataP);};\
316
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
317
318
319
320
321
322
323
324
            MIH_C_INTEGER2_decode(bbP, (MIH_C_INTEGER2_T*)dataP);\
        };

    /*! \def TYPEDEF_INTEGER4(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_INTEGER4_T.
     */
    #define TYPEDEF_INTEGER4(DATA_TYPE_NAME)            typedef MIH_C_INTEGER4_T   DATA_TYPE_NAME  ## _T;\
325
326
        void MIH_C_INTEGER4_encode(Bit_Buffer_t* bbP, MIH_C_INTEGER4_T* dataP);\
        void MIH_C_INTEGER4_decode(Bit_Buffer_t* bbP, MIH_C_INTEGER4_T* dataP);\
327
328
329
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP) {\
            return sprintf(buffP, "0x%08X", (MIH_C_INTEGER4_T)*dataP);\
        };\
330
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
331
            MIH_C_INTEGER4_encode(bbP, (MIH_C_INTEGER4_T*)dataP);};\
332
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
333
334
335
336
337
338
339
340
            MIH_C_INTEGER4_decode(bbP, (MIH_C_INTEGER4_T*)dataP);\
        };

    /*! \def TYPEDEF_INTEGER8(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_INTEGER48T.
     */
    #define TYPEDEF_INTEGER8(DATA_TYPE_NAME)            typedef MIH_C_INTEGER8_T   DATA_TYPE_NAME  ## _T;\
341
342
        void MIH_C_INTEGER8_encode(Bit_Buffer_t* bbP, MIH_C_INTEGER8_T* dataP);\
        void MIH_C_INTEGER8_decode(Bit_Buffer_t* bbP, MIH_C_INTEGER8_T* dataP);\
343
344
345
346
347
348
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP) {\
            unsigned int buffer_index = 0;\
            buffer_index = sprintf(buffP, "0x%08x", (MIH_C_UNSIGNED_INT4_T)(*dataP>>32));\
            buffer_index = sprintf(&buffP[buffer_index], "%08x", (MIH_C_UNSIGNED_INT4_T)(*dataP));\
            return buffer_index;\
        };\
349
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
350
            MIH_C_INTEGER8_encode(bbP, (MIH_C_INTEGER8_T*)dataP);};\
351
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
352
353
354
355
356
            MIH_C_INTEGER8_decode(bbP, (MIH_C_INTEGER8_T*)dataP);\
        };
#else
    #define TYPEDEF_INTEGER1(DATA_TYPE_NAME)            typedef MIH_C_INTEGER1_T   DATA_TYPE_NAME  ## _T;\
        extern unsigned int  DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP);\
357
358
        void   DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void   DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
359
360
361

    #define TYPEDEF_INTEGER2(DATA_TYPE_NAME)            typedef MIH_C_INTEGER2_T   DATA_TYPE_NAME  ## _T;\
        extern unsigned int  DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP);\
362
363
        void   DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void   DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
364
365
366

    #define TYPEDEF_INTEGER4(DATA_TYPE_NAME)            typedef MIH_C_INTEGER4_T   DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP);\
367
368
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
369
370
371

    #define TYPEDEF_INTEGER8(DATA_TYPE_NAME)            typedef MIH_C_INTEGER8_T   DATA_TYPE_NAME  ## _T;\
        extern unsigned int  DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP);\
372
373
        void   DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void   DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
#endif

/*! \def INTEGER1(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_INTEGER1_T.
 */
#define INTEGER1(VAR_NAME)                                  MIH_C_INTEGER1_T   VAR_NAME;
/*! \def INTEGER2(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_INTEGER2_T.
 */
#define INTEGER2(VAR_NAME)                                  MIH_C_INTEGER2_T   VAR_NAME;
/*! \def INTEGER4(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_INTEGER4_T.
 */
#define INTEGER4(VAR_NAME)                                  MIH_C_INTEGER4_T   VAR_NAME;
/*! \def INTEGER8(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_INTEGER8_T.
 */
#define INTEGER8(VAR_NAME)                                  MIH_C_INTEGER8_T   VAR_NAME;


//----------------------- UNSIGNED_INT(size) ----------------------------------
/*! \var typedef int8_t                     MIH_C_UNSIGNED_INT1_T;
 * \brief A type definition for int8_t.
 */
typedef u_int8_t                           MIH_C_UNSIGNED_INT1_T;
/*! \var u_int16_t                          MIH_C_UNSIGNED_INT2_T
 * \brief A type definition for u_int16_t.
 */
typedef u_int16_t                          MIH_C_UNSIGNED_INT2_T;
/*! \var typedef u_int32_t                  MIH_C_UNSIGNED_INT4_T;
 * \brief A type definition for u_int32_t.
 */
typedef u_int32_t                          MIH_C_UNSIGNED_INT4_T;
/*! \var u_int64_t                          MIH_C_UNSIGNED_INT8_T;
 * \brief A type definition for u_int64_t.
 */
typedef u_int64_t                          MIH_C_UNSIGNED_INT8_T;

#ifdef MIH_C_F1_BASIC_DATA_TYPES_CODEC_C
    /*! \def TYPEDEF_UNSIGNED_INT1(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_UNSIGNED_INT1_T.
     */
    #define TYPEDEF_UNSIGNED_INT1(DATA_TYPE_NAME)            typedef MIH_C_UNSIGNED_INT1_T   DATA_TYPE_NAME  ## _T;\
422
423
        void MIH_C_UNSIGNED_INT1_encode(Bit_Buffer_t* bbP, MIH_C_UNSIGNED_INT1_T* dataP);\
        void MIH_C_UNSIGNED_INT1_decode(Bit_Buffer_t* bbP, MIH_C_UNSIGNED_INT1_T* dataP);\
424
425
426
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP) {\
            return sprintf(buffP, "0x%02X", *dataP);\
        };\
427
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
428
            MIH_C_UNSIGNED_INT1_encode(bbP, dataP);};\
429
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
430
431
432
433
434
435
436
437
            MIH_C_UNSIGNED_INT1_decode(bbP, dataP);\
        };

    /*! \def TYPEDEF_UNSIGNED_INT2(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_UNSIGNED_INT2_T.
     */
    #define TYPEDEF_UNSIGNED_INT2(DATA_TYPE_NAME)            typedef MIH_C_UNSIGNED_INT2_T   DATA_TYPE_NAME  ## _T;\
438
439
        void MIH_C_UNSIGNED_INT2_encode(Bit_Buffer_t* bbP, MIH_C_UNSIGNED_INT2_T* dataP);\
        void MIH_C_UNSIGNED_INT2_decode(Bit_Buffer_t* bbP, MIH_C_UNSIGNED_INT2_T* dataP);\
440
441
442
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP) {\
            return sprintf(buffP, "0x%04X", *dataP);\
        };\
443
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
444
            MIH_C_UNSIGNED_INT2_encode(bbP, dataP);};\
445
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
446
447
448
449
450
451
452
453
            MIH_C_UNSIGNED_INT2_decode(bbP, dataP);\
        };

    /*! \def TYPEDEF_UNSIGNED_INT4(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_UNSIGNED_INT4_T.
     */
    #define TYPEDEF_UNSIGNED_INT4(DATA_TYPE_NAME)            typedef MIH_C_UNSIGNED_INT4_T   DATA_TYPE_NAME  ## _T;\
454
455
        void MIH_C_UNSIGNED_INT4_encode(Bit_Buffer_t* bbP, MIH_C_UNSIGNED_INT4_T* dataP);\
        void MIH_C_UNSIGNED_INT4_decode(Bit_Buffer_t* bbP, MIH_C_UNSIGNED_INT4_T* dataP);\
456
457
458
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP) {\
            return sprintf(buffP, "0x%08X", *dataP);\
        };\
459
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
460
            MIH_C_UNSIGNED_INT4_encode(bbP, dataP);};\
461
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
462
463
464
465
466
467
468
469
            MIH_C_UNSIGNED_INT4_decode(bbP, dataP);\
        };

    /*! \def TYPEDEF_UNSIGNED_INT8(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a MIH_C_UNSIGNED_INT8_T.
     */
    #define TYPEDEF_UNSIGNED_INT8(DATA_TYPE_NAME)            typedef MIH_C_UNSIGNED_INT8_T   DATA_TYPE_NAME  ## _T;\
470
471
        void MIH_C_UNSIGNED_INT8_encode(Bit_Buffer_t* bbP, MIH_C_UNSIGNED_INT8_T* dataP);\
        void MIH_C_UNSIGNED_INT8_decode(Bit_Buffer_t* bbP, MIH_C_UNSIGNED_INT8_T* dataP);\
472
473
474
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP) {\
            return sprintf(buffP, "0x%16X", *dataP);\
        };\
475
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
476
            MIH_C_UNSIGNED_INT8_encode(bbP, dataP);};\
477
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
478
479
480
481
482
            MIH_C_UNSIGNED_INT8_decode(bbP, dataP);\
        };
#else
    #define TYPEDEF_UNSIGNED_INT1(DATA_TYPE_NAME)            typedef MIH_C_UNSIGNED_INT1_T   DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP);\
483
484
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
485
486
487

    #define TYPEDEF_UNSIGNED_INT2(DATA_TYPE_NAME)            typedef MIH_C_UNSIGNED_INT2_T   DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP);\
488
489
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
490
491
492

    #define TYPEDEF_UNSIGNED_INT4(DATA_TYPE_NAME)            typedef MIH_C_UNSIGNED_INT4_T   DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP);\
493
494
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
495
496
497

    #define TYPEDEF_UNSIGNED_INT8(DATA_TYPE_NAME)            typedef MIH_C_UNSIGNED_INT8_T   DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* buffP);\
498
499
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
#endif

/*! \def UNSIGNED_INT1(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_UNSIGNED_INT1_T.
 */
#define UNSIGNED_INT1(VAR_NAME)                             MIH_C_UNSIGNED_INT1_T VAR_NAME;
/*! \def UNSIGNED_INT2(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_UNSIGNED_INT2_T.
 */
#define UNSIGNED_INT2(VAR_NAME)                             MIH_C_UNSIGNED_INT2_T VAR_NAME;
/*! \def UNSIGNED_INT4(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_UNSIGNED_INT4_T.
 */
#define UNSIGNED_INT4(VAR_NAME)                             MIH_C_UNSIGNED_INT4_T VAR_NAME;
/*! \def UNSIGNED_INT8(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_UNSIGNED_INT8_T.
 */
#define UNSIGNED_INT8(VAR_NAME)                             MIH_C_UNSIGNED_INT8_T VAR_NAME;

//----------------------- LIST(DATATYPE) --------------------------------------
void      MIH_C_LIST_LENGTH_encode(Bit_Buffer_t *bbP, u_int16_t lengthP);
void      MIH_C_LIST_LENGTH_decode(Bit_Buffer_t *bbP, u_int16_t *lengthP);
u_int16_t MIH_C_LIST_LENGTH_get_encode_length(u_int16_t lengthP);

#ifdef MIH_C_F1_BASIC_DATA_TYPES_CODEC_C
    /*! \def TYPEDEF_LIST(DATA_TYPE_NAME, MAX_LENGTH)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a LIST of MAX_LENGTH elements of DATA_TYPE_NAME type, and its functions for de/serializing this type.
     */
#define TYPEDEF_LIST(DATA_TYPE_NAME, MAX_LENGTH)    typedef  struct DATA_TYPE_NAME ## _LIST { u_int16_t length; DATA_TYPE_NAME ## _T val[MAX_LENGTH];} DATA_TYPE_NAME ## _LIST_T;\
    extern void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *val);\
    extern void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *val);\
    extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *val, char* bufP);\
    unsigned int DATA_TYPE_NAME ## _LIST2String(DATA_TYPE_NAME ## _LIST_T *listP, char* bufP) {\
        int index = 0;\
        unsigned int buffer_index = 0;\
        while ((index <  listP->length) && (index < MAX_LENGTH)){\
            buffer_index += sprintf(&bufP[buffer_index], "%s (%d) = ", STR(DATA_TYPE_NAME) , index);\
            buffer_index += DATA_TYPE_NAME ## 2String(&listP->val[index], &bufP[buffer_index]);\
            buffer_index += sprintf(&bufP[buffer_index], " ");\
            index = index + 1;\
        }\
        return buffer_index;\
    };\
548
    void DATA_TYPE_NAME ## _LIST_decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _LIST_T *listP) {\
549
550
        int index = 0;\
        MIH_C_LIST_LENGTH_decode(bbP, &listP->length);\
551
        if (listP->length > MAX_LENGTH) {printf("[MIH_C] ERROR DATA_TYPE_NAME ## _LIST_decode num elements in list out of bounds: %d, max is %d\n", listP->length, MAX_LENGTH);\
552
553
554
555
556
557
        } else {\
            while ((index <  listP->length) && (index < MAX_LENGTH)){\
                DATA_TYPE_NAME ## _decode(bbP, &listP->val[index++]);\
            }\
        }\
    };\
558
    void DATA_TYPE_NAME ## _LIST_encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _LIST_T *listP) {\
559
560
        int index = 0;\
        if (listP->length > MAX_LENGTH) {\
561
            printf("[MIH_C] ERROR DATA_TYPE_NAME ## _LIST_encode num elements in list out of bounds: %d, max is %d\n", listP->length, MAX_LENGTH);\
562
563
564
565
566
567
        } else {\
            MIH_C_LIST_LENGTH_encode(bbP, listP->length);\
            while (index <  listP->length) {\
                DATA_TYPE_NAME ## _encode(bbP, &listP->val[index++]);\
            }\
        }\
gauthier's avatar
gauthier committed
568
    };\
569
    void DATA_TYPE_NAME ## _LIST_init(DATA_TYPE_NAME ## _LIST_T *listP) {\
gauthier's avatar
gauthier committed
570
571
        listP->length = 0;\
        memset(listP->val, 0, MAX_LENGTH*sizeof(DATA_TYPE_NAME ## _T));\
572
573
574
575
576
577
    };

#else
#define TYPEDEF_LIST(DATA_TYPE_NAME, MAX_LENGTH)    typedef  struct DATA_TYPE_NAME ## _LIST { u_int16_t length; DATA_TYPE_NAME ## _T val[MAX_LENGTH];} DATA_TYPE_NAME ## _LIST_T;\
    extern unsigned int DATA_TYPE_NAME ## _LIST2String(DATA_TYPE_NAME ## _LIST_T *listP, char* bufP);\
    extern void         DATA_TYPE_NAME ## _LIST_decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _LIST_T *listP);\
gauthier's avatar
gauthier committed
578
579
    extern void         DATA_TYPE_NAME ## _LIST_encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _LIST_T *listP);\
    extern void         DATA_TYPE_NAME ## _LIST_init(DATA_TYPE_NAME ## _LIST_T *listP);
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
#endif
#define LIST(DATA_TYPE_NAME, VAR_NAME)              DATA_TYPE_NAME ## _LIST_T VAR_NAME ## _list;



//----------------------- NULL ------------------------------------------------
#define MIH_C_NULL_T     u_int8_t

//----------------------- OCTET(size) -----------------------------------------
#ifdef MIH_C_F1_BASIC_DATA_TYPES_CODEC_C
    /*! \def TYPEDEF_OCTET(DATA_TYPE_NAME, MAX_LENGTH)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a LIST of MAX_LENGTH octet elements, and its functions for de/serializing this type.
     */
#define TYPEDEF_OCTET(DATA_TYPE_NAME, LENGTH)       typedef struct DATA_TYPE_NAME {u_int8_t val[LENGTH];} DATA_TYPE_NAME  ## _T;\
    unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* bufP) {\
        int index = 0;\
        unsigned int buffer_index = 0;\
        while ( index <  LENGTH ){\
            buffer_index += sprintf(&bufP[buffer_index], "%02X", dataP->val[index]);\
            index = index + 1;\
        }\
        return buffer_index;\
    };\
604
605
    void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) { BitBuffer_readMem(bbP, &dataP->val[0], LENGTH);};\
    void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) { BitBuffer_writeMem(bbP, &dataP->val[0], LENGTH);};
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
#else
#define TYPEDEF_OCTET(DATA_TYPE_NAME, LENGTH)       typedef struct DATA_TYPE_NAME {u_int8_t val[LENGTH];} DATA_TYPE_NAME  ## _T;\
    extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* bufP);\
    extern void         DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
    extern void         DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
#endif

//----------------------- SEQUENCE(DATATYPE1, DATATYPE2[,...]) : NO MACRO -----

//-----------------------------------------------------------------------------
// STD 802.21-2008 Table F.2 General data types
//-----------------------------------------------------------------------------

//----------------------- ENUMERATED ------------------------------------------
TYPEDEF_UNSIGNED_INT1(MIH_C_ENUMERATED)

#ifdef MIH_C_F2_GENERAL_DATA_TYPES_CODEC_C
    /*! \def TYPEDEF_ENUMERATED(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as MIH_C_ENUMERATED_T, and its functions for de/serializing this type.
     */
    #define TYPEDEF_ENUMERATED(DATA_TYPE_NAME)          typedef MIH_C_ENUMERATED_T  DATA_TYPE_NAME  ## _T;\
628
629
630
        void MIH_C_ENUMERATED_encode(Bit_Buffer_t* bbP, MIH_C_ENUMERATED_T* dataP);\
        void MIH_C_ENUMERATED_decode(Bit_Buffer_t* bbP, MIH_C_ENUMERATED_T* dataP);\
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
631
            MIH_C_ENUMERATED_encode(bbP, dataP);};\
632
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {MIH_C_ENUMERATED_decode(bbP, dataP);};
633
634
#else
    #define TYPEDEF_ENUMERATED(DATA_TYPE_NAME)          typedef MIH_C_ENUMERATED_T  DATA_TYPE_NAME  ## _T;\
635
636
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
#endif

/*! \def ENUMERATED(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_ENUMERATED_T.
 */
#define ENUMERATED(VAR_NAME)                                MIH_C_ENUMERATED_T  VAR_NAME;


//----------------------- BOOLEAN ---------------------------------------------
TYPEDEF_ENUMERATED(MIH_C_BOOLEAN)

#define MIH_C_BOOLEAN_TRUE       (MIH_C_ENUMERATED_T)1
#define MIH_C_BOOLEAN_FALSE      (MIH_C_ENUMERATED_T)0
#ifdef MIH_C_F2_GENERAL_DATA_TYPES_CODEC_C
    /*! \def TYPEDEF_BOOLEAN(DATA_TYPE_NAME)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as MIH_C_BOOLEAN_T, and its functions for de/serializing this type.
     */
    #define TYPEDEF_BOOLEAN(DATA_TYPE_NAME)          typedef MIH_C_BOOLEAN_T  DATA_TYPE_NAME  ## _T;\
657
658
        void MIH_C_BOOLEAN_encode(Bit_Buffer_t* bbP, MIH_C_BOOLEAN_T* dataP);\
        void MIH_C_BOOLEAN_decode(Bit_Buffer_t* bbP, MIH_C_BOOLEAN_T* dataP);\
659
660
661
662
663
664
665
666
667
        unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* bufP) {\
            unsigned int buffer_index = 0;\
            if (*dataP != MIH_C_BOOLEAN_FALSE) {\
                buffer_index += sprintf(&bufP[buffer_index], "TRUE");\
            } else {\
                buffer_index += sprintf(&bufP[buffer_index], "FALSE");\
            }\
            return buffer_index;\
        };\
668
        void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
669
            MIH_C_BOOLEAN_encode(bbP, dataP);};\
670
        void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {MIH_C_ENUMERATED_decode(bbP, dataP);};
671
672
673
#else
    #define TYPEDEF_BOOLEAN(DATA_TYPE_NAME)          typedef MIH_C_BOOLEAN_T  DATA_TYPE_NAME  ## _T;\
        extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* bufP);\
674
675
        void  DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
        void  DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
#endif

/*! \def BOOLEAN(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief A variable declaration of type MIH_C_BOOLEAN_T.
 */
#define BOOLEAN(VAR_NAME)                     MIH_C_BOOLEAN_T  VAR_NAME;


//----------------------- OCTET_STRING ----------------------------------------
#ifdef MIH_C_F2_GENERAL_DATA_TYPES_CODEC_C
    /*! \def TYPEDEF_OCTET_STRING(DATA_TYPE_NAME, MAX_LENGTH)
     * \ingroup MIH_C_F1_BASIC_DATA_TYPES
     * \brief Defines DATA_TYPE_NAME as a LIST of MAX_LENGTH char elements, and its functions for de/serializing this type.
     */
#define TYPEDEF_OCTET_STRING(DATA_TYPE_NAME, MAX_LENGTH)    typedef  struct DATA_TYPE_NAME { u_int16_t length; u_int8_t val[MAX_LENGTH];} DATA_TYPE_NAME ## _T;\
    unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *listP, char* bufP) {\
        memcpy(bufP, listP->val, listP->length);\
        bufP[listP->length] = 0;\
        return listP->length;\
    };\
697
    void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *listP) {\
698
        MIH_C_LIST_LENGTH_decode(bbP, &listP->length);\
699
        if (listP->length > MAX_LENGTH) {printf("[MIH_C] ERROR DATA_TYPE_NAME ## _decode String length out of bounds: %d, max is %d\n", listP->length, MAX_LENGTH);\
700
701
702
703
        } else {\
            BitBuffer_readMem(bbP, listP->val, listP->length);\
        }\
    };\
704
    void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *listP) {\
705
        if (listP->length > MAX_LENGTH) {\
706
            printf("[MIH_C] ERROR DATA_TYPE_NAME ## _encode String length out of bounds: %d, max is %d\n", listP->length, MAX_LENGTH);\
707
708
709
710
711
        } else {\
            MIH_C_LIST_LENGTH_encode(bbP, listP->length);\
            BitBuffer_writeMem(bbP, listP->val, listP->length);\
        }\
    };\
712
    void DATA_TYPE_NAME ## _set(DATA_TYPE_NAME ## _T *octet_strP, u_int8_t* strP, u_int16_t lengthP) {\
713
        if (lengthP > MAX_LENGTH) {\
714
            printf("[MIH_C] ERROR DATA_TYPE_NAME ## _set String length out of bounds\n");\
715
716
717
            octet_strP->length = 0;\
        } else {\
            octet_strP->length = lengthP;\
718
719
720
721
722
            if (strP != NULL) {\
                memcpy((char *)octet_strP->val, (char *)strP, lengthP);\
            } else {\
                memset((char *)octet_strP->val, 0, lengthP);\
            }\
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
        }\
    };
#else
#define TYPEDEF_OCTET_STRING(DATA_TYPE_NAME, MAX_LENGTH)    typedef  struct DATA_TYPE_NAME { u_int16_t length; u_int8_t val[MAX_LENGTH];} DATA_TYPE_NAME ## _T;\
    extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *listP, char* bufP);\
    extern void         DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *listP);\
    extern void         DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *listP);\
    extern void         DATA_TYPE_NAME ## _set(DATA_TYPE_NAME ## _T *octet_strP, u_int8_t* strP, u_int16_t lengthP);
#endif


//----------------------- PERCENTAGE ------------------------------------------
TYPEDEF_UNSIGNED_INT1(MIH_C_PERCENTAGE);
/*! \var PERCENTAGE(VAR_NAME)
 * \ingroup MIH_C_F1_BASIC_DATA_TYPES
 * \brief Defines VAR_NAME as MIH_C_PERCENTAGE_T.
 */
#define PERCENTAGE(VAR_NAME)                 MIH_C_PERCENTAGE_T  VAR_NAME;

//----------------------- STATUS ----------------------------------------------
TYPEDEF_ENUMERATED(MIH_C_STATUS);
#define MIH_C_STATUS_SUCCESS                 (MIH_C_STATUS_T)0
#define MIH_C_STATUS_UNSPECIFIED_FAILURE     (MIH_C_STATUS_T)1
#define MIH_C_STATUS_REJECTED                (MIH_C_STATUS_T)2
#define MIH_C_STATUS_AUTHORIZATION_FAILURE   (MIH_C_STATUS_T)3
#define MIH_C_STATUS_NETWORK_ERROR           (MIH_C_STATUS_T)4

//-----------------------------------------------------------------------------
// STD 802.21-2008 Table F.3 Data types for addresses
//-----------------------------------------------------------------------------
/*! \var MIH_C_UNSIGNED_INT4_T MIH_C_CELL_ID_T
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief This data type identifies a cell uniquely within 3GPP UTRAN and
* consists of radio network controller (RNC)-ID and C-ID as defined in
* 3GPP TS 25.401.
* Valid Range: 0..268435455.
*/
TYPEDEF_UNSIGNED_INT4(MIH_C_CELL_ID)
//-------------------------------------------
/*!
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief The BSS and cell within the BSS are identified by Cell Identity (CI).
* See 3GPP TS 23.003.
*/
TYPEDEF_OCTET(MIH_C_CI, 2)
//-------------------------------------------
/*!
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief The public land mobile network (PLMN) unique identifier.
*        PLMN_ID consists of Mobile Country Code (MCC) and Mobile Network Code (MNC).
*        This is to represent the access network identifier.
*        Coding of PLMN_ID is defined in 3GPP TS 25.413.
*/
TYPEDEF_OCTET(MIH_C_PLMN_ID, 3)
//-------------------------------------------
/*!
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief Location Area Code (LAC) is a fixed length code (of 2 octets)
* identifying a location area within a public landmobile network (PLMN).
* See 3GPP TS 23.003.
*/
TYPEDEF_OCTET(MIH_C_LAC, 2)
//-------------------------------------------
/*! \struct MIH_C_3GPP_2G_CELL_ID
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief A data type to represent a 3GPP 2G cell identifier.
*/
typedef struct MIH_C_3GPP_2G_CELL_ID {
    MIH_C_PLMN_ID_T        plmn_id;
    MIH_C_LAC_T            lac;
    MIH_C_CI_T             ci;
} MIH_C_3GPP_2G_CELL_ID_T;

//-------------------------------------------
/*! \struct  MIH_C_3GPP_3G_CELL_ID
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief A data type to represent a 3GPP 3G cell identifier.
*/
typedef struct MIH_C_3GPP_3G_CELL_ID {
    MIH_C_PLMN_ID_T        plmn_id;
    MIH_C_CELL_ID_T        cell_id;
} MIH_C_3GPP_3G_CELL_ID_T;
//-------------------------------------------
/*! \struct  MIH_C_3GPP_ADDR
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief A data type to represent a 3GPP transport address.
*/
TYPEDEF_OCTET_STRING(MIH_C_3GPP_ADDR, MIH_C_3GPP_ADDR_LENGTH)
//-------------------------------------------
/*! \struct  MIH_C_3GPP2_ADDR
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief A data type to represent a 3GPP2 transport address.
*/
TYPEDEF_OCTET_STRING(MIH_C_3GPP2_ADDR, MIH_C_3GPP2_ADDR_LENGTH)
//-------------------------------------------
/*! \var MIH_C_IANA_ADDR_T
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief Is the address family type of a transport address.
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_IANA_ADDR)
//-------------------------------------------
/*! \struct MIH_C_TRANSPORT_ADDR_T
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief A type to represent a transport address. The
* UNSIGNED_INT(2) is the address type defined in
* http://www.iana.org/assignments/address-family-numbers.
*/
TYPEDEF_OCTET_STRING(MIH_C_TRANSPORT_ADDR_VALUE, 128)
//-------------------------------------------
#ifdef MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC_C
#define TYPEDEF_TRANSPORT_ADDR(DATA_TYPE_NAME)  typedef struct DATA_TYPE_NAME {\
                                                                MIH_C_IANA_ADDR_T              address_family;\
                                                                MIH_C_TRANSPORT_ADDR_VALUE_T   address;\
                                                            } DATA_TYPE_NAME ## _T;\
    unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* bufP) {\
        unsigned int buffer_index = 0;\
        buffer_index += sprintf(&bufP[buffer_index], "IANA = ");\
        buffer_index += MIH_C_IANA_ADDR2String(&dataP->address_family, &bufP[buffer_index]);\
        buffer_index += sprintf(&bufP[buffer_index], "TRANSPORT_ADDR = ");\
        buffer_index += MIH_C_TRANSPORT_ADDR_VALUE2String(&dataP->address, &bufP[buffer_index]);\
        return buffer_index;\
    };\
845
    void DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
846
847
848
        MIH_C_IANA_ADDR_decode(bbP, &dataP->address_family);\
        MIH_C_TRANSPORT_ADDR_VALUE_decode(bbP, &dataP->address);\
    };\
849
    void DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP) {\
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
        MIH_C_IANA_ADDR_encode(bbP, &dataP->address_family);\
        MIH_C_TRANSPORT_ADDR_VALUE_encode(bbP, &dataP->address);\
    };
#else
#define TYPEDEF_TRANSPORT_ADDR(DATA_TYPE_NAME)  typedef struct DATA_TYPE_NAME {\
                                                                MIH_C_IANA_ADDR_T              address_family;\
                                                                MIH_C_TRANSPORT_ADDR_VALUE_T   address;\
                                                            } DATA_TYPE_NAME ## _T;\
    extern unsigned int DATA_TYPE_NAME ## 2String(DATA_TYPE_NAME ## _T *dataP, char* bufP);\
    extern void         DATA_TYPE_NAME ## _decode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);\
    extern void         DATA_TYPE_NAME ## _encode(Bit_Buffer_t *bbP, DATA_TYPE_NAME ## _T *dataP);
#endif
//-------------------------------------------
/*! \struct  MIH_C_IP_ADDR_T
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief Represents an IP address. The Address Type is either 1 (IPv4) or 2 (IPv6).
*/
//typedef MIH_C_TRANSPORT_ADDR_T   MIH_C_IP_ADDR_T;
TYPEDEF_TRANSPORT_ADDR(MIH_C_IP_ADDR)
//-------------------------------------------
/*! \struct  MIH_C_MAC_ADDR_T
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief Represents a MAC address. The Address Type contains the one used for a specific link layer.
*/
//typedef MIH_C_TRANSPORT_ADDR_T   MIH_C_MAC_ADDR_T;
TYPEDEF_TRANSPORT_ADDR(MIH_C_MAC_ADDR)
//-------------------------------------------
/*! \struct  MIH_C_OTHER_L2_ADDR_T
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief A data type to represent a link-layer address other than the address already defined.
* For example, SSID.
*/
TYPEDEF_OCTET_STRING(MIH_C_OTHER_L2_ADDR, MIH_C_OTHER_L2_ADDR_LENGTH)
//-------------------------------------------

typedef enum  {
                  MIH_C_CHOICE_MAC_ADDR = 0,
                  MIH_C_CHOICE_3GPP_3G_CELL_ID,
                  MIH_C_CHOICE_3GPP_2G_CELL_ID,
                  MIH_C_CHOICE_3GPP_ADDR,
                  MIH_C_CHOICE_3GPP2_ADDR,
                  MIH_C_CHOICE_OTHER_L2_ADDR
              } MIH_C_LINK_ADDR_CHOICE_ENUM_T;
//-------------------------------------------
/*! \struct MIH_C_LINK_ADDR
* \ingroup MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC
* \brief A data type to represent an address of any link layer.
*/
typedef struct MIH_C_LINK_ADDR {
    MIH_C_CHOICE_T               choice;
    union  {
        MIH_C_MAC_ADDR_T         mac_addr;
        MIH_C_3GPP_3G_CELL_ID_T  _3gpp_3g_cell_id;
        MIH_C_3GPP_2G_CELL_ID_T  _3gpp_2g_cell_id;
        MIH_C_3GPP_ADDR_T        _3gpp_addr;
        MIH_C_3GPP2_ADDR_T       _3gpp2_addr;
        MIH_C_OTHER_L2_ADDR_T    other_l2_addr;
    } _union;
} MIH_C_LINK_ADDR_T;




//-----------------------------------------------------------------------------
// STD 802.21-2008 Table F.4 Data types for links (MAINLY because of precedence definition)
//-----------------------------------------------------------------------------
/*!
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents percentage of battery charge remaining.

*/
TYPEDEF_INTEGER1(MIH_C_BATT_LEVEL)
//-------------------------------------------
/*!
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Channel identifier as defined in the specific link technology (e.g., standards
*        development organization (SDO)).
*        Valid Range: 0..65535
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_CHANNEL_ID)
//-------------------------------------------
#define MIH_C_CONFIG_STATUS_SUCCESS MIH_C_BOOLEAN_TRUE
#define MIH_C_CONFIG_STATUS_ERROR   MIH_C_BOOLEAN_FALSE
/*! \var  MIH_C_CONFIG_STATUS_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The status of link parameter configuration.
*        TRUE: Success
*        FALSE: Error
*/
TYPEDEF_BOOLEAN(MIH_C_CONFIG_STATUS)
//-------------------------------------------
/*! \var  MIH_C_DEVICE_INFO_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A non-NULL terminated string whose length shall not exceed 253 octets, representing
*        information on manufacturer, model number, revision number of the software/firmware
*        and serial number in displayable text.
*/
TYPEDEF_OCTET_STRING(MIH_C_DEVICE_INFO, 253)
//-------------------------------------------
#define MIH_C_BIT_DEVICE_INFO   MIH_C_BIT_0_VALUE
#define MIH_C_BIT_BATT_LEVEL    MIH_C_BIT_1_VALUE
/*!
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A list of device status request.
*        Bitmap Values:
*        Bit 0: DEVICE_INFO
*        Bit 1: BATT_LEVEL
*        Bit 2–15: (Reserved)
*/
TYPEDEF_BITMAP16(MIH_C_DEV_STATES_REQ)
//-------------------------------------------
/*! \struct  MIH_C_DEV_STATE_RSP_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents a device status.
*/
typedef struct MIH_C_DEV_STATE_RSP {
    MIH_C_CHOICE_T          choice;
    union  {
        MIH_C_DEVICE_INFO_T      device_info;
        MIH_C_BATT_LEVEL_T       batt_level;
    } _union;
} MIH_C_DEV_STATE_RSP_T;
//-------------------------------------------
/*!
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Time (in ms) to elapse before an action needs to be taken. A value of 0 indicates
*        that the action will be taken immediately. Time elapsed will be calculated from the
*        instance the command arrives until the time when the execution of the action is carried out.
*        Valid Range: 0..65535
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_LINK_AC_EX_TIME)
//-------------------------------------------
/*!
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Link action result.
*        0: Success
*        1: Failure
*        2: Refused
*        3: Incapable
*/
TYPEDEF_ENUMERATED(MIH_C_LINK_AC_RESULT)
#define MIH_C_LINK_AC_RESULT_SUCCESS   (MIH_C_LINK_AC_RESULT_T)0
#define MIH_C_LINK_AC_RESULT_FAILURE   (MIH_C_LINK_AC_RESULT_T)1
#define MIH_C_LINK_AC_RESULT_REFUSED   (MIH_C_LINK_AC_RESULT_T)2
#define MIH_C_LINK_AC_RESULT_INCAPABLE (MIH_C_LINK_AC_RESULT_T)3
//-------------------------------------------
#define MIH_C_BIT_LINK_AC_ATTR_LINK_SCAN          MIH_C_BIT_0_VALUE
#define MIH_C_BIT_LINK_AC_ATTR_LINK_RES_RETAIN    MIH_C_BIT_1_VALUE
#define MIH_C_BIT_LINK_AC_ATTR_DATA_FWD_REQ       MIH_C_BIT_2_VALUE
/*!
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Link action attribute that can be executed along with a valid link action.
*        Detail description of each attribute is in Table F.6.
*        Bitmap Values:
*        Bit 0: LINK_SCAN
*        Bit 1: LINK_RES_RETAIN
*        Bit 2: DATA_FWD_REQ
*        Bit 3–7: (Reserved)
*/
TYPEDEF_BITMAP8(MIH_C_LINK_AC_ATTR)
//-------------------------------------------
/*!
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief An action for a link. The meaning of each link action is defined in Table F.5.
*        0: NONE
*        1: LINK_DISCONNECT
*        2: LINK_LOW_POWER
*        3: LINK_POWER_DOWN
*        4: LINK_POWER_UP
*        5–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_AC_TYPE)
#define MIH_C_LINK_AC_TYPE_NONE                      (MIH_C_LINK_AC_TYPE_T)0
#define MIH_C_LINK_AC_TYPE_LINK_DISCONNECT           (MIH_C_LINK_AC_TYPE_T)1
#define MIH_C_LINK_AC_TYPE_LINK_LOW_POWER            (MIH_C_LINK_AC_TYPE_T)2
#define MIH_C_LINK_AC_TYPE_LINK_POWER_DOWN           (MIH_C_LINK_AC_TYPE_T)3
#define MIH_C_LINK_AC_TYPE_LINK_POWER_UP             (MIH_C_LINK_AC_TYPE_T)4
#ifdef MIH_C_MEDIEVAL_EXTENSIONS
#define MIH_C_LINK_AC_TYPE_LINK_FLOW_ATTR            (MIH_C_LINK_AC_TYPE_T)5
#define MIH_C_LINK_AC_TYPE_LINK_ACTIVATE_RESOURCES   (MIH_C_LINK_AC_TYPE_T)6
#define MIH_C_LINK_AC_TYPE_LINK_DEACTIVATE_RESOURCES (MIH_C_LINK_AC_TYPE_T)7
#endif
//-------------------------------------------
/*!
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents the link type.a
*        Number assignments:
*        0: Reserved
*        1: Wireless - GSM
*        2: Wireless - GPRS
*        3: Wireless - EDGE
*        15: Ethernet
*        18: Wireless - Other
*        19: Wireless - IEEE 802.11
*        22: Wireless - CDMA2000
*        23: Wireless - UMTS
*        24: Wireless - cdma2000-HRPD
*        25: Wireless - LTE (MEDIEVAL)
*        27: Wireless - IEEE 802.16
*        28: Wireless - IEEE 802.20
*        29: Wireless - IEEE 802.22
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_TYPE)
#define MIH_C_WIRELESS_GSM            (MIH_C_LINK_TYPE_T)1
#define MIH_C_WIRELESS_GPRS           (MIH_C_LINK_TYPE_T)2
#define MIH_C_WIRELESS_EDGE           (MIH_C_LINK_TYPE_T)3
#define MIH_C_ETHERNET                (MIH_C_LINK_TYPE_T)15
#define MIH_C_WIRELESS_OTHER          (MIH_C_LINK_TYPE_T)18
#define MIH_C_WIRELESS_IEEE802_11     (MIH_C_LINK_TYPE_T)19
#define MIH_C_WIRELESS_CDMA_2000      (MIH_C_LINK_TYPE_T)22
//#define MIH_C_WIRELESS_UMTS           (MIH_C_LINK_TYPE_T)23
// Temp - MW modified to test LTE for MEDIEVAL
#define MIH_C_WIRELESS_UMTS           (MIH_C_LINK_TYPE_T)25
#define MIH_C_WIRELESS_CDMA_2000_HRPD (MIH_C_LINK_TYPE_T)24
#define MIH_C_WIRELESS_LTE            (MIH_C_LINK_TYPE_T)25
#define MIH_C_WIRELESS_IEEE802_16     (MIH_C_LINK_TYPE_T)27
#define MIH_C_WIRELESS_IEEE802_20     (MIH_C_LINK_TYPE_T)28
#define MIH_C_WIRELESS_IEEE802_22     (MIH_C_LINK_TYPE_T)29
//-------------------------------------------
/*! \struct  MIH_C_LINK_ID_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The identifier of a link that is not associated with the peer node.
*        The LINK_ADDR contains the address of this link.
*/
typedef struct MIH_C_LINK_ID {
    MIH_C_LINK_TYPE_T           link_type;
    MIH_C_LINK_ADDR_T           link_addr;
} MIH_C_LINK_ID_T;
//-------------------------------------------
#ifdef MIH_C_MEDIEVAL_EXTENSIONS
/*! \var MIH_C_PORT_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief 2 octets defining the port used by the transport protocol
*/
TYPEDEF_OCTET(MIH_C_PORT, 2)
//-------------------------------------------
/*! \struct MIH_C_IP_TUPLE_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief Tuple consisting on an IP address and the port
*/
typedef struct MIH_C_IP_TUPLE {
    MIH_C_IP_ADDR_T              ip_addr;
    MIH_C_PORT_T                 port;
} MIH_C_IP_TUPLE_T;
//-------------------------------------------
/*! \var MIH_C_PROTO_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief The transport protocol used:
*    0: TCP
*    1: UDP
*/
TYPEDEF_ENUMERATED(MIH_C_PROTO)
#define MIH_C_PROTO_TCP   (MIH_C_PROTO_T)0
#define MIH_C_PROTO_UDP   (MIH_C_PROTO_T)1
//-------------------------------------------
/*! \struct MIH_C_FLOW_ID_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief Five tuple, consisting on the source and destination address
* and ports plus the transport protocol used.
*/
/*typedef struct MIH_C_FLOW_ID {
    MIH_C_IP_TUPLE_T              source_addr;
    MIH_C_IP_TUPLE_T              dest_addr;
    MIH_C_PROTO_T                 transport_protocol;
} MIH_C_FLOW_ID_T;*/
TYPEDEF_UNSIGNED_INT4(MIH_C_FLOW_ID)
//-------------------------------------------
/*! \struct MIH_C_MARK_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief 6 Bits (IPv4) or 20 Bits (IPv6) mask to be applied to the DSCP
* or Flow Label field of IPv4/v6 header.
*/
typedef struct MIH_C_MARK {
    MIH_C_CHOICE_T          choice;
    union  {
        BITMAP6(dscp_mask);
        BITMAP20(flow_label_mask);
    } _union;
} MIH_C_MARK_T;
//-------------------------------------------
/*! \var MIH_C_MAX_DELAY_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief Maximum delay supported by the flow in ms.
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_MAX_DELAY)
//-------------------------------------------
/*! \var MIH_C_BITRATE_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief A type to represent the maximum data rate in kb/s.
*  Valid Range: 0 –– 2^32 – 1

*/
TYPEDEF_UNSIGNED_INT4(MIH_C_BITRATE)
//-------------------------------------------
/*! \var MIH_C_JITTER_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief A type to represent the packet transfer delay jitter in ms.
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_JITTER)
//-------------------------------------------
/*! \var MIH_C_PKT_LOSS_RATE_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief A type to represent the packet loss rate. The loss rate is equal
* to the integer part of the result of multiplying --100 times the
* log10 of the ratio between the number of packets lost and the
* total number of packets transmitted.
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_PKT_LOSS_RATE)
//-------------------------------------------
/*! \var MIH_C_COS_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief COS Class to be used for queuing.
*  To be filled for LTE and WLAN
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_COS)
//-------------------------------------------
/*! \var MIH_C_DROP_ELIGIBILITY_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief 0 means the frames are not eligible to discarding.
* 1 means frames are eligible for discarding.
*/
TYPEDEF_BOOLEAN(MIH_C_DROP_ELIGIBILITY)
//-------------------------------------------
/*! \var MIH_C_MULTICAST_ENABLE_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief Identifies if a flow is multicast.
*  0: is not multicast
*  1: is multicast
*/
TYPEDEF_BOOLEAN(MIH_C_MULTICAST_ENABLE)
//-------------------------------------------
/*! \var MIH_C_JUMBO_ENABLE_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief Identifies if JUMBO must be activated
*  0: Deactivate Jumbo
*  1: Activate Jumbo
*/
TYPEDEF_BOOLEAN(MIH_C_JUMBO_ENABLE)
#endif
//-------------------------------------------
/*! \var MIH_C_LINK_DATA_RATE_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent the maximum data rate in kb/s.
*        Valid Range: 0 – 232–1
*/
TYPEDEF_UNSIGNED_INT4(MIH_C_LINK_DATA_RATE)
//-------------------------------------------
#ifdef MIH_C_MEDIEVAL_EXTENSIONS
/*! \struct MIH_C_QOS_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief The choice of delay and bitrate corresponds to a new flow being
*  signalled through the MIH_SAP, the COS parameter is used after being processed by the WP3 AQM.
*/
typedef struct MIH_C_QOS {
    MIH_C_CHOICE_T          choice;
    union  {
        struct {
            MIH_C_MAX_DELAY_T      max_delay;
            MIH_C_BITRATE_T        bitrate;
            MIH_C_JITTER_T         jitter;
            MIH_C_PKT_LOSS_RATE_T  pkt_loss;
        }                          mark_qos;
        MIH_C_COS_T                cos;
    } _union;
} MIH_C_QOS_T;
//-------------------------------------------
/*! \struct MIH_C_RESOURCE_DESC_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief The choice of RESOURCE_DESC is used when the LINK_ACTIVATE_RESOURCES
* or DEACTIVATE action is selected in order to identify and
* configure the flow subject to action
*/
typedef struct MIH_C_RESOURCE_DESC {
    MIH_C_LINK_ID_T         link_id;
    MIH_C_FLOW_ID_T         flow_id;
    MIH_C_CHOICE_T          choice_link_data_rate;
    union  {
1227
        MIH_C_NULL_T             null_attr;
1228
1229
1230
1231
        MIH_C_LINK_DATA_RATE_T   link_data_rate;
    } _union_link_data_rate;
    MIH_C_CHOICE_T          choice_qos;
    union  {
1232
        MIH_C_NULL_T             null_attr;
1233
1234
1235
1236
        MIH_C_QOS_T          qos;
    } _union_qos;
    MIH_C_CHOICE_T          choice_jumbo_enable;
    union  {
1237
        MIH_C_NULL_T             null_attr;
1238
1239
1240
1241
        MIH_C_JUMBO_ENABLE_T     jumbo_enable;
    } _union_jumbo_enable;
    MIH_C_CHOICE_T          choice_multicast_enable;
    union  {
1242
        MIH_C_NULL_T             null_attr;
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
        MIH_C_MULTICAST_ENABLE_T multicast_enable;
    } _union_multicast_enable;
} MIH_C_RESOURCE_DESC_T;
//-------------------------------------------
/*! \struct MIH_C_FLOW_ATTRIBUTE_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief The choice of FLOW_ATTRIBUTE is used when the FLOW_ATTR action is
* selected in order to provide the mark and multicast configuration
* to be set up for the flow.
*/
typedef struct MIH_C_FLOW_ATTRIBUTE {
    MIH_C_FLOW_ID_T         flow_id;
    MIH_C_CHOICE_T          choice_multicast_enable;
    union  {
1257
        MIH_C_NULL_T             null_attr;
1258
1259
1260
1261
        MIH_C_MULTICAST_ENABLE_T multicast_enable;
    } _union_multicast_enable;
    MIH_C_CHOICE_T          choice_mark_qos;
    union  {
1262
        MIH_C_NULL_T             null_attr;
1263
1264
1265
1266
1267
1268
1269
        struct {
            MIH_C_MARK_T         mark;
            MIH_C_QOS_T          qos;
        }                        mark_qos;
    } _union_mark_qos;
    MIH_C_CHOICE_T                      choice_mark_drop_eligibility;
    union  {
1270
        MIH_C_NULL_T                    null_attr;
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
        struct {
            MIH_C_MARK_T                mark;
            MIH_C_DROP_ELIGIBILITY_T    drop_eligibility;
        }                               mark_drop_eligibility;
    } _union_mark_drop_eligibility;

} MIH_C_FLOW_ATTRIBUTE_T;
//-------------------------------------------
/*! \struct MIH_C_LINK_AC_PARAM_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief The choice of FLOW_ATTRIBUTE is used when the FLOW_ATTR action is selected
*  in order to provide the mark and multicast configuration to be set up for the flow.
*  The choice of RESOURCE_DESC is used when LINK_ACTIVATE_RESOURCES or
*  LINK_DEACTIVATE_RESOURCES actions are used.
*/
typedef struct MIH_C_LINK_AC_PARAM {
    MIH_C_CHOICE_T          choice;
    union  {
1289
        MIH_C_NULL_T             null_attr;
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
        MIH_C_FLOW_ATTRIBUTE_T   flow_attribute;
        MIH_C_RESOURCE_DESC_T    resource_desc;
    } _union;
} MIH_C_LINK_AC_PARAM_T;
#endif
//-------------------------------------------
/*! \struct  MIH_C_LINK_ACTION_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Link action.
*/
typedef struct MIH_C_LINK_ACTION {
    MIH_C_LINK_AC_TYPE_T           link_ac_type;
    MIH_C_LINK_AC_ATTR_T           link_ac_attr;
#ifdef MIH_C_MEDIEVAL_EXTENSIONS
    MIH_C_LINK_AC_PARAM_T          link_ac_param; /*!<  \brief extension of MEDIEVAL PROJECT  */
#endif
} MIH_C_LINK_ACTION_T;
//-------------------------------------------
/*! \struct MIH_C_LINK_ACTION_REQ_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A set of handover action request parameters. The choice of LINK_ADDR is to
*        provide PoA address information when the LINK_ACTION contains the attribute for  DATA_FWD_REQ.
*/
typedef struct MIH_C_LINK_ACTION_REQ {
    MIH_C_LINK_ID_T              link_id;
    MIH_C_CHOICE_T               choice;
    union  {
1317
        MIH_C_NULL_T             null_attr;
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
        MIH_C_LINK_ADDR_T        link_addr;
    } _union;

    MIH_C_LINK_ACTION_T          link_action;
    MIH_C_LINK_AC_EX_TIME_T      link_action_ex_time;
} MIH_C_LINK_ACTION_REQ_T;
//-------------------------------------------
/*! \struct  MIH_C_SIG_STRENGTH_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents the signal strength in dBm unit or its relative value in an arbitrary percentage scale.
*/
typedef struct MIH_C_SIG_STRENGTH {
    MIH_C_CHOICE_T               choice;
    union  {
        INTEGER1(dbm)
        PERCENTAGE(percentage)
    } _union;
} MIH_C_SIG_STRENGTH_T;
#define MIH_C_SIG_STRENGTH_CHOICE_DBM        (MIH_C_CHOICE_T)0
#define MIH_C_SIG_STRENGTH_CHOICE_PERCENTAGE (MIH_C_CHOICE_T)1
//-------------------------------------------
/*! \var  MIH_C_NETWORK_ID_T
* \ingroup MIH_C_F13_DATA_TYPES_FOR_INFORMATION_ELEMENTS
* \brief A type to represent a network identifier.
*        A non-NULL terminated string whose length shall not exceed 253 octets.
*/
TYPEDEF_OCTET_STRING(MIH_C_NETWORK_ID, 253)
//-------------------------------------------
/*! \struct  MIH_C_LINK_SCAN_RSP_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents a scan response. The LINK_ADDR contains the PoA link address.
*        The PoA belongs to the NETWORK_ID with the given SIG_STRENGTH.
*/
typedef struct MIH_C_LINK_SCAN_RSP {
    MIH_C_LINK_ADDR_T            link_addr;
    MIH_C_NETWORK_ID_T           network_id;
    MIH_C_SIG_STRENGTH_T         sig_strength;
} MIH_C_LINK_SCAN_RSP_T;
//-------------------------------------------
/*! \var MIH_C_LINK_SCAN_RSP_T
* \brief
*/
TYPEDEF_LIST(MIH_C_LINK_SCAN_RSP, MIH_C_LINK_SCAN_RSP_LENGTH)
//-------------------------------------------
/*! \struct  MIH_C_LINK_ACTION_RSP_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A set of link action returned results.
*/
typedef struct MIH_C_LINK_ACTION_RSP {
    MIH_C_LINK_ID_T              link_id;
    MIH_C_LINK_AC_RESULT_T       link_ac_result;
    MIH_C_CHOICE_T               choice;
    union  {
1371
        MIH_C_NULL_T             null_attr;
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
        LIST(MIH_C_LINK_SCAN_RSP, link_scan_rsp)
    } _union;
} MIH_C_LINK_ACTION_RSP_T;
//-------------------------------------------
#define MIH_C_BIT_LINK_EVENT_SUBSCRIBE      MIH_C_BIT_1_VALUE
#define MIH_C_BIT_LINK_EVENT_UNSUBSCRIBE    MIH_C_BIT_2_VALUE
#define MIH_C_BIT_LINK_GET_PARAMETERS       MIH_C_BIT_3_VALUE
#define MIH_C_BIT_LINK_CONFIGURE_THRESHOLDS MIH_C_BIT_4_VALUE
#define MIH_C_BIT_LINK_ACTION               MIH_C_BIT_5_VALUE
/*! \var MIH_C_LINK_CMD_LIST_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A list of link commands.
*        Bitmap Values:
*        Bit 0: Reserved
*        Bit 1: Link_Event_Subscribe
*        Bit 2: Link_Event_Unsubscribe
*        Bit 3: Link_Get_Parameters
*        Bit 4: Link_Configure_Thresholds
*        Bit 5: Link_Action
*        Bit 6-31: (Reserved)
*/
TYPEDEF_BITMAP32(MIH_C_LINK_CMD_LIST)
//-------------------------------------------
/*! \var MIH_C_TH_ACTION_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief
*        0: Set normal threshold
*        1: Set one-shot threshold
*        2: Cancel threshold
*/
TYPEDEF_ENUMERATED(MIH_C_TH_ACTION)
#define MIH_C_SET_NORMAL_THRESHOLD      (MIH_C_TH_ACTION_T)0
#define MIH_C_SET_ONE_SHOT_THRESHOLD    (MIH_C_TH_ACTION_T)1
#define MIH_C_CANCEL_THRESHOLD          (MIH_C_TH_ACTION_T)2
//-------------------------------------------
/*! \var MIH_C_THRESHOLD_VAL_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Threshold value. The format of the media-dependent value is defined in the
*        respective media specification standard and the equivalent number of bits (i.e.,
*        first bits) of this data type is used. In case that there are remaining unused bits
*        in the data type, these are marked as all-zeros (‘0’).
*        Valid Range: 0..65535
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_THRESHOLD_VAL)

//-------------------------------------------
/*! \var MIH_C_THRESHOLD_XDIR_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The direction the threshold is to be crossed.
*        0: ABOVE_THRESHOLD
*        1: BELOW_THRESHOLD
*        2–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_THRESHOLD_XDIR)
#define MIH_C_ABOVE_THRESHOLD           (MIH_C_THRESHOLD_XDIR_T)0
#define MIH_C_BELOW_THRESHOLD           (MIH_C_THRESHOLD_XDIR_T)1
//-------------------------------------------
/*! \struct  MIH_C_THRESHOLD_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A link threshold. The threshold is considered crossed when the value of the
*        link parameter passes the threshold in the specified direction.
*/
typedef struct MIH_C_THRESHOLD {
    MIH_C_THRESHOLD_VAL_T        threshold_val;
    MIH_C_THRESHOLD_XDIR_T       threshold_xdir;
} MIH_C_THRESHOLD_T;
//-------------------------------------------
/*! \var MIH_C_TIMER_INTERVAL_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief This timer value (ms) is used to set the interval between periodic reports.
*        Valid Range: 0..65535
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_TIMER_INTERVAL)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_GEN_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a generic link parameter that is applicable to any link type.
*        0: Data Rate—the parameter value is represented as a DATA_RATE.
*        1: Signal Strength—the parameter value is represented as a SIG_STRENGTH.
*        2: Signal over interference plus noise ratio (SINR)—the parameter value is
*           represented as an UNSIGNED_INT(2).
*        3:Throughput (the number of bits successfully received divided by the time it
*          took to transmit them over the medium)—the parameter value is represented as
*          an UNSIGNED_INT(2).
*        4: Packet Error Rate (representing the ratio between the number of frames received
*           in error and the total number of frames transmitted in a link population of interest)
*           the parameter value is represented as a PERCENTAGE.
*        5–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_GEN)
#define MIH_C_LINK_PARAM_GEN_DATA_RATE         (MIH_C_LINK_PARAM_GEN_T)0
#define MIH_C_LINK_PARAM_GEN_SIGNAL_STRENGTH   (MIH_C_LINK_PARAM_GEN_T)1
#define MIH_C_LINK_PARAM_GEN_SINR              (MIH_C_LINK_PARAM_GEN_T)2
#define MIH_C_LINK_PARAM_GEN_THROUGHPUT        (MIH_C_LINK_PARAM_GEN_T)3
#define MIH_C_LINK_PARAM_GEN_PACKET_ERROR_RATE (MIH_C_LINK_PARAM_GEN_T)4
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_QOS_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent QOS_LIST parameters.
*        0: Maximum number of differentiable classes of service supported.
*        1: Minimum packet transfer delay for all CoS, the minimum delay over a class
*           population of interest.
*        2: Average packet transfer delay for all CoS, the arithmetic mean of the delay
*           over a class population of interest. (See B.3.4)
*        3: Maximum packet transfer delay for all CoS, the maximum delay over a class
*           population of interest.
*        4: Packet transfer delay jitter for all CoS, the standard deviation of the delay
*           over a class population of interest. (See B.3.5.)
*        5: Packet loss rate for all CoS, the ratio between the number of frames that are
*           transmitted but not received and the total number of frames transmitted over
*           a class population of interest. (See B.3.2.)
*        6–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_QOS)
gauthier's avatar
gauthier committed
1486
1487
1488
1489
1490
1491
#define MIH_C_LINK_PARAM_QOS_MAX_NUM_DIF_COS_SUPPORTED            (MIH_C_LINK_PARAM_QOS_T)0
#define MIH_C_LINK_PARAM_QOS_MIN_PACKET_TRANSFER_DELAY_ALL_COS    (MIH_C_LINK_PARAM_QOS_T)1
#define MIH_C_LINK_PARAM_QOS_AVG_PACKET_TRANSFER_DELAY_ALL_COS    (MIH_C_LINK_PARAM_QOS_T)2
#define MIH_C_LINK_PARAM_QOS_MAX_PACKET_TRANSFER_DELAY_ALL_COS    (MIH_C_LINK_PARAM_QOS_T)3
#define MIH_C_LINK_PARAM_QOS_STD_DEVIATION_PACKET_TRANSFER_DELAY  (MIH_C_LINK_PARAM_QOS_T)4
#define MIH_C_LINK_PARAM_QOS_PACKET_LOSS_RATE_ALL_COS_FRAME_RATIO (MIH_C_LINK_PARAM_QOS_T)5
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_GG_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for GSM and GPRS. See 3GPP TS 25.008.
*        0: RxQual
*        1: RsLev
*        2: Mean BEP
*        3: StDev BEP
*        4-255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_GG)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_EDGE_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for EDGE.
*        0-255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_EDGE)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_ETH_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for Ethernet.
*        0-255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_ETH)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_802_11_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for IEEE 802.11.
*        0: RSSI of the beacon channel, as defined in IEEE Std 802.11-2007.
*           (This is applicable only for an MN.)
*        1: No QoS resource available. The corresponding LINK_PARAM_VAL is BOOLEAN set to TRUE when
*           no QoS resources available. (This applicable when the traffic stream to be transmitted
*           is on an access category configured for mandatory admission control and the request for
*           bandwidth was denied by the available APs in the access network).
*        2: Multicast packet loss rate.
*        3–255: (Reserved)
*        Medieval extensions:
*           3: System Load. Percentage of usage load present at the system.
*           4:Number registered users.
*           5:Number active users.
*           6:Congestion window of users. Ordered list of the CW used by the clients, ordered according to
*             highest value of MAC address.
*           7:Transmission rate of users. Ordered list of the transmission rate used by the clients, ordered
*             according to highest value of MAC address.
*           8-255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_802_11)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_C2K_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for CDMA2000.
*        0: PILOT_STRENGTH
*        1–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_C2K)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_FDD_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for UMTS. See 3GPP TS 25.215.
*        0: CPICH RSCP
*        1: PCCPCH RSCP
*        2: UTRA carrier RSSI
*        3: GSM carrier RSSI
*        4: CPICH Ec/No
*        5: Transport channel BLER
*        6: user equipment (UE) transmitted power
*        7–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_FDD)
#define MIH_C_LINK_PARAM_FDD_CPICH_RSCP              (MIH_C_LINK_PARAM_FDD_T)0
#define MIH_C_LINK_PARAM_FDD_PCCPCH_RSCP             (MIH_C_LINK_PARAM_FDD_T)1
#define MIH_C_LINK_PARAM_FDD_UTRA_CARRIER_RSSI       (MIH_C_LINK_PARAM_FDD_T)2
#define MIH_C_LINK_PARAM_FDD_GSM_CARRIER_RSSI        (MIH_C_LINK_PARAM_FDD_T)3
#define MIH_C_LINK_PARAM_FDD_CPICH_EC_NO             (MIH_C_LINK_PARAM_FDD_T)4
#define MIH_C_LINK_PARAM_FDD_TRANSPORT_CHANNEL_BLER  (MIH_C_LINK_PARAM_FDD_T)5
#define MIH_C_LINK_PARAM_FDD_UE_TRANMITTED_POWER     (MIH_C_LINK_PARAM_FDD_T)6
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_HRPD_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for CDMA2000 HRPD.
*        0: PILOT_STRENGTH
*        1–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_HRPD)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_802_16_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for IEEE 802.16.
*        0–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_802_16)
//-------------------------------------------
/*! \var MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for IEEE 802.20.
*        0–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_802_20)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_802_22_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A type to represent a link parameter for IEEE 802.22.
*        0–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_802_22)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_LTE_T
* \ingroup MIH_C_MEDIEVAL_EXTENSIONS
* \brief A type to represent a link parameter for LTE.
*
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_PARAM_LTE)
#define MIH_C_LINK_PARAM_LTE_UE_RSRP                              0
#define MIH_C_LINK_PARAM_LTE_UE_RSRQ                              1
#define MIH_C_LINK_PARAM_LTE_UE_CQI                               2
#define MIH_C_LINK_PARAM_LTE_AVAILABLE_BW                         3
#define MIH_C_LINK_PARAM_LTE_PACKET_DELAY                         4
#define MIH_C_LINK_PARAM_LTE_PACKET_LOSS_RATE                     5
#define MIH_C_LINK_PARAM_LTE_L2_BUFFER_STATUS                     6
#define MIH_C_LINK_PARAM_LTE_MOBILE_NODE_CAPABILITIES             7
#define MIH_C_LINK_PARAM_LTE_EMBMS_CAPABILITY                     8
#define MIH_C_LINK_PARAM_LTE_JUMBO_FEASIBILITY                    9
#define MIH_C_LINK_PARAM_LTE_JUMBO_SETUP_STATUS                   10
#define MIH_C_LINK_PARAM_LTE_NUM_ACTIVE_EMBMS_RECEIVERS_PER_FLOW  11

//-------------------------------------------
/*! \struct  MIH_C_LINK_PARAM_TYPE_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Measurable link parameter for which thresholds are being set.
*/
#define MIH_C_LINK_PARAM_TYPE_CHOICE_GEN    (MIH_C_CHOICE_T)0
#define MIH_C_LINK_PARAM_TYPE_CHOICE_QOS    (MIH_C_CHOICE_T)1
#define MIH_C_LINK_PARAM_TYPE_CHOICE_GG     (MIH_C_CHOICE_T)2
#define MIH_C_LINK_PARAM_TYPE_CHOICE_EDGE   (MIH_C_CHOICE_T)3
#define MIH_C_LINK_PARAM_TYPE_CHOICE_ETH    (MIH_C_CHOICE_T)4
#define MIH_C_LINK_PARAM_TYPE_CHOICE_802_11 (MIH_C_CHOICE_T)5
#define MIH_C_LINK_PARAM_TYPE_CHOICE_C2K    (MIH_C_CHOICE_T)6
#define MIH_C_LINK_PARAM_TYPE_CHOICE_FDD    (MIH_C_CHOICE_T)7
#define MIH_C_LINK_PARAM_TYPE_CHOICE_HRPD   (MIH_C_CHOICE_T)8
#define MIH_C_LINK_PARAM_TYPE_CHOICE_802_16 (MIH_C_CHOICE_T)9
#define MIH_C_LINK_PARAM_TYPE_CHOICE_802_20 (MIH_C_CHOICE_T)10
#define MIH_C_LINK_PARAM_TYPE_CHOICE_802_22 (MIH_C_CHOICE_T)11
#define MIH_C_LINK_PARAM_TYPE_CHOICE_LTE    (MIH_C_CHOICE_T)12

typedef struct MIH_C_LINK_PARAM_TYPE {
    MIH_C_CHOICE_T               choice;
    union  {
        MIH_C_LINK_PARAM_GEN_T      link_param_gen;
        MIH_C_LINK_PARAM_QOS_T      link_param_qos;
        MIH_C_LINK_PARAM_GG_T       link_param_gg;
        MIH_C_LINK_PARAM_EDGE_T     link_param_edge;
        MIH_C_LINK_PARAM_ETH_T      link_param_eth;
        MIH_C_LINK_PARAM_802_11_T   link_param_802_11;
        MIH_C_LINK_PARAM_C2K_T      link_param_c2k;
        MIH_C_LINK_PARAM_FDD_T      link_param_fdd;
        MIH_C_LINK_PARAM_HRPD_T     link_param_hrpd;
        MIH_C_LINK_PARAM_802_16_T   link_param_802_16;
        MIH_C_LINK_PARAM_802_20_T   link_param_802_20;
        MIH_C_LINK_PARAM_802_22_T   link_param_802_22;
        MIH_C_LINK_PARAM_LTE_T      link_param_lte;
    } _union;
} MIH_C_LINK_PARAM_TYPE_T;
//-------------------------------------------
/*! \var MIH_C_THRESHOLD_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_THRESHOLD, MIH_C_THRESHOLD_LIST_LENGTH)
/*! \struct  MIH_C_LINK_CFG_PARAM_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A link configuration parameter.
*        TH_ACTION indicates what action to apply to the listed thresholds.
*        When “Cancel threshold” is selected and no thresholds are specified, then all
*        currently configured thresholds for the given LINK_PARAM_TYPE are cancelled.
*        When “Cancel threshold” is selected and thresholds are specified only those
*        configured thresholds for the given LINK_PARAM_TYPE and whose threshold value
*        match what was specified are cancelled.
*        With “Set one-shot threshold” the listed thresholds are first set and then each of
*        the threshold is cancelled as soon as it is crossed for the first time.
*/
typedef struct MIH_C_LINK_CFG_PARAM {
    MIH_C_LINK_PARAM_TYPE_T      link_param_type;
    MIH_C_CHOICE_T               choice;
    union  {
1676
        MIH_C_NULL_T             null_attr;
1677
        MIH_C_TIMER_INTERVAL_T   timer_interval;
gauthier's avatar
Updates    
gauthier committed
1678
#ifdef RAL_SAME_AS_MEDIEVAL_PROJECT_BUT_I_THINK_THIS_IS_AN_ERROR
1679
        LIST(MIH_C_LINK_SCAN_RSP, link_scan_rsp)
gauthier's avatar
Updates    
gauthier committed
1680
#endif
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
    } _union;
    MIH_C_TH_ACTION_T             th_action;
    LIST(MIH_C_THRESHOLD, threshold)
} MIH_C_LINK_CFG_PARAM_T;
//-------------------------------------------
/*! \struct  MIH_C_LINK_CFG_STATUS_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The status of link parameter configuration for each threshold specified in the THRESHOLD.
*/
typedef struct MIH_C_LINK_CFG_STATUS {
    MIH_C_LINK_PARAM_TYPE_T      link_param_type;
    MIH_C_THRESHOLD_T            threshold;
    MIH_C_CONFIG_STATUS_T        config_status;
} MIH_C_LINK_CFG_STATUS_T;
//-------------------------------------------
#define MIH_C_BIT_NUMBER_OF_CLASSES_OF_SERVICE_SUPPORTED    MIH_C_BIT_0_VALUE
#define MIH_C_BIT_NUMBER_OF_QUEUES_SUPPORTED                MIH_C_BIT_1_VALUE
/*! \var MIH_C_LINK_DESC_REQ_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A set of link descriptors.
*        Bitmap Values:
*        Bit 0: Number of Classes of Service Supported
*        Bit 1: Number of Queues Supported
*        Bits 2–15: (Reserved)
*/
TYPEDEF_BITMAP16(MIH_C_LINK_DESC_REQ)
//-------------------------------------------
/*! \var MIH_C_NUM_COS_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The maximum number of differentiable classes of service supported.
*        Valid Range: 0..255
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_NUM_COS)
//-------------------------------------------
/*! \var MIH_C_NUM_QUEUE_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The number of transmit queues supported.
*        Valid Range: 0..255
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_NUM_QUEUE)
//-------------------------------------------
/*! \struct  MIH_C_LINK_DESC_RSP_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Descriptors of a link.
*/
typedef struct MIH_C_LINK_DESC_RSP {
    MIH_C_CHOICE_T               choice;
    union  {
        MIH_C_NUM_COS_T          num_cos;
        MIH_C_NUM_QUEUE_T        num_queue;
    } _union;
} MIH_C_LINK_DESC_RSP_T;
//-------------------------------------------
/*! \var MIH_C_LINK_DN_REASON_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents the reason of a link down event.
*        See Table F.7 for the enumeration values.
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_DN_REASON)
//-------------------------------------------
#define MIH_C_BIT_LINK_DETECTED            MIH_C_BIT_0_VALUE
#define MIH_C_BIT_LINK_UP                  MIH_C_BIT_1_VALUE
#define MIH_C_BIT_LINK_DOWN                MIH_C_BIT_2_VALUE
#define MIH_C_BIT_LINK_PARAMETERS_REPORT   MIH_C_BIT_3_VALUE
#define MIH_C_BIT_LINK_GOING_DOWN          MIH_C_BIT_4_VALUE
#define MIH_C_BIT_LINK_HANDOVER_IMMINENT   MIH_C_BIT_5_VALUE
#define MIH_C_BIT_LINK_HANDOVER_COMPLETE   MIH_C_BIT_6_VALUE
#define MIH_C_BIT_LINK_PDU_TRANSMIT_STATUS MIH_C_BIT_7_VALUE
/*! \var MIH_C_LINK_EVENT_LIST_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A list of link events. The specified event is selected if the corresponding bit is set to 1.
*        Bitmap values:
*        Bit 0: Link_Detected
*        Bit 1: Link_Up
*        Bit 2: Link_Down
*        Bit 3: Link_Parameters_Report
*        Bit 4: Link_Going_Down
*        Bit 5: Link_Handover_Imminent
*        Bit 6: Link_Handover_Complete
*        Bit 7: Link_PDU_Transmit_Status
*        Bit 8–31: (Reserved)
*/
TYPEDEF_BITMAP32(MIH_C_LINK_EVENT_LIST)
//-------------------------------------------
/*! \var MIH_C_LINK_GD_REASON_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents the reason of a link going down. See Table F.8 for the enumeration values.
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_LINK_GD_REASON)
//-------------------------------------------
#define MIH_C_BIT_EVENT_SERVICE_SUPPORTED        MIH_C_BIT_1_VALUE
#define MIH_C_BIT_COMMAND_SERVICE_SUPPORTED      MIH_C_BIT_2_VALUE
#define MIH_C_BIT_INFORMATION_SERVICE_SUPPORTED  MIH_C_BIT_3_VALUE
/*! \var MIH_C_LINK_MIHCAP_FLAG_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents if MIH capability is supported or not. If the bit is set, it indicates
*        that the capability is supported.
*        Bitmap values:
*        Bit 1: event service (ES) supported
*        Bit 2: command service (CS) supported
*        Bit 3: information service (IS) supported
*        Bit 0, 4–7: (Reserved)
*/
TYPEDEF_BITMAP8(MIH_C_LINK_MIHCAP_FLAG)
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_VAL_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The current value of the parameter. The format of the media-dependent value is defined in
*        the respective media specification standard and the equivalent number of bits (i.e., first
*        bits) of this data type is used. In case that there are remaining unused bits in the data
*        type, these are marked as all-zeros (‘0’).
*        Valid Range: 0..65535
*/
TYPEDEF_UNSIGNED_INT2(MIH_C_LINK_PARAM_VAL)





//-----------------------------------------------------------------------------
// STD 802.21-2008 Table F.9 Data types for QOS (MAINLY because of precedence definition)
//-----------------------------------------------------------------------------
//-------------------------------------------
/*! \var MIH_C_COS_ID_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief Defines MIH_C_COS_ID_T as a MIH_C_UNSIGNED_INT1_T.
*        Valid Range: 0–255
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_COS_ID)
//-------------------------------------------
/*! \struct  MIH_C_MIN_PK_TX_DELAY_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief A type to represent the minimum packet transfer delay in ms for the specific CoS specified by the COS_ID.
*/
typedef struct MIH_C_MIN_PK_TX_DELAY {
    MIH_C_COS_ID_T               cos_id;
    UNSIGNED_INT2(value)
} MIH_C_MIN_PK_TX_DELAY_T;
//-------------------------------------------
/*! \struct  MIH_C_AVG_PK_TX_DELAY_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief A type to represent the average packet transfer delay in ms for the specific CoS specified by the COS_ID.
*/
typedef struct MIH_C_AVG_PK_TX_DELAY {
    MIH_C_COS_ID_T               cos_id;
    UNSIGNED_INT2(value)
} MIH_C_AVG_PK_TX_DELAY_T;
//-------------------------------------------
/*! \struct  MIH_C_MAX_PK_TX_DELAY_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief A type to represent the maximum packet transfer delay in ms for the specific CoS specified by the COS_ID.
*/
typedef struct MIH_C_MAX_PK_TX_DELAY {
    MIH_C_COS_ID_T               cos_id;
    UNSIGNED_INT2(value)
} MIH_C_MAX_PK_TX_DELAY_T;
//-------------------------------------------
/*! \struct  MIH_C_PK_DELAY_JITTER_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief A type to represent the packet transfer delay jitter in ms for the specific CoS specified by the COS_ID.
*/
typedef struct MIH_C_PK_DELAY_JITTER {
    MIH_C_COS_ID_T               cos_id;
    UNSIGNED_INT2(value)
} MIH_C_PK_DELAY_JITTER_T;
//-------------------------------------------
/*! \struct  MIH_C_PK_LOSS_RATE_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief A type to represent the packet loss rate for the specific CoS specified by the COS_ID. The loss rate is
*        equal to the integer part of the result of multiplying –100 times the log10 of the ratio between the num-
*        ber of packets lost and the total number of packets transmitted in the class population of interest.
*/
typedef struct MIH_C_PK_LOSS_RATE {
    MIH_C_COS_ID_T               cos_id;
    UNSIGNED_INT2(value)
} MIH_C_PK_LOSS_RATE_T;
//-------------------------------------------
/*! \var MIH_C_MIN_PK_TX_DELAY_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_MIN_PK_TX_DELAY, MIH_C_QOS_LIST_LENGTH)
/*! \var MIH_C_AVG_PK_TX_DELAY_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_AVG_PK_TX_DELAY, MIH_C_QOS_LIST_LENGTH)
/*! \var MIH_C_MAX_PK_TX_DELAY_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_MAX_PK_TX_DELAY, MIH_C_QOS_LIST_LENGTH)
/*! \var MIH_C_PK_DELAY_JITTER_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_PK_DELAY_JITTER, MIH_C_QOS_LIST_LENGTH)
/*! \var MIH_C_PK_LOSS_RATE_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_PK_LOSS_RATE,    MIH_C_QOS_LIST_LENGTH)

//-------------------------------------------
/*! \var MIH_C_NUM_COS_TYPES_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_NUM_COS_TYPES)

/*! \struct  MIH_C_QOS_PARAM_VAL_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief A choice of Class of Service (CoS) parameters.
*/
typedef struct MIH_C_QOS_PARAM_VAL {
    MIH_C_CHOICE_T               choice;
    union  {
        MIH_C_NUM_COS_TYPES_T    num_qos_types;
        LIST(MIH_C_MIN_PK_TX_DELAY, min_pk_tx_delay)
        LIST(MIH_C_AVG_PK_TX_DELAY, avg_pk_tx_delay)
        LIST(MIH_C_MAX_PK_TX_DELAY, max_pk_tx_delay)
        LIST(MIH_C_PK_DELAY_JITTER, pk_delay_jitter)
        LIST(MIH_C_PK_LOSS_RATE,    pk_loss_rate)
    } _union;
} MIH_C_QOS_PARAM_VAL_T;
#define MIH_C_QOS_PARAM_VAL_CHOICE_NUM_QOS_TYPES    (MIH_C_CHOICE_T)0
#define MIH_C_QOS_PARAM_VAL_CHOICE_MIN_PK_TX_DELAY  (MIH_C_CHOICE_T)1
#define MIH_C_QOS_PARAM_VAL_CHOICE_AVG_PK_TX_DELAY  (MIH_C_CHOICE_T)2
#define MIH_C_QOS_PARAM_VAL_CHOICE_MAX_PK_TX_DELAY  (MIH_C_CHOICE_T)3
#define MIH_C_QOS_PARAM_VAL_CHOICE_PK_DELAY_JITTER  (MIH_C_CHOICE_T)4
#define MIH_C_QOS_PARAM_VAL_CHOICE_PK_LOSS_RATE     (MIH_C_CHOICE_T)5

//-------------------------------------------
/*! \struct  MIH_C_QOS_LIST_T
* \ingroup MIH_C_F9_DATA_TYPES_FOR_QOS
* \brief A list of Class of Service (CoS) parameters.
*/
typedef struct MIH_C_QOS_LIST {
    MIH_C_NUM_COS_TYPES_T              num_qos_types;
    LIST(MIH_C_MIN_PK_TX_DELAY, min_pk_tx_delay)
    LIST(MIH_C_AVG_PK_TX_DELAY, avg_pk_tx_delay)
    LIST(MIH_C_MAX_PK_TX_DELAY, max_pk_tx_delay)
    LIST(MIH_C_PK_DELAY_JITTER, pk_delay_jitter)
    LIST(MIH_C_PK_LOSS_RATE,    pk_loss_rate)
} MIH_C_QOS_LIST_T;



//-------------------------------------------
/*! \struct  MIH_C_LINK_PARAM_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents a link parameter type and value pair.
*/
typedef struct MIH_C_LINK_PARAM {
    MIH_C_LINK_PARAM_TYPE_T      link_param_type;
    MIH_C_CHOICE_T               choice;
    union  {
        MIH_C_LINK_PARAM_VAL_T   link_param_val;
        MIH_C_QOS_PARAM_VAL_T    qos_param_val;
    } _union;
} MIH_C_LINK_PARAM_T;
#define MIH_C_LINK_PARAM_CHOICE_LINK_PARAM_VAL (MIH_C_CHOICE_T)0
#define MIH_C_LINK_PARAM_CHOICE_QOS_PARAM_VAL  (MIH_C_CHOICE_T)1
//-------------------------------------------
/*! \struct  MIH_C_LINK_PARAM_RPT_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents a link parameter report.
*        Includes an option of the THRESHOLD that was crossed.
*        If no THRESHOLD is included, then this is a periodic report.
*/
typedef struct MIH_C_LINK_PARAM_RPT {
    MIH_C_LINK_PARAM_T           link_param;
    MIH_C_CHOICE_T               choice;
    union  {
1950
        MIH_C_NULL_T             null_attr;
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
        MIH_C_THRESHOLD_T        threshold;
    } _union;
} MIH_C_LINK_PARAM_RPT_T;
#define MIH_C_LINK_PARAM_RPT_CHOICE_NULL      0
#define MIH_C_LINK_PARAM_RPT_CHOICE_THRESHOLD 1
//-------------------------------------------
/*! \var MIH_C_LINK_ADDR_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_LINK_ADDR, MIH_C_LINK_ADDR_LIST_LENGTH)
/*! \struct  MIH_C_LINK_POA_LIST_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A list of PoAs for a particular link. The LIST(LINK_ADDR) is a list of PoA
*        link addresses and is sorted from most preferred first to least preferred last.
*/
typedef struct MIH_C_LINK_POA_LIST {
    MIH_C_LINK_ID_T              link_id;
    LIST(MIH_C_LINK_ADDR, link_addr)
} MIH_C_LINK_POA_LIST_T;
//-------------------------------------------
#define MIH_C_LINK_RES_STATUS_AVAILABLE          MIH_C_MIH_C_BOOLEAN_TRUE
#define MIH_C_LINK_RES_STATUS_NOT_AVAILABLE      MIH_C_BOOLEAN_FALSE
/*! \var MIH_C_LINK_RES_STATUS_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Indicates if a resource is available or not.
*        TRUE: Available
*        FALSE: Not available.
*/
TYPEDEF_BOOLEAN(MIH_C_LINK_RES_STATUS)
//-------------------------------------------
#define MIH_C_BIT_LINK_STATES_REQ_OP_MODE            MIH_C_BIT_0_VALUE
#define MIH_C_BIT_LINK_STATES_REQ_CHANNEL_ID         MIH_C_BIT_1_VALUE
/*! \var MIH_C_LINK_STATES_REQ_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Link states to be requested.
* Bit 0: OP_MODE
* Bit 1: CHANNEL_ID
* Bit 2–15: (Reserved)
*/
TYPEDEF_BITMAP16(MIH_C_LINK_STATES_REQ)
//-------------------------------------------
#define MIH_C_OPMODE_NORMAL_MODE                 0
#define MIH_C_OPMODE_POWER_SAVING_MODE           1
#define MIH_C_OPMODE_POWERED_DOWN                2
/*! \var MIH_C_OPMODE_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The link power mode.
*        0: Normal Mode
*        1: Power Saving Mode
*        2: Powered Down
*        3–255: (Reserved)
*/
TYPEDEF_UNSIGNED_INT1(MIH_C_OPMODE)
//-------------------------------------------
/*! \struct  MIH_C_LINK_STATES_RSP_T
* \brief The operation mode or the channel ID of the link.
*/
typedef struct MIH_C_LINK_STATES_RSP {
    MIH_C_CHOICE_T               choice;
    union  {
        MIH_C_OPMODE_T           op_mode;
        MIH_C_CHANNEL_ID_T       channel_id;
    } _union;
} MIH_C_LINK_STATES_RSP_T;
//-------------------------------------------
/*! \var MIH_C_LINK_PARAM_TYPE_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_LINK_PARAM_TYPE, MIH_C_LINK_STATUS_REQ_LIST_LENGTH)
/*! \struct MIH_C_LINK_STATUS_REQ_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief Represents the possible information to request from a link.
*/
typedef struct MIH_C_LINK_STATUS_REQ {
    MIH_C_LINK_STATES_REQ_T      link_states_req;
    LIST(MIH_C_LINK_PARAM_TYPE, link_param_type)
    MIH_C_LINK_DESC_RSP_T        link_desc_rsp;
} MIH_C_LINK_STATUS_REQ_T;
//-------------------------------------------
/*! \var MIH_C_LINK_STATES_RSP_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_LINK_STATES_RSP, MIH_C_LINK_STATUS_REQ_LIST_LENGTH)
/*! \var MIH_C_LINK_PARAM_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_LINK_PARAM, MIH_C_LINK_STATUS_REQ_LIST_LENGTH)
/*! \var MIH_C_LINK_DESC_RSP_LIST_T
* \brief
*/
TYPEDEF_LIST(MIH_C_LINK_DESC_RSP, MIH_C_LINK_STATUS_REQ_LIST_LENGTH)
/*! \struct  MIH_C_LINK_STATUS_RSP_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief A set of link status parameter values correspond to the LINK_STATUS_REQ.
*/
typedef struct MIH_C_LINK_STATUS_RSP {
    LIST(MIH_C_LINK_STATES_RSP,  link_states_rsp)
    LIST(MIH_C_LINK_PARAM,       link_param)
    LIST(MIH_C_LINK_DESC_RSP,    link_desc_rsp)
} MIH_C_LINK_STATUS_RSP_T;
//-------------------------------------------
/*! \struct  MIH_C_LINK_TUPLE_ID_T
* \ingroup MIH_C_F4_DATA_TYPES_FOR_LINKS_CODEC
* \brief The identifier of a link that is associated with a PoA. The LINK_ID contains the MN LINK_ADDR.
*        The optional LINK_ADDR contains a link address of PoA.
*/
typedef struct MIH_C_LINK_TUPLE_ID {
    MIH_C_LINK_ID_T              link_id;
    MIH_C_CHOICE_T               choice;
    union  {
2061
        MIH_C_NULL_T             null_attr;
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113