commonDef.h 8.62 KB
Newer Older
nikaeinn's avatar
nikaeinn 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
29
/*******************************************************************************
    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, Compus SophiaTech 450, route des chappes, 06451 Biot, France.

*******************************************************************************/
/*
Cedric Roux's avatar
   
Cedric Roux committed
30

Cedric Roux's avatar
Cedric Roux committed
31
Source      commonDef.h
Cedric Roux's avatar
   
Cedric Roux committed
32

Cedric Roux's avatar
Cedric Roux committed
33
Version     0.1
Cedric Roux's avatar
   
Cedric Roux committed
34

Cedric Roux's avatar
Cedric Roux committed
35
Date        2012/02/27
Cedric Roux's avatar
   
Cedric Roux committed
36

Cedric Roux's avatar
Cedric Roux committed
37
Product     NAS stack
Cedric Roux's avatar
   
Cedric Roux committed
38

Cedric Roux's avatar
Cedric Roux committed
39
Subsystem   include
Cedric Roux's avatar
   
Cedric Roux committed
40

Cedric Roux's avatar
Cedric Roux committed
41
Author      Frederic Maurel
Cedric Roux's avatar
   
Cedric Roux committed
42

Cedric Roux's avatar
Cedric Roux committed
43
Description Contains global common definitions
Cedric Roux's avatar
   
Cedric Roux committed
44
45
46
47
48
49
50
51
52
53
54
55

*****************************************************************************/
#ifndef __COMMONDEF_H__
#define __COMMONDEF_H__

#include <stdint.h>
#include <stddef.h>

/****************************************************************************/
/*********************  G L O B A L    C O N S T A N T S  *******************/
/****************************************************************************/

Cedric Roux's avatar
Cedric Roux committed
56
57
#define RETURNok        (0)
#define RETURNerror     (-1)
Cedric Roux's avatar
   
Cedric Roux committed
58
59

#ifndef FALSE
Cedric Roux's avatar
Cedric Roux committed
60
#define FALSE           (0)
Cedric Roux's avatar
   
Cedric Roux committed
61
62
#endif
#ifndef TRUE
Cedric Roux's avatar
Cedric Roux committed
63
#define TRUE            (1)
Cedric Roux's avatar
   
Cedric Roux committed
64
65
66
67
68
69
70
#endif

/*
 * Name of the environment variable which defines the default directory
 * where the NAS application is executed and where are located files
 * where non-volatile data are stored
 */
Cedric Roux's avatar
Cedric Roux committed
71
#define DEFAULT_NAS_PATH    "PWD"
Cedric Roux's avatar
   
Cedric Roux committed
72
73
74
75
76
77
78

/****************************************************************************/
/************************  G L O B A L    T Y P E S  ************************/
/****************************************************************************/

/*
-----------------------------------------------------------------------------
Cedric Roux's avatar
Cedric Roux committed
79
            Standard data type definitions
Cedric Roux's avatar
   
Cedric Roux committed
80
81
-----------------------------------------------------------------------------
*/
gauthier's avatar
gauthier committed
82
83
typedef int8_t      SByte_t;    /* 8 bit  signed integer     */
typedef int8_t      Int8_t;     /* 8 bit  signed integer     */
Cedric Roux's avatar
Cedric Roux committed
84
85
86
typedef int16_t     Int16_t;    /* 16 bit signed integer    */
typedef int32_t     Int32_t;    /* 32 bit signed integer    */
typedef int64_t     Int64_t;    /* 64 bit signed integer    */
Cedric Roux's avatar
   
Cedric Roux committed
87
88


Cedric Roux's avatar
Cedric Roux committed
89
90
91
92
93
typedef uint8_t     Byte_t;     /* 8 bit unsigned integer   */
typedef uint8_t     UInt8_t;    /* 8 bit unsigned integer   */
typedef uint16_t    UInt16_t;   /* 16 bit unsigned integer  */
typedef uint32_t    UInt32_t;   /* 32 bit unsigned integer  */
typedef uint64_t    UInt64_t;   /* 64 bit unsigned integer  */
Cedric Roux's avatar
   
Cedric Roux committed
94
95
96

/*
-----------------------------------------------------------------------------
Cedric Roux's avatar
Cedric Roux committed
97
            Common NAS data type definitions
Cedric Roux's avatar
   
Cedric Roux committed
98
99
100
-----------------------------------------------------------------------------
*/

Cedric Roux's avatar
Cedric Roux committed
101
102
103
104
105
106
typedef UInt8_t     Stat_t;     /* Registration status  */
typedef UInt16_t    lac_t;      /* Location Area Code   */
typedef UInt8_t     rac_t;      /* Routing Area Code    */
typedef UInt16_t    tac_t;      /* Tracking Area Code   */
typedef UInt32_t    ci_t;       /* Cell Identifier  */
typedef UInt8_t     AcT_t;      /* Access Technology    */
Cedric Roux's avatar
   
Cedric Roux committed
107
108
109
110
111
112
113

/*
 * International Mobile Subscriber Identity
 */
typedef struct {
    Byte_t length;
    union {
Cedric Roux's avatar
Cedric Roux committed
114
115
116
        struct {
            Byte_t digit2:4;
            Byte_t digit1:4;
Cedric Roux's avatar
Cedric Roux committed
117
118
119
120
121
122
123
124
125
126
127
128
            Byte_t digit4:4;
            Byte_t digit3:4;
            Byte_t digit6:4;
            Byte_t digit5:4;
            Byte_t digit8:4;
            Byte_t digit7:4;
            Byte_t digit10:4;
            Byte_t digit9:4;
            Byte_t digit12:4;
            Byte_t digit11:4;
            Byte_t digit14:4;
            Byte_t digit13:4;
Cedric Roux's avatar
Cedric Roux committed
129
130
131
#define EVEN_PARITY 0
#define ODD_PARITY  1
            Byte_t parity:4;
Cedric Roux's avatar
Cedric Roux committed
132
            Byte_t digit15:4;
Cedric Roux's avatar
Cedric Roux committed
133
134
135
        } num;
#define IMSI_SIZE   8
        Byte_t value[IMSI_SIZE];
Cedric Roux's avatar
   
Cedric Roux committed
136
137
138
139
140
141
142
143
    } u;
} imsi_t;

/*
 * Mobile subscriber dialing number
 */
typedef struct {
    Byte_t ext:1;
Cedric Roux's avatar
Cedric Roux committed
144
145
146
147
148
149
150
151
    /* Type Of Number           */
#define MSISDN_TON_UNKNOWKN     0b000
#define MSISDN_TON_INTERNATIONAL    0b001
#define MSISDN_TON_NATIONAL     0b010
#define MSISDN_TON_NETWORK      0b011
#define MSISDN_TON_SUBCRIBER        0b100
#define MSISDN_TON_ABBREVIATED      0b110
#define MSISDN_TON_RESERVED     0b111
Cedric Roux's avatar
   
Cedric Roux committed
152
    Byte_t ton:3;
Cedric Roux's avatar
Cedric Roux committed
153
154
155
156
157
158
159
160
161
162
163
    /* Numbering Plan Identification    */
#define MSISDN_NPI_UNKNOWN      0b0000
#define MSISDN_NPI_ISDN_TELEPHONY   0b0001
#define MSISDN_NPI_GENERIC      0b0010
#define MSISDN_NPI_DATA         0b0011
#define MSISDN_NPI_TELEX        0b0100
#define MSISDN_NPI_MARITIME_MOBILE  0b0101
#define MSISDN_NPI_LAND_MOBILE      0b0110
#define MSISDN_NPI_ISDN_MOBILE      0b0111
#define MSISDN_NPI_PRIVATE      0b1110
#define MSISDN_NPI_RESERVED     0b1111
Cedric Roux's avatar
   
Cedric Roux committed
164
    Byte_t npi:4;
Cedric Roux's avatar
Cedric Roux committed
165
    /* Dialing Number           */
Cedric Roux's avatar
   
Cedric Roux committed
166
    struct {
Cedric Roux's avatar
Cedric Roux committed
167
168
169
        Byte_t lsb:4;
        Byte_t msb:4;
#define MSISDN_DIGIT_SIZE   10
Cedric Roux's avatar
   
Cedric Roux committed
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
    } digit[MSISDN_DIGIT_SIZE];
} msisdn_t;

/*
 * International Mobile Equipment Identity
 */
typedef imsi_t imei_t;

/*
 * Public Land Mobile Network identifier
 * PLMN = BCD encoding (Mobile Country Code + Mobile Network Code)
 */
typedef struct {
    Byte_t MCCdigit2:4;
    Byte_t MCCdigit1:4;
    Byte_t MNCdigit3:4;
    Byte_t MCCdigit3:4;
    Byte_t MNCdigit2:4;
    Byte_t MNCdigit1:4;
} plmn_t;

/*
 * Location Area Identification
 */
typedef struct {
Cedric Roux's avatar
Cedric Roux committed
195
196
    plmn_t plmn;    /* <MCC> + <MNC>    */
    lac_t lac;      /* Location Area Code   */
Cedric Roux's avatar
   
Cedric Roux committed
197
198
199
200
201
202
} lai_t;

/*
 * GPRS Routing Area Identification
 */
typedef struct {
Cedric Roux's avatar
Cedric Roux committed
203
204
205
    plmn_t plmn;    /* <MCC> + <MNC>    */
    lac_t lac;      /* Location Area Code   */
    rac_t rac;      /* Routing Area Code    */
Cedric Roux's avatar
   
Cedric Roux committed
206
207
208
209
210
211
} RAI_t;

/*
 * EPS Tracking Area Identification
 */
typedef struct {
Cedric Roux's avatar
Cedric Roux committed
212
213
    plmn_t plmn;    /* <MCC> + <MNC>    */
    tac_t tac;      /* Tracking Area Code   */
Cedric Roux's avatar
   
Cedric Roux committed
214
215
216
217
218
219
} tai_t;

/*
 * EPS Globally Unique MME Identity
 */
typedef struct {
Cedric Roux's avatar
Cedric Roux committed
220
221
222
    plmn_t plmn;    /* <MCC> + <MNC>    */
    UInt16_t MMEgid;    /* MME group identifier */
    UInt8_t MMEcode;    /* MME code     */
Cedric Roux's avatar
   
Cedric Roux committed
223
224
225
226
227
228
} gummei_t;

/*
 * EPS Globally Unique Temporary UE Identity
 */
typedef struct {
Cedric Roux's avatar
Cedric Roux committed
229
230
    gummei_t gummei;    /* Globally Unique MME Identity         */
    UInt32_t m_tmsi;    /* M-Temporary Mobile Subscriber Identity   */
Cedric Roux's avatar
   
Cedric Roux committed
231
232
233
} GUTI_t;

/* Checks PLMN validity */
Cedric Roux's avatar
Cedric Roux committed
234
235
236
#define PLMN_IS_VALID(plmn) (((plmn).MCCdigit1 &    \
                              (plmn).MCCdigit2 &    \
                              (plmn).MCCdigit3) != 0x0F)
Cedric Roux's avatar
   
Cedric Roux committed
237
238

/* Checks TAC validity */
Cedric Roux's avatar
Cedric Roux committed
239
#define TAC_IS_VALID(tac)   (((tac) != 0x0000) && ((tac) != 0xFFF0))
Cedric Roux's avatar
   
Cedric Roux committed
240
241

/* Checks TAI validity */
Cedric Roux's avatar
Cedric Roux committed
242
243
#define TAI_IS_VALID(tai)   (PLMN_IS_VALID((tai).plmn) &&   \
                             TAC_IS_VALID((tai).tac))
Cedric Roux's avatar
   
Cedric Roux committed
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
 * A list of PLMNs
 */
#define PLMN_LIST_T(SIZE) struct {Byte_t n_plmns; plmn_t plmn[SIZE];}

/*
 * A list of TACs
 */
#define TAC_LIST_T(SIZE) struct {Byte_t n_tacs; TAC_t tac[SIZE];}

/*
 * A list of TAIs
 */
#define TAI_LIST_T(SIZE) struct {Byte_t n_tais; tai_t tai[SIZE];}

/*
 * User notification callback, executed whenever a change of data with
 * respect of network information (e.g. network registration and/or
 * location change, new PLMN becomes available) is notified by the
 * EPS Mobility Management sublayer
 */
Cedric Roux's avatar
Cedric Roux committed
265
266
typedef int (*emm_indication_callback_t) (Stat_t, tac_t, ci_t, AcT_t,
        const char *, size_t);
Cedric Roux's avatar
   
Cedric Roux committed
267

winckel's avatar
winckel committed
268
269
270
271
272
273
274
275
typedef enum eps_protocol_discriminator_e {
    /* Protocol discriminator identifier for EPS Mobility Management */
    EPS_MOBILITY_MANAGEMENT_MESSAGE =   0x7,

    /* Protocol discriminator identifier for EPS Session Management */
    EPS_SESSION_MANAGEMENT_MESSAGE =    0x2,
} eps_protocol_discriminator_t;

Cedric Roux's avatar
   
Cedric Roux committed
276
277
278
279
280
281
282
283
284
/****************************************************************************/
/********************  G L O B A L    V A R I A B L E S  ********************/
/****************************************************************************/

/****************************************************************************/
/******************  E X P O R T E D    F U N C T I O N S  ******************/
/****************************************************************************/

#endif /* __COMMONDEF_H__*/