blob: 8de636293b7b343721b01c12b2804c4da910ffb9 [file] [log] [blame]
Harald Welte9b455bf2010-03-14 15:45:01 +08001#ifndef _GSM48_GPRS_H
2#define _GSM48_GPRS_H
3
Harald Welteeaa614c2010-05-02 11:26:34 +02004#include <stdint.h>
Harald Welte6abf94e2010-05-18 10:35:06 +02005#include <osmocore/protocol/gsm_04_08.h>
Harald Welteeaa614c2010-05-02 11:26:34 +02006
Harald Welte9b455bf2010-03-14 15:45:01 +08007/* Table 10.4 / 10.4a, GPRS Mobility Management (GMM) */
8#define GSM48_MT_GMM_ATTACH_REQ 0x01
9#define GSM48_MT_GMM_ATTACH_ACK 0x02
10#define GSM48_MT_GMM_ATTACH_COMPL 0x03
11#define GSM48_MT_GMM_ATTACH_REJ 0x04
12#define GSM48_MT_GMM_DETACH_REQ 0x05
13#define GSM48_MT_GMM_DETACH_ACK 0x06
14
15#define GSM48_MT_GMM_RA_UPD_REQ 0x08
16#define GSM48_MT_GMM_RA_UPD_ACK 0x09
17#define GSM48_MT_GMM_RA_UPD_COMPL 0x0a
18#define GSM48_MT_GMM_RA_UPD_REJ 0x0b
19
20#define GSM48_MT_GMM_PTMSI_REALL_CMD 0x10
21#define GSM48_MT_GMM_PTMSI_REALL_COMPL 0x11
22#define GSM48_MT_GMM_AUTH_CIPH_REQ 0x12
23#define GSM48_MT_GMM_AUTH_CIPH_RESP 0x13
24#define GSM48_MT_GMM_AUTH_CIPH_REJ 0x14
25#define GSM48_MT_GMM_ID_REQ 0x15
26#define GSM48_MT_GMM_ID_RESP 0x16
27#define GSM48_MT_GMM_STATUS 0x20
28#define GSM48_MT_GMM_INFO 0x21
29
30/* Table 10.4a, GPRS Session Management (GSM) */
31#define GSM48_MT_GSM_ACT_PDP_REQ 0x41
32#define GSM48_MT_GSM_ACT_PDP_ACK 0x42
33#define GSM48_MT_GSM_ACT_PDP_REJ 0x43
34#define GSM48_MT_GSM_REQ_PDP_ACT 0x44
35#define GSM48_MT_GSM_REQ_PDP_ACT_REJ 0x45
36#define GSM48_MT_GSM_DEACT_PDP_REQ 0x46
37#define GSM48_MT_GSM_DEACT_PDP_ACK 0x47
38#define GSM48_MT_GSM_ACT_AA_PDP_REQ 0x50
39#define GSM48_MT_GSM_ACT_AA_PDP_ACK 0x51
40#define GSM48_MT_GSM_ACT_AA_PDP_REJ 0x52
41#define GSM48_MT_GSM_DEACT_AA_PDP_REQ 0x53
42#define GSM48_MT_GSM_DEACT_AA_PDP_ACK 0x54
43#define GSM48_MT_GSM_STATUS 0x55
44
45/* Chapter 10.5.5.2 / Table 10.5.135 */
46#define GPRS_ATT_T_ATTACH 1
47#define GPRS_ATT_T_ATT_WHILE_IMSI 2
48#define GPRS_ATT_T_COMBINED 3
49
Harald Welte2720e732010-05-17 00:44:57 +020050/* Chapter 10.5.5.5 / Table 10.5.138 */
51#define GPRS_DET_T_MO_GPRS 1
52#define GPRS_DET_T_MO_IMSI 2
53#define GPRS_DET_T_MO_COMBINED 3
54/* Network to MS direction */
55#define GPRS_DET_T_MT_REATT_REQ 1
56#define GPRS_DET_T_MT_REATT_NOTREQ 2
57#define GPRS_DET_T_MT_IMSI 3
58
Harald Welte9b455bf2010-03-14 15:45:01 +080059/* Chapter 10.5.5.18 / Table 105.150 */
60#define GPRS_UPD_T_RA 0
61#define GPRS_UPD_T_RA_LA 1
62#define GPRS_UPD_T_RA_LA_IMSI_ATT 2
63#define GPRS_UPD_T_PERIODIC 3
64
65enum gsm48_gprs_ie_mm {
Harald Welte4b6ac1e2010-07-03 11:09:06 +020066 GSM48_IE_GMM_CIPH_CKSN = 0x08, /* 10.5.1.2 */
Harald Welte6463c072010-05-18 17:04:55 +020067 GSM48_IE_GMM_TIMER_READY = 0x17, /* 10.5.7.3 */
68 GSM48_IE_GMM_ALLOC_PTMSI = 0x18, /* 10.5.1.4 */
Harald Welte9b455bf2010-03-14 15:45:01 +080069 GSM48_IE_GMM_PTMSI_SIG = 0x19, /* 10.5.5.8 */
Harald Welte6463c072010-05-18 17:04:55 +020070 GSM48_IE_GMM_AUTH_RAND = 0x21, /* 10.5.3.1 */
71 GSM48_IE_GMM_AUTH_SRES = 0x22, /* 10.5.3.2 */
72 GSM48_IE_GMM_IMEISV = 0x23, /* 10.5.1.4 */
Harald Welte9b455bf2010-03-14 15:45:01 +080073 GSM48_IE_GMM_DRX_PARAM = 0x27, /* 10.5.5.6 */
74 GSM48_IE_GMM_MS_NET_CAPA = 0x31, /* 10.5.5.12 */
Harald Welte588d44e2010-06-09 10:28:29 +020075 GSM48_IE_GMM_PDP_CTX_STATUS = 0x32, /* 10.5.7.1 */
76 GSM48_IE_GMM_PS_LCS_CAPA = 0x33, /* 10.5.5.22 */
77 GSM48_IE_GMM_GMM_MBMS_CTX_ST = 0x35, /* 10.5.7.6 */
Harald Welte9b455bf2010-03-14 15:45:01 +080078};
79
80enum gsm48_gprs_ie_sm {
81 GSM48_IE_GSM_APN = 0x28, /* 10.5.6.1 */
82 GSM48_IE_GSM_PROTO_CONF_OPT = 0x27, /* 10.5.6.3 */
83 GSM48_IE_GSM_PDP_ADDR = 0x2b, /* 10.5.6.4 */
84 GSM48_IE_GSM_AA_TMR = 0x29, /* 10.5.7.3 */
85 GSM48_IE_GSM_NAME_FULL = 0x43, /* 10.5.3.5a */
86 GSM48_IE_GSM_NAME_SHORT = 0x45, /* 10.5.3.5a */
87 GSM48_IE_GSM_TIMEZONE = 0x46, /* 10.5.3.8 */
88 GSM48_IE_GSM_UTC_AND_TZ = 0x47, /* 10.5.3.9 */
89 GSM48_IE_GSM_LSA_ID = 0x48, /* 10.5.3.11 */
Harald Welte2720e732010-05-17 00:44:57 +020090
91 /* Fake IEs that are not present on the Layer3 air interface,
92 * but which we use to simplify internal APIs */
93 OSMO_IE_GSM_REQ_QOS = 0xfd,
94 OSMO_IE_GSM_REQ_PDP_ADDR = 0xfe,
Harald Welte9b455bf2010-03-14 15:45:01 +080095};
96
Harald Welte9b455bf2010-03-14 15:45:01 +080097/* Chapter 9.4.15 / Table 9.4.15 */
98struct gsm48_ra_upd_ack {
Harald Welteeaa614c2010-05-02 11:26:34 +020099 uint8_t force_stby:4, /* 10.5.5.7 */
Harald Welte9b455bf2010-03-14 15:45:01 +0800100 upd_result:4; /* 10.5.5.17 */
Harald Welteeaa614c2010-05-02 11:26:34 +0200101 uint8_t ra_upd_timer; /* 10.5.7.3 */
Harald Welte9b455bf2010-03-14 15:45:01 +0800102 struct gsm48_ra_id ra_id; /* 10.5.5.15 */
Harald Welteeaa614c2010-05-02 11:26:34 +0200103 uint8_t data[0];
Harald Welte9b455bf2010-03-14 15:45:01 +0800104} __attribute__((packed));
105
106/* Chapter 10.5.7.3 */
107enum gsm48_gprs_tmr_unit {
108 GPRS_TMR_2SECONDS = 0 << 5,
109 GPRS_TMR_MINUTE = 1 << 5,
110 GPRS_TMR_6MINUTE = 2 << 5,
111 GPRS_TMR_DEACTIVATED = 3 << 5,
112};
113
114/* Chapter 9.4.2 / Table 9.4.2 */
115struct gsm48_attach_ack {
Harald Welteeaa614c2010-05-02 11:26:34 +0200116 uint8_t att_result:4, /* 10.5.5.7 */
Harald Welte9b455bf2010-03-14 15:45:01 +0800117 force_stby:4; /* 10.5.5.1 */
Harald Welteeaa614c2010-05-02 11:26:34 +0200118 uint8_t ra_upd_timer; /* 10.5.7.3 */
119 uint8_t radio_prio; /* 10.5.7.2 */
Harald Welte9b455bf2010-03-14 15:45:01 +0800120 struct gsm48_ra_id ra_id; /* 10.5.5.15 */
Harald Welteeaa614c2010-05-02 11:26:34 +0200121 uint8_t data[0];
Harald Welte9b455bf2010-03-14 15:45:01 +0800122} __attribute__((packed));
123
Harald Welte4b6ac1e2010-07-03 11:09:06 +0200124/* Chapter 9.4.9 / Table 9.4.9 */
125struct gsm48_auth_ciph_req {
126 uint8_t ciph_alg:4, /* 10.5.5.3 */
127 imeisv_req:4; /* 10.5.5.10 */
128 uint8_t force_stby:4, /* 10.5.5.7 */
129 ac_ref_nr:4; /* 10.5.5.19 */
130 uint8_t data[0];
131} __attribute__((packed));
132/* optional: TV RAND, TV CKSN */
133
134struct gsm48_auth_ciph_resp {
135 uint8_t ac_ref_nr:4,
136 spare:4;
137 uint8_t data[0];
138} __attribute__((packed));
139
Harald Welte9b455bf2010-03-14 15:45:01 +0800140/* Chapter 9.5.1 / Table 9.5.1 */
141struct gsm48_act_pdp_ctx_req {
Harald Welteeaa614c2010-05-02 11:26:34 +0200142 uint8_t req_nsapi;
143 uint8_t req_llc_sapi;
Harald Welteeaa614c2010-05-02 11:26:34 +0200144 uint8_t data[0];
Harald Welte9b455bf2010-03-14 15:45:01 +0800145} __attribute__((packed));
146
Harald Welte9b455bf2010-03-14 15:45:01 +0800147/* Chapter 10.5.5.14 / Table 10.5.147 */
148enum gsm48_gmm_cause {
149 GMM_CAUSE_IMSI_UNKNOWN = 0x02,
150 GMM_CAUSE_ILLEGAL_MS = 0x03,
151 GMM_CAUSE_ILLEGAL_ME = 0x06,
152 GMM_CAUSE_GPRS_NOTALLOWED = 0x07,
153 GMM_CAUSE_GPRS_OTHER_NOTALLOWED = 0x08,
154 GMM_CAUSE_MS_ID_NOT_DERIVED = 0x09,
155 GMM_CAUSE_IMPL_DETACHED = 0x0a,
156 GMM_CAUSE_PLMN_NOTALLOWED = 0x0b,
157 GMM_CAUSE_LA_NOTALLOWED = 0x0c,
158 GMM_CAUSE_ROAMING_NOTALLOWED = 0x0d,
159 GMM_CAUSE_NO_GPRS_PLMN = 0x0e,
160 GMM_CAUSE_MSC_TEMP_NOTREACH = 0x10,
161 GMM_CAUSE_NET_FAIL = 0x11,
162 GMM_CAUSE_CONGESTION = 0x16,
163 GMM_CAUSE_SEM_INCORR_MSG = 0x5f,
164 GMM_CAUSE_INV_MAND_INFO = 0x60,
165 GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL = 0x61,
166 GMM_CAUSE_MSGT_INCOMP_P_STATE = 0x62,
167 GMM_CAUSE_IE_NOTEXIST_NOTIMPL = 0x63,
168 GMM_CAUSE_COND_IE_ERR = 0x64,
169 GMM_CAUSE_MSG_INCOMP_P_STATE = 0x65,
170 GMM_CAUSE_PROTO_ERR_UNSPEC = 0x6f,
171};
172
173/* Chapter 10.4.6.6 / Table 10.5.157 */
174enum gsm48_gsm_cause {
175 GSM_CAUSE_INSUFF_RSRC = 0x1a,
176 GSM_CAUSE_MISSING_APN = 0x1b,
177 GSM_CAUSE_UNKNOWN_PDP = 0x1c,
178 GSM_CAUSE_AUTH_FAILED = 0x1d,
179 GSM_CAUSE_ACT_REJ_GGSN = 0x1e,
180 GSM_CAUSE_ACT_REJ_UNSPEC = 0x1f,
181 GSM_CAUSE_SERV_OPT_NOTSUPP = 0x20,
182 GSM_CAUSE_REQ_SERV_OPT_NOTSUB = 0x21,
183 GSM_CAUSE_SERV_OPT_TEMP_OOO = 0x22,
184 GSM_CAUSE_NSAPI_IN_USE = 0x23,
185 GSM_CAUSE_DEACT_REGULAR = 0x24,
186 GSM_CAUSE_QOS_NOT_ACCEPTED = 0x25,
187 GSM_CAUSE_NET_FAIL = 0x26,
188 GSM_CAUSE_REACT_RQD = 0x27,
189 GSM_CAUSE_FEATURE_NOTSUPP = 0x28,
190 GSM_CAUSE_INVALID_TRANS_ID = 0x51,
191 GSM_CAUSE_SEM_INCORR_MSG = 0x5f,
192 GSM_CAUSE_INV_MAND_INFO = 0x60,
193 GSM_CAUSE_MSGT_NOTEXIST_NOTIMPL = 0x61,
194 GSM_CAUSE_MSGT_INCOMP_P_STATE = 0x62,
195 GSM_CAUSE_IE_NOTEXIST_NOTIMPL = 0x63,
196 GSM_CAUSE_COND_IE_ERR = 0x64,
197 GSM_CAUSE_MSG_INCOMP_P_STATE = 0x65,
198 GSM_CAUSE_PROTO_ERR_UNSPEC = 0x6f,
199};
200
Harald Welte9b455bf2010-03-14 15:45:01 +0800201/* Section 6.1.2.2: Session management states on the network side */
202enum gsm48_pdp_state {
203 PDP_S_INACTIVE,
204 PDP_S_ACTIVE_PENDING,
205 PDP_S_ACTIVE,
206 PDP_S_INACTIVE_PENDING,
207 PDP_S_MODIFY_PENDING,
208};
209
Harald Welte421cba42010-05-02 23:11:50 +0200210/* Table 10.5.155/3GPP TS 24.008 */
211enum gsm48_pdp_type_org {
212 PDP_TYPE_ORG_ETSI = 0x00,
213 PDP_TYPE_ORG_IETF = 0x01,
214};
215enum gsm48_pdp_type_nr {
216 PDP_TYPE_N_ETSI_RESERVED = 0x00,
217 PDP_TYPE_N_ETSI_PPP = 0x01,
218 PDP_TYPE_N_IETF_IPv4 = 0x21,
219 PDP_TYPE_N_IETF_IPv6 = 0x57,
220};
221
Harald Welte86fda902010-05-03 10:54:35 +0200222/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
223enum gsm48_qos_reliab_class {
224 GSM48_QOS_RC_LLC_ACK_RLC_ACK_DATA_PROT = 2,
225 GSM48_QOS_RC_LLC_UN_RLC_ACK_DATA_PROT = 3,
226 GSM48_QOS_RC_LLC_UN_RLC_UN_PROT_DATA = 4,
227 GSM48_QOS_RC_LLC_UN_RLC_UN_DATA_UN = 5,
228};
229
230/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
231enum gsm48_qos_preced_class {
232 GSM48_QOS_PC_HIGH = 1,
233 GSM48_QOS_PC_NORMAL = 2,
234 GSM48_QOS_PC_LOW = 3,
235};
236
237/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
238enum gsm48_qos_peak_tput {
239 GSM48_QOS_PEAK_TPUT_1000bps = 1,
240 GSM48_QOS_PEAK_TPUT_2000bps = 2,
241 GSM48_QOS_PEAK_TPUT_4000bps = 3,
242 GSM48_QOS_PEAK_TPUT_8000bps = 4,
243 GSM48_QOS_PEAK_TPUT_16000bps = 5,
244 GSM48_QOS_PEAK_TPUT_32000bps = 6,
245 GSM48_QOS_PEAK_TPUT_64000bps = 7,
246 GSM48_QOS_PEAK_TPUT_128000bps = 8,
247 GSM48_QOS_PEAK_TPUT_256000bps = 9,
248};
249
250/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
251enum gsm48_qos_mean_tput {
252 GSM48_QOS_MEAN_TPUT_100bph = 1,
253 GSM48_QOS_MEAN_TPUT_200bph = 2,
254 GSM48_QOS_MEAN_TPUT_500bph = 3,
255 GSM48_QOS_MEAN_TPUT_1000bph = 4,
256 GSM48_QOS_MEAN_TPUT_2000bph = 5,
257 GSM48_QOS_MEAN_TPUT_5000bph = 6,
258 GSM48_QOS_MEAN_TPUT_10000bph = 7,
259 GSM48_QOS_MEAN_TPUT_20000bph = 8,
260 GSM48_QOS_MEAN_TPUT_50000bph = 9,
261 GSM48_QOS_MEAN_TPUT_100kbph = 10,
262 GSM48_QOS_MEAN_TPUT_200kbph = 11,
263 GSM48_QOS_MEAN_TPUT_500kbph = 0xc,
264 GSM48_QOS_MEAN_TPUT_1Mbph = 0xd,
265 GSM48_QOS_MEAN_TPUT_2Mbph = 0xe,
266 GSM48_QOS_MEAN_TPUT_5Mbph = 0xf,
267 GSM48_QOS_MEAN_TPUT_10Mbph = 0x10,
268 GSM48_QOS_MEAN_TPUT_20Mbph = 0x11,
269 GSM48_QOS_MEAN_TPUT_50Mbph = 0x12,
270 GSM48_QOS_MEAN_TPUT_BEST_EFFORT = 0x1f,
271};
272
273/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
274enum gsm48_qos_err_sdu {
275 GSM48_QOS_ERRSDU_NODETECT = 1,
276 GSM48_QOS_ERRSDU_YES = 2,
277 GSM48_QOS_ERRSDU_NO = 3,
278};
279
280/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
281enum gsm48_qos_deliv_order {
282 GSM48_QOS_DO_ORDERED = 1,
283 GSM48_QOS_DO_UNORDERED = 2,
284};
285
286/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
287enum gsm48_qos_traf_class {
288 GSM48_QOS_TC_CONVERSATIONAL = 1,
289 GSM48_QOS_TC_STREAMING = 2,
290 GSM48_QOS_TC_INTERACTIVE = 3,
291 GSM48_QOS_TC_BACKGROUND = 4,
292};
293
294/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
295enum gsm48_qos_max_sdu_size {
296 /* values below in 10 octet granularity */
297 GSM48_QOS_MAXSDU_1502 = 0x97,
298 GSM48_QOS_MAXSDU_1510 = 0x98,
299 GSM48_QOS_MAXSDU_1520 = 0x99,
300};
301
302/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
303enum gsm48_qos_max_bitrate {
304 GSM48_QOS_MBRATE_1k = 0x01,
305 GSM48_QOS_MBRATE_63k = 0x3f,
306 GSM48_QOS_MBRATE_64k = 0x40,
307 GSM48_QOS_MBRATE_568k = 0x7f,
308 GSM48_QOS_MBRATE_576k = 0x80,
309 GSM48_QOS_MBRATE_8640k = 0xfe,
310 GSM48_QOS_MBRATE_0k = 0xff,
311};
312
313/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
314enum gsm48_qos_resid_ber {
315 GSM48_QOS_RBER_5e_2 = 0x01,
316 GSM48_QOS_RBER_1e_2 = 0x02,
317 GSM48_QOS_RBER_5e_3 = 0x03,
318 GSM48_QOS_RBER_4e_3 = 0x04,
319 GSM48_QOS_RBER_1e_3 = 0x05,
320 GSM48_QOS_RBER_1e_4 = 0x06,
321 GSM48_QOS_RBER_1e_5 = 0x07,
322 GSM48_QOS_RBER_1e_6 = 0x08,
323 GSM48_QOS_RBER_6e_8 = 0x09,
324};
325
326/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
327enum gsm48_qos_sdu_err {
328 GSM48_QOS_SERR_1e_2 = 0x01,
329 GSM48_QOS_SERR_7e_2 = 0x02,
330 GSM48_QOS_SERR_1e_3 = 0x03,
331 GSM48_QOS_SERR_1e_4 = 0x04,
332 GSM48_QOS_SERR_1e_5 = 0x05,
333 GSM48_QOS_SERR_1e_6 = 0x06,
334 GSM48_QOS_SERR_1e_1 = 0x07,
335};
336
337/* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
338struct gsm48_qos {
339 /* octet 3 */
340 uint8_t reliab_class:3;
341 uint8_t delay_class:3;
342 uint8_t spare:2;
343 /* octet 4 */
344 uint8_t preced_class:3;
345 uint8_t spare2:1;
346 uint8_t peak_tput:4;
347 /* octet 5 */
348 uint8_t mean_tput:5;
349 uint8_t spare3:3;
350 /* octet 6 */
351 uint8_t deliv_err_sdu:3;
352 uint8_t deliv_order:2;
353 uint8_t traf_class:3;
354 /* octet 7 */
355 uint8_t max_sdu_size;
356 /* octet 8 */
357 uint8_t max_bitrate_up;
358 /* octet 9 */
359 uint8_t max_bitrate_down;
360 /* octet 10 */
361 uint8_t sdu_err_ratio:4;
362 uint8_t resid_ber:4;
363 /* octet 11 */
364 uint8_t handling_prio:2;
365 uint8_t xfer_delay:6;
366 /* octet 12 */
367 uint8_t guar_bitrate_up;
368 /* octet 13 */
369 uint8_t guar_bitrate_down;
370 /* octet 14 */
371 uint8_t src_stats_desc:4;
372 uint8_t sig_ind:1;
373 uint8_t spare5:3;
374 /* octet 15 */
375 uint8_t max_bitrate_down_ext;
376 /* octet 16 */
377 uint8_t guar_bitrate_down_ext;
378};
379
380
Harald Welteeaa614c2010-05-02 11:26:34 +0200381int gprs_tlli_type(uint32_t tlli);
Harald Welte9b455bf2010-03-14 15:45:01 +0800382
Harald Welte9b455bf2010-03-14 15:45:01 +0800383#endif /* _GSM48_GPRS_H */