From Pascal Quantin:
[metze/wireshark/wip.git] / epan / dissectors / packet-gsm_a_common.h
1 /* packet-gsm_a_common.h
2  *
3  * $Id$
4  *
5  *   Reference [3]
6  *   Mobile radio interface Layer 3 specification;
7  *   Core network protocols;
8  *   Stage 3
9  *   (3GPP TS 24.008 version 4.7.0 Release 4)
10  *   (ETSI TS 124 008 V6.8.0 (2005-03))
11  *
12  *   Reference [5]
13  *   Point-to-Point (PP) Short Message Service (SMS)
14  *   support on mobile radio interface
15  *   (3GPP TS 24.011 version 4.1.1 Release 4)
16  *
17  *   Reference [7]
18  *   Mobile radio interface Layer 3 specification;
19  *   Core network protocols;
20  *   Stage 3
21  *   (3GPP TS 24.008 version 5.9.0 Release 5)
22  *
23  *   Reference [8]
24  *   Mobile radio interface Layer 3 specification;
25  *   Core network protocols;
26  *   Stage 3
27  *   (3GPP TS 24.008 version 6.7.0 Release 6)
28  *       (3GPP TS 24.008 version 6.8.0 Release 6)
29  *
30  * Copyright 2003, Michael Lum <mlum [AT] telostech.com>,
31  * In association with Telos Technology Inc.
32  *
33  * Wireshark - Network traffic analyzer
34  * By Gerald Combs <gerald@wireshark.org>
35  * Copyright 1998 Gerald Combs
36  *
37  * This program is free software; you can redistribute it and/or
38  * modify it under the terms of the GNU General Public License
39  * as published by the Free Software Foundation; either version 2
40  * of the License, or (at your option) any later version.
41  *
42  * This program is distributed in the hope that it will be useful,
43  * but WITHOUT ANY WARRANTY; without even the implied warranty of
44  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45  * GNU General Public License for more details.
46  *
47  * You should have received a copy of the GNU General Public License
48  * along with this program; if not, write to the Free Software
49  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
50  */
51 #ifndef __PACKET_GSM_A_COMMON_H__
52 #define __PACKET_GSM_A_COMMON_H__
53
54 #include "packet-sccp.h"
55
56 /* PROTOTYPES/FORWARDS */
57 typedef guint16 (*elem_fcn)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
58 typedef void (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
59
60 typedef struct dgt_set_t
61 {
62         unsigned char out[15];
63 }
64 dgt_set_t;
65
66 int my_dgt_tbcd_unpack( 
67         char    *out,           /* ASCII pattern out */
68         guchar  *in,            /* packed pattern in */
69         int             num_octs,       /* Number of octets to unpack */
70         dgt_set_t       *dgt            /* Digit definitions */
71         );
72
73 /* globals needed as a result of spltting the packet-gsm_a.c into several files
74  * until further restructuring can take place to make them more modular
75  */
76
77 /* common PD values */
78 extern const value_string protocol_discriminator_vals[];
79 extern const value_string gsm_a_pd_short_str_vals[];
80
81 extern guint16 de_cld_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
82
83 /* Needed to share the packet-gsm_a_common.c functions */
84 extern const value_string gsm_bssmap_elem_strings[];
85 extern gint ett_gsm_bssmap_elem[];
86 extern elem_fcn bssmap_elem_fcn[];
87 extern int hf_gsm_a_bssmap_elem_id;
88 extern int hf_gsm_a_bssmap_cell_ci;
89
90 extern const value_string gsm_dtap_elem_strings[];
91 extern gint ett_gsm_dtap_elem[];
92 extern elem_fcn dtap_elem_fcn[];
93 extern int hf_gsm_a_dtap_elem_id;
94
95 extern const value_string gsm_rp_elem_strings[];
96 extern gint ett_gsm_rp_elem[];
97 extern elem_fcn rp_elem_fcn[];
98 extern int hf_gsm_a_rp_elem_id;
99
100 extern const value_string gsm_rr_elem_strings[];
101 extern gint ett_gsm_rr_elem[];
102 extern elem_fcn rr_elem_fcn[];
103 extern int hf_gsm_a_rr_elem_id;
104 extern void get_rr_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn);
105
106 extern const value_string gsm_common_elem_strings[];
107 extern gint ett_gsm_common_elem[];
108 extern elem_fcn common_elem_fcn[];
109 extern int hf_gsm_a_common_elem_id;
110
111 extern const value_string gsm_gm_elem_strings[];
112 extern gint ett_gsm_gm_elem[];
113 extern elem_fcn gm_elem_fcn[];
114 extern int hf_gsm_a_gm_elem_id;
115 extern void get_gmm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn);
116 extern void get_sm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn);
117
118 extern const value_string gsm_bsslap_elem_strings[];
119 extern gint ett_gsm_bsslap_elem[];
120 extern elem_fcn bsslap_elem_fcn[];
121 extern int hf_gsm_a_bsslap_elem_id;
122
123 extern const value_string gsm_bssmap_le_elem_strings[];
124 extern gint ett_gsm_bssmap_le_elem[];
125 extern elem_fcn bssmap_le_elem_fcn[];
126 extern int hf_gsm_bssmap_le_elem_id;
127
128 extern const value_string nas_eps_common_elem_strings[];
129 extern gint ett_nas_eps_common_elem[];
130 extern elem_fcn nas_eps_common_elem_fcn[];
131 extern int hf_nas_eps_common_elem_id;
132
133 extern const value_string nas_emm_elem_strings[];
134 extern gint ett_nas_eps_emm_elem[];
135 extern elem_fcn emm_elem_fcn[];
136 extern int hf_nas_eps_emm_elem_id;
137
138 extern const value_string nas_esm_elem_strings[];
139 extern gint ett_nas_eps_esm_elem[];
140 extern elem_fcn esm_elem_fcn[];
141 extern int hf_nas_eps_esm_elem_id;
142
143 extern sccp_msg_info_t* sccp_msg;
144 extern sccp_assoc_info_t* sccp_assoc;
145
146 extern int gsm_a_tap;
147 extern gboolean lower_nibble;
148 extern packet_info *gsm_a_dtap_pinfo;
149
150 /* TS 23 032 */
151 void dissect_geographical_description(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
152
153 /* common field values */
154 extern int hf_gsm_a_length;
155 extern int hf_gsm_a_extension;
156 extern int hf_gsm_a_tmsi;
157 extern int hf_gsm_a_L3_protocol_discriminator;
158 extern int hf_gsm_a_call_prio;
159 extern int hf_gsm_a_b8spare;
160 extern int hf_gsm_a_skip_ind;
161 extern int hf_gsm_a_rr_chnl_needed_ch1;
162 extern int hf_gsm_a_spare_bits;
163 extern int hf_gsm_a_lac;
164
165 /* for the nasty hack below */
166 #define GSM_BSSMAP_APDU_IE      0x49
167
168 /* flags for the packet-gsm_a_common routines */
169 #define GSM_A_PDU_TYPE_BSSMAP           0  /* BSSAP_PDU_TYPE_BSSMAP i.e. 0 - until split complete at least! */
170 #define GSM_A_PDU_TYPE_DTAP             1  /* BSSAP_PDU_TYPE_DTAP i.e. 1   - until split complete at least! */
171 #define GSM_A_PDU_TYPE_RP               2
172 #define GSM_A_PDU_TYPE_RR               3
173 #define GSM_A_PDU_TYPE_COMMON           4
174 #define GSM_A_PDU_TYPE_GM               5
175 #define GSM_A_PDU_TYPE_BSSLAP           6
176 #define GSM_A_PDU_TYPE_SACCH            7
177 #define GSM_PDU_TYPE_BSSMAP_LE          8
178 #define NAS_PDU_TYPE_COMMON             9
179 #define NAS_PDU_TYPE_EMM                10
180 #define NAS_PDU_TYPE_ESM                11
181
182 extern const char* get_gsm_a_msg_string(int pdu_type, int idx);
183
184 /*
185  * this should be set on a per message basis, if possible
186  */
187 #define IS_UPLINK_FALSE         0
188 #define IS_UPLINK_TRUE          1
189 #define IS_UPLINK_UNKNOWN       2
190
191 /* Defines and nasty static for handling half octet mandatory V IEs 
192  * TODO: Note originally UPPER_NIBBLE was -2 and LOWER_NIBBLE was -1
193  * changed here to unsigned integer as it wouldn't compile (Warnings on Ubuntu)
194  * ugly hack...
195  */
196 #define UPPER_NIBBLE    (2)
197 #define LOWER_NIBBLE    (1)
198
199 /* FUNCTIONS */
200
201 /* ELEMENT FUNCTIONS */
202
203 #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \
204         if (((edc_len) > (edc_max_len))||lower_nibble) \
205         { \
206                 proto_tree_add_text(tree, tvb, \
207                         curr_offset, (edc_len) - (edc_max_len), "Extraneous Data"); \
208                 curr_offset += ((edc_len) - (edc_max_len)); \
209         }
210
211 #define SHORT_DATA_CHECK(sdc_len, sdc_min_len) \
212         if ((sdc_len) < (sdc_min_len)) \
213         { \
214                 proto_tree_add_text(tree, tvb, \
215                         curr_offset, (sdc_len), "Short Data (?)"); \
216                 curr_offset += (sdc_len); \
217                 return(curr_offset - offset); \
218         }
219
220 #define EXACT_DATA_CHECK(edc_len, edc_eq_len) \
221         if ((edc_len) != (edc_eq_len)) \
222         { \
223                 proto_tree_add_text(tree, tvb, \
224                         curr_offset, (edc_len), "Unexpected Data Length"); \
225                 curr_offset += (edc_len); \
226                 return(curr_offset - offset); \
227         }
228
229 #define NO_MORE_DATA_CHECK(nmdc_len) \
230         if ((nmdc_len) == (curr_offset - offset)) return(nmdc_len);
231
232 #define SET_ELEM_VARS(SEV_pdu_type, SEV_elem_names, SEV_elem_ett, SEV_elem_funcs) \
233         switch (SEV_pdu_type) \
234         { \
235         case GSM_A_PDU_TYPE_BSSMAP: \
236                 SEV_elem_names = gsm_bssmap_elem_strings; \
237                 SEV_elem_ett = ett_gsm_bssmap_elem; \
238                 SEV_elem_funcs = bssmap_elem_fcn; \
239                 break; \
240         case GSM_A_PDU_TYPE_DTAP: \
241                 SEV_elem_names = gsm_dtap_elem_strings; \
242                 SEV_elem_ett = ett_gsm_dtap_elem; \
243                 SEV_elem_funcs = dtap_elem_fcn; \
244                 break; \
245         case GSM_A_PDU_TYPE_RP: \
246                 SEV_elem_names = gsm_rp_elem_strings; \
247                 SEV_elem_ett = ett_gsm_rp_elem; \
248                 SEV_elem_funcs = rp_elem_fcn; \
249                 break; \
250         case GSM_A_PDU_TYPE_RR: \
251                 SEV_elem_names = gsm_rr_elem_strings; \
252                 SEV_elem_ett = ett_gsm_rr_elem; \
253                 SEV_elem_funcs = rr_elem_fcn; \
254                 break; \
255         case GSM_A_PDU_TYPE_COMMON: \
256                 SEV_elem_names = gsm_common_elem_strings; \
257                 SEV_elem_ett = ett_gsm_common_elem; \
258                 SEV_elem_funcs = common_elem_fcn; \
259                 break; \
260         case GSM_A_PDU_TYPE_GM: \
261                 SEV_elem_names = gsm_gm_elem_strings; \
262                 SEV_elem_ett = ett_gsm_gm_elem; \
263                 SEV_elem_funcs = gm_elem_fcn; \
264                 break; \
265         case GSM_A_PDU_TYPE_BSSLAP: \
266                 SEV_elem_names = gsm_bsslap_elem_strings; \
267                 SEV_elem_ett = ett_gsm_bsslap_elem; \
268                 SEV_elem_funcs = bsslap_elem_fcn; \
269                 break; \
270         case GSM_PDU_TYPE_BSSMAP_LE: \
271                 SEV_elem_names = gsm_bssmap_le_elem_strings; \
272                 SEV_elem_ett = ett_gsm_bssmap_le_elem; \
273                 SEV_elem_funcs = bssmap_le_elem_fcn; \
274                 break; \
275         case NAS_PDU_TYPE_COMMON: \
276                 SEV_elem_names = nas_eps_common_elem_strings; \
277                 SEV_elem_ett = ett_nas_eps_common_elem; \
278                 SEV_elem_funcs = nas_eps_common_elem_fcn; \
279                 break; \
280         case NAS_PDU_TYPE_EMM: \
281                 SEV_elem_names = nas_emm_elem_strings; \
282                 SEV_elem_ett = ett_nas_eps_emm_elem; \
283                 SEV_elem_funcs = emm_elem_fcn; \
284                 break; \
285         case NAS_PDU_TYPE_ESM: \
286                 SEV_elem_names = nas_esm_elem_strings; \
287                 SEV_elem_ett = ett_nas_eps_esm_elem; \
288                 SEV_elem_funcs = esm_elem_fcn; \
289                 break; \
290         default: \
291                 proto_tree_add_text(tree, \
292                         tvb, curr_offset, -1, \
293                         "Unknown PDU type (%u) gsm_a_common", SEV_pdu_type); \
294                 return(consumed); \
295         }
296
297 /*
298  * Type Length Value (TLV) element dissector
299  */
300 extern guint16 elem_tlv(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, guint len, const gchar *name_add);
301
302 /*
303  * Type Length Value (TLV-E) element dissector
304  */
305 extern guint16 elem_tlv_e(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, guint len, const gchar *name_add);
306
307 /*
308  * Type Value (TV) element dissector
309  *
310  * Length cannot be used in these functions, big problem if a element dissector
311  * is not defined for these.
312  */
313 extern guint16 elem_tv(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add);
314
315 /*
316  * Type Value (TV) element dissector
317  * Where top half nibble is IEI and bottom half nibble is value.
318  *
319  * Length cannot be used in these functions, big problem if a element dissector
320  * is not defined for these.
321  */
322 extern guint16 elem_tv_short(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add);
323
324 /*
325  * Type (T) element dissector
326  */
327 extern guint16 elem_t(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add);
328
329 /*
330  * Length Value (LV) element dissector
331  */
332 extern guint16 elem_lv(tvbuff_t *tvb, proto_tree *tree, gint pdu_type, int idx, guint32 offset, guint len, const gchar *name_add);
333
334 /*
335  * Length Value (LV-E) element dissector
336  */
337 extern guint16 elem_lv_e(tvbuff_t *tvb, proto_tree *tree, gint pdu_type, int idx, guint32 offset, guint len, const gchar *name_add);
338
339 /*
340  * Value (V) element dissector
341  *
342  * Length cannot be used in these functions, big problem if a element dissector
343  * is not defined for these.
344  */
345 extern guint16 elem_v(tvbuff_t *tvb, proto_tree *tree, gint pdu_type, int idx, guint32 offset);
346
347 /*
348  * Short Value (V_SHORT) element dissector
349  *
350  * Length is (ab)used in these functions to indicate upper nibble of the octet (-2) or lower nibble (-1)
351  * noting that the tv_short dissector always sets the length to -1, as the upper nibble is the IEI.
352  * This is expected to be used upper nibble first, as the tables of 24.008.
353  */
354
355 extern guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, gint pdu_type, int idx, guint32 offset);
356
357
358 /* XXX: Most (if not all) the functions which make use of the following macros have the variables 'consumed',
359  *      'curr_offset', and 'cur_len' declared as *unsigned*.  This means that the 'if (curr_len <= 0)' statement
360  *      originally at the end of each of the macros would always be FALSE since an unsigned cannot be less than 0.
361  *      I've chosen to change the statement to 'if ((signed)curr_len <= 0)'. (Although this may be a bit of a
362  *      hack, it seems simpler than changing declarations to signed in all the places these macros are used).
363  *      Is there a better approach ?
364  */
365
366 #define ELEM_MAND_TLV(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition) \
367 {\
368         if ((consumed = elem_tlv(tvb, tree, (guint8) EMT_iei, EMT_pdu_type, EMT_elem_idx, curr_offset, curr_len, EMT_elem_name_addition)) > 0) \
369         { \
370                 curr_offset += consumed; \
371                 curr_len -= consumed; \
372         } \
373         else \
374         { \
375                 proto_tree_add_text(tree, \
376                         tvb, curr_offset, 0, \
377                         "Missing Mandatory element (0x%02x) %s%s, rest of dissection is suspect", \
378                         EMT_iei, \
379                         get_gsm_a_msg_string(EMT_pdu_type, EMT_elem_idx), \
380                         (EMT_elem_name_addition == NULL) ? "" : EMT_elem_name_addition \
381                         ); \
382         } \
383         if ((signed)curr_len <= 0) return;      \
384 }
385
386 #define ELEM_MAND_TLV_E(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition) \
387 {\
388         if ((consumed = elem_tlv_e(tvb, tree, (guint8) EMT_iei, EMT_pdu_type, EMT_elem_idx, curr_offset, curr_len, EMT_elem_name_addition)) > 0) \
389         { \
390                 curr_offset += consumed; \
391                 curr_len -= consumed; \
392         } \
393         else \
394         { \
395                 proto_tree_add_text(tree, \
396                         tvb, curr_offset, 0, \
397                         "Missing Mandatory element (0x%02x) %s%s, rest of dissection is suspect", \
398                         EMT_iei, \
399                         get_gsm_a_msg_string(EMT_pdu_type, EMT_elem_idx), \
400                         (EMT_elem_name_addition == NULL) ? "" : EMT_elem_name_addition \
401                         ); \
402         } \
403         if ((signed)curr_len <= 0) return;      \
404 }
405 #define ELEM_OPT_TLV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
406 {\
407         if ((consumed = elem_tlv(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, curr_len, EOT_elem_name_addition)) > 0) \
408         { \
409                 curr_offset += consumed; \
410                 curr_len -= consumed; \
411         } \
412         if ((signed)curr_len <= 0) return;      \
413 }
414
415 #define ELEM_OPT_TLV_E(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
416 {\
417         if ((consumed = elem_tlv_e(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, curr_len, EOT_elem_name_addition)) > 0) \
418         { \
419                 curr_offset += consumed; \
420                 curr_len -= consumed; \
421         } \
422         if ((signed)curr_len <= 0) return;      \
423 }
424
425 #define ELEM_MAND_TV(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition) \
426 {\
427         if ((consumed = elem_tv(tvb, tree, (guint8) EMT_iei, EMT_pdu_type, EMT_elem_idx, curr_offset, EMT_elem_name_addition)) > 0) \
428         { \
429                 curr_offset += consumed; \
430                 curr_len -= consumed; \
431         } \
432         else \
433         { \
434                 proto_tree_add_text(tree, \
435                         tvb, curr_offset, 0, \
436                         "Missing Mandatory element (0x%02x) %s%s, rest of dissection is suspect", \
437                         EMT_iei, \
438                         get_gsm_a_msg_string(EMT_pdu_type, EMT_elem_idx), \
439                         (EMT_elem_name_addition == NULL) ? "" : EMT_elem_name_addition \
440                 ); \
441         } \
442         if ((signed)curr_len <= 0) return;      \
443 }
444
445 #define ELEM_OPT_TV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
446 {\
447         if ((consumed = elem_tv(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
448         { \
449                 curr_offset += consumed; \
450                 curr_len -= consumed; \
451         } \
452         if ((signed)curr_len <= 0) return;      \
453 }
454
455 #define ELEM_OPT_TV_SHORT(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
456 {\
457         if ((consumed = elem_tv_short(tvb, tree, EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
458         { \
459                 curr_offset += consumed; \
460                 curr_len -= consumed; \
461         } \
462         if ((signed)curr_len <= 0) return;      \
463 }
464
465 #define ELEM_OPT_T(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
466 {\
467         if ((consumed = elem_t(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
468         { \
469                 curr_offset += consumed; \
470                 curr_len -= consumed; \
471         } \
472         if ((signed)curr_len <= 0) return;      \
473 }
474
475 #define ELEM_MAND_LV(EML_pdu_type, EML_elem_idx, EML_elem_name_addition) \
476 {\
477         if ((consumed = elem_lv(tvb, tree, EML_pdu_type, EML_elem_idx, curr_offset, curr_len, EML_elem_name_addition)) > 0) \
478         { \
479                 curr_offset += consumed; \
480                 curr_len -= consumed; \
481         } \
482         else \
483         { \
484                 /* Mandatory, but nothing we can do */ \
485         } \
486         if ((signed)curr_len <= 0) return;      \
487 }
488
489 #define ELEM_MAND_LV_E(EML_pdu_type, EML_elem_idx, EML_elem_name_addition) \
490 {\
491         if ((consumed = elem_lv_e(tvb, tree, EML_pdu_type, EML_elem_idx, curr_offset, curr_len, EML_elem_name_addition)) > 0) \
492         { \
493                 curr_offset += consumed; \
494                 curr_len -= consumed; \
495         } \
496         else \
497         { \
498                 /* Mandatory, but nothing we can do */ \
499         } \
500         if ((signed)curr_len <= 0) return;      \
501 }
502
503 #define ELEM_MAND_V(EMV_pdu_type, EMV_elem_idx) \
504 {\
505         if ((consumed = elem_v(tvb, tree, EMV_pdu_type, EMV_elem_idx, curr_offset)) > 0) \
506         { \
507                 curr_offset += consumed; \
508                 curr_len -= consumed; \
509         } \
510         else \
511         { \
512                 /* Mandatory, but nothing we can do */ \
513         } \
514         if ((signed)curr_len <= 0) return;      \
515 }
516
517 #define ELEM_MAND_V_SHORT(EMV_pdu_type, EMV_elem_idx) \
518 {\
519         if ((consumed = elem_v_short(tvb, tree, EMV_pdu_type, EMV_elem_idx, curr_offset)) > 0) \
520         { \
521                 curr_offset += consumed; \
522                 curr_len -= consumed; \
523         } \
524         else \
525         { \
526                 /* Mandatory, but nothing we can do */ \
527         } \
528         if ((signed)curr_len <= 0) return;      \
529 }
530
531 /*
532  * this enum must be kept in-sync with 'gsm_a_pd_str'
533  * it is used as an index into the array
534  */
535 typedef enum
536 {
537         PD_GCC = 0,
538         PD_BCC,
539         PD_RSVD_1,
540         PD_CC,
541         PD_GTTP,
542         PD_MM,
543         PD_RR,
544         PD_UNK_1,
545         PD_GMM,
546         PD_SMS,
547         PD_SM,
548         PD_SS,
549         PD_LCS,
550         PD_UNK_2,
551         PD_RSVD_EXT,
552         PD_TP
553 }
554 gsm_a_pd_str_e;
555
556 typedef struct _gsm_a_tap_rec_t {
557         /*
558          * value from packet-bssap.h
559          */
560         guint8          pdu_type;
561         guint8          message_type;
562         gsm_a_pd_str_e  protocol_disc;
563 } gsm_a_tap_rec_t;
564
565 void dissect_bssmap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
566
567 void dissect_bssmap_le(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
568
569 void bssmap_old_bss_to_new_bss_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo);
570 void bssmap_new_bss_to_old_bss_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo);
571
572 void dtap_mm_mm_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
573
574 guint16 be_cell_id_aux(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len, guint8 disc);
575 guint16 be_cell_id_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
576 guint16 be_chan_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
577
578 guint16 de_lai(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
579 guint16 de_mid(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
580 guint16 de_cell_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
581 guint16 de_bearer_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
582 guint16 de_bearer_cap_uplink(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
583 guint16 be_ganss_loc_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
584 guint16 be_ganss_pos_dta(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
585 guint16 be_ganss_ass_dta(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
586 guint16 de_plmn_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
587 guint16 de_ms_cm_1(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
588 guint16 de_ms_cm_2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
589 guint16 de_ms_cm_3(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
590 guint16 de_serv_cat(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
591 guint16 de_sm_apn(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
592 guint16 de_sm_pco(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
593 guint16 de_sm_qos(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
594 guint16 de_sm_pflow_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
595 guint16 de_sm_tflow_temp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
596
597 guint16 de_gmm_drx_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
598 guint16 de_gmm_ms_net_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
599 guint16 de_gmm_rai(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
600 guint16 de_gmm_ms_radio_acc_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
601
602 guint16 de_rr_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
603 guint16 de_rr_cell_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
604 guint16 de_rr_ch_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
605 guint16 de_rr_ch_mode(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
606 guint16 de_rr_chnl_needed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
607 guint16 de_rr_cip_mode_set(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
608 guint16 de_rr_cm_enq_mask(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
609 guint16 de_rr_meas_res(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
610 guint16 de_rr_multirate_conf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
611 guint16 de_rr_sus_cau(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
612 guint16 de_rr_tlli(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
613
614 guint16 de_rej_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
615 guint16 de_d_gb_call_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
616
617 void dtap_rr_ho_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
618 void dtap_rr_cip_mode_cpte(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
619
620 void bssmap_perf_loc_abort(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
621 void bssmap_reset(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
622 void bssmap_conn_oriented(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
623
624 /*
625  * the following allows TAP code access to the messages
626  * without having to duplicate it. With MSVC and a 
627  * libwireshark.dll, we need a special declaration.
628  */
629 WS_VAR_IMPORT const value_string gsm_a_bssmap_msg_strings[];
630 WS_VAR_IMPORT const value_string gsm_a_dtap_msg_mm_strings[];
631 WS_VAR_IMPORT const value_string gsm_a_dtap_msg_rr_strings[];
632 WS_VAR_IMPORT const value_string gsm_a_dtap_msg_cc_strings[];
633 WS_VAR_IMPORT const value_string gsm_a_dtap_msg_gmm_strings[];
634 WS_VAR_IMPORT const value_string gsm_a_dtap_msg_sms_strings[];
635 WS_VAR_IMPORT const value_string gsm_a_dtap_msg_sm_strings[];
636 WS_VAR_IMPORT const value_string gsm_a_dtap_msg_ss_strings[];
637 WS_VAR_IMPORT const value_string gsm_a_dtap_msg_tp_strings[];
638 WS_VAR_IMPORT const value_string gsm_a_sacch_msg_rr_strings[];
639 WS_VAR_IMPORT const gchar *gsm_a_pd_str[];
640
641 extern const value_string gsm_a_qos_del_of_err_sdu_vals[];
642 extern const value_string gsm_a_qos_del_order_vals[];
643 extern const value_string gsm_a_qos_traffic_cls_vals[];
644 extern const value_string gsm_a_qos_ber_vals[];
645 extern const value_string gsm_a_qos_sdu_err_rat_vals[];
646 extern const value_string gsm_a_qos_traff_hdl_pri_vals[];
647
648 extern const value_string gsm_a_type_of_number_values[];
649 extern const value_string gsm_a_numbering_plan_id_values[]; 
650 extern const value_string gsm_a_sms_vals[];
651 extern const value_string gsm_a_rr_rxlev_vals [];
652
653 typedef enum
654 {
655         /* Common Information Elements [3] 10.5.1 */
656         DE_CELL_ID,                             /* Cell Identity */
657         DE_CIPH_KEY_SEQ_NUM,    /* Ciphering Key Sequence Number */
658         DE_LAI,                                 /* Location Area Identification */
659         DE_MID,                                 /* Mobile Identity */
660         DE_MS_CM_1,                             /* Mobile Station Classmark 1 */
661         DE_MS_CM_2,                             /* Mobile Station Classmark 2 */
662         DE_MS_CM_3,                             /* Mobile Station Classmark 3 */
663         DE_SPARE_NIBBLE,                /* Spare Half Octet */
664         DE_D_GB_CALL_REF,               /* Descriptive group or broadcast call reference */
665         DE_G_CIPH_KEY_NUM,              /* Group Cipher Key Number */
666         DE_PD_SAPI,                             /* PD and SAPI $(CCBS)$ */
667         DE_PRIO,                                /* Priority Level */
668         DE_PLMN_LIST,                   /* PLMN List */
669
670         DE_COMMON_NONE                                                  /* NONE */
671 }
672 common_elem_idx_t;
673
674 typedef enum
675 {
676         BE_CIC,  /* Circuit Identity Code */
677         BE_RSVD_1,       /* Reserved */
678         BE_RES_AVAIL,    /* Resource Available */
679         BE_CAUSE,        /* Cause */
680         BE_CELL_ID,      /* Cell Identifier */
681         BE_PRIO,         /* Priority */
682         BE_L3_HEADER_INFO,       /* Layer 3 Header Information */
683         BE_IMSI,         /* IMSI */
684         BE_TMSI,         /* TMSI */
685         BE_ENC_INFO,     /* Encryption Information */
686         BE_CHAN_TYPE,    /* Channel Type */
687         BE_PERIODICITY,  /* Periodicity */
688         BE_EXT_RES_IND,  /* Extended Resource Indicator */
689         BE_NUM_MS,       /* Number Of MSs */
690         BE_RSVD_2,       /* Reserved */
691         BE_RSVD_3,       /* Reserved */
692         BE_RSVD_4,       /* Reserved */
693         BE_CM_INFO_2,    /* Classmark Information Type 2 */
694         BE_CM_INFO_3,    /* Classmark Information Type 3 */
695         BE_INT_BAND,     /* Interference Band To Be Used */
696         BE_RR_CAUSE,     /* RR Cause */
697         BE_RSVD_5,       /* Reserved */
698         BE_L3_INFO,      /* Layer 3 Information */
699         BE_DLCI,         /* DLCI */
700         BE_DOWN_DTX_FLAG,        /* Downlink DTX Flag */
701         BE_CELL_ID_LIST,         /* Cell Identifier List */
702         BE_RESP_REQ,     /* Response Request */
703         BE_RES_IND_METHOD,       /* Resource Indication Method */
704         BE_CM_INFO_1,    /* Classmark Information Type 1 */
705         BE_CIC_LIST,     /* Circuit Identity Code List */
706         BE_DIAG,         /* Diagnostic */
707         BE_L3_MSG,       /* Layer 3 Message Contents */
708         BE_CHOSEN_CHAN,  /* Chosen Channel */
709         BE_TOT_RES_ACC,  /* Total Resource Accessible */
710         BE_CIPH_RESP_MODE,       /* Cipher Response Mode */
711         BE_CHAN_NEEDED,  /* Channel Needed */
712         BE_TRACE_TYPE,   /* Trace Type */
713         BE_TRIGGERID,    /* TriggerID */
714         BE_TRACE_REF,    /* Trace Reference */
715         BE_TRANSID,      /* TransactionID */
716         BE_MID,  /* Mobile Identity */
717         BE_OMCID,        /* OMCID */
718         BE_FOR_IND,      /* Forward Indicator */
719         BE_CHOSEN_ENC_ALG,       /* Chosen Encryption Algorithm */
720         BE_CCT_POOL,     /* Circuit Pool */
721         BE_CCT_POOL_LIST,        /* Circuit Pool List */
722         BE_TIME_IND,     /* Time Indication */
723         BE_RES_SIT,      /* Resource Situation */
724         BE_CURR_CHAN_1,  /* Current Channel Type 1 */
725         BE_QUE_IND,      /* Queueing Indicator */
726         BE_SPEECH_VER,   /* Speech Version */
727         BE_ASS_REQ,      /* Assignment Requirement */
728         BE_TALKER_FLAG,  /* Talker Flag */
729         BE_CONN_REL_REQ,         /* Connection Release Requested */
730         BE_GROUP_CALL_REF,       /* Group Call Reference */
731         BE_EMLPP_PRIO,   /* eMLPP Priority */
732         BE_CONF_EVO_IND,         /* Configuration Evolution Indication */
733         BE_OLD2NEW_INFO,         /* Old BSS to New BSS Information */
734         BE_LSA_ID,       /* LSA Identifier */
735         BE_LSA_ID_LIST,  /* LSA Identifier List */
736         BE_LSA_INFO,     /* LSA Information */
737         BE_LCS_QOS,      /* LCS QoS */
738         BE_LSA_ACC_CTRL,         /* LSA access control suppression */
739         BE_LCS_PRIO,     /* LCS Priority */
740         BE_LOC_TYPE,     /* Location Type */
741         BE_LOC_EST,      /* Location Estimate */
742         BE_POS_DATA,     /* Positioning Data */
743         BE_LCS_CAUSE,    /* 3.2.2.66 LCS Cause */
744         BE_LCS_CLIENT,   /* 10.14 LCS Client Type */
745         BE_APDU,         /* APDU */
746         BE_NE_ID,        /* Network Element Identity */
747         BE_GPS_ASSIST_DATA,      /* GPS Assistance Data */
748         BE_DECIPH_KEYS,  /* Deciphering Keys */
749         BE_RET_ERR_REQ,  /* Return Error Request */
750         BE_RET_ERR_CAUSE,        /* Return Error Cause */
751         BE_SEG,  /* Segmentation */
752         BE_SERV_HO,     /* Service Handover */
753         BE_SRC_RNC_TO_TAR_RNC_UMTS,     /* Source RNC to target RNC transparent information (UMTS) */
754         BE_SRC_RNC_TO_TAR_RNC_CDMA,     /* Source RNC to target RNC transparent information (cdma2000) */
755         BE_GERAN_CLS_M, /* GERAN Classmark */
756         BE_GRAN_BSC_CONT,       /* GERAN BSC Container */
757         BE_NEW_BSS_TO_OLD_BSS_INF,      /* New BSS to Old BSS Information */
758         BE_INTER_SYS_INF,       /*      Inter-System Information */
759         BE_SNA_ACC_INF,         /* SNA Access Information */
760         BE_VSTK_RAND_INF,       /* VSTK_RAND Information */
761         BE_VSTK_INF,            /* VSTK Information */
762         BE_PAGING_INF,          /* Paging Information */
763         BE_IMEI,                        /* IMEI */
764         BE_VEL_EST,                     /* Velocity Estimate */
765         BE_VGCS_FEAT_FLG,       /* VGCS Feature Flags */
766         BE_TALKER_PRI,          /* Talker Priority */
767         BE_EMRG_SET_IND,        /* Emergency Set Indication */
768         BE_TALKER_ID,           /* Talker Identity */
769         BE_CELL_ID_LIST_SEG,/* Cell Identifier List Segment */
770         BE_SMS_TO_VGCS,         /* SMS to VGCS */
771         BE_VGCS_TALKER_MOD, /*  VGCS Talker Mode */
772         BE_VGS_VBS_CELL_STAT, /*        VGCS/VBS Cell Status */
773         BE_CELL_ID_LST_SEG_F_EST_CELLS, /*      Cell Identifier List Segment for established cells */
774         BE_CELL_ID_LST_SEG_F_CELL_TB_EST,       /* Cell Identifier List Segment for cells to be established */
775         BE_CELL_ID_LST_SEG_F_REL_CELL,  /* Cell Identifier List Segment for released cells - no user present */
776         BE_CELL_ID_LST_SEG_F_NOT_EST_CELL,      /* Cell Identifier List Segment for not established cells - no establishment possible */
777         BE_GANSS_ASS_DTA,       /*      GANSS Assistance Data */
778         BE_GANSS_POS_DTA,       /*      GANSS Positioning Data */
779         BE_GANSS_LOC_TYP,       /* GANSS Location Type */
780         BE_APP_DATA,            /* Application Data */
781         BE_DATA_ID,                     /* Data Identity */
782         BE_APP_DATA_INF,        /*  Application Data Information */
783         BE_MSISDN,                      /* MSISDN */
784         BE_AOIP_TRANS_LAY_ADD,  /*      AoIP Transport Layer Address */
785         BE_SPEECH_CODEC_LST,    /* Speech Codec List */
786         BE_SPEECH_CODEC,                /* Speech Codec */
787         BE_CALL_ID,                             /* Call Identifier */
788         BE_CALL_ID_LST,                 /* Call Identifier List */
789         BE_NONE /* NONE */
790 }
791 bssmap_elem_idx_t;
792
793 typedef enum
794 {
795         /* BSSMAP LE Elements */
796         DE_BMAPLE_LCSQOS,                       /* LCS QOS */
797         DE_BMAPLE_LCS_PRIO,                     /* LCS Priority */
798         DE_BMAPLE_LOC_TYPE,                     /* Location Type */
799         DE_BMAPLE_GANSS_LOC_TYPE,       /* GANSS Location Type */       
800         DE_BMAPLE_GEO_LOC,                      /* 10.9 Geographic Location */  
801         DE_BMAPLE_POS_DATA,                     /* Positioning Data */                  
802         DE_BMAPLE_GANSS_POS_DATA,       /* GANSS Positioning Data */
803         DE_BMAPLE_VELOC_DATA,           /* Velocity Data */
804         DE_BMAPLE_LCS_CAUSE,            /* LCS Cause */ 
805         DE_BMAPLE_LCS_CLIENT_TYPE,      /* LCS Client Type */
806         DE_BMAPLE_APDU,                         /* 10.3 APDU */         
807         DE_BMAPLE_NETWORK_ELEM_ID,      /* Network Element Identity */
808         DE_BMAPLE_REQ_GPS_ASSIST_D, /* 10.10 Requested GPS Assistance Data */   
809         DE_BMAPLE_REQ_GNSS_ASSIST_D,/* Requested GANSS Assistance Data */
810         DE_BMAPLE_DECIPH_KEYS,          /* 10.8 Deciphering Keys */
811         DE_BMAPLE_RETURN_ERROR_REQ,     /* Return Error Request */
812         DE_BMAPLE_RETURN_ERROR_CAUSE,   /* Return Error Cause */
813         DE_BMAPLE_SEGMENTATION,         /* Segmentation */
814         DE_BMAPLE_CLASSMARK_TYPE_3,     /* Classmark Information Type 3 */
815         DE_BMAPLE_CAUSE,                        /* 10.4 Cause */
816         DE_BMAPLE_CELL_IDENTIFIER,      /* 10.5 Cell Identifier */
817         DE_BMAPLE_CHOSEN_CHANNEL,       /* 10.6 Chosen Channel */
818         DE_BMAPLE_IMSI,                         /* 10.11 IMSI */
819         DE_BMAPLE_RES1,                         /* Reserved */
820         DE_BMAPLE_RES2,                         /* Reserved */
821         DE_BMAPLE_RES3,                         /* Reserved */
822         DE_BMAPLE_LCS_CAPABILITY,       /* LCS Capability */
823         DE_BMAPLE_PACKET_MEAS_REP,      /* Packet Measurement Report */
824         DE_BMAPLE_MEAS_CELL_ID,         /* Measured Cell Identity */
825         DE_BMAPLE_IMEI,                         /* IMEI */
826         BMAPLE_NONE                                     /* NONE */
827 }
828 bssmap_le_elem_idx_t;
829
830 typedef enum
831 {
832         /* BSS LAP Elements 5 */
833         DE_BLAP_RES1,                   /* Reserved */
834         DE_BLAP_TA,                             /* Timing Advance */
835         DE_BLAP_RES3,                   /* Reserved */                  /* (note) */
836         DE_BLAP_RES4,                   /* Cell Identity */     
837         DE_BLAP_RES5,                   /* Reserved */                  /* (note) */
838         DE_BLAP_RES6,                   /* Reserved */                  /* (note) */
839         DE_BLAP_RES7,                   /* Reserved */                  /* (note) */
840         DE_BLAP_CH_DESC,                /* Channel Description */
841         DE_BLAP_RES9,                   /* Reserved */                  /* (note) */
842         DE_BLAP_RES10,                  /* Reserved */                  /* (note) */
843         DE_BLAP_RES11,                  /* Reserved */                  /* (note) */
844         DE_BLAP_MEAS_REP,               /* Measurement Report */
845         DE_BLAP_RES13,                  /* Reserved */                  /* (note) */
846         DE_BLAP_CAUSE,                  /* Cause */
847         DE_BLAP_RRLP_FLG,               /* RRLP Flag */
848         DE_BLAP_RRLP_IE,                /* RRLP IE */
849         DE_BLAP_CELL_ID_LIST,   /* Cell Identity List */
850         DE_BLAP_ENH_MEAS_REP,   /* Enhanced Measurement Report */
851         DE_BLAP_LAC,                    /* Location Area Code */
852         DE_BLAP_FREQ_LIST,              /* Frequency List */
853         DE_BLAP_MS_POW,                 /* MS Power */
854         DE_BLAP_DELTA_TIME,             /* Delta Timer */
855         DE_BLAP_SERV_CELL_ID,   /* Serving Cell Identifier */
856         DE_BLAP_ENC_KEY,                /* Encryption Key (Kc) */
857         DE_BLAP_CIP_M_SET,              /* Cipher Mode Setting */
858         DE_BLAP_CH_MODE,                /* Channel Mode */
859         DE_BLAP_POLL_REP,               /* Polling Repetition */
860         DE_BLAP_PKT_CH_DESC,    /* Packet Channel Description */
861         DE_BLAP_TLLI,                   /* TLLI */
862         DE_BLAP_TFI,                    /* TFI */
863         DE_BLAP_START_TIME,             /* Starting Time */
864         BSSLAP_NONE                             /* NONE */
865 }
866 bsslap_elem_idx_t;
867
868 typedef enum
869 {
870         /* Mobility Management Information Elements [3] 10.5.3 */
871         DE_AUTH_PARAM_RAND,                             /* Authentication Parameter RAND */
872         DE_AUTH_PARAM_AUTN,                             /* Authentication Parameter AUTN (UMTS authentication challenge only) */
873         DE_AUTH_RESP_PARAM,                             /* Authentication Response Parameter */
874         DE_AUTH_RESP_PARAM_EXT,                 /* Authentication Response Parameter (extension) (UMTS authentication challenge only) */
875         DE_AUTH_FAIL_PARAM,                             /* Authentication Failure Parameter (UMTS authentication challenge only) */
876         DE_CM_SRVC_TYPE,                                /* CM Service Type */
877         DE_ID_TYPE,                                             /* Identity Type */
878         DE_LOC_UPD_TYPE,                                /* Location Updating Type */
879         DE_NETWORK_NAME,                                /* Network Name */
880         DE_REJ_CAUSE,                                   /* Reject Cause */
881         DE_FOP,                                                 /* Follow-on Proceed */
882         DE_TIME_ZONE,                                   /* Time Zone */
883         DE_TIME_ZONE_TIME,                              /* Time Zone and Time */
884         DE_CTS_PERM,                                    /* CTS Permission */
885         DE_LSA_ID,                                              /* LSA Identifier */
886         DE_DAY_SAVING_TIME,                             /* Daylight Saving Time */
887         DE_EMERGENCY_NUM_LIST,                  /* Emergency Number List */
888         /* Call Control Information Elements 10.5.4 */
889         DE_AUX_STATES,                                  /* Auxiliary States */
890         DE_BEARER_CAP,                                  /* Bearer Capability */
891         DE_CC_CAP,                                              /* Call Control Capabilities */
892         DE_CALL_STATE,                                  /* Call State */
893         DE_CLD_PARTY_BCD_NUM,                   /* Called Party BCD Number */
894         DE_CLD_PARTY_SUB_ADDR,                  /* Called Party Subaddress */
895         DE_CLG_PARTY_BCD_NUM,                   /* Calling Party BCD Number */
896         DE_CLG_PARTY_SUB_ADDR,                  /* Calling Party Subaddress */
897         DE_CAUSE,                                               /* Cause */
898         DE_CLIR_SUP,                                    /* CLIR Suppression */
899         DE_CLIR_INV,                                    /* CLIR Invocation */
900         DE_CONGESTION,                                  /* Congestion Level */
901         DE_CONN_NUM,                                    /* Connected Number */
902         DE_CONN_SUB_ADDR,                               /* Connected Subaddress */
903         DE_FACILITY,                                    /* Facility */
904         DE_HLC,                                                 /* High Layer Compatibility */
905         DE_KEYPAD_FACILITY,                             /* Keypad Facility */
906         DE_LLC,                                                 /* Low Layer Compatibility */
907         DE_MORE_DATA,                                   /* More Data */
908         DE_NOT_IND,                                             /* Notification Indicator */
909         DE_PROG_IND,                                    /* Progress Indicator */
910         DE_RECALL_TYPE,                                 /* Recall type $(CCBS)$ */
911         DE_RED_PARTY_BCD_NUM,                   /* Redirecting Party BCD Number */
912         DE_RED_PARTY_SUB_ADDR,                  /* Redirecting Party Subaddress */
913         DE_REPEAT_IND,                                  /* Repeat Indicator */
914         DE_REV_CALL_SETUP_DIR,                  /* Reverse Call Setup Direction */
915         DE_SETUP_CONTAINER,                             /* SETUP Container $(CCBS)$ */
916         DE_SIGNAL,                                              /* Signal */
917         DE_SS_VER_IND,                                  /* SS Version Indicator */
918         DE_USER_USER,                                   /* User-user */
919         DE_ALERT_PATTERN,                               /* Alerting Pattern $(NIA)$ */
920         DE_ALLOWED_ACTIONS,                             /* Allowed Actions $(CCBS)$ */
921         DE_SI,                                                  /* Stream Identifier */
922         DE_NET_CC_CAP,                                  /* Network Call Control Capabilities */
923         DE_CAUSE_NO_CLI,                                /* Cause of No CLI */
924         DE_SUP_CODEC_LIST,                              /* Supported Codec List */
925         DE_SERV_CAT,                                    /* Service Category */
926         DE_REDIAL,                                              /* 10.5.4.34 Redial */
927         DE_NET_INIT_SERV_UPG,                   /* 10.5.4.35 Network-initiated Service Upgrade ind */
928         /* Short Message Service Information Elements [5] 8.1.4 */
929         DE_CP_USER_DATA,                                /* CP-User Data */
930         DE_CP_CAUSE,                                    /* CP-Cause */
931         /* Tests procedures information elements 3GPP TS 44.014 6.4.0 and 3GPP TS 34.109 6.4.0 */
932         DE_TP_SUB_CHANNEL,                      /* Close TCH Loop Cmd Sub-channel */
933         DE_TP_ACK,                      /* Open Loop Cmd Ack */
934         DE_TP_LOOP_TYPE,                        /* Close Multi-slot Loop Cmd Loop type*/
935         DE_TP_LOOP_ACK,                 /* Close Multi-slot Loop Ack Result */
936         DE_TP_TESTED_DEVICE,                    /* Test Interface Tested device */
937         DE_TP_PDU_DESCRIPTION,                  /* GPRS Test Mode Cmd PDU description */
938         DE_TP_MODE_FLAG,                        /* GPRS Test Mode Cmd Mode flag */
939         DE_TP_EGPRS_MODE_FLAG,                  /* EGPRS Start Radio Block Loopback Cmd Mode flag */
940         DE_TP_UE_TEST_LOOP_MODE,                        /* Close UE Test Loop Mode */
941         DE_TP_UE_POSITIONING_TECHNOLOGY,                        /* UE Positioning Technology */
942         DE_TP_RLC_SDU_COUNTER_VALUE,                    /* RLC SDU Counter Value */
943         DE_TP_EPC_UE_TEST_LOOP_MODE,    /* UE Test Loop Mode */
944         DE_TP_EPC_UE_TL_A_LB_SETUP,             /* UE Test Loop Mode A LB Setup */
945         DE_TP_EPC_UE_TL_B_LB_SETUP,             /* UE Test Loop Mode B LB Setup */
946         DE_NONE                                                 /* NONE */
947 }
948 dtap_elem_idx_t;
949
950 typedef enum
951 {
952         /* GPRS Mobility Management Information Elements [3] 10.5.5 */
953         DE_ATTACH_RES,                                  /* [7] 10.5.1 Attach Result*/
954         DE_ATTACH_TYPE,                                 /* [7] 10.5.2 Attach Type */
955         DE_CIPH_ALG,                                    /* [7] 10.5.3 Cipher Algorithm */
956         DE_TMSI_STAT,                                   /* [7] 10.5.4 TMSI Status */
957         DE_DETACH_TYPE,                                 /* [7] 10.5.5 Detach Type */
958         DE_DRX_PARAM,                                   /* [7] 10.5.6 DRX Parameter */
959         DE_FORCE_TO_STAND,                              /* [7] 10.5.7 Force to Standby */
960         DE_FORCE_TO_STAND_H,                    /* [7] 10.5.8 Force to Standby - Info is in the high nibble */
961         DE_P_TMSI_SIG,                                  /* [7] 10.5.9 P-TMSI Signature */
962         DE_P_TMSI_SIG_2,                                /* [7] 10.5.10 P-TMSI Signature 2 */
963         DE_ID_TYPE_2,                                   /* [7] 10.5.11 Identity Type 2 */
964         DE_IMEISV_REQ,                                  /* [7] 10.5.12 IMEISV Request */
965         DE_REC_N_PDU_NUM_LIST,                  /* [7] 10.5.13 Receive N-PDU Numbers List */
966         DE_MS_NET_CAP,                                  /* [7] 10.5.14 MS Network Capability */
967         DE_MS_RAD_ACC_CAP,                              /* [7] 10.5.15 MS Radio Access Capability */
968         DE_GMM_CAUSE,                                   /* [7] 10.5.16 GMM Cause */
969         DE_RAI,                                                 /* [7] 10.5.17 Routing Area Identification */
970         DE_UPD_RES,                                             /* [7] 10.5.18 Update Result */
971         DE_UPD_TYPE,                                    /* [7] 10.5.19 Update Type */
972         DE_AC_REF_NUM,                                  /* [7] 10.5.20 A&C Reference Number */
973         DE_AC_REF_NUM_H,                                /* A&C Reference Number - Info is in the high nibble */
974         DE_SRVC_TYPE,                                   /* [7] 10.5.20 Service Type */
975         DE_CELL_NOT,                                    /* [7] 10.5.21 Cell Notification */
976         DE_PS_LCS_CAP,                                  /* [7] 10.5.22 PS LCS Capability */
977         DE_NET_FEAT_SUP,                                /* [7] 10.5.23 Network Feature Support */
978         DE_RAT_INFO_CONTAINER,                  /* [7] 10.5.24 Inter RAT information container */
979         /* [7] 10.5.25 Requested MS information */
980         /* Session Management Information Elements [3] 10.5.6 */
981         DE_ACC_POINT_NAME,                              /* Access Point Name */
982         DE_NET_SAPI,                                    /* Network Service Access Point Identifier */
983         DE_PRO_CONF_OPT,                                /* Protocol Configuration Options */
984         DE_PD_PRO_ADDR,                                 /* Packet Data Protocol Address */
985         DE_QOS,                                                 /* Quality Of Service */
986         DE_SM_CAUSE,                                    /* SM Cause */
987         DE_SM_CAUSE_2,                                  /* SM Cause 2 */
988         DE_LINKED_TI,                                   /* Linked TI */
989         DE_LLC_SAPI,                                    /* LLC Service Access Point Identifier */
990         DE_TEAR_DOWN_IND,                               /* Tear Down Indicator */
991         DE_PACKET_FLOW_ID,                              /* Packet Flow Identifier */
992         DE_TRAFFIC_FLOW_TEMPLATE,               /* Traffic Flow Template */
993         DE_TMGI,                                                /* Temporary Mobile Group Identity (TMGI) */
994         DE_MBMS_BEARER_CAP,                             /* MBMS bearer capabilities */
995         DE_MBMS_PROT_CONF_OPT,                  /* MBMS protocol configuration options */
996         DE_ENH_NSAPI,                                   /* Enhanced network service access point identifier */
997         DE_REQ_TYPE,                                    /* Request type */
998         /* GPRS Common Information Elements [8] 10.5.7 */
999         DE_PDP_CONTEXT_STAT,                    /* [8] 10.5.7.1         PDP Context Status */
1000         DE_RAD_PRIO,                                    /* [8] 10.5.7.2         Radio Priority */
1001         DE_GPRS_TIMER,                                  /* [8] 10.5.7.3         GPRS Timer */
1002         DE_GPRS_TIMER_2,                                /* [8] 10.5.7.4         GPRS Timer 2 */
1003         DE_RAD_PRIO_2,                                  /* [8] 10.5.7.5         Radio Priority 2 */
1004         DE_MBMS_CTX_STATUS,                             /* [8] 10.5.7.6         MBMS context status */
1005         DE_GM_NONE                                                      /* NONE */
1006 }
1007 gm_elem_idx_t;
1008
1009 typedef enum
1010 {
1011         /* Radio Resource Management Information Elements 10.5.2, most are from 10.5.1  */
1012         DE_RR_BA_RANGE,                            /* [3]  10.5.2.1a    BA Range */
1013         DE_RR_CELL_CH_DSC,                         /* [3]  10.5.2.1b    Cell Channel Description        */
1014         DE_RR_BA_LIST_PREF,                        /* [3]  10.5.2.1c    BA List Pref */
1015         DE_RR_UTRAN_FREQ_LIST,             /* [3]  10.5.2.1d    UTRAN Frequency List */
1016         DE_RR_CELL_SELECT_INDIC,           /* [3]  10.5.2.1e    Cell selection indicator after release of all TCH and SDCCH IE */
1017         DE_RR_CELL_DSC,                                 /* 10.5.2.2   RR Cell Description                               */
1018         DE_RR_CELL_OPT_BCCH,                            /* [3]  10.5.2.3        Cell Options (BCCH)             */
1019         DE_RR_CELL_OPT_SACCH,                           /* [3]  10.5.2.3a       Cell Options (SACCH)            */
1020         DE_RR_CELL_SEL_PARAM,                           /* [3]  10.5.2.4        Cell Selection Parameters               */
1021 /*
1022  * [3]  10.5.2.4a       (void)
1023  */
1024         DE_RR_CH_DSC,                                   /* [3]  10.5.2.5        Channel Description                     */
1025         DE_RR_CH_DSC2,                                  /* [3]  10.5.2.5a   Channel Description 2               */
1026         DE_RR_CH_DSC3,                                  /* [3]  10.5.2.5c   Channel Description 3               */
1027         DE_RR_CH_MODE,                                  /* [3]  10.5.2.6        Channel Mode                            */
1028         DE_RR_CH_MODE2,                                 /* [3]  10.5.2.7        Channel Mode 2                          */
1029         DE_RR_UTRAN_CM,                                 /* [3]  10.5.2.7a       UTRAN Classmark */
1030 /* [3]  10.5.2.7b       (void) */
1031         DE_RR_CM_ENQ_MASK,                              /* [3]  10.5.2.7c       Classmark Enquiry Mask          */
1032 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element                                             */
1033         DE_RR_CHNL_NEEDED,                              /* [3]  10.5.2.8        Channel Needed
1034  * [3]  10.5.2.8a       (void)
1035  * [3]  10.5.2.8b       Channel Request Description 2 */
1036         DE_RR_CIP_MODE_SET,                             /* [3]  10.5.2.9        Cipher Mode Setting                     */
1037         DE_RR_CIP_MODE_RESP,                    /* [3]  10.5.2.10       Cipher Response                  */
1038         DE_RR_CTRL_CH_DESC,                             /* [3]  10.5.2.11       Control Channel Description     */
1039 /* [3]  10.5.2.11a      DTM Information Details */
1040         DE_RR_DYN_ARFCN_MAP,                    /* [3]  10.5.2.11b      Dynamic ARFCN Mapping           */
1041         DE_RR_FREQ_CH_SEQ,                              /* [3]  10.5.2.12       Frequency Channel Sequence      */
1042         DE_RR_FREQ_LIST,                                /* [3]  10.5.2.13       Frequency List                          */
1043         DE_RR_FREQ_SHORT_LIST,                  /* [3]  10.5.2.14       Frequency Short List            */
1044         DE_RR_FREQ_SHORT_LIST2,                 /* [3]  10.5.2.14a      Frequency Short List 2          */
1045 /* [3]  10.5.2.14b      Group Channel Description */
1046         DE_RR_GPRS_RESUMPTION,                  /* [3]  10.5.2.14c      GPRS Resumption */
1047         DE_RR_GPRS_BROADCAST_INFORMATION,                       /* [3]  10.5.2.14d      GPRS broadcast information */
1048 /* [3]  10.5.2.14e      Enhanced DTM CS Release Indication*/
1049
1050         DE_RR_HO_REF,                                   /* 10.5.2.15  Handover Reference                                */
1051
1052         DE_RR_IA_REST_OCT,                              /* [3] 10.5.2.16 IA Rest Octets                         */
1053         DE_RR_IAR_REST_OCT,                             /* [3] 10.5.2.17 IAR Rest Octets                                */
1054         DE_RR_IAX_REST_OCT,                             /* [3] 10.5.2.18 IAX Rest Octets                                */
1055         DE_RR_L2_PSEUDO_LEN,                    /* [3] 10.5.2.19 L2 Pseudo Length                               */
1056         DE_RR_MEAS_RES,                                 /* [3] 10.5.2.20 Measurement Results            */
1057  /* [3] 10.5.2.20a GPRS Measurement Results */
1058         DE_RR_MOB_ALL,                                  /* [3] 10.5.2.21 Mobile Allocation                              */
1059         DE_RR_MOB_TIME_DIFF,                    /* [3] 10.5.2.21a Mobile Time Difference                */
1060         DE_RR_MULTIRATE_CONF,                   /* [3] 10.5.2.21aa MultiRate configuration              */
1061         DE_RR_MULT_ALL,                                 /* [3] 10.5.2.21b Multislot Allocation                  */
1062 /*
1063  * [3] 10.5.2.21c NC mode
1064  */
1065         DE_RR_NEIGH_CELL_DESC,                          /* [3] 10.5.2.22 Neighbour Cell Description     */
1066         DE_RR_NEIGH_CELL_DESC2,                         /* [3] 10.5.2.22a Neighbour Cell Description 2  */
1067 /*
1068  * [3] 10.5.2.22b (void)
1069  * [3] 10.5.2.22c NT/N Rest Octets */
1070         DE_RR_P1_REST_OCT,                                      /* [3] 10.5.2.23 P1 Rest Octets */
1071         DE_RR_P2_REST_OCT,                                      /* [3] 10.5.2.24 P2 Rest Octets */
1072         DE_RR_P3_REST_OCT,                                      /* [3] 10.5.2.25 P3 Rest Octets */
1073         DE_RR_PACKET_CH_DESC,                           /* [3] 10.5.2.25a Packet Channel Description    */
1074         DE_RR_DED_MOD_OR_TBF,                   /* [3] 10.5.2.25b Dedicated mode or TBF                 */
1075 /* [3] 10.5.2.25c RR Packet Uplink Assignment
1076  * [3] 10.5.2.25d RR Packet Downlink Assignment */
1077         DE_RR_PAGE_MODE,                                /* [3] 10.5.2.26 Page Mode                                              */
1078 /* [3] 10.5.2.26a (void)
1079  * [3] 10.5.2.26b (void)
1080  * [3] 10.5.2.26c (void)
1081  * [3] 10.5.2.26d (void)
1082  */
1083         DE_RR_NCC_PERM,                                 /* [3] 10.5.2.27 NCC Permitted */
1084         DE_RR_POW_CMD,                                  /* 10.5.2.28  Power Command                                             */
1085         DE_RR_POW_CMD_AND_ACC_TYPE,             /* 10.5.2.28a Power Command and access type             */
1086         DE_RR_RACH_CTRL_PARAM,                  /* [3] 10.5.2.29 RACH Control Parameters */
1087         DE_RR_REQ_REF,                                  /* [3] 10.5.2.30 Request Reference                              */
1088         DE_RR_CAUSE,                                    /* 10.5.2.31  RR Cause                                                  */
1089         DE_RR_SYNC_IND,                                 /* 10.5.2.39  Synchronization Indication                */
1090         DE_RR_SI1_REST_OCT,                             /* [3] 10.5.2.32 SI1 Rest Octets */
1091 /* [3] 10.5.2.33 SI 2bis Rest Octets */
1092         DE_RR_SI2TER_REST_OCT,                  /* [3] 10.5.2.33a SI 2ter Rest Octets */
1093         DE_RR_SI2QUATER_REST_OCT,               /* [3] 10.5.2.33b SI 2quater Rest Octets */
1094         DE_RR_SI3_REST_OCT,                             /* [3] 10.5.2.34 SI3 Rest Octets */
1095         DE_RR_SI4_REST_OCT,                             /* [3] 10.5.2.35 SI4 Rest Octets */
1096         DE_RR_SI6_REST_OCT,                             /* [3] 10.5.2.35a SI6 Rest Octets */
1097 /* [3] 10.5.2.36 SI 7 Rest Octets
1098  * [3] 10.5.2.37 SI 8 Rest Octets
1099  * [3] 10.5.2.37a SI 9 Rest Octets
1100  */
1101         DE_RR_SI13_REST_OCT,                            /* [3] 10.5.2.37b SI13 Rest Octets */
1102 /* [3] 10.5.2.37c (void)
1103  * [3] 10.5.2.37d (void)
1104  * [3] 10.5.2.37e SI 16 Rest Octets
1105  * [3] 10.5.2.37f SI 17 Rest Octets
1106  * [3] 10.5.2.37g SI 19 Rest Octets
1107  * [3] 10.5.2.37h SI 18 Rest Octets
1108  * [3] 10.5.2.37i SI 20 Rest Octets */
1109         DE_RR_STARTING_TIME,                    /* [3] 10.5.2.38 Starting Time                                  */
1110         DE_RR_TIMING_ADV,                               /* [3] 10.5.2.40 Timing Advance                                 */
1111         DE_RR_TIME_DIFF,                                /* [3] 10.5.2.41 Time Difference                                */
1112         DE_RR_TLLI,                                             /* [3] 10.5.2.41a TLLI                                                  */
1113         DE_RR_TMSI_PTMSI,                               /* [3] 10.5.2.42 TMSI/P-TMSI */
1114         DE_RR_VGCS_TAR_MODE_IND,                /* [3] 10.5.2.42a VGCS target mode Indication   */
1115         DE_RR_VGCS_CIP_PAR,                             /* [3] 10.5.2.42b       VGCS Ciphering Parameters       */
1116
1117         DE_RR_WAIT_IND,                                 /* [3] 10.5.2.43 Wait Indication */
1118 /* [3] 10.5.2.44 SI10 rest octets $(ASCI)$ */
1119         DE_RR_EXT_MEAS_RESULT,          /* [3] 10.5.2.45 Extended Measurement Results */
1120         DE_RR_EXT_MEAS_FREQ_LIST,               /* [3] 10.5.2.46 Extended Measurement Frequency List */
1121         DE_RR_SUS_CAU,                                  /* [3] 10.5.2.47 Suspension Cause                               */
1122         DE_RR_APDU_ID,                                  /* [3] 10.5.2.48 APDU ID */
1123         DE_RR_APDU_FLAGS,                               /* [3] 10.5.2.49 APDU Flags */
1124         DE_RR_APDU_DATA,                                /* [3] 10.5.2.50 APDU Data */
1125         DE_RR_HO_TO_UTRAN_CMD,                  /* [3] 10.5.2.51 Handover To UTRAN Command */
1126 /* [3] 10.5.2.52 Handover To cdma2000 Command
1127  * [3] 10.5.2.53 (void)
1128  * [3] 10.5.2.54 (void)
1129  * [3] 10.5.2.55 (void)
1130  * [3] 10.5.2.56 3G Target Cell */
1131         DE_RR_SERV_SUP,                                 /* 10.5.2.57 Service Support                                            */
1132 /* 10.5.2.58 MBMS p-t-m Channel Description
1133  */
1134
1135         DE_RR_DED_SERV_INF,                             /* [3] 10.5.2.59        Dedicated Service Information */
1136
1137 /*
1138  * 10.5.2.60 MPRACH Description
1139  * 10.5.2.61 Restriction Timer
1140  * 10.5.2.62 MBMS Session Identity
1141  * 10.5.2.63 Reduced group or broadcast call reference
1142  * 10.5.2.64 Talker Priority status
1143  * 10.5.2.65 Talker Identity
1144  * 10.5.2.66 Token
1145  * 10.5.2.67 PS Cause
1146  * 10.5.2.68 VGCS AMR Configuration
1147  */
1148         DE_RR_CARRIER_IND,                              /* 10.5.2.69 Carrier Indication */
1149         DE_RR_NONE                                                      /* NONE */
1150 }
1151 rr_elem_idx_t;
1152
1153 #endif /* __PACKET_GSM_A_COMMON_H__ */