Replace tabs by spaces when editor modelines has "expandtab"
[metze/wireshark/wip.git] / epan / dissectors / packet-gsm_a_dtap.c
1 /* packet-gsm_a_dtap.c
2  * Routines for GSM A Interface DTAP dissection - A.K.A. GSM layer 3
3  * NOTE: it actually includes RR messages, which are (generally) not carried
4  * over the A interface on DTAP, but are part of the same Layer 3 protocol set
5  *
6  * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
7  * In association with Telos Technology Inc.
8  *
9  *
10  * Added the GPRS Mobility Managment Protocol and
11  * the GPRS Session Managment Protocol
12  *   Copyright 2004, Rene Pilz <rene.pilz [AT] ftw.com>
13  *   In association with Telecommunications Research Center
14  *   Vienna (ftw.)Betriebs-GmbH within the Project Metawin.
15  *
16  * Added Dissection of Radio Resource Management Information Elements
17  * and other enhancements and fixes.
18  * Copyright 2005 - 2009, Anders Broman [AT] ericsson.com
19  * Small bugfixes, mainly in Qos and TFT by Nils Ljungberg and Stefan Boman [AT] ericsson.com
20  *
21  * Various updates, enhancements and fixes
22  * Copyright 2009, Gerasimos Dimitriadis <dimeg [AT] intracom.gr>
23  * In association with Intracom Telecom SA
24  *
25  * Title        3GPP            Other
26  *
27  *   Reference [3]
28  *   Mobile radio interface Layer 3 specification;
29  *   Core network protocols;
30  *   Stage 3
31  *   (3GPP TS 24.008 version 4.7.0 Release 4)
32  *   (ETSI TS 124 008 V6.8.0 (2005-03))
33  *
34  *   Reference [4]
35  *   Mobile radio interface layer 3 specification;
36  *   Radio Resource Control Protocol
37  *   (GSM 04.18 version 8.4.1 Release 1999)
38  *   (3GPP TS 04.18 version 8.26.0 Release 1999)
39  *
40  *   Reference [5]
41  *   Point-to-Point (PP) Short Message Service (SMS)
42  *   support on mobile radio interface
43  *   (3GPP TS 24.011 version 4.1.1 Release 4)
44  *
45  *   Reference [6]
46  *   Mobile radio Layer 3 supplementary service specification;
47  *   Formats and coding
48  *   (3GPP TS 24.080 version 4.3.0 Release 4)
49  *
50  *   Reference [7]
51  *   Mobile radio interface Layer 3 specification;
52  *   Core network protocols;
53  *   Stage 3
54  *   (3GPP TS 24.008 version 5.9.0 Release 5)
55  *
56  *   Reference [8]
57  *   Mobile radio interface Layer 3 specification;
58  *   Core network protocols;
59  *   Stage 3
60  *   (3GPP TS 24.008 version 6.7.0 Release 6)
61  *   (3GPP TS 24.008 version 6.8.0 Release 6)
62  *
63  *   Reference [9]
64  *   Mobile radio interface Layer 3 specification;
65  *   Core network protocols;
66  *   Stage 3
67  *   (3GPP TS 24.008 version 9.6.0 Release 9)
68  *
69  *   Reference [10]
70  *   Mobile radio interface Layer 3 specification;
71  *   Core network protocols;
72  *   Stage 3
73  *   (3GPP TS 24.008 version 10.6.1 Release 10)
74  *
75  *   Reference [11]
76  *   Mobile radio interface Layer 3 specification;
77  *   Core network protocols;
78  *   Stage 3
79  *   (3GPP TS 24.008 version 11.6.0 Release 11)
80  *
81  * Wireshark - Network traffic analyzer
82  * By Gerald Combs <gerald@wireshark.org>
83  * Copyright 1998 Gerald Combs
84  *
85  * This program is free software; you can redistribute it and/or
86  * modify it under the terms of the GNU General Public License
87  * as published by the Free Software Foundation; either version 2
88  * of the License, or (at your option) any later version.
89  *
90  * This program is distributed in the hope that it will be useful,
91  * but WITHOUT ANY WARRANTY; without even the implied warranty of
92  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
93  * GNU General Public License for more details.
94  *
95  * You should have received a copy of the GNU General Public License
96  * along with this program; if not, write to the Free Software
97  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
98  */
99
100 #include "config.h"
101
102 #include <epan/packet.h>
103 #include <epan/expert.h>
104 #include <epan/tap.h>
105 #include <epan/strutil.h>
106
107 #include "packet-bssap.h"
108 #include "packet-ber.h"
109 #include "packet-q931.h"
110 #include "packet-gsm_a_common.h"
111 #include "packet-ppp.h"
112 #include "packet-isup.h"
113
114 void proto_register_gsm_a_dtap(void);
115 void proto_reg_handoff_gsm_a_dtap(void);
116
117 /* PROTOTYPES/FORWARDS */
118
119 const value_string gsm_a_dtap_msg_mm_strings[] = {
120     { 0x01, "IMSI Detach Indication" },
121     { 0x02, "Location Updating Accept" },
122     { 0x04, "Location Updating Reject" },
123     { 0x08, "Location Updating Request" },
124     { 0x11, "Authentication Reject" },
125     { 0x12, "Authentication Request" },
126     { 0x14, "Authentication Response" },
127     { 0x1c, "Authentication Failure" },
128     { 0x18, "Identity Request" },
129     { 0x19, "Identity Response" },
130     { 0x1a, "TMSI Reallocation Command" },
131     { 0x1b, "TMSI Reallocation Complete" },
132     { 0x21, "CM Service Accept" },
133     { 0x22, "CM Service Reject" },
134     { 0x23, "CM Service Abort" },
135     { 0x24, "CM Service Request" },
136     { 0x25, "CM Service Prompt" },
137     { 0x26, "Reserved: was allocated in earlier phases of the protocol" },
138     { 0x28, "CM Re-establishment Request" },
139     { 0x29, "Abort" },
140     { 0x30, "MM Null" },
141     { 0x31, "MM Status" },
142     { 0x32, "MM Information" },
143     { 0, NULL }
144 };
145
146 const value_string gsm_a_dtap_msg_cc_strings[] = {
147     { 0x01, "Alerting" },
148     { 0x08, "Call Confirmed" },
149     { 0x02, "Call Proceeding" },
150     { 0x07, "Connect" },
151     { 0x0f, "Connect Acknowledge" },
152     { 0x0e, "Emergency Setup" },
153     { 0x03, "Progress" },
154     { 0x04, "CC-Establishment" },
155     { 0x06, "CC-Establishment Confirmed" },
156     { 0x0b, "Recall" },
157     { 0x09, "Start CC" },
158     { 0x05, "Setup" },
159     { 0x17, "Modify" },
160     { 0x1f, "Modify Complete" },
161     { 0x13, "Modify Reject" },
162     { 0x10, "User Information" },
163     { 0x18, "Hold" },
164     { 0x19, "Hold Acknowledge" },
165     { 0x1a, "Hold Reject" },
166     { 0x1c, "Retrieve" },
167     { 0x1d, "Retrieve Acknowledge" },
168     { 0x1e, "Retrieve Reject" },
169     { 0x25, "Disconnect" },
170     { 0x2d, "Release" },
171     { 0x2a, "Release Complete" },
172     { 0x39, "Congestion Control" },
173     { 0x3e, "Notify" },
174     { 0x3d, "Status" },
175     { 0x34, "Status Enquiry" },
176     { 0x35, "Start DTMF" },
177     { 0x31, "Stop DTMF" },
178     { 0x32, "Stop DTMF Acknowledge" },
179     { 0x36, "Start DTMF Acknowledge" },
180     { 0x37, "Start DTMF Reject" },
181     { 0x3a, "Facility" },
182     { 0, NULL }
183 };
184
185 const value_string gsm_a_dtap_msg_sms_strings[] = {
186     { 0x01, "CP-DATA" },
187     { 0x04, "CP-ACK" },
188     { 0x10, "CP-ERROR" },
189     { 0, NULL }
190 };
191
192 const value_string gsm_a_dtap_msg_ss_strings[] = {
193     { 0x2a, "Release Complete" },
194     { 0x3a, "Facility" },
195     { 0x3b, "Register" },
196     { 0, NULL }
197 };
198
199 const value_string gsm_a_dtap_msg_tp_strings[] = {
200     { 0x00, "Close TCH Loop Cmd" },
201     { 0x01, "Close TCH Loop Ack" },
202     { 0x06, "Open Loop Cmd" },
203     { 0x0c, "Act EMMI Cmd" },
204     { 0x0d, "Act EMMI Ack" },
205     { 0x10, "Deact EMMI" },
206     { 0x14, "Test Interface" },
207     { 0x20, "Close Multi-slot Loop Cmd" },
208     { 0x21, "Close Multi-slot Loop Ack" },
209     { 0x22, "Open Multi-slot Loop Cmd" },
210     { 0x23, "Open Multi-slot Loop Ack" },
211     { 0x24, "GPRS Test Mode Cmd" },
212     { 0x25, "EGPRS Start Radio Block Loopback Cmd" },
213     { 0x26, "Reset MS Positioning Stored Information" },
214     { 0x40, "Close UE Test Loop" },
215     { 0x41, "Close UE Test Loop Complete" },
216     { 0x42, "Open UE Test Loop" },
217     { 0x43, "Open UE Test Loop Complete" },
218     { 0x44, "Activate RB Test Mode" },
219     { 0x45, "Activate RB Test Mode Complete" },
220     { 0x46, "Deactivate RB Test Mode" },
221     { 0x47, "Deactivate RB Test Mode Complete" },
222     { 0x48, "Reset UE Positioning Stored Information" },
223     { 0x49, "UE Test Loop Mode 3 RLC SDU Counter Request" },
224     { 0x4A, "UE Test Loop Mode 3 RLC SDU Counter Response" },
225     { 0x80, "Close UE Test Loop" },
226     { 0x81, "Close UE Test Loop Complete" },
227     { 0x82, "Open UE Test Loop" },
228     { 0x83, "Open UE Test Loop Complete" },
229     { 0x84, "Activate Test Mode" },
230     { 0x85, "Activate Test Mode Complete" },
231     { 0x86, "Deactivate Test Mode" },
232     { 0x87, "Deactivate Test Mode Complete" },
233     { 0x88, "Reset UE Positioning Stored Information" },
234     { 0x89, "UE Test Loop Mode C MBMS Packet Counter Request" },
235     { 0x8a, "UE Test Loop Mode C MBMS Packet Counter Response" },
236     { 0x8b, "Update UE Location Information" },
237     { 0, NULL }
238 };
239
240 static const value_string gsm_dtap_elem_strings[] = {
241     /* Mobility Management Information Elements 10.5.3 */
242     { DE_AUTH_PARAM_RAND,                  "Authentication Parameter RAND" },
243     { DE_AUTH_PARAM_AUTN,                  "Authentication Parameter AUTN (UMTS and EPS authentication challenge)" },
244     { DE_AUTH_RESP_PARAM,                  "Authentication Response Parameter" },
245     { DE_AUTH_RESP_PARAM_EXT,              "Authentication Response Parameter (extension) (UMTS authentication challenge only)" },
246     { DE_AUTH_FAIL_PARAM,                  "Authentication Failure Parameter (UMTS and EPS authentication challenge)" },
247     { DE_CM_SRVC_TYPE,                     "CM Service Type" },
248     { DE_ID_TYPE,                          "Identity Type" },
249     { DE_LOC_UPD_TYPE,                     "Location Updating Type" },
250     { DE_NETWORK_NAME,                     "Network Name" },
251     { DE_REJ_CAUSE,                        "Reject Cause" },
252     { DE_FOP,                              "Follow-on Proceed" },
253     { DE_TIME_ZONE,                        "Time Zone" },
254     { DE_TIME_ZONE_TIME,                   "Time Zone and Time" },
255     { DE_CTS_PERM,                         "CTS Permission" },
256     { DE_LSA_ID,                           "LSA Identifier" },
257     { DE_DAY_SAVING_TIME,                  "Daylight Saving Time" },
258     { DE_EMERGENCY_NUM_LIST,               "Emergency Number List" },
259     { DE_ADD_UPD_PARAMS,                   "Additional update parameters" },
260     { DE_MM_TIMER,                         "MM Timer" },
261     /* Call Control Information Elements 10.5.4 */
262     { DE_AUX_STATES,                       "Auxiliary States" },                /* 10.5.4.4 Auxiliary states */
263     { DE_BEARER_CAP,                       "Bearer Capability" },               /* 10.5.4.4a Backup bearer capability */
264     { DE_CC_CAP,                           "Call Control Capabilities" },
265     { DE_CALL_STATE,                       "Call State" },
266     { DE_CLD_PARTY_BCD_NUM,                "Called Party BCD Number" },
267     { DE_CLD_PARTY_SUB_ADDR,               "Called Party Subaddress" },
268     { DE_CLG_PARTY_BCD_NUM,                "Calling Party BCD Number" },
269     { DE_CLG_PARTY_SUB_ADDR,               "Calling Party Subaddress" },
270     { DE_CAUSE,                            "Cause" },
271     { DE_CLIR_SUP,                         "CLIR Suppression" },
272     { DE_CLIR_INV,                         "CLIR Invocation" },
273     { DE_CONGESTION,                       "Congestion Level" },
274     { DE_CONN_NUM,                         "Connected Number" },
275     { DE_CONN_SUB_ADDR,                    "Connected Subaddress" },
276     { DE_FACILITY,                         "Facility" },
277     { DE_HLC,                              "High Layer Compatibility" },
278     { DE_KEYPAD_FACILITY,                  "Keypad Facility" },
279     { DE_LLC,                              "Low Layer Compatibility" },
280     { DE_MORE_DATA,                        "More Data" },
281     { DE_NOT_IND,                          "Notification Indicator" },
282     { DE_PROG_IND,                         "Progress Indicator" },
283     { DE_RECALL_TYPE,                      "Recall type $(CCBS)$" },
284     { DE_RED_PARTY_BCD_NUM,                "Redirecting Party BCD Number" },
285     { DE_RED_PARTY_SUB_ADDR,               "Redirecting Party Subaddress" },
286     { DE_REPEAT_IND,                       "Repeat Indicator" },
287     { DE_REV_CALL_SETUP_DIR,               "Reverse Call Setup Direction" },
288     { DE_SETUP_CONTAINER,                  "SETUP Container $(CCBS)$" },
289     { DE_SIGNAL,                           "Signal" },
290     { DE_SS_VER_IND,                       "SS Version Indicator" },
291     { DE_USER_USER,                        "User-user" },
292     { DE_ALERT_PATTERN,                    "Alerting Pattern $(NIA)$" },        /* 10.5.4.26 Alerting Pattern $(NIA)$ */
293     { DE_ALLOWED_ACTIONS,                  "Allowed Actions $(CCBS)$" },
294     { DE_SI,                               "Stream Identifier" },
295     { DE_NET_CC_CAP,                       "Network Call Control Capabilities" },
296     { DE_CAUSE_NO_CLI,                     "Cause of No CLI" },                 /* 10.5.4.30 Cause of No CLI */
297     /* 10.5.4.31 Void */
298     { DE_SUP_CODEC_LIST,                   "Supported Codec List" },            /* 10.5.4.32 Supported codec list */
299     { DE_SERV_CAT,                         "Service Category" },                /* 10.5.4.33 Service category */
300     { DE_REDIAL,                           "Redial" },                          /* 10.5.4.34 Redial */
301     { DE_NET_INIT_SERV_UPG,                "Network-initiated Service Upgrade indicator" },
302     /* 10.5.4.35 Network-initiated Service Upgrade indicator */
303     /* Short Message Service Information Elements [5] 8.1.4 */
304     { DE_CP_USER_DATA,                     "CP-User Data" },
305     { DE_CP_CAUSE,                         "CP-Cause" },
306     /* Tests procedures information elements 3GPP TS 44.014 6.4.0, 3GPP TS 34.109 6.4.0 and 3GPP TS 36.509 9.1.0*/
307     { DE_TP_SUB_CHANNEL,                   "Close TCH Loop Cmd Sub-channel"},
308     { DE_TP_ACK,                           "Open Loop Cmd Ack"},
309     { DE_TP_LOOP_TYPE,                     "Close Multi-slot Loop Cmd Loop type"},
310     { DE_TP_LOOP_ACK,                      "Close Multi-slot Loop Ack Result"},
311     { DE_TP_TESTED_DEVICE,                 "Test Interface Tested device"},
312     { DE_TP_PDU_DESCRIPTION,               "GPRS Test Mode Cmd PDU description"},
313     { DE_TP_MODE_FLAG,                     "GPRS Test Mode Cmd Mode flag"},
314     { DE_TP_EGPRS_MODE_FLAG,               "EGPRS Start Radio Block Loopback Cmd Mode flag"},
315     { DE_TP_MS_POSITIONING_TECHNOLOGY,     "MS Positioning Technology"},
316     { DE_TP_UE_TEST_LOOP_MODE,             "Close UE Test Loop Mode"},
317     { DE_TP_UE_POSITIONING_TECHNOLOGY,     "UE Positioning Technology"},
318     { DE_TP_RLC_SDU_COUNTER_VALUE,         "RLC SDU Counter Value"},
319     { DE_TP_EPC_UE_TEST_LOOP_MODE,         "UE Test Loop Mode"},
320     { DE_TP_EPC_UE_TL_A_LB_SETUP,          "UE Test Loop Mode A LB Setup"},
321     { DE_TP_EPC_UE_TL_B_LB_SETUP,          "UE Test Loop Mode B LB Setup"},
322     { DE_TP_EPC_UE_TL_C_SETUP,             "UE Test Loop Mode C Setup"},
323     { DE_TP_EPC_UE_POSITIONING_TECHNOLOGY, "UE Positioning Technology"},
324     { DE_TP_EPC_MBMS_PACKET_COUNTER_VALUE, "MBMS Packet Counter Value"},
325     { DE_TP_EPC_ELLIPSOID_POINT_WITH_ALT,  "Ellipsoid Point With Altitude"},
326     { DE_TP_EPC_HORIZONTAL_VELOCITY,       "Horizontal Velocity"},
327     { DE_TP_EPC_GNSS_TOD_MSEC,             "GNSS-TOD-msec"},
328     { 0, NULL }
329 };
330 value_string_ext gsm_dtap_elem_strings_ext = VALUE_STRING_EXT_INIT(gsm_dtap_elem_strings);
331
332 const gchar *gsm_a_pd_str[] = {
333     "Group Call Control",
334     "Broadcast Call Control",
335     "EPS session management messages",
336     "Call Control; call related SS messages",
337     "GPRS Transparent Transport Protocol (GTTP)",
338     "Mobility Management messages",
339     "Radio Resources Management messages",
340     "EPS mobility management messages",
341     "GPRS Mobility Management messages",
342     "SMS messages",
343     "GPRS Session Management messages",
344     "Non call related SS messages",
345     "Location services specified in 3GPP TS 44.071",
346     "Unknown",
347     "Reserved for extension of the PD to one octet length",
348     "Special conformance testing functions"
349 };
350 /* L3 Protocol discriminator values according to TS 24 007 (6.4.0)  */
351 const value_string protocol_discriminator_vals[] = {
352     {0x0,       "Group call control"},
353     {0x1,       "Broadcast call control"},
354     {0x2,       "EPS session management messages"},
355     {0x3,       "Call Control; call related SS messages"},
356     {0x4,       "GPRS Transparent Transport Protocol (GTTP)"},
357     {0x5,       "Mobility Management messages"},
358     {0x6,       "Radio Resources Management messages"},
359     {0x7,       "EPS mobility management messages"},
360     {0x8,       "GPRS mobility management messages"},
361     {0x9,       "SMS messages"},
362     {0xa,       "GPRS session management messages"},
363     {0xb,       "Non call related SS messages"},
364     {0xc,       "Location services specified in 3GPP TS 44.071"},
365     {0xd,       "Unknown"},
366     {0xe,       "Reserved for extension of the PD to one octet length "},
367     {0xf,       "Tests procedures described in 3GPP TS 44.014, 3GPP TS 34.109 and 3GPP TS 36.509"},
368     { 0,    NULL }
369 };
370
371 const value_string gsm_a_pd_short_str_vals[] = {
372     {0x0,       "GCC"},     /* Group Call Control */
373     {0x1,       "BCC"},     /* Broadcast Call Control */
374     {0x2,       "Reserved"},    /* : was allocated in earlier phases of the protocol */
375     {0x3,       "CC"},      /* Call Control; call related SS messages */
376     {0x4,       "GTTP"},    /* GPRS Transparent Transport Protocol (GTTP) */
377     {0x5,       "MM"},      /* Mobility Management messages */
378     {0x6,       "RR"},      /* Radio Resources Management messages */
379     {0x7,       "Unknown"},
380     {0x8,       "GMM"},     /* GPRS Mobility Management messages */
381     {0x9,       "SMS"},
382     {0xa,       "SM"},      /* GPRS Session Management messages */
383     {0xb,       "SS"},
384     {0xc,       "LS"},      /* Location Services */
385     {0xd,       "Unknown"},
386     {0xe,       "Reserved"},    /*  for extension of the PD to one octet length  */
387     {0xf,       "TP"},      /*  for tests procedures described in 3GPP TS 44.014 6.4.0 and 3GPP TS 34.109 6.4.0.*/
388     { 0,    NULL }
389 };
390
391 static const true_false_string tfs_acceptable_not_acceptable = { "Acceptable", "Not Acceptable" };
392
393
394 #define DTAP_PD_MASK        0x0f
395 #define DTAP_SKIP_MASK      0xf0
396 #define DTAP_TI_MASK        DTAP_SKIP_MASK
397 #define DTAP_TIE_PRES_MASK  0x07            /* after TI shifted to right */
398 #define DTAP_TIE_MASK       0x7f
399
400 #define DTAP_MM_IEI_MASK    0x3f
401 #define DTAP_CC_IEI_MASK    0x3f
402 #define DTAP_SMS_IEI_MASK   0xff
403 #define DTAP_SS_IEI_MASK    0x3f
404 #define DTAP_TP_IEI_MASK    0xff
405
406 /* Initialize the protocol and registered fields */
407 static int proto_a_dtap = -1;
408
409 static int hf_gsm_a_dtap_msg_mm_type = -1;
410 static int hf_gsm_a_dtap_msg_cc_type = -1;
411 static int hf_gsm_a_seq_no = -1;
412 static int hf_gsm_a_dtap_msg_sms_type = -1;
413 static int hf_gsm_a_dtap_msg_ss_type = -1;
414 static int hf_gsm_a_dtap_msg_tp_type = -1;
415 int hf_gsm_a_dtap_elem_id = -1;
416 static int hf_gsm_a_dtap_cld_party_bcd_num = -1;
417 static int hf_gsm_a_dtap_clg_party_bcd_num = -1;
418 static int hf_gsm_a_dtap_conn_num   = -1;
419 static int hf_gsm_a_dtap_red_party_bcd_num = -1;
420 static int hf_gsm_a_dtap_present_ind = -1;
421 static int hf_gsm_a_dtap_screening_ind = -1;
422 static int hf_gsm_a_dtap_type_of_sub_addr   = -1;
423 static int hf_gsm_a_dtap_odd_even_ind   = -1;
424
425 static int hf_gsm_a_dtap_cause = -1;
426 static int hf_gsm_a_dtap_cause_ss_diagnostics   = -1;
427 static int hf_gsm_a_dtap_emergency_bcd_num  = -1;
428 static int hf_gsm_a_dtap_emerg_num_info_length = -1;
429
430 static int hf_gsm_a_dtap_type_of_number = -1;
431 static int hf_gsm_a_dtap_numbering_plan_id = -1;
432
433 static int hf_gsm_a_dtap_lsa_id = -1;
434 static int hf_gsm_a_dtap_speech_vers_ind = -1;
435 static int hf_gsm_a_dtap_itc = -1;
436 static int hf_gsm_a_dtap_sysid = -1;
437 static int hf_gsm_a_dtap_bitmap_length = -1;
438 static int hf_gsm_a_dtap_serv_cat_b7 = -1;
439 static int hf_gsm_a_dtap_serv_cat_b6 = -1;
440 static int hf_gsm_a_dtap_serv_cat_b5 = -1;
441 static int hf_gsm_a_dtap_serv_cat_b4 = -1;
442 static int hf_gsm_a_dtap_serv_cat_b3 = -1;
443 static int hf_gsm_a_dtap_serv_cat_b2 = -1;
444 static int hf_gsm_a_dtap_serv_cat_b1 = -1;
445 static int hf_gsm_a_dtap_csmo = -1;
446 static int hf_gsm_a_dtap_csmt = -1;
447 static int hf_gsm_a_dtap_mm_timer_unit = -1;
448 static int hf_gsm_a_dtap_mm_timer_value = -1;
449 static int hf_gsm_a_dtap_alerting_pattern = -1;
450 static int hf_gsm_a_dtap_ccbs_activation = -1;
451 static int hf_gsm_a_dtap_stream_identifier = -1;
452 static int hf_gsm_a_dtap_mcs = -1;
453 static int hf_gsm_a_dtap_cause_of_no_cli = -1;
454 static int hf_gsm_a_dtap_signal_value = -1;
455
456 static int hf_gsm_a_dtap_codec_tdma_efr = -1;
457 static int hf_gsm_a_dtap_codec_umts_amr_2 = -1;
458 static int hf_gsm_a_dtap_codec_umts_amr = -1;
459 static int hf_gsm_a_dtap_codec_hr_amr = -1;
460 static int hf_gsm_a_dtap_codec_fr_amr = -1;
461 static int hf_gsm_a_dtap_codec_gsm_efr = -1;
462 static int hf_gsm_a_dtap_codec_gsm_hr = -1;
463 static int hf_gsm_a_dtap_codec_gsm_fr = -1;
464 static int hf_gsm_a_dtap_codec_ohr_amr_wb = -1;
465 static int hf_gsm_a_dtap_codec_ofr_amr_wb = -1;
466 static int hf_gsm_a_dtap_codec_ohr_amr = -1;
467 static int hf_gsm_a_dtap_codec_umts_amr_wb = -1;
468 static int hf_gsm_a_dtap_codec_fr_amr_wb = -1;
469 static int hf_gsm_a_dtap_codec_pdc_efr = -1;
470
471 static int hf_gsm_a_dtap_notification_description = -1;
472 static int hf_gsm_a_dtap_recall_type    = -1;
473 static int hf_gsm_a_dtap_coding_standard    = -1;
474 static int hf_gsm_a_dtap_call_state = -1;
475 static int hf_gsm_a_dtap_prog_coding_standard    = -1;
476 static int hf_gsm_a_dtap_location   = -1;
477 static int hf_gsm_a_dtap_progress_description   = -1;
478 static int hf_gsm_a_dtap_afi    = -1;
479 static int hf_gsm_a_dtap_rej_cause  = -1;
480 static int hf_gsm_a_dtap_u2u_prot_discr = -1;
481 static int hf_gsm_a_dtap_mcat   = -1;
482 static int hf_gsm_a_dtap_enicm  = -1;
483 static int hf_gsm_a_dtap_rand   = -1;
484 static int hf_gsm_a_dtap_autn   = -1;
485 static int hf_gsm_a_dtap_xres   = -1;
486 static int hf_gsm_a_dtap_sres   = -1;
487 static int hf_gsm_a_dtap_auts   = -1;
488 static int hf_gsm_a_dtap_autn_sqn_xor_ak = -1;
489 static int hf_gsm_a_dtap_autn_amf   = -1;
490 static int hf_gsm_a_dtap_autn_mac   = -1;
491 static int hf_gsm_a_dtap_auts_sqn_ms_xor_ak  = -1;
492 static int hf_gsm_a_dtap_auts_mac_s = -1;
493
494 static int hf_gsm_a_dtap_epc_ue_tl_mode = -1;
495 static int hf_gsm_a_dtap_epc_ue_tl_a_ul_sdu_size = -1;
496 static int hf_gsm_a_dtap_epc_ue_tl_a_drb = -1;
497 static int hf_gsm_a_dtap_epc_ue_tl_b_ip_pdu_delay = -1;
498 static int hf_gsm_a_dtap_epc_ue_tl_c_mbsfn_area_id = -1;
499 static int hf_gsm_a_dtap_epc_ue_tl_c_mch_id = -1;
500 static int hf_gsm_a_dtap_epc_ue_tl_c_lcid = -1;
501 static int hf_gsm_a_dtap_epc_ue_positioning_technology = -1;
502 static int hf_gsm_a_dtap_epc_mbms_packet_counter_value = -1;
503 static int hf_gsm_a_dtap_epc_latitude_sign = -1;
504 static int hf_gsm_a_dtap_epc_degrees_latitude = -1;
505 static int hf_gsm_a_dtap_epc_degrees_longitude = -1;
506 static int hf_gsm_a_dtap_epc_altitude_dir = -1;
507 static int hf_gsm_a_dtap_epc_altitude = -1;
508 static int hf_gsm_a_dtap_epc_bearing = -1;
509 static int hf_gsm_a_dtap_epc_horizontal_speed = -1;
510 static int hf_gsm_a_dtap_epc_gnss_tod_msec = -1;
511
512 /* Generated from convert_proto_tree_add_text.pl */
513 static int hf_gsm_a_dtap_maximum_number_of_supported_bearers = -1;
514 static int hf_gsm_a_dtap_edge_channel_codings = -1;
515 static int hf_gsm_a_dtap_acceptable_channel_codings_TCH_F9_6 = -1;
516 static int hf_gsm_a_dtap_assignor_assignee = -1;
517 static int hf_gsm_a_dtap_configuration = -1;
518 static int hf_gsm_a_dtap_de_cause_coding_standard = -1;
519 static int hf_gsm_a_dtap_ss_version_indicator = -1;
520 static int hf_gsm_a_dtap_mode_of_operation = -1;
521 static int hf_gsm_a_dtap_bearer_cap_coding_standard = -1;
522 static int hf_gsm_a_dtap_nirr = -1;
523 static int hf_gsm_a_dtap_other_rate_adaption = -1;
524 static int hf_gsm_a_dtap_connection_element = -1;
525 static int hf_gsm_a_dtap_nic_on_tx = -1;
526 static int hf_gsm_a_dtap_user_rate = -1;
527 static int hf_gsm_a_dtap_protocol_discriminator = -1;
528 static int hf_gsm_a_dtap_cp_cause = -1;
529 static int hf_gsm_a_dtap_rate_adaption_header = -1;
530 static int hf_gsm_a_dtap_synchronous = -1;
531 static int hf_gsm_a_dtap_logical_link_identifier_negotiation = -1;
532 static int hf_gsm_a_dtap_multi_party_auxiliary_state = -1;
533 static int hf_gsm_a_dtap_parity_information = -1;
534 static int hf_gsm_a_dtap_channel_coding03 = -1;
535 static int hf_gsm_a_dtap_channel_coding30 = -1;
536 static int hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F43_2 = -1;
537 static int hf_gsm_a_dtap_ue_positioning_technology = -1;
538 static int hf_gsm_a_dtap_acceptable_channel_codings_TCH_F4_8 = -1;
539 static int hf_gsm_a_dtap_number_of_spare_bits = -1;
540 static int hf_gsm_a_dtap_tie = -1;
541 static int hf_gsm_a_dtap_updating_type = -1;
542 static int hf_gsm_a_dtap_multiple_frame_establishment_support = -1;
543 static int hf_gsm_a_dtap_maximum_number_of_traffic_channels = -1;
544 static int hf_gsm_a_dtap_compression = -1;
545 static int hf_gsm_a_dtap_compression_up = -1;
546 static int hf_gsm_a_dtap_downlink_timeslot_offset = -1;
547 static int hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F32_0 = -1;
548 static int hf_gsm_a_dtap_tio = -1;
549 static int hf_gsm_a_dtap_other_modem_type = -1;
550 static int hf_gsm_a_dtap_other_itc = -1;
551 static int hf_gsm_a_dtap_negotiation = -1;
552 static int hf_gsm_a_dtap_rate_adaption = -1;
553 static int hf_gsm_a_dtap_ms_positioning_technology = -1;
554 static int hf_gsm_a_dtap_number_of_data_bits = -1;
555 static int hf_gsm_a_dtap_follow_on_request = -1;
556 static int hf_gsm_a_dtap_repeat_indicator = -1;
557 static int hf_gsm_a_dtap_dst_adjustment = -1;
558 static int hf_gsm_a_dtap_pcp = -1;
559 static int hf_gsm_a_dtap_user_information_layer_2_protocol = -1;
560 static int hf_gsm_a_dtap_structure = -1;
561 static int hf_gsm_a_dtap_congestion_level = -1;
562 static int hf_gsm_a_dtap_access_identity = -1;
563 static int hf_gsm_a_dtap_modem_type = -1;
564 static int hf_gsm_a_dtap_test_loop = -1;
565 static int hf_gsm_a_dtap_layer_1_identity = -1;
566 static int hf_gsm_a_dtap_ciphering_key_sequence_number70 = -1;
567 static int hf_gsm_a_dtap_tp_pdu_description = -1;
568 static int hf_gsm_a_dtap_dtmf = -1;
569 static int hf_gsm_a_dtap_coding = -1;
570 static int hf_gsm_a_dtap_nic_on_rx = -1;
571 static int hf_gsm_a_dtap_emergency_number_information = -1;
572 static int hf_gsm_a_dtap_uimi = -1;
573 static int hf_gsm_a_dtap_number_of_stop_bits = -1;
574 static int hf_gsm_a_dtap_acceptable_channel_codings_spare78 = -1;
575 static int hf_gsm_a_dtap_type_of_identity = -1;
576 static int hf_gsm_a_dtap_ciphering_key_sequence_number = -1;
577 static int hf_gsm_a_dtap_recommendation = -1;
578 static int hf_gsm_a_dtap_max_num_of_speech_bearers = -1;
579 static int hf_gsm_a_dtap_keypad_information = -1;
580 static int hf_gsm_a_dtap_signalling_access_protocol = -1;
581 static int hf_gsm_a_dtap_user_information_layer_1_protocol = -1;
582 static int hf_gsm_a_dtap_wanted_air_interface_user_rate = -1;
583 static int hf_gsm_a_dtap_hold_auxiliary_state = -1;
584 static int hf_gsm_a_dtap_radio_channel_requirement = -1;
585 static int hf_gsm_a_dtap_channel_coding_asymmetry_indication = -1;
586 static int hf_gsm_a_dtap_service_type = -1;
587 static int hf_gsm_a_dtap_text_string = -1;
588 static int hf_gsm_a_dtap_tp_tested_device = -1;
589 static int hf_gsm_a_dtap_fixed_network_user_rate = -1;
590 static int hf_gsm_a_dtap_coding_scheme = -1;
591 static int hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F28_8 = -1;
592 static int hf_gsm_a_dtap_v110_x30_rate_adaptation = -1;
593 static int hf_gsm_a_dtap_transfer_mode = -1;
594 static int hf_gsm_a_dtap_layer_2_identity = -1;
595 static int hf_gsm_a_dtap_add_ci = -1;
596 static int hf_gsm_a_dtap_mm_timer = -1;
597 static int hf_gsm_a_dtap_in_out_band = -1;
598 static int hf_gsm_a_dtap_data = -1;
599 static int hf_gsm_a_dtap_acceptable_channel_codings_TCH_F14_4 = -1;
600 static int hf_gsm_a_dtap_ti_flag = -1;
601 static int hf_gsm_a_dtap_time_zone_time = -1;
602 static int hf_gsm_a_dtap_acceptable_channel_codings_spare20 = -1;
603 static int hf_gsm_a_dtap_establishment = -1;
604 static int hf_gsm_a_dtap_duplex_mode = -1;
605
606 /* Initialize the subtree pointers */
607 static gint ett_dtap_msg = -1;
608 static gint ett_dtap_oct_1 = -1;
609 static gint ett_cm_srvc_type = -1;
610 static gint ett_gsm_enc_info = -1;
611 static gint ett_bc_oct_3 = -1;
612 static gint ett_bc_oct_3a = -1;
613 static gint ett_bc_oct_4 = -1;
614 static gint ett_bc_oct_5 = -1;
615 static gint ett_bc_oct_5a = -1;
616 static gint ett_bc_oct_5b = -1;
617 static gint ett_bc_oct_6 = -1;
618 static gint ett_bc_oct_6a = -1;
619 static gint ett_bc_oct_6b = -1;
620 static gint ett_bc_oct_6c = -1;
621 static gint ett_bc_oct_6d = -1;
622 static gint ett_bc_oct_6e = -1;
623 static gint ett_bc_oct_6f = -1;
624 static gint ett_bc_oct_6g = -1;
625 static gint ett_bc_oct_7 = -1;
626 static gint ett_epc_ue_tl_a_lb_setup = -1;
627 static gint ett_mm_timer = -1;
628
629 static expert_field ei_gsm_a_dtap_keypad_info_not_dtmf_digit = EI_INIT;
630 static expert_field ei_gsm_a_dtap_text_string_not_multiple_of_7 = EI_INIT;
631 static expert_field ei_gsm_a_dtap_autn = EI_INIT;
632 static expert_field ei_gsm_a_dtap_invalid_ia5_character = EI_INIT;
633 static expert_field ei_gsm_a_dtap_auts = EI_INIT;
634 static expert_field ei_gsm_a_dtap_end_mark_unexpected = EI_INIT;
635 static expert_field ei_gsm_a_dtap_extraneous_data = EI_INIT;
636 static expert_field ei_gsm_a_dtap_missing_mandatory_element = EI_INIT;
637
638 static char a_bigbuf[1024];
639
640 static dissector_handle_t data_handle;
641 static dissector_handle_t gsm_map_handle;
642 static dissector_handle_t rp_handle;
643
644 static proto_tree *g_tree;
645
646 /*
647  * this should be set on a per message basis, if possible
648  */
649 static gint is_uplink;
650 static guint8 epc_test_loop_mode;
651
652 #define NUM_GSM_DTAP_ELEM (sizeof(gsm_dtap_elem_strings)/sizeof(value_string))
653 gint ett_gsm_dtap_elem[NUM_GSM_DTAP_ELEM];
654
655 static dgt_set_t Dgt_mbcd = {
656     {
657     /* 0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f */
658       '0','1','2','3','4','5','6','7','8','9','*','#','a','b','c','?'
659     }
660 };
661
662 /*
663  * [9] 10.5.3.1 Authentication parameter RAND
664  */
665 static guint16
666 de_auth_param_rand(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
667 {
668     /* The RAND value is 16 octets long */
669     proto_tree_add_item(tree, hf_gsm_a_dtap_rand, tvb, offset, 16, ENC_NA);
670
671     /* no length check possible */
672     return (16);
673 }
674
675 /*
676  * [9] 10.5.3.1.1 Authentication Parameter AUTN (UMTS and EPS authentication challenge)
677  */
678 static guint16
679 de_auth_param_autn(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
680 {
681     proto_item *item;
682     proto_tree *subtree;
683
684     item = proto_tree_add_item(tree, hf_gsm_a_dtap_autn, tvb, offset, len, ENC_NA);
685     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_AUTH_PARAM_AUTN]);
686
687     if (len == 16)
688     {
689         proto_tree_add_item(subtree, hf_gsm_a_dtap_autn_sqn_xor_ak, tvb, offset, 6, ENC_NA);
690         proto_tree_add_item(subtree, hf_gsm_a_dtap_autn_amf, tvb, offset + 6, 2, ENC_NA);
691         proto_tree_add_item(subtree, hf_gsm_a_dtap_autn_mac, tvb, offset + 8, 8, ENC_NA);
692     }
693     else
694         expert_add_info(pinfo, item, &ei_gsm_a_dtap_autn);
695
696     return (len);
697 }
698
699 /*
700  * [9] 10.5.3.2 Authentication Response parameter
701  */
702 static guint16
703 de_auth_resp_param(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
704 {
705     /* This IE contains either the SRES or the 4 most significant octets of the RES */
706     proto_tree_add_item(tree, hf_gsm_a_dtap_sres, tvb, offset, 4, ENC_NA);
707
708     /* no length check possible */
709     return (4);
710 }
711
712 /*
713  * [9] 10.5.3.2.1 Authentication Response Parameter (extension) (UMTS authentication challenge only)
714  */
715 static guint16
716 de_auth_resp_param_ext(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
717 {
718     /* This IE contains all but 4 most significant octets of RES */
719     proto_tree_add_item(tree, hf_gsm_a_dtap_xres, tvb, offset, len, ENC_NA);
720
721     return (len);
722 }
723
724 /*
725  * [9] 10.5.3.2.2 Authentication Failure parameter (UMTS and EPS authentication challenge)
726  */
727 static guint16
728 de_auth_fail_param(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
729 {
730     proto_item *item;
731     proto_tree *subtree;
732
733     item = proto_tree_add_item(tree, hf_gsm_a_dtap_auts, tvb, offset, len, ENC_NA);
734     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_AUTH_FAIL_PARAM]);
735
736     if (len == 14)
737     {
738         proto_tree_add_item(subtree, hf_gsm_a_dtap_auts_sqn_ms_xor_ak, tvb, offset, 6, ENC_NA);
739         proto_tree_add_item(subtree, hf_gsm_a_dtap_auts_mac_s, tvb, offset + 6, 8, ENC_NA);
740     }
741     else
742         expert_add_info(pinfo, item, &ei_gsm_a_dtap_auts);
743
744     return (len);
745 }
746
747 /*
748  * 10.5.3.3 CM service type
749  *  handled inline
750  */
751 /*
752  * 10.5.3.4 Identity type
753  *  handled inline
754  */
755 /*
756  * 10.5.3.5 Location updating type
757  *  handled inline
758  */
759 /*
760  * [3] 10.5.3.5a Network Name
761  */
762 static const value_string gsm_a_dtap_number_of_spare_bits_vals[] = {
763     { 0, "this field carries no information about the number of spare bits in octet n"},
764     { 1, "bit 8 is spare and set to '0' in octet n"},
765     { 2, "bits 7 and 8 are spare and set to '0' in octet n"},
766     { 3, "bits 6 to 8(inclusive) are spare and set to '0' in octet n"},
767     { 4, "bits 5 to 8(inclusive) are spare and set to '0' in octet n"},
768     { 5, "bits 4 to 8(inclusive) are spare and set to '0' in octet n"},
769     { 6, "bits 3 to 8(inclusive) are spare and set to '0' in octet n"},
770     { 7, "bits 2 to 8(inclusive) are spare and set to '0' in octet n"},
771     { 0, NULL }
772 };
773
774 const true_false_string tfs_add_ci = { "The MS should add the letters for the Country's Initials and a separator (e.g. a space) to the text string",
775                                        "The MS should not add the letters for the Country's Initials to the text string" };
776
777 static guint16
778 de_network_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
779 {
780     guint8       oct;
781     guint32      curr_offset;
782     const gchar *str;
783     guint8       coding_scheme, num_spare_bits;
784     guint32      num_text_bits;
785     gchar       *net_name     = NULL;
786     proto_item  *item;
787
788     curr_offset = offset;
789
790     oct = tvb_get_guint8(tvb, curr_offset);
791
792     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
793
794     coding_scheme = (oct & 0x70) >> 4;
795     switch (coding_scheme)
796     {
797     case 0x00: str = "Cell Broadcast data coding scheme, GSM default alphabet, language unspecified, defined in 3GPP TS 23.038"; break;
798     case 0x01: str = "UCS2 (16 bit)"; break;
799     default:
800         str = "Reserved";
801     break;
802     }
803
804     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_coding_scheme, tvb, curr_offset, 1, oct, "%s", str);
805     proto_tree_add_item(tree, hf_gsm_a_dtap_add_ci, tvb, curr_offset, 1, ENC_NA);
806
807     num_spare_bits = oct & 0x07;
808     item = proto_tree_add_item(tree, hf_gsm_a_dtap_number_of_spare_bits, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
809     curr_offset++;
810
811     NO_MORE_DATA_CHECK(len);
812     switch (coding_scheme)
813     {
814     case 0:
815         /* Check if there was a reasonable value for number of spare bits in last octet */
816         num_text_bits = ((len - 1) << 3) - num_spare_bits;
817         if (num_spare_bits && (num_text_bits % 7))
818         {
819             expert_add_info(pinfo, item, &ei_gsm_a_dtap_text_string_not_multiple_of_7);
820         }
821         proto_tree_add_ts_23_038_7bits_item(tree, hf_gsm_a_dtap_text_string, tvb, curr_offset<<3, num_text_bits/7);
822         break;
823     case 1:
824         net_name = tvb_get_string_enc(wmem_packet_scope(), tvb, curr_offset, (len - 1), ENC_UCS_2|ENC_BIG_ENDIAN);
825         proto_tree_add_string(tree, hf_gsm_a_dtap_text_string, tvb, curr_offset, len - 1, net_name);
826         break;
827     default:
828         proto_tree_add_text(tree,
829             tvb, curr_offset, len - 1,
830             "Text string encoded according to an unknown Coding Scheme");
831     }
832
833     return (len);
834 }
835
836 /* 3GPP TS 24.008
837  * [9] 10.5.3.6 Reject cause
838  */
839 static const range_string gsm_a_dtap_rej_cause_vals[] = {
840     { 0x02, 0x02, "IMSI unknown in HLR"},
841     { 0x03, 0x03, "Illegal MS"},
842     { 0x04, 0x04, "IMSI unknown in VLR"},
843     { 0x05, 0x05, "IMEI not accepted"},
844     { 0x06, 0x06, "Illegal ME"},
845     { 0x0b, 0x0b, "PLMN not allowed"},
846     { 0x0c, 0x0c, "Location Area not allowed"},
847     { 0x0d, 0x0d, "Roaming not allowed in this location area"},
848     { 0x0f, 0x0f, "No Suitable Cells In Location Area"},
849     { 0x11, 0x11, "Network failure"},
850     { 0x14, 0x14, "MAC failure"},
851     { 0x15, 0x15, "Synch failure"},
852     { 0x16, 0x16, "Congestion"},
853     { 0x17, 0x17, "GSM authentication unacceptable"},
854     { 0x19, 0x19, "Not authorized for this CSG"},
855     { 0x20, 0x20, "Service option not supported"},
856     { 0x21, 0x21, "Requested service option not subscribed"},
857     { 0x22, 0x22, "Service option temporarily out of order"},
858     { 0x26, 0x26, "Call cannot be identified"},
859     { 0x30, 0x3f, "Retry upon entry into a new cell"},
860     { 0x5f, 0x5f, "Semantically incorrect message"},
861     { 0x60, 0x60, "Invalid mandatory information"},
862     { 0x61, 0x61, "Message type non-existent or not implemented"},
863     { 0x62, 0x62, "Message type not compatible with the protocol state"},
864     { 0x63, 0x63, "Information element non-existent or not implemented"},
865     { 0x64, 0x64, "Conditional IE error"},
866     { 0x65, 0x65, "Message not compatible with the protocol state"},
867     { 0x6f, 0x6f, "Protocol error, unspecified"},
868     { 0, 0, NULL }
869 };
870
871 guint16
872 de_rej_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
873 {
874     guint8       oct;
875     const gchar *str;
876
877     oct = tvb_get_guint8(tvb, offset);
878
879     str = try_rval_to_str(oct, gsm_a_dtap_rej_cause_vals);
880     if (!str)
881     {
882         if (is_uplink == IS_UPLINK_TRUE)
883             str = "Protocol error, unspecified";
884         else
885             str = "Service option temporarily out of order";
886     }
887
888     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_rej_cause, tvb,
889                 offset, 1, oct, "%s (%u)", str, oct);
890
891     /* no length check possible */
892
893     return (1);
894 }
895
896 /*
897  * 10.5.3.7 Follow-on Proceed
898  *  No data
899  */
900 /*
901  * [3] 10.5.3.8 Time Zone
902  */
903 guint16
904 de_time_zone(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
905 {
906     guint8  oct;
907     guint32 curr_offset;
908     char    sign;
909
910     curr_offset = offset;
911
912     /* 3GPP TS 23.040 version 6.6.0 Release 6
913      * 9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
914      * :
915      * The Time Zone indicates the difference, expressed in quarters of an hour,
916      * between the local time and GMT. In the first of the two semi-octets,
917      * the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field)
918      * represents the algebraic sign of this difference (0: positive, 1: negative).
919      */
920
921     oct = tvb_get_guint8(tvb, curr_offset);
922     sign = (oct & 0x08)?'-':'+';
923     oct = (oct >> 4) + (oct & 0x07) * 10;
924
925     proto_tree_add_text(tree,
926         tvb, curr_offset, 1,
927         "Timezone: GMT %c %d hours %d minutes",
928         sign, oct / 4, oct % 4 * 15);
929     curr_offset++;
930
931     /* no length check possible */
932
933     return (curr_offset - offset);
934 }
935
936 /*
937  * [3] 10.5.3.9 Time Zone and Time
938  */
939 static guint16
940 de_time_zone_time(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
941 {
942     guint8  oct;
943     guint32 curr_offset;
944     char    sign;
945     nstime_t tv;
946     struct tm tm;
947
948     curr_offset = offset;
949
950     /* "unused" part of structure */
951     tm.tm_wday = 0;
952     tm.tm_yday = 0;
953     tm.tm_isdst = -1;
954
955     oct = tvb_get_guint8(tvb, curr_offset);
956     tm.tm_year = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4) + 100;
957     oct = tvb_get_guint8(tvb, curr_offset+1);
958     tm.tm_mon = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4) - 1;
959     oct = tvb_get_guint8(tvb, curr_offset+2);
960     tm.tm_mday = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4);
961     oct = tvb_get_guint8(tvb, curr_offset+3);
962     tm.tm_hour = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4);
963     oct = tvb_get_guint8(tvb, curr_offset+4);
964     tm.tm_min = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4);
965     oct = tvb_get_guint8(tvb, curr_offset+5);
966     tm.tm_sec = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4);
967
968     tv.secs = mktime(&tm);
969     tv.nsecs = 0;
970
971     proto_tree_add_time_format_value(tree, hf_gsm_a_dtap_time_zone_time, tvb, curr_offset, 6,
972                                      &tv, "%s", abs_time_to_str(wmem_packet_scope(), &tv, ABSOLUTE_TIME_LOCAL, FALSE));
973     curr_offset += 6;
974
975     /* 3GPP TS 23.040 version 6.6.0 Release 6
976      * 9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
977      * :
978      * The Time Zone indicates the difference, expressed in quarters of an hour,
979      * between the local time and GMT. In the first of the two semi-octets,
980      * the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field)
981      * represents the algebraic sign of this difference (0: positive, 1: negative).
982      */
983
984     oct = tvb_get_guint8(tvb, curr_offset);
985     sign = (oct & 0x08)?'-':'+';
986     oct = (oct >> 4) + (oct & 0x07) * 10;
987
988     proto_tree_add_text(tree,
989         tvb, curr_offset, 1,
990         "Timezone: GMT %c %d hours %d minutes",
991         sign, oct / 4, oct % 4 * 15);
992
993     curr_offset++;
994
995     /* no length check possible */
996
997     return (curr_offset - offset);
998 }
999 /*
1000  * 10.5.3.10 CTS permission
1001  * No data
1002  */
1003 /*
1004  * [3] 10.5.3.11 LSA Identifier
1005  * 3GPP TS 24.008 version 6.8.0 Release 6
1006  */
1007 static guint16
1008 de_lsa_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1009 {
1010     guint32 curr_offset;
1011
1012     curr_offset = offset;
1013
1014     if (len == 0) {
1015         proto_tree_add_text(tree,tvb, curr_offset, len,"LSA ID not included");
1016     }
1017     else
1018     {
1019         proto_tree_add_item(tree, hf_gsm_a_dtap_lsa_id, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
1020     }
1021
1022     curr_offset += len;
1023
1024     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
1025
1026     return (curr_offset - offset);
1027 }
1028
1029 /*
1030  * [3] 10.5.3.12 Daylight Saving Time
1031  */
1032 static const value_string gsm_a_dtap_dst_adjustment_vals[] = {
1033     { 0, "No adjustment for Daylight Saving Time"},
1034     { 1, "+1 hour adjustment for Daylight Saving Time"},
1035     { 2, "+2 hours adjustment for Daylight Saving Time"},
1036     { 3, "Reserved"},
1037     { 0, NULL }
1038 };
1039
1040 static guint16
1041 de_day_saving_time(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1042 {
1043     guint32      curr_offset;
1044
1045     curr_offset = offset;
1046
1047     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 6, ENC_BIG_ENDIAN);
1048
1049     proto_tree_add_item(tree, hf_gsm_a_dtap_dst_adjustment, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1050     curr_offset++;
1051
1052     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
1053
1054     return (curr_offset - offset);
1055 }
1056
1057 /*
1058  * 10.5.3.13 Emergency Number List
1059  */
1060 static guint16
1061 de_emerg_num_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1062 {
1063     guint32     curr_offset;
1064     guint8      en_len;
1065     guint8      count;
1066     proto_tree *subtree;
1067     proto_item *item;
1068     const char *digit_str;
1069
1070     curr_offset = offset;
1071
1072     count = 1;
1073     while ((curr_offset - offset) < len) {
1074         /* Length of 1st Emergency Number information note 1) octet 3
1075          * NOTE 1: The length contains the number of octets used to encode the
1076          * Emergency Service Category Value and the Number digits.
1077          */
1078         en_len = tvb_get_guint8(tvb, curr_offset);
1079
1080         item = proto_tree_add_uint(tree, hf_gsm_a_dtap_emergency_number_information,
1081             tvb, curr_offset, en_len + 1, count);
1082         subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_EMERGENCY_NUM_LIST]);
1083         proto_tree_add_item(subtree, hf_gsm_a_dtap_emerg_num_info_length, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1084
1085         curr_offset++;
1086         /* 0 0 0 Emergency Service Category Value (see
1087          *       Table 10.5.135d/3GPP TS 24.008
1088          * Table 10.5.135d/3GPP TS 24.008: Service Category information element
1089          */
1090         proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 3, ENC_BIG_ENDIAN);
1091         proto_tree_add_item(subtree, hf_gsm_a_dtap_serv_cat_b5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1092         proto_tree_add_item(subtree, hf_gsm_a_dtap_serv_cat_b4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1093         proto_tree_add_item(subtree, hf_gsm_a_dtap_serv_cat_b3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1094         proto_tree_add_item(subtree, hf_gsm_a_dtap_serv_cat_b2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1095         proto_tree_add_item(subtree, hf_gsm_a_dtap_serv_cat_b1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1096         curr_offset++;
1097         en_len--;
1098
1099         digit_str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, en_len, NULL, FALSE);
1100         item = proto_tree_add_string(subtree, hf_gsm_a_dtap_emergency_bcd_num, tvb, curr_offset, en_len, digit_str);
1101
1102         /* Check for overdicadic digits, we used the standard digit map from tvbuff.c
1103          *  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e  f
1104          * '0','1','2','3','4','5','6','7','8','9','?','?','?','?','?','?'
1105          *
1106          */
1107         if(strchr(digit_str,'?')){
1108             expert_add_info(pinfo, item, &ei_gsm_a_dtap_end_mark_unexpected);
1109         }
1110
1111         curr_offset = curr_offset + en_len;
1112         count++;
1113     }
1114
1115     return (len);
1116 }
1117
1118 /*
1119  * 10.5.3.14 Additional update parameters
1120  */
1121 static const true_false_string gsm_a_dtap_csmo_value = {
1122     "CS fallback mobile originating call",
1123     "No additional information"
1124 };
1125
1126 static const true_false_string gsm_a_dtap_csmt_value = {
1127     "CS fallback mobile terminating call",
1128     "No additional information"
1129 };
1130
1131 static guint16
1132 de_add_upd_params(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1133 {
1134     guint32 curr_offset;
1135
1136     curr_offset = offset;
1137
1138     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+4, 2, ENC_BIG_ENDIAN);
1139     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_csmo, tvb, (curr_offset<<3)+6, 1, ENC_BIG_ENDIAN);
1140     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_csmt, tvb, (curr_offset<<3)+7, 1, ENC_BIG_ENDIAN);
1141
1142     return (len);
1143 }
1144
1145 /*
1146  * 10.5.3.15 MM Timer
1147  */
1148 static const value_string gsm_a_dtap_mm_timer_unit_vals[] = {
1149     { 0x00, "value is incremented in multiples of 2 seconds" },
1150     { 0x01, "value is incremented in multiples of 1 minute" },
1151     { 0x02, "value is incremented in multiples of decihours" },
1152     { 0x07, "value indicates that the timer is deactivated" },
1153     { 0, NULL }
1154 };
1155
1156 static guint16
1157 de_mm_timer(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1158 {
1159     guint8       oct;
1160     guint16      val;
1161     const gchar *str;
1162     proto_tree  *subtree;
1163     proto_item  *item = NULL;
1164
1165     oct = tvb_get_guint8(tvb, offset);
1166     val = oct&0x1f;
1167
1168     switch (oct>>5)
1169     {
1170     case 0:
1171         str = "sec"; val*=2;
1172         break;
1173     case 1:
1174         str = "min";
1175         break;
1176     case 2:
1177         str = "min"; val*=6;
1178         break;
1179     case 7:
1180         str = "";
1181         item = proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_mm_timer, tvb, offset, 1,
1182                             oct, "timer is deactivated");
1183         break;
1184     default:
1185         str = "min";
1186         break;
1187     }
1188
1189     if (item == NULL) {
1190         item = proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_mm_timer, tvb, offset, 1, val,
1191                                    "%u %s", val, str);
1192     }
1193
1194     subtree = proto_item_add_subtree(item, ett_mm_timer);
1195     proto_tree_add_item(subtree, hf_gsm_a_dtap_mm_timer_unit, tvb, offset, 1, ENC_BIG_ENDIAN);
1196     proto_tree_add_item(subtree, hf_gsm_a_dtap_mm_timer_value, tvb, offset, 1, ENC_BIG_ENDIAN);
1197
1198     return (1);
1199 }
1200
1201  /*
1202  * [3] 10.5.4.4 Auxiliary states
1203  */
1204
1205 static const value_string gsm_a_dtap_hold_auxilary_state_vals[] = {
1206     { 0x00, "Idle" },
1207     { 0x01, "Hold request" },
1208     { 0x02, "Call held" },
1209     { 0x03, "Retrieve request" },
1210     { 0, NULL }
1211 };
1212
1213 static const value_string gsm_a_dtap_multi_party_auxilary_state_vals[] = {
1214     { 0x00, "Idle" },
1215     { 0x01, "MPTY request" },
1216     { 0x02, "Call in MPTY" },
1217     { 0x03, "Split request" },
1218     { 0, NULL }
1219 };
1220
1221 static guint16
1222 de_aux_states(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1223 {
1224     guint32      curr_offset;
1225
1226     curr_offset = offset;
1227
1228     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1229
1230     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+1, 3, ENC_BIG_ENDIAN);
1231     proto_tree_add_item(tree, hf_gsm_a_dtap_hold_auxiliary_state, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1232     proto_tree_add_item(tree, hf_gsm_a_dtap_multi_party_auxiliary_state, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1233     curr_offset++;
1234
1235     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
1236
1237     return (curr_offset - offset);
1238 }
1239 /*
1240  * 10.5.4.4a Backup bearer capability
1241  */
1242 /*
1243  * [3] 10.5.4.5 Bearer capability (3GPP TS 24.008 version 8.4.0 Release 8)
1244  */
1245 /* Speech version indication (octet(s) 3a etc.) Bits 4 3 2 1 */
1246
1247 static const value_string gsm_a_dtap_speech_vers_ind_values[] = {
1248     { 0x0,  "GSM full rate speech version 1(GSM FR)" },
1249     { 0x1,  "GSM half rate speech version 1(GSM HR)" },
1250     { 0x2,  "GSM full rate speech version 2(GSM EFR)" },
1251     { 0x3,  "Speech version tbd" },
1252     { 0x4,  "GSM full rate speech version 3(FR AMR)" },
1253     { 0x5,  "GSM half rate speech version 3(HR AMR)" },
1254     { 0x6,  "GSM full rate speech version 4(OFR AMR-WB)" },
1255     { 0x7,  "GSM half rate speech version 4(OHR AMR-WB)" },
1256     { 0x8,  "GSM full rate speech version 5(FR AMR-WB)" },
1257     { 0x9,  "Speech version tbd" },
1258     { 0xa,  "Speech version tbd" },
1259     { 0xb,  "GSM half rate speech version 6(OHR AMR)" },
1260     { 0xc,  "Speech version tbd" },
1261     { 0xd,  "Speech version tbd" },
1262     { 0xe,  "Speech version tbd" },
1263     { 0xf,  "No speech version supported for GERAN" },
1264     { 0, NULL }
1265 };
1266 /* All other values have the meaning "speech version tbd" and shall be ignored
1267  * when received.
1268  */
1269 /*
1270  * Information transfer capability (octet 3) Bits 3 2 1
1271  */
1272 static const value_string gsm_a_dtap_itc_values[] = {
1273     { 0x0,  "Speech" },
1274     { 0x1,  "Unrestricted digital information" },
1275     { 0x2,  "3.1 kHz audio, ex PLMN" },
1276     { 0x3,  "Facsimile group 3" },
1277     { 0x5,  "Other ITC (See Octet 5a)" },
1278     { 0x7,  "Reserved,(In Network alternate speech/facsimile group 3)" },
1279     { 0, NULL }
1280 };
1281
1282 static const value_string gsm_a_dtap_structure_vals[] = {
1283     { 0x0,  "Service data unit integrity" },
1284     { 0x1,  "Reserved" },
1285     { 0x2,  "Reserved" },
1286     { 0x3,  "Unstructured" },
1287     { 0, NULL }
1288 };
1289
1290 static const value_string gsm_a_dtap_access_identity_vals[] = {
1291     { 0x0,  "Octet identifier" },
1292     { 0x1,  "Octet identifier" },
1293     { 0x2,  "Octet identifier" },
1294     { 0x3,  "Reserved" },
1295     { 0, NULL }
1296 };
1297
1298 static const value_string gsm_a_dtap_rate_adaption_vals[] = {
1299     { 0x0,  "No rate adaption" },
1300     { 0x1,  "Rate adaptation according to ITU-T Rec. V.110 and ITU-T Rec. X.30" },
1301     { 0x2,  "Flag stuffing according to ITU-T Rec. X.31" },
1302     { 0x3,  "Other rate adaption (see octet 5a)" },
1303     { 0, NULL }
1304 };
1305
1306 static const value_string gsm_a_dtap_signal_access_protocol_vals[] = {
1307     { 0x0,  "Reserved" },
1308     { 0x1,  "Rate adaptation according to ITU-T Rec. V.110 and ITU-T Rec. X.30" },
1309     { 0x2,  "Flag stuffing according to ITU-T Rec. X.31" },
1310     { 0x3,  "Other rate adaption (see octet 5a)" },
1311     { 0x4,  "No rate adaption" },
1312     { 0x5,  "Rate adaptation according to ITU-T Rec. V.110 and ITU-T Rec. X.30" },
1313     { 0x6,  "Flag stuffing according to ITU-T Rec. X.31" },
1314     { 0x7,  "Reserved" },
1315     { 0, NULL }
1316 };
1317
1318 static const value_string gsm_a_dtap_other_itc_vals[] = {
1319     { 0x0,  "Restricted digital information" },
1320     { 0x1,  "Restricted digital information" },
1321     { 0x2,  "Restricted digital information" },
1322     { 0x3,  "Reserved" },
1323     { 0, NULL }
1324 };
1325
1326 static const value_string gsm_a_dtap_other_rate_adaption_vals[] = {
1327     { 0x0,  "According to ITU-T Rec. V.120" },
1328     { 0x1,  "According to ITU-T Rec. H.223 and ITU-T Rec. H.245" },
1329     { 0x2,  "PIAFS" },
1330     { 0x3,  "Reserved" },
1331     { 0, NULL }
1332 };
1333
1334 static const value_string gsm_a_dtap_user_rate_vals[] = {
1335     { 0x1,  "0.3 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)" },
1336     { 0x2,  "1.2 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)" },
1337     { 0x3,  "2.4 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)" },
1338     { 0x4,  "4.8 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)" },
1339     { 0x5,  "9.6 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)" },
1340     { 0x6,  "12.0 kbit/s transparent (non compliance with ITU-T Rec. X.1 and ITU-T Rec. V.110)" },
1341     { 0x7,  "Reserved: was allocated in earlier phases of the protocol" },
1342     { 0, NULL }
1343 };
1344
1345 static const value_string gsm_a_dtap_v110_x30_rate_adaptation_vals[] = {
1346     { 0x0,  "Reserved" },
1347     { 0x1,  "Reserved" },
1348     { 0x2,  "8 kbit/s" },
1349     { 0x3,  "16 kbit/s" },
1350     { 0, NULL }
1351 };
1352
1353 static const value_string gsm_a_dtap_parity_info_vals[] = {
1354     { 0x0,  "Odd" },
1355     { 0x1,  "Reserved" },
1356     { 0x2,  "Even" },
1357     { 0x3,  "None" },
1358     { 0x4,  "Forced to 0" },
1359     { 0x5,  "Forced to 1" },
1360     { 0x6,  "Reserved" },
1361     { 0x7,  "Reserved" },
1362     { 0, NULL }
1363 };
1364
1365 static const value_string gsm_a_dtap_connection_element_vals[] = {
1366     { 0x0,  "Transparent" },
1367     { 0x1,  "Non transparent (RLP)" },
1368     { 0x2,  "Both, transparent preferred" },
1369     { 0x3,  "Both, non transparent preferred" },
1370     { 0, NULL }
1371 };
1372
1373 static const value_string gsm_a_dtap_modem_type_vals[] = {
1374     { 0x0,  "None" },
1375     { 0x1,  "According to ITU-T Rec. V.21" },
1376     { 0x2,  "According to ITU-T Rec. V.22" },
1377     { 0x3,  "According to ITU-T Rec. V.22 bis" },
1378     { 0x4,  "Reserved: was allocated in earlier phases of the protocol" },
1379     { 0x5,  "According to ITU-T Rec. V.26 ter" },
1380     { 0x6,  "According to ITU-T Rec. V.32" },
1381     { 0x7,  "Modem for undefined interface" },
1382     { 0x8,  "Autobauding type 1" },
1383     { 0, NULL }
1384 };
1385
1386 static const value_string gsm_a_dtap_other_modem_type_vals[] = {
1387     { 0x0,  "No other modem type specified in this field" },
1388     { 0x1,  "Reserved" },
1389     { 0x2,  "According to ITU-T Rec. V.34" },
1390     { 0x3,  "Reserved" },
1391     { 0, NULL }
1392 };
1393
1394 static const value_string gsm_a_dtap_fixed_network_user_rate_vals[] = {
1395     { 0x00, "Fixed network user rate not applicable/No meaning is associated with this value"},
1396     { 0x01, "9.6 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)"},
1397     { 0x02, "14.4 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)"},
1398     { 0x03, "19.2 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)"},
1399     { 0x04, "28.8 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)"},
1400     { 0x05, "38.4 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110)"},
1401     { 0x06, "48.0 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110 (synch))"},
1402     { 0x07, "56.0 kbit/s (according to ITU-T Rec. X.1 and ITU-T Rec. V.110 (synch) /bit transparent)"},
1403     { 0x08, "64.0 kbit/s bit transparent"},
1404     { 0x09, "33.6 kbit/s bit transparent"},
1405     { 0x0a, "32.0 kbit/s (according to ITU-T Rec. I.460)"},
1406     { 0x0b, "31.2 kbit/s (according to ITU-T Rec. V.34)"},
1407     { 0, NULL }
1408 };
1409
1410 static const value_string gsm_a_dtap_uimi_vals[] = {
1411     { 0x0,  "not allowed/required/applicable" },
1412     { 0x1,  "up to 1 TCH/F allowed/may be requested" },
1413     { 0x2,  "up to 2 TCH/F allowed/may be requested" },
1414     { 0x3,  "up to 3 TCH/F allowed/may be requested" },
1415     { 0x4,  "up to 4 TCH/F allowed/may be requested" },
1416     { 0x5,  "up to 4 TCH/F may be requested" },
1417     { 0x6,  "up to 4 TCH/F may be requested" },
1418     { 0x7,  "up to 4 TCH/F may be requested" },
1419     { 0, NULL }
1420 };
1421
1422 static const value_string gsm_a_dtap_wanted_air_rate_vals[] = {
1423     { 0x0,  "Air interface user rate not applicable/No meaning associated with this value" },
1424     { 0x1,  "9.6 kbit/s" },
1425     { 0x2,  "14.4 kbit/s" },
1426     { 0x3,  "19.2 kbit/s" },
1427     { 0x4,  "Reserved" },
1428     { 0x5,  "28.8 kbit/s" },
1429     { 0x6,  "38.4 kbit/s" },
1430     { 0x7,  "43.2 kbit/s" },
1431     { 0x8,  "57.6 kbit/s" },
1432     { 0x9,  "interpreted by the network as 38.4 kbit/s in this version of the protocol" },
1433     { 0xa,  "interpreted by the network as 38.4 kbit/s in this version of the protocol" },
1434     { 0xb,  "interpreted by the network as 38.4 kbit/s in this version of the protocol" },
1435     { 0xc,  "interpreted by the network as 38.4 kbit/s in this version of the protocol" },
1436     { 0xd,  "Reserved" },
1437     { 0xe,  "Reserved" },
1438     { 0xf,  "Reserved" },
1439     { 0, NULL }
1440 };
1441
1442 static const value_string gsm_a_dtap_channel_coding_asymmetry_ind_vals[] = {
1443     { 0x0,  "Channel coding symmetry preferred" },
1444     { 0x1,  "Uplink biased channel coding asymmetry is preferred" },
1445     { 0x2,  "Downlink biased channel coding asymmetry is preferred" },
1446     { 0x3,  "Unused, treat as Channel coding symmetry preferred" },
1447     { 0, NULL }
1448 };
1449
1450 static const value_string gsm_a_dtap_user_info_layer2_vals[] = {
1451     { 0x06, "Reserved: was allocated in earlier phases of the protocol" },
1452     { 0x08, "According to ISO/IEC 6429, codeset 0 (DC1/DC3)" },
1453     { 0x09, "Reserved: was allocated but never used in earlier phases of the protocol" },
1454     { 0x0a, "Videotex profile 1" },
1455     { 0x0c, "COPnoFlCt (Character oriented Protocol with no Flow Control mechanism)" },
1456     { 0x0d, "Reserved: was allocated in earlier phases of the protocol" },
1457     { 0, NULL }
1458 };
1459
1460 static const true_false_string tfs_bearer_cap_coding_standard = { "reserved", "GSM standardized coding" };
1461 static const true_false_string tfs_bearer_cap_transfer_mode = { "packet", "circuit" };
1462 static const true_false_string tfs_bearer_cap_coding = { "octet used for other extension of octet 3", "octet used for extension of information transfer capability" };
1463 static const true_false_string tfs_bearer_cap_configuration = { "Reserved", "Point-to-point" };
1464 static const true_false_string tfs_nirr = { "Data up to and including 4.8 kb/s, full rate, non-transparent, 6 kb/s radio interface rate is requested",
1465                         "No meaning is associated with this value" };
1466 static const true_false_string tfs_bearer_cap_establishment = { "Reserved", "Demand" };
1467 static const true_false_string tfs_frame_est_supported_not_supported = { "Supported", "Not supported, only UI frames allowed" };
1468 static const true_false_string tfs_log_link_neg = { "Full protocol negotiation", "Default, LLI=256 only" };
1469 static const true_false_string tfs_assignor_assignee = { "Message originator is assignor only", "Message originator is default assignee" };
1470 static const true_false_string tfs_in_out_band = { "Negotiation is done with USER INFORMATION messages on a temporary signalling connection",
1471                            "Negotiation is done in-band using logical link zero" };
1472 static const true_false_string tfs_stop_bits = { "2", "1" };
1473 static const true_false_string tfs_negotiation = { "Reserved", "In-band negotiation not possible" };
1474 static const true_false_string tfs_parity_bits = { "8", "7" };
1475 static const true_false_string tfs_nic_on_tx = { "requires to send data with network independent clock",
1476                          "does not require to send data with network independent clock" };
1477 static const true_false_string tfs_nic_on_rx = { "can accept data with network independent clock",
1478                          "cannot accept data with network independent clock" };
1479
1480 guint16
1481 de_bearer_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len)
1482 {
1483     guint8       oct;
1484     guint8       itc;
1485     gboolean     extended;
1486     guint32      curr_offset;
1487     guint32      saved_offset;
1488     proto_tree  *subtree;
1489     proto_item  *item;
1490     const gchar *str;
1491
1492 #define DE_BC_ITC_SPEECH    0x00
1493 #define DE_BC_ITC_UDI       0x01
1494 #define DE_BC_ITC_EX_PLMN   0x02
1495 #define DE_BC_ITC_FASC_G3   0x03
1496 #define DE_BC_ITC_OTHER_ITC 0x05
1497 #define DE_BC_ITC_RSVD_NET  0x07
1498
1499     curr_offset = offset;
1500
1501     oct = tvb_get_guint8(tvb, curr_offset);
1502
1503     /* octet 3 */
1504
1505     /*
1506      * warning, bearer cap uses extended values that
1507      * are reversed from other parameters!
1508      */
1509     subtree =
1510         proto_tree_add_subtree(tree,
1511             tvb, curr_offset, 1,
1512             ett_bc_oct_3, NULL, "Octet 3");
1513
1514     extended = (oct & 0x80) ? FALSE : TRUE;
1515     itc = oct & 0x07;
1516
1517     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1518
1519     switch (is_uplink)
1520     {
1521     case IS_UPLINK_FALSE:
1522         str = "Spare";
1523         break;
1524
1525     case IS_UPLINK_TRUE:
1526         /*
1527          * depends on Information transfer capability
1528          */
1529         switch (itc)
1530         {
1531         case DE_BC_ITC_SPEECH:
1532             if (extended)
1533             {
1534                 switch ((oct & 0x60) >> 5)
1535                 {
1536                 case 1: str = "MS supports at least full rate speech version 1 but does not support half rate speech version 1"; break;
1537                 case 2: str = "MS supports at least full rate speech version 1 and half rate speech version 1. MS has a greater preference for half rate speech version 1 than for full rate speech version 1"; break;
1538                 case 3: str = "MS supports at least full rate speech version 1 and half rate speech version 1. MS has a greater preference for full rate speech version 1 than for half rate speech version 1"; break;
1539                 default:
1540                     str = "Reserved";
1541                     break;
1542                 }
1543             }
1544             else
1545             {
1546                 switch ((oct & 0x60) >> 5)
1547                 {
1548                 case 1: str = "Full rate support only MS/fullrate speech version 1 supported"; break;
1549                 case 2: str = "Dual rate support MS/half rate speech version 1 preferred, full rate speech version 1 also supported"; break;
1550                 case 3: str = "Dual rate support MS/full rate speech version 1 preferred, half rate speech version 1 also supported"; break;
1551                 default:
1552                     str = "Reserved";
1553                     break;
1554                 }
1555             }
1556             break;
1557
1558         default:
1559             switch ((oct & 0x60) >> 5)
1560             {
1561             case 1: str = "Full rate support only MS"; break;
1562             case 2: str = "Dual rate support MS/half rate preferred"; break;
1563             case 3: str = "Dual rate support MS/full rate preferred"; break;
1564             default:
1565                 str = "Reserved";
1566                 break;
1567             }
1568             break;
1569         }
1570         break;
1571
1572         default:
1573             str = "(dissect problem)";
1574             break;
1575         }
1576
1577     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_radio_channel_requirement, tvb, curr_offset, 1,
1578                                      oct, "%s", str);
1579
1580     proto_tree_add_item(subtree, hf_gsm_a_dtap_bearer_cap_coding_standard, tvb, curr_offset, 1, ENC_NA);
1581     proto_tree_add_item(subtree, hf_gsm_a_dtap_transfer_mode, tvb, curr_offset, 1, ENC_NA);
1582
1583     proto_tree_add_item(subtree, hf_gsm_a_dtap_itc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1584
1585     if (add_string)
1586         g_snprintf(add_string, string_len, " - (%s)", str);
1587
1588     curr_offset++;
1589
1590     NO_MORE_DATA_CHECK(len);
1591
1592     switch (itc)
1593     {
1594     case DE_BC_ITC_SPEECH:
1595         /* octets 3a */
1596
1597         subtree =
1598             proto_tree_add_subtree(tree,
1599                 tvb, curr_offset, -1, ett_bc_oct_3a, &item,
1600                 "Octets 3a - Speech Versions");
1601
1602         saved_offset = curr_offset;
1603
1604         do
1605         {
1606             oct = tvb_get_guint8(tvb, curr_offset);
1607
1608             extended = (oct & 0x80) ? FALSE : TRUE;
1609
1610             proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1611             proto_tree_add_item(subtree, hf_gsm_a_dtap_coding, tvb, curr_offset, 1, ENC_NA);
1612             proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+2, 2, ENC_BIG_ENDIAN);
1613             proto_tree_add_item(subtree, hf_gsm_a_dtap_speech_vers_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1614             curr_offset++;
1615         }
1616         while (extended &&
1617             ((len - (curr_offset - offset)) > 0));
1618
1619         proto_item_set_len(item, curr_offset - saved_offset);
1620         break;
1621
1622         default:
1623         /* octet 4 */
1624
1625         subtree =
1626             proto_tree_add_subtree(tree,
1627                 tvb, curr_offset, 1,
1628                 ett_bc_oct_4, NULL, "Octet 4");
1629
1630         proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1631         proto_tree_add_item(subtree, is_uplink ? hf_gsm_a_dtap_compression_up : hf_gsm_a_dtap_compression,
1632             tvb, curr_offset, 1, ENC_NA);
1633
1634         proto_tree_add_item(subtree, hf_gsm_a_dtap_structure, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1635         proto_tree_add_item(subtree, hf_gsm_a_dtap_duplex_mode, tvb, curr_offset, 1, ENC_NA);
1636         proto_tree_add_item(subtree, hf_gsm_a_dtap_configuration, tvb, curr_offset, 1, ENC_NA);
1637         proto_tree_add_item(subtree, hf_gsm_a_dtap_nirr, tvb, curr_offset, 1, ENC_NA);
1638         proto_tree_add_item(subtree, hf_gsm_a_dtap_establishment, tvb, curr_offset, 1, ENC_NA);
1639         curr_offset++;
1640
1641     NO_MORE_DATA_CHECK(len);
1642
1643     /* octet 5 */
1644
1645     subtree =
1646         proto_tree_add_subtree(tree,
1647         tvb, curr_offset, 1,
1648         ett_bc_oct_5, NULL, "Octet 5");
1649
1650     oct = tvb_get_guint8(tvb, curr_offset);
1651
1652     extended = (oct & 0x80) ? FALSE : TRUE;
1653
1654     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1655     proto_tree_add_item(subtree, hf_gsm_a_dtap_access_identity, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1656     proto_tree_add_item(subtree, hf_gsm_a_dtap_rate_adaption, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1657     proto_tree_add_item(subtree, hf_gsm_a_dtap_signalling_access_protocol, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1658     curr_offset++;
1659
1660     NO_MORE_DATA_CHECK(len);
1661
1662     if (!extended) goto bc_octet_6;
1663
1664     /* octet 5a */
1665
1666     subtree =
1667         proto_tree_add_subtree(tree,
1668         tvb, curr_offset, 1,
1669         ett_bc_oct_5a, NULL, "Octet 5a");
1670
1671     oct = tvb_get_guint8(tvb, curr_offset);
1672
1673     extended = (oct & 0x80) ? FALSE : TRUE;
1674
1675     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1676     proto_tree_add_item(subtree, hf_gsm_a_dtap_other_itc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1677     proto_tree_add_item(subtree, hf_gsm_a_dtap_other_rate_adaption, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1678     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+5, 3, ENC_BIG_ENDIAN);
1679     curr_offset++;
1680
1681     NO_MORE_DATA_CHECK(len);
1682
1683     if (!extended) goto bc_octet_6;
1684
1685     /* octet 5b */
1686
1687     subtree =
1688         proto_tree_add_subtree(tree,
1689         tvb, curr_offset, 1,
1690         ett_bc_oct_5b, NULL, "Octet 5b");
1691
1692     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1693     proto_tree_add_item(subtree, hf_gsm_a_dtap_rate_adaption_header, tvb, curr_offset, 1, ENC_NA);
1694     proto_tree_add_item(subtree, hf_gsm_a_dtap_multiple_frame_establishment_support, tvb, curr_offset, 1, ENC_NA);
1695     proto_tree_add_item(subtree, hf_gsm_a_dtap_mode_of_operation, tvb, curr_offset, 1, ENC_NA);
1696     proto_tree_add_item(subtree, hf_gsm_a_dtap_logical_link_identifier_negotiation, tvb, curr_offset, 1, ENC_NA);
1697     proto_tree_add_item(subtree, hf_gsm_a_dtap_assignor_assignee, tvb, curr_offset, 1, ENC_NA);
1698     proto_tree_add_item(subtree, hf_gsm_a_dtap_in_out_band, tvb, curr_offset, 1, ENC_NA);
1699     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+7, 1, ENC_BIG_ENDIAN);
1700
1701     curr_offset++;
1702
1703     NO_MORE_DATA_CHECK(len);
1704
1705 bc_octet_6:
1706
1707     /* octet 6 */
1708
1709     subtree =
1710         proto_tree_add_subtree(tree,
1711         tvb, curr_offset, 1,
1712         ett_bc_oct_6, NULL, "Octet 6");
1713
1714     oct = tvb_get_guint8(tvb, curr_offset);
1715
1716     extended = (oct & 0x80) ? FALSE : TRUE;
1717
1718     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1719
1720     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_layer_1_identity, tvb, curr_offset, 1, oct,
1721         "%s", ((oct & 0x60) == 0x20) ? "Octet identifier" : "Reserved");
1722
1723     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_user_information_layer_1_protocol,
1724         tvb, curr_offset, 1, oct, "%s",
1725         (oct & 0x1e) ? "Reserved" : "Default layer 1 protocol");
1726
1727     proto_tree_add_item(subtree, hf_gsm_a_dtap_synchronous, tvb, curr_offset, 1, ENC_NA);
1728     curr_offset++;
1729
1730     NO_MORE_DATA_CHECK(len);
1731
1732     if (!extended) goto bc_octet_7;
1733
1734     /* octet 6a */
1735
1736     subtree =
1737         proto_tree_add_subtree(tree,
1738         tvb, curr_offset, 1,
1739         ett_bc_oct_6a, NULL, "Octet 6a");
1740
1741     oct = tvb_get_guint8(tvb, curr_offset);
1742
1743     extended = (oct & 0x80) ? FALSE : TRUE;
1744
1745     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1746     proto_tree_add_item(subtree, hf_gsm_a_dtap_number_of_stop_bits, tvb, curr_offset, 1, ENC_NA);
1747     proto_tree_add_item(subtree, hf_gsm_a_dtap_negotiation, tvb, curr_offset, 1, ENC_NA);
1748     proto_tree_add_item(subtree, hf_gsm_a_dtap_number_of_data_bits, tvb, curr_offset, 1, ENC_NA);
1749
1750     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_user_rate,
1751         tvb, curr_offset, 1, oct, "%s", val_to_str_const(oct & 0xF, gsm_a_dtap_user_rate_vals, "Reserved"));
1752
1753     curr_offset++;
1754
1755     NO_MORE_DATA_CHECK(len);
1756
1757     if (!extended) goto bc_octet_7;
1758
1759     /* octet 6b */
1760
1761     subtree =
1762         proto_tree_add_subtree(tree,
1763         tvb, curr_offset, 1,
1764         ett_bc_oct_6b, NULL, "Octet 6b");
1765
1766     oct = tvb_get_guint8(tvb, curr_offset);
1767
1768     extended = (oct & 0x80) ? FALSE : TRUE;
1769
1770     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1771     proto_tree_add_item(subtree, hf_gsm_a_dtap_v110_x30_rate_adaptation, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1772     proto_tree_add_item(subtree, hf_gsm_a_dtap_nic_on_tx, tvb, curr_offset, 1, ENC_NA);
1773     proto_tree_add_item(subtree, hf_gsm_a_dtap_nic_on_rx, tvb, curr_offset, 1, ENC_NA);
1774     proto_tree_add_item(subtree, hf_gsm_a_dtap_parity_information, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1775     curr_offset++;
1776
1777     NO_MORE_DATA_CHECK(len);
1778
1779     if (!extended) goto bc_octet_7;
1780
1781     /* octet 6c */
1782
1783     subtree =
1784         proto_tree_add_subtree(tree,
1785         tvb, curr_offset, 1,
1786         ett_bc_oct_6c, NULL, "Octet 6c");
1787
1788     oct = tvb_get_guint8(tvb, curr_offset);
1789
1790     extended = (oct & 0x80) ? FALSE : TRUE;
1791
1792     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1793     proto_tree_add_item(subtree, hf_gsm_a_dtap_connection_element, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1794     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_modem_type, tvb, curr_offset, 1,
1795         oct, "%s", val_to_str_const(oct & 0x1f, gsm_a_dtap_modem_type_vals, "Reserved"));
1796
1797     curr_offset++;
1798
1799     NO_MORE_DATA_CHECK(len);
1800
1801     if (!extended) goto bc_octet_7;
1802
1803     /* octet 6d */
1804
1805     subtree =
1806         proto_tree_add_subtree(tree,
1807         tvb, curr_offset, 1,
1808         ett_bc_oct_6d, NULL, "Octet 6d");
1809
1810     oct = tvb_get_guint8(tvb, curr_offset);
1811
1812     extended = (oct & 0x80) ? FALSE : TRUE;
1813
1814     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1815     proto_tree_add_item(subtree, hf_gsm_a_dtap_other_modem_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1816     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_fixed_network_user_rate, tvb, curr_offset, 1,
1817         oct, "%s", val_to_str_const(oct & 0x1f, gsm_a_dtap_fixed_network_user_rate_vals, "Reserved"));
1818     curr_offset++;
1819
1820     NO_MORE_DATA_CHECK(len);
1821
1822     if (!extended) goto bc_octet_7;
1823
1824     /* octet 6e */
1825
1826     subtree =
1827         proto_tree_add_subtree(tree,
1828         tvb, curr_offset, 1,
1829         ett_bc_oct_6e, NULL, "Octet 6e");
1830
1831     oct = tvb_get_guint8(tvb, curr_offset);
1832
1833     extended = (oct & 0x80) ? FALSE : TRUE;
1834
1835     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1836
1837     if (is_uplink == IS_UPLINK_TRUE)
1838     {
1839         proto_tree_add_item(subtree, hf_gsm_a_dtap_acceptable_channel_codings_TCH_F14_4, tvb, curr_offset, 1, ENC_NA);
1840         proto_tree_add_item(subtree, hf_gsm_a_dtap_acceptable_channel_codings_spare20, tvb, curr_offset, 1, ENC_NA);
1841         proto_tree_add_item(subtree, hf_gsm_a_dtap_acceptable_channel_codings_TCH_F9_6, tvb, curr_offset, 1, ENC_NA);
1842         proto_tree_add_item(subtree, hf_gsm_a_dtap_acceptable_channel_codings_TCH_F4_8, tvb, curr_offset, 1, ENC_NA);
1843
1844         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_maximum_number_of_traffic_channels, tvb, curr_offset, 1,
1845             (oct & 0x07) + 1, "%u TCH", (oct & 0x07) + 1);
1846     }
1847     else
1848     {
1849         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_acceptable_channel_codings_spare78, tvb, curr_offset, 1,
1850             oct, "Spare");
1851         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_maximum_number_of_traffic_channels, tvb, curr_offset, 1,
1852             oct, "Spare");
1853     }
1854
1855     curr_offset++;
1856
1857     NO_MORE_DATA_CHECK(len);
1858
1859     if (!extended) goto bc_octet_7;
1860
1861     /* octet 6f */
1862
1863     subtree =
1864         proto_tree_add_subtree(tree,
1865         tvb, curr_offset, 1,
1866         ett_bc_oct_6f, NULL, "Octet 6f");
1867
1868     oct = tvb_get_guint8(tvb, curr_offset);
1869
1870     extended = (oct & 0x80) ? FALSE : TRUE;
1871
1872     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1873     proto_tree_add_item(subtree, hf_gsm_a_dtap_uimi, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1874
1875     if (is_uplink == IS_UPLINK_TRUE)
1876     {
1877         proto_tree_add_item(subtree, hf_gsm_a_dtap_wanted_air_interface_user_rate, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1878     }
1879     else
1880     {
1881         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_wanted_air_interface_user_rate, tvb, curr_offset, 1,
1882             oct, "Spare");
1883     }
1884
1885     curr_offset++;
1886
1887     NO_MORE_DATA_CHECK(len);
1888
1889     if (!extended) goto bc_octet_7;
1890
1891     /* octet 6g */
1892
1893     subtree =
1894         proto_tree_add_subtree(tree,
1895         tvb, curr_offset, 1,
1896         ett_bc_oct_6g, NULL, "Octet 6g");
1897
1898     oct = tvb_get_guint8(tvb, curr_offset);
1899
1900     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1901
1902     if (is_uplink == IS_UPLINK_TRUE)
1903     {
1904         proto_tree_add_item(subtree, hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F28_8, tvb, curr_offset, 1, ENC_NA);
1905         proto_tree_add_item(subtree, hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F32_0, tvb, curr_offset, 1, ENC_NA);
1906         proto_tree_add_item(subtree, hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F43_2, tvb, curr_offset, 1, ENC_NA);
1907         proto_tree_add_item(subtree, hf_gsm_a_dtap_channel_coding_asymmetry_indication, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1908     }
1909     else
1910     {
1911         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_edge_channel_codings, tvb, curr_offset, 1, oct, "Spare");
1912     }
1913
1914     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+6, 2, ENC_BIG_ENDIAN);
1915
1916     curr_offset++;
1917
1918     NO_MORE_DATA_CHECK(len);
1919
1920 bc_octet_7:
1921     /* octet 7 */
1922
1923     subtree =
1924         proto_tree_add_subtree(tree,
1925         tvb, curr_offset, 1,
1926         ett_bc_oct_7, NULL, "Octet 7");
1927
1928     proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1929
1930     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_layer_2_identity, tvb, curr_offset, 1, oct,
1931         "%s", ((oct & 0x60) == 0x40) ? "Octet identifier" : "Reserved");
1932
1933     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_user_information_layer_2_protocol, tvb, curr_offset, 1,
1934         oct, "%s", val_to_str_const(oct & 0x1F, gsm_a_dtap_user_info_layer2_vals, "Reserved"));
1935     break;
1936     }
1937
1938     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
1939
1940     return (curr_offset - offset);
1941 }
1942
1943
1944 guint16
1945 de_bearer_cap_uplink(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len)
1946 {
1947     is_uplink = IS_UPLINK_TRUE;
1948     return de_bearer_cap(tvb, tree, pinfo, offset, len, add_string, string_len);
1949
1950 }
1951
1952 /*
1953  * [9] 10.5.4.5a Call Control Capabilities
1954  */
1955 const true_false_string gsm_a_dtap_mcat_value = {
1956     "The mobile station supports Multimedia CAT during the alerting phase of a mobile originated multimedia call establishment",
1957     "The mobile station does not support Multimedia CAT"
1958 };
1959
1960 const true_false_string gsm_a_dtap_enicm_value = {
1961     "The mobile station supports the Enhanced Network-initiated In-Call Modification procedure",
1962     "The mobile station does not support the Enhanced Network-initiated In-Call Modification procedure"
1963 };
1964
1965 const true_false_string gsm_a_dtap_dtmf_value = {
1966     "the mobile station supports DTMF as specified in subclause 5.5.7 of TS 24.008",
1967     "reserved for earlier versions of the protocol"
1968 };
1969
1970 static guint16
1971 de_cc_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_) {
1972     guint8  oct;
1973     guint32 curr_offset;
1974
1975     curr_offset = offset;
1976
1977     oct = tvb_get_guint8(tvb, curr_offset);
1978
1979     if (((oct & 0xf0) >> 4) == 0)
1980     {
1981         proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_maximum_number_of_supported_bearers, tvb, curr_offset, 1, 0, "1");
1982     }
1983     else
1984     {
1985         proto_tree_add_item(tree, hf_gsm_a_dtap_maximum_number_of_supported_bearers, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1986     }
1987
1988     proto_tree_add_item(tree, hf_gsm_a_dtap_mcat, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1989     proto_tree_add_item(tree, hf_gsm_a_dtap_enicm, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1990     proto_tree_add_item(tree, hf_gsm_a_dtap_pcp, tvb, curr_offset, 1, ENC_NA);
1991     proto_tree_add_item(tree, hf_gsm_a_dtap_dtmf, tvb, curr_offset, 1, ENC_NA);
1992
1993     curr_offset++;
1994
1995     NO_MORE_DATA_CHECK(len);
1996
1997     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
1998     proto_tree_add_item(tree, hf_gsm_a_dtap_max_num_of_speech_bearers, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1999
2000     curr_offset++;
2001
2002     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
2003
2004     return (curr_offset - offset);
2005 }
2006
2007 /*
2008  * [3] 10.5.4.6 Call state
2009  */
2010 static const value_string gsm_a_dtap_coding_standard_vals[] = {
2011     { 0x00, "standardized coding as described in ITU-T Rec. Q.931" },
2012     { 0x01, "reserved for other international standards" },
2013     { 0x02, "national standard" },
2014     { 0x03, "standard defined for the GSM PLMNS as described below" },
2015     { 0, NULL }
2016 };
2017
2018 static const value_string gsm_a_dtap_call_state_vals[] = {
2019     { 0x00, "U0/N0 - null" },
2020     { 0x02, "U0.1/N0.1 - MM connection pending" },
2021     { 0x22, "U0.2 - CC prompt present / N0.2 - CC connection pending" },
2022     { 0x23, "U0.3 - Wait for network information / N0.3 - Network answer pending" },
2023     { 0x24, "U0.4/N0.4 - CC-Establishment present" },
2024     { 0x25, "U0.5/N0.5 - CC-Establishment confirmed" },
2025     { 0x26, "U0.6/N0.6 - Recall present" },
2026     { 0x01, "U1/N1 - call initiated" },
2027     { 0x03, "U3/N3 - mobile originating call proceeding" },
2028     { 0x04, "U4/N4 - call delivered" },
2029     { 0x06, "U6/N6 - call present" },
2030     { 0x07, "U7/N7 - call received" },
2031     { 0x08, "U8/N8 - connect request" },
2032     { 0x09, "U9/N9 - mobile terminating call confirmed" },
2033     { 0x0a, "U10/N10 - active" },
2034     { 0x0b, "U11 - disconnect request" },
2035     { 0x0c, "U12/N12 - disconnect indication" },
2036     { 0x13, "U19/N19 - release request" },
2037     { 0x1a, "U26/N26 - mobile originating modify" },
2038     { 0x1b, "U27/N27 - mobile terminating modify" },
2039     { 0x1c, "N28 - connect indication" },
2040     { 0, NULL }
2041 };
2042
2043 static guint16
2044 de_call_state(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2045 {
2046     guint8      oct, coding_standard, call_state;
2047     proto_tree *subtree;
2048
2049     subtree =
2050     proto_tree_add_subtree(tree,
2051         tvb, offset, 1, ett_gsm_dtap_elem[DE_CALL_STATE], NULL,
2052         val_to_str_ext_const(DE_CALL_STATE, &gsm_dtap_elem_strings_ext, ""));
2053
2054     proto_tree_add_item(subtree, hf_gsm_a_dtap_coding_standard, tvb, offset, 1, ENC_BIG_ENDIAN);
2055
2056     oct = tvb_get_guint8(tvb, offset);
2057     coding_standard = (oct & 0xc0) >> 6;
2058     call_state = oct & 0x3f;
2059
2060     switch (coding_standard)
2061     {
2062     case 0:
2063         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_call_state, tvb,
2064                 offset, 1, call_state, "%s (%u)",
2065                 val_to_str_ext_const(call_state, &q931_call_state_vals_ext, "Reserved"),
2066                 call_state);
2067         break;
2068     case 1:
2069     case 2:
2070         proto_tree_add_item(subtree, hf_gsm_a_dtap_call_state, tvb, offset, 1, ENC_BIG_ENDIAN);
2071         break;
2072     default:
2073         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_call_state, tvb,
2074                 offset, 1, call_state, "%s (%u)",
2075                 val_to_str_const(call_state, gsm_a_dtap_call_state_vals, "Reserved"),
2076                 call_state);
2077         break;
2078     }
2079
2080     /* no length check possible */
2081
2082     return (1);
2083 }
2084
2085 /*
2086  * Helper function for BCD address decoding
2087  */
2088 const value_string gsm_a_dtap_type_of_number_values[] = {
2089     { 0x00, "unknown" },
2090     { 0x01, "International Number" },
2091     { 0x02, "National number" },
2092     { 0x03, "Network Specific Number" },
2093     { 0x04, "Dedicated access, short code" },
2094     { 0x05, "Reserved" },
2095     { 0x06, "Reserved" },
2096     { 0x07, "Reserved for extension" },
2097     { 0, NULL }
2098 };
2099
2100 const value_string gsm_a_dtap_numbering_plan_id_values[] = {
2101     { 0x00, "unknown" },
2102     { 0x01, "ISDN/Telephony Numbering (ITU-T Rec. E.164 / ITU-T Rec. E.163)" },
2103     { 0x02, "spare" },
2104     { 0x03, "Data Numbering (ITU-T Rec. X.121)" },
2105     { 0x04, "Telex Numbering (ITU-T Rec. F.69)" },
2106     { 0x08, "National Numbering" },
2107     { 0x09, "Private Numbering" },
2108     { 0x0d, "Reserved for CTS (see 3GPP TS 44.056)" },
2109     { 0x0f, "Reserved for extension" },
2110     { 0, NULL }
2111 };
2112
2113 const value_string gsm_a_dtap_present_ind_values[] = {
2114     { 0x00, "Presentation allowed" },
2115     { 0x01, "Presentation restricted" },
2116     { 0x02, "Number not available due to interworking" },
2117     { 0x03, "Reserved" },
2118     { 0, NULL }
2119 };
2120
2121 const value_string gsm_a_dtap_screening_ind_values[] = {
2122     { 0x00, "User-provided, not screened" },
2123     { 0x01, "User-provided, verified and passed" },
2124     { 0x02, "User-provided, verified and failed" },
2125     { 0x03, "Network provided" },
2126     { 0, NULL }
2127 };
2128
2129 static guint16
2130 de_bcd_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, int header_field, gboolean *address_extracted)
2131 {
2132     guint8     *poctets;
2133     guint8      extension;
2134     guint32     curr_offset, num_string_len;
2135     proto_item *item;
2136     const char *digit_str;
2137
2138     *address_extracted = FALSE;
2139     curr_offset = offset;
2140
2141     extension = tvb_get_guint8(tvb, curr_offset) & 0x80;
2142     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2143     proto_tree_add_item(tree, hf_gsm_a_dtap_type_of_number, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2144     proto_tree_add_item(tree, hf_gsm_a_dtap_numbering_plan_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2145     curr_offset++;
2146
2147     if (!extension)
2148     {
2149         proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2150         proto_tree_add_item(tree, hf_gsm_a_dtap_present_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2151         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+3, 3, ENC_BIG_ENDIAN);
2152         proto_tree_add_item(tree, hf_gsm_a_dtap_screening_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2153         curr_offset++;
2154     }
2155
2156     NO_MORE_DATA_CHECK(len);
2157
2158     num_string_len = len - (curr_offset - offset);
2159     poctets = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, num_string_len);
2160
2161     *address_extracted = TRUE;
2162     my_dgt_tbcd_unpack(a_bigbuf, poctets, num_string_len,
2163         &Dgt_mbcd);
2164
2165     digit_str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, num_string_len, NULL, FALSE);
2166     proto_tree_add_string(tree, header_field, tvb, curr_offset, num_string_len, digit_str);
2167     item = proto_tree_add_string_format(tree, header_field,
2168         tvb, curr_offset, num_string_len,
2169         a_bigbuf,
2170         "BCD Digits: %s",
2171         a_bigbuf);
2172
2173     /* Check for overdicadic digits, we used the standard digit map from tvbuff.c
2174      *  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e  f
2175      * '0','1','2','3','4','5','6','7','8','9','?','?','?','?','?','?'
2176      *
2177      */
2178     if(strchr(digit_str,'?')){
2179         expert_add_info(pinfo, item, &ei_gsm_a_dtap_end_mark_unexpected);
2180     }
2181
2182     return (len);
2183 }
2184
2185 /*
2186  * Helper function for sub address decoding
2187  */
2188 const value_string gsm_a_dtap_type_of_sub_addr_values[] = {
2189     { 0x00, "NSAP (ITU-T Rec. X.213/ISO 8348 AD2)" },
2190     { 0x02, "User specified" },
2191     { 0, NULL }
2192 };
2193
2194 const value_string gsm_a_dtap_odd_even_ind_values[] = {
2195     { 0x00, "even number of address signals" },
2196     { 0x01, "odd number of address signals" },
2197     { 0, NULL }
2198 };
2199
2200
2201 static guint16
2202 de_sub_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gboolean *address_extracted)
2203 {
2204     guint32     curr_offset, ia5_string_len, i;
2205     guint8      type_of_sub_addr, afi, dig1, dig2, oct;
2206     gchar      *ia5_string;
2207     gboolean    invalid_ia5_char;
2208     proto_item *item;
2209
2210     curr_offset = offset;
2211
2212     *address_extracted = FALSE;
2213     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2214     proto_tree_add_item(tree, hf_gsm_a_dtap_type_of_sub_addr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2215     proto_tree_add_item(tree, hf_gsm_a_dtap_odd_even_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2216     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+5, 3, ENC_BIG_ENDIAN);
2217     type_of_sub_addr = (tvb_get_guint8(tvb, curr_offset) & 0x70) >> 4;
2218     curr_offset++;
2219
2220     NO_MORE_DATA_CHECK(len);
2221
2222     if (!type_of_sub_addr)
2223     {
2224         afi = tvb_get_guint8(tvb, curr_offset);
2225         proto_tree_add_item(tree, hf_gsm_a_dtap_afi, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2226         curr_offset++;
2227
2228         NO_MORE_DATA_CHECK(len);
2229
2230         if (afi == 0x50)
2231         {
2232             ia5_string_len = len - (curr_offset - offset);
2233             ia5_string = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, ia5_string_len);
2234
2235             invalid_ia5_char = FALSE;
2236             for(i = 0; i < ia5_string_len; i++)
2237             {
2238                 dig1 = (ia5_string[i] & 0xf0) >> 4;
2239                 dig2 = ia5_string[i] & 0x0f;
2240                 oct = (dig1 * 10) + dig2 + 32;
2241                 if (oct > 127)
2242                     invalid_ia5_char = TRUE;
2243                 ia5_string[i] = oct;
2244
2245             }
2246
2247             IA5_7BIT_decode(a_bigbuf, ia5_string, ia5_string_len);
2248             *address_extracted = TRUE;
2249
2250             item = proto_tree_add_text(tree,
2251                 tvb, curr_offset, len - (curr_offset - offset),
2252                 "Subaddress: %s", a_bigbuf);
2253
2254             if (invalid_ia5_char)
2255                 expert_add_info(pinfo, item, &ei_gsm_a_dtap_invalid_ia5_character);
2256
2257             return (len);
2258         }
2259     }
2260
2261     proto_tree_add_text(tree,
2262         tvb, curr_offset, len - (curr_offset - offset),
2263         "Subaddress information");
2264
2265     return (len);
2266 }
2267
2268 /*
2269  * [3] 10.5.4.7 Called party BCD number
2270  */
2271 guint16
2272 de_cld_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len)
2273 {
2274     gboolean addr_extr;
2275
2276     de_bcd_num(tvb, tree, pinfo, offset, len, hf_gsm_a_dtap_cld_party_bcd_num, &addr_extr);
2277
2278     if (addr_extr) {
2279         if (sccp_assoc && ! sccp_assoc->called_party) {
2280             sccp_assoc->called_party = wmem_strdup(wmem_file_scope(), a_bigbuf);
2281         }
2282
2283         if (add_string)
2284             g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
2285     }
2286
2287     return (len);
2288 }
2289
2290 /*
2291  * [3] 10.5.4.8 Called party subaddress
2292  */
2293 static guint16
2294 de_cld_party_sub_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2295 {
2296     gboolean addr_extr;
2297
2298     de_sub_addr(tvb, tree, pinfo, offset, len, &addr_extr);
2299
2300     if (addr_extr && add_string)
2301         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
2302
2303     return (len);
2304 }
2305
2306 /* 3GPP TS 24.008
2307  * [3] 10.5.4.9 Calling party BCD number
2308  */
2309 static guint16
2310 de_clg_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len)
2311 {
2312     gboolean addr_extr;
2313
2314     de_bcd_num(tvb, tree, pinfo, offset, len, hf_gsm_a_dtap_clg_party_bcd_num, &addr_extr);
2315
2316     if (addr_extr && add_string)
2317         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
2318
2319     return (len);
2320 }
2321
2322 /*
2323  * [3] 10.5.4.10 Calling party subaddress
2324  */
2325 static guint16
2326 de_clg_party_sub_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2327 {
2328     gboolean addr_extr;
2329
2330     de_sub_addr(tvb, tree, pinfo, offset, len, &addr_extr);
2331
2332     if (addr_extr && add_string)
2333         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
2334
2335     return (len);
2336 }
2337
2338 /*
2339  * [3] 10.5.4.11 Cause
2340  */
2341 static const value_string gsm_a_dtap_cause_ss_diagnostics_vals[] = {
2342     { 0x01, "Outgoing calls barred within CUG" },
2343     { 0x02, "No CUG selected" },
2344     { 0x03, "Unknown CUG index" },
2345     { 0x04, "CUG index incompatible with requested basic service" },
2346     { 0x05, "CUG call failure, unspecified" },
2347     { 0x06, "CLIR not subscribed" },
2348     { 0x07, "CCBS possible" },
2349     { 0x08, "CCBS not possible" },
2350     { 0, NULL }
2351 };
2352
2353 static const value_string gsm_a_dtap_de_cause_coding_standard_vals[] = {
2354     { 0x00, "Coding as specified in ITU-T Rec. Q.931" },
2355     { 0x01, "Reserved for other international standards" },
2356     { 0x02, "National standard" },
2357     { 0x03, "Standard defined for the GSM PLMNS" },
2358     { 0, NULL }
2359 };
2360
2361 static guint16
2362 de_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len)
2363 {
2364     guint8       oct;
2365     guint8       cause;
2366     guint32      curr_offset;
2367     guint32      diag_length;
2368     proto_tree  *subtree;
2369     const gchar *str;
2370
2371     curr_offset = offset;
2372
2373     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2374     proto_tree_add_item(tree, hf_gsm_a_dtap_de_cause_coding_standard, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2375
2376     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+3, 1, ENC_BIG_ENDIAN);
2377
2378     proto_tree_add_item(tree, hf_gsm_a_dtap_location, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2379     curr_offset++;
2380
2381     oct = tvb_get_guint8(tvb, curr_offset);
2382
2383     if (!(oct & 0x80))
2384     {
2385     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2386     proto_tree_add_item(tree, hf_gsm_a_dtap_recommendation, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2387
2388     curr_offset++;
2389
2390     oct = tvb_get_guint8(tvb, curr_offset);
2391     }
2392
2393     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2394
2395     cause = oct & 0x7f;
2396     switch (cause)
2397     {
2398     case   1: str = "Unassigned (unallocated) number";                                    break;
2399     case   3: str = "No route to destination";                                            break;
2400     case   6: str = "Channel unacceptable";                                               break;
2401     case   8: str = "Operator determined barring";                                        break;
2402     case  16: str = "Normal call clearing";                                               break;
2403     case  17: str = "User busy";                                                          break;
2404     case  18: str = "No user responding";                                                 break;
2405     case  19: str = "User alerting, no answer";                                           break;
2406     case  21: str = "Call rejected";                                                      break;
2407     case  22: str = "Call rejected due to feature at the destination";                    break;
2408     case  24: str = "Number changed";                                                     break;
2409     case  25: str = "Pre-emption";                                                        break;
2410     case  26: str = "Non selected user clearing";                                         break;
2411     case  27: str = "Destination out of order";                                           break;
2412     case  28: str = "Invalid number format (incomplete number)";                          break;
2413     case  29: str = "Facility rejected";                                                  break;
2414     case  30: str = "Response to STATUS ENQUIRY";                                         break;
2415     case  31: str = "Normal, unspecified";                                                break;
2416     case  34: str = "No circuit/channel available";                                       break;
2417     case  38: str = "Network out of order";                                               break;
2418     case  41: str = "Temporary failure";                                                  break;
2419     case  42: str = "Switching equipment congestion";                                     break;
2420     case  43: str = "Access information discarded";                                       break;
2421     case  44: str = "requested circuit/channel not available";                            break;
2422     case  47: str = "Resources unavailable, unspecified";                                 break;
2423     case  49: str = "Quality of service unavailable";                                     break;
2424     case  50: str = "Requested facility not subscribed";                                  break;
2425     case  55: str = "Incoming calls barred within the CUG";                               break;
2426     case  57: str = "Bearer capability not authorized";                                   break;
2427     case  58: str = "Bearer capability not presently available";                          break;
2428     case  63: str = "Service or option not available, unspecified";                       break;
2429     case  65: str = "Bearer service not implemented";                                     break;
2430     case  68: str = "ACM equal to or greater than ACMmax";                                break;
2431     case  69: str = "Requested facility not implemented";                                 break;
2432     case  70: str = "Only restricted digital information bearer capability is available"; break;
2433     case  79: str = "Service or option not implemented, unspecified";                     break;
2434     case  81: str = "Invalid transaction identifier value";                               break;
2435     case  87: str = "User not member of CUG";                                             break;
2436     case  88: str = "Incompatible destination";                                           break;
2437     case  91: str = "Invalid transit network selection";                                  break;
2438     case  95: str = "Semantically incorrect message";                                     break;
2439     case  96: str = "Invalid mandatory information";                                      break;
2440     case  97: str = "Message type non-existent or not implemented";                       break;
2441     case  98: str = "Message type not compatible with protocol state";                    break;
2442     case  99: str = "Information element non-existent or not implemented";                break;
2443     case 100: str = "Conditional IE error";                                               break;
2444     case 101: str = "Message not compatible with protocol state";                         break;
2445     case 102: str = "Recovery on timer expiry";                                           break;
2446     case 111: str = "Protocol error, unspecified";                                        break;
2447     case 127: str = "Interworking, unspecified";                                          break;
2448     default:
2449         if (cause <= 31) { str = "Treat as Normal, unspecified"; }
2450         else if ((cause >= 32) && (cause <= 47)) { str = "Treat as Resources unavailable, unspecified"; }
2451         else if ((cause >= 48) && (cause <= 63)) { str = "Treat as Service or option not available, unspecified"; }
2452         else if ((cause >= 64) && (cause <= 79)) { str = "Treat as Service or option not implemented, unspecified"; }
2453         else if ((cause >= 80) && (cause <= 95)) { str = "Treat as Semantically incorrect message"; }
2454         else if ((cause >= 96) && (cause <= 111)) { str = "Treat as Protocol error, unspecified"; }
2455         else { str = "Treat as Interworking, unspecified"; }
2456         break;
2457     }
2458
2459     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_cause,
2460         tvb, curr_offset, 1, cause,
2461         "Cause: (%u) %s",
2462         cause,
2463         str);
2464
2465     curr_offset++;
2466
2467     if (add_string)
2468         g_snprintf(add_string, string_len, " - (%u) %s", cause, str);
2469
2470     NO_MORE_DATA_CHECK(len);
2471
2472     subtree = proto_tree_add_subtree(tree, tvb, curr_offset, len - (curr_offset - offset),
2473                                         ett_gsm_dtap_elem[DE_CAUSE], NULL, "Diagnostics");
2474
2475     /*
2476      * Diagnostics for supplementary services may be included in the case of
2477      * the following cause codes:
2478      *   17 - User busy
2479      *   29 - Facility rejected
2480      *   34 - No circuit/channel available
2481      *   50 - Requested facility not subscribed
2482      *   55 - Incoming calls barred within the CUG
2483      *   69 - Requested facility not implemented
2484      *   87 - User not member of CUG
2485      */
2486     if ((cause == 17) || (cause == 29) || (cause == 34) || (cause == 50) ||
2487         (cause == 55) || (cause == 69) || (cause == 87))
2488     {
2489         proto_tree_add_item(subtree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2490         proto_tree_add_item(subtree, hf_gsm_a_dtap_cause_ss_diagnostics, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2491         curr_offset++;
2492     }
2493     else
2494     {
2495         diag_length = len - (curr_offset - offset);
2496         proto_tree_add_item(subtree, hf_gsm_a_dtap_data, tvb, curr_offset, diag_length, ENC_NA);
2497         curr_offset += diag_length;
2498     }
2499
2500     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
2501
2502     return (curr_offset - offset);
2503 }
2504 /*
2505  * 10.5.4.11a CLIR suppression
2506  * No data
2507  */
2508 /*
2509  * 10.5.4.11b CLIR invocation
2510  * No data
2511  */
2512 /*
2513  * 10.5.4.12 Congestion level
2514  *  handled inline
2515  */
2516 /*
2517  * 10.5.4.13 Connected number
2518  */
2519 static guint16
2520 de_conn_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len)
2521 {
2522     gboolean addr_extr;
2523
2524     de_bcd_num(tvb, tree, pinfo, offset, len, hf_gsm_a_dtap_conn_num, &addr_extr);
2525
2526     if (addr_extr && add_string)
2527         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
2528
2529     return (len);
2530 }
2531
2532 /*
2533  * 10.5.4.14 Connected subaddress
2534  */
2535 static guint16
2536 de_conn_sub_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2537 {
2538     gboolean addr_extr;
2539
2540     de_sub_addr(tvb, tree, pinfo, offset, len, &addr_extr);
2541
2542     if (addr_extr && add_string)
2543         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
2544
2545     return (len);
2546 }
2547
2548 /*
2549  * 10.5.4.15 Facility
2550  */
2551
2552 static guint16
2553 de_facility(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint fac_len, gchar *add_string _U_, int string_len _U_)
2554 {
2555     guint        saved_offset;
2556     gint8        appclass;
2557     gboolean     pc;
2558     gboolean     ind           = FALSE;
2559     guint32      component_len = 0;
2560     guint32      header_end_offset;
2561     guint32      header_len;
2562     asn1_ctx_t   asn1_ctx;
2563     tvbuff_t    *SS_tvb        = NULL;
2564     static gint  comp_type_tag;
2565
2566     asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
2567
2568     saved_offset = offset;
2569     col_append_str(pinfo->cinfo, COL_PROTOCOL,"/");
2570     col_set_fence(pinfo->cinfo, COL_PROTOCOL);
2571     while (fac_len > (offset - saved_offset)) {
2572
2573         /* Get the length of the component there can be more than one component in a facility message */
2574
2575         header_end_offset = get_ber_identifier(tvb, offset, &appclass, &pc, &comp_type_tag);
2576         header_end_offset = get_ber_length(tvb, header_end_offset, &component_len, &ind);
2577         header_len = header_end_offset - offset;
2578         component_len = header_len + component_len;
2579         /*
2580         dissect_ROS_Component(FALSE, tvb, offset, &asn1_ctx, tree, hf_ROS_component);
2581         TODO Call gsm map here
2582         */
2583         SS_tvb = tvb_new_subset_length(tvb, offset, component_len);
2584         col_append_str(pinfo->cinfo, COL_INFO,"(GSM MAP) ");
2585         col_set_fence(pinfo->cinfo, COL_INFO);
2586         call_dissector(gsm_map_handle, SS_tvb, pinfo, tree);
2587         offset = offset + component_len;
2588     }
2589     return (fac_len);
2590 }
2591 /*
2592  * 10.5.4.16 High layer compatibility
2593  */
2594 static guint16
2595 de_hlc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2596 {
2597     guint32 curr_offset;
2598
2599     curr_offset = offset;
2600
2601     dissect_q931_high_layer_compat_ie(tvb, offset, len, tree);
2602
2603     curr_offset = curr_offset + len;
2604     return (curr_offset - offset);
2605 }
2606
2607 /*
2608  * [3] 10.5.4.17 Keypad facility
2609  */
2610 static guint16
2611 de_keypad_facility(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string, int string_len)
2612 {
2613     guint8      keypad_char;
2614     guint32     curr_offset;
2615     proto_item *item;
2616
2617     curr_offset = offset;
2618
2619     keypad_char = tvb_get_guint8(tvb, curr_offset) & 0x7f;
2620
2621     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
2622
2623     item = proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_keypad_information, tvb, curr_offset, 1,
2624         keypad_char, "%c", keypad_char);
2625
2626     if (((keypad_char < '0') || (keypad_char > '9')) &&
2627         ((keypad_char < 'A') || (keypad_char > 'D')) &&
2628         (keypad_char != '*') && (keypad_char != '#'))
2629         expert_add_info(pinfo, item, &ei_gsm_a_dtap_keypad_info_not_dtmf_digit);
2630     curr_offset++;
2631
2632     if (add_string)
2633         g_snprintf(add_string, string_len, " - %c", keypad_char);
2634
2635     /* no length check possible */
2636
2637     return (curr_offset - offset);
2638 }
2639
2640 /*
2641  * 10.5.4.18 Low layer compatibility
2642  */
2643 static guint16
2644 de_llc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2645 {
2646     guint32 curr_offset;
2647
2648     curr_offset = offset;
2649
2650     dissect_q931_bearer_capability_ie(tvb, offset, len, tree);
2651
2652     curr_offset = curr_offset + len;
2653     return (curr_offset - offset);
2654 }
2655
2656 /*
2657  * 10.5.4.19 More data
2658  * No data
2659  */
2660 /*
2661  * 10.5.4.20 Notification indicator
2662  */
2663 static const value_string gsm_a_dtap_notification_description_vals[] = {
2664     { 0x00, "User suspended" },
2665     { 0x01, "User resumed" },
2666     { 0x02, "Bearer change" },
2667     { 0, NULL }
2668 };
2669
2670 static guint16
2671 de_notif_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2672 {
2673     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, offset, 1, ENC_BIG_ENDIAN);
2674     proto_tree_add_item(tree, hf_gsm_a_dtap_notification_description, tvb, offset, 1, ENC_BIG_ENDIAN);
2675
2676     return 1;
2677 }
2678 /*
2679  * [3] 10.5.4.21 Progress indicator
2680  */
2681 static const value_string gsm_a_dtap_location_vals[] = {
2682     { 0x00, "User" },
2683     { 0x01, "Private network serving the local user" },
2684     { 0x02, "Public network serving the local user" },
2685     { 0x03, "Transit network" },
2686     { 0x04, "Public network serving the remote user" },
2687     { 0x05, "Private network serving the remote user" },
2688     { 0x07, "International network" },
2689     { 0x0a, "Network beyond interworking point" },
2690     { 0, NULL }
2691 };
2692
2693 static const value_string gsm_a_dtap_progress_description_vals[] = {
2694     { 0x01, "Call is not end-to-end PLMN/ISDN, further call progress information may be available in-band" },
2695     { 0x02, "Destination address in non-PLMN/ISDN" },
2696     { 0x03, "Origination address in non-PLMN/ISDN" },
2697     { 0x04, "Call has returned to the PLMN/ISDN" },
2698     { 0x08, "In-band information or appropriate pattern now available" },
2699     { 0x09, "In-band multimedia CAT available" },
2700     { 0x20, "Call is end-to-end PLMN/ISDN" },
2701     { 0x40, "Queueing" },
2702     { 0, NULL }
2703 };
2704
2705 static guint16
2706 de_prog_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2707 {
2708     guint8  oct, coding_standard, progress_description;
2709     guint32 curr_offset;
2710
2711     curr_offset = offset;
2712
2713     oct = tvb_get_guint8(tvb, curr_offset);
2714     coding_standard = (oct & 0x60) >> 5;
2715     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2716     proto_tree_add_item(tree, hf_gsm_a_dtap_prog_coding_standard, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2717     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3) + 3, 1, ENC_BIG_ENDIAN);
2718     proto_tree_add_item(tree, hf_gsm_a_dtap_location, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2719     curr_offset++;
2720
2721     oct = tvb_get_guint8(tvb, curr_offset);
2722     progress_description = oct & 0x7f;
2723     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2724
2725     switch (coding_standard)
2726     {
2727     case 0:
2728         proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_progress_description, tvb,
2729                 curr_offset, 1, progress_description, "%s (%u)",
2730                 val_to_str_ext_const(progress_description, &q931_progress_description_vals_ext, "Reserved"),
2731                 progress_description);
2732         break;
2733     case 1:
2734     case 2:
2735         proto_tree_add_item(tree, hf_gsm_a_dtap_progress_description, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2736         break;
2737     default:
2738         proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_progress_description, tvb,
2739                 curr_offset, 1, progress_description, "%s (%u)",
2740                 val_to_str_const(progress_description, gsm_a_dtap_progress_description_vals, "Unspecific"),
2741                 progress_description);
2742         break;
2743     }
2744     curr_offset++;
2745
2746     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
2747
2748     return (curr_offset - offset);
2749 }
2750
2751 /*
2752  * 10.5.4.21a Recall type $(CCBS)$
2753  */
2754 static const range_string gsm_a_dtap_recall_type_vals[] = {
2755     { 0x00, 0x00, "CCBS" },
2756     { 0x01, 0x06, "shall be treated as CCBS (intended for other similar type of Recall)" },
2757     { 0, 0, NULL }
2758 };
2759
2760 static guint16
2761 de_recall_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2762 {
2763     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset<<3), 5, ENC_BIG_ENDIAN);
2764     proto_tree_add_item(tree, hf_gsm_a_dtap_recall_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2765
2766     return (1);
2767 }
2768
2769 /*
2770  * 10.5.4.21b Redirecting party BCD number
2771  */
2772 static guint16
2773 de_red_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len)
2774 {
2775     gboolean    addr_extr;
2776
2777     de_bcd_num(tvb, tree, pinfo, offset, len, hf_gsm_a_dtap_red_party_bcd_num, &addr_extr);
2778
2779     if (addr_extr && add_string)
2780         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
2781
2782     return (len);
2783 }
2784
2785 /*
2786  * 10.5.4.21c Redirecting party subaddress
2787  */
2788 static guint16
2789 de_red_party_sub_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2790 {
2791     gboolean    addr_extr;
2792
2793     de_sub_addr(tvb, tree, pinfo, offset, len, &addr_extr);
2794
2795     if (addr_extr && add_string)
2796         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
2797
2798     return (len);
2799 }
2800
2801 /*
2802  * [3] 10.5.4.22 Repeat indicator
2803  */
2804 static const value_string gsm_a_dtap_repeat_indicator_vals[] = {
2805     { 0x01, "Circular for successive selection 'mode 1 alternate mode 2'" },
2806     { 0x02, "Support of fallback mode 1 preferred, mode 2 selected if setup of mode 1 fails" },
2807     { 0x03, "Reserved: was allocated in earlier phases of the protocol" },
2808     { 0, NULL }
2809 };
2810
2811 static guint16
2812 de_repeat_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2813 {
2814     guint8  oct;
2815     guint32 curr_offset;
2816
2817     curr_offset = offset;
2818
2819     oct = tvb_get_guint8(tvb, curr_offset);
2820
2821     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_repeat_indicator, tvb, curr_offset, 1, oct,
2822         "%s", val_to_str_const(oct & 0xF, gsm_a_dtap_repeat_indicator_vals, "Reserved"));
2823     curr_offset++;
2824
2825     /* no length check possible */
2826
2827     return (curr_offset - offset);
2828 }
2829 /*
2830  * 10.5.4.22a Reverse call setup direction
2831  * No data
2832  */
2833 /*
2834  * 10.5.4.22b SETUP Container $(CCBS)$
2835  */
2836 static void
2837 dtap_cc_setup(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len);
2838
2839 static guint16
2840 de_setup_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2841 {
2842     dtap_cc_setup(tvb, tree, pinfo, offset, len);
2843
2844     return (len);
2845 }
2846
2847 /*
2848  * 10.5.4.23 Signal
2849  */
2850 static const value_string gsm_a_dtap_signal_value_vals[] = {
2851     { 0x00, "dial tone on" },
2852     { 0x01, "ring back tone on" },
2853     { 0x02, "intercept tone on" },
2854     { 0x03, "network congestion tone on" },
2855     { 0x04, "busy tone on" },
2856     { 0x05, "confirm tone on" },
2857     { 0x06, "answer tone on" },
2858     { 0x07, "call waiting tone on" },
2859     { 0x08, "off-hook warning tone on" },
2860     { 0x3f, "tones off" },
2861     { 0x4f, "alerting off" },
2862     { 0, NULL }
2863 };
2864
2865 static guint16
2866 de_signal(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2867 {
2868     proto_tree_add_item(tree, hf_gsm_a_dtap_signal_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2869
2870     return 1;
2871 }
2872
2873 /*
2874  * 10.5.4.24 SS Version Indicator
2875  */
2876 static const value_string gsm_a_dtap_ss_ver_ind_vals[] = {
2877     { 0x00, "Phase 2 service, ellipsis notation, and phase 2 error handling is supported" },
2878     { 0x01, "SS-Protocol version 3 is supported, and phase 2 error handling is supported" },
2879     { 0, NULL }
2880 };
2881
2882 static guint16
2883 de_ss_ver_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2884 {
2885     guint8       oct;
2886     guint32      curr_offset;
2887
2888     curr_offset = offset;
2889
2890     oct = tvb_get_guint8(tvb, curr_offset);
2891
2892     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_ss_version_indicator, tvb, curr_offset, 1,
2893         oct, "%s", val_to_str_const(oct, gsm_a_dtap_ss_ver_ind_vals, "Reserved"));
2894     curr_offset++;
2895
2896     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
2897
2898     return (curr_offset - offset);
2899 }
2900 /*
2901  * 10.5.4.25 User-user
2902  */
2903 /*
2904 User-user protocol discriminator (octet 3)
2905 Bits
2906 8   7   6   5   4   3   2   1
2907 0   0   0   0   0   0   0   0       User specific protocol (Note 1)
2908 0   0   0   0   0   0   0   1       OSI high layer protocols
2909 0   0   0   0   0   0   1   0       X.244 (Note 2)
2910 0   0   0   0   0   0   1   1       Reserved for system management convergence function
2911 0   0   0   0   0   1   0   0       IA5 characters (Note 3)
2912 0   0   0   0   0   1   1   1       Rec.V.120 rate adaption
2913 0   0   0   0   1   0   0   0       Q.931 (I.451) user-network call control messages
2914
2915 0   0   0   1   0   0   0   0       Reserved for other network layer or
2916 through     layer 3 protocols
2917 0   0   1   1   1   1   1   1
2918
2919 0   1   0   0   0   0   0   0
2920 through     National use
2921 0   1   0   0   1   1   1   0
2922 0   1   0   0   1   1   1   1       3GPP capability exchange protocol (NOTE 4)
2923
2924 0   1   0   1   0   0   0   0       Reserved for other network
2925 through     layer or layer 3 protocols
2926 1   1   1   1   1   1   1   0
2927
2928 All other values are reserved.
2929 */
2930 static const range_string gsm_a_dtap_u2u_prot_discr_vals[] = {
2931     { 0x00, 0x00, "User specific protocol" },
2932     { 0x01, 0x01, "OSI high layer protocols" },
2933     { 0x02, 0x02, "X.244" },
2934     { 0x03, 0x03, "Reserved for system management convergence function" },
2935     { 0x04, 0x04, "IA5 characters" },
2936     { 0x07, 0x07, "Rate adaption according to ITU-T Rec. V.120" },
2937     { 0x08, 0x08, "User-network call control messages according to ITU-T Rec. Q.931" },
2938     { 0x10, 0x3F, "Reserved for other network layer or layer 3 protocols" },
2939     { 0x40, 0x4E, "National use" },
2940     { 0x4F, 0x4F, "3GPP capability exchange protocol" },
2941     { 0x50, 0xFE, "Reserved for other network layer or layer 3 protocols" },
2942     { 0, 0, NULL }
2943 };
2944
2945 static guint16
2946 de_u2u(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2947 {
2948     guint32     curr_offset;
2949     proto_tree *subtree;
2950
2951     curr_offset = offset;
2952     proto_tree_add_item(tree, hf_gsm_a_dtap_u2u_prot_discr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2953     curr_offset++;
2954
2955     subtree = proto_tree_add_subtree(tree, tvb, curr_offset, len - 1, ett_gsm_dtap_elem[DE_USER_USER], NULL, "User-user information");
2956     proto_tree_add_item(subtree, hf_gsm_a_dtap_data, tvb, curr_offset, len - 1, ENC_NA);
2957
2958     return (len);
2959 }
2960 /*
2961  * 10.5.4.26 Alerting Pattern $(NIA)$
2962  */
2963 static const value_string gsm_a_alerting_pattern_vals[] = {
2964     { 0x00, "Alerting Pattern 1" },
2965     { 0x01, "Alerting Pattern 2" },
2966     { 0x02, "Alerting Pattern 3" },
2967     { 0x04, "Alerting Pattern 5" },
2968     { 0x05, "Alerting Pattern 6" },
2969     { 0x06, "Alerting Pattern 7" },
2970     { 0x07, "Alerting Pattern 8" },
2971     { 0x08, "Alerting Pattern 9" },
2972     { 0, NULL }
2973 };
2974
2975 static guint16
2976 de_alert_pat(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2977 {
2978     guint32 curr_offset;
2979
2980     curr_offset = offset;
2981
2982     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 4, ENC_BIG_ENDIAN);
2983     proto_tree_add_item(tree, hf_gsm_a_dtap_alerting_pattern, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2984     curr_offset++;
2985
2986     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
2987
2988     return (len);
2989 }
2990 /*
2991  * 10.5.4.27 Allowed actions $(CCBS)$
2992  */
2993 const true_false_string gsm_a_ccbs_activation_value = {
2994     "Activation of CCBS possible",
2995     "Activation of CCBS not possible"
2996 };
2997 static guint16
2998 de_allowed_act(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2999 {
3000     guint32 curr_offset;
3001
3002     curr_offset = offset;
3003
3004     proto_tree_add_item(tree, hf_gsm_a_dtap_ccbs_activation, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3005     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3) + 1, 7, ENC_BIG_ENDIAN);
3006
3007     curr_offset++;
3008
3009     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
3010
3011     return (len);
3012 }
3013 /*
3014  * 10.5.4.28 Stream Identifier
3015  */
3016 static guint16
3017 de_stream_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string, int string_len)
3018 {
3019     guint32 curr_offset;
3020     guint8 oct;
3021
3022     curr_offset = offset;
3023
3024     oct = tvb_get_guint8(tvb, curr_offset);
3025     if (oct == 0x00)
3026     {
3027         proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_stream_identifier, tvb, curr_offset, 1, oct,
3028             "No Bearer (%u)", oct);
3029
3030         if (add_string)
3031             g_snprintf(add_string, string_len, " - (No Bearer)");
3032     }
3033     else
3034     {
3035         proto_tree_add_item(tree, hf_gsm_a_dtap_stream_identifier, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3036
3037         if (add_string)
3038             g_snprintf(add_string, string_len, " - (%u)", oct);
3039     }
3040
3041     curr_offset++;
3042
3043     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
3044
3045     return (len);
3046 }
3047 /*
3048  * 10.5.4.29 Network Call Control Capabilities
3049  */
3050
3051 static const true_false_string gsm_a_mcs_value = {
3052     "This value indicates that the network supports the multicall",
3053     "This value indicates that the network does not support the multicall"
3054 };
3055 static guint16
3056 de_nw_call_ctrl_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3057 {
3058     guint32 curr_offset;
3059
3060     curr_offset = offset;
3061
3062     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 7, ENC_BIG_ENDIAN);
3063     proto_tree_add_item(tree, hf_gsm_a_dtap_mcs, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3064
3065     curr_offset++;
3066
3067     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
3068
3069     return (len);
3070 }
3071 /*
3072  * 10.5.4.30 Cause of No CLI
3073  */
3074 static const value_string gsm_a_cause_of_no_cli_values[] = {
3075     { 0x00, "Unavailable" },
3076     { 0x01, "Reject by user" },
3077     { 0x02, "Interaction with other service" },
3078     { 0x03, "Coin line/payphone" },
3079     { 0, NULL }
3080 };
3081
3082 static guint16
3083 de_ca_of_no_cli(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string, int string_len)
3084 {
3085     guint32 curr_offset;
3086     guint8  oct;
3087
3088     curr_offset = offset;
3089
3090     oct = tvb_get_guint8(tvb, curr_offset);
3091     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_cause_of_no_cli, tvb, curr_offset, 1, oct,
3092                    "%s (%u)",
3093                    val_to_str_const(oct, gsm_a_cause_of_no_cli_values, "Unavailable"),
3094                    oct);
3095
3096     curr_offset++;
3097
3098     if (add_string)
3099         g_snprintf(add_string, string_len, " - (%s)", val_to_str_const(oct, gsm_a_cause_of_no_cli_values, "Unavailable"));
3100
3101     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
3102
3103     return (len);
3104 }
3105 /*
3106  * 10.5.4.31 Void
3107  */
3108 /*
3109  * 10.5.4.32 Supported codec list
3110  */
3111 /* 6.1 System Identifiers for GSM and UMTS
3112  * The system identifiers for the radio access technologies
3113  * supported by this specification are:
3114  * SysID for GSM: 0x0000.0000 (bit 8 .. bit 1)
3115  * SysID for UMTS: 0x0000.0100 (bit 8 .. bit 1)
3116  * These values are selected in accordance with [7] (3GPP TS 28.062).
3117  */
3118 static const value_string gsm_a_dtap_sysid_values[] = {
3119     { 0x0,  "GSM" },
3120     { 0x4,  "UMTS" },
3121     { 0, NULL }
3122 };
3123 guint16
3124 de_sup_codec_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3125 {
3126     guint32     curr_offset;
3127     guint8      length;
3128     proto_tree *subtree;
3129     guint8      sysid_counter;
3130
3131     curr_offset = offset;
3132
3133     /*  System Identification 1 (SysID 1) octet 3
3134      * SysID indicates the radio access technology for which the subsequent Codec
3135      * Bitmap indicates the supported codec types.
3136      * Coding of this Octet is defined in 3GPP TS 26.103
3137      */
3138     sysid_counter = 0;
3139     while (len>(curr_offset-offset)) {
3140         sysid_counter++;
3141         proto_tree_add_item(tree, hf_gsm_a_dtap_sysid, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3142         curr_offset++;
3143         /*  Length Of Bitmap for SysID */
3144         proto_tree_add_item(tree, hf_gsm_a_dtap_bitmap_length, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3145         length = tvb_get_guint8(tvb,curr_offset);
3146         curr_offset++;
3147         if (length > 0)
3148         {
3149             subtree = proto_tree_add_subtree_format(tree, tvb, curr_offset, length, ett_gsm_dtap_elem[DE_SUP_CODEC_LIST], NULL,
3150                                                 "Codec Bitmap for SysID %u", sysid_counter);
3151             /* 6.2 Codec Bitmap
3152              * The Codec Types are coded in the first and second octet of the Codec List
3153              * Bitmap as follows:
3154              * 8         7         6        5       4       3       2       bit 1
3155              * TDMA      UMTS      UMTS     HR AMR  FR AMR  GSM EFR GSM HR  GSM FR Octet 1
3156              * EFR       AMR 2     AMR
3157              * bit 16    15        14       13      12      11      10      bit 9
3158              *(reserved) (reserved)OHR      OFR     OHR     UMTS    FR      PDC EFR Octet 2
3159              *                     AMR-WB   AMR-WB  AMR     AMR-WB  AMR-WB
3160              * A Codec Type is supported, if the corresponding bit is set to "1".
3161              * All reserved bits shall be set to "0".
3162              *
3163              * NOTE: If the Codec Bitmap for a SysID is 1 octet, it is an indication that
3164              * all codecs of the 2nd octet are not supported.
3165              * If the Codec Bitmap for a SysID is more than 2 octets, the network shall
3166              * ignore the additional octet(s) of the bitmap and process the rest of the
3167              * information element.
3168              *
3169              * Right now we are sure that at least the first octet of the bitmap is present
3170              */
3171             proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_tdma_efr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3172             proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_umts_amr_2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3173             proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_umts_amr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3174             proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_hr_amr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3175             proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_fr_amr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3176             proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_gsm_efr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3177             proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_gsm_hr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3178             proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_gsm_fr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3179             curr_offset++;
3180             length--;
3181
3182             if (length > 0)
3183             {
3184                 /*
3185                  * We can proceed with the second octet of the bitmap
3186                  */
3187                 proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, curr_offset << 3, 2, ENC_BIG_ENDIAN);
3188                 proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_ohr_amr_wb, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3189                 proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_ofr_amr_wb, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3190                 proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_ohr_amr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3191                 proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_umts_amr_wb, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3192                 proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_fr_amr_wb, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3193                 proto_tree_add_item(subtree, hf_gsm_a_dtap_codec_pdc_efr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3194                 curr_offset++;
3195                 length--;
3196             }
3197         }
3198
3199         curr_offset = curr_offset + length;
3200     }
3201
3202
3203     return (curr_offset-offset);
3204 }
3205 /*
3206  * 10.5.4.33 Service category
3207  */
3208 /*
3209 Emergency Service Category Value (octet 3)
3210 The meaning of the Emergency Category Value is derived from the following settings (see 3GPP TS 22.101 [8] clause
3211 10):
3212 Bit 1 Police
3213 Bit 2 Ambulance
3214 Bit 3 Fire Brigade
3215 Bit 4 Marine Guard
3216 Bit 5 Mountain Rescue
3217 Bit 6 manually initiated eCall
3218 Bit 7 automatically initiated eCall
3219 Bit 8 is spare and set to "0"
3220 */
3221 guint16
3222 de_serv_cat(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3223 {
3224     guint32 curr_offset;
3225
3226     curr_offset = offset;
3227
3228     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
3229     proto_tree_add_item(tree, hf_gsm_a_dtap_serv_cat_b7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3230     proto_tree_add_item(tree, hf_gsm_a_dtap_serv_cat_b6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3231     proto_tree_add_item(tree, hf_gsm_a_dtap_serv_cat_b5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3232     proto_tree_add_item(tree, hf_gsm_a_dtap_serv_cat_b4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3233     proto_tree_add_item(tree, hf_gsm_a_dtap_serv_cat_b3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3234     proto_tree_add_item(tree, hf_gsm_a_dtap_serv_cat_b2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3235     proto_tree_add_item(tree, hf_gsm_a_dtap_serv_cat_b1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3236     curr_offset++;
3237
3238     return len;
3239 }
3240 /*
3241  * 10.5.4.34 Redial
3242  * No data
3243  */
3244 /*
3245  * 10.5.4.35 Network-initiated Service Upgrade indicator
3246  * No data
3247  */
3248 /*
3249  * [5] 8.1.4.1 3GPP TS 24.011 version 6.1.0 Release 6
3250  */
3251 static guint16
3252 de_cp_user_data(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3253 {
3254     guint32   curr_offset;
3255     tvbuff_t *rp_tvb;
3256
3257     curr_offset = offset;
3258
3259     proto_tree_add_text(tree, tvb, curr_offset, len,
3260         "RPDU (not displayed)");
3261
3262     /*
3263      * dissect the embedded RP message
3264      */
3265     rp_tvb = tvb_new_subset_length(tvb, curr_offset, len);
3266
3267     call_dissector(rp_handle, rp_tvb, pinfo, g_tree);
3268
3269     curr_offset += len;
3270
3271     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
3272
3273     return (curr_offset - offset);
3274 }
3275
3276 /*
3277  * [5] 8.1.4.2
3278  */
3279 static const value_string gsm_a_dtap_cp_cause_values[] = {
3280     { 17, "Network failure"},
3281     { 22, "Congestion"},
3282     { 81, "Invalid Transaction Identifier value"},
3283     { 95, "Semantically incorrect message"},
3284     { 96, "Invalid mandatory information"},
3285     { 97, "Message type non-existent or not implemented"},
3286     { 98, "Message not compatible with the short message protocol state"},
3287     { 99, "Information element non-existent or not implemented"},
3288     { 111, "Protocol error, unspecified"},
3289     { 0, NULL }
3290 };
3291
3292 static guint16
3293 de_cp_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string, int string_len)
3294 {
3295     guint8       oct;
3296     guint32      curr_offset;
3297     const gchar *str;
3298
3299     curr_offset = offset;
3300
3301     oct = tvb_get_guint8(tvb, curr_offset);
3302     str = val_to_str_const(oct, gsm_a_dtap_cp_cause_values, "Reserved, treat as Protocol error, unspecified");
3303     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_cp_cause, tvb, curr_offset, 1,
3304         oct, "(%u) %s", oct, str);
3305     curr_offset++;
3306
3307     if (add_string)
3308         g_snprintf(add_string, string_len, " - (%u) %s", oct, str);
3309
3310     /* no length check possible */
3311
3312     return (curr_offset - offset);
3313 }
3314
3315 static guint16
3316 de_tp_sub_channel(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3317 {
3318     guint32      curr_offset;
3319     guchar       oct;
3320     const gchar *str;
3321
3322     curr_offset = offset;
3323
3324     oct = tvb_get_guint8(tvb, curr_offset) & 0x3f;
3325     if ((oct & 0x38) == 0x38)
3326         str = "I";
3327     else if ((oct & 0x38) == 0x18)
3328         str = "F";
3329     else if ((oct & 0x38) == 0x10)
3330         str = "E";
3331     else if ((oct & 0x38) == 0x08)
3332         str = "D";
3333     else if ((oct & 0x3c) == 0x04)
3334         str = "C";
3335     else if ((oct & 0x3e) == 0x02)
3336         str = "B";
3337     else if ((oct & 0x3e) == 0x00)
3338         str = "A";
3339     else
3340         str = "unknown";
3341
3342     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_test_loop, tvb, curr_offset, 1,
3343         oct, "%s", str);
3344
3345     if (oct & 0x01)
3346         proto_tree_add_text(tree,
3347             tvb, curr_offset, 1,
3348             "Only one TCH active or sub-channel 0 of two half rate channels is to be looped");
3349     else
3350         proto_tree_add_text(tree,
3351             tvb, curr_offset, 1,
3352             "Sub-channel 1 of two half rate channels is to be looped");
3353
3354     curr_offset+= 1;
3355
3356     return (curr_offset - offset);
3357 }
3358
3359 static guint16
3360 de_tp_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3361 {
3362     guint32 curr_offset;
3363     guchar  oct;
3364
3365     curr_offset = offset;
3366
3367     oct = tvb_get_guint8(tvb, curr_offset);
3368
3369     if ((oct & 0xF0) == 0x80)
3370         proto_tree_add_text(tree,tvb, curr_offset, 1, "Acknowledgment element: %d",oct&0x01);
3371     else
3372         proto_tree_add_text(tree,tvb, curr_offset, 1, "No acknowledgment element present");
3373
3374     curr_offset+= 1;
3375
3376     return (curr_offset - offset);
3377 }
3378
3379 static const value_string gsm_channel_coding_vals[] = {
3380     { 0x00, "not needed. The Burst-by-Burst loop is activated, type G" },
3381     { 0x01, "Channel coding needed. Frame erasure is to be signalled, type H" },
3382     { 0x02, "reserved" },
3383     { 0x03, "reserved" },
3384     { 0, NULL }
3385 };
3386
3387 static guint16
3388 de_tp_loop_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3389 {
3390     guint32 curr_offset;
3391     guchar  oct;
3392
3393     curr_offset = offset;
3394
3395     oct = tvb_get_guint8(tvb, curr_offset);
3396
3397     proto_tree_add_item(tree, hf_gsm_a_dtap_channel_coding03, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3398
3399     switch (oct & 0x1c)
3400     {
3401     case 0x00:
3402         proto_tree_add_text(tree, tvb, curr_offset, 1, "Multi-slot mechanism 1");
3403         proto_tree_add_text(tree, tvb, curr_offset, 1, "Timeslot number %d",(oct & 0xe0)>>5);
3404         break;
3405     case 0x04:
3406         proto_tree_add_text(tree, tvb, curr_offset, 1, "Multi-slot mechanism 2");
3407         break;
3408     default:
3409         proto_tree_add_text(tree, tvb, curr_offset, 1, "Loop mechanism reserved (%d)",(oct & 0x1c)>>2);
3410         break;
3411     }
3412
3413     curr_offset+= 1;
3414
3415     return (curr_offset - offset);
3416 }
3417
3418 static guint16
3419 de_tp_loop_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3420 {
3421     guint32 curr_offset;
3422     guchar  oct;
3423
3424     curr_offset = offset;
3425
3426     oct = tvb_get_guint8(tvb, curr_offset);
3427
3428     proto_tree_add_item(tree, hf_gsm_a_dtap_channel_coding30, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3429
3430     switch (oct & 0x0e)
3431     {
3432     case 0x00:
3433         proto_tree_add_text(tree, tvb, curr_offset, 1, "Multi-slot mechanism 1");
3434         break;
3435     case 0x02:
3436         proto_tree_add_text(tree, tvb, curr_offset, 1, "Multi-slot mechanism 2");
3437         break;
3438     default:
3439         proto_tree_add_text(tree, tvb, curr_offset, 1, "Loop mechanism reserved (%d)",(oct & 0x0e)>>1);
3440         break;
3441     }
3442
3443     if (oct & 0x01)
3444         proto_tree_add_text(tree, tvb, curr_offset, 1, "Multi-slot TCH loop was not closed due to error");
3445     else
3446         proto_tree_add_text(tree, tvb, curr_offset, 1, "Multi-slot TCH loop was closed successfully");
3447
3448     curr_offset+= 1;
3449
3450     return (curr_offset - offset);
3451 }
3452
3453 static const value_string gsm_tp_tested_device_vals[] = {
3454     { 0x00, "Normal operation (no tested device via DAI)" },
3455     { 0x01, "Test of speech decoder / DTX functions (downlink)" },
3456     { 0x02, "Test of speech encoder / DTX functions (uplink)" },
3457     { 0x03, "Test of acoustic devices and A/D & D/A" },
3458     { 0, NULL }
3459 };
3460
3461 static guint16
3462 de_tp_tested_device(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3463 {
3464     guint32 curr_offset;
3465     guchar  oct;
3466
3467     curr_offset = offset;
3468
3469     oct = tvb_get_guint8(tvb, curr_offset);
3470     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_tp_tested_device, tvb, curr_offset, 1,
3471         oct, "%s", val_to_str(oct, gsm_tp_tested_device_vals, "Reserved (%d)"));
3472     curr_offset+= 1;
3473
3474     return (curr_offset - offset);
3475 }
3476
3477 static guint16
3478 de_tp_pdu_description(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3479 {
3480     guint32 curr_offset;
3481     guint16 value;
3482
3483     curr_offset = offset;
3484
3485     value = tvb_get_ntohs(tvb, curr_offset);
3486     curr_offset += 2;
3487
3488     if (value & 0x8000)
3489     {
3490         if ((value & 0xfff) == 0)
3491             proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_tp_pdu_description,
3492                 tvb, curr_offset, 2, value, "Infinite number of PDUs to be transmitted in the TBF");
3493         else
3494             proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_tp_pdu_description,
3495                 tvb, curr_offset, 2, value & 0xfff, "%d PDUs to be transmitted in the TBF", value & 0xfff);
3496     }
3497     else
3498         proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_tp_pdu_description,
3499             tvb, curr_offset, 2, value, "reserved");
3500
3501     return (curr_offset - offset);
3502 }
3503
3504 static guint16
3505 de_tp_mode_flag(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3506 {
3507     guint32 curr_offset;
3508     guchar  oct;
3509
3510     curr_offset = offset;
3511
3512     oct = tvb_get_guint8(tvb, curr_offset);
3513
3514     if (oct & 0x01)
3515         proto_tree_add_text(tree, tvb, curr_offset, 1, "MS shall select the loop back option");
3516     else
3517         proto_tree_add_text(tree, tvb, curr_offset, 1, "MS shall itself generate the pseudorandom data");
3518
3519     proto_tree_add_item(tree, hf_gsm_a_dtap_downlink_timeslot_offset, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3520
3521     curr_offset+= 1;
3522
3523     return (curr_offset - offset);
3524 }
3525
3526 static guint16
3527 de_tp_egprs_mode_flag(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3528 {
3529     guint32 curr_offset;
3530     guchar  oct;
3531
3532     curr_offset = offset;
3533
3534     oct = tvb_get_guint8(tvb, curr_offset);
3535
3536     if (oct & 0x01)
3537         proto_tree_add_text(tree, tvb, curr_offset, 1, "MS loops back blocks on the uplink using GMSK modulation only");
3538     else
3539         proto_tree_add_text(tree, tvb, curr_offset, 1, "MS loops back blocks on the uplink using either GMSK or 8-PSK modulation following the detected received modulation");
3540
3541     proto_tree_add_item(tree, hf_gsm_a_dtap_downlink_timeslot_offset, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3542
3543     curr_offset+= 1;
3544
3545     return (curr_offset - offset);
3546 }
3547
3548 static const value_string gsm_positioning_technology_vals[] = {
3549     { 0x00, "AGPS" },
3550     { 0x01, "AGNSS" },
3551     { 0, NULL }
3552 };
3553
3554 static guint16
3555 de_tp_ms_positioning_technology(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3556 {
3557     guint32 curr_offset;
3558     guchar  oct;
3559
3560     curr_offset = offset;
3561
3562     oct = tvb_get_guint8(tvb, curr_offset);
3563     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_ms_positioning_technology, tvb, curr_offset, 1,
3564         oct, "%s", val_to_str(oct, gsm_positioning_technology_vals, "Reserved (%d)"));
3565     curr_offset+= 1;
3566
3567     return (curr_offset - offset);
3568 }
3569
3570 static guint16
3571 de_tp_ue_test_loop_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3572 {
3573     guint32 curr_offset;
3574     guchar  oct;
3575     guint8  lb_setup_length,i,j;
3576     guint16 value;
3577
3578     curr_offset = offset;
3579
3580     oct = tvb_get_guint8(tvb, curr_offset);
3581     curr_offset+= 1;
3582
3583     switch (oct & 0x03)
3584     {
3585     case 0:
3586     {
3587         proto_tree_add_text(tree, tvb, curr_offset, 1, "UE test loop mode 1 loop back (loopback of RLC SDUs or PDCP SDUs)");
3588         lb_setup_length = tvb_get_guint8(tvb, curr_offset);
3589         curr_offset += 1;
3590         for (i=0,j=0; (i<lb_setup_length) && (j<4); i+=3,j++)
3591         {
3592             proto_tree_add_text(tree, tvb, curr_offset, 1, "LB setup RB IE %d",j+1);
3593             value = tvb_get_ntohs(tvb, curr_offset);
3594             curr_offset += 2;
3595             proto_tree_add_text(tree, tvb, curr_offset, 1, "Uplink RLC SDU size is %d bits",value);
3596             oct = tvb_get_guint8(tvb, curr_offset);
3597             curr_offset+= 1;
3598             proto_tree_add_text(tree, tvb, curr_offset, 1, "Radio Bearer %d",oct & 0x1f);
3599         }
3600         break;
3601     }
3602     case 1:
3603         proto_tree_add_text(tree, tvb, curr_offset, 1, "UE test loop mode 2 loop back (loopback of transport block data and CRC bits)");
3604         break;
3605     case 2:
3606         proto_tree_add_text(tree, tvb, curr_offset, 1, "UE test loop mode 3 RLC SDU counting (counting of received RLC SDUs)");
3607         oct = tvb_get_guint8(tvb, curr_offset);
3608         curr_offset+= 1;
3609         proto_tree_add_text(tree, tvb, curr_offset, 1, "MBMS short transmission identity %d",(oct & 0x1f)+1);
3610         break;
3611     default:
3612         proto_tree_add_text(tree, tvb, curr_offset, 1, "UE test loop mode reserved (%d)",oct & 0x03);
3613         break;
3614     }
3615
3616     return (curr_offset - offset);
3617 }
3618
3619 static guint16
3620 de_tp_ue_positioning_technology(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3621 {
3622     guint32 curr_offset;
3623     guchar  oct;
3624
3625     curr_offset = offset;
3626
3627     oct = tvb_get_guint8(tvb, curr_offset);
3628
3629     proto_tree_add_uint_format_value(tree, hf_gsm_a_dtap_ue_positioning_technology, tvb, curr_offset, 1,
3630         oct, "%s", val_to_str(oct, gsm_positioning_technology_vals, "Reserved (%d)"));
3631     curr_offset+= 1;
3632
3633     return (curr_offset - offset);
3634 }
3635
3636 static guint16
3637 de_tp_rlc_sdu_counter_value(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3638 {
3639     guint32 curr_offset;
3640     guint32 value;
3641
3642     curr_offset = offset;
3643
3644     value = tvb_get_ntohl(tvb, curr_offset);
3645     curr_offset+= 4;
3646
3647     proto_tree_add_text(tree, tvb, curr_offset, 1, "UE received RLC SDU counter value: %d",value);
3648
3649     return (curr_offset - offset);
3650 }
3651
3652 static const value_string epc_ue_test_loop_mode_vals[] = {
3653     { 0,    "A"},
3654     { 1,    "B"},
3655     { 2,    "C"},
3656     { 3,    "reserved"},
3657     { 0, NULL }
3658 };
3659 static guint16
3660 de_tp_epc_ue_test_loop_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3661 {
3662     guint32 curr_offset;
3663     guint32 bit_offset;
3664
3665     curr_offset = offset;
3666     bit_offset = curr_offset<<3;
3667
3668     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 6, ENC_BIG_ENDIAN);
3669     bit_offset += 6;
3670     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_ue_tl_mode, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
3671     /*bit_offset += 2;*/
3672     /* Store test loop mode to know how to dissect Close UE Test Loop message */
3673     epc_test_loop_mode = tvb_get_guint8(tvb, curr_offset) & 0x03;
3674     curr_offset++;
3675
3676     return (curr_offset - offset);
3677 }
3678
3679 static guint16
3680 de_tp_epc_ue_tl_a_lb_setup(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3681 {
3682     guint32     curr_offset;
3683     guint32     count, nb_lb;
3684     guint8      drb;
3685     proto_tree *lb_setup_tree = NULL;
3686
3687     curr_offset = offset;
3688
3689     count = 0;
3690     nb_lb = len / 3;
3691
3692     proto_tree_add_text(tree, tvb, curr_offset, len, "Number of LB entities: %d", nb_lb);
3693     while ((count < nb_lb) && (count < 8)) {
3694         lb_setup_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, 3,
3695                                 ett_epc_ue_tl_a_lb_setup, NULL, "LB entity %d", count);
3696
3697         proto_tree_add_bits_item(lb_setup_tree, hf_gsm_a_dtap_epc_ue_tl_a_ul_sdu_size, tvb, curr_offset<<3, 16, ENC_BIG_ENDIAN);
3698         curr_offset += 2;
3699         drb = tvb_get_guint8(tvb, curr_offset) & 0x1f;
3700         proto_tree_add_uint_format_value(lb_setup_tree, hf_gsm_a_dtap_epc_ue_tl_a_drb, tvb, curr_offset, 1,
3701                                          drb, "%d (%d)", drb+1, drb);
3702         curr_offset++;
3703         count++;
3704     }
3705
3706     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_gsm_a_dtap_extraneous_data);
3707
3708     return (len);
3709 }
3710
3711 static guint16
3712 de_tp_epc_ue_tl_b_lb_setup(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3713 {
3714     guint32 curr_offset;
3715
3716     curr_offset = offset;
3717
3718     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_ue_tl_b_ip_pdu_delay, tvb, curr_offset<<3, 8, ENC_BIG_ENDIAN);
3719     curr_offset++;
3720
3721     return (curr_offset - offset);
3722 }
3723
3724 static guint16
3725 de_tp_epc_ue_tl_c_setup(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3726 {
3727     guint32 curr_offset;
3728
3729     curr_offset = offset;
3730
3731     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_ue_tl_c_mbsfn_area_id, tvb, curr_offset<<3, 8, ENC_BIG_ENDIAN);
3732     curr_offset++;
3733     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_ue_tl_c_mch_id, tvb, (curr_offset<<3)+4, 4, ENC_BIG_ENDIAN);
3734     curr_offset++;
3735     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_ue_tl_c_lcid, tvb, (curr_offset<<3)+3, 5, ENC_BIG_ENDIAN);
3736     curr_offset++;
3737
3738     return (curr_offset - offset);
3739 }
3740
3741 static const value_string epc_ue_positioning_technology_vals[] = {
3742     { 0,    "AGNSS"},
3743     { 1,    "OTDOA"},
3744     { 0, NULL }
3745 };
3746
3747 static guint16
3748 de_tp_epc_ue_positioning_technology(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3749 {
3750     guint32 curr_offset;
3751
3752     curr_offset = offset;
3753
3754     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_ue_positioning_technology, tvb, curr_offset<<3, 8, ENC_BIG_ENDIAN);
3755     curr_offset++;
3756
3757     return (curr_offset - offset);
3758 }
3759
3760 static guint16
3761 de_tp_epc_mbms_packet_counter_value(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3762 {
3763     guint32 curr_offset;
3764
3765     curr_offset = offset;
3766
3767     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_mbms_packet_counter_value, tvb, curr_offset<<3, 32, ENC_BIG_ENDIAN);
3768     curr_offset += 4;
3769
3770     return (curr_offset - offset);
3771 }
3772
3773 static const true_false_string epc_latitude_sign_value = {
3774     "South",
3775     "North"
3776 };
3777
3778 static const true_false_string epc_altitude_dir_value = {
3779     "Depth",
3780     "Height"
3781 };
3782
3783 static guint16
3784 de_tp_epc_ellipsoid_point_with_alt(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3785 {
3786     guint32 curr_offset;
3787     guint32 longitude;
3788
3789     curr_offset = offset;
3790
3791     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_latitude_sign, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
3792     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_degrees_latitude, tvb, (curr_offset<<3)+1, 23, ENC_BIG_ENDIAN);
3793     curr_offset += 3;
3794     longitude = tvb_get_ntoh24(tvb, curr_offset);
3795     proto_tree_add_int_format(tree, hf_gsm_a_dtap_epc_degrees_longitude, tvb, curr_offset, 3, longitude,
3796                               "%s = %s: %d", decode_bits_in_field(curr_offset<<3, 24, longitude),
3797                               proto_registrar_get_name(hf_gsm_a_dtap_epc_degrees_longitude), longitude-8388608);
3798     curr_offset += 3;
3799     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_altitude_dir, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
3800     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_altitude, tvb, (curr_offset<<3)+1, 15, ENC_BIG_ENDIAN);
3801     curr_offset += 2;
3802
3803     return (curr_offset - offset);
3804 }
3805
3806 static guint16
3807 de_tp_epc_horizontal_velocity(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3808 {
3809     guint32 curr_offset;
3810
3811     curr_offset = offset;
3812
3813     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_bearing, tvb, curr_offset<<3, 9, ENC_BIG_ENDIAN);
3814     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_horizontal_speed, tvb, (curr_offset<<3)+9, 11, ENC_BIG_ENDIAN);
3815     curr_offset += 3;
3816
3817     return (curr_offset - offset);
3818 }
3819
3820 static guint16
3821 de_tp_epc_gnss_tod_msec(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3822 {
3823     guint32 curr_offset;
3824
3825     curr_offset = offset;
3826
3827     proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_gnss_tod_msec, tvb, (curr_offset<<3)+2, 22, ENC_BIG_ENDIAN);
3828     curr_offset += 3;
3829
3830     return (curr_offset - offset);
3831 }
3832
3833 guint16 (*dtap_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) = {
3834     /* Mobility Management Information Elements 10.5.3 */
3835     de_auth_param_rand,                  /* Authentication Parameter RAND */
3836     de_auth_param_autn,                  /* Authentication Parameter AUTN (UMTS and EPS authentication challenge) */
3837     de_auth_resp_param,                  /* Authentication Response Parameter */
3838     de_auth_resp_param_ext,              /* Authentication Response Parameter (extension) (UMTS authentication challenge only) */
3839     de_auth_fail_param,                  /* Authentication Failure Parameter (UMTS and EPS authentication challenge) */
3840     NULL                                 /* handled inline */,  /* CM Service Type */
3841     NULL                                 /* handled inline */,  /* Identity Type */
3842     NULL                                 /* handled inline */,  /* Location Updating Type */
3843     de_network_name,                     /* Network Name */
3844     de_rej_cause,                        /* Reject Cause */
3845     NULL                                 /* no associated data */,  /* Follow-on Proceed */
3846     de_time_zone,                        /* Time Zone */
3847     de_time_zone_time,                   /* Time Zone and Time */
3848     NULL                                 /* no associated data */,  /* CTS Permission */
3849     de_lsa_id,                           /* LSA Identifier */
3850     de_day_saving_time,                  /* Daylight Saving Time */
3851     de_emerg_num_list,                   /* Emergency Number List */
3852     de_add_upd_params,                   /* Additional update parameters */
3853     de_mm_timer,                         /* MM Timer */
3854                                          /* Call Control Information Elements 10.5.4 */
3855     de_aux_states,                       /* Auxiliary States */
3856     de_bearer_cap,                       /* Bearer Capability */
3857     de_cc_cap,                           /* Call Control Capabilities */
3858     de_call_state,                       /* Call State */
3859     de_cld_party_bcd_num,                /* Called Party BCD Number */
3860     de_cld_party_sub_addr,               /* Called Party Subaddress */
3861     de_clg_party_bcd_num,                /* Calling Party BCD Number */
3862     de_clg_party_sub_addr,               /* Calling Party Subaddress */
3863     de_cause,                            /* Cause */
3864     NULL                                 /* no associated data */,  /* CLIR Suppression */
3865     NULL                                 /* no associated data */,  /* CLIR Invocation */
3866     NULL                                 /* handled inline */,  /* Congestion Level */
3867     de_conn_num,                         /* Connected Number */
3868     de_conn_sub_addr,                    /* Connected Subaddress */
3869     de_facility,                         /* Facility */
3870     de_hlc,                              /* High Layer Compatibility */
3871     de_keypad_facility,                  /* Keypad Facility */
3872     de_llc,                              /* 10.5.4.18 Low layer compatibility */
3873     NULL,                                /* More Data */
3874     de_notif_ind,                        /* Notification Indicator */
3875     de_prog_ind,                         /* Progress Indicator */
3876     de_recall_type,                      /* 10.5.4.21a Recall type $(CCBS)$ */
3877     de_red_party_bcd_num,                /* Redirecting Party BCD Number */
3878     de_red_party_sub_addr,               /* Redirecting Party Subaddress */
3879     de_repeat_ind,                       /* Repeat Indicator */
3880     NULL                                 /* no associated data */,  /* Reverse Call Setup Direction */
3881     de_setup_cont,                       /* SETUP Container $(CCBS)$ */
3882     de_signal,                           /* Signal */
3883     de_ss_ver_ind,                       /* SS Version Indicator */
3884     de_u2u,                              /* User-user */
3885     de_alert_pat,                        /* Alerting Pattern $(NIA)$ */
3886     de_allowed_act,                      /* Allowed Actions $(CCBS)$ */
3887     de_stream_id,                        /* Stream Identifier */
3888     de_nw_call_ctrl_cap,                 /* Network Call Control Capabilities */
3889     de_ca_of_no_cli,                     /* Cause of No CLI */
3890     de_sup_codec_list,                   /* Supported Codec List */
3891     de_serv_cat,                         /* Service Category */
3892     NULL,                                /* 10.5.4.34 Redial */
3893     NULL,                                /* 10.5.4.35 Network-initiated Service Upgrade ind */
3894                                          /* Short Message Service Information Elements [5] 8.1.4 */
3895     de_cp_user_data,                     /* CP-User Data */
3896     de_cp_cause,                         /* CP-Cause */
3897                                          /* Tests procedures information elements 3GPP TS 44.014 6.4.0 and 3GPP TS 34.109 6.4.0 */
3898     de_tp_sub_channel,                   /* Close TCH Loop Cmd Sub-channel */
3899     de_tp_ack,                           /* Open Loop Cmd Ack */
3900     de_tp_loop_type,                     /* Close Multi-slot Loop Cmd Loop type */
3901     de_tp_loop_ack,                      /* Close Multi-slot Loop Ack Result */
3902     de_tp_tested_device,                 /* Test Interface Tested device */
3903     de_tp_pdu_description,               /* GPRS Test Mode Cmd PDU description */
3904     de_tp_mode_flag,                     /* GPRS Test Mode Cmd Mode flag */
3905     de_tp_egprs_mode_flag,               /* EGPRS Start Radio Block Loopback Cmd Mode flag */
3906     de_tp_ms_positioning_technology,     /* MS Positioning Technology */
3907     de_tp_ue_test_loop_mode,             /* Close UE Test Loop Mode */
3908     de_tp_ue_positioning_technology,     /* UE Positioning Technology */
3909     de_tp_rlc_sdu_counter_value,         /* RLC SDU Counter Value */
3910     de_tp_epc_ue_test_loop_mode,         /* UE Test Loop Mode */
3911     de_tp_epc_ue_tl_a_lb_setup,          /* UE Test Loop Mode A LB Setup */
3912     de_tp_epc_ue_tl_b_lb_setup,          /* UE Test Loop Mode B LB Setup */
3913     de_tp_epc_ue_tl_c_setup,             /* UE Test Loop Mode C Setup */
3914     de_tp_epc_ue_positioning_technology, /* UE Positioning Technology */
3915     de_tp_epc_mbms_packet_counter_value, /* MBMS Packet Counter Value */
3916     de_tp_epc_ellipsoid_point_with_alt,  /* ellipsoidPointWithAltitude */
3917     de_tp_epc_horizontal_velocity,       /* horizontalVelocity */
3918     de_tp_epc_gnss_tod_msec,             /* gnss-TOD-msec */
3919     NULL,                                /* NONE */
3920 };
3921
3922 /* MESSAGE FUNCTIONS */
3923
3924 /*
3925  * [4] 9.2.2 Authentication request
3926  */
3927 static void
3928 dtap_mm_auth_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3929 {
3930     guint32     curr_offset;
3931     guint32     consumed;
3932     guint       curr_len;
3933     guint8      oct;
3934     proto_tree *subtree;
3935
3936     curr_offset = offset;
3937     curr_len = len;
3938
3939     is_uplink = IS_UPLINK_FALSE;
3940
3941     /*
3942      * special dissection for Cipher Key Sequence Number
3943      */
3944     oct = tvb_get_guint8(tvb, curr_offset);
3945
3946     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
3947
3948     subtree =
3949     proto_tree_add_subtree(tree,
3950         tvb, curr_offset, 1, ett_gsm_common_elem[DE_CIPH_KEY_SEQ_NUM], NULL,
3951         val_to_str_ext_const(DE_CIPH_KEY_SEQ_NUM, &gsm_common_elem_strings_ext, ""));
3952
3953     proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+4, 1, ENC_BIG_ENDIAN);
3954
3955     switch (oct & 0x07)
3956     {
3957     case 0x07:
3958         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_ciphering_key_sequence_number, tvb, curr_offset, 1,
3959             oct, "No key is available");
3960         break;
3961
3962     default:
3963         proto_tree_add_item(subtree, hf_gsm_a_dtap_ciphering_key_sequence_number, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3964         break;
3965     }
3966
3967     curr_offset++;
3968     curr_len--;
3969
3970     if ((signed)curr_len <= 0) return;
3971
3972     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_AUTH_PARAM_RAND, " - UMTS challenge or GSM challenge");
3973
3974     ELEM_OPT_TLV(0x20, GSM_A_PDU_TYPE_DTAP, DE_AUTH_PARAM_AUTN, NULL);
3975
3976     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
3977 }
3978
3979 /*
3980  * [4] 9.2.3 Authentication response
3981  */
3982 static void
3983 dtap_mm_auth_resp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3984 {
3985     guint32 curr_offset;
3986     guint32 consumed;
3987     guint   curr_len;
3988
3989     curr_offset = offset;
3990     curr_len = len;
3991
3992     is_uplink = IS_UPLINK_TRUE;
3993
3994     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM, NULL);
3995
3996     ELEM_OPT_TLV(0x21, GSM_A_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM_EXT, NULL);
3997
3998     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
3999 }
4000
4001 /*
4002  * [4] 9.2.3a Authentication Failure
4003  */
4004 static void
4005 dtap_mm_auth_fail(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4006 {
4007     guint32 curr_offset;
4008     guint32 consumed;
4009     guint   curr_len;
4010
4011     curr_offset = offset;
4012     curr_len = len;
4013
4014     is_uplink = IS_UPLINK_TRUE;
4015
4016     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_REJ_CAUSE, NULL);
4017
4018     ELEM_OPT_TLV(0x22, GSM_A_PDU_TYPE_DTAP, DE_AUTH_FAIL_PARAM, NULL);
4019
4020     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4021 }
4022
4023 /*
4024  * [3] 9.2.4 CM Re-establishment request
4025  */
4026 static void
4027 dtap_mm_cm_reestab_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4028 {
4029     guint32     curr_offset;
4030     guint32     consumed;
4031     guint       curr_len;
4032     guint8      oct;
4033     proto_tree *subtree;
4034
4035     curr_offset = offset;
4036     curr_len = len;
4037
4038     is_uplink = IS_UPLINK_TRUE;
4039
4040     /*
4041      * special dissection for Cipher Key Sequence Number
4042      */
4043     oct = tvb_get_guint8(tvb, curr_offset);
4044
4045     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
4046
4047     subtree =
4048     proto_tree_add_subtree(tree,
4049         tvb, curr_offset, 1, ett_gsm_common_elem[DE_CIPH_KEY_SEQ_NUM], NULL,
4050         val_to_str_ext_const(DE_CIPH_KEY_SEQ_NUM, &gsm_common_elem_strings_ext, ""));
4051
4052     proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+4, 1, ENC_BIG_ENDIAN);
4053
4054     switch (oct & 0x07)
4055     {
4056     case 0x07:
4057         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_ciphering_key_sequence_number, tvb, curr_offset, 1,
4058             oct, "No key is available");
4059         break;
4060
4061     default:
4062         proto_tree_add_item(subtree, hf_gsm_a_dtap_ciphering_key_sequence_number, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4063         break;
4064     }
4065
4066     curr_offset++;
4067     curr_len--;
4068
4069     if ((signed)curr_len <= 0) return;
4070
4071     ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL);
4072
4073     ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
4074
4075     ELEM_OPT_TV(0x13, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL);
4076
4077     ELEM_OPT_TV_SHORT(0xD0, GSM_A_PDU_TYPE_GM, DE_DEVICE_PROPERTIES, NULL);
4078
4079
4080     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4081 }
4082
4083 /*
4084  * [3] 9.2.5a CM service prompt $(CCBS)
4085  */
4086 static void
4087 dtap_mm_cm_srvc_prompt(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4088 {
4089     guint32 curr_offset;
4090     guint32 consumed;
4091     guint   curr_len;
4092
4093     curr_offset = offset;
4094     curr_len = len;
4095
4096     is_uplink = IS_UPLINK_FALSE;
4097
4098     ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_PD_SAPI, NULL);
4099
4100     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4101 }
4102
4103 /*
4104  * [4] 9.2.6 CM service reject
4105  */
4106 static void
4107 dtap_mm_cm_srvc_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4108 {
4109     guint32 curr_offset;
4110     guint32 consumed;
4111     guint   curr_len;
4112
4113     curr_offset = offset;
4114     curr_len = len;
4115
4116     is_uplink = IS_UPLINK_FALSE;
4117
4118     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_REJ_CAUSE, NULL);
4119
4120     ELEM_OPT_TLV(0x36, GSM_A_PDU_TYPE_DTAP, DE_MM_TIMER, " - T3246 value");
4121
4122     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4123 }
4124
4125 /*
4126  * [4] 9.2.8 Abort
4127  */
4128 static void
4129 dtap_mm_abort(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4130 {
4131     guint32 curr_offset;
4132     guint32 consumed;
4133     guint   curr_len;
4134
4135     curr_offset = offset;
4136     curr_len = len;
4137
4138     is_uplink = IS_UPLINK_FALSE;
4139
4140     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_REJ_CAUSE, NULL);
4141
4142     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4143 }
4144
4145 /*
4146  * [3] 9.2.9 CM service request
4147  */
4148 static const value_string gsm_a_dtap_service_type_vals[] = {
4149     { 0x00, "Reserved"},
4150     { 0x01, "Mobile originating call establishment or packet mode connection establishment"},
4151     { 0x02, "Emergency call establishment"},
4152     { 0x03, "Reserved"},
4153     { 0x04, "Short message service"},
4154     { 0x05, "Reserved"},
4155     { 0x06, "Reserved"},
4156     { 0x07, "Reserved"},
4157     { 0x08, "Supplementary service activation"},
4158     { 0x09, "Voice group call establishment"},
4159     { 0x0a, "Voice broadcast call establishment"},
4160     { 0x0b, "Location Services"},
4161     { 0x0c, "Reserved"},
4162     { 0x0d, "Reserved"},
4163     { 0x0e, "Reserved"},
4164     { 0x0f, "Reserved"},
4165     { 0, NULL }
4166 };
4167
4168 static void
4169 dtap_mm_cm_srvc_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4170 {
4171     guint32      curr_offset;
4172     guint32      consumed;
4173     guint        curr_len;
4174     guint8       oct;
4175     proto_tree  *subtree;
4176
4177     curr_offset = offset;
4178     curr_len = len;
4179
4180     is_uplink = IS_UPLINK_TRUE;
4181
4182     /*
4183      * special dissection for CM Service Type
4184      */
4185     oct = tvb_get_guint8(tvb, curr_offset);
4186
4187     subtree =
4188     proto_tree_add_subtree(tree,
4189         tvb, curr_offset, 1, ett_gsm_common_elem[DE_CIPH_KEY_SEQ_NUM], NULL,
4190         val_to_str_ext_const(DE_CIPH_KEY_SEQ_NUM, &gsm_common_elem_strings_ext, ""));
4191
4192     proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
4193
4194     switch ((oct & 0x70) >> 4)
4195     {
4196     case 0x07:
4197         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_ciphering_key_sequence_number70, tvb, curr_offset, 1,
4198             oct, "No key is available");
4199         break;
4200
4201     default:
4202         proto_tree_add_item(subtree, hf_gsm_a_dtap_ciphering_key_sequence_number70, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4203         break;
4204     }
4205
4206     subtree =
4207     proto_tree_add_subtree(tree,
4208         tvb, curr_offset, 1, ett_gsm_dtap_elem[DE_CM_SRVC_TYPE], NULL,
4209         val_to_str_ext_const(DE_CM_SRVC_TYPE, &gsm_dtap_elem_strings_ext, ""));
4210
4211     proto_tree_add_item(subtree, hf_gsm_a_dtap_service_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4212
4213     curr_offset++;
4214     curr_len--;
4215
4216     if ((signed)curr_len <= 0) return;
4217
4218     ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL);
4219
4220     ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
4221
4222     ELEM_OPT_TV_SHORT(0x80, GSM_A_PDU_TYPE_COMMON, DE_PRIO, NULL);
4223
4224     ELEM_OPT_TV_SHORT(0xC0, GSM_A_PDU_TYPE_DTAP, DE_ADD_UPD_PARAMS, NULL);
4225
4226     ELEM_OPT_TV_SHORT(0xD0, GSM_A_PDU_TYPE_GM, DE_DEVICE_PROPERTIES, NULL);
4227
4228     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4229 }
4230
4231 /*
4232  * [3] 9.2.10 Identity request
4233  */
4234 static const value_string gsm_a_dtap_type_of_identity_vals[] = {
4235     { 0x00, "Reserved"},
4236     { 0x01, "IMSI"},
4237     { 0x02, "IMEI"},
4238     { 0x03, "IMEISV"},
4239     { 0x04, "TMSI"},
4240     { 0x05, "P-TMSI, RAI, P-TMSI signature"},
4241     { 0x06, "Reserved"},
4242     { 0x07, "Reserved"},
4243     { 0, NULL }
4244 };
4245
4246 static void
4247 dtap_mm_id_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4248 {
4249     guint32      curr_offset;
4250     guint        curr_len;
4251     proto_tree  *subtree;
4252
4253     curr_offset = offset;
4254     curr_len = len;
4255
4256     is_uplink = IS_UPLINK_FALSE;
4257
4258     /*
4259      * special dissection for Identity Type
4260      */
4261     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
4262
4263     subtree =
4264     proto_tree_add_subtree(tree,
4265         tvb, curr_offset, 1, ett_gsm_dtap_elem[DE_ID_TYPE], NULL,
4266         val_to_str_ext_const(DE_ID_TYPE, &gsm_dtap_elem_strings_ext, ""));
4267
4268     proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+4, 1, ENC_BIG_ENDIAN);
4269     proto_tree_add_item(subtree, hf_gsm_a_dtap_type_of_identity, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4270
4271     curr_offset++;
4272     curr_len--;
4273
4274     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4275 }
4276
4277 /*
4278  * [3] 9.2.11 Identity response
4279  */
4280 static void
4281 dtap_mm_id_resp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4282 {
4283     guint32 curr_offset;
4284     guint32 consumed;
4285     guint   curr_len;
4286
4287     curr_offset = offset;
4288     curr_len = len;
4289
4290     is_uplink = IS_UPLINK_TRUE;
4291
4292     ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
4293
4294     ELEM_OPT_TV_SHORT(0xE0, GSM_A_PDU_TYPE_GM, DE_PTMSI_TYPE, NULL);
4295
4296     ELEM_OPT_TLV( 0x1B, GSM_A_PDU_TYPE_GM, DE_RAI_2, " - Routing area identification");
4297
4298     ELEM_OPT_TLV( 0x19, GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG_2, " - P-TMSI signature");
4299
4300     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4301 }
4302
4303 /*
4304  * [3] 9.2.12 IMSI detach indication
4305  */
4306 static void
4307 dtap_mm_imsi_det_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4308 {
4309     guint32 curr_offset;
4310     guint32 consumed;
4311     guint   curr_len;
4312
4313     curr_offset = offset;
4314     curr_len = len;
4315
4316     is_uplink = IS_UPLINK_TRUE;
4317
4318     ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_MS_CM_1, NULL);
4319
4320     ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
4321
4322     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4323 }
4324
4325 /*
4326  * [3] 9.2.13 Location updating accept
4327  */
4328 static void
4329 dtap_mm_loc_upd_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4330 {
4331     guint32 curr_offset;
4332     guint32 consumed;
4333     guint   curr_len;
4334
4335     curr_offset = offset;
4336     curr_len = len;
4337
4338     is_uplink = IS_UPLINK_FALSE;
4339
4340     ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL);
4341
4342     ELEM_OPT_TLV(0x17, GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
4343
4344     ELEM_OPT_T(0xa1, GSM_A_PDU_TYPE_DTAP, DE_FOP, NULL);
4345
4346     /* CTS permission O T 1 10.5.3.10 */
4347     ELEM_OPT_T(0xa2, GSM_A_PDU_TYPE_DTAP, DE_CTS_PERM, NULL);
4348
4349     /* PLMN list O TLV 5-47 10.5.1.13 */
4350     ELEM_OPT_TLV(0x4a, GSM_A_PDU_TYPE_COMMON, DE_PLMN_LIST, " Equivalent");
4351
4352     /* 34 Emergency Number List O TLV 5-50 10.5.3.13 */
4353     ELEM_OPT_TLV(0x34, GSM_A_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST, NULL);
4354
4355     ELEM_OPT_TLV(0x35, GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_3, " - Per MS T3212");
4356
4357     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4358 }
4359
4360 /*
4361  * [3] 9.2.14 Location updating reject
4362  */
4363 static void
4364 dtap_mm_loc_upd_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4365 {
4366     guint32 curr_offset;
4367     guint32 consumed;
4368     guint   curr_len;
4369
4370     curr_offset = offset;
4371     curr_len = len;
4372
4373     is_uplink = IS_UPLINK_FALSE;
4374
4375     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_REJ_CAUSE, NULL);
4376
4377     ELEM_OPT_TLV(0x36, GSM_A_PDU_TYPE_DTAP, DE_MM_TIMER, " - T3246 value");
4378
4379     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4380 }
4381
4382 /*
4383  * [3] 9.2.15 Location updating request
4384  */
4385 static const value_string gsm_a_dtap_updating_type_vals[] = {
4386     { 0x00, "Normal"},
4387     { 0x01, "Periodic"},
4388     { 0x02, "IMSI attach"},
4389     { 0x03, "Reserved"},
4390     { 0, NULL }
4391 };
4392
4393 static const true_false_string tfs_follow_on_request_value = {
4394     "Follow-on request pending",
4395     "No follow-on request pending"
4396 };
4397
4398 static void
4399 dtap_mm_loc_upd_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4400 {
4401     guint32 curr_offset;
4402     guint32 consumed;
4403     guint   curr_len;
4404     guint8  oct;
4405     proto_tree  *subtree;
4406     proto_item  *item;
4407
4408     curr_offset = offset;
4409     curr_len = len;
4410
4411     is_uplink = IS_UPLINK_TRUE;
4412
4413     /*
4414      * special dissection for Location Updating Type
4415      */
4416     oct = tvb_get_guint8(tvb, curr_offset);
4417
4418     subtree =
4419     proto_tree_add_subtree(tree,
4420         tvb, curr_offset, 1, ett_gsm_common_elem[DE_CIPH_KEY_SEQ_NUM], NULL,
4421         val_to_str_ext_const(DE_CIPH_KEY_SEQ_NUM, &gsm_common_elem_strings_ext, ""));
4422
4423     proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
4424
4425     switch ((oct & 0x70) >> 4)
4426     {
4427     case 0x07:
4428         proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_ciphering_key_sequence_number70, tvb, curr_offset, 1,
4429             oct, "No key is available");
4430         break;
4431
4432     default:
4433         proto_tree_add_item(subtree, hf_gsm_a_dtap_ciphering_key_sequence_number70, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4434         break;
4435     }
4436
4437     subtree =
4438     proto_tree_add_subtree(tree,
4439         tvb, curr_offset, 1, ett_gsm_dtap_elem[DE_LOC_UPD_TYPE], &item,
4440         val_to_str_ext_const(DE_LOC_UPD_TYPE, &gsm_dtap_elem_strings_ext, ""));
4441
4442     proto_tree_add_item(subtree, hf_gsm_a_dtap_follow_on_request, tvb, curr_offset, 1, ENC_NA);
4443
4444     proto_tree_add_bits_item(subtree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+5, 1, ENC_BIG_ENDIAN);
4445
4446     proto_tree_add_item(subtree, hf_gsm_a_dtap_updating_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4447
4448     proto_item_append_text(item, " - %s", val_to_str_const(oct & 0x03, gsm_a_dtap_updating_type_vals, "Reserved"));
4449
4450     curr_offset++;
4451     curr_len--;
4452
4453     if ((signed)curr_len <= 0) return;
4454
4455     ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL);
4456
4457     ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_MS_CM_1, NULL);
4458
4459     ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
4460
4461     ELEM_OPT_TLV(0x33, GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, " - Mobile station classmark for UMTS");
4462
4463     ELEM_OPT_TV_SHORT(0xc0, GSM_A_PDU_TYPE_DTAP, DE_ADD_UPD_PARAMS, NULL);
4464
4465     ELEM_OPT_TV_SHORT(0xD0, GSM_A_PDU_TYPE_GM, DE_DEVICE_PROPERTIES, NULL);
4466
4467     ELEM_OPT_TV_SHORT(0xC0, GSM_A_PDU_TYPE_COMMON, DE_MS_NET_FEAT_SUP, NULL);
4468
4469     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4470 }
4471
4472
4473 /*
4474  * [4] 9.2.15a MM information
4475  */
4476 void
4477 dtap_mm_mm_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4478 {
4479     guint32 curr_offset;
4480     guint32 consumed;
4481     guint   curr_len;
4482
4483     curr_offset = offset;
4484     curr_len = len;
4485
4486     is_uplink = IS_UPLINK_TRUE;
4487
4488     ELEM_OPT_TLV(0x43, GSM_A_PDU_TYPE_DTAP, DE_NETWORK_NAME, " - Full Name");
4489
4490     ELEM_OPT_TLV(0x45, GSM_A_PDU_TYPE_DTAP, DE_NETWORK_NAME, " - Short Name");
4491
4492     ELEM_OPT_TV(0x46, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE, " - Local");
4493
4494     ELEM_OPT_TV(0x47, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE_TIME, " - Universal Time and Local Time Zone");
4495
4496     ELEM_OPT_TLV(0x48, GSM_A_PDU_TYPE_DTAP, DE_LSA_ID, NULL);
4497
4498     ELEM_OPT_TLV(0x49, GSM_A_PDU_TYPE_DTAP, DE_DAY_SAVING_TIME, NULL);
4499
4500     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4501 }
4502
4503 /*
4504  * [4] 9.2.16 MM Status
4505  */
4506 static void
4507 dtap_mm_mm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4508 {
4509     guint32 curr_offset;
4510     guint32 consumed;
4511     guint   curr_len;
4512
4513     curr_offset = offset;
4514     curr_len = len;
4515
4516     is_uplink = IS_UPLINK_TRUE;
4517
4518     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_REJ_CAUSE, NULL);
4519
4520     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4521 }
4522
4523 /*
4524  * [3] 9.2.17 TMSI reallocation command
4525  */
4526 static void
4527 dtap_mm_tmsi_realloc_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4528 {
4529     guint32 curr_offset;
4530     guint32 consumed;
4531     guint   curr_len;
4532
4533     curr_offset = offset;
4534     curr_len = len;
4535
4536     is_uplink = IS_UPLINK_FALSE;
4537
4538     ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL);
4539
4540     ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
4541
4542     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4543 }
4544 /*
4545  * 9.2.18 TMSI reallocation complete
4546  * No data
4547  */
4548
4549 /*
4550  * 9.2.19 MM Null
4551  * No data
4552  */
4553
4554 /*
4555  * [4] 9.3.1 Alerting
4556  */
4557 static void
4558 dtap_cc_alerting(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4559 {
4560     guint32 curr_offset;
4561     guint32 consumed;
4562     guint   curr_len;
4563
4564     curr_offset = offset;
4565     curr_len = len;
4566
4567     is_uplink = IS_UPLINK_TRUE;
4568
4569     ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
4570
4571     ELEM_OPT_TLV(0x1e, GSM_A_PDU_TYPE_DTAP, DE_PROG_IND, NULL);
4572
4573     ELEM_OPT_TLV(0x7e, GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL);
4574
4575     /* uplink only */
4576
4577     ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL);
4578
4579     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4580 }
4581
4582 /*
4583  * [4] 9.3.2 Call confirmed
4584  */
4585 static void
4586 dtap_cc_call_conf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4587 {
4588     guint32 curr_offset;
4589     guint32 consumed;
4590     guint   curr_len;
4591
4592     curr_offset = offset;
4593     curr_len = len;
4594
4595     is_uplink = IS_UPLINK_TRUE;
4596
4597     ELEM_OPT_TV_SHORT(0xd0, GSM_A_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
4598
4599     ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
4600
4601     ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
4602
4603     ELEM_OPT_TLV(0x08, GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
4604
4605     ELEM_OPT_TLV(0x15, GSM_A_PDU_TYPE_DTAP, DE_CC_CAP, NULL);
4606
4607     ELEM_OPT_TLV(0x2d, GSM_A_PDU_TYPE_DTAP, DE_SI, NULL);
4608
4609     ELEM_OPT_TLV(0x40, GSM_A_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, NULL);
4610
4611     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4612 }
4613
4614 /*
4615  * [4] 9.3.3 Call proceeding
4616  */
4617 static void
4618 dtap_cc_call_proceed(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4619 {
4620     guint32 curr_offset;
4621     guint32 consumed;
4622     guint   curr_len;
4623
4624     curr_offset = offset;
4625     curr_len = len;
4626
4627     is_uplink = IS_UPLINK_FALSE;
4628
4629     ELEM_OPT_TV_SHORT(0xd0, GSM_A_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
4630
4631     ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
4632
4633     ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
4634
4635     ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
4636
4637     ELEM_OPT_TLV(0x1e, GSM_A_PDU_TYPE_DTAP, DE_PROG_IND, NULL);
4638
4639     ELEM_OPT_TV_SHORT(0x80, GSM_A_PDU_TYPE_COMMON, DE_PRIO, NULL);
4640
4641     ELEM_OPT_TLV(0x2f, GSM_A_PDU_TYPE_DTAP, DE_NET_CC_CAP, NULL);
4642
4643     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4644 }
4645
4646 /*
4647  * [4] 9.3.4 Congestion control
4648  */
4649 static const value_string gsm_a_dtap_congestion_level_vals[] = {
4650     { 0, "Receiver ready"},
4651     { 15, "Receiver not ready"},
4652     { 0, NULL }
4653 };
4654
4655 static void
4656 dtap_cc_congestion_control(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4657 {
4658     guint32      curr_offset;
4659     guint32      consumed;
4660     guint        curr_len;
4661     guint8       oct;
4662     proto_tree  *subtree;
4663
4664     curr_offset = offset;
4665     curr_len = len;
4666
4667     is_uplink = IS_UPLINK_FALSE;
4668
4669     /*
4670      * special dissection for Congestion Level
4671      */
4672     oct = tvb_get_guint8(tvb, curr_offset);
4673
4674     proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
4675
4676     subtree =
4677     proto_tree_add_subtree(tree,
4678             tvb, curr_offset, 1, ett_gsm_dtap_elem[DE_CONGESTION], NULL,
4679             val_to_str_ext_const(DE_CONGESTION, &gsm_dtap_elem_strings_ext, ""));
4680
4681     proto_tree_add_uint_format_value(subtree, hf_gsm_a_dtap_congestion_level, tvb, curr_offset, 1,
4682         oct, "%s", val_to_str_const(oct & 0xF, gsm_a_dtap_congestion_level_vals, "Reserved"));
4683
4684     curr_offset++;
4685     curr_len--;
4686
4687     if ((signed)curr_len <= 0) return;
4688
4689     ELEM_OPT_TLV(0x08, GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
4690
4691     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4692 }
4693
4694 /*
4695  * [4] 9.3.5 Connect
4696  */
4697 static void
4698 dtap_cc_connect(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4699 {
4700     guint32 curr_offset;
4701     guint32 consumed;
4702     guint   curr_len;
4703
4704     curr_offset = offset;
4705     curr_len = len;
4706
4707     is_uplink = IS_UPLINK_TRUE;
4708
4709     ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
4710
4711     ELEM_OPT_TLV(0x1e, GSM_A_PDU_TYPE_DTAP, DE_PROG_IND, NULL);
4712
4713     ELEM_OPT_TLV(0x4c, GSM_A_PDU_TYPE_DTAP, DE_CONN_NUM, NULL);
4714
4715     ELEM_OPT_TLV(0x4d, GSM_A_PDU_TYPE_DTAP, DE_CONN_SUB_ADDR, NULL);
4716
4717     ELEM_OPT_TLV(0x7e, GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL);
4718
4719     /* uplink only */
4720
4721     ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL);
4722
4723     ELEM_OPT_TLV(0x2d, GSM_A_PDU_TYPE_DTAP, DE_SI, NULL);
4724
4725     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4726 }
4727
4728 /*
4729  * [4] 9.3.7 Disconnect
4730  */
4731 static void
4732 dtap_cc_disconnect(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4733 {
4734     guint32 curr_offset;
4735     guint32 consumed;
4736     guint   curr_len;
4737
4738     curr_offset = offset;
4739     curr_len = len;
4740
4741     is_uplink = IS_UPLINK_TRUE;
4742
4743     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
4744
4745     ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
4746
4747     ELEM_OPT_TLV(0x1e, GSM_A_PDU_TYPE_DTAP, DE_PROG_IND, NULL);
4748
4749     ELEM_OPT_TLV(0x7e, GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL);
4750
4751     ELEM_OPT_TLV(0x7b, GSM_A_PDU_TYPE_DTAP, DE_ALLOWED_ACTIONS, NULL);
4752
4753     /* uplink only */
4754
4755     ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL);
4756
4757     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4758 }
4759
4760 /*
4761  * [4] 9.3.8 Emergency setup
4762  */
4763 static void
4764 dtap_cc_emerg_setup(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4765 {
4766     guint32 curr_offset;
4767     guint32 consumed;
4768     guint   curr_len;
4769
4770     curr_offset = offset;
4771     curr_len = len;
4772
4773     is_uplink = IS_UPLINK_TRUE;
4774
4775     ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, NULL);
4776
4777     ELEM_OPT_TLV(0x2d, GSM_A_PDU_TYPE_DTAP, DE_SI, NULL);
4778
4779     ELEM_OPT_TLV(0x40, GSM_A_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, NULL);
4780
4781     ELEM_OPT_TLV(0x2e, GSM_A_PDU_TYPE_DTAP, DE_SERV_CAT, " - Emergency category");
4782
4783     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4784 }
4785
4786 /*
4787  * [4] 9.3.9 Facility
4788  */
4789 static void
4790 dtap_cc_facility(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4791 {
4792     guint32 curr_offset;
4793     guint32 consumed;
4794     guint   curr_len;
4795
4796     curr_offset = offset;
4797     curr_len = len;
4798
4799     is_uplink = IS_UPLINK_TRUE;
4800
4801     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
4802
4803     /* uplink only */
4804
4805     ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL);
4806
4807     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4808 }
4809 /*
4810  * 9.3.10 Hold
4811  * No data
4812  */
4813 /*
4814  * 9.3.11 Hold Acknowledge
4815  */
4816 /*
4817  * [4] 9.3.12 Hold Reject
4818  */
4819 static void
4820 dtap_cc_hold_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4821 {
4822     guint32 curr_offset;
4823     guint32 consumed;
4824     guint   curr_len;
4825
4826     curr_offset = offset;
4827     curr_len = len;
4828
4829     is_uplink = IS_UPLINK_FALSE;
4830
4831     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
4832
4833     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4834 }
4835
4836 /*
4837  * [4] 9.3.13 Modify
4838  */
4839 static void
4840 dtap_cc_modify(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4841 {
4842     guint32 curr_offset;
4843     guint32 consumed;
4844     guint   curr_len;
4845
4846     curr_offset = offset;
4847     curr_len = len;
4848
4849     is_uplink = IS_UPLINK_TRUE;
4850
4851     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, NULL);
4852
4853     ELEM_OPT_TLV(0x7c, GSM_A_PDU_TYPE_DTAP, DE_LLC, NULL);
4854
4855     ELEM_OPT_TLV(0x7d, GSM_A_PDU_TYPE_DTAP, DE_HLC, NULL);
4856
4857     ELEM_OPT_T(0xa3, GSM_A_PDU_TYPE_DTAP, DE_REV_CALL_SETUP_DIR, NULL);
4858
4859     ELEM_OPT_T(0xa4, GSM_A_PDU_TYPE_DTAP, DE_NET_INIT_SERV_UPG, NULL);
4860
4861     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4862 }
4863
4864 /*
4865  * [4] 9.3.14 Modify complete
4866  */
4867 static void
4868 dtap_cc_modify_complete(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4869 {
4870     guint32 curr_offset;
4871     guint32 consumed;
4872     guint   curr_len;
4873
4874     curr_offset = offset;
4875     curr_len = len;
4876
4877     is_uplink = IS_UPLINK_TRUE;
4878
4879     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, NULL);
4880
4881     ELEM_OPT_TLV(0x7c, GSM_A_PDU_TYPE_DTAP, DE_LLC, NULL);
4882
4883     ELEM_OPT_TLV(0x7d, GSM_A_PDU_TYPE_DTAP, DE_HLC, NULL);
4884
4885     ELEM_OPT_T(0xa3, GSM_A_PDU_TYPE_DTAP, DE_REV_CALL_SETUP_DIR, NULL);
4886
4887     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4888 }
4889
4890 /*
4891  * [4] 9.3.15 Modify reject
4892  */
4893 static void
4894 dtap_cc_modify_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4895 {
4896     guint32 curr_offset;
4897     guint32 consumed;
4898     guint   curr_len;
4899
4900     curr_offset = offset;
4901     curr_len = len;
4902
4903     is_uplink = IS_UPLINK_FALSE;
4904
4905     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, NULL);
4906
4907     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
4908
4909     ELEM_OPT_TLV(0x7c, GSM_A_PDU_TYPE_DTAP, DE_LLC, NULL);
4910
4911     ELEM_OPT_TLV(0x7d, GSM_A_PDU_TYPE_DTAP, DE_HLC, NULL);
4912
4913     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4914 }
4915
4916 /*
4917  * [4] 9.3.16 Notify
4918  */
4919 static void
4920 dtap_cc_notify(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4921 {
4922     guint32 curr_offset;
4923     guint32 consumed;
4924     guint   curr_len;
4925
4926     curr_offset = offset;
4927     curr_len = len;
4928
4929     is_uplink = IS_UPLINK_FALSE;
4930
4931     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_NOT_IND, NULL);
4932
4933     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4934 }
4935
4936 /*
4937  * [4] 9.3.17 Progress
4938  */
4939 static void
4940 dtap_cc_progress(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4941 {
4942     guint32 curr_offset;
4943     guint32 consumed;
4944     guint   curr_len;
4945
4946     curr_offset = offset;
4947     curr_len = len;
4948
4949     is_uplink = IS_UPLINK_FALSE;
4950
4951     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_PROG_IND, NULL);
4952
4953     ELEM_OPT_TLV(0x7e, GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL);
4954
4955     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4956 }
4957
4958 /*
4959  * [4] 9.3.17a CC-Establishment $(CCBS)$
4960  */
4961 static void
4962 dtap_cc_cc_est(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4963 {
4964     guint32 curr_offset;
4965     guint32 consumed;
4966     guint   curr_len;
4967
4968     curr_offset = offset;
4969     curr_len = len;
4970
4971     is_uplink = IS_UPLINK_FALSE;
4972
4973     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_SETUP_CONTAINER, NULL);
4974
4975     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
4976 }
4977
4978 /*
4979  * [4] 9.3.17b CC-Establishment confirmed $(CCBS)$
4980  */
4981 static void
4982 dtap_cc_cc_est_conf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4983 {
4984     guint32 curr_offset;
4985     guint32 consumed;
4986     guint   curr_len;
4987
4988     curr_offset = offset;
4989     curr_len = len;
4990
4991     is_uplink = IS_UPLINK_TRUE;
4992
4993     ELEM_OPT_TV_SHORT(0xd0, GSM_A_PDU_TYPE_DTAP, DE_REPEAT_IND, " Repeat indicator");
4994
4995     ELEM_MAND_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1", ei_gsm_a_dtap_missing_mandatory_element);
4996
4997     ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
4998
4999     ELEM_OPT_TLV(0x08, GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
5000
5001     ELEM_OPT_TLV(0x40, GSM_A_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, NULL);
5002
5003     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5004 }
5005
5006 /*
5007  * [4] 9.3.18 Release
5008  */
5009 static void
5010 dtap_cc_release(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5011 {
5012     guint32 curr_offset;
5013     guint32 consumed;
5014     guint   curr_len;
5015
5016     curr_offset = offset;
5017     curr_len = len;
5018
5019     is_uplink = IS_UPLINK_TRUE;
5020
5021     ELEM_OPT_TLV(0x08, GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
5022
5023     ELEM_OPT_TLV(0x08, GSM_A_PDU_TYPE_DTAP, DE_CAUSE, " 2");
5024
5025     ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
5026
5027     ELEM_OPT_TLV(0x7e, GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL);
5028
5029     /* uplink only */
5030
5031     ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL);
5032
5033     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5034 }
5035
5036 /*
5037  * [4] 9.3.18a Recall $(CCBS)$
5038  */
5039 static void
5040 dtap_cc_recall(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5041 {
5042     guint32 curr_offset;
5043     guint32 consumed;
5044     guint   curr_len;
5045
5046     curr_offset = offset;
5047     curr_len = len;
5048
5049     is_uplink = IS_UPLINK_FALSE;
5050
5051     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_RECALL_TYPE, NULL);
5052
5053     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
5054
5055     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5056 }
5057
5058 /*
5059  * [4] 9.3.19 Release complete
5060  */
5061 static void
5062 dtap_cc_release_complete(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5063 {
5064     guint32 curr_offset;
5065     guint32 consumed;
5066     guint   curr_len;
5067
5068     curr_offset = offset;
5069     curr_len = len;
5070
5071     is_uplink = IS_UPLINK_FALSE;
5072
5073     ELEM_OPT_TLV(0x08, GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
5074
5075     ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
5076
5077     ELEM_OPT_TLV(0x7e, GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL);
5078
5079     /* uplink only */
5080
5081     ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL);
5082
5083     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5084 }
5085
5086 /*
5087  * [4] 9.3.22 Retrieve
5088  */
5089 static void
5090 dtap_cc_retrieve_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5091 {
5092     guint32 curr_offset;
5093     guint32 consumed;
5094     guint   curr_len;
5095
5096     curr_offset = offset;
5097     curr_len = len;
5098
5099     is_uplink = IS_UPLINK_FALSE;
5100
5101     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
5102
5103     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5104 }
5105
5106 /*
5107  * 9.3.21 Retrieve Acknowledge
5108  * No data
5109  */
5110 /*
5111  * 9.3.22 Retrieve Reject
5112  * No data
5113  */
5114 /*
5115  * [4] 9.3.23 Setup
5116  * 3GPP TS 24.008 version 7.5.0 Release 7
5117  */
5118 static void
5119 dtap_cc_setup(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5120 {
5121     guint32 curr_offset;
5122     guint32 consumed;
5123     guint   curr_len;
5124
5125     curr_offset = offset;
5126     curr_len = len;
5127
5128     is_uplink = IS_UPLINK_TRUE;
5129
5130     ELEM_OPT_TV_SHORT(0xd0, GSM_A_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
5131
5132     ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
5133
5134     ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
5135
5136     ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL);
5137
5138     ELEM_OPT_TLV(0x1e, GSM_A_PDU_TYPE_DTAP, DE_PROG_IND, NULL);
5139
5140     ELEM_OPT_TV(0x34, GSM_A_PDU_TYPE_DTAP, DE_SIGNAL, NULL);
5141
5142     ELEM_OPT_TLV(0x5c, GSM_A_PDU_TYPE_DTAP, DE_CLG_PARTY_BCD_NUM, NULL);
5143
5144     ELEM_OPT_TLV(0x5d, GSM_A_PDU_TYPE_DTAP, DE_CLG_PARTY_SUB_ADDR, NULL);
5145
5146     ELEM_OPT_TLV(0x5e, GSM_A_PDU_TYPE_DTAP, DE_CLD_PARTY_BCD_NUM, NULL);
5147
5148     ELEM_OPT_TLV(0x6d, GSM_A_PDU_TYPE_DTAP, DE_CLD_PARTY_SUB_ADDR, NULL);
5149
5150     ELEM_OPT_TLV(0x74, GSM_A_PDU_TYPE_DTAP, DE_RED_PARTY_BCD_NUM, NULL);
5151
5152     ELEM_OPT_TLV(0x75, GSM_A_PDU_TYPE_DTAP, DE_RED_PARTY_SUB_ADDR, NULL);
5153
5154     ELEM_OPT_TV_SHORT(0xd0, GSM_A_PDU_TYPE_DTAP, DE_REPEAT_IND, " LLC repeat indicator");
5155
5156     ELEM_OPT_TLV(0x7c, GSM_A_PDU_TYPE_DTAP, DE_LLC, " 1");
5157
5158     ELEM_OPT_TLV(0x7c, GSM_A_PDU_TYPE_DTAP, DE_LLC, " 2");
5159
5160     ELEM_OPT_TV_SHORT(0xd0, GSM_A_PDU_TYPE_DTAP, DE_REPEAT_IND, " HLC repeat indicator");
5161
5162     ELEM_OPT_TLV(0x7d, GSM_A_PDU_TYPE_DTAP, DE_HLC, " 1");
5163
5164     ELEM_OPT_TLV(0x7d, GSM_A_PDU_TYPE_DTAP, DE_HLC, " 2");
5165
5166     ELEM_OPT_TLV(0x7e, GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL);
5167
5168     /* downlink only */
5169
5170     ELEM_OPT_TV_SHORT(0x80, GSM_A_PDU_TYPE_COMMON, DE_PRIO, NULL);
5171
5172     ELEM_OPT_TLV(0x19, GSM_A_PDU_TYPE_DTAP, DE_ALERT_PATTERN, NULL);
5173
5174     ELEM_OPT_TLV(0x2f, GSM_A_PDU_TYPE_DTAP, DE_NET_CC_CAP, NULL);
5175
5176     ELEM_OPT_TLV(0x3a, GSM_A_PDU_TYPE_DTAP, DE_CAUSE_NO_CLI, NULL);
5177
5178     /* Backup bearer capability O TLV 3-15 10.5.4.4a */
5179     ELEM_OPT_TLV(0x41, GSM_A_PDU_TYPE_DTAP, DE_BEARER_CAP, NULL);
5180
5181     /* uplink only */
5182
5183     ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL);
5184
5185     ELEM_OPT_T(0xa1, GSM_A_PDU_TYPE_DTAP, DE_CLIR_SUP, NULL);
5186
5187     ELEM_OPT_T(0xa2, GSM_A_PDU_TYPE_DTAP, DE_CLIR_INV, NULL);
5188
5189     ELEM_OPT_TLV(0x15, GSM_A_PDU_TYPE_DTAP, DE_CC_CAP, NULL);
5190
5191     ELEM_OPT_TLV(0x1d, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, " $(CCBS)$ (advanced recall alignment)");
5192
5193     ELEM_OPT_TLV(0x1b, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, " (recall alignment Not essential) $(CCBS)$");
5194
5195     ELEM_OPT_TLV(0x2d, GSM_A_PDU_TYPE_DTAP, DE_SI, NULL);
5196
5197     ELEM_OPT_TLV(0x40, GSM_A_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, NULL);
5198
5199     /*A3 Redial O T 1 10.5.4.34 */
5200     ELEM_OPT_T(0xA3, GSM_A_PDU_TYPE_DTAP, DE_REDIAL, NULL);
5201
5202     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5203 }
5204
5205 /*
5206  * [4] 9.3.23a Start CC $(CCBS)$
5207  */
5208 static void
5209 dtap_cc_start_cc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5210 {
5211     guint32 curr_offset;
5212     guint32 consumed;
5213     guint   curr_len;
5214
5215     curr_offset = offset;
5216     curr_len = len;
5217
5218     is_uplink = IS_UPLINK_FALSE;
5219
5220     ELEM_OPT_TLV(0x15, GSM_A_PDU_TYPE_DTAP, DE_CC_CAP, NULL);
5221
5222     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5223 }
5224
5225 /*
5226  * [4] 9.3.24 Start DTMF
5227  */
5228 static void
5229 dtap_cc_start_dtmf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5230 {
5231     guint32 curr_offset;
5232     guint32 consumed;
5233     guint   curr_len;
5234
5235     curr_offset = offset;
5236     curr_len = len;
5237
5238     is_uplink = IS_UPLINK_TRUE;
5239
5240     ELEM_MAND_TV(0x2c, GSM_A_PDU_TYPE_DTAP, DE_KEYPAD_FACILITY, NULL, ei_gsm_a_dtap_missing_mandatory_element);
5241
5242     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5243 }
5244
5245 /*
5246  * [4] 9.3.25 Start DTMF Acknowledge
5247  */
5248 static void
5249 dtap_cc_start_dtmf_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5250 {
5251     guint32 curr_offset;
5252     guint32 consumed;
5253     guint   curr_len;
5254
5255     curr_offset = offset;
5256     curr_len = len;
5257
5258     is_uplink = IS_UPLINK_FALSE;
5259
5260     ELEM_MAND_TV(0x2c, GSM_A_PDU_TYPE_DTAP, DE_KEYPAD_FACILITY, NULL, ei_gsm_a_dtap_missing_mandatory_element);
5261
5262     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5263 }
5264
5265 /*
5266  * [4] 9.3.26 Start DTMF reject
5267  */
5268 static void
5269 dtap_cc_start_dtmf_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5270 {
5271     guint32 curr_offset;
5272     guint32 consumed;
5273     guint   curr_len;
5274
5275     curr_offset = offset;
5276     curr_len = len;
5277
5278     is_uplink = IS_UPLINK_FALSE;
5279
5280     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
5281
5282     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5283 }
5284
5285 /*
5286  * [4] 9.3.27 Status
5287  */
5288 static void
5289 dtap_cc_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5290 {
5291     guint32 curr_offset;
5292     guint32 consumed;
5293     guint   curr_len;
5294
5295     curr_offset = offset;
5296     curr_len = len;
5297
5298     is_uplink = IS_UPLINK_FALSE;
5299
5300     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_CAUSE, NULL);
5301
5302     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_CALL_STATE, NULL);
5303
5304     ELEM_OPT_TLV(0x24, GSM_A_PDU_TYPE_DTAP, DE_AUX_STATES, NULL);
5305
5306     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5307 }
5308 /*
5309  * 9.3.28 Status enquiry
5310  * No data
5311  */
5312 /*
5313  * 9.3.29 Stop DTMF
5314  * No data
5315  */
5316 /*
5317  * Stop DTMF acknowledge
5318  * No data
5319  */
5320 /*
5321  * [4] 9.3.31 User information
5322  */
5323 static void
5324 dtap_cc_user_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5325 {
5326     guint32 curr_offset;
5327     guint32 consumed;
5328     guint   curr_len;
5329
5330     curr_offset = offset;
5331     curr_len = len;
5332
5333     is_uplink = IS_UPLINK_TRUE;
5334
5335     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL);
5336
5337     ELEM_OPT_T(0xa0, GSM_A_PDU_TYPE_DTAP, DE_MORE_DATA, NULL);
5338
5339     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5340 }
5341
5342 /*
5343  * 3GPP TS 24.080
5344  * [6] 2.4.2
5345  */
5346 static void
5347 dtap_ss_register(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5348 {
5349     guint32 curr_offset;
5350     guint32 consumed;
5351     guint   curr_len;
5352
5353     curr_offset = offset;
5354     curr_len = len;
5355
5356     is_uplink = IS_UPLINK_TRUE;
5357
5358     ELEM_MAND_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL, ei_gsm_a_dtap_missing_mandatory_element);
5359
5360     ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL);
5361
5362     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5363 }
5364
5365 /*
5366  * 3GPP TS 24.011
5367  * [5] 7.2.1
5368  */
5369 static void
5370 dtap_sms_cp_data(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5371 {
5372     guint32 curr_offset;
5373     guint32 consumed;
5374     guint   curr_len;
5375
5376     curr_offset = offset;
5377     curr_len = len;
5378
5379     is_uplink = IS_UPLINK_TRUE;
5380
5381     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_CP_USER_DATA, NULL);
5382
5383     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5384 }
5385
5386 /*
5387  * [5] 7.2.3
5388  */
5389 static void
5390 dtap_sms_cp_error(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5391 {
5392     guint32 curr_offset;
5393     guint32 consumed;
5394     guint   curr_len;
5395
5396     curr_offset = offset;
5397     curr_len = len;
5398
5399     is_uplink = IS_UPLINK_TRUE;
5400
5401     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_CP_CAUSE, NULL);
5402
5403     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5404 }
5405
5406 static void
5407 dtap_tp_close_tch_loop_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5408 {
5409     guint32 curr_offset;
5410     guint32 consumed;
5411     guint   curr_len;
5412
5413     curr_len = len;
5414     curr_offset = offset;
5415
5416     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_SUB_CHANNEL, NULL);
5417
5418     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5419 }
5420
5421 static void
5422 dtap_tp_open_loop_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5423 {
5424     guint32 curr_offset;
5425     guint32 consumed;
5426     guint   curr_len;
5427
5428     curr_len = len;
5429     curr_offset = offset;
5430
5431     if (curr_len)
5432         ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_ACK, NULL);
5433
5434     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5435 }
5436
5437 static void
5438 dtap_tp_multi_slot_loop_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5439 {
5440     guint32 curr_offset;
5441     guint32 consumed;
5442     guint   curr_len;
5443
5444     curr_len = len;
5445     curr_offset = offset;
5446
5447     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_LOOP_TYPE, NULL);
5448
5449     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5450 }
5451
5452 static void
5453 dtap_tp_multi_slot_loop_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5454 {
5455     guint32 curr_offset;
5456     guint32 consumed;
5457     guint   curr_len;
5458
5459     curr_len = len;
5460     curr_offset = offset;
5461
5462     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_LOOP_ACK, NULL);
5463
5464     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5465 }
5466
5467 static void
5468 dtap_tp_test_interface(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5469 {
5470     guint32 curr_offset;
5471     guint32 consumed;
5472     guint   curr_len;
5473
5474     curr_len = len;
5475     curr_offset = offset;
5476
5477     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_TESTED_DEVICE, NULL);
5478
5479     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5480 }
5481
5482 static void
5483 dtap_tp_gprs_test_mode_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5484 {
5485     guint32 curr_offset;
5486     guint32 consumed;
5487     guint   curr_len;
5488
5489     curr_len = len;
5490     curr_offset = offset;
5491
5492     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_PDU_DESCRIPTION, NULL);
5493
5494     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_MODE_FLAG, NULL);
5495
5496     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5497 }
5498
5499 static void
5500 dtap_tp_egprs_start_radio_block_loopback_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5501 {
5502     guint32 curr_offset;
5503     guint32 consumed;
5504     guint   curr_len;
5505
5506     curr_len = len;
5507     curr_offset = offset;
5508
5509     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EGPRS_MODE_FLAG, NULL);
5510
5511     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5512 }
5513
5514 static void
5515 dtap_tp_reset_ms_positioning_stored_information(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5516 {
5517     guint32 curr_offset;
5518     guint32 consumed;
5519     guint   curr_len;
5520
5521     curr_len = len;
5522     curr_offset = offset;
5523
5524     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_MS_POSITIONING_TECHNOLOGY, NULL);
5525
5526     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5527 }
5528
5529 static void
5530 dtap_tp_close_ue_test_loop(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5531 {
5532     guint32 curr_offset;
5533     guint32 consumed;
5534     guint   curr_len;
5535
5536     curr_len = len;
5537     curr_offset = offset;
5538
5539     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_UE_TEST_LOOP_MODE, NULL);
5540
5541     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5542 }
5543
5544 static void
5545 dtap_tp_reset_ue_positioning_stored_information(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5546 {
5547     guint32 curr_offset;
5548     guint32 consumed;
5549     guint   curr_len;
5550
5551     curr_len = len;
5552     curr_offset = offset;
5553
5554     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_UE_POSITIONING_TECHNOLOGY, NULL);
5555
5556     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5557 }
5558
5559 static void
5560 dtap_tp_ue_test_loop_mode_3_rlc_sdu_counter_response(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5561 {
5562     guint32 curr_offset;
5563     guint32 consumed;
5564     guint   curr_len;
5565
5566     curr_len = len;
5567     curr_offset = offset;
5568
5569     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_RLC_SDU_COUNTER_VALUE, NULL);
5570
5571     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5572 }
5573
5574 static void
5575 dtap_tp_epc_close_ue_test_loop(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5576 {
5577     guint32 curr_offset;
5578     guint32 consumed;
5579     guint   curr_len;
5580
5581     curr_len = len;
5582     curr_offset = offset;
5583
5584     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_UE_TEST_LOOP_MODE, NULL);
5585
5586     switch (epc_test_loop_mode)
5587     {
5588     case 0:
5589         ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_UE_TL_A_LB_SETUP, NULL);
5590         break;
5591     case 1:
5592         ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_UE_TL_B_LB_SETUP, NULL);
5593         break;
5594     case 2:
5595         ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_UE_TL_C_SETUP, NULL);
5596         break;
5597     default:
5598         break;
5599     }
5600
5601     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5602 }
5603
5604 static void
5605 dtap_tp_epc_activate_test_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5606 {
5607     guint32 curr_offset;
5608     guint32 consumed;
5609     guint   curr_len;
5610
5611     curr_len = len;
5612     curr_offset = offset;
5613
5614     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_UE_TEST_LOOP_MODE, NULL);
5615
5616     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5617 }
5618
5619 static void
5620 dtap_tp_epc_reset_ue_positioning_stored_information(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5621 {
5622     guint32 curr_offset;
5623     guint32 consumed;
5624     guint   curr_len;
5625
5626     curr_len = len;
5627     curr_offset = offset;
5628
5629     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_UE_POSITIONING_TECHNOLOGY, NULL);
5630
5631     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5632 }
5633
5634 static void
5635 dtap_tp_epc_test_loop_mode_c_mbms_packet_counter_response(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5636 {
5637     guint32 curr_offset;
5638     guint32 consumed;
5639     guint   curr_len;
5640
5641     curr_len = len;
5642     curr_offset = offset;
5643
5644     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_MBMS_PACKET_COUNTER_VALUE, NULL);
5645
5646     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5647 }
5648 static void
5649 dtap_tp_epc_update_ue_location_information(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
5650 {
5651     guint32 curr_offset;
5652     guint32 consumed;
5653     guint   curr_len;
5654
5655     curr_len = len;
5656     curr_offset = offset;
5657
5658     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_ELLIPSOID_POINT_WITH_ALT, NULL);
5659
5660     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_HORIZONTAL_VELOCITY, NULL);
5661
5662     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_TP_EPC_GNSS_TOD_MSEC, NULL);
5663
5664     EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data);
5665 }
5666
5667 #define NUM_GSM_DTAP_MSG_MM (sizeof(gsm_a_dtap_msg_mm_strings)/sizeof(value_string))
5668 static gint ett_gsm_dtap_msg_mm[NUM_GSM_DTAP_MSG_MM];
5669 static void (*dtap_msg_mm_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = {
5670     dtap_mm_imsi_det_ind,       /* IMSI Detach Indication */
5671     dtap_mm_loc_upd_acc,        /* Location Updating Accept */
5672     dtap_mm_loc_upd_rej,        /* Location Updating Reject */
5673     dtap_mm_loc_upd_req,        /* Location Updating Request */
5674     NULL                        /* no associated data */,   /* Authentication Reject */
5675     dtap_mm_auth_req,           /* Authentication Request */
5676     dtap_mm_auth_resp,          /* Authentication Response */
5677     dtap_mm_auth_fail,          /* Authentication Failure */
5678     dtap_mm_id_req,             /* Identity Request */
5679     dtap_mm_id_resp,            /* Identity Response */
5680     dtap_mm_tmsi_realloc_cmd,   /* TMSI Reallocation Command */
5681     NULL                        /* no associated data */,   /* TMSI Reallocation Complete */
5682     NULL                        /* no associated data */,   /* CM Service Accept */
5683     dtap_mm_cm_srvc_rej,        /* CM Service Reject */
5684     NULL                        /* no associated data */,   /* CM Service Abort */
5685     dtap_mm_cm_srvc_req,        /* CM Service Request */
5686     dtap_mm_cm_srvc_prompt,     /* CM Service Prompt */
5687     NULL,                       /* Reserved: was allocated in earlier phases of the protocol */
5688     dtap_mm_cm_reestab_req,     /* CM Re-establishment Request */
5689     dtap_mm_abort,              /* Abort */
5690     NULL                        /* no associated data */,   /* MM Null */
5691     dtap_mm_mm_status,          /* MM Status */
5692     dtap_mm_mm_info,            /* MM Information */
5693     NULL,                       /* NONE */
5694 };
5695
5696 #define NUM_GSM_DTAP_MSG_CC (sizeof(gsm_a_dtap_msg_cc_strings)/sizeof(value_string))
5697 static gint ett_gsm_dtap_msg_cc[NUM_GSM_DTAP_MSG_CC];
5698 static void (*dtap_msg_cc_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = {
5699     dtap_cc_alerting,           /* Alerting */
5700     dtap_cc_call_conf,          /* Call Confirmed */
5701     dtap_cc_call_proceed,       /* Call Proceeding */
5702     dtap_cc_connect,            /* Connect */
5703     NULL                        /* no associated data */,   /* Connect Acknowledge */
5704     dtap_cc_emerg_setup,        /* Emergency Setup */
5705     dtap_cc_progress,           /* Progress */
5706     dtap_cc_cc_est,             /* CC-Establishment */
5707     dtap_cc_cc_est_conf,        /* CC-Establishment Confirmed */
5708     dtap_cc_recall,             /* Recall */
5709     dtap_cc_start_cc,           /* Start CC */
5710     dtap_cc_setup,              /* Setup */
5711     dtap_cc_modify,             /* Modify */
5712     dtap_cc_modify_complete,    /* Modify Complete */
5713     dtap_cc_modify_rej,         /* Modify Reject */
5714     dtap_cc_user_info,          /* User Information */
5715     NULL                        /* no associated data */,   /* Hold */
5716     NULL                        /* no associated data */,   /* Hold Acknowledge */
5717     dtap_cc_hold_rej,           /* Hold Reject */
5718     NULL                        /* no associated data */,   /* Retrieve */
5719     NULL                        /* no associated data */,   /* Retrieve Acknowledge */
5720     dtap_cc_retrieve_rej,       /* Retrieve Reject */
5721     dtap_cc_disconnect,         /* Disconnect */
5722     dtap_cc_release,            /* Release */
5723     dtap_cc_release_complete,   /* Release Complete */
5724     dtap_cc_congestion_control, /* Congestion Control */
5725     dtap_cc_notify,             /* Notify */
5726     dtap_cc_status,             /* Status */
5727     NULL                        /* no associated data */,   /* Status Enquiry */
5728     dtap_cc_start_dtmf,         /* Start DTMF */
5729     NULL                        /* no associated data */,   /* Stop DTMF */
5730     NULL                        /* no associated data */,   /* Stop DTMF Acknowledge */
5731     dtap_cc_start_dtmf_ack,     /* Start DTMF Acknowledge */
5732     dtap_cc_start_dtmf_rej,     /* Start DTMF Reject */
5733     dtap_cc_facility,           /* Facility */
5734     NULL,                       /* NONE */
5735 };
5736
5737 #define NUM_GSM_DTAP_MSG_SMS (sizeof(gsm_a_dtap_msg_sms_strings)/sizeof(value_string))
5738 static gint ett_gsm_dtap_msg_sms[NUM_GSM_DTAP_MSG_SMS];
5739 static void (*dtap_msg_sms_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = {
5740     dtap_sms_cp_data,  /* CP-DATA */
5741     NULL               /* no associated data */,    /* CP-ACK */
5742     dtap_sms_cp_error, /* CP-ERROR */
5743     NULL,              /* NONE */
5744 };
5745
5746 #define NUM_GSM_DTAP_MSG_SS (sizeof(gsm_a_dtap_msg_ss_strings)/sizeof(value_string))
5747 static gint ett_gsm_dtap_msg_ss[NUM_GSM_DTAP_MSG_SS];
5748 static void (*dtap_msg_ss_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = {
5749     dtap_cc_release_complete, /* Release Complete */
5750     dtap_cc_facility,         /* Facility */
5751     dtap_ss_register,         /* Register */
5752     NULL,                     /* NONE */
5753 };
5754
5755 #define NUM_GSM_DTAP_MSG_TP (sizeof(gsm_a_dtap_msg_tp_strings)/sizeof(value_string))
5756 static gint ett_gsm_dtap_msg_tp[NUM_GSM_DTAP_MSG_TP];
5757 static void (*dtap_msg_tp_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = {
5758     dtap_tp_close_tch_loop_cmd,                                /* CLOSE TCH LOOP CMD */
5759     NULL,                                                      /* CLOSE TCH LOOP ACK */
5760     dtap_tp_open_loop_cmd,                                     /* OPEN LOOP CMD */
5761     NULL,                                                      /* ACT EMMI CMD */
5762     NULL,                                                      /* ACT EMMI ACK */
5763     NULL,                                                      /* DEACT EMMI */
5764     dtap_tp_test_interface,                                    /* Test Interface */
5765     dtap_tp_multi_slot_loop_cmd,                               /* CLOSE Multi-slot LOOP CMD */
5766     dtap_tp_multi_slot_loop_ack,                               /* CLOSE Multi-slot LOOP ACK */
5767     NULL,                                                      /* OPEN Multi-slot LOOP CMD */
5768     NULL,                                                      /* OPEN Multi-slot LOOP ACK */
5769     dtap_tp_gprs_test_mode_cmd,                                /* GPRS TEST MODE CMD */
5770     dtap_tp_egprs_start_radio_block_loopback_cmd,              /* EGPRS START RADIO BLOCK LOOPBACK CMD */
5771     dtap_tp_reset_ms_positioning_stored_information,           /* RESET MS POSITIONING STORED INFORMATION */
5772     dtap_tp_close_ue_test_loop,                                /* CLOSE UE TEST LOOP */
5773     NULL,                                                      /* CLOSE UE TEST LOOP COMPLETE */
5774     NULL,                                                      /* OPEN UE TEST LOOP */
5775     NULL,                                                      /* OPEN UE TEST LOOP COMPLETE */
5776     NULL,                                                      /* ACTIVATE RB TEST MODE */
5777     NULL,                                                      /* ACTIVATE RB TEST MODE COMPLETE */
5778     NULL,                                                      /* DEACTIVATE RB TEST MODE */
5779     NULL,                                                      /* DEACTIVATE RB TEST MODE COMPLETE */
5780     dtap_tp_reset_ue_positioning_stored_information,           /* RESET UE POSITIONING STORED INFORMATION */
5781     NULL,                                                      /* UE TEST LOOP MODE 3 RLC SDU COUNTER REQUEST */
5782     dtap_tp_ue_test_loop_mode_3_rlc_sdu_counter_response,      /* UE TEST LOOP MODE 3 RLC SDU COUNTER RESPONSE */
5783     dtap_tp_epc_close_ue_test_loop,                            /* CLOSE UE TEST LOOP */
5784     NULL,                                                      /* CLOSE UE TEST LOOP COMPLETE */
5785     NULL,                                                      /* OPEN UE TEST LOOP */
5786     NULL,                                                      /* OPEN UE TEST LOOP COMPLETE */
5787     dtap_tp_epc_activate_test_mode,                            /* ACTIVATE TEST MODE */
5788     NULL,                                                      /* ACTIVATE TEST MODE COMPLETE */
5789     NULL,                                                      /* DEACTIVATE TEST MODE */
5790     NULL,                                                      /* DEACTIVATE TEST MODE COMPLETE */
5791     dtap_tp_epc_reset_ue_positioning_stored_information,       /* RESET UE POSITIONING STORED INFORMATION */
5792     NULL,                                                      /* UE TEST LOOP MODE C MBMS PACKET COUNTER REQUEST */
5793     dtap_tp_epc_test_loop_mode_c_mbms_packet_counter_response, /* UE TEST LOOP MODE C MBMS PACKET COUNTER RESPONSE */
5794     dtap_tp_epc_update_ue_location_information,                /* UPDATE UE LOCATION INFORMATION */
5795     NULL,                                                      /* NONE */
5796 };
5797
5798 /* GENERIC DISSECTOR FUNCTIONS */
5799
5800 static int
5801 dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
5802 {
5803     static gsm_a_tap_rec_t  tap_rec[4];
5804     static gsm_a_tap_rec_t *tap_p;
5805     static guint            tap_current = 0;
5806
5807     void  (*dtap_msg_fcn)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len);
5808
5809     guint8        oct;
5810     guint8        pd;
5811     guint32       offset;
5812     guint32       len;
5813     guint32       oct_1;
5814     gint          idx;
5815     proto_item   *dtap_item   = NULL;
5816     proto_tree   *dtap_tree   = NULL;
5817     proto_item   *oct_1_item  = NULL;
5818     proto_tree   *pd_tree     = NULL;
5819     const gchar  *msg_str;
5820     gint          ett_tree;
5821     gint          ti;
5822     int       hf_idx;
5823     gboolean      nsd;
5824     sccp_msg_info_t* sccp_msg = (sccp_msg_info_t*)data;
5825
5826
5827     len = tvb_reported_length(tvb);
5828
5829     if (len < 2)
5830     {
5831         /*
5832          * too short to be DTAP
5833          */
5834         call_dissector(data_handle, tvb, pinfo, tree);
5835         return len;
5836     }
5837
5838     col_append_str(pinfo->cinfo, COL_INFO, "(DTAP) ");
5839
5840     /*
5841      * set tap record pointer
5842      */
5843     tap_current++;
5844     if (tap_current >= 4)
5845     {
5846         tap_current = 0;
5847     }
5848     tap_p = &tap_rec[tap_current];
5849
5850
5851     offset = 0;
5852
5853     g_tree = tree;
5854
5855     /*
5856      * get protocol discriminator
5857      */
5858     oct_1 = tvb_get_guint8(tvb, offset++);
5859
5860     if ((((oct_1 & DTAP_TI_MASK) >> 4) & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
5861     {
5862         /*
5863          * eventhough we don't know if a TI should be in the message yet
5864          * we rely on the TI/SKIP indicator to be 0 to avoid taking this
5865          * octet
5866          */
5867         offset++;
5868     }
5869
5870     oct = tvb_get_guint8(tvb, offset);
5871
5872     pd = oct_1 & DTAP_PD_MASK;
5873     ti = -1;
5874     msg_str = NULL;
5875     ett_tree = -1;
5876     hf_idx = -1;
5877     dtap_msg_fcn = NULL;
5878     nsd = FALSE;
5879     col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",val_to_str_const(pd,gsm_a_pd_short_str_vals,"unknown"));
5880
5881     /*
5882      * octet 1
5883      */
5884     /* Initialize hf_idx, ett_tree and dtap_msg_fcn.
5885        ett_tree and dtap_msg_fcn will not be used if msg_str == NULL. */
5886     switch (pd)
5887     {
5888     case 3:
5889         msg_str = try_val_to_str_idx((guint32) (oct & DTAP_CC_IEI_MASK), gsm_a_dtap_msg_cc_strings, &idx);
5890         if (msg_str != NULL)
5891         {
5892             ett_tree = ett_gsm_dtap_msg_cc[idx];
5893             dtap_msg_fcn = dtap_msg_cc_fcn[idx];
5894         }
5895         hf_idx = hf_gsm_a_dtap_msg_cc_type;
5896         ti = (oct_1 & DTAP_TI_MASK) >> 4;
5897         nsd = TRUE;
5898         break;
5899
5900     case 5:
5901         msg_str = try_val_to_str_idx((guint32) (oct & DTAP_MM_IEI_MASK), gsm_a_dtap_msg_mm_strings, &idx);
5902         if (msg_str != NULL)
5903         {
5904             ett_tree = ett_gsm_dtap_msg_mm[idx];
5905             dtap_msg_fcn = dtap_msg_mm_fcn[idx];
5906         }
5907         hf_idx = hf_gsm_a_dtap_msg_mm_type;
5908         nsd = TRUE;
5909         break;
5910
5911     case 6:
5912         get_rr_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &dtap_msg_fcn);
5913         break;
5914
5915     case 8:
5916         get_gmm_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &dtap_msg_fcn);
5917         break;
5918
5919     case 9:
5920         msg_str = try_val_to_str_idx((guint32) (oct & DTAP_SMS_IEI_MASK), gsm_a_dtap_msg_sms_strings, &idx);
5921         hf_idx = hf_gsm_a_dtap_msg_sms_type;
5922         if (msg_str != NULL)
5923         {
5924             ett_tree = ett_gsm_dtap_msg_sms[idx];
5925             dtap_msg_fcn = dtap_msg_sms_fcn[idx];
5926         }
5927         ti = (oct_1 & DTAP_TI_MASK) >> 4;
5928         break;
5929
5930     case 10:
5931         get_sm_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &dtap_msg_fcn);
5932         ti = (oct_1 & DTAP_TI_MASK) >> 4;
5933         break;
5934
5935     case 11:
5936         msg_str = try_val_to_str_idx((guint32) (oct & DTAP_SS_IEI_MASK), gsm_a_dtap_msg_ss_strings, &idx);
5937         hf_idx = hf_gsm_a_dtap_msg_ss_type;
5938         if (msg_str != NULL)
5939         {
5940             ett_tree = ett_gsm_dtap_msg_ss[idx];
5941             dtap_msg_fcn = dtap_msg_ss_fcn[idx];
5942         }
5943         ti = (oct_1 & DTAP_TI_MASK) >> 4;
5944         nsd = TRUE;
5945         break;
5946
5947     case 15:
5948         msg_str = try_val_to_str_idx((guint32) (oct & DTAP_TP_IEI_MASK), gsm_a_dtap_msg_tp_strings, &idx);
5949         hf_idx = hf_gsm_a_dtap_msg_tp_type;
5950         if (msg_str != NULL)
5951         {
5952             ett_tree = ett_gsm_dtap_msg_tp[idx];
5953             dtap_msg_fcn = dtap_msg_tp_fcn[idx];
5954         }
5955         nsd = TRUE;
5956         break;
5957
5958     default:
5959         /* XXX - hf_idx is still -1! this is a bug in the implementation, and I don't know how to fix it so simple return here */
5960         return len;
5961     }
5962
5963     if (sccp_msg && sccp_msg->data.co.assoc) {
5964         sccp_assoc = sccp_msg->data.co.assoc;
5965     }
5966     else
5967     {
5968         sccp_assoc = NULL;
5969         sccp_msg = NULL;
5970     }
5971
5972     /*
5973      * create the protocol tree
5974      */
5975     if (msg_str == NULL)
5976     {
5977         dtap_item =
5978             proto_tree_add_protocol_format(tree, proto_a_dtap, tvb, 0, len,
5979             "GSM A-I/F DTAP - Unknown DTAP Message Type (0x%02x)",
5980             oct);
5981
5982         dtap_tree = proto_item_add_subtree(dtap_item, ett_dtap_msg);
5983
5984         if (sccp_msg && !sccp_msg->data.co.label) {
5985             sccp_msg->data.co.label = wmem_strdup_printf(wmem_file_scope(), "DTAP (0x%02x)",oct);
5986         }
5987
5988
5989     }
5990     else
5991     {
5992         dtap_item =
5993             proto_tree_add_protocol_format(tree, proto_a_dtap, tvb, 0, -1,
5994                 "GSM A-I/F DTAP - %s",
5995                 msg_str);
5996
5997         dtap_tree = proto_item_add_subtree(dtap_item, ett_tree);
5998
5999         if (sccp_msg && !sccp_msg->data.co.label) {
6000             sccp_msg->data.co.label = wmem_strdup(wmem_file_scope(), msg_str);
6001         }
6002
6003         col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
6004         col_set_fence(pinfo->cinfo, COL_INFO);
6005     }
6006
6007     oct_1_item = proto_tree_add_uint(dtap_tree, hf_gsm_a_dtap_protocol_discriminator, tvb, 0, 1, pd);
6008     pd_tree = proto_item_add_subtree(oct_1_item, ett_dtap_oct_1);
6009
6010     proto_tree_add_item(pd_tree, hf_gsm_a_L3_protocol_discriminator, tvb, 0, 1, ENC_BIG_ENDIAN);
6011
6012     if (ti == -1)
6013     {
6014         proto_tree_add_item(pd_tree, hf_gsm_a_skip_ind, tvb, 0, 1, ENC_BIG_ENDIAN);
6015     }
6016     else
6017     {
6018
6019         proto_tree_add_item(pd_tree, hf_gsm_a_dtap_ti_flag, tvb, 0, 1, ENC_NA);
6020
6021         if ((ti & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
6022         {
6023             /* ti is extended to next octet */
6024             proto_tree_add_uint_format_value(pd_tree, hf_gsm_a_dtap_tio, tvb, 0, 1,
6025                 oct_1, "The TI value is given by the TIE in octet 2");
6026         }
6027         else
6028         {
6029             proto_tree_add_item(pd_tree, hf_gsm_a_dtap_tio, tvb, 0, 1, ENC_BIG_ENDIAN);
6030         }
6031     }
6032
6033     if ((ti != -1) &&
6034         (ti & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
6035     {
6036         proto_tree_add_item(tree, hf_gsm_a_extension, tvb, 1, 1, ENC_BIG_ENDIAN);
6037         proto_tree_add_item(pd_tree, hf_gsm_a_dtap_tie, tvb, 1, 1, ENC_BIG_ENDIAN);
6038     }
6039
6040     /*
6041      * N(SD)
6042      */
6043     if ((pinfo->p2p_dir == P2P_DIR_RECV) &&
6044         nsd)
6045     {
6046         /* XXX */
6047     }
6048     /* 3GPP TS 24.008 version 8.5.0 Release 8
6049      * Bits 5 to 8 of the first octet of every message belonging to the protocols "Call Control;
6050      * call related SS messages" and "Session Management"contain the transaction identifier (TI).
6051      * The transaction identifier and its use are defined in 3GPP TS 24.007 [20].
6052      *  5 = Mobility Management messages
6053      *  3 = Call Control; call related SS messages
6054      * 10 = GPRS session management messages
6055      */
6056     if ((pd == 5) || (pd == 3) || (pd == 10)) {
6057         proto_tree_add_item(dtap_tree, hf_gsm_a_seq_no, tvb, offset, 1, ENC_BIG_ENDIAN);
6058     }
6059     /*
6060      * add DTAP message name
6061      */
6062     proto_tree_add_item(dtap_tree, hf_idx, tvb, offset, 1, ENC_BIG_ENDIAN);
6063     offset++;
6064
6065     tap_p->pdu_type = GSM_A_PDU_TYPE_DTAP;
6066     tap_p->message_type = (nsd ? (oct & 0x3f) : oct);
6067     tap_p->protocol_disc = (gsm_a_pd_str_e)pd;
6068
6069     tap_queue_packet(gsm_a_tap, pinfo, tap_p);
6070
6071     if (msg_str == NULL) return len;
6072
6073     if (offset >= len) return len;
6074
6075     /*
6076      * decode elements
6077      */
6078     if (dtap_msg_fcn == NULL)
6079     {
6080         proto_tree_add_text(dtap_tree,
6081             tvb, offset, len - offset,
6082             "Message Elements");
6083     }
6084     else
6085     {
6086         (*dtap_msg_fcn)(tvb, dtap_tree, pinfo, offset, len - offset);
6087     }
6088
6089     return len;
6090 }
6091
6092
6093 /* Register the protocol with Wireshark */
6094 void
6095 proto_register_gsm_a_dtap(void)
6096 {
6097     guint i;
6098     guint last_offset;
6099
6100     /* Setup list of header fields */
6101
6102     static hf_register_info hf[] = {
6103         { &hf_gsm_a_seq_no,
6104           { "Sequence number", "gsm_a.dtap.seq_no",
6105             FT_UINT8, BASE_DEC, NULL, 0xc0,
6106             NULL, HFILL }
6107         },
6108         { &hf_gsm_a_dtap_msg_mm_type,
6109           { "DTAP Mobility Management Message Type", "gsm_a.dtap.msg_mm_type",
6110             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_mm_strings), 0x3f,
6111             NULL, HFILL }
6112         },
6113         { &hf_gsm_a_dtap_msg_cc_type,
6114           { "DTAP Call Control Message Type", "gsm_a.dtap.msg_cc_type",
6115             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_cc_strings), 0x3f,
6116             NULL, HFILL }
6117         },
6118         { &hf_gsm_a_dtap_msg_sms_type,
6119           { "DTAP Short Message Service Message Type", "gsm_a.dtap.msg_sms_type",
6120             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_sms_strings), 0x0,
6121             NULL, HFILL }
6122         },
6123         { &hf_gsm_a_dtap_msg_ss_type,
6124           { "DTAP Non call Supplementary Service Message Type", "gsm_a.dtap.msg_ss_type",
6125             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_ss_strings), 0x3f,
6126             NULL, HFILL }
6127         },
6128         { &hf_gsm_a_dtap_msg_tp_type,
6129           { "DTAP Tests Procedures Message Type", "gsm_a.dtap.msg_tp_type",
6130             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_tp_strings), 0x0,
6131             NULL, HFILL }
6132         },
6133         { &hf_gsm_a_dtap_elem_id,
6134           { "Element ID", "gsm_a.dtap.elem_id",
6135             FT_UINT8, BASE_HEX, NULL, 0,
6136             NULL, HFILL }
6137         },
6138         { &hf_gsm_a_dtap_cld_party_bcd_num,
6139           { "Called Party BCD Number", "gsm_a.dtap.cld_party_bcd_num",
6140             FT_STRING, BASE_NONE, 0, 0,
6141             NULL, HFILL }
6142         },
6143         { &hf_gsm_a_dtap_clg_party_bcd_num,
6144           { "Calling Party BCD Number", "gsm_a.dtap.clg_party_bcd_num",
6145             FT_STRING, BASE_NONE, 0, 0,
6146             NULL, HFILL }
6147         },
6148         { &hf_gsm_a_dtap_conn_num,
6149           { "Connected Number", "gsm_a.dtap.conn_num",
6150             FT_STRING, BASE_NONE, 0, 0,
6151             NULL, HFILL }
6152         },
6153         { &hf_gsm_a_dtap_red_party_bcd_num,
6154           { "Redirecting Party BCD Number", "gsm_a.dtap.red_party_bcd_num",
6155             FT_STRING, BASE_NONE, 0, 0,
6156             NULL, HFILL }
6157         },
6158         { &hf_gsm_a_dtap_cause,
6159           { "DTAP Cause", "gsm_a.dtap.cause",
6160             FT_UINT8, BASE_HEX, 0, 0x7f,
6161             NULL, HFILL }
6162         },
6163         { &hf_gsm_a_dtap_type_of_number,
6164           { "Type of number", "gsm_a.dtap.type_of_number",
6165             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_type_of_number_values), 0x70,
6166             NULL, HFILL }
6167         },
6168         { &hf_gsm_a_dtap_numbering_plan_id,
6169           { "Numbering plan identification", "gsm_a.dtap.numbering_plan_id",
6170             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_numbering_plan_id_values), 0x0f,
6171             NULL, HFILL }
6172         },
6173         { &hf_gsm_a_dtap_present_ind,
6174           { "Presentation indicator", "gsm_a.dtap.present_ind",
6175             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_present_ind_values), 0x60,
6176             NULL, HFILL }
6177         },
6178         { &hf_gsm_a_dtap_screening_ind,
6179           { "Screening indicator", "gsm_a.dtap.screening_ind",
6180             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_screening_ind_values), 0x03,
6181             NULL, HFILL }
6182         },
6183         { &hf_gsm_a_dtap_type_of_sub_addr,
6184           { "Type of subaddress", "gsm_a.dtap.type_of_sub_addr",
6185             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_type_of_sub_addr_values), 0x70,
6186             NULL, HFILL }
6187         },
6188         { &hf_gsm_a_dtap_odd_even_ind,
6189           { "Odd/even indicator", "gsm_a.dtap.odd_even_ind",
6190             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_odd_even_ind_values), 0x08,
6191             NULL, HFILL }
6192         },
6193         { &hf_gsm_a_dtap_lsa_id,
6194           { "LSA Identifier", "gsm_a.dtap.lsa_id",
6195             FT_UINT24, BASE_HEX, NULL, 0x0,
6196             NULL, HFILL }
6197         },
6198         { &hf_gsm_a_dtap_speech_vers_ind,
6199           { "Speech version indication", "gsm_a.dtap.speech_vers_ind",
6200             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_speech_vers_ind_values), 0x0f,
6201             NULL, HFILL }
6202         },
6203         { &hf_gsm_a_dtap_itc,
6204           { "Information transfer capability", "gsm_a.dtap.itc",
6205             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_itc_values), 0x07,
6206             NULL, HFILL }
6207         },
6208         { &hf_gsm_a_dtap_sysid,
6209           { "System Identification (SysID)", "gsm_a.dtap.sysid",
6210             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_sysid_values), 0x0,
6211             NULL, HFILL }
6212         },
6213         { &hf_gsm_a_dtap_bitmap_length,
6214           { "Bitmap Length", "gsm_a.dtap.bitmap_length",
6215             FT_UINT8, BASE_DEC, NULL, 0x0,
6216             NULL, HFILL }
6217         },
6218         { &hf_gsm_a_dtap_serv_cat_b7,
6219           { "Automatically initiated eCall", "gsm_a.dtap.serv_cat_b7",
6220             FT_BOOLEAN, 8, NULL, 0x40,
6221             NULL, HFILL }
6222         },
6223         { &hf_gsm_a_dtap_serv_cat_b6,
6224           { "Manually initiated eCall", "gsm_a.dtap.serv_cat_b6",
6225             FT_BOOLEAN, 8, NULL, 0x20,
6226             NULL, HFILL }
6227         },
6228         { &hf_gsm_a_dtap_serv_cat_b5,
6229           { "Mountain Rescue", "gsm_a.dtap.serv_cat_b5",
6230             FT_BOOLEAN, 8, NULL, 0x10,
6231             NULL, HFILL }
6232         },
6233         { &hf_gsm_a_dtap_serv_cat_b4,
6234           { "Marine Guard", "gsm_a.dtap.serv_cat_b4",
6235             FT_BOOLEAN, 8, NULL, 0x08,
6236             NULL, HFILL }
6237         },
6238         { &hf_gsm_a_dtap_serv_cat_b3,
6239           { "Fire Brigade", "gsm_a.dtap.serv_cat_b3",
6240             FT_BOOLEAN, 8, NULL, 0x04,
6241             NULL, HFILL }
6242         },
6243         { &hf_gsm_a_dtap_serv_cat_b2,
6244           { "Ambulance", "gsm_a.dtap.serv_cat_b2",
6245             FT_BOOLEAN, 8, NULL, 0x02,
6246             NULL, HFILL }
6247         },
6248         { &hf_gsm_a_dtap_serv_cat_b1,
6249           { "Police", "gsm_a.dtap.serv_cat_b1",
6250             FT_BOOLEAN, 8, NULL, 0x01,
6251             NULL, HFILL }
6252         },
6253         { &hf_gsm_a_dtap_csmo,
6254           { "CSMO", "gsm_a.dtap.csmo",
6255             FT_BOOLEAN, BASE_NONE, TFS(&gsm_a_dtap_csmo_value), 0x0,
6256             NULL, HFILL }
6257         },
6258         { &hf_gsm_a_dtap_csmt,
6259           { "CSMT", "gsm_a.dtap.csmt",
6260             FT_BOOLEAN, BASE_NONE, TFS(&gsm_a_dtap_csmt_value), 0x0,
6261             NULL, HFILL }
6262         },
6263         { &hf_gsm_a_dtap_mm_timer_unit,
6264           { "Unit", "gsm_a.dtap.mm_timer_unit",
6265             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_mm_timer_unit_vals), 0xe0,
6266             NULL, HFILL }
6267         },
6268         { &hf_gsm_a_dtap_mm_timer_value,
6269           { "Timer value", "gsm_a.dtap.mm_timer_value",
6270             FT_UINT8, BASE_DEC, NULL, 0x1f,
6271             NULL, HFILL }
6272         },
6273         { &hf_gsm_a_dtap_alerting_pattern,
6274           { "Alerting Pattern", "gsm_a.dtap.alerting_pattern",
6275             FT_UINT8, BASE_DEC, VALS(gsm_a_alerting_pattern_vals), 0x0f,
6276             NULL, HFILL }
6277         },
6278         { &hf_gsm_a_dtap_ccbs_activation,
6279           { "CCBS Activation", "gsm_a.dtap.ccbs_activation",
6280             FT_BOOLEAN, 8, TFS(&gsm_a_ccbs_activation_value), 0x80,
6281             NULL, HFILL }
6282         },
6283         { &hf_gsm_a_dtap_stream_identifier,
6284           { "Stream Identifier", "gsm_a.dtap.stream_identifier",
6285             FT_UINT8, BASE_HEX, 0, 0x0,
6286             NULL, HFILL }
6287         },
6288         { &hf_gsm_a_dtap_mcs,
6289           { "MCS", "gsm_a.dtap.mcs",
6290             FT_BOOLEAN, 8, TFS(&gsm_a_mcs_value), 0x01,
6291             NULL, HFILL }
6292         },
6293         { &hf_gsm_a_dtap_cause_of_no_cli,
6294           { "Cause of no CLI", "gsm_a.dtap.cause_of_no_cli",
6295             FT_UINT8, BASE_HEX, 0, 0x0,
6296             NULL, HFILL }
6297         },
6298         { &hf_gsm_a_dtap_cause_ss_diagnostics,
6299           { "Supplementary Services Diagnostics", "gsm_a.dtap.cause_ss_diagnostics",
6300             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_cause_ss_diagnostics_vals), 0x7f,
6301             NULL, HFILL }
6302         },
6303         { &hf_gsm_a_dtap_codec_tdma_efr,
6304           { "TDMA EFR", "gsm_a.dtap.codec.tdma_efr",
6305             FT_BOOLEAN, 8, NULL, 0x80,
6306             NULL, HFILL }
6307         },
6308         { &hf_gsm_a_dtap_codec_umts_amr_2,
6309           { "UMTS AMR 2", "gsm_a.dtap.codec.umts_amr_2",
6310             FT_BOOLEAN, 8, NULL, 0x40,
6311             NULL, HFILL }
6312         },
6313         { &hf_gsm_a_dtap_codec_umts_amr,
6314           { "UMTS AMR", "gsm_a.dtap.codec.umts_amr",
6315             FT_BOOLEAN, 8, NULL, 0x20,
6316             NULL, HFILL }
6317         },
6318         { &hf_gsm_a_dtap_codec_hr_amr,
6319           { "HR AMR", "gsm_a.dtap.codec.hr_amr",
6320             FT_BOOLEAN, 8, NULL, 0x10,
6321             NULL, HFILL }
6322         },
6323         { &hf_gsm_a_dtap_codec_fr_amr,
6324           { "FR AMR", "gsm_a.dtap.codec.fr_amr",
6325             FT_BOOLEAN, 8, NULL, 0x08,
6326             NULL, HFILL }
6327         },
6328         { &hf_gsm_a_dtap_codec_gsm_efr,
6329           { "GSM EFR", "gsm_a.dtap.codec.gsm_efr",
6330             FT_BOOLEAN, 8, NULL, 0x04,
6331             NULL, HFILL }
6332         },
6333         { &hf_gsm_a_dtap_codec_gsm_hr,
6334           { "GSM HR", "gsm_a.dtap.codec.gsm_hr",
6335             FT_BOOLEAN, 8, NULL, 0x02,
6336             NULL, HFILL }
6337         },
6338         { &hf_gsm_a_dtap_codec_gsm_fr,
6339           { "GSM FR", "gsm_a.dtap.codec.gsm_fr",
6340             FT_BOOLEAN, 8, NULL, 0x01,
6341             NULL, HFILL }
6342         },
6343         { &hf_gsm_a_dtap_codec_ohr_amr_wb,
6344           { "OHR AMR-WB", "gsm_a.dtap.codec.ohr_amr_wb",
6345             FT_BOOLEAN, 8, NULL, 0x20,
6346             NULL, HFILL }
6347         },
6348         { &hf_gsm_a_dtap_codec_ofr_amr_wb,
6349           { "OFR AMR-WB", "gsm_a.dtap.codec.ofr_amr_wb",
6350             FT_BOOLEAN, 8, NULL, 0x10,
6351             NULL, HFILL }
6352         },
6353         { &hf_gsm_a_dtap_codec_ohr_amr,
6354           { "OHR AMR", "gsm_a.dtap.codec.ohr_amr",
6355             FT_BOOLEAN, 8, NULL, 0x08,
6356             NULL, HFILL }
6357         },
6358         { &hf_gsm_a_dtap_codec_umts_amr_wb,
6359           { "UMTS AMR-WB", "gsm_a.dtap.codec.umts_amr_wb",
6360             FT_BOOLEAN, 8, NULL, 0x04,
6361             NULL, HFILL }
6362         },
6363         { &hf_gsm_a_dtap_codec_fr_amr_wb,
6364           { "FR AMR-WB", "gsm_a.dtap.codec.fr_amr_wb",
6365             FT_BOOLEAN, 8, NULL, 0x02,
6366             NULL, HFILL }
6367         },
6368         { &hf_gsm_a_dtap_codec_pdc_efr,
6369           { "PDC EFR", "gsm_a.dtap.codec.pdc_efr",
6370             FT_BOOLEAN, 8, NULL, 0x01,
6371             NULL, HFILL }
6372         },
6373         { &hf_gsm_a_dtap_notification_description,
6374           { "Notification description", "gsm_a.dtap.notif_descr",
6375             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_notification_description_vals), 0x7f,
6376             NULL, HFILL }
6377         },
6378         { &hf_gsm_a_dtap_emerg_num_info_length,
6379           { "Emergency Number Info length", "gsm_a.dtap.emerg_num_info_length",
6380             FT_UINT8, BASE_DEC, 0, 0x0,
6381             NULL, HFILL }
6382         },
6383         { &hf_gsm_a_dtap_emergency_bcd_num,
6384           { "Emergency BCD Number", "gsm_a.dtap.emergency_bcd_num",
6385             FT_STRING, BASE_NONE, 0, 0,
6386             NULL, HFILL }
6387         },
6388         { &hf_gsm_a_dtap_signal_value,
6389           { "Signal value", "gsm_a.dtap.signal_value",
6390             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_signal_value_vals), 0x0,
6391             NULL, HFILL }
6392         },
6393         { &hf_gsm_a_dtap_recall_type,
6394           { "Recall type", "gsm_a.dtap.recall_type",
6395             FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(gsm_a_dtap_recall_type_vals), 0x07,
6396             NULL, HFILL }
6397         },
6398         { &hf_gsm_a_dtap_coding_standard,
6399           { "Coding standard", "gsm_a.dtap.coding_standard",
6400             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_coding_standard_vals), 0xc0,
6401             NULL, HFILL }
6402         },
6403         { &hf_gsm_a_dtap_call_state,
6404           { "Call state", "gsm_a.dtap.call_state",
6405             FT_UINT8, BASE_DEC, NULL, 0x3f,
6406             NULL, HFILL }
6407         },
6408         { &hf_gsm_a_dtap_prog_coding_standard,
6409           { "Coding standard", "gsm_a.dtap.coding_standard",
6410             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_coding_standard_vals), 0x60,
6411             NULL, HFILL }
6412         },
6413         { &hf_gsm_a_dtap_location,
6414           { "Location", "gsm_a.dtap.location",
6415             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_location_vals), 0x0f,
6416             NULL, HFILL }
6417         },
6418         { &hf_gsm_a_dtap_progress_description,
6419           { "Progress description", "gsm_a.dtap.progress_description",
6420             FT_UINT8, BASE_DEC, NULL, 0x7f,
6421             NULL, HFILL }
6422         },
6423         { &hf_gsm_a_dtap_afi,
6424           { "Authority and Format Identifier", "gsm_a.dtap.afi",
6425             FT_UINT8, BASE_HEX|BASE_EXT_STRING, &x213_afi_value_ext, 0x0,
6426             NULL, HFILL }
6427         },
6428         { &hf_gsm_a_dtap_rej_cause,
6429           { "Reject cause", "gsm_a.dtap.rej_cause",
6430             FT_UINT8, BASE_DEC, NULL, 0x0,
6431             NULL, HFILL }
6432         },
6433         { &hf_gsm_a_dtap_u2u_prot_discr,
6434           { "User-user protocol discriminator", "gsm_a.dtap.u2u_prot_discr",
6435             FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(gsm_a_dtap_u2u_prot_discr_vals), 0x00,
6436             NULL, HFILL }
6437         },
6438         { &hf_gsm_a_dtap_mcat,
6439           { "MCAT", "gsm_a.dtap.mcat",
6440             FT_BOOLEAN, 8, TFS(&gsm_a_dtap_mcat_value), 0x08,
6441             NULL, HFILL }
6442         },
6443         { &hf_gsm_a_dtap_enicm,
6444           { "ENICM", "gsm_a.dtap.mcat",
6445             FT_BOOLEAN, 8, TFS(&gsm_a_dtap_enicm_value), 0x04,
6446             NULL, HFILL }
6447         },
6448         { &hf_gsm_a_dtap_rand,
6449           { "RAND value", "gsm_a.dtap.rand",
6450             FT_BYTES, FT_NONE, NULL, 0x00,
6451             NULL, HFILL }
6452         },
6453         { &hf_gsm_a_dtap_autn,
6454           { "AUTN value", "gsm_a.dtap.autn",
6455             FT_BYTES, FT_NONE, NULL, 0x00,
6456             NULL, HFILL }
6457         },
6458         { &hf_gsm_a_dtap_sres,
6459           { "SRES value", "gsm_a.dtap.sres",
6460             FT_BYTES, FT_NONE, NULL, 0x00,
6461             NULL, HFILL }
6462         },
6463         { &hf_gsm_a_dtap_xres,
6464           { "XRES value", "gsm_a.dtap.xres",
6465             FT_BYTES, FT_NONE, NULL, 0x00,
6466             NULL, HFILL }
6467         },
6468         { &hf_gsm_a_dtap_auts,
6469           { "AUTS value", "gsm_a.dtap.auts",
6470             FT_BYTES, FT_NONE, NULL, 0x00,
6471             NULL, HFILL }
6472         },
6473         { &hf_gsm_a_dtap_autn_sqn_xor_ak,
6474           { "SQN xor AK", "gsm_a.dtap.autn.sqn_xor_ak",
6475             FT_BYTES, FT_NONE, NULL, 0x00,
6476             NULL, HFILL }
6477         },
6478         { &hf_gsm_a_dtap_autn_amf,
6479           { "AMF", "gsm_a.dtap.autn.amf",
6480             FT_BYTES, FT_NONE, NULL, 0x00,
6481             NULL, HFILL }
6482         },
6483         { &hf_gsm_a_dtap_autn_mac,
6484           { "MAC", "gsm_a.dtap.autn.mac",
6485             FT_BYTES, FT_NONE, NULL, 0x00,
6486             NULL, HFILL }
6487         },
6488         { &hf_gsm_a_dtap_auts_sqn_ms_xor_ak,
6489           { "SQN_MS xor AK", "gsm_a.dtap.auts.sqn_ms_xor_ak",
6490             FT_BYTES, FT_NONE, NULL, 0x00,
6491             NULL, HFILL }
6492         },
6493         { &hf_gsm_a_dtap_auts_mac_s,
6494           { "MAC-S", "gsm_a.dtap.auts.mac_s",
6495             FT_BYTES, FT_NONE, NULL, 0x00,
6496             NULL, HFILL }
6497         },
6498         { &hf_gsm_a_dtap_epc_ue_tl_mode,
6499           { "UE test loop mode","gsm_a.dtap.epc.ue_tl_mode",
6500             FT_UINT8,BASE_DEC, VALS(epc_ue_test_loop_mode_vals), 0x0,
6501             NULL, HFILL }
6502         },
6503         { &hf_gsm_a_dtap_epc_ue_tl_a_ul_sdu_size,
6504           { "Uplink PDCP SDU size in bits","gsm_a.dtap.epc.ue_tl_a_ul_sdu_size",
6505             FT_UINT16,BASE_DEC, NULL, 0x0,
6506             NULL, HFILL }
6507         },
6508         { &hf_gsm_a_dtap_epc_ue_tl_a_drb,
6509           { "Data Radio Bearer identity number","gsm_a.dtap.epc.ue_tl_a_drb",
6510             FT_UINT8,BASE_DEC, NULL, 0x1f,
6511             NULL, HFILL }
6512         },
6513         { &hf_gsm_a_dtap_epc_ue_tl_b_ip_pdu_delay,
6514           { "IP PDU delay in seconds","gsm_a.dtap.epc.ue_tl_b_ip_pdu_delay",
6515             FT_UINT8,BASE_DEC, NULL, 0x0,
6516             NULL, HFILL }
6517         },
6518         { &hf_gsm_a_dtap_epc_ue_tl_c_mbsfn_area_id,
6519           { "MBSFN area identity","gsm_a.dtap.epc.ue_tl_c_mbsfn_area_id",
6520             FT_UINT8, BASE_DEC, NULL, 0x0,
6521             NULL, HFILL }
6522         },
6523         { &hf_gsm_a_dtap_epc_ue_tl_c_mch_id,
6524           { "MCH identity","gsm_a.dtap.epc.ue_tl_c_mch_id",
6525             FT_UINT8, BASE_DEC, NULL, 0x0,
6526             NULL, HFILL }
6527         },
6528         { &hf_gsm_a_dtap_epc_ue_tl_c_lcid,
6529           { "Logical channel identity","gsm_a.dtap.epc.ue_tl_c_lcid",
6530             FT_UINT8, BASE_DEC, NULL, 0x0,
6531             NULL, HFILL }
6532         },
6533         { &hf_gsm_a_dtap_epc_ue_positioning_technology,
6534           { "UE positioning technology","gsm_a.dtap.epc.ue_positioning_technology",
6535             FT_UINT8, BASE_DEC, VALS(epc_ue_positioning_technology_vals), 0x0,
6536             NULL, HFILL }
6537         },
6538         { &hf_gsm_a_dtap_epc_mbms_packet_counter_value,
6539           { "MBMS packet counter value","gsm_a.dtap.epc.mbms_packet_counter_value",
6540             FT_UINT32, BASE_DEC, NULL, 0x0,
6541             NULL, HFILL }
6542         },
6543         { &hf_gsm_a_dtap_epc_latitude_sign,
6544           { "Latitude Sign","gsm_a.dtap.epc.latitude_sign",
6545             FT_BOOLEAN, BASE_NONE, TFS(&epc_latitude_sign_value), 0x0,
6546             NULL, HFILL }
6547         },
6548         { &hf_gsm_a_dtap_epc_degrees_latitude,
6549           { "Degrees Latitude","gsm_a.dtap.epc.degrees_latitude",
6550             FT_UINT24, BASE_DEC, NULL, 0x0,
6551             NULL, HFILL }
6552         },
6553         { &hf_gsm_a_dtap_epc_degrees_longitude,
6554           { "Degrees Longitude","gsm_a.dtap.epc.degrees_longitude",
6555             FT_INT24, BASE_DEC, NULL, 0x0,
6556             NULL, HFILL }
6557         },
6558         { &hf_gsm_a_dtap_epc_altitude_dir,
6559           { "Altitude Direction","gsm_a.dtap.epc.altitude_direction",
6560             FT_BOOLEAN, BASE_NONE, TFS(&epc_altitude_dir_value), 0x0,
6561             NULL, HFILL }
6562         },
6563         { &hf_gsm_a_dtap_epc_altitude,
6564           { "Altitude","gsm_a.dtap.epc.altitude",
6565             FT_UINT16, BASE_DEC, NULL, 0x0,
6566             NULL, HFILL }
6567         },
6568         { &hf_gsm_a_dtap_epc_bearing,
6569           { "Bearing","gsm_a.dtap.epc.bearing",
6570             FT_UINT16, BASE_DEC, NULL, 0x0,
6571             NULL, HFILL }
6572         },
6573         { &hf_gsm_a_dtap_epc_horizontal_speed,
6574           { "Horizontal Speed","gsm_a.dtap.epc.horizontal_speed",
6575             FT_UINT16, BASE_DEC, NULL, 0x0,
6576             NULL, HFILL }
6577         },
6578         { &hf_gsm_a_dtap_epc_gnss_tod_msec,
6579           { "GNSS-TOD-msec","gsm_a.dtap.epc.gnss_tod_msec",
6580             FT_UINT24, BASE_DEC, NULL, 0x0,
6581             NULL, HFILL }
6582         },
6583         /* Generated from convert_proto_tree_add_text.pl */
6584         { &hf_gsm_a_dtap_coding_scheme,
6585           { "Coding Scheme", "gsm_a.dtap.coding_scheme",
6586             FT_UINT8, BASE_DEC, NULL, 0x70,
6587             NULL, HFILL }
6588         },
6589         { &hf_gsm_a_dtap_add_ci,
6590           { "Add CI", "gsm_a.dtap.add_ci",
6591             FT_BOOLEAN, 8, TFS(&tfs_add_ci), 0x08,
6592             NULL, HFILL }
6593         },
6594         { &hf_gsm_a_dtap_number_of_spare_bits,
6595           { "Number of spare bits in last octet", "gsm_a.dtap.number_of_spare_bits",
6596             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_number_of_spare_bits_vals), 0x07,
6597             NULL, HFILL }
6598         },
6599         { &hf_gsm_a_dtap_text_string,
6600           { "Text String", "gsm_a.dtap.text_string",
6601             FT_STRING, BASE_NONE, NULL, 0x0,
6602             NULL, HFILL }
6603         },
6604         { &hf_gsm_a_dtap_time_zone_time,
6605           { "Time", "gsm_a.dtap.time_zone_time",
6606             FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0,
6607             NULL, HFILL }
6608         },
6609         { &hf_gsm_a_dtap_dst_adjustment,
6610           { "DST Adjustment", "gsm_a.dtap.dst_adjustment",
6611             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_dst_adjustment_vals), 0x03,
6612             NULL, HFILL }
6613         },
6614         { &hf_gsm_a_dtap_emergency_number_information,
6615           { "Emergency Number Information", "gsm_a.dtap.emergency_number_information",
6616             FT_UINT32, BASE_DEC, NULL, 0x0,
6617             NULL, HFILL }
6618         },
6619         { &hf_gsm_a_dtap_mm_timer,
6620           { "MM Timer", "gsm_a.dtap.mm_timer",
6621             FT_UINT8, BASE_DEC, NULL, 0,
6622             NULL, HFILL }
6623         },
6624         { &hf_gsm_a_dtap_hold_auxiliary_state,
6625           { "Hold auxiliary state", "gsm_a.dtap.hold_auxiliary_state",
6626             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_hold_auxilary_state_vals), 0x0C,
6627             NULL, HFILL }
6628         },
6629         { &hf_gsm_a_dtap_multi_party_auxiliary_state,
6630           { "Multi party auxiliary state", "gsm_a.dtap.multi_party_auxiliary_state",
6631             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_multi_party_auxilary_state_vals), 0x03,
6632             NULL, HFILL }
6633         },
6634         { &hf_gsm_a_dtap_radio_channel_requirement,
6635           { "Radio channel requirement", "gsm_a.dtap.radio_channel_requirement",
6636             FT_UINT8, BASE_DEC, NULL, 0x60,
6637             NULL, HFILL }
6638         },
6639         { &hf_gsm_a_dtap_bearer_cap_coding_standard,
6640           { "Coding standard", "gsm_a.dtap.coding_standard",
6641             FT_BOOLEAN, 8, TFS(&tfs_bearer_cap_coding_standard), 0x10,
6642             NULL, HFILL }
6643         },
6644         { &hf_gsm_a_dtap_transfer_mode,
6645           { "Transfer mode", "gsm_a.dtap.transfer_mode",
6646             FT_BOOLEAN, 8, TFS(&tfs_bearer_cap_transfer_mode), 0x08,
6647             NULL, HFILL }
6648         },
6649         { &hf_gsm_a_dtap_coding,
6650           { "Coding", "gsm_a.dtap.coding",
6651             FT_BOOLEAN, 8, TFS(&tfs_bearer_cap_coding), 0x40,
6652             NULL, HFILL }
6653         },
6654         { &hf_gsm_a_dtap_compression,
6655           { "Compression", "gsm_a.dtap.compression",
6656             FT_BOOLEAN, 8, TFS(&tfs_possible_not_possible), 0x40,
6657             NULL, HFILL }
6658         },
6659         { &hf_gsm_a_dtap_compression_up,
6660           { "Compression", "gsm_a.dtap.compression",
6661             FT_BOOLEAN, 8, TFS(&tfs_allowed_not_allowed), 0x40,
6662             NULL, HFILL }
6663         },
6664         { &hf_gsm_a_dtap_structure,
6665           { "Structure", "gsm_a.dtap.structure",
6666             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_structure_vals), 0x30,
6667             NULL, HFILL }
6668         },
6669         { &hf_gsm_a_dtap_duplex_mode,
6670           { "Duplex mode", "gsm_a.dtap.duplex_mode",
6671             FT_BOOLEAN, 8, TFS(&tfs_full_half), 0x08,
6672             NULL, HFILL }
6673         },
6674         { &hf_gsm_a_dtap_configuration,
6675           { "Configuration", "gsm_a.dtap.configuration",
6676             FT_BOOLEAN, 8, TFS(&tfs_bearer_cap_configuration), 0x04,
6677             NULL, HFILL }
6678         },
6679         { &hf_gsm_a_dtap_nirr,
6680           { "NIRR", "gsm_a.dtap.nirr",
6681             FT_BOOLEAN, 8, TFS(&tfs_nirr), 0x02,
6682             NULL, HFILL }
6683         },
6684         { &hf_gsm_a_dtap_establishment,
6685           { "Establishment", "gsm_a.dtap.establishment",
6686             FT_BOOLEAN, 8, TFS(&tfs_bearer_cap_establishment), 0x01,
6687             NULL, HFILL }
6688         },
6689         { &hf_gsm_a_dtap_access_identity,
6690           { "Access Identity", "gsm_a.dtap.access_identity",
6691             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_access_identity_vals), 0x60,
6692             NULL, HFILL }
6693         },
6694         { &hf_gsm_a_dtap_rate_adaption,
6695           { "Rate Adaption", "gsm_a.dtap.rate_adaption",
6696             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_rate_adaption_vals), 0x18,
6697             NULL, HFILL }
6698         },
6699         { &hf_gsm_a_dtap_signalling_access_protocol,
6700           { "Signalling Access Protocol", "gsm_a.dtap.signalling_access_protocol",
6701             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_signal_access_protocol_vals), 0x07,
6702             NULL, HFILL }
6703         },
6704         { &hf_gsm_a_dtap_other_itc,
6705           { "Other ITC", "gsm_a.dtap.other_itc",
6706             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_other_itc_vals), 0x60,
6707             NULL, HFILL }
6708         },
6709         { &hf_gsm_a_dtap_other_rate_adaption,
6710           { "Other Rate Adaption", "gsm_a.dtap.other_rate_adaption",
6711             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_other_rate_adaption_vals), 0x18,
6712             NULL, HFILL }
6713         },
6714         { &hf_gsm_a_dtap_rate_adaption_header,
6715           { "Rate Adaption Header", "gsm_a.dtap.rate_adaption_header",
6716             FT_BOOLEAN, 8, TFS(&tfs_included_not_included), 0x40,
6717             NULL, HFILL }
6718         },
6719         { &hf_gsm_a_dtap_multiple_frame_establishment_support,
6720           { "Multiple frame establishment support in data link", "gsm_a.dtap.multiple_frame_establishment_support",
6721             FT_BOOLEAN, 8, TFS(&tfs_frame_est_supported_not_supported), 0x20,
6722             NULL, HFILL }
6723         },
6724         { &hf_gsm_a_dtap_mode_of_operation,
6725           { "Mode of operation", "gsm_a.dtap.mode_of_operation",
6726             FT_BOOLEAN, 8, TFS(&tfs_protocol_sensative_bit_transparent), 0x10,
6727             NULL, HFILL }
6728         },
6729         { &hf_gsm_a_dtap_logical_link_identifier_negotiation,
6730           { "Logical link identifier negotiation", "gsm_a.dtap.logical_link_identifier_negotiation",
6731             FT_BOOLEAN, 8, TFS(&tfs_log_link_neg), 0x08,
6732             NULL, HFILL }
6733         },
6734         { &hf_gsm_a_dtap_assignor_assignee,
6735           { "Assignor/Assignee", "gsm_a.dtap.assignor_assignee",
6736             FT_BOOLEAN, 8, TFS(&tfs_assignor_assignee), 0x04,
6737             NULL, HFILL }
6738         },
6739         { &hf_gsm_a_dtap_in_out_band,
6740           { "In band/Out of band negotiation", "gsm_a.dtap.in_out_band",
6741             FT_BOOLEAN, 8, TFS(&tfs_in_out_band), 0x02,
6742             NULL, HFILL }
6743         },
6744         { &hf_gsm_a_dtap_layer_1_identity,
6745           { "Layer 1 Identity", "gsm_a.dtap.layer_1_identity",
6746             FT_UINT8, BASE_DEC, NULL, 0x60,
6747             NULL, HFILL }
6748         },
6749         { &hf_gsm_a_dtap_user_information_layer_1_protocol,
6750           { "User information layer 1 protocol", "gsm_a.dtap.user_information_layer_1_protocol",
6751             FT_UINT8, BASE_DEC, NULL, 0x1e,
6752             NULL, HFILL }
6753         },
6754         { &hf_gsm_a_dtap_synchronous,
6755           { "Synchronous/asynchronous", "gsm_a.dtap.synchronous",
6756             FT_BOOLEAN, 8, TFS(&tfs_asynchronous_synchronous), 0x01,
6757             NULL, HFILL }
6758         },
6759         { &hf_gsm_a_dtap_number_of_stop_bits,
6760           { "Number of Stop Bits", "gsm_a.dtap.number_of_stop_bits",
6761             FT_BOOLEAN, 8, TFS(&tfs_stop_bits), 0x40,
6762             NULL, HFILL }
6763         },
6764         { &hf_gsm_a_dtap_negotiation,
6765           { "Negotiation", "gsm_a.dtap.negotiation",
6766             FT_BOOLEAN, 8, TFS(&tfs_negotiation), 0x20,
6767             NULL, HFILL }
6768         },
6769         { &hf_gsm_a_dtap_number_of_data_bits,
6770           { "Number of data bits excluding parity bit if present", "gsm_a.dtap.number_of_data_bits",
6771             FT_BOOLEAN, 8, TFS(&tfs_parity_bits), 0x10,
6772             NULL, HFILL }
6773         },
6774         { &hf_gsm_a_dtap_user_rate,
6775           { "User rate", "gsm_a.dtap.user_rate",
6776             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_user_rate_vals), 0x0F,
6777             NULL, HFILL }
6778         },
6779         { &hf_gsm_a_dtap_v110_x30_rate_adaptation,
6780           { "V.110/X.30 rate adaptation Intermediate rate", "gsm_a.dtap.v110_x30_rate_adaptation",
6781             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_v110_x30_rate_adaptation_vals), 0x60,
6782             NULL, HFILL }
6783         },
6784         { &hf_gsm_a_dtap_nic_on_tx,
6785           { "Network independent clock (NIC) on transmission (Tx)", "gsm_a.dtap.nic_on_tx",
6786             FT_BOOLEAN, 8, TFS(&tfs_nic_on_tx), 0x10,
6787             NULL, HFILL }
6788         },
6789         { &hf_gsm_a_dtap_nic_on_rx,
6790           { "Network independent clock (NIC) on reception (Rx)", "gsm_a.dtap.nic_on_rx",
6791             FT_BOOLEAN, 8, TFS(&tfs_nic_on_rx), 0x08,
6792             NULL, HFILL }
6793         },
6794         { &hf_gsm_a_dtap_parity_information,
6795           { "Parity information", "gsm_a.dtap.parity_information",
6796             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_parity_info_vals), 0x07,
6797             NULL, HFILL }
6798         },
6799         { &hf_gsm_a_dtap_connection_element,
6800           { "Connection element", "gsm_a.dtap.connection_element",
6801             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_connection_element_vals), 0x60,
6802             NULL, HFILL }
6803         },
6804         { &hf_gsm_a_dtap_modem_type,
6805           { "Modem type", "gsm_a.dtap.modem_type",
6806             FT_UINT8, BASE_DEC, NULL, 0x1f,
6807             NULL, HFILL }
6808         },
6809         { &hf_gsm_a_dtap_other_modem_type,
6810           { "Other modem type", "gsm_a.dtap.other_modem_type",
6811             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_other_modem_type_vals), 0x60,
6812             NULL, HFILL }
6813         },
6814         { &hf_gsm_a_dtap_fixed_network_user_rate,
6815           { "Fixed network user rate", "gsm_a.dtap.fixed_network_user_rate",
6816             FT_UINT8, BASE_DEC, NULL, 0x1f,
6817             NULL, HFILL }
6818         },
6819         { &hf_gsm_a_dtap_acceptable_channel_codings_TCH_F14_4,
6820           { "Acceptable channel codings (TCH/F14.4)", "gsm_a.dtap.acceptable_channel_codings.TCH_F14_4",
6821             FT_BOOLEAN, 8, TFS(&tfs_acceptable_not_acceptable), 0x40,
6822             NULL, HFILL }
6823         },
6824         { &hf_gsm_a_dtap_acceptable_channel_codings_spare20,
6825           { "Acceptable channel codings (Spare)", "gsm_a.dtap.acceptable_channel_codings.spare",
6826             FT_BOOLEAN, 8, NULL, 0x20,
6827             NULL, HFILL }
6828         },
6829         { &hf_gsm_a_dtap_acceptable_channel_codings_TCH_F9_6,
6830           { "Acceptable channel codings (TCH/F9.6)", "gsm_a.dtap.acceptable_channel_codings.TCH_F9_6",
6831             FT_BOOLEAN, 8, TFS(&tfs_acceptable_not_acceptable), 0x10,
6832             NULL, HFILL }
6833         },
6834         { &hf_gsm_a_dtap_acceptable_channel_codings_TCH_F4_8,
6835           { "Acceptable channel codings (TCH/F4.8)", "gsm_a.dtap.acceptable_channel_codings.TCH_F4_8",
6836             FT_BOOLEAN, 8, TFS(&tfs_acceptable_not_acceptable), 0x08,
6837             NULL, HFILL }
6838         },
6839         { &hf_gsm_a_dtap_maximum_number_of_traffic_channels,
6840           { "Maximum number of traffic channels", "gsm_a.dtap.maximum_number_of_traffic_channels",
6841             FT_UINT8, BASE_DEC, NULL, 0x07,
6842             NULL, HFILL }
6843         },
6844         { &hf_gsm_a_dtap_acceptable_channel_codings_spare78,
6845           { "Acceptable channel codings", "gsm_a.dtap.acceptable_channel_codings",
6846             FT_UINT8, BASE_DEC, NULL, 0x78,
6847             NULL, HFILL }
6848         },
6849         { &hf_gsm_a_dtap_uimi,
6850           { "UIMI, User initiated modification indication",
6851             "gsm_a.dtap.uimi", FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_uimi_vals),
6852             0x70, NULL, HFILL }
6853         },
6854         { &hf_gsm_a_dtap_wanted_air_interface_user_rate,
6855           { "Wanted air interface user rate", "gsm_a.dtap.wanted_air_interface_user_rate",
6856             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_wanted_air_rate_vals), 0x0F,
6857             NULL, HFILL }
6858         },
6859         { &hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F28_8,
6860           { "Acceptable channel codings extended (TCH/F28.8)", "gsm_a.dtap.acceptable_channel_codings_ext.TCH_F28_8",
6861             FT_BOOLEAN, 8, TFS(&tfs_acceptable_not_acceptable), 0x40,
6862             NULL, HFILL }
6863         },
6864         { &hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F32_0,
6865           { "Acceptable channel codings extended (TCH/F32.0)", "gsm_a.dtap.acceptable_channel_codings_ext.TCH_F32_0",
6866             FT_BOOLEAN, 8, TFS(&tfs_acceptable_not_acceptable), 0x20,
6867             NULL, HFILL }
6868         },
6869         { &hf_gsm_a_dtap_acceptable_channel_codings_ext_TCH_F43_2,
6870           { "Acceptable channel codings extended (TCH/F43.2)", "gsm_a.dtap.acceptable_channel_codings_ext.TCH_F43_2",
6871             FT_BOOLEAN, 8, TFS(&tfs_acceptable_not_acceptable), 0x10,
6872             NULL, HFILL }
6873         },
6874         { &hf_gsm_a_dtap_channel_coding_asymmetry_indication,
6875           { "Channel Coding Asymmetry Indication", "gsm_a.dtap.channel_coding_asymmetry_indication",
6876             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_channel_coding_asymmetry_ind_vals), 0x0c,
6877             NULL, HFILL }
6878         },
6879         { &hf_gsm_a_dtap_edge_channel_codings,
6880           { "EDGE Channel Codings", "gsm_a.dtap.edge_channel_codings",
6881             FT_UINT8, BASE_DEC, NULL, 0x7c,
6882             NULL, HFILL }
6883         },
6884         { &hf_gsm_a_dtap_layer_2_identity,
6885           { "Layer 2 Identity", "gsm_a.dtap.layer_2_identity",
6886             FT_UINT8, BASE_DEC, NULL, 0x60,
6887             NULL, HFILL }
6888         },
6889         { &hf_gsm_a_dtap_user_information_layer_2_protocol,
6890           { "User information layer 2 protocol", "gsm_a.dtap.user_information_layer_2_protocol",
6891             FT_UINT8, BASE_DEC, NULL, 0x1f,
6892             NULL, HFILL }
6893         },
6894         { &hf_gsm_a_dtap_maximum_number_of_supported_bearers,
6895           { "Maximum number of supported bearers", "gsm_a.dtap.maximum_number_of_supported_bearers",
6896             FT_UINT8, BASE_DEC, NULL, 0xf0,
6897             NULL, HFILL }
6898         },
6899         { &hf_gsm_a_dtap_pcp,
6900           { "Prolonged Clearing Procedure", "gsm_a.dtap.pcp",
6901             FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x02,
6902             NULL, HFILL }
6903         },
6904         { &hf_gsm_a_dtap_dtmf,
6905           { "DTMF", "gsm_a.dtap.dtmf",
6906             FT_BOOLEAN, 8, TFS(&gsm_a_dtap_dtmf_value), 0x01,
6907             NULL, HFILL }
6908         },
6909         { &hf_gsm_a_dtap_max_num_of_speech_bearers,
6910           { "Maximum number of speech bearers", "gsm_a.dtap.max_num_of_speech_bearers",
6911             FT_UINT8, BASE_DEC, NULL, 0x0f,
6912             NULL, HFILL }
6913         },
6914         { &hf_gsm_a_dtap_de_cause_coding_standard,
6915           { "Coding standard", "gsm_a.dtap.coding_standard",
6916             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_de_cause_coding_standard_vals), 0x60,
6917             NULL, HFILL }
6918         },
6919         { &hf_gsm_a_dtap_recommendation,
6920           { "Recommendation", "gsm_a.dtap.recommendation",
6921             FT_UINT8, BASE_DEC, NULL, 0x7f,
6922             NULL, HFILL }
6923         },
6924         { &hf_gsm_a_dtap_data,
6925           { "Data", "gsm_a.dtap.data",
6926             FT_BYTES, BASE_NONE, NULL, 0x0,
6927             NULL, HFILL }
6928         },
6929         { &hf_gsm_a_dtap_keypad_information,
6930           { "Keypad information", "gsm_a.dtap.keypad_information",
6931             FT_UINT8, BASE_DEC, NULL, 0x7f,
6932             NULL, HFILL }
6933         },
6934         { &hf_gsm_a_dtap_repeat_indicator,
6935           { "Repeat Indicator", "gsm_a.dtap.repeat_indicator",
6936             FT_UINT8, BASE_DEC, NULL, 0x0f,
6937             NULL, HFILL }
6938         },
6939         { &hf_gsm_a_dtap_ss_version_indicator,
6940           { "SS Version Indicator", "gsm_a.dtap.ss_version_indicator",
6941             FT_UINT8, BASE_DEC, NULL, 0x0,
6942             NULL, HFILL }
6943         },
6944         { &hf_gsm_a_dtap_cp_cause,
6945           { "Cause", "gsm_a.dtap.cp_cause",
6946             FT_UINT8, BASE_DEC, NULL, 0x0,
6947             NULL, HFILL }
6948         },
6949         { &hf_gsm_a_dtap_test_loop,
6950           { "Test Loop", "gsm_a.dtap.test_loop",
6951             FT_UINT8, BASE_DEC, NULL, 0x3f,
6952             NULL, HFILL }
6953         },
6954         { &hf_gsm_a_dtap_channel_coding03,
6955           { "Channel coding", "gsm_a.dtap.channel_coding",
6956             FT_UINT8, BASE_DEC, VALS(gsm_channel_coding_vals), 0x03,
6957             NULL, HFILL }
6958         },
6959         { &hf_gsm_a_dtap_channel_coding30,
6960           { "Channel coding", "gsm_a.dtap.channel_coding",
6961             FT_UINT8, BASE_DEC, VALS(gsm_channel_coding_vals), 0x30,
6962             NULL, HFILL }
6963         },
6964         { &hf_gsm_a_dtap_tp_tested_device,
6965           { "Tested device", "gsm_a.dtap.tp_tested_device",
6966             FT_UINT8, BASE_DEC, NULL, 0x0,
6967             NULL, HFILL }
6968         },
6969         { &hf_gsm_a_dtap_tp_pdu_description,
6970           { "PDUs transmitted", "gsm_a.dtap.tp_pdu_description",
6971             FT_UINT16, BASE_DEC, NULL, 0x0,
6972             NULL, HFILL }
6973         },
6974         { &hf_gsm_a_dtap_downlink_timeslot_offset,
6975           { "Downlink Timeslot Offset", "gsm_a.dtap.downlink_timeslot_offset",
6976             FT_UINT8, BASE_DEC, NULL, 0x0E,
6977             NULL, HFILL }
6978         },
6979         { &hf_gsm_a_dtap_ms_positioning_technology,
6980           { "MS positioning technology", "gsm_a.dtap.ms_positioning_technology",
6981             FT_UINT8, BASE_DEC, VALS(gsm_positioning_technology_vals), 0x0,
6982             NULL, HFILL }
6983         },
6984         { &hf_gsm_a_dtap_ue_positioning_technology,
6985           { "UE positioning technology", "gsm_a.dtap.ue_positioning_technology",
6986             FT_UINT8, BASE_DEC, VALS(gsm_positioning_technology_vals), 0x0,
6987             NULL, HFILL }
6988         },
6989         { &hf_gsm_a_dtap_ciphering_key_sequence_number,
6990           { "Ciphering Key Sequence Number", "gsm_a.dtap.ciphering_key_sequence_number",
6991             FT_UINT8, BASE_DEC, NULL, 0x07,
6992             NULL, HFILL }
6993         },
6994         { &hf_gsm_a_dtap_ciphering_key_sequence_number70,
6995           { "Ciphering Key Sequence Number", "gsm_a.dtap.ciphering_key_sequence_number",
6996             FT_UINT8, BASE_DEC, NULL, 0x70,
6997             NULL, HFILL }
6998         },
6999         { &hf_gsm_a_dtap_service_type,
7000           { "Service Type", "gsm_a.dtap.service_type",
7001             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_service_type_vals), 0x0F,
7002             NULL, HFILL }
7003         },
7004         { &hf_gsm_a_dtap_type_of_identity,
7005           { "Type of identity", "gsm_a.dtap.type_of_identity",
7006             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_type_of_identity_vals), 0x07,
7007             NULL, HFILL }
7008         },
7009         { &hf_gsm_a_dtap_follow_on_request,
7010           { "Follow-On Request (FOR)", "gsm_a.dtap.follow_on_request",
7011             FT_BOOLEAN, 8, TFS(&tfs_follow_on_request_value ), 0x08,
7012             NULL, HFILL }
7013         },
7014         { &hf_gsm_a_dtap_updating_type,
7015           { "Updating Type", "gsm_a.dtap.updating_type",
7016             FT_UINT8, BASE_DEC, VALS(gsm_a_dtap_updating_type_vals), 0x03,
7017             NULL, HFILL }
7018         },
7019         { &hf_gsm_a_dtap_congestion_level,
7020           { "Congestion level", "gsm_a.dtap.congestion_level",
7021             FT_UINT8, BASE_DEC, NULL, 0x0F,
7022             NULL, HFILL }
7023         },
7024         { &hf_gsm_a_dtap_protocol_discriminator,
7025           { "Protocol Discriminator", "gsm_a.dtap.protocol_discriminator",
7026             FT_UINT8, BASE_DEC, VALS(protocol_discriminator_vals), 0x0,
7027             NULL, HFILL }
7028         },
7029         { &hf_gsm_a_dtap_ti_flag,
7030           { "TI flag", "gsm_a.dtap.ti_flag",
7031             FT_BOOLEAN, 8, TFS(&tfs_allocated_by_receiver_sender), 0x80,
7032             NULL, HFILL }
7033         },
7034         { &hf_gsm_a_dtap_tio,
7035           { "TIO", "gsm_a.dtap.tio",
7036             FT_UINT8, BASE_DEC, NULL, 0x70,
7037             NULL, HFILL }
7038         },
7039         { &hf_gsm_a_dtap_tie,
7040           { "TIE", "gsm_a.dtap.tie",
7041             FT_UINT8, BASE_DEC, NULL, DTAP_TIE_MASK,
7042             NULL, HFILL }
7043         },
7044     };
7045
7046     /* Setup protocol subtree array */
7047 #define NUM_INDIVIDUAL_ELEMS    21
7048     gint *ett[NUM_INDIVIDUAL_ELEMS +
7049           NUM_GSM_DTAP_MSG_MM + NUM_GSM_DTAP_MSG_CC +
7050           NUM_GSM_DTAP_MSG_SMS + NUM_GSM_DTAP_MSG_SS + NUM_GSM_DTAP_MSG_TP +
7051           NUM_GSM_DTAP_ELEM];
7052
7053     static ei_register_info ei[] = {
7054         { &ei_gsm_a_dtap_autn, { "gsm_a.dtap.autn.invalid", PI_MALFORMED, PI_WARN, "AUTN length not equal to 16", EXPFILL }},
7055         { &ei_gsm_a_dtap_auts, { "gsm_a.dtap.auts.invalid", PI_MALFORMED, PI_WARN, "AUTS length not equal to 14", EXPFILL }},
7056         { &ei_gsm_a_dtap_text_string_not_multiple_of_7, { "gsm_a.dtap.text_string_not_multiple_of_7", PI_MALFORMED, PI_WARN, "Value leads to a Text String whose length is not a multiple of 7 bits", EXPFILL }},
7057         { &ei_gsm_a_dtap_end_mark_unexpected, { "gsm_a.dtap.end_mark_unexpected", PI_MALFORMED, PI_WARN, "\'f\' end mark present in unexpected position", EXPFILL }},
7058         { &ei_gsm_a_dtap_invalid_ia5_character, { "gsm_a.dtap.invalid_ia5_character", PI_MALFORMED, PI_WARN, "Invalid IA5 character(s) in string (value > 127)", EXPFILL }},
7059         { &ei_gsm_a_dtap_keypad_info_not_dtmf_digit, { "gsm_a.dtap.keypad_info_not_dtmf_digit", PI_MALFORMED, PI_WARN, "Keypad information contains character that is not a DTMF digit", EXPFILL }},
7060         { &ei_gsm_a_dtap_extraneous_data, { "gsm_a.dtap.extraneous_data", PI_PROTOCOL, PI_NOTE, "Extraneous Data, dissector bug or later version spec(report to wireshark.org)", EXPFILL }},
7061         { &ei_gsm_a_dtap_missing_mandatory_element, { "gsm_a.dtap.missing_mandatory_element", PI_PROTOCOL, PI_WARN, "Missing Mandatory element, rest of dissection is suspect", EXPFILL }},
7062     };
7063
7064     expert_module_t* expert_a_dtap;
7065
7066     ett[0]  = &ett_dtap_msg;
7067     ett[1]  = &ett_dtap_oct_1;
7068     ett[2]  = &ett_cm_srvc_type;
7069     ett[3]  = &ett_gsm_enc_info;
7070     ett[4]  = &ett_bc_oct_3;
7071     ett[5]  = &ett_bc_oct_3a;
7072     ett[6]  = &ett_bc_oct_4;
7073     ett[7]  = &ett_bc_oct_5;
7074     ett[8]  = &ett_bc_oct_5a;
7075     ett[9]  = &ett_bc_oct_5b;
7076     ett[10] = &ett_bc_oct_6;
7077     ett[11] = &ett_bc_oct_6a;
7078     ett[12] = &ett_bc_oct_6b;
7079     ett[13] = &ett_bc_oct_6c;
7080     ett[14] = &ett_bc_oct_6d;
7081     ett[15] = &ett_bc_oct_6e;
7082     ett[16] = &ett_bc_oct_6f;
7083     ett[17] = &ett_bc_oct_6g;
7084     ett[18] = &ett_bc_oct_7;
7085     ett[19] = &ett_epc_ue_tl_a_lb_setup;
7086     ett[20] = &ett_mm_timer;
7087
7088     last_offset = NUM_INDIVIDUAL_ELEMS;
7089
7090     for (i=0; i < NUM_GSM_DTAP_MSG_MM; i++, last_offset++)
7091     {
7092         ett_gsm_dtap_msg_mm[i] = -1;
7093         ett[last_offset] = &ett_gsm_dtap_msg_mm[i];
7094     }
7095
7096     for (i=0; i < NUM_GSM_DTAP_MSG_CC; i++, last_offset++)
7097     {
7098         ett_gsm_dtap_msg_cc[i] = -1;
7099         ett[last_offset] = &ett_gsm_dtap_msg_cc[i];
7100     }
7101
7102     for (i=0; i < NUM_GSM_DTAP_MSG_SMS; i++, last_offset++)
7103     {
7104         ett_gsm_dtap_msg_sms[i] = -1;
7105         ett[last_offset] = &ett_gsm_dtap_msg_sms[i];
7106     }
7107
7108     for (i=0; i < NUM_GSM_DTAP_MSG_SS; i++, last_offset++)
7109     {
7110         ett_gsm_dtap_msg_ss[i] = -1;
7111         ett[last_offset] = &ett_gsm_dtap_msg_ss[i];
7112     }
7113
7114     for (i=0; i < NUM_GSM_DTAP_MSG_TP; i++, last_offset++)
7115     {
7116         ett_gsm_dtap_msg_tp[i] = -1;
7117         ett[last_offset] = &ett_gsm_dtap_msg_tp[i];
7118     }
7119
7120     for (i=0; i < NUM_GSM_DTAP_ELEM; i++, last_offset++)
7121     {
7122         ett_gsm_dtap_elem[i] = -1;
7123         ett[last_offset] = &ett_gsm_dtap_elem[i];
7124     }
7125
7126     /* Register the protocol name and description */
7127
7128     proto_a_dtap =
7129         proto_register_protocol("GSM A-I/F DTAP", "GSM DTAP", "gsm_a.dtap");
7130
7131     proto_register_field_array(proto_a_dtap, hf, array_length(hf));
7132
7133     proto_register_subtree_array(ett, array_length(ett));
7134     expert_a_dtap = expert_register_protocol(proto_a_dtap);
7135     expert_register_field_array(expert_a_dtap, ei, array_length(ei));
7136
7137
7138     /* subdissector code */
7139     new_register_dissector("gsm_a_dtap", dissect_dtap, proto_a_dtap);
7140 }
7141
7142 void
7143 proto_reg_handoff_gsm_a_dtap(void)
7144 {
7145     dissector_handle_t dtap_handle;
7146
7147     dtap_handle = find_dissector("gsm_a_dtap");
7148     dissector_add_uint("bssap.pdu_type", BSSAP_PDU_TYPE_DTAP, dtap_handle);
7149     dissector_add_uint("ranap.nas_pdu", BSSAP_PDU_TYPE_DTAP, dtap_handle);
7150     dissector_add_uint("llcgprs.sapi", 1 , dtap_handle); /* GPRS Mobility Management */
7151     dissector_add_uint("llcgprs.sapi", 7 , dtap_handle); /* SMS */
7152     dissector_add_uint("lapdm.sapi",   0 , dtap_handle); /* LAPDm: CC/RR/MM */
7153     dissector_add_uint("lapdm.sapi",   3 , dtap_handle); /* LAPDm: SMS/SS */
7154
7155     data_handle    = find_dissector("data");
7156     gsm_map_handle = find_dissector("gsm_map");
7157     rp_handle      = find_dissector("gsm_a_rp");
7158 }
7159
7160
7161 /*
7162  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
7163  *
7164  * Local variables:
7165  * c-basic-offset: 4
7166  * tab-width: 8
7167  * indent-tabs-mode: nil
7168  * End:
7169  *
7170  * vi: set shiftwidth=4 tabstop=8 expandtab:
7171  * :indentSize=4:tabSize=8:noTabs=true:
7172  */