some compilers dont like unnamed unions and structs
[obnox/wireshark/wip.git] / epan / dissectors / packet-gsm_a.c
1 /* packet-gsm_a.c
2  * Routines for GSM A Interface (BSSMAP/DTAP) dissection
3  *
4  * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
5  * In association with Telos Technology Inc.
6  *
7  *
8  * Added the GPRS Mobility Managment Protocol and 
9  * the GPRS Session Managment Protocol
10  *   Copyright 2004, Rene Pilz <rene.pilz [AT] ftw.com>
11  *   In association with Telecommunications Research Center 
12  *   Vienna (ftw.)Betriebs-GmbH within the Project Metawin.
13  *
14  * Added Dissection of Radio Resource Management Information Elements
15  * and othere enhancements and fixes.
16  * Copyright 2005 - 2006, Anders Broman [AT] ericsson.com
17  * Small bugfixes, mainly in Qos and TFT by Nils Ljungberg and Stefan Boman [AT] ericsson.com
18  *
19  * Title                3GPP                    Other
20  *
21  *   Reference [1]
22  *   Mobile radio interface signalling layer 3;
23  *   General Aspects
24  *   (3GPP TS 24.007 version 3.9.0 Release 1999)
25  *
26  *   Reference [2]
27  *   Mobile-services Switching Centre - Base Station System
28  *   (MSC - BSS) interface;
29  *   Layer 3 specification
30  *   (GSM 08.08 version 7.7.0 Release 1998)     TS 100 590 v7.7.0
31  *
32  *   Reference [3]
33  *   Mobile radio interface Layer 3 specification;
34  *   Core network protocols;
35  *   Stage 3
36  *   (3GPP TS 24.008 version 4.7.0 Release 4)
37  *   (ETSI TS 124 008 V6.8.0 (2005-03))
38  *
39  *   Reference [4]
40  *   Mobile radio interface layer 3 specification;
41  *   Radio Resource Control Protocol
42  *   (GSM 04.18 version 8.4.1 Release 1999)
43  *   (3GPP TS 04.18 version 8.26.0 Release 1999)
44  *
45  *   Reference [5]
46  *   Point-to-Point (PP) Short Message Service (SMS)
47  *   support on mobile radio interface
48  *   (3GPP TS 24.011 version 4.1.1 Release 4)
49  *
50  *   Reference [6]
51  *   Mobile radio Layer 3 supplementary service specification;
52  *   Formats and coding
53  *   (3GPP TS 24.080 version 4.3.0 Release 4)
54  *
55  *   Reference [7]
56  *   Mobile radio interface Layer 3 specification;
57  *   Core network protocols;
58  *   Stage 3
59  *   (3GPP TS 24.008 version 5.9.0 Release 5)
60  *
61  *   Reference [8]
62  *   Mobile radio interface Layer 3 specification;
63  *   Core network protocols;
64  *   Stage 3
65  *   (3GPP TS 24.008 version 6.7.0 Release 6)
66  *       (3GPP TS 24.008 version 6.8.0 Release 6)
67  *
68  * $Id$
69  *
70  * Wireshark - Network traffic analyzer
71  * By Gerald Combs <gerald@wireshark.org>
72  * Copyright 1998 Gerald Combs
73  *
74  * This program is free software; you can redistribute it and/or
75  * modify it under the terms of the GNU General Public License
76  * as published by the Free Software Foundation; either version 2
77  * of the License, or (at your option) any later version.
78  *
79  * This program is distributed in the hope that it will be useful,
80  * but WITHOUT ANY WARRANTY; without even the implied warranty of
81  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
82  * GNU General Public License for more details.
83  *
84  * You should have received a copy of the GNU General Public License
85  * along with this program; if not, write to the Free Software
86  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
87  */
88
89 #ifdef HAVE_CONFIG_H
90 # include "config.h"
91 #endif
92
93 #include <stdio.h>
94 #include <stdlib.h>
95
96 #include <string.h>
97
98 #include <epan/packet.h>
99 #include <epan/prefs.h>
100 #include <epan/tap.h>
101 #include <epan/emem.h>
102
103 #include "packet-bssap.h"
104 #include "packet-gsm_ss.h"
105 #include "packet-ber.h"
106 #include "packet-q931.h"
107 #include "packet-gsm_a.h"
108 #include "packet-ipv6.h"
109
110 #include "packet-ppp.h"
111
112 /* PROTOTYPES/FORWARDS */
113
114 const value_string gsm_a_bssmap_msg_strings[] = {
115     { 0x01,     "Assignment Request" },
116     { 0x02,     "Assignment Complete" },
117     { 0x03,     "Assignment Failure" },
118     { 0x10,     "Handover Request" },
119     { 0x11,     "Handover Required" },
120     { 0x12,     "Handover Request Acknowledge" },
121     { 0x13,     "Handover Command" },
122     { 0x14,     "Handover Complete" },
123     { 0x15,     "Handover Succeeded" },
124     { 0x16,     "Handover Failure" },
125     { 0x17,     "Handover Performed" },
126     { 0x18,     "Handover Candidate Enquire" },
127     { 0x19,     "Handover Candidate Response" },
128     { 0x1a,     "Handover Required Reject" },
129     { 0x1b,     "Handover Detect" },
130     { 0x20,     "Clear Command" },
131     { 0x21,     "Clear Complete" },
132     { 0x22,     "Clear Request" },
133     { 0x23,     "Reserved" },
134     { 0x24,     "Reserved" },
135     { 0x25,     "SAPI 'n' Reject" },
136     { 0x26,     "Confusion" },
137     { 0x28,     "Suspend" },
138     { 0x29,     "Resume" },
139     { 0x2a,     "Connection Oriented Information" },
140     { 0x2b,     "Perform Location Request" },
141     { 0x2c,     "LSA Information" },
142     { 0x2d,     "Perform Location Response" },
143     { 0x2e,     "Perform Location Abort" },
144     { 0x2f,     "Common Id" },
145     { 0x30,     "Reset" },
146     { 0x31,     "Reset Acknowledge" },
147     { 0x32,     "Overload" },
148     { 0x33,     "Reserved" },
149     { 0x34,     "Reset Circuit" },
150     { 0x35,     "Reset Circuit Acknowledge" },
151     { 0x36,     "MSC Invoke Trace" },
152     { 0x37,     "BSS Invoke Trace" },
153     { 0x3a,     "Connectionless Information" },
154     { 0x40,     "Block" },
155     { 0x41,     "Blocking Acknowledge" },
156     { 0x42,     "Unblock" },
157     { 0x43,     "Unblocking Acknowledge" },
158     { 0x44,     "Circuit Group Block" },
159     { 0x45,     "Circuit Group Blocking Acknowledge" },
160     { 0x46,     "Circuit Group Unblock" },
161     { 0x47,     "Circuit Group Unblocking Acknowledge" },
162     { 0x48,     "Unequipped Circuit" },
163     { 0x4e,     "Change Circuit" },
164     { 0x4f,     "Change Circuit Acknowledge" },
165     { 0x50,     "Resource Request" },
166     { 0x51,     "Resource Indication" },
167     { 0x52,     "Paging" },
168     { 0x53,     "Cipher Mode Command" },
169     { 0x54,     "Classmark Update" },
170     { 0x55,     "Cipher Mode Complete" },
171     { 0x56,     "Queuing Indication" },
172     { 0x57,     "Complete Layer 3 Information" },
173     { 0x58,     "Classmark Request" },
174     { 0x59,     "Cipher Mode Reject" },
175     { 0x5a,     "Load Indication" },
176     { 0x04,     "VGCS/VBS Setup" },
177     { 0x05,     "VGCS/VBS Setup Ack" },
178     { 0x06,     "VGCS/VBS Setup Refuse" },
179     { 0x07,     "VGCS/VBS Assignment Request" },
180     { 0x1c,     "VGCS/VBS Assignment Result" },
181     { 0x1d,     "VGCS/VBS Assignment Failure" },
182     { 0x1e,     "VGCS/VBS Queuing Indication" },
183     { 0x1f,     "Uplink Request" },
184     { 0x27,     "Uplink Request Acknowledge" },
185     { 0x49,     "Uplink Request Confirmation" },
186     { 0x4a,     "Uplink Release Indication" },
187     { 0x4b,     "Uplink Reject Command" },
188     { 0x4c,     "Uplink Release Command" },
189     { 0x4d,     "Uplink Seized Command" },
190     { 0, NULL },
191 };
192
193 const value_string gsm_a_dtap_msg_mm_strings[] = {
194     { 0x01,     "IMSI Detach Indication" },
195     { 0x02,     "Location Updating Accept" },
196     { 0x04,     "Location Updating Reject" },
197     { 0x08,     "Location Updating Request" },
198     { 0x11,     "Authentication Reject" },
199     { 0x12,     "Authentication Request" },
200     { 0x14,     "Authentication Response" },
201     { 0x1c,     "Authentication Failure" },
202     { 0x18,     "Identity Request" },
203     { 0x19,     "Identity Response" },
204     { 0x1a,     "TMSI Reallocation Command" },
205     { 0x1b,     "TMSI Reallocation Complete" },
206     { 0x21,     "CM Service Accept" },
207     { 0x22,     "CM Service Reject" },
208     { 0x23,     "CM Service Abort" },
209     { 0x24,     "CM Service Request" },
210     { 0x25,     "CM Service Prompt" },
211     { 0x26,     "Reserved: was allocated in earlier phases of the protocol" },
212     { 0x28,     "CM Re-establishment Request" },
213     { 0x29,     "Abort" },
214     { 0x30,     "MM Null" },
215     { 0x31,     "MM Status" },
216     { 0x32,     "MM Information" },
217     { 0, NULL },
218 };
219
220 const value_string gsm_a_dtap_msg_rr_strings[] = {
221     { 0x3c,     "RR Initialisation Request" },
222     { 0x3b,     "Additional Assignment" },
223     { 0x3f,     "Immediate Assignment" },
224     { 0x39,     "Immediate Assignment Extended" },
225     { 0x3a,     "Immediate Assignment Reject" },
226
227     { 0x48,     "DTM Assignment Failure" },
228     { 0x49,     "DTM Reject" },
229     { 0x4a,     "DTM Request" },
230     { 0x4b,     "Main DCCH Assignment Command" },
231     { 0x4c,     "Packet Assignment Command" },
232
233     { 0x35,     "Ciphering Mode Command" },
234     { 0x32,     "Ciphering Mode Complete" },
235
236     { 0x30,     "Configuration Change Command" },
237     { 0x31,     "Configuration Change Ack." },
238     { 0x33,     "Configuration Change Reject" },
239
240     { 0x2e,     "Assignment Command" },
241     { 0x29,     "Assignment Complete" },
242     { 0x2f,     "Assignment Failure" },
243     { 0x2b,     "Handover Command" },
244     { 0x2c,     "Handover Complete" },
245     { 0x28,     "Handover Failure" },
246     { 0x2d,     "Physical Information" },
247     { 0x4d,     "DTM Assignment Command" },
248
249     { 0x08,     "RR-cell Change Order" },
250     { 0x23,     "PDCH Assignment Command" },
251
252     { 0x0d,     "Channel Release" },
253     { 0x0a,     "Partial Release" },
254     { 0x0f,     "Partial Release Complete" },
255
256     { 0x21,     "Paging Request Type 1" },
257     { 0x22,     "Paging Request Type 2" },
258     { 0x24,     "Paging Request Type 3" },
259     { 0x27,     "Paging Response" },
260     { 0x20,     "Notification/NCH" },
261     { 0x25,     "Reserved" },
262     { 0x26,     "Notification/Response" },
263
264     { 0x0b,     "Reserved" },
265
266 /*      ETSI TS 101 503 V8.5.0 Seems to give Other def for this Messages???
267     { 0xc0,     "Utran Classmark Change" }, CONFLICTS WITH Handover To UTRAN Command 
268     { 0xc1,     "UE RAB Preconfiguration" },
269     { 0xc2,     "cdma2000 Classmark Change" },*/
270
271         /* ETSI TS 101 503 V8.5.0 */
272     { 0x60,     "Utran Classmark Change" },  
273     { 0x61,     "UE RAB Preconfiguration" },
274     { 0x62,     "cdma2000 Classmark Change" },
275     { 0x63,     "Inter System to UTRAN Handover Command" },
276     { 0x64,     "Inter System to cdma2000 Handover Command" },
277     { 0x18,     "System Information Type 8" },
278     { 0x19,     "System Information Type 1" },
279     { 0x1a,     "System Information Type 2" },
280     { 0x1b,     "System Information Type 3" },
281     { 0x1c,     "System Information Type 4" },
282     { 0x1d,     "System Information Type 5" },
283     { 0x1e,     "System Information Type 6" },
284     { 0x1f,     "System Information Type 7" },
285
286     { 0x02,     "System Information Type 2bis" },
287     { 0x03,     "System Information Type 2ter" },
288     { 0x07,     "System Information Type 2quater" },
289     { 0x05,     "System Information Type 5bis" },
290     { 0x06,     "System Information Type 5ter" },
291     { 0x04,     "System Information Type 9" },
292     { 0x00,     "System Information Type 13" },
293
294     { 0x3d,     "System Information Type 16" },
295     { 0x3e,     "System Information Type 17" },
296
297     { 0x40,     "System Information Type 18" },
298     { 0x41,     "System Information Type 19" },
299     { 0x42,     "System Information Type 20" },
300
301     { 0x10,     "Channel Mode Modify" },
302     { 0x12,     "RR Status" },
303     { 0x17,     "Channel Mode Modify Acknowledge" },
304     { 0x14,     "Frequency Redefinition" },
305     { 0x15,     "Measurement Report" },
306     { 0x16,     "Classmark Change" },
307     { 0x13,     "Classmark Enquiry" },
308     { 0x36,     "Extended Measurement Report" },
309     { 0x37,     "Extended Measurement Order" },
310     { 0x34,     "GPRS Suspension Request" },
311
312     { 0x09,     "VGCS Uplink Grant" },
313     { 0x0e,     "Uplink Release" },
314     { 0x0c,     "Reserved" },
315     { 0x2a,     "Uplink Busy" },
316     { 0x11,     "Talker Indication" },
317
318     { 0xc0,     "UTRAN Classmark Change/Handover To UTRAN Command" },   /* spec conflict */
319
320     { 0x38,     "Application Information" },
321
322     { 0, NULL },
323 };
324
325 const value_string gsm_a_dtap_msg_cc_strings[] = {
326     { 0x01,     "Alerting" },
327     { 0x08,     "Call Confirmed" },
328     { 0x02,     "Call Proceeding" },
329     { 0x07,     "Connect" },
330     { 0x0f,     "Connect Acknowledge" },
331     { 0x0e,     "Emergency Setup" },
332     { 0x03,     "Progress" },
333     { 0x04,     "CC-Establishment" },
334     { 0x06,     "CC-Establishment Confirmed" },
335     { 0x0b,     "Recall" },
336     { 0x09,     "Start CC" },
337     { 0x05,     "Setup" },
338     { 0x17,     "Modify" },
339     { 0x1f,     "Modify Complete" },
340     { 0x13,     "Modify Reject" },
341     { 0x10,     "User Information" },
342     { 0x18,     "Hold" },
343     { 0x19,     "Hold Acknowledge" },
344     { 0x1a,     "Hold Reject" },
345     { 0x1c,     "Retrieve" },
346     { 0x1d,     "Retrieve Acknowledge" },
347     { 0x1e,     "Retrieve Reject" },
348     { 0x25,     "Disconnect" },
349     { 0x2d,     "Release" },
350     { 0x2a,     "Release Complete" },
351     { 0x39,     "Congestion Control" },
352     { 0x3e,     "Notify" },
353     { 0x3d,     "Status" },
354     { 0x34,     "Status Enquiry" },
355     { 0x35,     "Start DTMF" },
356     { 0x31,     "Stop DTMF" },
357     { 0x32,     "Stop DTMF Acknowledge" },
358     { 0x36,     "Start DTMF Acknowledge" },
359     { 0x37,     "Start DTMF Reject" },
360     { 0x3a,     "Facility" },
361     { 0, NULL },
362 };
363
364 const value_string gsm_a_dtap_msg_gmm_strings[] = {
365     { 0x01,     "Attach Request" },
366     { 0x02,     "Attach Accept" },
367     { 0x03,     "Attach Complete" },
368     { 0x04,     "Attach Reject" },
369     { 0x05,     "Detach Request" },
370     { 0x06,     "Detach Accept" },
371     { 0x08,     "Routing Area Update Request" },
372     { 0x09,     "Routing Area Update Accept" },
373     { 0x0a,     "Routing Area Update Complete" },
374     { 0x0b,     "Routing Area Update Reject" },
375     { 0x0c,     "Service Request" },
376     { 0x0d,     "Service Accept" },
377     { 0x0e,     "Service Reject" },
378     { 0x10,     "P-TMSI Reallocation Command" },
379     { 0x11,     "P-TMSI Reallocation Complete" },
380     { 0x12,     "Authentication and Ciphering Req" },
381     { 0x13,     "Authentication and Ciphering Resp" },
382     { 0x14,     "Authentication and Ciphering Rej" },
383     { 0x1c,     "Authentication and Ciphering Failure" },
384     { 0x15,     "Identity Request" },
385     { 0x16,     "Identity Response" },
386     { 0x20,     "GMM Status" },
387     { 0x21,     "GMM Information" },
388     { 0, NULL },
389 };
390
391 const value_string gsm_a_dtap_msg_sms_strings[] = {
392     { 0x01,     "CP-DATA" },
393     { 0x04,     "CP-ACK" },
394     { 0x10,     "CP-ERROR" },
395     { 0, NULL },
396 };
397
398 const value_string gsm_a_dtap_msg_sm_strings[] = {
399     { 0x41,     "Activate PDP Context Request" },
400     { 0x42,     "Activate PDP Context Accept" },
401     { 0x43,     "Activate PDP Context Reject" },
402     { 0x44,     "Request PDP Context Activation" },
403     { 0x45,     "Request PDP Context Activation rej." },
404     { 0x46,     "Deactivate PDP Context Request" },
405     { 0x47,     "Deactivate PDP Context Accept" },
406     { 0x48,     "Modify PDP Context Request(Network to MS direction)" },
407     { 0x49,     "Modify PDP Context Accept (MS to network direction)" },
408     { 0x4a,     "Modify PDP Context Request(MS to network direction)" },
409     { 0x4b,     "Modify PDP Context Accept (Network to MS direction)" },
410     { 0x4c,     "Modify PDP Context Reject" },
411     { 0x4d,     "Activate Secondary PDP Context Request" },
412     { 0x4e,     "Activate Secondary PDP Context Accept" },
413     { 0x4f,     "Activate Secondary PDP Context Reject" },
414     { 0x50,     "Reserved: was allocated in earlier phases of the protocol" },
415     { 0x51,     "Reserved: was allocated in earlier phases of the protocol" },
416     { 0x52,     "Reserved: was allocated in earlier phases of the protocol" },
417     { 0x53,     "Reserved: was allocated in earlier phases of the protocol" },
418     { 0x54,     "Reserved: was allocated in earlier phases of the protocol" },
419     { 0x55,     "SM Status" },
420     { 0x56,     "Activate MBMS Context Request" },
421     { 0x57,     "Activate MBMS Context Accept" },
422     { 0x58,     "Activate MBMS Context Reject" },
423     { 0x59,     "Request MBMS Context Activation" },
424     { 0x5a,     "Request MBMS Context Activation Reject" },
425     { 0, NULL },
426 };
427
428 const value_string gsm_a_dtap_msg_ss_strings[] = {
429     { 0x2a,     "Release Complete" },
430     { 0x3a,     "Facility" },
431     { 0x3b,     "Register" },
432     { 0, NULL },
433 };
434
435 static const value_string gsm_rp_msg_strings[] = {
436     { 0x00,     "RP-DATA (MS to Network)" },
437     { 0x01,     "RP-DATA (Network to MS)" },
438     { 0x02,     "RP-ACK (MS to Network)" },
439     { 0x03,     "RP-ACK (Network to MS)" },
440     { 0x04,     "RP-ERROR (MS to Network)" },
441     { 0x05,     "RP-ERROR (Network to MS)" },
442     { 0x06,     "RP-SMMA (MS to Network)" },
443     { 0, NULL },
444 };
445
446 static const value_string gsm_bssmap_elem_strings[] = {
447     { 0x01,     "Circuit Identity Code" },
448     { 0x02,     "Reserved" },
449     { 0x03,     "Resource Available" },
450     { 0x04,     "Cause" },
451     { 0x05,     "Cell Identifier" },
452     { 0x06,     "Priority" },
453     { 0x07,     "Layer 3 Header Information" },
454     { 0x08,     "IMSI" },
455     { 0x09,     "TMSI" },
456     { 0x0a,     "Encryption Information" },
457     { 0x0b,     "Channel Type" },
458     { 0x0c,     "Periodicity" },
459     { 0x0d,     "Extended Resource Indicator" },
460     { 0x0e,     "Number Of MSs" },
461     { 0x0f,     "Reserved" },
462     { 0x10,     "Reserved" },
463     { 0x11,     "Reserved" },
464     { 0x12,     "Classmark Information Type 2" },
465     { 0x13,     "Classmark Information Type 3" },
466     { 0x14,     "Interference Band To Be Used" },
467     { 0x15,     "RR Cause" },
468     { 0x16,     "Reserved" },
469     { 0x17,     "Layer 3 Information" },
470     { 0x18,     "DLCI" },
471     { 0x19,     "Downlink DTX Flag" },
472     { 0x1a,     "Cell Identifier List" },
473     { 0x1b,     "Response Request" },
474     { 0x1c,     "Resource Indication Method" },
475     { 0x1d,     "Classmark Information Type 1" },
476     { 0x1e,     "Circuit Identity Code List" },
477     { 0x1f,     "Diagnostic" },
478     { 0x20,     "Layer 3 Message Contents" },
479     { 0x21,     "Chosen Channel" },
480     { 0x22,     "Total Resource Accessible" },
481     { 0x23,     "Cipher Response Mode" },
482     { 0x24,     "Channel Needed" },
483     { 0x25,     "Trace Type" },
484     { 0x26,     "TriggerID" },
485     { 0x27,     "Trace Reference" },
486     { 0x28,     "TransactionID" },
487     { 0x29,     "Mobile Identity" },
488     { 0x2a,     "OMCID" },
489     { 0x2b,     "Forward Indicator" },
490     { 0x2c,     "Chosen Encryption Algorithm" },
491     { 0x2d,     "Circuit Pool" },
492     { 0x2e,     "Circuit Pool List" },
493     { 0x2f,     "Time Indication" },
494     { 0x30,     "Resource Situation" },
495     { 0x31,     "Current Channel Type 1" },
496     { 0x32,     "Queuing Indicator" },
497     { 0x40,     "Speech Version" },
498     { 0x33,     "Assignment Requirement" },
499     { 0x35,     "Talker Flag" },
500     { 0x36,     "Connection Release Requested" },
501     { 0x37,     "Group Call Reference" },
502     { 0x38,     "eMLPP Priority" },
503     { 0x39,     "Configuration Evolution Indication" },
504     { 0x3a,     "Old BSS to New BSS Information" },
505     { 0x3b,     "LSA Identifier" },
506     { 0x3c,     "LSA Identifier List" },
507     { 0x3d,     "LSA Information" },
508     { 0x3e,     "LCS QoS" },
509     { 0x3f,     "LSA access control suppression" },
510     { 0x43,     "LCS Priority" },
511     { 0x44,     "Location Type" },
512     { 0x45,     "Location Estimate" },
513     { 0x46,     "Positioning Data" },
514     { 0x47,     "LCS Cause" },
515     { 0x48,     "LCS Client Type" },
516     { 0x49,     "APDU" },
517     { 0x4a,     "Network Element Identity" },
518     { 0x4b,     "GPS Assistance Data" },
519     { 0x4c,     "Deciphering Keys" },
520     { 0x4d,     "Return Error Request" },
521     { 0x4e,     "Return Error Cause" },
522     { 0x4f,     "Segmentation" },
523     { 0, NULL },
524 };
525
526 static const value_string gsm_dtap_elem_strings[] = {
527     /* Common Information Elements 10.5.1 */
528     { 0x00,     "Cell Identity" },
529     { 0x00,     "Ciphering Key Sequence Number" },
530     { 0x00,     "Location Area Identification" },
531     { 0x00,     "Mobile Identity" },
532     { 0x00,     "Mobile Station Classmark 1" },
533     { 0x00,     "Mobile Station Classmark 2" },
534     { 0x00,     "Mobile Station Classmark 3" },
535     { 0x00,     "Descriptive group or broadcast call reference" },
536     { 0x00,     "Group Cipher Key Number" },
537     { 0x00,     "PD and SAPI $(CCBS)$" },
538         /* Pos 10 */
539     { 0x00,     "Priority Level" },
540     { 0x00,     "PLMN List" },
541     /* Radio Resource Management Information Elements 10.5.2, most are from 10.5.1 */
542 /*
543  * [3]  10.5.2.1a       BA Range
544  */
545     { 0x00,     "Cell Channel Description" },           /* [3]  10.5.2.1b       */      
546 /* [3]  10.5.2.1c       BA List Pref
547  * [3]  10.5.2.1d       UTRAN Frequency List
548  * [3]  10.5.2.1e       Cell selection indicator after release of all TCH and SDCCH IE
549  */
550         { 0x00, "Cell Description" },                           /* 10.5.2.2  */
551 /*
552  * [3]  10.5.2.3        Cell Options (BCCH)     
553  * [3]  10.5.2.3a       Cell Options (SACCH)
554  * [3]  10.5.2.4        Cell Selection Parameters
555  * [3]  10.5.2.4a       (void) */
556         { 0x00, "Channel Description" },                        /* 10.5.2.5      */
557         { 0x00, "Channel Description 2" },                      /* 10.5.2.5a */
558
559         { 0x00, "Channel Mode" },                                       /* [3]  10.5.2.6 */     
560         { 0x00, "Channel Mode 2" },                                     /* [3]  10.5.2.7 */     
561 /* [3]  10.5.2.7a       UTRAN predefined configuration status information / START-CS / UE CapabilityUTRAN Classmark information element 218
562  * [3]  10.5.2.7b       (void) */
563         { 0x00, "Classmark Enquiry Mask" },                     /* [3]  10.5.2.7c */
564 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element */
565         { 0x00, "Channel Needed"},                                      /* [3]  10.5.2.8        */
566  /* [3]  10.5.2.8a      (void) */
567  /* [3]  10.5.2.8b      Channel Request Description 2 */
568                 /* Pos 20 */
569         { 0x00, "Cipher Mode Setting" },                                /* [3]  10.5.2.9        */
570 /* [3]  10.5.2.10       Cipher Response
571  * [3]  10.5.2.11       Control Channel Description
572  * [3]  10.5.2.11a      DTM Information Details */
573         { 0x00, "Dynamic ARFCN Mapping" },                      /* [3]  10.5.2.11b      */
574         { 0x00, "Frequency Channel Sequence" },         /* [3]  10.5.2.12       */
575     { 0x00,     "Frequency List" },                                     /* 10.5.2.13            */
576         { 0x00, "Frequency Short List" },                       /* 10.5.2.14            */
577         { 0x00, "Frequency Short List2" },                      /* 10.5.2.14a           */
578 /* [3]  10.5.2.14b      Group Channel Description
579  * [3]  10.5.2.14c      GPRS Resumption
580  * [3]  10.5.2.14d      GPRS broadcast information
581  * [3]  10.5.2.14e      Enhanced DTM CS Release Indication
582  */
583         { 0x00, "Handover Reference" },                         /* 10.5.2.15 */
584 /*
585  * [3] 10.5.2.16 IA Rest Octets
586  * [3] 10.5.2.17 IAR Rest Octets
587  * [3] 10.5.2.18 IAX Rest Octets
588  * [3] 10.5.2.19 L2 Pseudo Length
589  * [3] 10.5.2.20 Measurement Results
590  * [3] 10.5.2.20a GPRS Measurement Results
591  */
592         { 0x00, "Mobile Allocation" },                          /* [3] 10.5.2.21        */ 
593         { 0x00, "Mobile Time Difference" },                     /* [3] 10.5.2.21a       */
594         { 0x00, "MultiRate configuration" },            /* [3] 10.5.2.21aa      */
595         /* Pos 30 */
596         { 0x00, "Multislot Allocation" },                       /* [3] 10.5.2.21b       */ 
597  /*
598  * [3] 10.5.2.21c NC mode
599  * [3] 10.5.2.22 Neighbour Cell Description
600  * [3] 10.5.2.22a Neighbour Cell Description 2
601  * [3] 10.5.2.22b (void)
602  * [3] 10.5.2.22c NT/N Rest Octets
603  * [3] 10.5.2.23 P1 Rest Octets
604  * [3] 10.5.2.24 P2 Rest Octets
605  * [3] 10.5.2.25 P3 Rest Octets
606  * [3] 10.5.2.25a Packet Channel Description
607  * [3] 10.5.2.25b Dedicated mode or TBF
608  * [3] 10.5.2.25c RR Packet Uplink Assignment
609  * [3] 10.5.2.25d RR Packet Downlink Assignment
610  * [3] 10.5.2.26 Page Mode
611  * [3] 10.5.2.26a (void)
612  * [3] 10.5.2.26b (void)
613  * [3] 10.5.2.26c (void)
614  * [3] 10.5.2.26d (void)
615  * [3] 10.5.2.27 NCC Permitted
616  */
617         { 0x00, "Power Command" },                                      /* 10.5.2.28 */
618         { 0x00, "Power Command and access type" },      /* 10.5.2.28a */
619 /*
620  * [3] 10.5.2.29 RACH Control Parameters
621  * [3] 10.5.2.30 Request Reference
622  */
623     { 0x00,     "RR Cause" },                                           /* 10.5.2.31 */
624         { 0x00, "Synchronization Indication" },         /* 10.5.2.39 */
625 /* [3] 10.5.2.32 SI 1 Rest Octets
626  * [3] 10.5.2.33 SI 2bis Rest Octets 
627  * [3] 10.5.2.33a SI 2ter Rest Octets
628  * [3] 10.5.2.33b SI 2quater Rest Octets
629  * [3] 10.5.2.34 SI 3 Rest Octets
630  * [3] 10.5.2.35 SI 4 Rest Octets
631  * [3] 10.5.2.35a SI 6 Rest Octets
632  * [3] 10.5.2.36 SI 7 Rest Octets
633  * [3] 10.5.2.37 SI 8 Rest Octets
634  * [3] 10.5.2.37a SI 9 Rest Octets
635  * [3] 10.5.2.37b SI 13 Rest Octets
636  * [3] 10.5.2.37c (void)
637  * [3] 10.5.2.37d (void)
638  * [3] 10.5.2.37e SI 16 Rest Octets
639  * [3] 10.5.2.37f SI 17 Rest Octets
640  * [3] 10.5.2.37g SI 19 Rest Octets
641  * [3] 10.5.2.37h SI 18 Rest Octets
642  * [3] 10.5.2.37i SI 20 Rest Octets */
643     { 0x00,     "Starting Time" },                                      /* [3] 10.5.2.38 Starting Time  */
644     { 0x00,     "Timing Advance" },                                     /* [3] 10.5.2.40 Timing Advance */ 
645         { 0x00, "Time Difference" },                            /* [3] 10.5.2.41 Time Difference                                */
646         { 0x00, "TLLI" },                                                       /* [3] 10.5.2.41a TLLI                                                  */
647 /*
648  * [3] 10.5.2.42 TMSI/P-TMSI */
649         { 0x00, "VGCS target mode Indication" },        /* [3] 10.5.2.42a                                                               */ 
650         /* Pos 40 */
651         { 0x00, "VGCS Ciphering Parameters" },          /* [3] 10.5.2.42b                                                               */
652 /* [3] 10.5.2.43 Wait Indication
653  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
654  * [3] 10.5.2.45 EXTENDED MEASUREMENT RESULTS
655  * [3] 10.5.2.46 Extended Measurement Frequency List */
656         { 0x00, "Suspension Cause" },                           /* [3] 10.5.2.47                                                                */ 
657 /* [3] 10.5.2.48 APDU ID 
658  * [3] 10.5.2.49 APDU Flags
659  * [3] 10.5.2.50 APDU Data
660  * [3] 10.5.2.51 Handover To UTRAN Command
661  * [3] 10.5.2.52 Handover To cdma2000 Command 
662  * [3] 10.5.2.53 (void)
663  * [3] 10.5.2.54 (void)
664  * [3] 10.5.2.55 (void)
665  * [3] 10.5.2.56 3G Target Cell */
666         { 0x00, "Dedicated Service Information" },              /* [3] 10.5.2.59        */
667
668
669     /* Mobility Management Information Elements 10.5.3 */
670     { 0x00,     "Authentication Parameter RAND" },
671     { 0x00,     "Authentication Parameter AUTN (UMTS authentication challenge only)" },
672     { 0x00,     "Authentication Response Parameter" },
673     { 0x00,     "Authentication Response Parameter (extension) (UMTS authentication challenge only)" },
674     { 0x00,     "Authentication Failure Parameter (UMTS authentication challenge only)" },
675     { 0x00,     "CM Service Type" },
676     { 0x00,     "Identity Type" },
677         /* Pos 50 */
678     { 0x00,     "Location Updating Type" },
679     { 0x00,     "Network Name" },
680     { 0x00,     "Reject Cause" },
681     { 0x00,     "Follow-on Proceed" },
682     { 0x00,     "Time Zone" },
683     { 0x00,     "Time Zone and Time" },
684     { 0x00,     "CTS Permission" },
685     { 0x00,     "LSA Identifier" },
686     { 0x00,     "Daylight Saving Time" },
687     { 0x00, "Emergency Number List" },
688     /* Call Control Information Elements 10.5.4 */
689         /* Pos 60 */
690     { 0x00,     "Auxiliary States" },                                   /* 10.5.4.4 Auxiliary states */
691     { 0x00,     "Bearer Capability" },                                  /* 10.5.4.4a Backup bearer capability */
692     { 0x00,     "Call Control Capabilities" },
693     { 0x00,     "Call State" },
694     { 0x00,     "Called Party BCD Number" },
695     { 0x00,     "Called Party Subaddress" },
696     { 0x00,     "Calling Party BCD Number" },
697     { 0x00,     "Calling Party Subaddress" },
698     { 0x00,     "Cause" },
699     { 0x00,     "CLIR Suppression" },
700     { 0x00,     "CLIR Invocation" },
701     { 0x00,     "Congestion Level" },
702     { 0x00,     "Connected Number" },
703     { 0x00,     "Connected Subaddress" },
704     { 0x00,     "Facility" },
705     { 0x00,     "High Layer Compatibility" },
706     { 0x00,     "Keypad Facility" },
707     { 0x00,     "Low Layer Compatibility" },
708     { 0x00,     "More Data" },
709     { 0x00,     "Notification Indicator" },
710     { 0x00,     "Progress Indicator" },
711     { 0x00,     "Recall type $(CCBS)$" },
712     { 0x00,     "Redirecting Party BCD Number" },
713     { 0x00,     "Redirecting Party Subaddress" },
714     { 0x00,     "Repeat Indicator" },
715     { 0x00,     "Reverse Call Setup Direction" },
716     { 0x00,     "SETUP Container $(CCBS)$" },
717     { 0x00,     "Signal" },
718     { 0x00,     "SS Version Indicator" },
719     { 0x00,     "User-user" },
720     { 0x00,     "Alerting Pattern $(NIA)$" },                   /* 10.5.4.26 Alerting Pattern $(NIA)$ */
721     { 0x00,     "Allowed Actions $(CCBS)$" },
722     { 0x00,     "Stream Identifier" },
723     { 0x00,     "Network Call Control Capabilities" },
724     { 0x00,     "Cause of No CLI" },
725     { 0x00,     "Immediate Modification Indicator" },   /* 10.5.4.30 Cause of No CLI */
726         /* 10.5.4.31 Void */
727     { 0x00,     "Supported Codec List" },                               /* 10.5.4.32 Supported codec list */
728     { 0x00,     "Service Category" },                                   /* 10.5.4.33 Service category */
729         /* 10.5.4.34 Redial */
730         /* 10.5.4.35 Network-initiated Service Upgrade indicator */
731     /* GPRS Mobility Management Information Elements 10.5.5 */
732     { 0x00,     "Attach Result" },
733     { 0x00,     "Attach Type" },
734     { 0x00,     "Cipher Algorithm" },
735     { 0x00,     "TMSI Status" },
736     { 0x00,     "Detach Type" },
737     { 0x00,     "DRX Parameter" },
738     { 0x00,     "Force to Standby" },
739     { 0x00, "Force to Standby" },
740     { 0x00,     "P-TMSI Signature" },
741     { 0x00,     "P-TMSI Signature 2" },
742     { 0x00,     "Identity Type 2" },
743     { 0x00,     "IMEISV Request" },
744     { 0x00,     "Receive N-PDU Numbers List" },
745     { 0x00,     "MS Network Capability" },
746     { 0x00,     "MS Radio Access Capability" },
747     { 0x00,     "GMM Cause" },
748     { 0x00,     "Routing Area Identification" },
749     { 0x00,     "Update Result" },
750     { 0x00, "Update Type" },
751     { 0x00,     "A&C Reference Number" },
752     { 0x00, "A&C Reference Number" },
753     { 0x00,     "Service Type" },
754     { 0x00,     "Cell Notification" },
755     { 0x00, "PS LCS Capability" },
756     { 0x00,     "Network Feature Support" },
757         { 0x00, "Inter RAT information container" },
758     /* Short Message Service Information Elements [5] 8.1.4 */
759     { 0x00,     "CP-User Data" },
760     { 0x00,     "CP-Cause" },
761     /* Short Message Service Information Elements [5] 8.2 */
762     { 0x00,     "RP-Message Reference" },
763     { 0x00,     "RP-Origination Address" },
764     { 0x00,     "RP-Destination Address" },
765     { 0x00,     "RP-User Data" },
766     { 0x00,     "RP-Cause" },
767     /* Session Management Information Elements 10.5.6 */
768     { 0x00,     "Access Point Name" },
769     { 0x00,     "Network Service Access Point Identifier" },
770     { 0x00,     "Protocol Configuration Options" },
771     { 0x00,     "Packet Data Protocol Address" },
772     { 0x00,     "Quality Of Service" },
773     { 0x00,     "SM Cause" },
774     { 0x00,     "Linked TI" },
775     { 0x00,     "LLC Service Access Point Identifier" },
776     { 0x00,     "Tear Down Indicator" },
777     { 0x00,     "Packet Flow Identifier" },
778     { 0x00,     "Traffic Flow Template" },
779     /* GPRS Common Information Elements 10.5.7 */
780     { 0x00,     "PDP Context Status" },
781     { 0x00,     "Radio Priority" },
782     { 0x00,     "GPRS Timer" },
783     { 0x00,     "GPRS Timer 2" },
784     { 0x00, "Radio Priority 2"},
785         { 0x00, "MBMS context status"},
786     { 0x00, "Spare Nibble"},
787     { 0, NULL },
788 };
789
790 const gchar *gsm_a_pd_str[] = {
791     "Group Call Control",
792     "Broadcast Call Control",
793     "Reserved: was allocated in earlier phases of the protocol",
794     "Call Control; call related SS messages",
795     "GPRS Transparent Transport Protocol (GTTP)",
796     "Mobility Management messages",
797     "Radio Resources Management messages",
798     "Unknown",
799     "GPRS Mobility Management messages",
800     "SMS messages",
801     "GPRS Session Management messages",
802     "Non call related SS messages",
803     "Location Services",
804     "Unknown",
805     "Reserved for extension of the PD to one octet length",
806     "Reserved for tests procedures"
807 };
808 /* L3 Protocol discriminator values according to TS 24 007 (6.4.0)  */
809 static const value_string protocol_discriminator_vals[] = {
810         {0x0,           "Group call control"},
811         {0x1,           "Broadcast call control"},
812         {0x2,           "Reserved: was allocated in earlier phases of the protocol"},
813         {0x3,           "Call Control; call related SS messages"},
814         {0x4,           "GPRS Transparent Transport Protocol (GTTP)"},
815         {0x5,           "Mobility Management messages"},
816         {0x6,           "Radio Resources Management messages"},
817         {0x7,           "Unknown"},
818         {0x8,           "GPRS mobility management messages"},
819         {0x9,           "SMS messages"},
820         {0xa,           "GPRS session management messages"},
821         {0xb,           "Non call related SS messages"},
822         {0xc,           "Location services specified in 3GPP TS 44.071 [8a]"},
823         {0xd,           "Unknown"},
824         {0xe,           "Reserved for extension of the PD to one octet length "},
825         {0xf,           "Reserved for tests procedures described in 3GPP TS 44.014 [5a] and 3GPP TS 34.109 [17a]."},
826         { 0,    NULL }
827 };
828
829 static const value_string gsm_a_pd_short_str_vals[] = {
830         {0x0,           "GCC"},                         /* Group Call Control */
831         {0x1,           "BCC"},                         /* Broadcast Call Control */
832         {0x2,           "Reserved"},            /* : was allocated in earlier phases of the protocol */
833         {0x3,           "CC"},                          /* Call Control; call related SS messages */
834         {0x4,           "GTTP"},                        /* GPRS Transparent Transport Protocol (GTTP) */
835         {0x5,           "MM"},                          /* Mobility Management messages */
836         {0x6,           "RR"},                          /* Radio Resources Management messages */
837         {0x7,           "Unknown"},
838         {0x8,           "GMM"},                         /* GPRS Session Management messages */
839         {0x9,           "SMS"},
840         {0xa,           "SM"},                          /* GPRS Session Management messages */
841         {0xb,           "SS"},
842         {0xc,           "LS"},                          /* Location Services */
843         {0xd,           "Unknown"},
844         {0xe,           "Reserved"},            /*  for extension of the PD to one octet length  */
845         {0xf,           "Reserved"},            /*  for tests procedures described in 3GPP TS 44.014 [5a] and 3GPP TS 34.109 [17a].*/
846         { 0,    NULL }
847 };
848 static const value_string bssap_cc_values[] = {
849     { 0x00,             "not further specified" },
850     { 0x80,             "FACCH or SDCCH" },
851     { 0xc0,             "SACCH" },
852     { 0,                NULL } };
853
854 static const value_string bssap_sapi_values[] = {
855     { 0x00,             "RR/MM/CC" },
856     { 0x03,             "SMS" },
857     { 0,                NULL } };
858
859 /* Mobile Station Classmark Value strings
860  */
861
862 /* Mobile Station Classmark  
863  * Revision level 
864  */
865 const value_string gsm_a_msc_rev_vals[] = {
866         { 0,            "Reserved for GSM phase 1"},
867         { 1,            "Used by GSM phase 2 mobile stations"},
868         { 2,            "Used by mobile stations supporting R99 or later versions of the protocol"},
869         { 3,            "Reserved for future use"},
870         { 0,    NULL }
871 };
872
873 /* ES IND (octet 3, bit 5) "Controlled Early Classmark Sending" option implementation */
874 static const value_string ES_IND_vals[] = {
875         { 0,            "Controlled Early Classmark Sending option is not implemented in the MS"},
876         { 1,            "Controlled Early Classmark Sending option is implemented in the MS"},
877         { 0,    NULL }
878 };
879 /* A5/1 algorithm supported (octet 3, bit 4 */
880 static const value_string A5_1_algorithm_sup_vals[] = {
881         { 0,            "encryption algorithm A5/1 available"},
882         { 1,            "encryption algorithm A5/1 not available"},
883         { 0,    NULL }
884 };
885 /* RF Power Capability (Octet 3) */
886 static const value_string RF_power_capability_vals[] = {
887         { 0,            "class 1"},
888         { 1,            "class 2"},
889         { 2,            "class 3"},
890         { 3,            "class 4"},
891         { 4,            "class 5"},
892         { 7,            "RF Power capability is irrelevant in this information element"},
893         { 0,    NULL }
894 };
895 /* PS capability (pseudo-synchronization capability) (octet 4) */
896 static const value_string ps_sup_cap_vals[] = {
897         { 0,            "PS capability not present"},
898         { 1,            "PS capability present"},
899         { 0,    NULL }
900 };
901 /* SS Screening Indicator (octet 4)defined in 3GPP TS 24.080 */
902 static const value_string SS_screening_indicator_vals[] = {
903         { 0,            "Default value of phase 1"},
904         { 1,            "Capability of handling of ellipsis notation and phase 2 error handling "},
905         { 2,            "For future use"},
906         { 3,            "For future use"},
907         { 0,    NULL }
908 };
909 /* SM capability (MT SMS pt to pt capability) (octet 4)*/
910 static const value_string SM_capability_vals[] = {
911         { 0,            "Mobile station does not support mobile terminated point to point SMS"},
912         { 1,            "Mobile station supports mobile terminated point to point SMS"},
913         { 0,    NULL }
914 };
915 /* VBS notification reception (octet 4) */
916 static const value_string VBS_notification_rec_vals[] = {
917         { 0,            "no VBS capability or no notifications wanted"},
918         { 1,            "VBS capability and notifications wanted"},
919         { 0,    NULL }
920 };
921 /* VGCS notification reception (octet 4) */
922 static const value_string VGCS_notification_rec_vals[] = {
923         { 0,            "no VGCS capability or no notifications wanted"},
924         { 1,            "VGCS capability and notifications wanted"},
925         { 0,    NULL }
926 };
927 /* FC Frequency Capability (octet 4 ) */
928 static const value_string FC_frequency_cap_vals[] = {
929         { 0,            "The MS does not support the E-GSM or R-GSM band"},
930         { 1,            "The MS does support the E-GSM or R-GSM "},
931         { 0,    NULL }
932 };
933 /* CM3 (octet 5, bit 8) */
934 static const value_string CM3_vals[] = {
935         { 0,            "The MS does not support any options that are indicated in CM3"},
936         { 1,            "The MS supports options that are indicated in classmark 3 IE"},
937         { 0,    NULL }
938 };
939 /* LCS VA capability (LCS value added location request notification capability) (octet 5,bit 6) */
940 static const value_string LCS_VA_cap_vals[] = {
941         { 0,            "LCS value added location request notification capability not supported"},
942         { 1,            "LCS value added location request notification capability supported"},
943         { 0,    NULL }
944 };
945 /* UCS2 treatment (octet 5, bit 5) */
946 static const value_string UCS2_treatment_vals[] = {
947         { 0,            "the ME has a preference for the default alphabet"},
948         { 1,            "the ME has no preference between the use of the default alphabet and the use of UCS2"},
949         { 0,    NULL }
950 };
951 /* SoLSA (octet 5, bit 4) */
952 static const value_string SoLSA_vals[] = {
953         { 0,            "The ME does not support SoLSA"},
954         { 1,            "The ME supports SoLSA"},
955         { 0,    NULL }
956 };
957 /* CMSP: CM Service Prompt (octet 5, bit 3) */
958 static const value_string CMSP_vals[] = {
959         { 0,            "Network initiated MO CM connection request not supported"},
960         { 1,            "Network initiated MO CM connection request supported for at least one CM protocol"},
961         { 0,    NULL }
962 };
963 /* A5/3 algorithm supported (octet 5, bit 2) */
964 static const value_string A5_3_algorithm_sup_vals[] = {
965         { 0,            "encryption algorithm A5/3 not available"},
966         { 1,            "encryption algorithm A5/3 available"},
967         { 0,    NULL }
968 };
969
970 /* A5/2 algorithm supported (octet 5, bit 1) */
971 static const value_string A5_2_algorithm_sup_vals[] = {
972         { 0,            "encryption algorithm A5/2 not available"},
973         { 1,            "encryption algorithm A5/2 available"},
974         { 0,    NULL }
975 };
976
977  static const value_string gsm_a_algorithm_identifier_vals[] = {
978         { 0,            "Cipher with algorithm A5/1"},
979         { 1,            "Cipher with algorithm A5/2"},
980         { 2,            "Cipher with algorithm A5/3"},
981         { 3,            "Cipher with algorithm A5/4"},
982         { 4,            "Cipher with algorithm A5/5"},
983         { 5,            "Cipher with algorithm A5/6"},
984         { 6,            "Cipher with algorithm A5/7"},
985         { 7,            "Reserved"},
986         { 0,    NULL }
987 };
988
989  static const value_string mobile_identity_type_vals[] = {
990         { 1,            "IMSI"},
991         { 2,            "IMEI"},
992         { 3,            "IMEISV"},
993         { 4,            "TMSI/P-TMSI"},
994         { 5,            "TMGI and optional MBMS Session Identity"}, /* ETSI TS 124 008 V6.8.0 (2005-03) p326 */
995         { 0,            "No Identity"},
996         { 0,    NULL }
997 };
998
999 static const value_string oddevenind_vals[] = {
1000         { 0,            "Even number of identity digits"},
1001         { 1,            "Odd number of identity digits"},
1002         { 0,    NULL }
1003 };
1004
1005 /* RR cause value (octet 2) TS 44.018 6.11.0*/
1006 static const value_string gsm_a_rr_RR_cause_vals[] = {
1007         { 0,            "Normal event"},
1008         { 1,            "Abnormal release, unspecified"},
1009         { 2,            "Abnormal release, channel unacceptable"},
1010         { 3,            "Abnormal release, timer expired"},
1011         { 4,            "Abnormal release, no activity on the radio path"},
1012         { 5,            "Preemptive release"},
1013         { 6,            "UTRAN configuration unknown"},
1014         { 8,            "Handover impossible, timing advance out of range"},
1015         { 9,            "Channel mode unacceptable"},
1016         { 10,           "Frequency not implemented"},
1017         { 13,           "Originator or talker leaving group call area"},
1018         { 12,           "Lower layer failure"},
1019         { 0x41,         "Call already cleared"},
1020         { 0x5f,         "Semantically incorrect message"},
1021         { 0x60,         "Invalid mandatory information"},
1022         { 0x61,         "Message type non-existent or not implemented"},
1023         { 0x62,         "Message type not compatible with protocol state"},
1024         { 0x64,         "Conditional IE error"},
1025         { 0x65,         "No cell allocation available"},
1026         { 0x6f,         "Protocol error unspecified"},
1027         { 0,    NULL }
1028 };
1029 /* Cell identification discriminator */
1030 static const value_string gsm_a_rr_cell_id_disc_vals[] = {
1031         { 0,            "The whole Cell Global Identification, CGI, is used to identify the cells."},
1032         { 1,            "Location Area Code, LAC, and Cell Identify, CI, is used to identify the cells."},
1033         { 2,            "Cell Identity, CI, is used to identify the cells."},
1034         { 3,            "No cell is associated with the transaction."},
1035         { 4,            "Location Area Identification, LAI, is used to identify all cells within a Location Area."},
1036         { 5,            "Location Area Code, LAC, is used to identify all cells within a location area."},
1037         { 6,            "All cells on the BSS are identified."},
1038         { 8,            "Intersystem Handover to UTRAN or cdma2000. PLMN-ID, LAC, and RNC-ID, are encoded to identify the target RNC."},
1039         { 9,            "Intersystem Handover to UTRAN or cdma2000. The RNC-ID is coded to identify the target RNC."},
1040         { 10,           "Intersystem Handover to UTRAN or cdma2000. LAC and RNC-ID are encoded to identify the target RNC."},
1041         { 0,    NULL }
1042 };
1043
1044
1045 #define DTAP_PD_MASK            0x0f
1046 #define DTAP_SKIP_MASK          0xf0
1047 #define DTAP_TI_MASK            DTAP_SKIP_MASK
1048 #define DTAP_TIE_PRES_MASK      0x07                    /* after TI shifted to right */
1049 #define DTAP_TIE_MASK           0x7f
1050
1051 #define DTAP_MM_IEI_MASK        0x3f
1052 #define DTAP_RR_IEI_MASK        0xff
1053 #define DTAP_CC_IEI_MASK        0x3f
1054 #define DTAP_GMM_IEI_MASK       0xff
1055 #define DTAP_SMS_IEI_MASK       0xff
1056 #define DTAP_SM_IEI_MASK        0xff
1057 #define DTAP_SS_IEI_MASK        0x3f
1058
1059 /* Initialize the protocol and registered fields */
1060 static int proto_a_bssmap = -1;
1061 static int proto_a_dtap = -1;
1062 static int proto_a_rp = -1;
1063
1064 static int gsm_a_tap = -1;
1065
1066 static int hf_gsm_a_none = -1;
1067 static int hf_gsm_a_bssmap_msg_type = -1;
1068 static int hf_gsm_a_dtap_msg_mm_type = -1;
1069 static int hf_gsm_a_dtap_msg_rr_type = -1;
1070 static int hf_gsm_a_dtap_msg_cc_type = -1;
1071 static int hf_gsm_a_dtap_msg_gmm_type = -1;
1072 static int hf_gsm_a_dtap_msg_sms_type = -1;
1073 static int hf_gsm_a_dtap_msg_sm_type = -1;
1074 static int hf_gsm_a_dtap_msg_ss_type = -1;
1075 static int hf_gsm_a_rp_msg_type = -1;
1076 static int hf_gsm_a_length = -1;
1077 static int hf_gsm_a_bssmap_elem_id = -1;
1078 static int hf_gsm_a_dtap_elem_id = -1;
1079 static int hf_gsm_a_imsi = -1;
1080 static int hf_gsm_a_tmsi = -1;
1081 static int hf_gsm_a_imei = -1;
1082 static int hf_gsm_a_imeisv = -1;
1083 static int hf_gsm_a_cld_party_bcd_num = -1;
1084 static int hf_gsm_a_clg_party_bcd_num = -1;
1085 static int hf_gsm_a_cell_ci = -1;
1086 static int hf_gsm_a_cell_lac = -1;
1087 static int hf_gsm_a_dlci_cc = -1;
1088 static int hf_gsm_a_dlci_spare = -1;
1089 static int hf_gsm_a_dlci_sapi = -1;
1090 static int hf_gsm_a_bssmap_cause = -1;
1091 static int hf_gsm_a_dtap_cause = -1;
1092
1093 static int hf_gsm_a_MSC_rev = -1;
1094 static int hf_gsm_a_ES_IND                      = -1;
1095 static int hf_gsm_a_qos_traffic_cls = -1;
1096 static int hf_gsm_a_qos_del_order = -1;
1097 static int hf_gsm_a_qos_del_of_err_sdu = -1;
1098 static int hf_gsm_a_qos_ber = -1;
1099 static int hf_gsm_a_qos_sdu_err_rat = -1;
1100 static int hf_gsm_a_qos_traff_hdl_pri = -1;
1101 static int hf_gsm_a_A5_1_algorithm_sup = -1;
1102 static int hf_gsm_a_RF_power_capability = -1;
1103 static int hf_gsm_a_ps_sup_cap          = -1;
1104 static int hf_gsm_a_SS_screening_indicator = -1;
1105 static int hf_gsm_a_SM_capability                = -1;
1106 static int hf_gsm_a_VBS_notification_rec = -1;
1107 static int hf_gsm_a_VGCS_notification_rec = -1;
1108 static int hf_gsm_a_FC_frequency_cap    = -1;
1109 static int hf_gsm_a_CM3                         = -1;
1110 static int hf_gsm_a_LCS_VA_cap          = -1;
1111 static int hf_gsm_a_UCS2_treatment      = -1;
1112 static int hf_gsm_a_SoLSA                               = -1;
1113 static int hf_gsm_a_CMSP                                = -1;
1114 static int hf_gsm_a_A5_3_algorithm_sup= -1;
1115 static int hf_gsm_a_A5_2_algorithm_sup = -1;
1116
1117 static int hf_gsm_a_odd_even_ind = -1;
1118 static int hf_gsm_a_mobile_identity_type = -1;
1119 static int hf_gsm_a_L3_protocol_discriminator = -1; 
1120 static int hf_gsm_a_skip_ind = -1; 
1121
1122 static int hf_gsm_a_bcc                         = -1;
1123 static int hf_gsm_a_ncc                         = -1;
1124 static int hf_gsm_a_bcch_arfcn          = -1;
1125 static int hf_gsm_a_rr_ho_ref_val = -1;
1126 static int hf_gsm_a_b7spare = -1;
1127 static int hf_gsm_a_b8spare = -1;
1128 static int hf_gsm_a_rr_pow_cmd_atc = -1;
1129 static int hf_gsm_a_rr_pow_cmd_epc = -1;
1130 static int hf_gsm_a_rr_pow_cmd_fpcepc = -1;
1131 static int hf_gsm_a_rr_pow_cmd_powlev = -1;
1132 static int hf_gsm_a_rr_sync_ind_nci = -1;
1133 static int hf_gsm_a_rr_sync_ind_rot = -1;
1134 static int hf_gsm_a_rr_sync_ind_si = -1;
1135 static int hf_gsm_a_rr_format_id = -1;
1136 static int hf_gsm_a_rr_channel_mode = -1;
1137 static int hf_gsm_a_rr_channel_mode2 = -1;
1138 static int hf_gsm_a_rr_sc = -1;
1139 static int hf_gsm_a_algorithm_id = -1;
1140 static int hf_gsm_a_rr_multirate_speech_ver = -1;
1141 static int hf_gsm_a_rr_NCSB                             = -1;
1142 static int hf_gsm_a_rr_ICMI                             = -1;
1143 static int hf_gsm_a_rr_start_mode               = -1;
1144 static int hf_gsm_a_rr_timing_adv = -1;
1145 static int hf_gsm_a_rr_time_diff = -1;
1146 static int hf_gsm_a_rr_tlli = -1;
1147 static int hf_gsm_a_rr_target_mode = -1;
1148 static int hf_gsm_a_rr_group_cipher_key_number = -1;
1149 static int hf_gsm_a_rr_last_segment = -1;
1150 static int hf_gsm_a_gmm_split_on_ccch = -1;
1151 static int hf_gsm_a_gmm_non_drx_timer = -1;
1152 static int hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef = -1;
1153 static int hf_gsm_a_rr_RR_cause = -1;
1154 static int hf_gsm_a_be_cell_id_disc = -1;
1155 static int hf_gsm_a_be_rnc_id = -1;
1156 static int hf_gsm_a_rr_cm_cng_msg_req = -1;
1157 static int hf_gsm_a_rr_utran_cm_cng_msg_req = -1;
1158 static int hf_gsm_a_rr_cdma200_cm_cng_msg_req = -1;
1159 static int hf_gsm_a_rr_geran_iu_cm_cng_msg_req = -1;
1160 static int hf_gsm_a_rr_chnl_needed_ch1 = -1;
1161 static int hf_gsm_a_rr_chnl_needed_ch2 = -1;
1162 static int hf_gsm_a_rr_suspension_cause = -1;
1163 static int hf_ROS_component = -1;
1164 static int hf_ROS_invoke = -1;                    /* Invoke */
1165 static int hf_ROS_returnResultLast = -1;          /* ReturnResult */
1166 static int hf_ROS_returnError = -1;               /* ReturnError */
1167 static int hf_ROS_reject = -1;                    /* Reject */
1168 static int hf_ROS_invokeID = -1;                  /* InvokeIdType */
1169 static int hf_ROS_linkedID = -1;                  /* InvokeIdType */
1170 static int hf_ROS_opCode = -1;                    /* OPERATION */
1171 static int hf_ROS_parameter = -1;                 /* Parameter */
1172 static int hf_ROS_resultretres = -1;              /* T_resultretres */
1173 static int hf_ROS_errorCode = -1;                 /* ErrorCode */
1174 static int hf_ROS_invokeIDRej = -1;               /* T_invokeIDRej */
1175 static int hf_ROS_derivable = -1;                 /* InvokeIdType */
1176 static int hf_ROS_not_derivable = -1;             /* NULL */
1177 static int hf_ROS_problem = -1;                   /* T_problem */
1178 static int hf_ROS_generalProblem = -1;            /* GeneralProblem */
1179 static int hf_ROS_invokeProblem = -1;             /* InvokeProblem */
1180 static int hf_ROS_returnResultProblem = -1;       /* ReturnResultProblem */
1181 static int hf_ROS_returnErrorProblem = -1;        /* ReturnErrorProblem */
1182 static int hf_ROS_localValue = -1;                /* INTEGER */
1183 static int hf_ROS_globalValue = -1;               /* OBJECT_IDENTIFIER */
1184 static int hf_ROS_nationaler = -1;                /* INTEGER_M32768_32767 */
1185 static int hf_ROS_privateer = -1;                 /* INTEGER */
1186 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8 = -1;
1187 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7 = -1;
1188 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6 = -1;
1189 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5 = -1;
1190 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4 = -1;
1191 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3 = -1;
1192 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2 = -1;
1193 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1 = -1;
1194 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5 = -1;
1195 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4 = -1;
1196 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3 = -1;
1197 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2 = -1;
1198 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1 = -1;
1199
1200 static int hf_gsm_a_extension = -1;
1201 static int hf_gsm_a_type_of_number = -1;
1202 static int hf_gsm_a_numbering_plan_id = -1;
1203
1204 static int hf_gsm_a_ptmsi_sig =-1;
1205 static int hf_gsm_a_ptmsi_sig2 =-1;
1206
1207 static int hf_gsm_a_tft_op_code = -1;
1208 static int hf_gsm_a_tft_e_bit = -1;
1209 static int hf_gsm_a_tft_pkt_flt = -1;
1210 static int hf_gsm_a_tft_ip4_address = -1;
1211 static int hf_gsm_a_tft_ip4_mask = -1;
1212 static int hf_gsm_a_tft_ip6_address = -1;
1213 static int hf_gsm_a_tft_ip6_mask = -1;
1214 static int hf_gsm_a_tft_protocol_header = -1;
1215 static int hf_gsm_a_tft_port = -1;
1216 static int hf_gsm_a_tft_port_low = -1;
1217 static int hf_gsm_a_tft_port_high = -1;
1218 static int hf_gsm_a_tft_security = -1;
1219 static int hf_gsm_a_tft_traffic_mask = -1;
1220 static int hf_gsm_a_tft_flow = -1;
1221
1222 static int hf_gsm_a_apdu_protocol_id = -1;
1223 static int hf_gsm_a_lsa_id = -1;
1224
1225 /* Initialize the subtree pointers */
1226 static gint ett_bssmap_msg = -1;
1227 static gint ett_dtap_msg = -1;
1228 static gint ett_rp_msg = -1;
1229 static gint ett_elems = -1;
1230 static gint ett_elem = -1;
1231 static gint ett_dtap_oct_1 = -1;
1232 static gint ett_cm_srvc_type = -1;
1233 static gint ett_gsm_enc_info = -1;
1234 static gint ett_cell_list = -1;
1235 static gint ett_dlci = -1;
1236 static gint ett_bc_oct_3a = -1;
1237 static gint ett_bc_oct_4 = -1;
1238 static gint ett_bc_oct_5 = -1;
1239 static gint ett_bc_oct_5a = -1;
1240 static gint ett_bc_oct_5b = -1;
1241 static gint ett_bc_oct_6 = -1;
1242 static gint ett_bc_oct_6a = -1;
1243 static gint ett_bc_oct_6b = -1;
1244 static gint ett_bc_oct_6c = -1;
1245 static gint ett_bc_oct_6d = -1;
1246 static gint ett_bc_oct_6e = -1;
1247 static gint ett_bc_oct_6f = -1;
1248 static gint ett_bc_oct_6g = -1;
1249 static gint ett_bc_oct_7 = -1;
1250
1251 static gint ett_tc_component = -1;
1252 static gint ett_tc_invoke_id = -1;
1253 static gint ett_tc_linked_id = -1;
1254 static gint ett_tc_opr_code = -1;
1255 static gint ett_tc_err_code = -1;
1256 static gint ett_tc_prob_code = -1;
1257 static gint ett_tc_sequence = -1;
1258
1259 static gint ett_gmm_drx = -1;
1260 static gint ett_gmm_detach_type = -1;
1261 static gint ett_gmm_attach_type = -1;
1262 static gint ett_gmm_context_stat = -1;
1263 static gint ett_gmm_update_type = -1;
1264 static gint ett_gmm_radio_cap = -1;
1265
1266 static gint ett_ros = -1;
1267 static gint ett_ROS_Component = -1;
1268 static gint ett_ROS_Invoke = -1;
1269 static gint ett_ROS_ReturnResult = -1;
1270 static gint ett_ROS_T_resultretres = -1;
1271 static gint ett_ROS_ReturnError = -1;
1272 static gint ett_ROS_Reject = -1;
1273 static gint ett_ROS_T_invokeIDRej = -1;
1274 static gint ett_ROS_T_problem = -1;
1275 static gint ett_ROS_OPERATION = -1;
1276 static gint ett_ROS_ERROR = -1;
1277 static gint ett_ROS_ErrorCode = -1;
1278
1279 static gint ett_sm_tft = -1;
1280
1281 static char a_bigbuf[1024];
1282
1283 static dissector_handle_t data_handle;
1284 static dissector_handle_t bssmap_handle;
1285 static dissector_handle_t dtap_handle;
1286 static dissector_handle_t rp_handle;
1287 static dissector_table_t sms_dissector_table;   /* SMS TPDU */
1288 static dissector_table_t gprs_sm_pco_subdissector_table; /* GPRS SM PCO PPP Protocols */
1289
1290 static packet_info *g_pinfo;
1291 static proto_tree *g_tree;
1292 static gint comp_type_tag;
1293 static guint32 localValue;
1294
1295
1296 /*
1297  * this should be set on a per message basis, if possible
1298  */
1299 #define IS_UPLINK_FALSE         0
1300 #define IS_UPLINK_TRUE          1
1301 #define IS_UPLINK_UNKNOWN       2
1302 static gint is_uplink;
1303
1304
1305 typedef struct dgt_set_t
1306 {
1307     unsigned char out[15];
1308 }
1309 dgt_set_t;
1310
1311 static dgt_set_t Dgt_mbcd = {
1312     {
1313   /*  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e */
1314      '0','1','2','3','4','5','6','7','8','9','*','#','a','b','c'
1315     }
1316 };
1317
1318 static dgt_set_t Dgt_tbcd = {
1319     {
1320   /*  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e */
1321      '0','1','2','3','4','5','6','7','8','9','?','B','C','*','#'
1322     }
1323 };
1324
1325 static dgt_set_t Dgt1_9_bcd = {
1326     {
1327   /*  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e */
1328      '0','1','2','3','4','5','6','7','8','9','?','?','?','?','?'
1329     }
1330 };
1331
1332 /* FUNCTIONS */
1333
1334 /*
1335  * Unpack BCD input pattern into output ASCII pattern
1336  *
1337  * Input Pattern is supplied using the same format as the digits
1338  *
1339  * Returns: length of unpacked pattern
1340  */
1341 static int
1342 my_dgt_tbcd_unpack(
1343     char        *out,           /* ASCII pattern out */
1344     guchar      *in,            /* packed pattern in */
1345     int         num_octs,       /* Number of octets to unpack */
1346     dgt_set_t   *dgt            /* Digit definitions */
1347     )
1348 {
1349     int cnt = 0;
1350     unsigned char i;
1351
1352     while (num_octs)
1353     {
1354         /*
1355          * unpack first value in byte
1356          */
1357         i = *in++;
1358         *out++ = dgt->out[i & 0x0f];
1359         cnt++;
1360
1361         /*
1362          * unpack second value in byte
1363          */
1364         i >>= 4;
1365
1366         if (i == 0x0f)  /* odd number bytes - hit filler */
1367             break;
1368
1369         *out++ = dgt->out[i];
1370         cnt++;
1371         num_octs--;
1372     }
1373
1374     *out = '\0';
1375
1376     return(cnt);
1377 }
1378
1379
1380 /* ELEMENT FUNCTIONS */
1381
1382 #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \
1383     if ((edc_len) > (edc_max_len)) \
1384     { \
1385         proto_tree_add_text(tree, tvb, \
1386             curr_offset, (edc_len) - (edc_max_len), "Extraneous Data"); \
1387         curr_offset += ((edc_len) - (edc_max_len)); \
1388     }
1389
1390 #define SHORT_DATA_CHECK(sdc_len, sdc_min_len) \
1391     if ((sdc_len) < (sdc_min_len)) \
1392     { \
1393         proto_tree_add_text(tree, tvb, \
1394             curr_offset, (sdc_len), "Short Data (?)"); \
1395         curr_offset += (sdc_len); \
1396         return(curr_offset - offset); \
1397     }
1398
1399 #define EXACT_DATA_CHECK(edc_len, edc_eq_len) \
1400     if ((edc_len) != (edc_eq_len)) \
1401     { \
1402         proto_tree_add_text(tree, tvb, \
1403             curr_offset, (edc_len), "Unexpected Data Length"); \
1404         curr_offset += (edc_len); \
1405         return(curr_offset - offset); \
1406     }
1407
1408 #define NO_MORE_DATA_CHECK(nmdc_len) \
1409     if ((nmdc_len) == (curr_offset - offset)) return(nmdc_len);
1410
1411 /*
1412  * Decode the MCC/MNC from 3 octets in 'octs'
1413  */
1414 static void
1415 mcc_mnc_aux(guint8 *octs, gchar *mcc, gchar *mnc)
1416 {
1417     if ((octs[0] & 0x0f) <= 9)
1418     {
1419         mcc[0] = Dgt_tbcd.out[octs[0] & 0x0f];
1420     }
1421     else
1422     {
1423         mcc[0] = (octs[0] & 0x0f) + 55;
1424     }
1425
1426     if (((octs[0] & 0xf0) >> 4) <= 9)
1427     {
1428         mcc[1] = Dgt_tbcd.out[(octs[0] & 0xf0) >> 4];
1429     }
1430     else
1431     {
1432         mcc[1] = ((octs[0] & 0xf0) >> 4) + 55;
1433     }
1434
1435     if ((octs[1] & 0x0f) <= 9)
1436     {
1437         mcc[2] = Dgt_tbcd.out[octs[1] & 0x0f];
1438     }
1439     else
1440     {
1441         mcc[2] = (octs[1] & 0x0f) + 55;
1442     }
1443
1444     mcc[3] = '\0';
1445
1446     if (((octs[1] & 0xf0) >> 4) <= 9)
1447     {
1448         mnc[2] = Dgt_tbcd.out[(octs[1] & 0xf0) >> 4];
1449     }
1450     else
1451     {
1452         mnc[2] = ((octs[1] & 0xf0) >> 4) + 55;
1453     }
1454
1455     if ((octs[2] & 0x0f) <= 9)
1456     {
1457         mnc[0] = Dgt_tbcd.out[octs[2] & 0x0f];
1458     }
1459     else
1460     {
1461         mnc[0] = (octs[2] & 0x0f) + 55;
1462     }
1463
1464     if (((octs[2] & 0xf0) >> 4) <= 9)
1465     {
1466         mnc[1] = Dgt_tbcd.out[(octs[2] & 0xf0) >> 4];
1467     }
1468     else
1469     {
1470         mnc[1] = ((octs[2] & 0xf0) >> 4) + 55;
1471     }
1472
1473     if (mnc[1] == 'F')
1474     {
1475         /*
1476          * only a 1 digit MNC (very old)
1477          */
1478         mnc[1] = '\0';
1479     }
1480     else if (mnc[2] == 'F')
1481     {
1482         /*
1483          * only a 2 digit MNC
1484          */
1485         mnc[2] = '\0';
1486     }
1487     else
1488     {
1489         mnc[3] = '\0';
1490     }
1491 }
1492
1493 typedef enum
1494 {
1495     BE_CIC,      /* Circuit Identity Code */
1496     BE_RSVD_1,   /* Reserved */
1497     BE_RES_AVAIL,        /* Resource Available */
1498     BE_CAUSE,    /* Cause */
1499     BE_CELL_ID,  /* Cell Identifier */
1500     BE_PRIO,     /* Priority */
1501     BE_L3_HEADER_INFO,   /* Layer 3 Header Information */
1502     BE_IMSI,     /* IMSI */
1503     BE_TMSI,     /* TMSI */
1504     BE_ENC_INFO,         /* Encryption Information */
1505     BE_CHAN_TYPE,        /* Channel Type */
1506     BE_PERIODICITY,      /* Periodicity */
1507     BE_EXT_RES_IND,      /* Extended Resource Indicator */
1508     BE_NUM_MS,   /* Number Of MSs */
1509     BE_RSVD_2,   /* Reserved */
1510     BE_RSVD_3,   /* Reserved */
1511     BE_RSVD_4,   /* Reserved */
1512     BE_CM_INFO_2,        /* Classmark Information Type 2 */
1513     BE_CM_INFO_3,        /* Classmark Information Type 3 */
1514     BE_INT_BAND,         /* Interference Band To Be Used */
1515     BE_RR_CAUSE,         /* RR Cause */
1516     BE_RSVD_5,   /* Reserved */
1517     BE_L3_INFO,  /* Layer 3 Information */
1518     BE_DLCI,     /* DLCI */
1519     BE_DOWN_DTX_FLAG,    /* Downlink DTX Flag */
1520     BE_CELL_ID_LIST,     /* Cell Identifier List */
1521     BE_RESP_REQ,         /* Response Request */
1522     BE_RES_IND_METHOD,   /* Resource Indication Method */
1523     BE_CM_INFO_1,        /* Classmark Information Type 1 */
1524     BE_CIC_LIST,         /* Circuit Identity Code List */
1525     BE_DIAG,     /* Diagnostic */
1526     BE_L3_MSG,   /* Layer 3 Message Contents */
1527     BE_CHOSEN_CHAN,      /* Chosen Channel */
1528     BE_TOT_RES_ACC,      /* Total Resource Accessible */
1529     BE_CIPH_RESP_MODE,   /* Cipher Response Mode */
1530     BE_CHAN_NEEDED,      /* Channel Needed */
1531     BE_TRACE_TYPE,       /* Trace Type */
1532     BE_TRIGGERID,        /* TriggerID */
1533     BE_TRACE_REF,        /* Trace Reference */
1534     BE_TRANSID,  /* TransactionID */
1535     BE_MID,      /* Mobile Identity */
1536     BE_OMCID,    /* OMCID */
1537     BE_FOR_IND,  /* Forward Indicator */
1538     BE_CHOSEN_ENC_ALG,   /* Chosen Encryption Algorithm */
1539     BE_CCT_POOL,         /* Circuit Pool */
1540     BE_CCT_POOL_LIST,    /* Circuit Pool List */
1541     BE_TIME_IND,         /* Time Indication */
1542     BE_RES_SIT,  /* Resource Situation */
1543     BE_CURR_CHAN_1,      /* Current Channel Type 1 */
1544     BE_QUE_IND,  /* Queueing Indicator */
1545     BE_SPEECH_VER,       /* Speech Version */
1546     BE_ASS_REQ,  /* Assignment Requirement */
1547     BE_TALKER_FLAG,      /* Talker Flag */
1548     BE_CONN_REL_REQ,     /* Connection Release Requested */
1549     BE_GROUP_CALL_REF,   /* Group Call Reference */
1550     BE_EMLPP_PRIO,       /* eMLPP Priority */
1551     BE_CONF_EVO_IND,     /* Configuration Evolution Indication */
1552     BE_OLD2NEW_INFO,     /* Old BSS to New BSS Information */
1553     BE_LSA_ID,   /* LSA Identifier */
1554     BE_LSA_ID_LIST,      /* LSA Identifier List */
1555     BE_LSA_INFO,         /* LSA Information */
1556     BE_LCS_QOS,  /* LCS QoS */
1557     BE_LSA_ACC_CTRL,     /* LSA access control suppression */
1558     BE_LCS_PRIO,         /* LCS Priority */
1559     BE_LOC_TYPE,         /* Location Type */
1560     BE_LOC_EST,  /* Location Estimate */
1561     BE_POS_DATA,         /* Positioning Data */
1562     BE_LCS_CAUSE,        /* LCS Cause */
1563     BE_LCS_CLIENT,       /* LCS Client Type */
1564     BE_APDU,     /* APDU */
1565     BE_NE_ID,    /* Network Element Identity */
1566     BE_GSP_ASSIST_DATA,  /* GPS Assistance Data */
1567     BE_DECIPH_KEYS,      /* Deciphering Keys */
1568     BE_RET_ERR_REQ,      /* Return Error Request */
1569     BE_RET_ERR_CAUSE,    /* Return Error Cause */
1570     BE_SEG,      /* Segmentation */
1571     BE_NONE     /* NONE */
1572 }
1573 bssmap_elem_idx_t;
1574
1575 #define NUM_GSM_BSSMAP_ELEM (sizeof(gsm_bssmap_elem_strings)/sizeof(value_string))
1576 static gint ett_gsm_bssmap_elem[NUM_GSM_BSSMAP_ELEM];
1577
1578 /*
1579  * [2] 3.2.2.2
1580  */
1581 static guint8
1582 be_cic(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
1583 {
1584     guint32     curr_offset;
1585     guint32     value;
1586
1587     len = len;
1588     curr_offset = offset;
1589
1590     value = tvb_get_ntohs(tvb, curr_offset);
1591
1592     other_decode_bitfield_value(a_bigbuf, value, 0xffe0, 16);
1593     proto_tree_add_text(tree,
1594         tvb, curr_offset, 2,
1595         "%s :  PCM Multiplexer: %u",
1596         a_bigbuf,
1597         (value & 0xffe0) >> 5);
1598
1599     other_decode_bitfield_value(a_bigbuf, value, 0x001f, 16);
1600     proto_tree_add_text(tree,
1601         tvb, curr_offset, 2,
1602         "%s :  Timeslot: %u",
1603         a_bigbuf,
1604         value & 0x001f);
1605
1606     curr_offset += 2;
1607
1608     if (add_string)
1609         g_snprintf(add_string, string_len, " - (%u) (0x%04x)", value, value);
1610
1611     /* no length check possible */
1612
1613     return(curr_offset - offset);
1614 }
1615
1616 /*
1617  * [2] 3.2.2.5
1618  */
1619 static guint8
1620 be_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
1621 {
1622     guint8      oct;
1623     guint32     value;
1624     guint32     curr_offset;
1625     const gchar *str = NULL;
1626
1627     curr_offset = offset;
1628
1629     oct = tvb_get_guint8(tvb, curr_offset);
1630
1631     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
1632     proto_tree_add_text(tree,
1633         tvb, curr_offset, 1,
1634         "%s :  Extension: %s",
1635         a_bigbuf,
1636         (oct & 0x80) ? "extended" : "not extended");
1637
1638     if (oct & 0x80)
1639     {
1640         /* 2 octet cause */
1641
1642         if ((oct & 0x0f) == 0x00)
1643         {
1644             /* national cause */
1645             switch ((oct & 0x70) >> 4)
1646             {
1647             case 0: str = "Normal Event"; break;
1648             case 1: str = "Normal Event"; break;
1649             case 2: str = "Resource Unavailable"; break;
1650             case 3: str = "Service or option not available"; break;
1651             case 4: str = "Service or option not implemented"; break;
1652             case 5: str = "Invalid message (e.g., parameter out of range)"; break;
1653             case 6: str = "Protocol error"; break;
1654             default:
1655                 str = "Interworking";
1656                 break;
1657             }
1658
1659             other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
1660             proto_tree_add_text(tree,
1661                 tvb, curr_offset, 1,
1662                 "%s :  Cause Class: %s",
1663                 a_bigbuf,
1664                 str);
1665
1666             other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
1667             proto_tree_add_text(tree,
1668                 tvb, curr_offset, 1,
1669                 "%s :  National Cause",
1670                 a_bigbuf);
1671
1672             curr_offset++;
1673
1674             proto_tree_add_text(tree, tvb, curr_offset, 1,
1675                 "Cause Value");
1676
1677             curr_offset++;
1678
1679             if (add_string)
1680                 g_snprintf(add_string, string_len, " - (National Cause)");
1681         }
1682         else
1683         {
1684             value = tvb_get_guint8(tvb, curr_offset + 1);
1685
1686             other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
1687             proto_tree_add_text(tree,
1688                 tvb, curr_offset, 1,
1689                 "%s :  Cause (MSB): %u",
1690                 a_bigbuf,
1691                 ((oct & 0x7f) << 8) | value);
1692
1693             curr_offset++;
1694
1695             other_decode_bitfield_value(a_bigbuf, value, 0xff, 8);
1696             proto_tree_add_text(tree, tvb, curr_offset, 1,
1697                 "%s :  Cause (LSB)",
1698                 a_bigbuf);
1699
1700             curr_offset++;
1701         }
1702     }
1703     else
1704     {
1705         switch (oct)
1706         {
1707         case 0x00: str = "Radio interface message failure"; break;
1708         case 0x01: str = "Radio interface failure"; break;
1709         case 0x02: str = "Uplink quality"; break;
1710         case 0x03: str = "Uplink strength"; break;
1711         case 0x04: str = "Downlink quality"; break;
1712         case 0x05: str = "Downlink strength"; break;
1713         case 0x06: str = "Distance"; break;
1714         case 0x07: str = "O and M intervention"; break;
1715         case 0x08: str = "Response to MSC invocation"; break;
1716         case 0x09: str = "Call control"; break;
1717         case 0x0a: str = "Radio interface failure, reversion to old channel"; break;
1718         case 0x0b: str = "Handover successful"; break;
1719         case 0x0c: str = "Better Cell"; break;
1720         case 0x0d: str = "Directed Retry"; break;
1721         case 0x0e: str = "Joined group call channel"; break;
1722         case 0x0f: str = "Traffic"; break;
1723
1724         case 0x20: str = "Equipment failure"; break;
1725         case 0x21: str = "No radio resource available"; break;
1726         case 0x22: str = "Requested terrestrial resource unavailable"; break;
1727         case 0x23: str = "CCCH overload"; break;
1728         case 0x24: str = "Processor overload"; break;
1729         case 0x25: str = "BSS not equipped"; break;
1730         case 0x26: str = "MS not equipped"; break;
1731         case 0x27: str = "Invalid cell"; break;
1732         case 0x28: str = "Traffic Load"; break;
1733         case 0x29: str = "Preemption"; break;
1734
1735         case 0x30: str = "Requested transcoding/rate adaption unavailable"; break;
1736         case 0x31: str = "Circuit pool mismatch"; break;
1737         case 0x32: str = "Switch circuit pool"; break;
1738         case 0x33: str = "Requested speech version unavailable"; break;
1739         case 0x34: str = "LSA not allowed"; break;
1740
1741         case 0x40: str = "Ciphering algorithm not supported"; break;
1742
1743         case 0x50: str = "Terrestrial circuit already allocated"; break;
1744         case 0x51: str = "Invalid message contents"; break;
1745         case 0x52: str = "Information element or field missing"; break;
1746         case 0x53: str = "Incorrect value"; break;
1747         case 0x54: str = "Unknown Message type"; break;
1748         case 0x55: str = "Unknown Information Element"; break;
1749
1750         case 0x60: str = "Protocol Error between BSS and MSC"; break;
1751         case 0x61: str = "VGCS/VBS call non existent"; break;
1752
1753         default:
1754             if ((oct >= 0x10) && (oct <= 0x17)) { str = "Reserved for international use"; }
1755             else if ((oct >= 0x18) && (oct <= 0x1f)) { str = "Reserved for national use"; }
1756             else if ((oct >= 0x2a) && (oct <= 0x2f)) { str = "Reserved for national use"; }
1757             else if ((oct >= 0x35) && (oct <= 0x3f)) { str = "Reserved for international use"; }
1758             else if ((oct >= 0x41) && (oct <= 0x47)) { str = "Reserved for international use"; }
1759             else if ((oct >= 0x48) && (oct <= 0x4f)) { str = "Reserved for national use"; }
1760             else if ((oct >= 0x56) && (oct <= 0x57)) { str = "Reserved for international use"; }
1761             else if ((oct >= 0x58) && (oct <= 0x5f)) { str = "Reserved for national use"; }
1762             else if ((oct >= 0x62) && (oct <= 0x67)) { str = "Reserved for international use"; }
1763             else if ((oct >= 0x68) && (oct <= 0x6f)) { str = "Reserved for national use"; }
1764             else if ((oct >= 0x70) && (oct <= 0x77)) { str = "Reserved for international use"; }
1765             else if ((oct >= 0x78) && (oct <= 0x7f)) { str = "Reserved for national use"; }
1766             break;
1767         }
1768
1769         other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
1770         proto_tree_add_uint_format(tree, hf_gsm_a_bssmap_cause,
1771             tvb, curr_offset, 1, oct & 0x7f,
1772             "%s :  Cause: (%u) %s",
1773             a_bigbuf,
1774             oct & 0x7f,
1775             str);
1776
1777         curr_offset++;
1778
1779         if (add_string)
1780             g_snprintf(add_string, string_len, " - (%u) %s", oct & 0x7f, str);
1781     }
1782
1783     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1784
1785     return(curr_offset - offset);
1786 }
1787
1788 /*
1789  * [2] 3.2.2.7
1790  */
1791 static guint8
1792 be_tmsi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
1793 {
1794     guint32     curr_offset;
1795     guint32     value;
1796
1797     curr_offset = offset;
1798
1799     value = tvb_get_ntohl(tvb, curr_offset);
1800
1801     proto_tree_add_uint(tree, hf_gsm_a_tmsi,
1802         tvb, curr_offset, 4,
1803         value);
1804
1805     if (add_string)
1806         g_snprintf(add_string, string_len, " - (0x%04x)", value);
1807
1808     curr_offset += 4;
1809
1810     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1811
1812     return(curr_offset - offset);
1813 }
1814
1815 /*
1816  * [2] 3.2.2.9
1817  */
1818 static guint8
1819 be_l3_header_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1820 {
1821     guint8      oct;
1822     guint32     curr_offset;
1823
1824     curr_offset = offset;
1825
1826     oct = tvb_get_guint8(tvb, curr_offset);
1827
1828     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
1829     proto_tree_add_text(tree,
1830         tvb, curr_offset, 1,
1831         "%s :  Spare",
1832         a_bigbuf);
1833
1834         proto_tree_add_item(tree, hf_gsm_a_L3_protocol_discriminator, tvb, curr_offset, 1, FALSE);
1835
1836
1837     curr_offset++;
1838
1839     NO_MORE_DATA_CHECK(len);
1840
1841     oct = tvb_get_guint8(tvb, curr_offset);
1842
1843     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
1844     proto_tree_add_text(tree,
1845         tvb, curr_offset, 1,
1846         "%s :  Spare",
1847         a_bigbuf);
1848
1849     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
1850     proto_tree_add_text(tree,
1851         tvb, curr_offset, 1,
1852         "%s :  TI flag: %s",
1853         a_bigbuf,
1854         ((oct & 0x08) ?  "allocated by receiver" : "allocated by sender"));
1855
1856     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
1857     proto_tree_add_text(tree,
1858         tvb, curr_offset, 1,
1859         "%s :  TIO: %u",
1860         a_bigbuf,
1861         oct & 0x07);
1862
1863     curr_offset++;
1864
1865     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1866
1867     return(curr_offset - offset);
1868 }
1869
1870 /*
1871  * [2] 3.2.2.10
1872  */
1873 static guint8
1874 be_enc_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1875 {
1876     guint8      oct;
1877     guint8      mask;
1878     guint8      alg_id;
1879     guint32     curr_offset;
1880
1881     curr_offset = offset;
1882
1883     oct = tvb_get_guint8(tvb, curr_offset);
1884
1885     mask = 0x80;
1886     alg_id = 7;
1887
1888     do
1889     {
1890         other_decode_bitfield_value(a_bigbuf, oct, mask, 8);
1891         proto_tree_add_text(tree,
1892             tvb, curr_offset, 1,
1893             "%s :  GSM A5/%u: %spermitted",
1894             a_bigbuf,
1895             alg_id,
1896             (mask & oct) ? "" : "not ");
1897
1898         mask >>= 1;
1899         alg_id--;
1900     }
1901     while (mask != 0x01);
1902
1903     other_decode_bitfield_value(a_bigbuf, oct, mask, 8);
1904     proto_tree_add_text(tree,
1905         tvb, curr_offset, 1,
1906         "%s :  No encryption: %spermitted",
1907         a_bigbuf,
1908         (mask & oct) ? "" : "not ");
1909
1910     curr_offset++;
1911
1912     NO_MORE_DATA_CHECK(len);
1913
1914     proto_tree_add_text(tree,
1915         tvb, curr_offset, len - (curr_offset - offset),
1916                         "Key: %s",
1917                         tvb_bytes_to_str(tvb, curr_offset, len-(curr_offset-offset) ));
1918
1919     curr_offset += len - (curr_offset - offset);
1920
1921     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1922
1923     return(curr_offset - offset);
1924 }
1925
1926 /*
1927  * [2] 3.2.2.11
1928  */
1929 guint8
1930 be_chan_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
1931 {
1932     guint8      oct;
1933     guint8      sdi;
1934     guint8      num_chan;
1935     guint32     curr_offset;
1936     const gchar *str;
1937
1938     curr_offset = offset;
1939
1940     oct = tvb_get_guint8(tvb, curr_offset);
1941
1942     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
1943     proto_tree_add_text(tree,
1944         tvb, curr_offset, 1,
1945         "%s :  Spare",
1946         a_bigbuf);
1947
1948     sdi = oct & 0x0f;
1949     switch (sdi)
1950     {
1951     case 1: str = "Speech"; break;
1952     case 2: str = "Data"; break;
1953     case 3: str = "Signalling"; break;
1954     default:
1955         str = "Reserved";
1956         break;
1957     }
1958
1959     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
1960     proto_tree_add_text(tree,
1961         tvb, curr_offset, 1,
1962         "%s :  Speech/Data Indicator: %s",
1963         a_bigbuf,
1964         str);
1965
1966     if (add_string)
1967         g_snprintf(add_string, string_len, " - (%s)", str);
1968
1969     curr_offset++;
1970
1971     NO_MORE_DATA_CHECK(len);
1972
1973     oct = tvb_get_guint8(tvb, curr_offset);
1974
1975     if (sdi == 0x01)
1976     {
1977         /* speech */
1978
1979         switch (oct)
1980         {
1981         case 0x08: str = "Full rate TCH channel Bm.  Prefer full rate TCH"; break;
1982         case 0x09: str = "Half rate TCH channel Lm.  Prefer half rate TCH"; break;
1983         case 0x0a: str = "Full or Half rate channel, Full rate preferred changes allowed after first allocation"; break;
1984         case 0x0b: str = "Full or Half rate channel, Half rate preferred changes allowed after first allocation"; break;
1985         case 0x1a: str = "Full or Half rate channel, Full rate preferred changes between full and half rate not allowed after first allocation"; break;
1986         case 0x1b: str = "Full or Half rate channel, Half rate preferred changes between full and half rate not allowed after first allocation"; break;
1987         case 0x0f: str = "Full or Half rate channel, changes allowed after first allocation"; break;
1988         case 0x1f: str = "Full or Half rate channel, changes between full and half rate not allowed after first allocation"; break;
1989         default:
1990             str = "Reserved";
1991             break;
1992         }
1993
1994         proto_tree_add_text(tree,
1995             tvb, curr_offset, 1,
1996             "Channel Rate and Type: %s",
1997             str);
1998
1999         curr_offset++;
2000
2001         NO_MORE_DATA_CHECK(len);
2002
2003         do
2004         {
2005             oct = tvb_get_guint8(tvb, curr_offset);
2006
2007             other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
2008             proto_tree_add_text(tree,
2009                 tvb, curr_offset, 1,
2010                 "%s :  Extension: %s",
2011                 a_bigbuf,
2012                 (oct & 0x80) ? "extended" : "not extended");
2013
2014             switch (oct & 0x7f)
2015             {
2016             case 0x01: str = "GSM speech full rate version 1"; break;
2017             case 0x11: str = "GSM speech full rate version 2"; break;
2018             case 0x21: str = "GSM speech full rate version 3 (AMR)"; break;
2019
2020             case 0x05: str = "GSM speech half rate version 1"; break;
2021             case 0x15: str = "GSM speech half rate version 2"; break;
2022             case 0x25: str = "GSM speech half rate version 3 (AMR)"; break;
2023
2024             default:
2025                 str = "Reserved";
2026                 break;
2027             }
2028
2029             other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
2030             proto_tree_add_text(tree,
2031                 tvb, curr_offset, 1,
2032                 "%s :  Speech version identifier: %s",
2033                 a_bigbuf,
2034                 str);
2035
2036             curr_offset++;
2037         }
2038         while ((len - (curr_offset - offset)) > 0);
2039     }
2040     else if (sdi == 0x02)
2041     {
2042         /* data */
2043
2044         num_chan = 0;
2045
2046         switch (oct)
2047         {
2048         case 0x08: str = "Full rate TCH channel Bm"; break;
2049         case 0x09: str = "Half rate TCH channel Lm"; break;
2050         case 0x0a: str = "Full or Half rate TCH channel, Full rate preferred, changes allowed also after first channel allocation as a result of the request"; break;
2051         case 0x0b: str = "Full or Half rate TCH channel, Half rate preferred, changes allowed also after first channel allocation as a result of the request"; break;
2052         case 0x1a: str = "Full or Half rate TCH channel, Full rate preferred, changes not allowed after first channel allocation as a result of the request"; break;
2053         case 0x1b: str = "Full or Half rate TCH channel. Half rate preferred, changes not allowed after first channel allocation as a result of the request"; break;
2054         default:
2055             if ((oct >= 0x20) && (oct <= 0x27))
2056             {
2057                 str = "Full rate TCH channels in a multislot configuration, changes by the BSS of the the number of TCHs and if applicable the used radio interface rate per channel allowed after first channel allocation as a result of the request";
2058
2059                 num_chan = (oct - 0x20) + 1;
2060             }
2061             else if ((oct >= 0x30) && (oct <= 0x37))
2062             {
2063                 str = "Full rate TCH channels in a multislot configuration, changes by the BSS of the number of TCHs or the used radio interface rate per channel not allowed after first channel allocation as a result of the request";
2064
2065                 num_chan = (oct - 0x30) + 1;
2066             }
2067             else
2068             {
2069                 str = "Reserved";
2070             }
2071             break;
2072         }
2073
2074         if (num_chan > 0)
2075         {
2076             proto_tree_add_text(tree,
2077                 tvb, curr_offset, 1,
2078                 "Channel Rate and Type: Max channels %u, %s",
2079                 num_chan,
2080                 str);
2081         }
2082         else
2083         {
2084             proto_tree_add_text(tree,
2085                 tvb, curr_offset, 1,
2086                 "Channel Rate and Type: %s",
2087                 str);
2088         }
2089
2090         curr_offset++;
2091
2092         NO_MORE_DATA_CHECK(len);
2093
2094         oct = tvb_get_guint8(tvb, curr_offset);
2095
2096         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
2097         proto_tree_add_text(tree,
2098             tvb, curr_offset, 1,
2099             "%s :  Extension: %s",
2100             a_bigbuf,
2101             (oct & 0x80) ? "extended" : "not extended");
2102
2103         other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
2104         proto_tree_add_text(tree,
2105             tvb, curr_offset, 1,
2106             "%s :  %sTransparent service",
2107             a_bigbuf,
2108             (oct & 0x40) ? "Non-" : "");
2109
2110         if (num_chan == 0)
2111         {
2112             if (oct & 0x40)
2113             {
2114                 /* non-transparent */
2115
2116                 switch (oct & 0x3f)
2117                 {
2118                 case 0x00: str = "12 kbit/s if the channel is a full rate TCH, or 6 kbit/s if the channel is a half rate TCH"; break;
2119                 case 0x18: str = "14.5 kbit/s"; break;
2120                 case 0x10: str = "12 kbits/s"; break;
2121                 case 0x11: str = "6 kbits/s"; break;
2122                 default:
2123                     str = "Reserved";
2124                     break;
2125                 }
2126             }
2127             else
2128             {
2129                 switch (oct & 0x3f)
2130                 {
2131                 case 0x18: str = "14.4 kbit/s"; break;
2132                 case 0x10: str = "9.6kbit/s"; break;
2133                 case 0x11: str = "4.8kbit/s"; break;
2134                 case 0x12: str = "2.4kbit/s"; break;
2135                 case 0x13: str = "1.2Kbit/s"; break;
2136                 case 0x14: str = "600 bit/s"; break;
2137                 case 0x15: str = "1200/75 bit/s (1200 network-to-MS / 75 MS-to-network)"; break;
2138                 default:
2139                     str = "Reserved";
2140                     break;
2141                 }
2142             }
2143         }
2144         else
2145         {
2146             if (oct & 0x40)
2147             {
2148                 /* non-transparent */
2149
2150                 switch (oct & 0x3f)
2151                 {
2152                 case 0x16: str = "58 kbit/s (4x14.5 kbit/s)"; break;
2153                 case 0x14: str = "48.0 / 43.5 kbit/s (4x12 kbit/s or 3x14.5 kbit/s)"; break;
2154                 case 0x13: str = "36.0 / 29.0 kbit/s (3x12 kbit/s or 2x14.5 kbit/s)"; break;
2155                 case 0x12: str = "24.0 / 24.0 (4x6 kbit/s or 2x12 kbit/s)"; break;
2156                 case 0x11: str = "18.0 / 14.5 kbit/s (3x6 kbit/s or 1x14.5 kbit/s)"; break;
2157                 case 0x10: str = "12.0 / 12.0 kbit/s (2x6 kbit/s or 1x12 kbit/s)"; break;
2158                 default:
2159                     str = "Reserved";
2160                     break;
2161                 }
2162             }
2163             else
2164             {
2165                 switch (oct & 0x3f)
2166                 {
2167                 case 0x1f: str = "64 kbit/s, bit transparent"; break;
2168                 case 0x1e: str = "56 kbit/s, bit transparent"; break;
2169                 case 0x1d: str = "56 kbit/s"; break;
2170                 case 0x1c: str = "48 kbit/s"; break;
2171                 case 0x1b: str = "38.4 kbit/s"; break;
2172                 case 0x1a: str = "28.8 kbit/s"; break;
2173                 case 0x19: str = "19.2 kbit/s"; break;
2174                 case 0x18: str = "14.4 kbit/s"; break;
2175                 case 0x10: str = "9.6 kbit/s"; break;
2176                 default:
2177                     str = "Reserved";
2178                     break;
2179                 }
2180             }
2181         }
2182
2183         other_decode_bitfield_value(a_bigbuf, oct, 0x3f, 8);
2184         proto_tree_add_text(tree,
2185             tvb, curr_offset, 1,
2186             "%s :  Rate: %s",
2187             a_bigbuf,
2188             str);
2189
2190         curr_offset++;
2191
2192         NO_MORE_DATA_CHECK(len);
2193
2194         oct = tvb_get_guint8(tvb, curr_offset);
2195
2196         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
2197         proto_tree_add_text(tree,
2198             tvb, curr_offset, 1,
2199             "%s :  Extension: %s",
2200             a_bigbuf,
2201             (oct & 0x80) ? "extended" : "not extended");
2202
2203         other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
2204         proto_tree_add_text(tree,
2205             tvb, curr_offset, 1,
2206             "%s :  Spare",
2207             a_bigbuf);
2208
2209         if (num_chan == 0)
2210         {
2211             other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
2212             proto_tree_add_text(tree,
2213                 tvb, curr_offset, 1,
2214                 "%s :  14.5 kbit/s (TCH/F14.4) %sallowed",
2215                 a_bigbuf,
2216                 (oct & 0x08) ? "" : "not ");
2217
2218             other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
2219             proto_tree_add_text(tree,
2220                 tvb, curr_offset, 1,
2221                 "%s :  Spare",
2222                 a_bigbuf);
2223
2224             other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
2225             proto_tree_add_text(tree,
2226                 tvb, curr_offset, 1,
2227                 "%s :  12.0 kbit/s (TCH F/9.6) %sallowed",
2228                 a_bigbuf,
2229                 (oct & 0x02) ? "" : "not ");
2230
2231             other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2232             proto_tree_add_text(tree,
2233                 tvb, curr_offset, 1,
2234                 "%s :  6.0 kbit/s (TCH F/4.8) %sallowed",
2235                 a_bigbuf,
2236                 (oct & 0x01) ? "" : "not ");
2237         }
2238         else
2239         {
2240             other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
2241             proto_tree_add_text(tree,
2242                 tvb, curr_offset, 1,
2243                 "%s :  14.5/14.4 kbit/s (TCH/F14.4) %sallowed",
2244                 a_bigbuf,
2245                 (oct & 0x08) ? "" : "not ");
2246
2247             other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
2248             proto_tree_add_text(tree,
2249                 tvb, curr_offset, 1,
2250                 "%s :  Spare",
2251                 a_bigbuf);
2252
2253             other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
2254             proto_tree_add_text(tree,
2255                 tvb, curr_offset, 1,
2256                 "%s :  12.0/9.6 kbit/s (TCH F/9.6) %sallowed",
2257                 a_bigbuf,
2258                 (oct & 0x02) ? "" : "not ");
2259
2260             other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2261             proto_tree_add_text(tree,
2262                 tvb, curr_offset, 1,
2263                 "%s :  6.0/4.8 kbit/s (TCH F/4.8) %sallowed",
2264                 a_bigbuf,
2265                 (oct & 0x01) ? "" : "not ");
2266         }
2267
2268         curr_offset++;
2269     }
2270     else if (sdi == 0x03)
2271     {
2272         /* signalling */
2273
2274         switch (oct)
2275         {
2276         case 0x00: str = "SDCCH or Full rate TCH channel Bm or Half rate TCH channel Lm"; break;
2277         case 0x01: str = "SDCCH"; break;
2278         case 0x02: str = "SDCCH or Full rate TCH channel Bm"; break;
2279         case 0x03: str = "SDCCH or Half rate TCH channel Lm"; break;
2280         case 0x08: str = "Full rate TCH channel Bm"; break;
2281         case 0x09: str = "Half rate TCH channel Lm"; break;
2282         case 0x0a: str = "Full or Half rate TCH channel, Full rate preferred, changes allowed also after first channel allocation as a result of the request"; break;
2283         case 0x0b: str = "Full or Half rate TCH channel, Half rate preferred, changes allowed also after first channel allocation as a result of the request"; break;
2284         case 0x1a: str = "Full or Half rate TCH channel, Full rate preferred, changes not allowed after first channel allocation as a result of the request"; break;
2285         case 0x1b: str = "Full or Half rate TCH channel. Half rate preferred, changes not allowed after first channel allocation as a result of the request"; break;
2286         default:
2287             str = "Reserved";
2288             break;
2289         }
2290
2291         proto_tree_add_text(tree,
2292             tvb, curr_offset, 1,
2293             "Channel Rate and Type: %s",
2294             str);
2295
2296         curr_offset++;
2297
2298         NO_MORE_DATA_CHECK(len);
2299
2300         proto_tree_add_text(tree,
2301             tvb, curr_offset, len - (curr_offset - offset),
2302             "Spare");
2303
2304         curr_offset += len - (curr_offset - offset);
2305     }
2306     else
2307     {
2308         /* unknown format */
2309
2310         proto_tree_add_text(tree,
2311             tvb, curr_offset, len - (curr_offset - offset),
2312             "Unknown format");
2313
2314         curr_offset += len - (curr_offset - offset);
2315     }
2316
2317     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
2318
2319     return(curr_offset - offset);
2320 }
2321
2322 /*
2323  * [2] 3.2.2.17
2324  * Formats everything after the discriminator, shared function
2325  */
2326 guint8
2327 be_cell_id_aux(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len, guint8 disc)
2328 {
2329     guint8      octs[3];
2330     guint32     value;
2331     guint32     curr_offset;
2332     gchar       mcc[4];
2333     gchar       mnc[4];
2334
2335     if (add_string)
2336         add_string[0] = '\0';
2337     curr_offset = offset;
2338
2339     switch (disc)
2340     {
2341     case 0x00:
2342         /* FALLTHRU */
2343
2344     case 0x04:
2345         /* FALLTHRU */
2346
2347     case 0x08:  /* For intersystem handover from GSM to UMTS or cdma2000: */
2348         octs[0] = tvb_get_guint8(tvb, curr_offset);
2349         octs[1] = tvb_get_guint8(tvb, curr_offset + 1);
2350         octs[2] = tvb_get_guint8(tvb, curr_offset + 2);
2351
2352         mcc_mnc_aux(octs, mcc, mnc);
2353
2354         proto_tree_add_text(tree,
2355             tvb, curr_offset, 3,
2356             "Mobile Country Code (MCC): %s, Mobile Network Code (MNC): %s",
2357             mcc,
2358             mnc);
2359
2360         curr_offset += 3;
2361
2362         /* FALLTHRU */
2363
2364     case 0x01:
2365     case 0x05:
2366     case 0x0a: /*For intersystem handover from GSM to UMTS or cdma2000: */
2367
2368         /* LAC */
2369
2370         value = tvb_get_ntohs(tvb, curr_offset);
2371
2372         proto_tree_add_item(tree, hf_gsm_a_cell_lac, tvb, curr_offset, 2, FALSE);
2373
2374         curr_offset += 2;
2375
2376         if (add_string)
2377             g_snprintf(add_string, string_len, " - LAC (0x%04x)", value);
2378
2379         /* FALLTHRU */
2380
2381     case 0x09: /* For intersystem handover from GSM to UMTS or cdma2000: */
2382
2383         if ((disc == 0x08) ||(disc == 0x09) || (disc == 0x0a)){ 
2384                 /* RNC-ID */
2385                 value = tvb_get_ntohs(tvb, curr_offset);
2386                 proto_tree_add_item(tree, hf_gsm_a_be_rnc_id, tvb, curr_offset, 2, FALSE);
2387
2388                 if (add_string)
2389                 {
2390                     if (add_string[0] == '\0')
2391                     {
2392                         g_snprintf(add_string, string_len, " - RNC-ID (%u)", value);
2393                     }
2394                     else
2395                     {
2396                         g_snprintf(add_string, string_len, "%s/RNC-ID (%u)", add_string, value);
2397                     }
2398                 }
2399                 break;
2400         }
2401
2402         if ((disc == 0x04) || (disc == 0x05) || (disc == 0x08)) break;
2403
2404         /* FALLTHRU */
2405
2406     case 0x02:
2407
2408         /* CI */
2409
2410         value = tvb_get_ntohs(tvb, curr_offset);
2411
2412         proto_tree_add_uint(tree, hf_gsm_a_cell_ci, tvb,
2413             curr_offset, 2, value);
2414
2415         curr_offset += 2;
2416
2417         if (add_string)
2418         {
2419             if (add_string[0] == '\0')
2420             {
2421                 g_snprintf(add_string, string_len, " - CI (%u)", value);
2422             }
2423             else
2424             {
2425                 g_snprintf(add_string, string_len, "%s/CI (%u)", add_string, value);
2426             }
2427         }
2428         break;
2429
2430     default:
2431         proto_tree_add_text(tree, tvb, curr_offset, len,
2432             "Cell ID - Unknown format");
2433
2434         curr_offset += (len);
2435         break;
2436     }
2437
2438     return(curr_offset - offset);
2439 }
2440
2441 static guint8
2442 be_cell_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2443 {
2444     guint8      oct;
2445     guint8      disc;
2446     guint32     curr_offset;
2447
2448     len = len;
2449     curr_offset = offset;
2450
2451     oct = tvb_get_guint8(tvb, curr_offset);
2452
2453     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2454     proto_tree_add_text(tree,
2455         tvb, curr_offset, 1,
2456         "%s :  Spare",
2457         a_bigbuf);
2458
2459     proto_tree_add_item(tree, hf_gsm_a_be_cell_id_disc, tvb, curr_offset, 1, FALSE);
2460         disc = oct&0x0f;
2461     curr_offset++;
2462
2463     NO_MORE_DATA_CHECK(len);
2464
2465     curr_offset +=
2466         be_cell_id_aux(tvb, tree, curr_offset, len - (curr_offset - offset), add_string, string_len, disc);
2467
2468     /* no length check possible */
2469
2470     return(curr_offset - offset);
2471 }
2472
2473 /*
2474  * [2] 3.2.2.18
2475  */
2476 static guint8
2477 be_prio(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2478 {
2479     guint8      oct;
2480     guint32     curr_offset;
2481     const gchar *str;
2482
2483     len = len;
2484     curr_offset = offset;
2485
2486     oct = tvb_get_guint8(tvb, curr_offset);
2487
2488     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
2489
2490     other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
2491     proto_tree_add_text(tree,
2492         tvb, curr_offset, 1,
2493         "%s :  Preemption Capability Indicator (PCI): this allocation request %s preempt an existing connection",
2494         a_bigbuf,
2495         (oct & 0x40) ? "may" : "shall not");
2496
2497     switch ((oct & 0x3c) >> 2)
2498     {
2499     case 0x00: str = "Spare"; break;
2500     case 0x0f: str = "priority not used"; break;
2501     default:
2502         str = "1 is highest";
2503         break;
2504     }
2505
2506     other_decode_bitfield_value(a_bigbuf, oct, 0x3c, 8);
2507     proto_tree_add_text(tree,
2508         tvb, curr_offset, 1,
2509         "%s :  Priority Level: (%u) %s",
2510         a_bigbuf,
2511         (oct & 0x3c) >> 2,
2512         str);
2513
2514     if (add_string)
2515         g_snprintf(add_string, string_len, " - (%u)", (oct & 0x3c) >> 2);
2516
2517     other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
2518     proto_tree_add_text(tree,
2519         tvb, curr_offset, 1,
2520         "%s :  Queuing Allowed Indicator (QA): queuing %sallowed",
2521         a_bigbuf,
2522         (oct & 0x02) ? "" : "not ");
2523
2524     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2525     proto_tree_add_text(tree,
2526         tvb, curr_offset, 1,
2527         "%s :  Preemption Vulnerability Indicator (PVI): this connection %s be preempted by another allocation request",
2528         a_bigbuf,
2529         (oct & 0x01) ? "might" : "shall not");
2530
2531     curr_offset++;
2532
2533     /* no length check possible */
2534
2535     return(curr_offset - offset);
2536 }
2537
2538 /*
2539  * [2] 3.2.2.24
2540  */
2541 static guint8
2542 be_l3_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2543 {
2544     guint32     curr_offset;
2545     tvbuff_t    *l3_tvb;
2546
2547     curr_offset = offset;
2548
2549     proto_tree_add_text(tree, tvb, curr_offset, len,
2550         "Layer 3 Information value");
2551
2552     /*
2553      * dissect the embedded DTAP message
2554      */
2555     l3_tvb = tvb_new_subset(tvb, curr_offset, len, len);
2556
2557     call_dissector(dtap_handle, l3_tvb, g_pinfo, g_tree);
2558
2559     curr_offset += len;
2560
2561     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
2562
2563     return(curr_offset - offset);
2564 }
2565
2566 /*
2567  * [2] 3.2.2.25
2568  */
2569 static guint8
2570 be_dlci(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2571 {
2572     guint8      oct;
2573     guint32     curr_offset;
2574     proto_item  *item = NULL;
2575     proto_tree  *subtree = NULL;
2576
2577     len = len;
2578     curr_offset = offset;
2579
2580     item =
2581         proto_tree_add_text(tree, tvb, curr_offset, 1,
2582             "Data Link Connection Identifier");
2583
2584     subtree = proto_item_add_subtree(item, ett_dlci);
2585
2586     oct = tvb_get_guint8(tvb, curr_offset);
2587
2588     proto_tree_add_uint(subtree, hf_gsm_a_dlci_cc, tvb, curr_offset, 1, oct);
2589     proto_tree_add_uint(subtree, hf_gsm_a_dlci_spare, tvb, curr_offset, 1, oct);
2590     proto_tree_add_uint(subtree, hf_gsm_a_dlci_sapi, tvb, curr_offset, 1, oct);
2591
2592     curr_offset++;
2593
2594     /* no length check possible */
2595
2596     return(curr_offset - offset);
2597 }
2598
2599 /*
2600  * [2] 3.2.2.26
2601  */
2602 static guint8
2603 be_down_dtx_flag(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2604 {
2605     guint       oct;
2606     guint32     curr_offset;
2607
2608     len = len;
2609     curr_offset = offset;
2610
2611     oct = tvb_get_guint8(tvb, curr_offset);
2612
2613     other_decode_bitfield_value(a_bigbuf, oct, 0xfe, 8);
2614     proto_tree_add_text(tree,
2615         tvb, curr_offset, 1,
2616         "%s :  Spare",
2617         a_bigbuf);
2618
2619     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2620     proto_tree_add_text(tree,
2621         tvb, curr_offset, 1,
2622         "%s :  BSS is %s to activate DTX in the downlink direction",
2623         a_bigbuf,
2624         (oct & 0x01) ? "forbidden" : "allowed");
2625
2626     curr_offset++;
2627
2628     /* no length check possible */
2629
2630     return(curr_offset - offset);
2631 }
2632
2633 /*
2634  * [2] 3.2.2.27
2635  */
2636 guint8
2637 be_cell_id_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2638 {
2639     guint8      oct;
2640     guint8      consumed;
2641     guint8      disc;
2642     guint8      num_cells;
2643     guint32     curr_offset;
2644     proto_item  *item = NULL;
2645     proto_tree  *subtree = NULL;
2646
2647     curr_offset = offset;
2648
2649     oct = tvb_get_guint8(tvb, curr_offset);
2650
2651     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2652     proto_tree_add_text(tree,
2653         tvb, curr_offset, 1,
2654         "%s :  Spare",
2655         a_bigbuf);
2656
2657         disc = oct & 0x0f;
2658         proto_tree_add_item(tree, hf_gsm_a_be_cell_id_disc, tvb, curr_offset, 1, FALSE);
2659     curr_offset++;
2660
2661     NO_MORE_DATA_CHECK(len);
2662
2663     num_cells = 0;
2664     do
2665     {
2666         item =
2667             proto_tree_add_text(tree,
2668                 tvb, curr_offset, -1,
2669                 "Cell %u",
2670                 num_cells + 1);
2671
2672         subtree = proto_item_add_subtree(item, ett_cell_list);
2673
2674         if (add_string)
2675             add_string[0] = '\0';
2676         consumed =
2677             be_cell_id_aux(tvb, subtree, curr_offset, len - (curr_offset - offset), add_string, string_len, disc);
2678
2679         if (add_string && add_string[0] != '\0')
2680         {
2681             proto_item_append_text(item, "%s", add_string ? add_string : "");
2682         }
2683
2684         proto_item_set_len(item, consumed);
2685
2686         curr_offset += consumed;
2687
2688         num_cells++;
2689     }
2690     while ((len - (curr_offset - offset)) > 0 && consumed > 0);
2691
2692     if (add_string) {
2693         g_snprintf(add_string, string_len, " - %u cell%s",
2694             num_cells, plurality(num_cells, "", "s"));
2695     }
2696
2697     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
2698
2699     return(curr_offset - offset);
2700 }
2701
2702 /*
2703  * [2] 3.2.2.33
2704  */
2705 static guint8
2706 be_chosen_chan(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2707 {
2708     guint8      oct;
2709     guint32     curr_offset;
2710     const gchar *str = NULL;
2711
2712     len = len;
2713     curr_offset = offset;
2714
2715     oct = tvb_get_guint8(tvb, curr_offset);
2716
2717     switch ((oct & 0xf0) >> 4)
2718     {
2719     case 0: str = "No channel mode indication"; break;
2720     case 9: str = "Speech (full rate or half rate)"; break;
2721     case 14: str = "Data, 14.5 kbit/s radio interface rate"; break;
2722     case 11: str = "Data, 12.0 kbit/s radio interface rate"; break;
2723     case 12: str = "Data, 6.0 kbit/s radio interface rate"; break;
2724     case 13: str = "Data, 3.6 kbit/s radio interface rate"; break;
2725     case 8: str = "Signalling only"; break;
2726     default:
2727         str = "Reserved";
2728         break;
2729     }
2730
2731     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2732     proto_tree_add_text(tree,
2733         tvb, curr_offset, 1,
2734         "%s :  Channel mode: %s",
2735         a_bigbuf,
2736         str);
2737
2738     switch (oct & 0x0f)
2739     {
2740     case 0: str = "None"; break;
2741     case 1: str = "SDCCH"; break;
2742     case 8: str = "1 Full rate TCH"; break;
2743     case 9: str = "1 Half rate TCH"; break;
2744     case 10: str = "2 Full Rate TCHs"; break;
2745     case 11: str = "3 Full Rate TCHs"; break;
2746     case 12: str = "4 Full Rate TCHs"; break;
2747     case 13: str = "5 Full Rate TCHs"; break;
2748     case 14: str = "6 Full Rate TCHs"; break;
2749     case 15: str = "7 Full Rate TCHs"; break;
2750     case 4: str = "8 Full Rate TCHs"; break;
2751     default:
2752         str = "Reserved";
2753         break;
2754     }
2755
2756     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
2757     proto_tree_add_text(tree,
2758         tvb, curr_offset, 1,
2759         "%s :  Channel: %s",
2760         a_bigbuf,
2761         str);
2762
2763     curr_offset++;
2764
2765     /* no length check possible */
2766
2767     return(curr_offset - offset);
2768 }
2769
2770 /*
2771  * [2] 3.2.2.34
2772  */
2773 static guint8
2774 be_ciph_resp_mode(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2775 {
2776     guint8      oct;
2777     guint32     curr_offset;
2778
2779     len = len;
2780     curr_offset = offset;
2781
2782     oct = tvb_get_guint8(tvb, curr_offset);
2783
2784     other_decode_bitfield_value(a_bigbuf, oct, 0xfe, 8);
2785     proto_tree_add_text(tree,
2786         tvb, curr_offset, 1,
2787         "%s :  Spare",
2788         a_bigbuf);
2789
2790     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2791     proto_tree_add_text(tree,
2792         tvb, curr_offset, 1,
2793         "%s :  IMEISV must %sbe included by the mobile station",
2794         a_bigbuf,
2795         (oct & 0x01) ? "" : "not ");
2796
2797     curr_offset++;
2798
2799     /* no length check possible */
2800
2801     return(curr_offset - offset);
2802 }
2803
2804
2805 /*
2806  * [2] 3.2.2.35
2807  */
2808 static guint8
2809 be_l3_msg(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2810 {
2811     guint32     curr_offset;
2812     tvbuff_t    *l3_tvb;
2813
2814     curr_offset = offset;
2815
2816     proto_tree_add_text(tree, tvb, curr_offset, len,
2817         "Layer 3 Message Contents");
2818
2819     /*
2820      * dissect the embedded DTAP message
2821      */
2822     l3_tvb = tvb_new_subset(tvb, curr_offset, len, len);
2823
2824     call_dissector(dtap_handle, l3_tvb, g_pinfo, g_tree);
2825
2826     curr_offset += len;
2827
2828     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
2829
2830     return(curr_offset - offset);
2831 }
2832
2833 /*
2834  * [2] 3.2.2.36 Channel Needed
2835  */static guint8 
2836 be_cha_needed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2837 {
2838     guint32     curr_offset;
2839     
2840     len = len;
2841     curr_offset = offset;
2842     
2843     /* no length check possible */
2844         proto_tree_add_item(tree, hf_gsm_a_rr_chnl_needed_ch1, tvb, curr_offset, 1, FALSE);
2845         curr_offset++;  
2846     return(curr_offset - offset);
2847 }
2848
2849
2850 /*
2851  * [2] 3.2.2.43
2852  */
2853 static guint8
2854 be_for_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2855 {
2856     guint8      oct;
2857     guint32     curr_offset;
2858     const gchar *str = NULL;
2859
2860     len = len;
2861     curr_offset = offset;
2862
2863     oct = tvb_get_guint8(tvb, curr_offset);
2864
2865     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2866     proto_tree_add_text(tree,
2867         tvb, curr_offset, 1,
2868         "%s :  Spare",
2869         a_bigbuf);
2870
2871     switch (oct & 0x0f)
2872     {
2873     case 1: str = "forward to subsequent BSS, no trace at MSC"; break;
2874     case 2: str = "forward to subsequent BSS, and trace at MSC"; break;
2875     default:
2876         str = "Reserved";
2877         break;
2878     }
2879
2880     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
2881     proto_tree_add_text(tree,
2882         tvb, curr_offset, 1,
2883         "%s :  %s",
2884         a_bigbuf,
2885         str);
2886
2887     curr_offset++;
2888
2889     /* no length check possible */
2890
2891     return(curr_offset - offset);
2892 }
2893
2894 /*
2895  * [2] 3.2.2.44
2896  */
2897 static guint8
2898 be_chosen_enc_alg(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2899 {
2900     guint8      oct;
2901     guint32     curr_offset;
2902     const gchar *str = NULL;
2903
2904     len = len;
2905     curr_offset = offset;
2906
2907     oct = tvb_get_guint8(tvb, curr_offset);
2908
2909     switch (oct)
2910     {
2911     case 0x01: str = "No encryption used"; break;
2912     case 0x02: str = "GSM A5/1"; break;
2913     case 0x03: str = "GSM A5/2"; break;
2914     case 0x04: str = "GSM A5/3"; break;
2915     case 0x05: str = "GSM A5/4"; break;
2916     case 0x06: str = "GSM A5/5"; break;
2917     case 0x07: str = "GSM A5/6"; break;
2918     case 0x08: str = "GSM A5/7"; break;
2919     default:
2920         str = "Reserved";
2921         break;
2922     }
2923
2924     proto_tree_add_text(tree,
2925         tvb, curr_offset, 1,
2926         "Algorithm Identifier: %s",
2927         str);
2928
2929     curr_offset++;
2930
2931     if (add_string)
2932         g_snprintf(add_string, string_len, " - %s", str);
2933
2934     /* no length check possible */
2935
2936     return(curr_offset - offset);
2937 }
2938
2939 /*
2940  * [2] 3.2.2.45
2941  */
2942 static guint8
2943 be_cct_pool(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2944 {
2945     guint8      oct;
2946     guint32     curr_offset;
2947     const gchar *str = NULL;
2948
2949     len = len;
2950     curr_offset = offset;
2951
2952     oct = tvb_get_guint8(tvb, curr_offset);
2953
2954     if (oct <= 32)
2955     {
2956         str = "";
2957     }
2958     else if ((oct >= 0x80) && (oct <= 0x8f))
2959     {
2960         str = ", for national/local use";
2961     }
2962     else
2963     {
2964         str = ", reserved for future international use";
2965     }
2966
2967     proto_tree_add_text(tree,
2968         tvb, curr_offset, 1,
2969         "Circuit pool number: %u%s",
2970         oct,
2971         str);
2972
2973     curr_offset++;
2974
2975     if (add_string)
2976         g_snprintf(add_string, string_len, " - (%u)", oct);
2977
2978     /* no length check possible */
2979
2980     return(curr_offset - offset);
2981 }
2982
2983 /*
2984  * [2] 3.2.2.49
2985  */
2986 static guint8
2987 be_curr_chan_1(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2988 {
2989     guint8      oct;
2990     guint32     curr_offset;
2991     const gchar *str;
2992
2993     len = len;
2994     curr_offset = offset;
2995
2996     oct = tvb_get_guint8(tvb, curr_offset);
2997
2998     switch ((oct & 0xf0) >> 4)
2999     {
3000     case 0x00: str = "Signalling only"; break;
3001     case 0x01: str = "Speech (full rate or half rate)"; break;
3002     case 0x06: str = "Data, 14.5 kbit/s radio interface rate"; break;
3003     case 0x03: str = "Data, 12.0 kbit/s radio interface rate"; break;
3004     case 0x04: str = "Data, 6.0 kbit/s radio interface rate"; break;
3005     case 0x05: str = "Data, 3.6 kbit/s radio interface rate"; break;
3006     default:
3007         str = "Reserved";
3008         break;
3009     }
3010
3011     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3012     proto_tree_add_text(tree,
3013         tvb, curr_offset, 1,
3014         "%s :  Channel Mode: %s",
3015         a_bigbuf,
3016         str);
3017
3018     switch (oct & 0x0f)
3019     {
3020     case 0x01: str = "SDCCH"; break;
3021     case 0x08: str = "1 Full rate TCH"; break;
3022     case 0x09: str = "1 Half rate TCH"; break;
3023     case 0x0a: str = "2 Full Rate TCHs"; break;
3024     case 0x0b: str = "3 Full Rate TCHs"; break;
3025     case 0x0c: str = "4 Full Rate TCHs"; break;
3026     case 0x0d: str = "5 Full Rate TCHs"; break;
3027     case 0x0e: str = "6 Full Rate TCHs"; break;
3028     case 0x0f: str = "7 Full Rate TCHs"; break;
3029     case 0x04: str = "8 Full Rate TCHs"; break;
3030     default:
3031         str = "Reserved";
3032         break;
3033     }
3034
3035     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
3036     proto_tree_add_text(tree,
3037         tvb, curr_offset, 1,
3038         "%s :  Channel: (%u) %s",
3039         a_bigbuf,
3040         oct & 0x0f,
3041         str);
3042
3043     curr_offset++;
3044
3045     /* no length check possible */
3046
3047     return(curr_offset - offset);
3048 }
3049
3050 /*
3051  * [2] 3.2.2.50
3052  */
3053 static guint8
3054 be_que_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3055 {
3056     guint8      oct;
3057     guint32     curr_offset;
3058
3059     len = len;
3060     curr_offset = offset;
3061
3062     oct = tvb_get_guint8(tvb, curr_offset);
3063
3064     other_decode_bitfield_value(a_bigbuf, oct, 0xfc, 8);
3065     proto_tree_add_text(tree,
3066         tvb, curr_offset, 1,
3067         "%s :  Spare",
3068         a_bigbuf);
3069
3070     other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
3071     proto_tree_add_text(tree,
3072         tvb, curr_offset, 1,
3073         "%s :  qri: it is recommended %sto allow queuing",
3074         a_bigbuf,
3075         (oct & 0x02) ? "" : "not ");
3076
3077     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
3078     proto_tree_add_text(tree,
3079         tvb, curr_offset, 1,
3080         "%s :  Spare",
3081         a_bigbuf);
3082
3083     curr_offset++;
3084
3085     /* no length check possible */
3086
3087     return(curr_offset - offset);
3088 }
3089
3090 /*
3091  * [2] 3.2.2.51
3092  */
3093 static guint8
3094 be_speech_ver(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
3095 {
3096     guint8      oct;
3097     guint32     curr_offset;
3098     const gchar *str = NULL;
3099     const gchar *short_str = NULL;
3100
3101     len = len;
3102     curr_offset = offset;
3103
3104     oct = tvb_get_guint8(tvb, curr_offset);
3105
3106     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3107
3108     switch (oct & 0x7f)
3109     {
3110     case 0x01: str = "GSM speech full rate version 1"; short_str = "FR1"; break;
3111     case 0x11: str = "GSM speech full rate version 2"; short_str = "FR2"; break;
3112     case 0x21: str = "GSM speech full rate version 3 (AMR)"; short_str = "FR3 (AMR)"; break;
3113
3114     case 0x05: str = "GSM speech half rate version 1"; short_str = "HR1"; break;
3115     case 0x15: str = "GSM speech half rate version 2"; short_str = "HR2"; break;
3116     case 0x25: str = "GSM speech half rate version 3 (AMR)"; short_str = "HR3 (AMR)"; break;
3117
3118     default:
3119         str = "Reserved";
3120         short_str = str;
3121         break;
3122     }
3123
3124     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
3125     proto_tree_add_text(tree,
3126         tvb, curr_offset, 1,
3127         "%s :  Speech version identifier: %s",
3128         a_bigbuf,
3129         str);
3130
3131     curr_offset++;
3132
3133     if (add_string)
3134         g_snprintf(add_string, string_len, " - (%s)", short_str);
3135
3136     /* no length check possible */
3137
3138     return(curr_offset - offset);
3139 }
3140
3141 /*
3142  * 3.2.2.68 3GPP TS 48.008 version 6.9.0 Release 6
3143  */
3144
3145 /* BSSLAP the embedded message is as defined in 3GPP TS 48.071
3146  * LLP the embedded message contains a Facility Information Element as defined in 3GPP TS 44.071
3147  *              excluding the Facility IEI and length of Facility IEI octets defined in 3GPP TS 44.071.
3148  * SMLCPP the embedded message is as defined in 3GPP TS 48.031
3149  */
3150 static const value_string gsm_a_apdu_protocol_id_strings[] = {
3151     { 0,        "reserved" },
3152     { 1,        "BSSLAP" },
3153     { 2,        "LLP" },
3154     { 3,        "SMLCPP" },
3155     { 0, NULL },
3156 };
3157
3158 static guint8
3159 be_apdu(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3160 {
3161     guint32     curr_offset;
3162
3163     curr_offset = offset;
3164
3165     proto_tree_add_text(tree, tvb, curr_offset, len,
3166         "APDU (not displayed)");
3167
3168     /*
3169      * dissect the embedded APDU message
3170      * if someone writes a TS 09.31 dissector
3171          *
3172          * The APDU octets 4 to n are coded in the same way as the 
3173          * equivalent octet in the APDU element of 3GPP TS 49.031.
3174      */
3175
3176         proto_tree_add_item(tree, hf_gsm_a_apdu_protocol_id, tvb, curr_offset, 1, FALSE);
3177
3178     curr_offset += len;
3179
3180     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
3181
3182     return(curr_offset - offset);
3183 }
3184
3185 typedef enum
3186 {
3187     /* Common Information Elements 10.5.1 */
3188         /* Pos 0 */
3189     DE_CELL_ID,                         /* Cell Identity */
3190     DE_CIPH_KEY_SEQ_NUM,        /* Ciphering Key Sequence Number */
3191     DE_LAI,                                     /* Location Area Identification */
3192     DE_MID,                                     /* Mobile Identity */
3193     DE_MS_CM_1,                         /* Mobile Station Classmark 1 */
3194     DE_MS_CM_2,                         /* Mobile Station Classmark 2 */
3195     DE_MS_CM_3,                         /* Mobile Station Classmark 3 */
3196     DE_D_GB_CALL_REF,           /* Descriptive group or broadcast call reference */
3197     DE_G_CIPH_KEY_NUM,          /* Group Cipher Key Number */
3198     DE_PD_SAPI,                         /* PD and SAPI $(CCBS)$ */
3199         /* Pos 10 */
3200     DE_PRIO,                            /* Priority Level */
3201     DE_PLMN_LIST,                       /* PLMN List */
3202
3203     /* Radio Resource Management Information Elements 10.5.2, most are from 10.5.1      */
3204 /*
3205  * [3]  10.5.2.1a       BA Range
3206  */
3207         DE_RR_CELL_CH_DSC,                              /* [3]  10.5.2.1b       Cell Channel Description        */
3208
3209 /* [3]  10.5.2.1c       BA List Pref
3210  * [3]  10.5.2.1d       UTRAN Frequency List
3211  * [3]  10.5.2.1e       Cell selection indicator after release of all TCH and SDCCH IE
3212  */
3213         DE_RR_CELL_DSC,                                 /* 10.5.2.2   RR Cell Description                               */
3214 /*
3215  * [3]  10.5.2.3        Cell Options (BCCH)     
3216  * [3]  10.5.2.3a       Cell Options (SACCH)
3217  * [3]  10.5.2.4        Cell Selection Parameters
3218  * [3]  10.5.2.4a       (void)
3219  */
3220         DE_RR_CH_DSC,                                   /* [3]  10.5.2.5        Channel Description                     */
3221         DE_RR_CH_DSC2,                                  /* [3]  10.5.2.5a   Channel Description 2               */
3222         DE_RR_CH_MODE,                                  /* [3]  10.5.2.6        Channel Mode                            */
3223         DE_RR_CH_MODE2,                                 /* [3]  10.5.2.7        Channel Mode 2                          */
3224 /* [3]  10.5.2.7a       UTRAN predefined configuration status information / START-CS / UE CapabilityUTRAN Classmark information element 218
3225  * [3]  10.5.2.7b       (void) */
3226         DE_RR_CM_ENQ_MASK,                              /* [3]  10.5.2.7c       Classmark Enquiry Mask          */
3227 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element                                             */
3228         DE_RR_CHNL_NEEDED,                              /* [3]  10.5.2.8        Channel Needed
3229  * [3]  10.5.2.8a       (void)  
3230  * [3]  10.5.2.8b       Channel Request Description 2 */
3231         /* Pos 20 */
3232         DE_RR_CIP_MODE_SET,                             /* [3]  10.5.2.9        Cipher Mode Setting                     */
3233 /* [3]  10.5.2.10       Cipher Response
3234  * [3]  10.5.2.11       Control Channel Description
3235  * [3]  10.5.2.11a      DTM Information Details */
3236         DE_RR_DYN_ARFCN_MAP,                    /* [3]  10.5.2.11b      Dynamic ARFCN Mapping           */
3237         DE_RR_FREQ_CH_SEQ,                              /* [3]  10.5.2.12       Frequency Channel Sequence      */
3238         DE_RR_FREQ_LIST,                                /* [3]  10.5.2.13       Frequency List                          */
3239         DE_RR_FREQ_SHORT_LIST,                  /* [3]  10.5.2.14       Frequency Short List            */
3240         DE_RR_FREQ_SHORT_LIST2,                 /* [3]  10.5.2.14a      Frequency Short List 2          */
3241 /* [3]  10.5.2.14b      Group Channel Description
3242  * [3]  10.5.2.14c      GPRS Resumption
3243  * [3]  10.5.2.14d      GPRS broadcast information
3244  * [3]  10.5.2.14e      Enhanced DTM CS Release Indication
3245  */
3246
3247         DE_RR_HO_REF,                                   /* 10.5.2.15  Handover Reference                                */
3248 /*
3249  * [3] 10.5.2.16 IA Rest Octets
3250  * [3] 10.5.2.17 IAR Rest Octets
3251  * [3] 10.5.2.18 IAX Rest Octets
3252  * [3] 10.5.2.19 L2 Pseudo Length
3253  * [3] 10.5.2.20 Measurement Results
3254  * [3] 10.5.2.20a GPRS Measurement Results
3255  */
3256         DE_RR_MOB_ALL,                                  /* [3] 10.5.2.21 Mobile Allocation                              */
3257         DE_RR_MOB_TIME_DIFF,                    /* [3] 10.5.2.21a Mobile Time Difference                */
3258         DE_RR_MULTIRATE_CONF,                   /* [3] 10.5.2.21aa MultiRate configuration              */
3259         /* Pos 30 */
3260         DE_RR_MULT_ALL,                                 /* [3] 10.5.2.21b Multislot Allocation                  */
3261
3262 /*
3263  * [3] 10.5.2.21c NC mode
3264  * [3] 10.5.2.22 Neighbour Cell Description
3265  * [3] 10.5.2.22a Neighbour Cell Description 2
3266  * [3] 10.5.2.22b (void)
3267  * [3] 10.5.2.22c NT/N Rest Octets
3268  * [3] 10.5.2.23 P1 Rest Octets
3269  * [3] 10.5.2.24 P2 Rest Octets
3270  * [3] 10.5.2.25 P3 Rest Octets
3271  * [3] 10.5.2.25a Packet Channel Description
3272  * [3] 10.5.2.25b Dedicated mode or TBF
3273  * [3] 10.5.2.25c RR Packet Uplink Assignment
3274  * [3] 10.5.2.25d RR Packet Downlink Assignment
3275  * [3] 10.5.2.26 Page Mode
3276  * [3] 10.5.2.26a (void)
3277  * [3] 10.5.2.26b (void)
3278  * [3] 10.5.2.26c (void)
3279  * [3] 10.5.2.26d (void)
3280  * [3] 10.5.2.27 NCC Permitted
3281  */
3282         DE_RR_POW_CMD,                                  /* 10.5.2.28  Power Command                                             */
3283         DE_RR_POW_CMD_AND_ACC_TYPE,             /* 10.5.2.28a Power Command and access type             */
3284 /*
3285  * [3] 10.5.2.29 RACH Control Parameters
3286  * [3] 10.5.2.30 Request Reference
3287  */
3288     DE_RR_CAUSE,                                        /* 10.5.2.31  RR Cause                                                  */
3289         DE_RR_SYNC_IND,                                 /* 10.5.2.39  Synchronization Indication                */
3290 /* [3] 10.5.2.32 SI 1 Rest Octets
3291  * [3] 10.5.2.33 SI 2bis Rest Octets 
3292  * [3] 10.5.2.33a SI 2ter Rest Octets
3293  * [3] 10.5.2.33b SI 2quater Rest Octets
3294  * [3] 10.5.2.34 SI 3 Rest Octets
3295  * [3] 10.5.2.35 SI 4 Rest Octets
3296  * [3] 10.5.2.35a SI 6 Rest Octets
3297  * [3] 10.5.2.36 SI 7 Rest Octets
3298  * [3] 10.5.2.37 SI 8 Rest Octets
3299  * [3] 10.5.2.37a SI 9 Rest Octets
3300  * [3] 10.5.2.37b SI 13 Rest Octets
3301  * [3] 10.5.2.37c (void)
3302  * [3] 10.5.2.37d (void)
3303  * [3] 10.5.2.37e SI 16 Rest Octets
3304  * [3] 10.5.2.37f SI 17 Rest Octets
3305  * [3] 10.5.2.37g SI 19 Rest Octets
3306  * [3] 10.5.2.37h SI 18 Rest Octets
3307  * [3] 10.5.2.37i SI 20 Rest Octets */
3308         DE_RR_STARTING_TIME,                    /* [3] 10.5.2.38 Starting Time                                  */
3309         DE_RR_TIMING_ADV,                               /* [3] 10.5.2.40 Timing Advance                                 */
3310         DE_RR_TIME_DIFF,                                /* [3] 10.5.2.41 Time Difference                                */
3311         DE_RR_TLLI,                                             /* [3] 10.5.2.41a TLLI                                                  */
3312 /*
3313  * [3] 10.5.2.42 TMSI/P-TMSI */
3314         DE_RR_VGCS_TAR_MODE_IND,                /* [3] 10.5.2.42a VGCS target mode Indication   */
3315         /* Pos 40 */
3316         DE_RR_VGCS_CIP_PAR,                             /* [3] 10.5.2.42b       VGCS Ciphering Parameters       */
3317
3318 /* [3] 10.5.2.43 Wait Indication
3319  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
3320  * [3] 10.5.2.45 EXTENDED MEASUREMENT RESULTS
3321  * [3] 10.5.2.46 Extended Measurement Frequency List */
3322         DE_RR_SUS_CAU,                                  /* [3] 10.5.2.47 Suspension Cause                               */
3323 /* [3] 10.5.2.48 APDU ID 
3324  * [3] 10.5.2.49 APDU Flags
3325  * [3] 10.5.2.50 APDU Data
3326  * [3] 10.5.2.51 Handover To UTRAN Command
3327  * [3] 10.5.2.52 Handover To cdma2000 Command 
3328  * [3] 10.5.2.53 (void)
3329  * [3] 10.5.2.54 (void)
3330  * [3] 10.5.2.55 (void)
3331  * [3] 10.5.2.56 3G Target Cell */
3332         DE_RR_DED_SERV_INF,                             /* [3] 10.5.2.59        Dedicated Service Information */
3333
3334
3335     /* Mobility Management Information Elements 10.5.3 */
3336     DE_AUTH_PARAM_RAND,                         /* Authentication Parameter RAND */
3337     DE_AUTH_PARAM_AUTN,                         /* Authentication Parameter AUTN (UMTS authentication challenge only) */
3338     DE_AUTH_RESP_PARAM,                         /* Authentication Response Parameter */
3339     DE_AUTH_RESP_PARAM_EXT,                     /* Authentication Response Parameter (extension) (UMTS authentication challenge only) */
3340     DE_AUTH_FAIL_PARAM,                         /* Authentication Failure Parameter (UMTS authentication challenge only) */
3341     DE_CM_SRVC_TYPE,                            /* CM Service Type */
3342     DE_ID_TYPE,                                         /* Identity Type */
3343         /* Pos 50 */
3344     DE_LOC_UPD_TYPE,                            /* Location Updating Type */
3345     DE_NETWORK_NAME,                            /* Network Name */
3346     DE_REJ_CAUSE,                                       /* Reject Cause */
3347     DE_FOP,                                                     /* Follow-on Proceed */
3348     DE_TIME_ZONE,                                       /* Time Zone */
3349     DE_TIME_ZONE_TIME,                          /* Time Zone and Time */
3350     DE_CTS_PERM,                                        /* CTS Permission */
3351     DE_LSA_ID,                                          /* LSA Identifier */
3352     DE_DAY_SAVING_TIME,                         /* Daylight Saving Time */
3353     DE_EMERGENCY_NUM_LIST,                      /* Emergency Number List */
3354     /* Call Control Information Elements 10.5.4 */
3355         /* Pos 60 */
3356     DE_AUX_STATES,                                      /* Auxiliary States */
3357     DE_BEARER_CAP,                                      /* Bearer Capability */
3358     DE_CC_CAP,                                          /* Call Control Capabilities */
3359     DE_CALL_STATE,                                      /* Call State */
3360     DE_CLD_PARTY_BCD_NUM,                       /* Called Party BCD Number */
3361     DE_CLD_PARTY_SUB_ADDR,                      /* Called Party Subaddress */
3362     DE_CLG_PARTY_BCD_NUM,                       /* Calling Party BCD Number */
3363     DE_CLG_PARTY_SUB_ADDR,                      /* Calling Party Subaddress */
3364     DE_CAUSE,                                           /* Cause */
3365     DE_CLIR_SUP,                                        /* CLIR Suppression */
3366     DE_CLIR_INV,                                        /* CLIR Invocation */
3367     DE_CONGESTION,                                      /* Congestion Level */
3368     DE_CONN_NUM,                                        /* Connected Number */
3369     DE_CONN_SUB_ADDR,                           /* Connected Subaddress */
3370     DE_FACILITY,                                        /* Facility */
3371     DE_HLC,                                                     /* High Layer Compatibility */
3372     DE_KEYPAD_FACILITY,                         /* Keypad Facility */
3373     DE_LLC,                                                     /* Low Layer Compatibility */
3374     DE_MORE_DATA,                                       /* More Data */
3375     DE_NOT_IND,                                         /* Notification Indicator */
3376     DE_PROG_IND,                                        /* Progress Indicator */
3377     DE_RECALL_TYPE,                                     /* Recall type $(CCBS)$ */
3378     DE_RED_PARTY_BCD_NUM,                       /* Redirecting Party BCD Number */
3379     DE_RED_PARTY_SUB_ADDR,                      /* Redirecting Party Subaddress */
3380     DE_REPEAT_IND,                                      /* Repeat Indicator */
3381     DE_REV_CALL_SETUP_DIR,                      /* Reverse Call Setup Direction */
3382     DE_SETUP_CONTAINER,                         /* SETUP Container $(CCBS)$ */
3383     DE_SIGNAL,                                          /* Signal */
3384     DE_SS_VER_IND,                                      /* SS Version Indicator */
3385     DE_USER_USER,                                       /* User-user */
3386     DE_ALERT_PATTERN,                           /* Alerting Pattern $(NIA)$ */
3387     DE_ALLOWED_ACTIONS,                         /* Allowed Actions $(CCBS)$ */
3388     DE_SI,                                                      /* Stream Identifier */
3389     DE_NET_CC_CAP,                                      /* Network Call Control Capabilities */
3390     DE_CAUSE_NO_CLI,                            /* Cause of No CLI */
3391     DE_IMM_MOD_IND,                                     /* Immediate Modification Indicator */
3392     DE_SUP_CODEC_LIST,                          /* Supported Codec List */
3393     DE_SRVC_CAT,                                        /* Service Category */
3394     /* GPRS Mobility Management Information Elements 10.5.5 */
3395     DE_ATTACH_RES,                                      /* [7] 10.5.1 Attach Result*/
3396     DE_ATTACH_TYPE,                                     /* [7] 10.5.2 Attach Type */
3397     DE_CIPH_ALG,                                        /* [7] 10.5.3 Cipher Algorithm */
3398     DE_TMSI_STAT,                                       /* [7] 10.5.4 TMSI Status */
3399     DE_DETACH_TYPE,                                     /* [7] 10.5.5 Detach Type */
3400     DE_DRX_PARAM,                                       /* [7] 10.5.6 DRX Parameter */
3401     DE_FORCE_TO_STAND,                          /* [7] 10.5.7 Force to Standby */
3402     DE_FORCE_TO_STAND_H,                        /* [7] 10.5.8 Force to Standby - Info is in the high nibble */
3403     DE_P_TMSI_SIG,                                      /* [7] 10.5.9 P-TMSI Signature */
3404     DE_P_TMSI_SIG_2,                            /* [7] 10.5.10 P-TMSI Signature 2 */
3405     DE_ID_TYPE_2,                                       /* [7] 10.5.11 Identity Type 2 */
3406     DE_IMEISV_REQ,                                      /* [7] 10.5.12 IMEISV Request */
3407     DE_REC_N_PDU_NUM_LIST,                      /* [7] 10.5.13 Receive N-PDU Numbers List */
3408     DE_MS_NET_CAP,                                      /* [7] 10.5.14 MS Network Capability */
3409     DE_MS_RAD_ACC_CAP,                          /* [7] 10.5.15 MS Radio Access Capability */
3410     DE_GMM_CAUSE,                                       /* [7] 10.5.16 GMM Cause */
3411     DE_RAI,                                                     /* [7] 10.5.17 Routing Area Identification */
3412     DE_UPD_RES,                                         /* [7] 10.5.18 Update Result */
3413     DE_UPD_TYPE,                                        /* [7] 10.5.19 Update Type */
3414     DE_AC_REF_NUM,                                      /* [7] 10.5.20 A&C Reference Number */
3415     DE_AC_REF_NUM_H,                            /* A&C Reference Number - Info is in the high nibble */
3416     DE_SRVC_TYPE,                                       /* [7] 10.5.20 Service Type */
3417     DE_CELL_NOT,                                        /* [7] 10.5.21 Cell Notification */
3418     DE_PS_LCS_CAP,                                      /* [7] 10.5.22 PS LCS Capability */
3419     DE_NET_FEAT_SUP,                            /* [7] 10.5.23 Network Feature Support */
3420         DE_RAT_INFO_CONTAINER,                  /* [7] 10.5.24 Inter RAT information container */
3421         /* [7] 10.5.25 Requested MS information */
3422
3423     /* Short Message Service Information Elements [5] 8.1.4 */
3424     DE_CP_USER_DATA,                            /* CP-User Data */
3425     DE_CP_CAUSE,                                        /* CP-Cause */
3426     /* Short Message Service Information Elements [5] 8.2 */
3427     DE_RP_MESSAGE_REF,                          /* RP-Message Reference */
3428     DE_RP_ORIG_ADDR,                            /* RP-Origination Address */
3429     DE_RP_DEST_ADDR,                            /* RP-Destination Address */
3430     DE_RP_USER_DATA,                            /* RP-User Data */
3431     DE_RP_CAUSE,                                        /* RP-Cause */
3432     /* Session Management Information Elements 10.5.6 */
3433     DE_ACC_POINT_NAME,                          /* Access Point Name */
3434     DE_NET_SAPI,                                        /* Network Service Access Point Identifier */
3435     DE_PRO_CONF_OPT,                            /* Protocol Configuration Options */
3436     DE_PD_PRO_ADDR,                                     /* Packet Data Protocol Address */
3437     DE_QOS,                                                     /* Quality Of Service */
3438     DE_SM_CAUSE,                                        /* SM Cause */
3439     DE_LINKED_TI,                                       /* Linked TI */
3440     DE_LLC_SAPI,                                        /* LLC Service Access Point Identifier */
3441     DE_TEAR_DOWN_IND,                           /* Tear Down Indicator */
3442     DE_PACKET_FLOW_ID,                          /* Packet Flow Identifier */
3443     DE_TRAFFIC_FLOW_TEMPLATE,           /* Traffic Flow Template */
3444     /* GPRS Common Information Elements 10.5.7 */
3445     DE_PDP_CONTEXT_STAT,                        /* [8] 10.5.7.1         PDP Context Status */
3446     DE_RAD_PRIO,                                        /* [8] 10.5.7.2         Radio Priority */
3447     DE_GPRS_TIMER,                                      /* [8] 10.5.7.3         GPRS Timer */
3448     DE_GPRS_TIMER_2,                            /* [8] 10.5.7.4         GPRS Timer 2 */
3449     DE_RAD_PRIO_2,                                      /* [8] 10.5.7.5         Radio Priority 2 */
3450         DE_MBMS_CTX_STATUS,                             /* [8] 10.5.7.6         MBMS context status */
3451     DE_SPARE_NIBBLE,                            /* Spare Nibble */
3452     DE_NONE                                                     /* NONE */
3453 }
3454 dtap_elem_idx_t;
3455
3456 #define NUM_GSM_DTAP_ELEM (sizeof(gsm_dtap_elem_strings)/sizeof(value_string))
3457 static gint ett_gsm_dtap_elem[NUM_GSM_DTAP_ELEM];
3458
3459 /* 3GPP TS 24.008
3460  * [3] 10.5.1.1 Cell Identity
3461  */
3462 guint8
3463 de_cell_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
3464 {
3465     guint32     curr_offset;
3466
3467     curr_offset = offset;
3468
3469     curr_offset +=
3470         /* 0x02 CI */
3471         be_cell_id_aux(tvb, tree, offset, len, add_string, string_len, 0x02);
3472
3473     /* no length check possible */
3474
3475     return(curr_offset - offset);
3476 }
3477
3478 /*
3479  * [3] 10.5.1.3
3480  */
3481 guint8
3482 de_lai(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3483 {
3484     guint8      octs[3];
3485     guint16     value;
3486     guint32     curr_offset;
3487     proto_tree  *subtree;
3488     proto_item  *item;
3489     gchar       mcc[4];
3490     gchar       mnc[4];
3491
3492     len = len;
3493     curr_offset = offset;
3494
3495     item =
3496         proto_tree_add_text(tree,
3497             tvb, curr_offset, 5,
3498             gsm_dtap_elem_strings[DE_LAI].strptr);
3499
3500     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_LAI]);
3501
3502     octs[0] = tvb_get_guint8(tvb, curr_offset);
3503     octs[1] = tvb_get_guint8(tvb, curr_offset + 1);
3504     octs[2] = tvb_get_guint8(tvb, curr_offset + 2);
3505
3506     mcc_mnc_aux(octs, mcc, mnc);
3507
3508
3509     proto_tree_add_text(subtree,
3510         tvb, curr_offset, 3,
3511         "Mobile Country Code (MCC): %s, Mobile Network Code (MNC): %s",
3512         mcc,
3513         mnc);
3514
3515     curr_offset += 3;
3516
3517     value = tvb_get_ntohs(tvb, curr_offset);
3518
3519     proto_tree_add_text(subtree,
3520         tvb, curr_offset, 2,
3521         "Location Area Code (LAC): 0x%04x (%u)",
3522         value,
3523         value);
3524
3525     proto_item_append_text(item, " - LAC (0x%04x)", value);
3526
3527     curr_offset += 2;
3528
3529     /* no length check possible */
3530
3531     return(curr_offset - offset);
3532 }
3533
3534 /*
3535  * [3] 10.5.1.4
3536  */
3537 guint8
3538 de_mid(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
3539 {
3540     guint8      oct;
3541     guint32     curr_offset;
3542     guint8      *poctets;
3543     guint32     value;
3544     gboolean    odd;
3545
3546     curr_offset = offset;
3547     odd = FALSE;
3548
3549     oct = tvb_get_guint8(tvb, curr_offset);
3550
3551     switch (oct & 0x07)
3552     {
3553     case 0:     /* No Identity */
3554         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3555         proto_tree_add_text(tree,
3556             tvb, curr_offset, 1,
3557             "%s :  Unused",
3558             a_bigbuf);
3559
3560         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3561
3562         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3563
3564         if (add_string)
3565             g_snprintf(add_string, string_len, " - No Identity Code");
3566
3567         curr_offset++;
3568
3569         if (len > 1)
3570         {
3571             proto_tree_add_text(tree, tvb, curr_offset, len - 1,
3572                 "Format not supported");
3573         }
3574
3575         curr_offset += len - 1;
3576         break;
3577
3578     case 3:     /* IMEISV */
3579
3580         /* FALLTHRU */
3581
3582     case 1:     /* IMSI */
3583
3584         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3585         proto_tree_add_text(tree,
3586             tvb, curr_offset, 1,
3587             "%s :  Identity Digit 1: %c",
3588             a_bigbuf,
3589             Dgt1_9_bcd.out[(oct & 0xf0) >> 4]);
3590
3591         odd = oct & 0x08;
3592
3593         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3594
3595         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3596
3597
3598         a_bigbuf[0] = Dgt1_9_bcd.out[(oct & 0xf0) >> 4];
3599         curr_offset++;
3600
3601         poctets = tvb_get_ephemeral_string(tvb, curr_offset, len - (curr_offset - offset));
3602
3603         my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset),
3604             &Dgt1_9_bcd);
3605
3606         proto_tree_add_string_format(tree,
3607             ((oct & 0x07) == 3) ? hf_gsm_a_imeisv : hf_gsm_a_imsi,
3608             tvb, curr_offset, len - (curr_offset - offset),
3609             a_bigbuf,
3610             "BCD Digits: %s",
3611             a_bigbuf);
3612
3613         if (add_string)
3614             g_snprintf(add_string, string_len, " - %s (%s)",
3615                 ((oct & 0x07) == 3) ? "IMEISV" : "IMSI",
3616                 a_bigbuf);
3617
3618         curr_offset += len - (curr_offset - offset);
3619
3620         if (!odd)
3621         {
3622             oct = tvb_get_guint8(tvb, curr_offset - 1);
3623
3624             other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3625             proto_tree_add_text(tree,
3626                 tvb, curr_offset - 1, 1,
3627                 "%s :  Filler",
3628                 a_bigbuf);
3629         }
3630         break;
3631
3632     case 2:     /* IMEI */
3633         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3634         proto_tree_add_text(tree,
3635             tvb, curr_offset, 1,
3636             "%s :  Identity Digit 1: %c",
3637             a_bigbuf,
3638             Dgt1_9_bcd.out[(oct & 0xf0) >> 4]);
3639
3640         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3641
3642         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3643
3644
3645         a_bigbuf[0] = Dgt1_9_bcd.out[(oct & 0xf0) >> 4];
3646         curr_offset++;
3647
3648         poctets = tvb_get_ephemeral_string(tvb, curr_offset, len - (curr_offset - offset));
3649
3650         my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset),
3651             &Dgt1_9_bcd);
3652
3653         proto_tree_add_string_format(tree,
3654             hf_gsm_a_imei,
3655             tvb, curr_offset, len - (curr_offset - offset),
3656             a_bigbuf,
3657             "BCD Digits: %s",
3658             a_bigbuf);
3659
3660         if (add_string)
3661             g_snprintf(add_string, string_len, " - IMEI (%s)", a_bigbuf);
3662
3663         curr_offset += len - (curr_offset - offset);
3664         break;
3665
3666     case 4:     /* TMSI/P-TMSI */
3667         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3668         proto_tree_add_text(tree,
3669             tvb, curr_offset, 1,
3670             "%s :  Unused",
3671             a_bigbuf);
3672
3673         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3674
3675         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3676
3677
3678         curr_offset++;
3679
3680         value = tvb_get_ntohl(tvb, curr_offset);
3681
3682         proto_tree_add_uint(tree, hf_gsm_a_tmsi,
3683             tvb, curr_offset, 4,
3684             value);
3685
3686         if (add_string)
3687             g_snprintf(add_string, string_len, " - TMSI/P-TMSI (0x%04x)", value);
3688
3689         curr_offset += 4;
3690         break;
3691
3692     default:    /* Reserved */
3693         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3694         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3695         proto_tree_add_text(tree, tvb, curr_offset, len,
3696             "Mobile station identity Format %u, Format Unknown",(oct & 0x07));
3697
3698         if (add_string)
3699             g_snprintf(add_string, string_len, " - Format Unknown");
3700
3701         curr_offset += len;
3702         break;
3703     }
3704
3705     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
3706
3707     return(curr_offset - offset);
3708 }
3709
3710 /*
3711  * [3] 10.5.1.5
3712  */
3713 guint8
3714 de_ms_cm_1(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3715 {
3716     guint8      oct;
3717     guint32     curr_offset;
3718     proto_tree  *subtree;
3719     proto_item  *item;
3720     len = len;
3721     curr_offset = offset;
3722
3723     oct = tvb_get_guint8(tvb, curr_offset);
3724
3725     item =
3726         proto_tree_add_text(tree,
3727             tvb, curr_offset, 1,
3728             gsm_dtap_elem_strings[DE_MS_CM_1].strptr);
3729
3730     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_MS_CM_1]);
3731
3732     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3733
3734     proto_tree_add_item(subtree, hf_gsm_a_MSC_rev, tvb, curr_offset, 1, FALSE);
3735
3736         proto_tree_add_item(subtree, hf_gsm_a_ES_IND, tvb, curr_offset, 1, FALSE);
3737
3738         proto_tree_add_item(subtree, hf_gsm_a_A5_1_algorithm_sup, tvb, curr_offset, 1, FALSE);
3739
3740     proto_tree_add_item(subtree, hf_gsm_a_RF_power_capability, tvb, curr_offset, 1, FALSE);
3741
3742     curr_offset++;
3743
3744     /* no length check possible */
3745
3746     return(curr_offset - offset);
3747 }
3748
3749 /*
3750  * [3] 10.5.1.6
3751  */
3752 guint8
3753 de_ms_cm_2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3754 {
3755     guint32     curr_offset;
3756     curr_offset = offset;
3757
3758
3759     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3760
3761         proto_tree_add_item(tree, hf_gsm_a_MSC_rev, tvb, curr_offset, 1, FALSE);
3762
3763         proto_tree_add_item(tree, hf_gsm_a_ES_IND, tvb, curr_offset, 1, FALSE);
3764
3765         proto_tree_add_item(tree, hf_gsm_a_A5_1_algorithm_sup, tvb, curr_offset, 1, FALSE);
3766
3767     proto_tree_add_item(tree, hf_gsm_a_RF_power_capability, tvb, curr_offset, 1, FALSE);
3768
3769     curr_offset++;
3770
3771     NO_MORE_DATA_CHECK(len);
3772
3773     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3774
3775     proto_tree_add_item(tree, hf_gsm_a_ps_sup_cap, tvb, curr_offset, 1, FALSE);
3776
3777     proto_tree_add_item(tree, hf_gsm_a_SS_screening_indicator, tvb, curr_offset, 1, FALSE);
3778
3779     /* SM capability (MT SMS pt to pt capability) (octet 4)*/
3780         proto_tree_add_item(tree, hf_gsm_a_SM_capability, tvb, curr_offset, 1, FALSE);
3781         /* VBS notification reception (octet 4) */
3782         proto_tree_add_item(tree, hf_gsm_a_VBS_notification_rec, tvb, curr_offset, 1, FALSE);
3783         /*VGCS notification reception (octet 4)*/
3784         proto_tree_add_item(tree, hf_gsm_a_VGCS_notification_rec, tvb, curr_offset, 1, FALSE);
3785         /* FC Frequency Capability (octet 4 ) */
3786         proto_tree_add_item(tree, hf_gsm_a_FC_frequency_cap, tvb, curr_offset, 1, FALSE);
3787
3788     curr_offset++;
3789
3790     NO_MORE_DATA_CHECK(len);
3791
3792         /* CM3 (octet 5, bit 8) */
3793         proto_tree_add_item(tree, hf_gsm_a_CM3, tvb, curr_offset, 1, FALSE);
3794         /* spare bit 7 */
3795         proto_tree_add_item(tree, hf_gsm_a_b7spare, tvb, curr_offset, 1, FALSE);
3796         /* LCS VA capability (LCS value added location request notification capability) (octet 5,bit 6) */
3797         proto_tree_add_item(tree, hf_gsm_a_LCS_VA_cap, tvb, curr_offset, 1, FALSE);
3798         /* UCS2 treatment (octet 5, bit 5) */
3799         proto_tree_add_item(tree, hf_gsm_a_UCS2_treatment, tvb, curr_offset, 1, FALSE);
3800         /* SoLSA (octet 5, bit 4) */
3801         proto_tree_add_item(tree, hf_gsm_a_SoLSA, tvb, curr_offset, 1, FALSE);
3802         /* CMSP: CM Service Prompt (octet 5, bit 3) */
3803         proto_tree_add_item(tree, hf_gsm_a_CMSP, tvb, curr_offset, 1, FALSE);
3804         /* A5/3 algorithm supported (octet 5, bit 2) */
3805         proto_tree_add_item(tree, hf_gsm_a_A5_3_algorithm_sup, tvb, curr_offset, 1, FALSE);
3806         /* A5/2 algorithm supported (octet 5, bit 1) */
3807         proto_tree_add_item(tree, hf_gsm_a_A5_2_algorithm_sup, tvb, curr_offset, 1, FALSE);
3808
3809     curr_offset++;
3810
3811     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
3812
3813     return(curr_offset - offset);
3814 }
3815
3816 /*
3817  * [3] 10.5.1.9
3818  */
3819
3820 static guint8
3821 de_d_gb_call_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3822 {
3823     guint8      oct;
3824     guint32     value;
3825     guint32     curr_offset;
3826     const gchar *str;
3827
3828     len = len;
3829     curr_offset = offset;
3830
3831     value = tvb_get_ntohl(tvb, curr_offset);
3832
3833     other_decode_bitfield_value(a_bigbuf, value, 0xffffffe0, 32);
3834     proto_tree_add_text(tree, tvb, curr_offset, 4,
3835         "%s :  Group or Broadcast call reference: %u (0x%04x)",
3836         a_bigbuf,
3837         (value & 0xffffffe0) >> 5,
3838         (value & 0xffffffe0) >> 5);
3839
3840     other_decode_bitfield_value(a_bigbuf, value, 0x00000010, 32);
3841     proto_tree_add_text(tree, tvb, curr_offset, 4,
3842         "%s :  SF Service Flag: %s",
3843         a_bigbuf,
3844         (value & 0x00000010) ?
3845             "VGCS (Group call reference)" : "VBS (Broadcast call reference)");
3846
3847     other_decode_bitfield_value(a_bigbuf, value, 0x00000008, 32);
3848     proto_tree_add_text(tree, tvb, curr_offset, 4,
3849         "%s :  AF Acknowledgement Flag: acknowledgment is %srequired",
3850         a_bigbuf,
3851         (value & 0x00000008) ? "" : "not ");
3852
3853     switch (value & 0x00000007)
3854     {
3855     case 1: str = "call priority level 4"; break;
3856     case 2: str = "call priority level 3"; break;
3857     case 3: str = "call priority level 2"; break;
3858     case 4: str = "call priority level 1"; break;
3859     case 5: str = "call priority level 0"; break;
3860     case 6: str = "call priority level B"; break;
3861     case 7: str = "call priority level A"; break;
3862     default:
3863         str = "no priority applied";
3864         break;
3865     }
3866
3867     other_decode_bitfield_value(a_bigbuf, value, 0x00000007, 32);
3868     proto_tree_add_text(tree, tvb, curr_offset, 4,
3869         "%s :  Call Priority: %s",
3870         a_bigbuf,
3871         str);
3872
3873     curr_offset += 4;
3874
3875     oct = tvb_get_guint8(tvb, curr_offset);
3876
3877     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3878     proto_tree_add_text(tree, tvb, curr_offset, 1,
3879         "%s :  Ciphering Information",
3880         a_bigbuf);
3881
3882     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
3883     proto_tree_add_text(tree, tvb, curr_offset, 1,
3884         "%s :  Spare",
3885         a_bigbuf);
3886
3887     curr_offset++;
3888
3889     /* no length check possible */
3890
3891     return(curr_offset - offset);
3892 }
3893
3894 /*
3895  * [3] 10.5.1.10a
3896  */
3897 static guint8
3898 de_pd_sapi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3899 {
3900     guint8      oct;
3901     guint32     curr_offset;
3902     proto_tree  *subtree;
3903     proto_item  *item;
3904     const gchar *str;
3905
3906     len = len;
3907     curr_offset = offset;
3908
3909     oct = tvb_get_guint8(tvb, curr_offset);
3910
3911     item =
3912         proto_tree_add_text(tree,
3913             tvb, curr_offset, 1,
3914             gsm_dtap_elem_strings[DE_PD_SAPI].strptr);
3915
3916     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_PD_SAPI]);
3917
3918     other_decode_bitfield_value(a_bigbuf, oct, 0xc0, 8);
3919     proto_tree_add_text(subtree, tvb, curr_offset, 1,
3920         "%s :  Spare",
3921         a_bigbuf);
3922
3923     switch ((oct & 0x30) >> 4)
3924     {
3925     case 0: str = "SAPI 0"; break;
3926     case 3: str = "SAPI 3"; break;
3927     default:
3928         str = "Reserved";
3929         break;
3930     }
3931
3932     other_decode_bitfield_value(a_bigbuf, oct, 0x30, 8);
3933     proto_tree_add_text(subtree, tvb, curr_offset, 1,
3934         "%s :  SAPI (Sevice Access Point Identifier): %s",
3935         a_bigbuf,
3936         str);
3937
3938     proto_tree_add_item(tree, hf_gsm_a_L3_protocol_discriminator, tvb, curr_offset, 1, FALSE);
3939
3940     curr_offset++;
3941
3942     /* no length check possible */
3943
3944     return(curr_offset - offset);
3945 }
3946
3947 /*
3948  * [3] 10.5.1.11
3949  */
3950
3951 static guint8
3952 de_prio(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3953 {
3954     guint8      oct;
3955     guint32     curr_offset;
3956     const gchar *str;
3957
3958     len = len;
3959     curr_offset = offset;
3960
3961     oct = tvb_get_guint8(tvb, curr_offset);
3962
3963     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
3964     proto_tree_add_text(tree,
3965         tvb, curr_offset, 1,
3966         "%s :  Spare",
3967         a_bigbuf);
3968
3969     switch (oct & 0x07)
3970     {
3971     case 1: str = "Call priority level 4"; break;
3972     case 2: str = "Call priority level 3"; break;
3973     case 3: str = "Call priority level 2"; break;
3974     case 4: str = "Call priority level 1"; break;
3975     case 5: str = "Call priority level 0"; break;
3976     case 6: str = "Call priority level B"; break;
3977     case 7: str = "Call priority level A"; break;
3978     default:
3979         str = "No priority applied";
3980         break;
3981     }
3982
3983     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
3984     proto_tree_add_text(tree,
3985         tvb, curr_offset, 1,
3986         "%s :  %s",
3987         a_bigbuf,
3988         str);
3989
3990     curr_offset++;
3991
3992     /* no length check possible */
3993
3994     return(curr_offset - offset);
3995 }
3996
3997 /*
3998  * [3] 10.5.1.13
3999  */
4000 static guint8
4001 de_plmn_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
4002 {
4003     guint8      octs[3];
4004     guint32     curr_offset;
4005     gchar       mcc[4];
4006     gchar       mnc[4];
4007     guint8      num_plmn;
4008
4009     curr_offset = offset;
4010
4011     num_plmn = 0;
4012     while ((len - (curr_offset - offset)) >= 3)
4013     {
4014         octs[0] = tvb_get_guint8(tvb, curr_offset);
4015         octs[1] = tvb_get_guint8(tvb, curr_offset + 1);
4016         octs[2] = tvb_get_guint8(tvb, curr_offset + 2);
4017
4018         mcc_mnc_aux(octs, mcc, mnc);
4019
4020         proto_tree_add_text(tree,
4021             tvb, curr_offset, 3,
4022             "PLMN[%u]  Mobile Country Code (MCC): %s, Mobile Network Code (MNC): %s",
4023             num_plmn + 1,
4024             mcc,
4025             mnc);
4026
4027         curr_offset += 3;
4028
4029         num_plmn++;
4030     }
4031
4032     if (add_string)
4033         g_snprintf(add_string, string_len, " - %u PLMN%s",
4034             num_plmn, plurality(num_plmn, "", "s"));
4035
4036     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
4037
4038     return(curr_offset - offset);
4039 }
4040 /*
4041 10.5.2 Radio Resource management information elements
4042  * [3] 10.5.2.1a BA Range
4043  */
4044 /*
4045  * [3] 10.5.2.1b Cell Channel Description
4046  */
4047 static guint8
4048 de_rr_cell_ch_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4049 {
4050     guint32     curr_offset;
4051     guint8  oct,bit,byte;
4052         guint16 arfcn;
4053         proto_item      *item;
4054
4055
4056     len = len;
4057     curr_offset = offset;
4058
4059     oct = tvb_get_guint8(tvb, curr_offset);
4060
4061         /* FORMAT-ID, Format Identifier (part of octet 3)*/
4062         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
4063         /* Cell Channel Description */ 
4064
4065         if ((oct & 0xc0) == 0x00)
4066         {
4067                 /* bit map 0 */
4068                 item = proto_tree_add_text(tree,tvb, curr_offset, 16,"list of ARFCN for hopping = ");
4069                 bit = 4;
4070                 arfcn = 125;
4071                 for (byte = 0;byte <= 15;byte++)
4072                 {
4073                         oct = tvb_get_guint8(tvb, curr_offset);
4074                         while (bit-- != 0)
4075                         {
4076                                 arfcn--;
4077                                 if (((oct >> bit) & 1) == 1)
4078                                 {
4079                                         proto_item_append_text(item," %4d",arfcn);
4080                                 }
4081                         }
4082                         bit = 8;
4083                         curr_offset++;
4084                 }
4085         }
4086     else if ((oct & 0xf8) == 0x80)
4087         { 
4088                 /* 1024 range */
4089                 proto_tree_add_text(tree,tvb, curr_offset, 16,"Cell Channel Description (1024 range) (Not decoded)");
4090                 curr_offset = curr_offset + 16;
4091         }
4092         else if ((oct & 0xfe) == 0x88)
4093         {
4094                 /* 512 range */
4095                 proto_tree_add_text(tree,tvb, curr_offset, 16,"Cell Channel Description (512 range) (Not decoded)");
4096                 curr_offset = curr_offset + 16;
4097         }
4098         else if ((oct & 0xfe) == 0x8a)
4099         {
4100                 /* 256 range */
4101                 proto_tree_add_text(tree,tvb, curr_offset, 16,"Cell Channel Description (256 range) (Not decoded)");
4102                 curr_offset = curr_offset + 16;
4103         }
4104         else if ((oct & 0xfe) == 0x8c)
4105         {
4106                 /* 128 range */
4107                 proto_tree_add_text(tree,tvb, curr_offset, 16,"Cell Channel Description (128 range) (Not decoded)");
4108                 curr_offset = curr_offset + 16;
4109         }
4110         else if ((oct & 0xfe) == 0x8e)
4111         {
4112                 /* variable bit map */
4113                 arfcn = ((oct & 0x01) << 9) | (tvb_get_guint8(tvb, curr_offset+1) << 1) | ((tvb_get_guint8(tvb, curr_offset + 2) & 0x80) >> 7);
4114                 item = proto_tree_add_text(tree,tvb, curr_offset, 16,"list of ARFCN for hopping = %d",arfcn);
4115                 curr_offset = curr_offset + 2;
4116                 bit = 7;
4117                 for (byte = 0;byte <= 13;byte++)
4118                 {
4119                         oct = tvb_get_guint8(tvb, curr_offset);
4120                         while (bit-- != 0)
4121                         {
4122                                 arfcn++;
4123                                 if (((oct >> bit) & 1) == 1)
4124                                 {
4125                                         proto_item_append_text(item," %4d",arfcn);
4126                                 }
4127                         }
4128                         bit = 8;
4129                         curr_offset++;
4130                 }
4131         }       
4132         
4133
4134     return(curr_offset - offset);
4135 }
4136 /*
4137  * [3] 10.5.2.1c BA List Pref 
4138  * [3] 10.5.2.1d UTRAN Frequency List 
4139  */
4140 /*
4141  * [3] 10.5.2.2 Cell Description 
4142  */
4143 guint8
4144 de_rr_cell_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4145 {
4146     proto_tree  *subtree;
4147     proto_item  *item;
4148     guint8      oct;
4149     guint32     curr_offset;
4150         guint16 bcch_arfcn;
4151
4152     len = len;
4153     curr_offset = offset;
4154
4155     oct = tvb_get_guint8(tvb, curr_offset);
4156         item =
4157         proto_tree_add_text(tree,
4158             tvb, curr_offset, 2,
4159             gsm_dtap_elem_strings[DE_RR_CELL_DSC].strptr);
4160
4161     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_CELL_DSC]);
4162
4163         proto_tree_add_item(subtree, hf_gsm_a_ncc, tvb, curr_offset, 1, FALSE);
4164         proto_tree_add_item(subtree, hf_gsm_a_bcc, tvb, curr_offset, 1, FALSE);
4165         bcch_arfcn = (tvb_get_guint8(tvb,curr_offset) & 0xc0) << 2;
4166         bcch_arfcn = bcch_arfcn | tvb_get_guint8(tvb,curr_offset+1);
4167         proto_tree_add_uint(subtree, hf_gsm_a_bcch_arfcn , tvb, curr_offset, 2, bcch_arfcn );
4168
4169
4170     curr_offset = curr_offset + 2;
4171
4172
4173     return(curr_offset - offset);
4174 }
4175 /*
4176  * [3] 10.5.2.3 Cell Options (BCCH) 
4177  * [3] 10.5.2.3a Cell Options (SACCH) 
4178  * [3] 10.5.2.4 Cell Selection Parameters
4179  * [3] 10.5.2.4a MAC Mode and Channel Coding Requested 
4180  * [3] 10.5.2.5 Channel Description
4181  */
4182 static guint8
4183 de_rr_ch_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4184 {
4185     guint32     curr_offset;
4186     guint8      oct8,subchannel;
4187     guint16 arfcn, hsn, maio;
4188         proto_tree      *subtree;
4189         proto_item      *item;
4190     const gchar *str;
4191
4192     len = len;
4193     curr_offset = offset;
4194
4195     item = proto_tree_add_text(tree,tvb, curr_offset, 3,gsm_dtap_elem_strings[DE_RR_CH_DSC].strptr);
4196
4197         subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_CH_DSC]);
4198
4199     /* Octet 2 */
4200     oct8 = tvb_get_guint8(tvb, curr_offset);
4201     
4202     if ((oct8 & 0xf8) == 0x08)
4203     {
4204         str = "TCH/F + ACCHs"; 
4205                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4206         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
4207     }
4208     else 
4209     {
4210         if ((oct8 & 0xf0) == 0x10) 
4211         {
4212                 str = "TCH/H + ACCHs, Subchannel";
4213                 subchannel = ((oct8 & 0x08)>>3);
4214         }
4215         else if ((oct8 & 0xe0) == 0x20)
4216         {
4217                 str = "SDCCH/4 + SACCH/C4 or CBCH (SDCCH/4), Subchannel";
4218                 subchannel = ((oct8 & 0x18)>>3);
4219         }
4220         else if ((oct8 & 0xc0) == 0x40)
4221         {
4222                 str = "SDCCH/8 + SACCH/C8 or CBCH (SDCCH/8), Subchannel";
4223                 subchannel = ((oct8 % 0x38)>>3);
4224                 }
4225                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4226         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s %d",a_bigbuf,str,subchannel);
4227     }
4228
4229         other_decode_bitfield_value(a_bigbuf, oct8, 0x07, 8);
4230     proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Timeslot: %d",a_bigbuf,(oct8 & 0x07));
4231
4232         curr_offset +=1;
4233                 
4234         /* Octet 3 */
4235         oct8 = tvb_get_guint8(tvb, curr_offset);
4236     other_decode_bitfield_value(a_bigbuf, oct8, 0xe0, 8);
4237         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Training Sequence: %d",a_bigbuf,((oct8 & 0xe0)>>5));
4238                 
4239     
4240         if ((oct8 & 0x10) == 0x10)
4241         {
4242                 /* Hopping sequence */
4243                 maio = ((oct8 & 0x0f)<<2) | ((tvb_get_guint8(tvb,curr_offset+1) & 0xc0) >> 6);
4244                 hsn = (tvb_get_guint8(tvb,curr_offset+1) & 0x3f);
4245                 str = "Yes";
4246
4247                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
4248                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
4249                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: MAIO %d",maio);
4250                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: HSN %d",hsn);
4251         }
4252         else
4253         {
4254                 /* sinlge ARFCN */
4255                 arfcn = ((oct8 & 0x03) << 8) | tvb_get_guint8(tvb,curr_offset+1);
4256                 str = "No";
4257
4258                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
4259                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
4260                 other_decode_bitfield_value(a_bigbuf, oct8, 0x0c, 8);
4261                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Spare",a_bigbuf);
4262                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Single channel : ARFCN %d",arfcn);
4263         }
4264                 
4265         curr_offset = curr_offset + 2;
4266
4267     return(curr_offset - offset);
4268 }
4269 /*
4270  * [3] 10.5.2.5a Channel Description 2
4271  */
4272 static guint8
4273 de_rr_ch_dsc2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4274 {
4275     guint32     curr_offset;
4276     guint8      oct8,subchannel;
4277     guint16 arfcn, hsn, maio;
4278         proto_tree      *subtree;
4279         proto_item      *item;
4280     const gchar *str;
4281
4282     len = len;
4283     curr_offset = offset;
4284
4285     item = proto_tree_add_text(tree,tvb, curr_offset, 3,gsm_dtap_elem_strings[DE_RR_CH_DSC2].strptr);
4286
4287         subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_CH_DSC2]);
4288
4289     /* Octet 2 */
4290     oct8 = tvb_get_guint8(tvb, curr_offset);
4291     
4292     if ((oct8 & 0xf8) == 0x0)
4293     {
4294         str = "TCH/F + FACCH/F and SACCH/M"; 
4295                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4296         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
4297     }
4298         else if ((oct8 & 0xf8) == 0x08)
4299     {
4300         str = "TCH/F + FACCH/F and SACCH/F"; 
4301                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4302         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
4303     }
4304         else if ((oct8 & 0xf8) == 0xf0)
4305         {
4306                 str = "TCH/F + FACCH/F and SACCH/M + bi- and unidirectional channels";
4307                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4308         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
4309         }
4310     else 
4311     {
4312         if ((oct8 & 0xf0) == 0x10) 
4313         {
4314                 str = "TCH/H + ACCHs, Subchannel";
4315                 subchannel = ((oct8 & 0x08)>>3);
4316         }
4317         else if ((oct8 & 0xe0) == 0x20)
4318         {
4319                 str = "SDCCH/4 + SACCH/C4 or CBCH (SDCCH/4), Subchannel";
4320                 subchannel = ((oct8 & 0x18)>>3);
4321         }
4322         else if ((oct8 & 0xc0) == 0x40)
4323         {
4324                 str = "SDCCH/8 + SACCH/C8 or CBCH (SDCCH/8), Subchannel";
4325                 subchannel = ((oct8 % 0x38)>>3);
4326                 }
4327                 else if ((oct8 & 0xc0) == 0x80)
4328                 {
4329                         str = "TCH/F + FACCH/F and SACCH/M + bidirectional channels at timeslot";
4330                         subchannel = ((oct8 % 0x38)>>3);
4331                 }
4332                 else if ((oct8 & 0xe0) == 0xc0)
4333                 {
4334                         str = "TCH/F + FACCH/F and SACCH/M + unidirectional channels at timeslot";
4335                         subchannel = ((oct8 % 0x38)>>3);
4336                 }
4337                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4338         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s %d",a_bigbuf,str,subchannel);
4339     }
4340
4341         other_decode_bitfield_value(a_bigbuf, oct8, 0x07, 8);
4342     proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Timeslot: %d",a_bigbuf,(oct8 & 0x07));
4343
4344         curr_offset +=1;
4345                 
4346         /* Octet 3 */
4347         oct8 = tvb_get_guint8(tvb, curr_offset);
4348     other_decode_bitfield_value(a_bigbuf, oct8, 0xe0, 8);
4349         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Training Sequence: %d",a_bigbuf,((oct8 & 0xe0)>>5));
4350                 
4351     
4352         if ((oct8 & 0x10) == 0x10)
4353         {
4354                 /* Hopping sequence */
4355                 maio = ((oct8 & 0x0f)<<2) | ((tvb_get_guint8(tvb,curr_offset+1) & 0xc0) >> 6);
4356                 hsn = (tvb_get_guint8(tvb,curr_offset+1) & 0x3f);
4357                 str = "Yes";
4358
4359                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
4360                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
4361                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: MAIO %d",maio);
4362                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: HSN %d",hsn);
4363         }
4364         else
4365         {
4366                 /* sinlge ARFCN */
4367                 arfcn = ((oct8 & 0x03) << 8) | tvb_get_guint8(tvb,curr_offset+1);
4368                 str = "No";
4369
4370                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
4371                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
4372                 other_decode_bitfield_value(a_bigbuf, oct8, 0x0c, 8);
4373                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Spare",a_bigbuf);
4374                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Single channel : ARFCN %d",arfcn);
4375         }
4376                 
4377         curr_offset = curr_offset + 2;
4378
4379     return(curr_offset - offset);
4380 }
4381 /*
4382  * [3] 10.5.2.6 Channel Mode
4383  */
4384
4385 /* Channel Mode  */
4386 static const value_string gsm_a_rr_channel_mode_vals[] = {
4387 { 0x00,         "signalling only"},
4388 { 0x01,         "speech full rate or half rate version 1(GSM FR or GSM HR)"},
4389 { 0x21,         "speech full rate or half rate version 2(GSM EFR)"},
4390 { 0x41,         "speech full rate or half rate version 3(FR AMR or HR AMR)"},
4391 { 0x81,         "speech full rate or half rate version 4(OFR AMR-WB or OHR AMR-WB)"},
4392 { 0x82,         "speech full rate or half rate version 5(FR AMR-WB )"},
4393 { 0x83,         "speech full rate or half rate version 6(OHR AMR )"},
4394 { 0x61,         "data, 43.5 kbit/s (downlink)+14.5 kbps (uplink)"},
4395 { 0x62,         "data, 29.0 kbit/s (downlink)+14.5 kbps (uplink)"},
4396 { 0x64,         "data, 43.5 kbit/s (downlink)+29.0 kbps (uplink)"},
4397 { 0x67,         "data, 14.5 kbit/s (downlink)+43.5 kbps (uplink)"},
4398 { 0x65,         "data, 14.5 kbit/s (downlink)+29.0 kbps (uplink)"},
4399 { 0x66,         "data, 29.0 kbit/s (downlink)+43.5 kbps (uplink)"},
4400 { 0x27,         "data, 43.5 kbit/s radio interface rate"},
4401 { 0x63,         "data, 32.0 kbit/s radio interface rate"},
4402 { 0x43,         "data, 29.0 kbit/s radio interface rate"},
4403 { 0x0f,         "data, 14.5 kbit/s radio interface rate"},
4404 { 0x03,         "data, 12.0 kbit/s radio interface rate"},
4405 { 0x0b,         "data, 6.0 kbit/s radio interface rate"},
4406 { 0x13,         "data, 3.6 kbit/s radio interface rate"},
4407         { 0,    NULL }
4408 };
4409
4410 guint8
4411 de_rr_ch_mode(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4412 {
4413     guint32     curr_offset;
4414
4415     len = len;
4416     curr_offset = offset;
4417
4418     proto_tree_add_item(tree, hf_gsm_a_rr_channel_mode, tvb, curr_offset, 1, FALSE);
4419         
4420         curr_offset = curr_offset + 1;
4421
4422     return(curr_offset - offset);
4423 }
4424 /*
4425  * [3] 10.5.2.7 Channel Mode 2 
4426  */
4427
4428 static const value_string gsm_a_rr_channel_mode2_vals[] = {
4429 { 0x00,         "signalling only"},
4430 { 0x05,         "speech half rate version 1(GSM HR)"},
4431 { 0x25,         "speech half rate version 2(GSM EFR)"},
4432 { 0x45,         "speech half rate version 3(HR AMR)"},
4433 { 0x85,         "speech half rate version 4(OHR AMR-WB)"},
4434 { 0x06,         "speech half rate version 6(OHR AMR )"},
4435 { 0x0f,         "data, 6.0 kbit/s radio interface rate"},
4436 { 0x17,         "data, 3.6 kbit/s radio interface rate"},
4437         { 0,    NULL }
4438 };
4439
4440 static guint8
4441 de_rr_ch_mode2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4442 {
4443     guint32     curr_offset;
4444
4445     len = len;
4446     curr_offset = offset;
4447
4448     proto_tree_add_item(tree, hf_gsm_a_rr_channel_mode2, tvb, curr_offset, 1, FALSE);
4449         
4450         curr_offset = curr_offset + 1;
4451
4452     return(curr_offset - offset);
4453 }  
4454 /*
4455  * [3] 10.5.2.7a UTRAN Classmark information element
4456  * [3] 10.5.2.7b (void)
4457  */
4458 /*
4459  * [3] 10.5.2.7c Classmark Enquiry Mask
4460  * Bit 8:
4461  * 0    CLASSMARK CHANGE message is requested
4462  * 1    CLASSMARK CHANGE message is not requested
4463  * Bits 7-5 . 5
4464  * 000  UTRAN CLASSMARK CHANGE message including status on predefined configurations (i.e. Sequence Description) is requested
4465  * 111  UTRAN CLASSMARK CHANGE message including status on predefined configurations (i.e. Sequence Description) is not requested.
4466  * All other values shall not be sent. If received, they shall be interpreted as '000'.
4467  * Bit 4:
4468  * 0    CDMA2000 CLASSMARK CHANGE message requested
4469  * 1    CDMA2000 CLASSMARK CHANGE message not requested.
4470  * Bit 3:
4471  * 0    GERAN IU MODE CLASSMARK CHANGE message requested
4472  * 1    GERAN IU MODE CLASSMARK CHANGE message not requested.
4473  * Bits 2 - 1: spare(0).
4474  */
4475 static const true_false_string gsm_a_msg_req_value  = {
4476   "message is not requested",
4477   "message is requested"
4478 };
4479 static const value_string gsm_a_rr_utran_cm_cng_msg_req_vals[] = {
4480 { 0x0,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4481 { 0x1,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4482 { 0x2,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4483 { 0x3,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4484 { 0x4,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4485 { 0x5,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4486 { 0x6,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4487 { 0x7,          "message including status on predefined configurations (i.e. Sequence Description) is not requested."},
4488         { 0,    NULL }
4489 };
4490 guint8
4491 de_rr_cm_enq_mask(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4492 {
4493     guint32     curr_offset;
4494
4495     len = len;
4496     curr_offset = offset;
4497         
4498         proto_tree_add_item(tree, hf_gsm_a_rr_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
4499         proto_tree_add_item(tree, hf_gsm_a_rr_utran_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
4500         proto_tree_add_item(tree, hf_gsm_a_rr_cdma200_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
4501         proto_tree_add_item(tree, hf_gsm_a_rr_geran_iu_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
4502
4503         curr_offset = curr_offset + 1;
4504
4505     return(curr_offset - offset);
4506 }
4507 /*
4508  * [3] 10.5.2.8 Channel Needed
4509  */
4510 static const value_string gsm_a_rr_channel_needed_vals[] = {
4511 { 0x00,         "Any channel"},
4512 { 0x01,         "SDCCH"},
4513 { 0x02,         "TCH/F (Full rate)"},
4514 { 0x03,         "TCH/H or TCH/F (Dual rate)"},
4515         { 0,    NULL }
4516 };
4517 guint8
4518 de_rr_chnl_needed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4519 {
4520     guint32     curr_offset;
4521
4522     len = len;
4523     curr_offset = offset;
4524         
4525         proto_tree_add_item(tree, hf_gsm_a_rr_chnl_needed_ch1, tvb, curr_offset, 1, FALSE);
4526         proto_tree_add_item(tree, hf_gsm_a_rr_chnl_needed_ch2, tvb, curr_offset, 1, FALSE);
4527
4528         curr_offset = curr_offset + 1;
4529
4530     return(curr_offset - offset);
4531 }
4532 /*
4533  * [3] 10.5.2.8a Channel Request Description
4534  * [3] 10.5.2.8b Channel Request Description 2
4535  */
4536 /*
4537  * [3] 10.5.2.9 Cipher Mode Setting
4538  */
4539 /* SC (octet 1) */
4540 static const value_string gsm_a_rr_sc_vals[] = {
4541         { 0,            "No ciphering"},
4542         { 1,            "Start ciphering"},
4543         { 0,    NULL }
4544 };
4545 /* algorithm identifier
4546  * If SC=1 then:
4547  * bits
4548  * 4 3 2
4549  */
4550
4551 guint8
4552 de_rr_cip_mode_set(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4553 {
4554     guint32     curr_offset;
4555         guint8 oct;
4556
4557     len = len;
4558     curr_offset = offset;               
4559
4560         /* Cipher Mode Setting
4561                  * Note: The coding of fields SC and algorithm identifier is defined in [44.018] 
4562                  * as part of the Cipher Mode Setting IE.
4563                  */
4564                 proto_tree_add_item(tree, hf_gsm_a_rr_sc, tvb, curr_offset, 1, FALSE);
4565                 oct = tvb_get_guint8(tvb,curr_offset);
4566                 if ( (oct & 1) == 1){ /* Start ciphering */
4567                         /* algorithm identifier */
4568                         proto_tree_add_item(tree, hf_gsm_a_algorithm_id, tvb, curr_offset, 1, FALSE);
4569                 }
4570         curr_offset = curr_offset + 1;
4571
4572     return(curr_offset - offset);
4573 }
4574 /*
4575  * [3] 10.5.2.10 Cipher Response
4576  * [3] 10.5.2.11 Control Channel Description
4577  * [3] 10.5.2.11a DTM Information Details
4578  */
4579 /* 
4580  * [3]  10.5.2.11b      Dynamic ARFCN Mapping           
4581  */
4582 static guint8
4583 de_rr_dyn_arfcn_map(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4584 {
4585     guint32     curr_offset;
4586
4587     len = len;
4588     curr_offset = offset;
4589
4590         proto_tree_add_text(tree,tvb, curr_offset, len,"Dynamic ARFCN Mapping content(Not decoded)");
4591
4592         
4593         curr_offset = curr_offset + len;
4594
4595     return(curr_offset - offset);
4596 }  
4597 /*
4598  * [3] 10.5.2.12 Frequency Channel Sequence
4599  */
4600 static guint8
4601 de_rr_freq_ch_seq(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4602 {
4603     guint32     curr_offset;
4604
4605     len = len;
4606     curr_offset = offset;
4607
4608         proto_tree_add_text(tree,tvb, curr_offset, 9,"Frequency Channel Sequence(Not decoded)");
4609
4610         
4611         curr_offset = curr_offset + 9;
4612
4613     return(curr_offset - offset);
4614 }  
4615 /*
4616  * [3] 10.5.2.13 Frequency List
4617  * 
4618  * Bit Bit Bit Bit Bit format notation
4619  * 8 7  4 3 2
4620  * 0 0  X X X bit map 0
4621  * 1 0  0 X X 1024 range
4622  * 1 0  1 0 0 512 range
4623  * 1 0  1 0 1 256 range
4624  * 1 0  1 1 0 128 range
4625  * 1 0  1 1 1 variable bit map
4626  */
4627 /* The mask 0xce (1100 1110) will produce the result 0110 0111*/ 
4628 static const value_string gsm_a_rr_freq_list_format_id_vals[] = {
4629         { 0x00,         "bit map 0"},
4630         { 0x02,         "bit map 0"},
4631         { 0x04,         "bit map 0"},
4632         { 0x06,         "bit map 0"},
4633         { 0x08,         "bit map 0"},
4634         { 0x0a,         "bit map 0"},
4635         { 0x0c,         "bit map 0"},
4636         { 0x0e,         "bit map 0"},
4637         { 0x40,         "1024 range"},
4638         { 0x41,         "1024 range"},
4639         { 0x42,         "1024 range"},
4640         { 0x43,         "1024 range"},
4641         { 0x44,         "512 range"},
4642         { 0x45,         "256 range"},
4643         { 0x46,         "128 range"},
4644         { 0x47,         "variable bit map"},
4645         { 0x00, NULL }
4646 };
4647 static guint8
4648 de_rr_freq_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4649 {
4650     guint32     curr_offset;
4651
4652     len = len;
4653     curr_offset = offset;
4654
4655         /* FORMAT-ID, Format Identifier (part of octet 3)*/
4656         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
4657         /* Frequency list */ 
4658         proto_tree_add_text(tree,tvb, curr_offset, len-1,"Frequency Data(Not decoded)");
4659
4660         curr_offset = curr_offset + len;
4661     return(curr_offset - offset);
4662
4663 }
4664 /*
4665  * [3] 10.5.2.13.1 General description
4666  * [3] 10.5.2.13.2 Bit map 0 format
4667  * [3] 10.5.2.13.3 Range 1024 format
4668  * [3] 10.5.2.13.4 Range 512 format
4669  * [3] 10.5.2.13.5 Range 256 format
4670  * [3] 10.5.2.13.6 Range 128 format
4671  * [3] 10.5.2.13.7 Variable bit map format
4672  */
4673 /*
4674  * [3] 10.5.2.14 Frequency Short List
4675  *
4676  *The Frequency Short List information element is a type 3 information element of 10 octet length.
4677  *
4678  * This element is encoded exactly as the Frequency List information element, 
4679  * except that it has a fixed length instead of a variable length and does 
4680  * not contain a length indicator and that it shall not be encoded in bitmap 0 format.
4681  */
4682 static guint8
4683 de_rr_freq_short_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4684 {
4685     guint32     curr_offset;
4686
4687     len = len;
4688     curr_offset = offset;
4689
4690         /* FORMAT-ID, Format Identifier (part of octet 3)*/
4691         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
4692         /* Frequency list */ 
4693         proto_tree_add_text(tree,tvb, curr_offset, 9,"Frequency Data(Not decoded)");
4694
4695         curr_offset = curr_offset + 9;
4696     return(curr_offset - offset);
4697
4698 }
4699 /*
4700  * [3] 10.5.2.14a Frequency Short List 2
4701  *
4702  * The Frequency Short List information element is a type 3 information element of 8 octet length.
4703  *
4704  * This element is encoded exactly as the Frequency List information element, 
4705  * except that it has a fixed length instead of a variable length and does 
4706  * not contain a length indicator and that it shall not be encoded in bitmap 0 format.
4707  */
4708 static guint8
4709 de_rr_freq_short_list2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4710 {
4711     guint32     curr_offset;
4712
4713     len = len;
4714     curr_offset = offset;
4715
4716         /* FORMAT-ID, Format Identifier (part of octet 3)*/
4717         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
4718
4719         /* Frequency list */ 
4720         proto_tree_add_text(tree,tvb, curr_offset, 7,"Frequency Data(Not decoded)");
4721
4722         curr_offset = curr_offset + 8;
4723     return(curr_offset - offset);
4724
4725 }
4726 /*
4727  * [3] 10.5.2.14b Group Channel Description
4728  * [3] 10.5.2.14c GPRS Resumption
4729  * [3] 10.5.2.14d GPRS broadcast information
4730  */
4731 /*
4732  * [3] 10.5.2.15 Handover Reference
4733  */
4734 static guint8
4735 de_rr_ho_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4736 {
4737     proto_tree  *subtree;
4738     proto_item  *item;
4739     guint32     curr_offset;
4740
4741     len = len;
4742     curr_offset = offset;
4743
4744         item =
4745         proto_tree_add_text(tree,
4746             tvb, curr_offset, 1,
4747             gsm_dtap_elem_strings[DE_RR_HO_REF].strptr);
4748
4749     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_HO_REF]);
4750
4751         /* Handover reference value */
4752     proto_tree_add_item(subtree, hf_gsm_a_rr_ho_ref_val, tvb, curr_offset, 1, FALSE);
4753         
4754         curr_offset = curr_offset + 1;
4755
4756     return(curr_offset - offset);
4757 }
4758 /*
4759  * [3] 10.5.2.16 IA Rest Octets
4760  * [3] 10.5.2.17 IAR Rest Octets
4761  * [3] 10.5.2.18 IAX Rest Octets
4762  * [3] 10.5.2.19 L2 Pseudo Length
4763  * [3] 10.5.2.20 Measurement Results
4764  * [3] 10.5.2.20a GPRS Measurement Results
4765  */
4766 /*
4767  * [3] 10.5.2.21 Mobile Allocation
4768  */
4769 static guint8
4770 de_rr_mob_all(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4771 {
4772     guint32     curr_offset;
4773
4774     len = len;
4775     curr_offset = offset;
4776
4777         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
4778
4779         curr_offset = curr_offset + len;
4780     return(curr_offset - offset);
4781
4782 }
4783 /*
4784  * [3] 10.5.2.21a Mobile Time Difference
4785  */
4786 static guint8
4787 de_rr_mob_time_diff(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4788 {
4789     guint32     curr_offset;
4790
4791     len = len;
4792     curr_offset = offset;
4793
4794         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
4795
4796         curr_offset = curr_offset + len;
4797     return(curr_offset - offset);
4798
4799 }
4800 /*
4801  * [3] 10.5.2.21aa MultiRate configuration
4802  */
4803 /*      Multirate speech version Octet 3 Bits 8 7 6 */
4804 static const value_string multirate_speech_ver_vals[] = {
4805         { 1,            "Adaptive Multirate speech version 1"},
4806         { 2,            "Adaptive Multirate speech version 2"},
4807         { 0,    NULL }
4808 };
4809 /* Bit  5       NSCB: Noise Suppression Control Bit */
4810 static const value_string NSCB_vals[] = {
4811         { 0,            "Noise Suppression can be used (default)"},
4812         { 1,            "Noise Suppression shall be turned off"},
4813         { 0,    NULL }
4814 };
4815 /* Bit  4       ICMI: Initial Codec Mode Indicator */
4816 static const value_string ICMI_vals[] = {
4817         { 0,            "The initial codec mode is defined by the implicit rule provided in 3GPP TS 05.09"},
4818         { 1,            "The initial codec mode is defined by the Start Mode field"},
4819         { 0,    NULL }
4820 };
4821 /*
4822 Table 10.5.2.21aa.2: Set of adaptive multirate codec modes field (octet 4)
4823 for the Multirate speech version 1
4824 */
4825 static const true_false_string gsm_a_rr_set_of_amr_codec_modes  = {
4826   "is part of the subset",
4827   "is not part of the subset"
4828 };
4829
4830
4831
4832 guint8
4833 de_rr_multirate_conf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4834 {
4835     guint32     curr_offset;
4836         guint8 oct;
4837
4838     len = len;
4839     curr_offset = offset;
4840
4841         proto_tree_add_item(tree, hf_gsm_a_rr_multirate_speech_ver, tvb, curr_offset, 1, FALSE);
4842         proto_tree_add_item(tree, hf_gsm_a_rr_NCSB, tvb, curr_offset, 1, FALSE);
4843         proto_tree_add_item(tree, hf_gsm_a_rr_ICMI, tvb, curr_offset, 1, FALSE);
4844         /* The initial codec mode is coded as in 3GPP TS 45.009 */
4845         proto_tree_add_item(tree, hf_gsm_a_rr_start_mode, tvb, curr_offset, 1, FALSE);
4846         oct = ( tvb_get_guint8(tvb,curr_offset) &0xe0 ) >> 5;
4847         curr_offset++;
4848         switch ( oct){
4849         case 1:
4850                 /* Adaptive Multirate speech version 1 */
4851                 /* Set of AMR codec modes */
4852                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8, tvb, curr_offset, 1, FALSE);
4853                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7, tvb, curr_offset, 1, FALSE);
4854                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6, tvb, curr_offset, 1, FALSE);
4855                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5, tvb, curr_offset, 1, FALSE);
4856                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4, tvb, curr_offset, 1, FALSE);
4857                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3, tvb, curr_offset, 1, FALSE);
4858                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2, tvb, curr_offset, 1, FALSE);
4859                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1, tvb, curr_offset, 1, FALSE);
4860                 curr_offset++;
4861
4862                 proto_tree_add_text(tree,tvb, curr_offset, len-2 ,"Parameters for multirate speech field(Not decoded)");
4863
4864                 break;
4865         case 2:
4866                 /* Adaptive Multirate speech version 2 */
4867                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5, tvb, curr_offset, 1, FALSE);
4868                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4, tvb, curr_offset, 1, FALSE);
4869                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3, tvb, curr_offset, 1, FALSE);
4870                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2, tvb, curr_offset, 1, FALSE);
4871                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1, tvb, curr_offset, 1, FALSE);
4872                 curr_offset++;
4873
4874                 proto_tree_add_text(tree,tvb, curr_offset, len-2 ,"Parameters for multirate speech field(Not decoded)");
4875                 break;
4876         default:
4877                 proto_tree_add_text(tree,tvb,offset,1,"Unknown version");
4878                 proto_tree_add_text(tree,tvb, curr_offset, len-1 ,"Data(Not decoded)");
4879                         break;
4880         }
4881
4882         curr_offset = offset + len;
4883     return(curr_offset - offset);
4884
4885 }
4886 /*
4887  * [3] 10.5.2.21b Multislot Allocation
4888  */
4889 static guint8
4890 de_rr_mult_all(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4891 {
4892     guint32     curr_offset;
4893
4894     len = len;
4895     curr_offset = offset;
4896
4897         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
4898
4899         curr_offset = curr_offset + len;
4900     return(curr_offset - offset);
4901
4902 }
4903 /*
4904  * [3] 10.5.2.21c NC mode
4905  * [3] 10.5.2.22 Neighbour Cell Description
4906  * [3] 10.5.2.22a Neighbour Cell Description 2
4907  * [3] 10.5.2.22b (void)
4908  * [3] 10.5.2.22c NT/N Rest Octets
4909  * [3] 10.5.2.23 P1 Rest Octets
4910  * [3] 10.5.2.24 P2 Rest Octets
4911  * [3] 10.5.2.25 P3 Rest Octets
4912  * [3] 10.5.2.25a Packet Channel Description
4913  * [3] 10.5.2.25b Dedicated mode or TBF
4914  * [3] 10.5.2.25c RR Packet Uplink Assignment
4915  * [3] 10.5.2.25d RR Packet Downlink Assignment
4916  * [3] 10.5.2.26 Page Mode
4917  * [3] 10.5.2.26a (void)
4918  * [3] 10.5.2.26b (void)
4919  * [3] 10.5.2.26c (void)
4920  * [3] 10.5.2.26d (void)
4921  * [3] 10.5.2.27 NCC Permitted
4922  */
4923 /*
4924  * [3] 10.5.2.28 Power Command
4925  *
4926  *
4927  * ATC (Access Type Control) (octet 2)Bit 8
4928  * 0    Sending of Handover access is mandatory
4929  * 1    Sending of Handover access is optional
4930  */
4931 static const true_false_string gsm_a_rr_pow_cmd_atc_value  = {
4932   "Sending of Handover access is optional",
4933   "Sending of Handover access is mandatory"
4934 };
4935 /*
4936  *  The EPC mode field (octet 2) indicates whether the assigned channel(s) 
4937  *  shall be in enhanced power control (EPC) mode. It is only valid for channels
4938  *  on which EPC may be used. It is coded as follows:
4939 */
4940 static const true_false_string gsm_a_rr_pow_cmd_epc_value  = {
4941   "Channel(s) in EPC mode",
4942   "Channel(s) not in EPC mode"
4943 };
4944 /*
4945  * FPC_EPC (octet 2)
4946  * The FPC_EPC field (octet 2) has different interpretation depending
4947  *              on the channel mode     of the assigned channel (s) and the value 
4948  *              of the EPC mode field.
4949  * If the channel mode is such that fast power control (FPC) may be 
4950  *              used, the FPC_EPC field indicates whether Fast Measurement
4951  *              Reporting and Power Control mechanism is used.
4952  *              It is coded as follows:
4953  * Value 0      FPC not in use
4954  *       1      FPC in use
4955  * If the channel mode is such that EPC may be used and the EPC mode 
4956  *              field indicates that the channel is in EPC mode, the FPC_EPC
4957  *              field indicates whether EPC shall be used for uplink power control. 
4958  * It is coded as follows:
4959  * Value 0      EPC not in use for uplink power control
4960  *               1      EPC in use for uplink power control
4961  *
4962  */
4963 static const true_false_string gsm_a_rr_pow_cmd_fpcepc_value  = {
4964   "FPC in use/EPC in use for uplink power control",
4965   "FPC not in use/C not in use for uplink power control"
4966 };
4967
4968 /*
4969  * Power level (octet 2)The power level field is coded as the binaryRepresentation 
4970  * of the "power control level", see 3GPP TS 3GPP TS 45.005. This value shall be used 
4971  * by the mobile station According to 3GPP TS 45.008.Range: 0 to 31.
4972  */
4973
4974 static guint8
4975 de_rr_pow_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4976 {
4977     proto_tree  *subtree;
4978     proto_item  *item;
4979     guint32     curr_offset;
4980
4981     len = len;
4982     curr_offset = offset;
4983
4984         item =
4985         proto_tree_add_text(tree,
4986             tvb, curr_offset, 1,
4987             gsm_dtap_elem_strings[DE_RR_POW_CMD].strptr);
4988
4989     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_POW_CMD]);
4990
4991     proto_tree_add_item(subtree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
4992         /*EPC mode */   
4993     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_epc, tvb, curr_offset, 1, FALSE);
4994         /*FPC_EPC*/
4995     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_fpcepc, tvb, curr_offset, 1, FALSE);
4996         /*POWER LEVEL*/
4997     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_powlev, tvb, curr_offset, 1, FALSE);
4998         
4999         curr_offset = curr_offset + 1;
5000
5001     return(curr_offset - offset);
5002 }
5003
5004 /*
5005  * [3] 10.5.2.28a Power Command and access type
5006  */
5007 static guint8
5008 de_rr_pow_cmd_and_acc_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5009 {
5010     proto_tree  *subtree;
5011     proto_item  *item;
5012     guint32     curr_offset;
5013
5014     len = len;
5015     curr_offset = offset;
5016
5017         item =
5018         proto_tree_add_text(tree,
5019             tvb, curr_offset, 1,
5020             gsm_dtap_elem_strings[DE_RR_POW_CMD_AND_ACC_TYPE].strptr);
5021
5022     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_POW_CMD_AND_ACC_TYPE]);
5023
5024         /*ATC */        
5025     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_atc, tvb, curr_offset, 1, FALSE);
5026         /*EPC mode */   
5027     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_epc, tvb, curr_offset, 1, FALSE);
5028         /*FPC_EPC*/
5029     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_fpcepc, tvb, curr_offset, 1, FALSE);
5030         /*POWER LEVEL*/
5031     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_powlev, tvb, curr_offset, 1, FALSE);
5032         
5033         curr_offset = curr_offset + 1;
5034
5035     return(curr_offset - offset);
5036 }
5037 /*
5038  * [3] 10.5.2.29 RACH Control Parameters
5039  * [3] 10.5.2.30 Request Reference
5040  */
5041
5042 /*
5043  * [3] 10.5.2.31
5044  */
5045 guint8
5046 de_rr_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5047 {
5048     guint32     curr_offset;
5049
5050     len = len;
5051     curr_offset = offset;
5052
5053         proto_tree_add_item(tree, hf_gsm_a_rr_RR_cause, tvb, curr_offset, 1, FALSE);
5054
5055     curr_offset++;
5056
5057     return(curr_offset - offset);
5058 }
5059 /*
5060  * [3] 10.5.2.32 SI 1 Rest Octets
5061  * [3] 10.5.2.33 SI 2bis Rest Octets 
5062  * [3] 10.5.2.33a SI 2ter Rest Octets
5063  * [3] 10.5.2.33b SI 2quater Rest Octets
5064  * [3] 10.5.2.34 SI 3 Rest Octets
5065  * [3] 10.5.2.35 SI 4 Rest Octets
5066  * [3] 10.5.2.35a SI 6 Rest Octets
5067  * [3] 10.5.2.36 SI 7 Rest Octets
5068  * [3] 10.5.2.37 SI 8 Rest Octets
5069  * [3] 10.5.2.37a SI 9 Rest Octets
5070  * [3] 10.5.2.37b SI 13 Rest Octets
5071  * [3] 10.5.2.37c (void)
5072  * [3] 10.5.2.37d (void)
5073  * [3] 10.5.2.37e SI 16 Rest Octets
5074  * [3] 10.5.2.37f SI 17 Rest Octets
5075  * [3] 10.5.2.37g SI 19 Rest Octets
5076  * [3] 10.5.2.37h SI 18 Rest Octets
5077  * [3] 10.5.2.37i SI 20 Rest Octets
5078  */
5079 /*
5080  * [3] 10.5.2.38 Starting Time
5081  */
5082 static guint8
5083 de_rr_starting_time(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5084 {
5085     guint32     curr_offset;
5086
5087     len = len;
5088     curr_offset = offset;
5089
5090         proto_tree_add_text(tree,tvb, curr_offset, 3 ,"Data(Not decoded)");
5091
5092         curr_offset = curr_offset + 2;
5093     return(curr_offset - offset);
5094 }
5095 /*
5096  * [3] 10.5.2.39 Synchronization Indication
5097  */
5098 /*
5099  * ROT: Report Observed Time Difference (Octet1 bit 3) */
5100
5101 static const true_false_string sm_a_rr_sync_ind_rot_value  = {
5102   "Mobile Time Difference IE shall be included in the HANDOVER COMPLETE message",
5103   "Mobile Time Difference IE shall not be included in the HANDOVER COMPLETE message"
5104 };
5105
5106 /* SI: Synchronization indication (octet 1)Bit2 1 */
5107
5108 static const value_string gsm_a_rr_sync_ind_si_vals[] = {
5109         { 0,            "Non-synchronized"},
5110         { 1,            "Synchronized"},
5111         { 2,            "Pre-synchronised"},
5112         { 3,            "Pseudo-synchronised"},
5113         { 0,    NULL }
5114 };
5115 /* NCI: Normal cell indication (octet 1, bit 4) */
5116
5117 static const true_false_string gsm_a_rr_sync_ind_nci_value  = {
5118   "Out of range timing advance shall trigger a handover failure procedure",
5119   "Out of range timing advance is ignored"
5120 };
5121
5122
5123 static guint8
5124 de_rr_sync_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5125 {
5126     guint32     curr_offset;
5127
5128     len = len;
5129     curr_offset = offset;
5130
5131         /*NCI */        
5132     proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_nci, tvb, curr_offset, 1, FALSE);
5133         /*ROT */        
5134     proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_rot, tvb, curr_offset, 1, FALSE);
5135         /*SI*/
5136     proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_si, tvb, curr_offset, 1, FALSE);
5137         
5138         curr_offset = curr_offset + 1;
5139
5140     return(curr_offset - offset);
5141 }
5142
5143 /*
5144  * [3] 10.5.2.40 Timing Advance
5145  */
5146 static guint8
5147 de_rr_timing_adv(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5148 {
5149     guint32     curr_offset;
5150
5151     len = len;
5152     curr_offset = offset;
5153
5154         proto_tree_add_item(tree, hf_gsm_a_rr_timing_adv, tvb, curr_offset, 1, FALSE);
5155         curr_offset = curr_offset + 1;
5156
5157     return(curr_offset - offset);
5158 }
5159
5160 /*
5161  * [3] 10.5.2.41 Time Difference
5162  */
5163 static guint8
5164 de_rr_time_diff(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5165 {
5166     guint32     curr_offset;
5167
5168     len = len;
5169     curr_offset = offset;
5170
5171         proto_tree_add_item(tree, hf_gsm_a_rr_time_diff, tvb, curr_offset, 1, FALSE);
5172         curr_offset = curr_offset + 1;
5173
5174     return(curr_offset - offset);
5175 }
5176 /*
5177  * [3] 10.5.2.41a TLLI
5178  * The TLLI is encoded as a binary number with a length of 4 octets. TLLI is defined in 3GPP TS 23.003
5179  */
5180 guint8
5181 de_rr_tlli(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5182 {
5183     guint32     curr_offset;
5184
5185     len = len;
5186     curr_offset = offset;
5187
5188         proto_tree_add_item(tree, hf_gsm_a_rr_tlli, tvb, curr_offset, 4, FALSE);
5189         curr_offset = curr_offset + 4;
5190
5191     return(curr_offset - offset);
5192 }
5193 /*
5194  * [3] 10.5.2.42 TMSI/P-TMSI
5195  */
5196 /*
5197  * [3] 10.5.2.42a VGCS target mode Indication
5198  */
5199 /*
5200 Target mode (octet 3)
5201 Bit     8 7
5202         0 0     dedicated mode
5203         0 1     group transmit mode
5204         Other values are reserved for future use.
5205 */
5206 static const value_string gsm_a_rr_target_mode_vals[] = {
5207         { 0,            "Dedicated mode"},
5208         { 1,            "Group transmit mode"},
5209         { 0,    NULL }
5210 };
5211 static guint8
5212 de_rr_vgcs_tar_mode_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5213 {
5214     guint32     curr_offset;
5215
5216     len = len;
5217     curr_offset = offset;
5218
5219         proto_tree_add_item(tree, hf_gsm_a_rr_target_mode, tvb, curr_offset, 1, FALSE);
5220         proto_tree_add_item(tree, hf_gsm_a_rr_group_cipher_key_number, tvb, curr_offset, 1, FALSE);
5221         curr_offset = curr_offset + 1;
5222
5223     return(curr_offset - offset);
5224 }
5225
5226 /* 
5227  * [3] 10.5.2.42b       VGCS Ciphering Parameters       
5228  */
5229 static guint8
5230 de_rr_vgcs_cip_par(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5231 {
5232     guint32     curr_offset;
5233
5234     len = len;
5235     curr_offset = offset;
5236
5237         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
5238
5239         curr_offset = curr_offset + 2;
5240     return(curr_offset - offset);
5241 }
5242 /*
5243  * [3] 10.5.2.43 Wait Indication
5244  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
5245  * [3] 10.5.2.45 EXTENDED MEASUREMENT RESULTS
5246  * [3] 10.5.2.46 Extended Measurement Frequency List
5247  */
5248 /*
5249  * [3] 10.5.2.47 Suspension Cause
5250  */
5251 /*Suspension cause value (octet 2)*/
5252 static const value_string gsm_a_rr_suspension_cause_vals[] = {
5253         { 0,            "Emergency call, mobile originating call or call re-establishment"},
5254         { 1,            "Location Area Update"},
5255         { 2,            "MO Short message service"},
5256         { 3,            "Other procedure which can be completed with an SDCCH"},
5257         { 4,            "MO Voice broadcast or group call"},
5258         { 5,            "Mobile terminating CS connection"},
5259         { 6,            "DTM not supported in the cell"},
5260         { 0,    NULL }
5261 };
5262 guint8
5263 de_rr_sus_cau(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5264 {
5265     guint32     curr_offset;
5266
5267     len = len;
5268     curr_offset = offset;
5269
5270         proto_tree_add_item(tree, hf_gsm_a_rr_suspension_cause, tvb, curr_offset, 1, FALSE);
5271
5272         curr_offset = curr_offset + 1;
5273     return(curr_offset - offset);
5274 }
5275 /*
5276  * [3] 10.5.2.48 APDU ID 
5277  * [3] 10.5.2.49 APDU Flags
5278  * [3] 10.5.2.50 APDU Data
5279  * [3] 10.5.2.51 Handover To UTRAN Command
5280  * [3] 10.5.2.52 Handover To cdma2000 Command 
5281  * [3] 10.5.2.53 (void)
5282  * [3] 10.5.2.54 (void)
5283  * [3] 10.5.2.55 (void)
5284  * [3] 10.5.2.56 3G Target Cell
5285 */
5286 /* 
5287  * [3] 10.5.2.59        Dedicated Service Information 
5288  */
5289 /*
5290 Last Segment (octet 2)
5291 bit 1
5292 0       mobile station shall not perform Service Information Sending procedure on new cell.
5293 1       mobile station shall perform Service Information Sending procedure on new cell.
5294 */
5295 static const true_false_string gsm_a_rr_last_segment_value  = {
5296   "Mobile station shall perform Service Information Sending procedure on new cell.",
5297   "mobile station shall not perform Service Information Sending procedure on new cell."
5298 };
5299 static guint8
5300 de_rr_ded_serv_inf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5301 {
5302     guint32     curr_offset;
5303
5304     len = len;
5305     curr_offset = offset;
5306
5307         proto_tree_add_item(tree, hf_gsm_a_rr_last_segment, tvb, curr_offset, 1, FALSE);
5308
5309         curr_offset = curr_offset + 3;
5310     return(curr_offset - offset);
5311 }
5312
5313
5314
5315 /*
5316  * [3] 10.5.3.1
5317  */
5318 static guint8
5319 de_auth_param_rand(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5320 {
5321     guint32     curr_offset;
5322
5323     len = len;
5324     curr_offset = offset;
5325
5326 /*
5327  * 16 octets == 128 bits
5328  */
5329 #define AUTH_PARAM_RAND_LEN     16
5330
5331     proto_tree_add_text(tree,
5332         tvb, curr_offset, AUTH_PARAM_RAND_LEN,
5333                         "RAND value: %s",
5334                         tvb_bytes_to_str(tvb, curr_offset, AUTH_PARAM_RAND_LEN));
5335
5336     curr_offset += AUTH_PARAM_RAND_LEN;
5337
5338     /* no length check possible */
5339
5340     return(curr_offset - offset);
5341 }
5342
5343 /*
5344  * [3] 10.5.3.1.1
5345  */
5346 static guint8
5347 de_auth_param_autn(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5348 {
5349     guint32     curr_offset;
5350
5351     curr_offset = offset;
5352
5353     proto_tree_add_text(tree,
5354         tvb, curr_offset, len,
5355         "AUTN value: %s",
5356         tvb_bytes_to_str(tvb, curr_offset, len));
5357
5358     curr_offset += len;
5359
5360     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5361
5362     return(curr_offset - offset);
5363 }
5364
5365 /*
5366  * [3] 10.5.3.2
5367  */
5368 static guint8
5369 de_auth_resp_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5370 {
5371     guint32     curr_offset;
5372
5373     len = len;
5374     curr_offset = offset;
5375
5376 /*
5377  * 4 octets == 32 bits
5378  */
5379 #define AUTH_PARAM_SRES_LEN     4
5380
5381     proto_tree_add_text(tree,
5382         tvb, curr_offset, AUTH_PARAM_SRES_LEN,
5383                         "SRES value: %s",
5384                         tvb_bytes_to_str(tvb, curr_offset, AUTH_PARAM_SRES_LEN));
5385
5386     curr_offset += AUTH_PARAM_SRES_LEN;
5387
5388     /* no length check possible */
5389
5390     return(curr_offset - offset);
5391 }
5392
5393 /*
5394  * [3] 10.5.3.2.1
5395  */
5396 static guint8
5397 de_auth_resp_param_ext(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5398 {
5399     guint32     curr_offset;
5400
5401     curr_offset = offset;
5402
5403     proto_tree_add_text(tree,
5404         tvb, curr_offset, len,
5405          "XRES value: %s",
5406          tvb_bytes_to_str(tvb, curr_offset, len));
5407
5408     curr_offset += len;
5409
5410     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5411
5412     return(curr_offset - offset);
5413 }
5414
5415 /*
5416  * [3] 10.5.3.2.2
5417  */
5418 static guint8
5419 de_auth_fail_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5420 {
5421     guint32     curr_offset;
5422
5423     curr_offset = offset;
5424
5425     proto_tree_add_text(tree,
5426         tvb, curr_offset, len,
5427         "AUTS value: %s",
5428         tvb_bytes_to_str(tvb, curr_offset, len));
5429
5430     curr_offset += len;
5431
5432     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5433
5434     return(curr_offset - offset);
5435 }
5436
5437 /*
5438  * [3] 10.5.3.5a
5439  */
5440 static guint8
5441 de_network_name(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5442 {
5443     guint8      oct;
5444     guint32     curr_offset;
5445     const gchar *str;
5446
5447     curr_offset = offset;
5448
5449     oct = tvb_get_guint8(tvb, curr_offset);
5450
5451     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
5452
5453     switch ((oct & 0x70) >> 4)
5454     {
5455     case 0x00: str = "Cell Broadcast data coding scheme, GSM default alphabet, language unspecified, defined in 3GPP TS 03.38"; break;
5456     case 0x01: str = "UCS2 (16 bit)"; break;
5457     default:
5458         str = "Reserved";
5459         break;
5460     }
5461
5462     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
5463     proto_tree_add_text(tree,
5464         tvb, curr_offset, 1,
5465         "%s :  Coding Scheme: %s",
5466         a_bigbuf,
5467         str);
5468
5469     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
5470     proto_tree_add_text(tree,
5471         tvb, curr_offset, 1,
5472         "%s :  Add CI: The MS should %s",
5473         a_bigbuf,
5474         (oct & 0x08) ?
5475             "add the letters for the Country's Initials and a separator (e.g. a space) to the text string" :
5476             "The MS should not add the letters for the Country's Initials to the text string");
5477
5478     switch (oct & 0x07)
5479     {
5480     case 1: str = "bit 8 is spare and set to '0' in octet n"; break;
5481     case 2: str = "bits 7 and 8 are spare and set to '0' in octet n"; break;
5482     case 3: str = "bits 6 to 8(inclusive) are spare and set to '0' in octet n"; break;
5483     case 4: str = "bits 5 to 8(inclusive) are spare and set to '0' in octet n"; break;
5484     case 5: str = "bits 4 to 8(inclusive) are spare and set to '0' in octet n"; break;
5485     case 6: str = "bits 3 to 8(inclusive) are spare and set to '0' in octet n"; break;
5486     case 7: str = "bits 2 to 8(inclusive) are spare and set to '0' in octet n"; break;
5487     default:
5488         str = "this field carries no information about the number of spare bits in octet n";
5489         break;
5490     }
5491
5492     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
5493     proto_tree_add_text(tree,
5494         tvb, curr_offset, 1,
5495         "%s :  Number of spare bits in last octet: %s",
5496         a_bigbuf,
5497         str);
5498
5499     curr_offset++;
5500
5501     NO_MORE_DATA_CHECK(len);
5502
5503     proto_tree_add_text(tree,
5504         tvb, curr_offset, len - 1,
5505         "Text string encoded according to Coding Scheme");
5506
5507     curr_offset += len - 1;
5508
5509     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5510
5511     return(curr_offset - offset);
5512 }
5513
5514 /* 3GPP TS 24.008
5515  * [3] 10.5.3.6 Reject cause
5516  */
5517 guint8
5518 de_rej_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5519 {
5520     guint8      oct;
5521     guint32     curr_offset;
5522     const gchar *str;
5523
5524     len = len;
5525     curr_offset = offset;
5526
5527     oct = tvb_get_guint8(tvb, curr_offset);
5528
5529     switch (oct)
5530     {
5531     case 0x02: str = "IMSI unknown in HLR"; break;
5532     case 0x03: str = "Illegal MS"; break;
5533     case 0x04: str = "IMSI unknown in VLR"; break;
5534     case 0x05: str = "IMEI not accepted"; break;
5535     case 0x06: str = "Illegal ME"; break;
5536     case 0x0b: str = "PLMN not allowed"; break;
5537     case 0x0c: str = "Location Area not allowed"; break;
5538     case 0x0d: str = "Roaming not allowed in this location area"; break;
5539     case 0x0f: str = "No Suitable Cells In Location Area"; break;
5540     case 0x11: str = "Network failure"; break;
5541     case 0x14: str = "MAC failure"; break;
5542     case 0x15: str = "Synch failure"; break;
5543     case 0x16: str = "Congestion"; break;
5544     case 0x17: str = "GSM authentication unacceptable"; break;
5545     case 0x20: str = "Service option not supported"; break;
5546     case 0x21: str = "Requested service option not subscribed"; break;
5547     case 0x22: str = "Service option temporarily out of order"; break;
5548     case 0x26: str = "Call cannot be identified"; break;
5549     case 0x5f: str = "Semantically incorrect message"; break;
5550     case 0x60: str = "Invalid mandatory information"; break;
5551     case 0x61: str = "Message type non-existent or not implemented"; break;
5552     case 0x62: str = "Message type not compatible with the protocol state"; break;
5553     case 0x63: str = "Information element non-existent or not implemented"; break;
5554     case 0x64: str = "Conditional IE error"; break;
5555     case 0x65: str = "Message not compatible with the protocol state"; break;
5556     case 0x6f: str = "Protocol error, unspecified"; break;
5557     default:
5558         switch (is_uplink)
5559         {
5560         case IS_UPLINK_FALSE:
5561             str = "Service option temporarily out of order";
5562             break;
5563         default:
5564             str = "Protocol error, unspecified";
5565             break;
5566         }
5567         break;
5568     }
5569
5570     proto_tree_add_text(tree,
5571         tvb, curr_offset, 1,
5572         "Reject Cause value: 0x%02x (%u) %s",
5573         oct,
5574         oct,
5575         str);
5576
5577     curr_offset++;
5578
5579     /* no length check possible */
5580
5581     return(curr_offset - offset);
5582 }
5583
5584 /*
5585  * [3] 10.5.3.8
5586  */
5587 static guint8
5588 de_time_zone(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5589 {
5590     guint8      oct;
5591     guint32     curr_offset;
5592     char sign;
5593
5594     len = len;
5595     curr_offset = offset;
5596
5597         /* 3GPP TS 23.040 version 6.6.0 Release 6 
5598          * 9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
5599          * :
5600          * The Time Zone indicates the difference, expressed in quarters of an hour, 
5601          * between the local time and GMT. In the first of the two semi-octets, 
5602          * the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field)
5603          * represents the algebraic sign of this difference (0: positive, 1: negative).
5604          */
5605
5606     oct = tvb_get_guint8(tvb, curr_offset);
5607     sign = (oct & 0x08)?'-':'+';
5608     oct = (oct >> 4) + (oct & 0x07) * 10;
5609
5610     proto_tree_add_text(tree,
5611         tvb, offset, 1,
5612         "Timezone: GMT %c %d hours %d minutes",
5613         sign, oct / 4, oct % 4 * 15);
5614     curr_offset++;
5615
5616     /* no length check possible */
5617
5618     return(curr_offset - offset);
5619 }
5620
5621 /*
5622  * [3] 10.5.3.9
5623  */
5624 static guint8
5625 de_time_zone_time(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5626 {
5627     guint8      oct, oct2, oct3;
5628     guint32     curr_offset;
5629     char sign;
5630
5631     len = len;
5632     curr_offset = offset;
5633
5634     oct = tvb_get_guint8(tvb, curr_offset);
5635     oct2 = tvb_get_guint8(tvb, curr_offset+1);
5636     oct3 = tvb_get_guint8(tvb, curr_offset+2);
5637
5638     proto_tree_add_text(tree,
5639         tvb, curr_offset, 3,
5640         "Year %u%u, Month %u%u, Day %u%u",
5641         oct & 0x0f,
5642         (oct & 0xf0) >> 4,
5643         oct2 & 0x0f,
5644         (oct2 & 0xf0) >> 4,
5645         oct3 & 0x0f,
5646         (oct3 & 0xf0) >> 4);
5647
5648     curr_offset += 3;
5649
5650     oct = tvb_get_guint8(tvb, curr_offset);
5651     oct2 = tvb_get_guint8(tvb, curr_offset+1);
5652     oct3 = tvb_get_guint8(tvb, curr_offset+2);
5653
5654     proto_tree_add_text(tree,
5655         tvb, curr_offset, 3,
5656         "Hour %u%u, Minutes %u%u, Seconds %u%u",
5657         oct & 0x0f,
5658         (oct & 0xf0) >> 4,
5659         oct2 & 0x0f,
5660         (oct2 & 0xf0) >> 4,
5661         oct3 & 0x0f,
5662         (oct3 & 0xf0) >> 4);
5663
5664     curr_offset += 3;
5665
5666         /* 3GPP TS 23.040 version 6.6.0 Release 6 
5667          * 9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
5668          * :
5669          * The Time Zone indicates the difference, expressed in quarters of an hour, 
5670          * between the local time and GMT. In the first of the two semi-octets, 
5671          * the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field)
5672          * represents the algebraic sign of this difference (0: positive, 1: negative).
5673          */
5674
5675     oct = tvb_get_guint8(tvb, curr_offset);
5676     sign = (oct & 0x08)?'-':'+';
5677     oct = (oct >> 4) + (oct & 0x07) * 10;
5678
5679     proto_tree_add_text(tree,
5680         tvb, offset, 1,
5681         "Timezone: GMT %c %d hours %d minutes",
5682         sign, oct / 4, oct % 4 * 15);
5683
5684     curr_offset++;
5685
5686     /* no length check possible */
5687
5688     return(curr_offset - offset);
5689 }
5690
5691 /*
5692  * [3] 10.5.3.11 3GPP TS 24.008 version 6.8.0 Release 6
5693  */
5694 static guint8
5695 de_lsa_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5696 {
5697     guint32     curr_offset;
5698
5699     curr_offset = offset;
5700
5701         if (len == 0){
5702                 proto_tree_add_text(tree,tvb, curr_offset, len,"LSA ID not included");
5703         }else{
5704                 proto_tree_add_item(tree, hf_gsm_a_lsa_id, tvb, curr_offset, 3, FALSE);
5705         }
5706
5707     curr_offset += len;
5708
5709     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5710
5711     return(curr_offset - offset);
5712 }
5713
5714 /*
5715  * [3] 10.5.3.12
5716  */
5717 static guint8
5718 de_day_saving_time(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5719 {
5720     guint8      oct;
5721     guint32     curr_offset;
5722     const gchar *str;
5723
5724     curr_offset = offset;
5725
5726     oct = tvb_get_guint8(tvb, curr_offset);
5727
5728     other_decode_bitfield_value(a_bigbuf, oct, 0xfc, 8);
5729     proto_tree_add_text(tree,
5730         tvb, curr_offset, 1,
5731         "%s :  Spare",
5732         a_bigbuf);
5733
5734     switch (oct & 0x03)
5735     {
5736     case 0: str = "No adjustment for Daylight Saving Time"; break;
5737     case 1: str = "+1 hour adjustment for Daylight Saving Time"; break;
5738     case 2: str = "+2 hours adjustment for Daylight Saving Time"; break;
5739     default:
5740         str = "Reserved";
5741         break;
5742     }
5743
5744     other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
5745     proto_tree_add_text(tree,
5746         tvb, curr_offset, 1,
5747         "%s :  %s",
5748         a_bigbuf,
5749         str);
5750
5751     curr_offset++;
5752
5753     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5754
5755     return(curr_offset - offset);
5756 }
5757
5758 /*
5759  * [3] 10.5.4.4
5760  */
5761 static guint8
5762 de_aux_states(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5763 {
5764     guint8      oct;
5765     guint32     curr_offset;
5766     const gchar *str;
5767
5768     curr_offset = offset;
5769
5770     oct = tvb_get_guint8(tvb, curr_offset);
5771
5772     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
5773
5774     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
5775     proto_tree_add_text(tree,
5776         tvb, curr_offset, 1,
5777         "%s :  Spare",
5778         a_bigbuf);
5779
5780     switch ((oct & 0x0c) >> 2)
5781     {
5782     case 0: str = "Idle"; break;
5783     case 1: str = "Hold request"; break;
5784     case 2: str = "Call held"; break;
5785     default:
5786         str = "Retrieve request";
5787         break;
5788     }
5789
5790     other_decode_bitfield_value(a_bigbuf, oct, 0x0c, 8);
5791     proto_tree_add_text(tree,
5792         tvb, curr_offset, 1,
5793         "%s :  Hold auxiliary state: %s",
5794         a_bigbuf,
5795         str);
5796
5797     switch (oct & 0x03)
5798     {
5799     case 0: str = "Idle"; break;
5800     case 1: str = "MPTY request"; break;
5801     case 2: str = "Call in MPTY"; break;
5802     default:
5803         str = "Split request";
5804         break;
5805     }
5806
5807     other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
5808     proto_tree_add_text(tree,
5809         tvb, curr_offset, 1,
5810         "%s :  Multi party auxiliary state: %s",
5811         a_bigbuf,
5812         str);
5813
5814     curr_offset++;
5815
5816     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5817
5818     return(curr_offset - offset);
5819 }
5820
5821 /*
5822  * [3] 10.5.4.5
5823  */
5824 static guint8
5825 de_bearer_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
5826 {
5827     guint8      oct;
5828     guint8      itc;
5829     gboolean    extended;
5830     guint32     curr_offset;
5831     guint32     saved_offset;
5832     proto_tree  *subtree;
5833     proto_item  *item;
5834     const gchar *str;
5835
5836 #define DE_BC_ITC_SPEECH        0x00
5837 #define DE_BC_ITC_UDI           0x01
5838 #define DE_BC_ITC_EX_PLMN       0x02
5839 #define DE_BC_ITC_FASC_G3       0x03
5840 #define DE_BC_ITC_OTHER_ITC     0x05
5841 #define DE_BC_ITC_RSVD_NET      0x07
5842
5843     curr_offset = offset;
5844
5845     oct = tvb_get_guint8(tvb, curr_offset);
5846
5847     /* octet 3 */
5848
5849     /*
5850      * warning, bearer cap uses extended values that
5851      * are reversed from other parameters!
5852      */
5853     extended = (oct & 0x80) ? FALSE : TRUE;
5854     itc = oct & 0x07;
5855
5856     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
5857     proto_tree_add_text(tree,
5858         tvb, curr_offset, 1,
5859         "%s :  Extension: %s",
5860         a_bigbuf,
5861         extended ? "extended" : "not extended");
5862
5863     switch (is_uplink)
5864     {
5865     case IS_UPLINK_FALSE:
5866         str = "Spare";
5867         break;
5868
5869     case IS_UPLINK_TRUE:
5870         /*
5871          * depends on Information transfer capability
5872          */
5873         switch (itc)
5874         {
5875         case DE_BC_ITC_SPEECH:
5876             if (extended)
5877             {
5878                 switch ((oct & 0x60) >> 5)
5879                 {
5880                 case 1: str = "MS supports at least full rate speech version 1 but does not support half rate speech version 1"; break;
5881                 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;
5882                 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;
5883                 default:
5884                     str = "Reserved";
5885                     break;
5886                 }
5887                 break;
5888             }
5889             else
5890             {
5891                 switch ((oct & 0x60) >> 5)
5892                 {
5893                 case 1: str = "Full rate support only MS/fullrate speech version 1 supported"; break;
5894                 case 2: str = "Dual rate support MS/half rate speech version 1 preferred, full rate speech version 1 also supported"; break;
5895                 case 3: str = "Dual rate support MS/full rate speech version 1 preferred, half rate speech version 1 also supported"; break;
5896                 default:
5897                     str = "Reserved";
5898                     break;
5899                 }
5900                 break;
5901             }
5902             break;
5903
5904         default:
5905             switch ((oct & 0x60) >> 5)
5906             {
5907             case 1: str = "Full rate support only MS"; break;
5908             case 2: str = "Dual rate support MS/half rate preferred"; break;
5909             case 3: str = "Dual rate support MS/full rate preferred"; break;
5910             default:
5911                 str = "Reserved";
5912                 break;
5913             }
5914             break;
5915         }
5916         break;
5917
5918     default:
5919         str = "(dissect problem)";
5920         break;
5921     }
5922
5923     other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
5924     proto_tree_add_text(tree,
5925         tvb, curr_offset, 1,
5926         "%s :  Radio channel requirement: %s",
5927         a_bigbuf,
5928         str);
5929
5930     other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
5931     proto_tree_add_text(tree,
5932         tvb, curr_offset, 1,
5933         "%s :  Coding standard: %s",
5934         a_bigbuf,
5935         (oct & 0x10) ? "reserved" : "GSM standardized coding");
5936
5937     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
5938     proto_tree_add_text(tree,
5939         tvb, curr_offset, 1,
5940         "%s :  Transfer mode: %s",
5941         a_bigbuf,
5942         (oct & 0x08) ? "packet" : "circuit");
5943
5944     switch (itc)
5945     {
5946     case DE_BC_ITC_SPEECH: str = "Speech"; break;
5947     case DE_BC_ITC_UDI: str = "Unrestricted digital information"; break;
5948     case DE_BC_ITC_EX_PLMN: str = "3.1 kHz audio, ex PLMN"; break;
5949     case DE_BC_ITC_FASC_G3: str = "Facsimile group 3"; break;
5950     case DE_BC_ITC_OTHER_ITC: str = "Other ITC (See Octet 5a)"; break;
5951     case DE_BC_ITC_RSVD_NET: str = "Reserved, to be used in the network"; break;
5952     default:
5953         str = "Reserved";
5954         break;
5955     }
5956
5957     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
5958     proto_tree_add_text(tree,
5959         tvb, curr_offset, 1,
5960         "%s :  Information transfer capability: %s",
5961         a_bigbuf,
5962         str);
5963
5964     if (add_string)
5965         g_snprintf(add_string, string_len, " - (%s)", str);
5966
5967     curr_offset++;
5968
5969     NO_MORE_DATA_CHECK(len);
5970
5971     switch (itc)
5972     {
5973     case DE_BC_ITC_SPEECH:
5974         /* octets 3a */
5975
5976         item =
5977             proto_tree_add_text(tree,
5978                 tvb, curr_offset, -1,
5979                 "Octets 3a - Speech Versions");
5980
5981         subtree = proto_item_add_subtree(item, ett_bc_oct_3a);
5982
5983         saved_offset = curr_offset;
5984
5985         do
5986         {
5987             oct = tvb_get_guint8(tvb, curr_offset);
5988
5989             extended = (oct & 0x80) ? FALSE : TRUE;
5990
5991             other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
5992             proto_tree_add_text(subtree,
5993                 tvb, curr_offset, 1,
5994                 "%s :  Extension: %s",
5995                 a_bigbuf,
5996                 extended ? "extended" : "not extended");
5997
5998             other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
5999             proto_tree_add_text(subtree,
6000                 tvb, curr_offset, 1,
6001                 "%s :  Coding: octet used for %s",
6002                 a_bigbuf,
6003                 (oct & 0x40) ? "other extension of octet 3" :
6004                     "extension of information transfer capability");
6005
6006             other_decode_bitfield_value(a_bigbuf, oct, 0x30, 8);
6007             proto_tree_add_text(subtree,
6008                 tvb, curr_offset, 1,
6009                 "%s :  Spare",
6010                 a_bigbuf);
6011
6012             switch (oct & 0x0f)
6013             {
6014             case 0: str = "GSM full rate speech version 1"; break;
6015             case 2: str = "GSM full rate speech version 2"; break;
6016             case 4: str = "GSM full rate speech version 3"; break;
6017             case 1: str = "GSM half rate speech version 1"; break;
6018             case 5: str = "GSM half rate speech version 3"; break;
6019             default:
6020                 str = "Speech version TBD";
6021                 break;
6022             }
6023
6024             other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6025             proto_tree_add_text(subtree,
6026                 tvb, curr_offset, 1,
6027                 "%s :  Speech version indication: %s",
6028                 a_bigbuf,
6029                 str);
6030
6031             curr_offset++;
6032         }
6033         while (extended &&
6034             ((len - (curr_offset - offset)) > 0));
6035
6036         proto_item_set_len(item, curr_offset - saved_offset);
6037         break;
6038
6039     default:
6040         /* octet 4 */
6041
6042         item =
6043             proto_tree_add_text(tree,
6044                 tvb, curr_offset, 1,
6045                 "Octet 4");
6046
6047         subtree = proto_item_add_subtree(item, ett_bc_oct_4);
6048
6049         oct = tvb_get_guint8(tvb, curr_offset);
6050
6051         extended = (oct & 0x80) ? FALSE : TRUE;
6052
6053         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6054         proto_tree_add_text(subtree,
6055             tvb, curr_offset, 1,
6056             "%s :  Extension: %s",
6057             a_bigbuf,
6058             extended ? "extended" : "not extended");
6059
6060         other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6061         proto_tree_add_text(subtree,
6062             tvb, curr_offset, 1,
6063             "%s :  Compression: data compression %s%s",
6064             a_bigbuf,
6065             (oct & 0x40) ? "" : "not ",
6066             is_uplink ? "allowed" : "possible");
6067
6068         switch ((oct & 0x30) >> 4)
6069         {
6070         case 0x00: str = "Service data unit integrity"; break;
6071         case 0x03: str = "Unstructured"; break;
6072         default:
6073             str = "Reserved";
6074             break;
6075         }
6076
6077         other_decode_bitfield_value(a_bigbuf, oct, 0x30, 8);
6078         proto_tree_add_text(subtree,
6079             tvb, curr_offset, 1,
6080             "%s :  Structure: %s",
6081             a_bigbuf,
6082             str);
6083
6084         other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
6085         proto_tree_add_text(subtree,
6086             tvb, curr_offset, 1,
6087             "%s :  Duplex mode: %s",
6088             a_bigbuf,
6089             (oct & 0x08) ? "Full" : "Half");
6090
6091         other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
6092         proto_tree_add_text(subtree,
6093             tvb, curr_offset, 1,
6094             "%s :  Configuration: %s",
6095             a_bigbuf,
6096             (oct & 0x04) ? "Reserved" : "Point-to-point");
6097
6098         other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
6099         proto_tree_add_text(subtree,
6100             tvb, curr_offset, 1,
6101             "%s :  NIRR: %s",
6102             a_bigbuf,
6103             (oct & 0x02) ?
6104                 "Data up to and including 4.8 kb/s, full rate, non-transparent, 6 kb/s radio interface rate is requested" :
6105                 "No meaning is associated with this value");
6106
6107         other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
6108         proto_tree_add_text(subtree,
6109             tvb, curr_offset, 1,
6110             "%s :  Establishment: %s",
6111             a_bigbuf,
6112             (oct & 0x01) ? "Reserved" : "Demand");
6113
6114         curr_offset++;
6115
6116         NO_MORE_DATA_CHECK(len);
6117
6118         /* octet 5 */
6119
6120         item =
6121             proto_tree_add_text(tree,
6122                 tvb, curr_offset, 1,
6123                 "Octet 5");
6124
6125         subtree = proto_item_add_subtree(item, ett_bc_oct_5);
6126
6127         oct = tvb_get_guint8(tvb, curr_offset);
6128
6129         extended = (oct & 0x80) ? FALSE : TRUE;
6130
6131         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6132         proto_tree_add_text(subtree,
6133             tvb, curr_offset, 1,
6134             "%s :  Extension: %s",
6135             a_bigbuf,
6136             extended ? "extended" : "not extended");
6137
6138         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6139         proto_tree_add_text(subtree,
6140             tvb, curr_offset, 1,
6141             "%s :  Access Identity: %s",
6142             a_bigbuf,
6143             (oct & 0x60) ? "Reserved" : "Octet identifier");
6144
6145         switch ((oct & 0x18) >> 3)
6146         {
6147         case 0x00: str = "No rate adaption"; break;
6148         case 0x01: str = "V.110, I.460/X.30 rate adaptation"; break;
6149         case 0x02: str = "ITU-T X.31 flag stuffing"; break;
6150         default:
6151             str = "Other rate adaption (see octet 5a)"; break;
6152             break;
6153         }
6154
6155         other_decode_bitfield_value(a_bigbuf, oct, 0x18, 8);
6156         proto_tree_add_text(subtree,
6157             tvb, curr_offset, 1,
6158             "%s :  Rate Adaption: %s",
6159             a_bigbuf,
6160             str);
6161
6162         switch (oct & 0x07)
6163         {
6164         case 0x01: str = "I.440/450"; break;
6165         case 0x02: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6166         case 0x03: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6167         case 0x04: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6168         case 0x05: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6169         case 0x06: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6170         default:
6171             str = "Reserved"; break;
6172             break;
6173         }
6174
6175         other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6176         proto_tree_add_text(subtree,
6177             tvb, curr_offset, 1,
6178             "%s :  Signalling Access Protocol: %s",
6179             a_bigbuf,
6180             str);
6181
6182         curr_offset++;
6183
6184         NO_MORE_DATA_CHECK(len);
6185
6186         if (!extended) goto bc_octet_6;
6187
6188         /* octet 5a */
6189
6190         item =
6191             proto_tree_add_text(tree,
6192                 tvb, curr_offset, 1,
6193                 "Octet 5a");
6194
6195         subtree = proto_item_add_subtree(item, ett_bc_oct_5a);
6196
6197         oct = tvb_get_guint8(tvb, curr_offset);
6198
6199         extended = (oct & 0x80) ? FALSE : TRUE;
6200
6201         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6202         proto_tree_add_text(subtree,
6203             tvb, curr_offset, 1,
6204             "%s :  Extension: %s",
6205             a_bigbuf,
6206             extended ? "extended" : "not extended");
6207
6208         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6209         proto_tree_add_text(subtree,
6210             tvb, curr_offset, 1,
6211             "%s :  Other ITC: %s",
6212             a_bigbuf,
6213             (oct & 0x60) ? "Reserved" : "Restricted digital information");
6214
6215         switch ((oct & 0x18) >> 3)
6216         {
6217         case 0x00: str = "V.120"; break;
6218         case 0x01: str = "H.223 & H.245"; break;
6219         case 0x02: str = "PIAFS"; break;
6220         default:
6221             str = "Reserved";
6222             break;
6223         }
6224
6225         other_decode_bitfield_value(a_bigbuf, oct, 0x18, 8);
6226         proto_tree_add_text(subtree,
6227             tvb, curr_offset, 1,
6228             "%s :  Other Rate Adaption: %s",
6229             a_bigbuf,
6230             str);
6231
6232         other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6233         proto_tree_add_text(subtree,
6234             tvb, curr_offset, 1,
6235             "%s :  Spare",
6236             a_bigbuf);
6237
6238         curr_offset++;
6239
6240         NO_MORE_DATA_CHECK(len);
6241
6242         if (!extended) goto bc_octet_6;
6243
6244         /* octet 5b */
6245
6246         item =
6247             proto_tree_add_text(tree,
6248                 tvb, curr_offset, 1,
6249                 "Octet 5b");
6250
6251         subtree = proto_item_add_subtree(item, ett_bc_oct_5b);
6252
6253         oct = tvb_get_guint8(tvb, curr_offset);
6254
6255         extended = (oct & 0x80) ? FALSE : TRUE;
6256
6257         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6258         proto_tree_add_text(subtree,
6259             tvb, curr_offset, 1,
6260             "%s :  Extension: %s",
6261             a_bigbuf,
6262             extended ? "extended" : "not extended");
6263
6264         other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6265         proto_tree_add_text(subtree,
6266             tvb, curr_offset, 1,
6267             "%s :  Rate Adaption Header: %sincluded",
6268             a_bigbuf,
6269             (oct & 0x40) ? "" : "not ");
6270
6271         other_decode_bitfield_value(a_bigbuf, oct, 0x20, 8);
6272         proto_tree_add_text(subtree,
6273             tvb, curr_offset, 1,
6274             "%s :  Multiple frame establishment support in data link: %s",
6275             a_bigbuf,
6276             (oct & 0x20) ? "Supported" : "Not supported, only UI frames allowed");
6277
6278         other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6279         proto_tree_add_text(subtree,
6280             tvb, curr_offset, 1,
6281             "%s :  Mode of operation: %s",
6282             a_bigbuf,
6283             (oct & 0x10) ? "Protocol sensitive" : "Bit transparent");
6284
6285         other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
6286         proto_tree_add_text(subtree,
6287             tvb, curr_offset, 1,
6288             "%s :  Logical link identifier negotiation: %s",
6289             a_bigbuf,
6290             (oct & 0x08) ? "Full protocol negotiation" : "Default, LLI=256 only");
6291
6292         other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
6293         proto_tree_add_text(subtree,
6294             tvb, curr_offset, 1,
6295             "%s :  Assignor/Assignee: Message originator is '%s'",
6296             a_bigbuf,
6297             (oct & 0x04) ? "assignor only" : "default assignee");
6298
6299         other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
6300         proto_tree_add_text(subtree,
6301             tvb, curr_offset, 1,
6302             "%s :  In band/Out of band negotiation: Negotiation is done %s",
6303             a_bigbuf,
6304             (oct & 0x02) ?
6305                 "with USER INFORMATION messages on a temporary signalling connection" :
6306                 "in-band using logical link zero");
6307
6308         other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
6309         proto_tree_add_text(subtree,
6310             tvb, curr_offset, 1,
6311             "%s :  Spare",
6312             a_bigbuf);
6313
6314         curr_offset++;
6315
6316         NO_MORE_DATA_CHECK(len);
6317
6318 bc_octet_6:
6319
6320         /* octet 6 */
6321
6322         item =
6323             proto_tree_add_text(tree,
6324                 tvb, curr_offset, 1,
6325                 "Octet 6");
6326
6327         subtree = proto_item_add_subtree(item, ett_bc_oct_6);
6328
6329         oct = tvb_get_guint8(tvb, curr_offset);
6330
6331         extended = (oct & 0x80) ? FALSE : TRUE;
6332
6333         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6334         proto_tree_add_text(subtree,
6335             tvb, curr_offset, 1,
6336             "%s :  Extension: %s",
6337             a_bigbuf,
6338             extended ? "extended" : "not extended");
6339
6340         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6341         proto_tree_add_text(subtree,
6342             tvb, curr_offset, 1,
6343             "%s :  Layer 1 Identity: %s",
6344             a_bigbuf,
6345             ((oct & 0x60) == 0x20) ? "Octet identifier" : "Reserved");
6346
6347         other_decode_bitfield_value(a_bigbuf, oct, 0x1e, 8);
6348         proto_tree_add_text(subtree,
6349             tvb, curr_offset, 1,
6350             "%s :  User information layer 1 protocol: %s",
6351             a_bigbuf,
6352             (oct & 0x1e) ? "Reserved" : "Default layer 1 protocol");
6353
6354         other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
6355         proto_tree_add_text(subtree,
6356             tvb, curr_offset, 1,
6357             "%s :  Synchronous/asynchronous: %s",
6358             a_bigbuf,
6359             (oct & 0x01) ? "Asynchronous" : "Synchronous");
6360
6361         curr_offset++;
6362
6363         NO_MORE_DATA_CHECK(len);
6364
6365         if (!extended) goto bc_octet_7;
6366
6367         /* octet 6a */
6368
6369         item =
6370             proto_tree_add_text(tree,
6371                 tvb, curr_offset, 1,
6372                 "Octet 6a");
6373
6374         subtree = proto_item_add_subtree(item, ett_bc_oct_6a);
6375
6376         oct = tvb_get_guint8(tvb, curr_offset);
6377
6378         extended = (oct & 0x80) ? FALSE : TRUE;
6379
6380         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6381         proto_tree_add_text(subtree,
6382             tvb, curr_offset, 1,
6383             "%s :  Extension: %s",
6384             a_bigbuf,
6385             extended ? "extended" : "not extended");
6386
6387         other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6388         proto_tree_add_text(subtree,
6389             tvb, curr_offset, 1,
6390             "%s :  Number of Stop Bits: %s",
6391             a_bigbuf,
6392             (oct & 0x40) ? "2" : "1");
6393
6394         other_decode_bitfield_value(a_bigbuf, oct, 0x20, 8);
6395         proto_tree_add_text(subtree,
6396             tvb, curr_offset, 1,
6397             "%s :  Negotiation: %s",
6398             a_bigbuf,
6399             (oct & 0x20) ? "Reserved" : "In-band negotiation not possible");
6400
6401         other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6402         proto_tree_add_text(subtree,
6403             tvb, curr_offset, 1,
6404             "%s :  Number of data bits excluding parity bit if present: %s",
6405             a_bigbuf,
6406             (oct & 0x10) ? "8" : "7");
6407
6408         switch (oct & 0x0f)
6409         {
6410         case 0x01: str = "0.3 kbit/s Recommendation X.1 and V.110"; break;
6411         case 0x02: str = "1.2 kbit/s Recommendation X.1 and V.110"; break;
6412         case 0x03: str = "2.4 kbit/s Recommendation X.1 and V.110"; break;
6413         case 0x04: str = "4.8 kbit/s Recommendation X.1 and V.110"; break;
6414         case 0x05: str = "9.6 kbit/s Recommendation X.1 and V.110"; break;
6415         case 0x06: str = "12.0 kbit/s transparent (non compliance with X.1 and V.110)"; break;
6416         case 0x07: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6417         default:
6418             str = "Reserved";
6419             break;
6420         }
6421
6422         other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6423         proto_tree_add_text(subtree,
6424             tvb, curr_offset, 1,
6425             "%s :  User rate: %s",
6426             a_bigbuf,
6427             str);
6428
6429         curr_offset++;
6430
6431         NO_MORE_DATA_CHECK(len);
6432
6433         if (!extended) goto bc_octet_7;
6434
6435         /* octet 6b */
6436
6437         item =
6438             proto_tree_add_text(tree,
6439                 tvb, curr_offset, 1,
6440                 "Octet 6b");
6441
6442         subtree = proto_item_add_subtree(item, ett_bc_oct_6b);
6443
6444         oct = tvb_get_guint8(tvb, curr_offset);
6445
6446         extended = (oct & 0x80) ? FALSE : TRUE;
6447
6448         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6449         proto_tree_add_text(subtree,
6450             tvb, curr_offset, 1,
6451             "%s :  Extension: %s",
6452             a_bigbuf,
6453             extended ? "extended" : "not extended");
6454
6455         switch ((oct & 0x60) >> 5)
6456         {
6457         case 0x02: str = "8 kbit/s"; break;
6458         case 0x03: str = "16 kbit/s"; break;
6459         default:
6460             str = "Reserved";
6461             break;
6462         }
6463
6464         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6465         proto_tree_add_text(subtree,
6466             tvb, curr_offset, 1,
6467             "%s :  V.110/X.30 rate adaptation Intermediate rate: %s",
6468             a_bigbuf,
6469             str);
6470
6471         other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6472         proto_tree_add_text(subtree,
6473             tvb, curr_offset, 1,
6474             "%s :  Network independent clock (NIC) on transmission (Tx): %s to send data with network independent clock",
6475             a_bigbuf,
6476             (oct & 0x10) ? "requires" : "does not require");
6477
6478         other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
6479         proto_tree_add_text(subtree,
6480             tvb, curr_offset, 1,
6481             "%s :  Network independent clock (NIC) on reception (Rx): %s accept data with network independent clock",
6482             a_bigbuf,
6483             (oct & 0x08) ? "can" : "cannot");
6484
6485         switch (oct & 0x07)
6486         {
6487         case 0x00: str = "Odd"; break;
6488         case 0x02: str = "Even"; break;
6489         case 0x03: str = "None"; break;
6490         case 0x04: str = "Forced to 0"; break;
6491         case 0x05: str = "Forced to 1"; break;
6492         default:
6493             str = "Reserved";
6494             break;
6495         }
6496
6497         other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6498         proto_tree_add_text(subtree,
6499             tvb, curr_offset, 1,
6500             "%s :  Parity information: %s",
6501             a_bigbuf,
6502             str);
6503
6504         curr_offset++;
6505
6506         NO_MORE_DATA_CHECK(len);
6507
6508         if (!extended) goto bc_octet_7;
6509
6510         /* octet 6c */
6511
6512         item =
6513             proto_tree_add_text(tree,
6514                 tvb, curr_offset, 1,
6515                 "Octet 6c");
6516
6517         subtree = proto_item_add_subtree(item, ett_bc_oct_6c);
6518
6519         oct = tvb_get_guint8(tvb, curr_offset);
6520
6521         extended = (oct & 0x80) ? FALSE : TRUE;
6522
6523         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6524         proto_tree_add_text(subtree,
6525             tvb, curr_offset, 1,
6526             "%s :  Extension: %s",
6527             a_bigbuf,
6528             extended ? "extended" : "not extended");
6529
6530         switch ((oct & 0x60) >> 5)
6531         {
6532         case 0x01: str = "Non transparent (RLP)"; break;
6533         case 0x02: str = "Both, transparent preferred"; break;
6534         case 0x03: str = "Both, non transparent preferred"; break;
6535         default:
6536             str = "Transparent";
6537             break;
6538         }
6539
6540         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6541         proto_tree_add_text(subtree,
6542             tvb, curr_offset, 1,
6543             "%s :  Connection element: %s",
6544             a_bigbuf,
6545             str);
6546
6547         switch (oct & 0x1f)
6548         {
6549         case 0x00: str = "None"; break;
6550         case 0x01: str = "V.21"; break;
6551         case 0x02: str = "V.22"; break;
6552         case 0x03: str = "V.22 bis"; break;
6553         case 0x04: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6554         case 0x05: str = "V.26 ter"; break;
6555         case 0x06: str = "V.32"; break;
6556         case 0x07: str = "Modem for undefined interface"; break;
6557         case 0x08: str = "Autobauding type 1"; break;
6558         default:
6559             str = "Reserved";
6560             break;
6561         }
6562
6563         other_decode_bitfield_value(a_bigbuf, oct, 0x1f, 8);
6564         proto_tree_add_text(subtree,
6565             tvb, curr_offset, 1,
6566             "%s :  Modem type: %s",
6567             a_bigbuf,
6568             str);
6569
6570         curr_offset++;
6571
6572         NO_MORE_DATA_CHECK(len);
6573
6574         if (!extended) goto bc_octet_7;
6575
6576         /* octet 6d */
6577
6578         item =
6579             proto_tree_add_text(tree,
6580                 tvb, curr_offset, 1,
6581                 "Octet 6d");
6582
6583         subtree = proto_item_add_subtree(item, ett_bc_oct_6d);
6584
6585         oct = tvb_get_guint8(tvb, curr_offset);
6586
6587         extended = (oct & 0x80) ? FALSE : TRUE;
6588
6589         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6590         proto_tree_add_text(subtree,
6591             tvb, curr_offset, 1,
6592             "%s :  Extension: %s",
6593             a_bigbuf,
6594             extended ? "extended" : "not extended");
6595
6596         switch ((oct & 0x60) >> 5)
6597         {
6598         case 0x00: str = "No other modem type specified in this field"; break;
6599         case 0x02: str = "V.34"; break;
6600         default:
6601             str = "Reserved";
6602             break;
6603         }
6604
6605         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6606         proto_tree_add_text(subtree,
6607             tvb, curr_offset, 1,
6608             "%s :  Other modem type: %s",
6609             a_bigbuf,
6610             str);
6611
6612         switch (oct & 0x1f)
6613         {
6614         case 0x00: str = "Fixed network user rate not applicable/No meaning is associated with this value"; break;
6615         case 0x01: str = "9.6 kbit/s Recommendation X.1 and V.110"; break;
6616         case 0x02: str = "14.4 kbit/s Recommendation X.1 and V.110"; break;
6617         case 0x03: str = "19.2 kbit/s Recommendation X.1 and V.110"; break;
6618         case 0x04: str = "28.8 kbit/s Recommendation X.1 and V.110"; break;
6619         case 0x05: str = "38.4 kbit/s Recommendation X.1 and V.110"; break;
6620         case 0x06: str = "48.0 kbit/s Recommendation X.1 and V.110(synch)"; break;
6621         case 0x07: str = "56.0 kbit/s Recommendation X.1 and V.110(synch) /bit transparent"; break;
6622         case 0x08: str = "64.0 kbit/s bit transparent"; break;
6623         case 0x09: str = "33.6 kbit/s bit transparent"; break;
6624         case 0x0a: str = "32.0 kbit/s Recommendation I.460"; break;
6625         case 0x0b: str = "31.2 kbit/s Recommendation V.34"; break;
6626         default:
6627             str = "Reserved";
6628             break;
6629         }
6630
6631         other_decode_bitfield_value(a_bigbuf, oct, 0x1f, 8);
6632         proto_tree_add_text(subtree,
6633             tvb, curr_offset, 1,
6634             "%s :  Fixed network user rate: %s",
6635             a_bigbuf,
6636             str);
6637
6638         curr_offset++;
6639
6640         NO_MORE_DATA_CHECK(len);
6641
6642         if (!extended) goto bc_octet_7;
6643
6644         /* octet 6e */
6645
6646         item =
6647             proto_tree_add_text(tree,
6648                 tvb, curr_offset, 1,
6649                 "Octet 6e");
6650
6651         subtree = proto_item_add_subtree(item, ett_bc_oct_6e);
6652
6653         oct = tvb_get_guint8(tvb, curr_offset);
6654
6655         extended = (oct & 0x80) ? FALSE : TRUE;
6656
6657         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6658         proto_tree_add_text(subtree,
6659             tvb, curr_offset, 1,
6660             "%s :  Extension: %s",
6661             a_bigbuf,
6662             extended ? "extended" : "not extended");
6663
6664         if (is_uplink == IS_UPLINK_TRUE)
6665         {
6666             other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6667             proto_tree_add_text(subtree,
6668                 tvb, curr_offset, 1,
6669                 "%s :  Acceptable channel codings: TCH/F14.4 %sacceptable",
6670                 a_bigbuf,
6671                 (oct & 0x40) ? "" : "not ");
6672
6673             other_decode_bitfield_value(a_bigbuf, oct, 0x20, 8);
6674             proto_tree_add_text(subtree,
6675                 tvb, curr_offset, 1,
6676                 "%s :  Acceptable channel codings: Spare",
6677                 a_bigbuf);
6678
6679             other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6680             proto_tree_add_text(subtree,
6681                 tvb, curr_offset, 1,
6682                 "%s :  Acceptable channel codings: TCH/F9.6 %sacceptable",
6683                 a_bigbuf,
6684                 (oct & 0x10) ? "" : "not ");
6685
6686             other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
6687             proto_tree_add_text(subtree,
6688                 tvb, curr_offset, 1,
6689                 "%s :  Acceptable channel codings: TCH/F4.8 %sacceptable",
6690                 a_bigbuf,
6691                 (oct & 0x08) ? "" : "not ");
6692
6693             other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6694             proto_tree_add_text(subtree,
6695                 tvb, curr_offset, 1,
6696                 "%s :  Maximum number of traffic channels: %u TCH",
6697                 a_bigbuf,
6698                 (oct & 0x07) + 1);
6699         }
6700         else
6701         {
6702             other_decode_bitfield_value(a_bigbuf, oct, 0x78, 8);
6703             proto_tree_add_text(subtree,
6704                 tvb, curr_offset, 1,
6705                 "%s :  Acceptable channel codings: Spare",
6706                 a_bigbuf);
6707
6708             other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6709             proto_tree_add_text(subtree,
6710                 tvb, curr_offset, 1,
6711                 "%s :  Maximum number of traffic channels: Spare",
6712                 a_bigbuf);
6713         }
6714
6715         curr_offset++;
6716
6717         NO_MORE_DATA_CHECK(len);
6718
6719         if (!extended) goto bc_octet_7;
6720
6721         /* octet 6f */
6722
6723         item =
6724             proto_tree_add_text(tree,
6725                 tvb, curr_offset, 1,
6726                 "Octet 6f");
6727
6728         subtree = proto_item_add_subtree(item, ett_bc_oct_6f);
6729
6730         oct = tvb_get_guint8(tvb, curr_offset);
6731
6732         extended = (oct & 0x80) ? FALSE : TRUE;
6733
6734         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6735         proto_tree_add_text(subtree,
6736             tvb, curr_offset, 1,
6737             "%s :  Extension: %s",
6738             a_bigbuf,
6739             extended ? "extended" : "not extended");
6740
6741         switch ((oct & 0x70) >> 4)
6742         {
6743         case 0x00: str = "not allowed/required/applicable"; break;
6744         case 0x01: str = "up to 1 TCH/F allowed/may be requested"; break;
6745         case 0x02: str = "up to 2 TCH/F allowed/may be requested"; break;
6746         case 0x03: str = "up to 3 TCH/F allowed/may be requested"; break;
6747         case 0x04: str = "up to 4 TCH/F allowed/may be requested"; break;
6748         default:
6749             str = "up to 4 TCH/F may be requested";
6750             break;
6751         }
6752
6753         other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
6754         proto_tree_add_text(subtree,
6755             tvb, curr_offset, 1,
6756             "%s :  UIMI, User initiated modification indication: %s",
6757             a_bigbuf,
6758             str);
6759
6760         if (is_uplink == IS_UPLINK_TRUE)
6761         {
6762             switch (oct & 0x0f)
6763             {
6764             case 0x00: str = "Air interface user rate not applicable/No meaning associated with this value"; break;
6765             case 0x01: str = "9.6 kbit/s"; break;
6766             case 0x02: str = "14.4 kbit/s"; break;
6767             case 0x03: str = "19.2 kbit/s"; break;
6768             case 0x05: str = "28.8 kbit/s"; break;
6769             case 0x06: str = "38.4 kbit/s"; break;
6770             case 0x07: str = "43.2 kbit/s"; break;
6771             case 0x08: str = "57.6 kbit/s"; break;
6772             case 0x09: str = "interpreted by the network as 38.4 kbit/s in this version of the protocol"; break;
6773             case 0x0a: str = "interpreted by the network as 38.4 kbit/s in this version of the protocol"; break;
6774             case 0x0b: str = "interpreted by the network as 38.4 kbit/s in this version of the protocol"; break;
6775             case 0x0c: str = "interpreted by the network as 38.4 kbit/s in this version of the protocol"; break;
6776             default:
6777                 str = "Reserved";
6778                 break;
6779             }
6780
6781             other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6782             proto_tree_add_text(subtree,
6783                 tvb, curr_offset, 1,
6784                 "%s :  Wanted air interface user rate: %s",
6785                 a_bigbuf,
6786                 str);
6787         }
6788         else
6789         {
6790             other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6791             proto_tree_add_text(subtree,
6792                 tvb, curr_offset, 1,
6793                 "%s :  Wanted air interface user rate: Spare",
6794                 a_bigbuf);
6795         }
6796
6797         curr_offset++;
6798
6799         NO_MORE_DATA_CHECK(len);
6800
6801         if (!extended) goto bc_octet_7;
6802
6803         /* octet 6g */
6804
6805         item =
6806             proto_tree_add_text(tree,
6807                 tvb, curr_offset, 1,
6808                 "Octet 6g");
6809
6810         subtree = proto_item_add_subtree(item, ett_bc_oct_6g);
6811
6812         oct = tvb_get_guint8(tvb, curr_offset);
6813
6814         extended = (oct & 0x80) ? FALSE : TRUE;
6815
6816         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6817         proto_tree_add_text(subtree,
6818             tvb, curr_offset, 1,
6819             "%s :  Extension: %s",
6820             a_bigbuf,
6821             extended ? "extended" : "not extended");
6822
6823         if (is_uplink == IS_UPLINK_TRUE)
6824         {
6825             other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6826             proto_tree_add_text(subtree,
6827                 tvb, curr_offset, 1,
6828                 "%s :  Acceptable channel codings extended: TCH/F28.8 %sacceptable",
6829                 a_bigbuf,
6830                 (oct & 0x40) ? "" : "not ");
6831
6832             other_decode_bitfield_value(a_bigbuf, oct, 0x20, 8);
6833             proto_tree_add_text(subtree,
6834                 tvb, curr_offset, 1,
6835                 "%s :  Acceptable channel codings extended: TCH/F32.0 %sacceptable",
6836                 a_bigbuf,
6837                 (oct & 0x20) ? "" : "not ");
6838
6839             other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6840             proto_tree_add_text(subtree,
6841                 tvb, curr_offset, 1,
6842                 "%s :  Acceptable channel codings extended: TCH/F43.2 %sacceptable",
6843                 a_bigbuf,
6844                 (oct & 0x10) ? "" : "not ");
6845
6846             other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6847             proto_tree_add_text(subtree,
6848                 tvb, curr_offset, 1,
6849                 "%s :  Acceptable channel codings extended: TCH/F43.2 %sacceptable",
6850                 a_bigbuf,
6851                 (oct & 0x10) ? "" : "not ");
6852
6853             switch ((oct & 0x0c) >> 2)
6854             {
6855             case 0: str = "Channel coding symmetry preferred"; break;
6856             case 2: str = "Downlink biased channel coding asymmetry is preferred"; break;
6857             case 1: str = "Uplink biased channel coding asymmetry is preferred"; break;
6858             default:
6859                 str = "Unused, treat as Channel coding symmetry preferred";
6860                 break;
6861             }
6862
6863             other_decode_bitfield_value(a_bigbuf, oct, 0x0c, 8);
6864             proto_tree_add_text(subtree,
6865                 tvb, curr_offset, 1,
6866                 "%s :  Channel Coding Asymmetry Indication: %s",
6867                 a_bigbuf,
6868                 str);
6869         }
6870         else
6871         {
6872             other_decode_bitfield_value(a_bigbuf, oct, 0x7c, 8);
6873             proto_tree_add_text(subtree,
6874                 tvb, curr_offset, 1,
6875                 "%s :  EDGE Channel Codings: Spare",
6876                 a_bigbuf);
6877         }
6878
6879         other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
6880         proto_tree_add_text(subtree,
6881             tvb, curr_offset, 1,
6882             "%s :  Spare",
6883             a_bigbuf);
6884
6885         curr_offset++;
6886
6887         NO_MORE_DATA_CHECK(len);
6888
6889 bc_octet_7:
6890
6891         /* octet 7 */
6892
6893         item =
6894             proto_tree_add_text(tree,
6895                 tvb, curr_offset, 1,
6896                 "Octet 7");
6897
6898         subtree = proto_item_add_subtree(item, ett_bc_oct_7);
6899
6900         extended = (oct & 0x80) ? FALSE : TRUE;
6901
6902         oct = tvb_get_guint8(tvb, curr_offset);
6903
6904         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6905         proto_tree_add_text(subtree,
6906             tvb, curr_offset, 1,
6907             "%s :  Extension: %s",
6908             a_bigbuf,
6909             extended ? "extended" : "not extended");
6910
6911         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6912         proto_tree_add_text(subtree,
6913             tvb, curr_offset, 1,
6914             "%s :  Layer 2 Identity: %s",
6915             a_bigbuf,
6916             ((oct & 0x60) == 0x40) ? "Octet identifier" : "Reserved");
6917
6918         switch (oct & 0x1f)
6919         {
6920         case 0x06: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6921         case 0x08: str = "ISO 6429, codeset 0 (DC1/DC3)"; break;
6922         case 0x09: str = "Reserved: was allocated but never used in earlier phases of the protocol"; break;
6923         case 0x0a: str = "Videotex profile 1"; break;
6924         case 0x0c: str = "COPnoFlCt (Character oriented Protocol with no Flow Control mechanism)"; break;
6925         case 0x0d: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6926         default:
6927             str = "Reserved";
6928             break;
6929         }
6930
6931         other_decode_bitfield_value(a_bigbuf, oct, 0x1f, 8);
6932         proto_tree_add_text(subtree,
6933             tvb, curr_offset, 1,
6934             "%s :  User information layer 2 protocol: %s",
6935             a_bigbuf,
6936             str);
6937         break;
6938     }
6939
6940     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
6941
6942     return(curr_offset - offset);
6943 }
6944
6945 /*
6946  * [3] 10.5.4.5a
6947  */
6948 static guint8
6949 de_cc_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
6950 {
6951     guint8      oct;
6952     guint32     curr_offset;
6953
6954     curr_offset = offset;
6955
6956     oct = tvb_get_guint8(tvb, curr_offset);
6957
6958     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
6959
6960     switch ((oct & 0xf0) >> 4)
6961     {
6962     case 0:
6963         proto_tree_add_text(tree,
6964             tvb, curr_offset, 1,
6965             "%s :  Maximum number of supported bearers: 1",
6966             a_bigbuf);
6967         break;
6968
6969     default:
6970         proto_tree_add_text(tree,
6971             tvb, curr_offset, 1,
6972             "%s :  Maximum number of supported bearers: %u",
6973             a_bigbuf,
6974             (oct & 0xf0) >> 4);
6975         break;
6976     }
6977
6978     other_decode_bitfield_value(a_bigbuf, oct, 0x0c, 8);
6979     proto_tree_add_text(tree,
6980         tvb, curr_offset, 1,
6981         "%s :  Spare",
6982         a_bigbuf);
6983
6984     other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
6985     proto_tree_add_text(tree,
6986         tvb, curr_offset, 1,
6987         "%s :  PCP: the mobile station %s the Prolonged Clearing Procedure",
6988         a_bigbuf,
6989         (oct & 0x02) ? "supports" : "does not support");
6990
6991     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
6992     proto_tree_add_text(tree,
6993         tvb, curr_offset, 1,
6994         "%s :  DTMF: %s",
6995         a_bigbuf,
6996         (oct & 0x01) ?
6997             "the mobile station supports DTMF as specified in subclause 5.5.7 of TS 24.008" :
6998             "reserved for earlier versions of the protocol");
6999
7000     curr_offset++;
7001
7002     NO_MORE_DATA_CHECK(len);
7003
7004     oct = tvb_get_guint8(tvb, curr_offset);
7005
7006     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
7007     proto_tree_add_text(tree,
7008         tvb, curr_offset, 1,
7009         "%s :  Spare",
7010         a_bigbuf);
7011
7012     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
7013     proto_tree_add_text(tree,
7014         tvb, curr_offset, 1,
7015         "%s :  Maximum number of speech bearers: %u",
7016         a_bigbuf,
7017         oct & 0x0f);
7018
7019     curr_offset++;
7020
7021     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7022
7023     return(curr_offset - offset);
7024 }
7025
7026 /*
7027  * [3] 10.5.4.6
7028  */
7029 static guint8
7030 de_call_state(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7031 {
7032     guint8      oct;
7033     guint32     curr_offset;
7034     proto_tree  *subtree;
7035     proto_item  *item;
7036     const gchar *str;
7037
7038     len = len;
7039     curr_offset = offset;
7040
7041     oct = tvb_get_guint8(tvb, curr_offset);
7042
7043     item =
7044         proto_tree_add_text(tree,
7045             tvb, curr_offset, 1,
7046             gsm_dtap_elem_strings[DE_CALL_STATE].strptr);
7047
7048     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CALL_STATE]);
7049
7050     switch ((oct & 0xc0) >> 6)
7051     {
7052     case 0: str = "Coding as specified in ITU-T Rec. Q.931"; break;
7053     case 1: str = "Reserved for other international standards"; break;
7054     case 2: str = "National standard"; break;
7055     default:
7056         str = "Standard defined for the GSM PLMNS";
7057         break;
7058     }
7059
7060     other_decode_bitfield_value(a_bigbuf, oct, 0xc0, 8);
7061     proto_tree_add_text(subtree,
7062         tvb, curr_offset, 1,
7063         "%s :  Coding standard: %s",
7064         a_bigbuf,
7065         str);
7066
7067     switch (oct & 0x3f)
7068     {
7069     case 0x00: str = "UO - null                                 NO - null"; break;
7070     case 0x02: str = "U0.1- MM connection pending               N0.1- MM connection pending"; break;
7071     case 0x22: str = "U0.2- CC prompt present                   N0.2- CC connection pending"; break;
7072     case 0x23: str = "U0.3- Wait for network information        N0.3- Network answer pending"; break;
7073     case 0x24: str = "U0.4- CC-Establishment present            N0.4- CC-Establishment present"; break;
7074     case 0x25: str = "U0.5- CC-Establishment confirmed          N0.5- CC-Establishment confirmed"; break;
7075     case 0x26: str = "U0.6- Recall present                      N0.6- Recall present"; break;
7076     case 0x01: str = "U1 - call initiated                       N1 - call initiated"; break;
7077     case 0x03: str = "U3 - mobile originating call proceeding   N3 - mobile originating call proceeding"; break;
7078     case 0x04: str = "U4 - call delivered                       N4 - call delivered"; break;
7079     case 0x06: str = "U6 - call present                         N6 - call present"; break;
7080     case 0x07: str = "U7 - call received                        N7 - call received"; break;
7081     case 0x08: str = "U8 - connect request                      N8 - connect request"; break;
7082     case 0x09: str = "U9 - mobile terminating call confirmed    N9 - mobile terminating call confirmed"; break;
7083     case 0x0a: str = "U10- active                               N10- active"; break;
7084     case 0x0b: str = "U11- disconnect request"; break;
7085     case 0x0c: str = "U12- disconnect indication                N12-disconnect indication"; break;
7086     case 0x13: str = "U19- release request                      N19- release request"; break;
7087     case 0x1a: str = "U26- mobile originating modify            N26- mobile originating modify"; break;
7088     case 0x1b: str = "U27- mobile terminating modify            N27- mobile terminating modify"; break;
7089     case 0x1c: str = "                                          N28- connect indication"; break;
7090     default:
7091         str = "Unknown";
7092         break;
7093     }
7094
7095     other_decode_bitfield_value(a_bigbuf, oct, 0x3f, 8);
7096     proto_tree_add_text(subtree,
7097         tvb, curr_offset, 1,
7098         "%s :  Call state value: %s",
7099         a_bigbuf,
7100         str);
7101
7102     curr_offset++;
7103
7104     /* no length check possible */
7105
7106     return(curr_offset - offset);
7107 }
7108
7109 static const true_false_string gsm_a_extension_value = {
7110   "No Extension",
7111   "Extension"
7112 };
7113
7114 const value_string gsm_a_type_of_number_values[] = {
7115         {   0x00,       "unknown" },
7116         {   0x01,       "International Number" },
7117         {   0x02,       "National number" },
7118         {   0x03,       "Network Specific Number" },
7119         {   0x04,       "Dedicated access, short code" },
7120         {   0x05,       "Reserved" },
7121         {   0x06,       "Reserved" },
7122         {   0x07,       "Reserved for extension" },
7123         { 0, NULL }
7124 };
7125
7126 const value_string gsm_a_numbering_plan_id_values[] = {
7127         {   0x00,       "unknown" },
7128         {   0x01,       "ISDN/Telephony Numbering (Rec ITU-T E.164)" },
7129         {   0x02,       "spare" },
7130         {   0x03,       "Data Numbering (ITU-T Rec. X.121)" },
7131         {   0x04,       "Telex Numbering (ITU-T Rec. F.69)" },
7132         {   0x08,       "National Numbering" },
7133         {   0x09,       "Private Numbering" },
7134         {       0x0d,   "reserved for CTS (see 3GPP TS 44.056 [91])" },
7135         {   0x0f,       "Reserved for extension" },
7136         { 0, NULL }
7137 };
7138
7139 /*
7140  * [3] 10.5.4.7
7141  */
7142 static guint8
7143 de_cld_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7144 {
7145     guint8      *poctets;
7146     guint32     curr_offset;
7147
7148     curr_offset = offset;
7149
7150     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7151         proto_tree_add_item(tree, hf_gsm_a_type_of_number , tvb, curr_offset, 1, FALSE);
7152         proto_tree_add_item(tree, hf_gsm_a_numbering_plan_id , tvb, curr_offset, 1, FALSE);
7153
7154     curr_offset++;
7155
7156     NO_MORE_DATA_CHECK(len);
7157
7158     poctets = tvb_get_ephemeral_string(tvb, curr_offset, len - (curr_offset - offset));
7159
7160     my_dgt_tbcd_unpack(a_bigbuf, poctets, len - (curr_offset - offset),
7161         &Dgt_mbcd);
7162
7163     proto_tree_add_string_format(tree, hf_gsm_a_cld_party_bcd_num,
7164         tvb, curr_offset, len - (curr_offset - offset),
7165         a_bigbuf,
7166         "BCD Digits: %s",
7167         a_bigbuf);
7168
7169     curr_offset += len - (curr_offset - offset);
7170
7171     if (add_string)
7172         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
7173
7174     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7175
7176     return(curr_offset - offset);
7177 }
7178
7179 /*
7180  * [3] 10.5.4.8
7181  */
7182 static guint8
7183 de_cld_party_sub_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7184 {
7185     guint8      oct;
7186     guint32     curr_offset;
7187     const gchar *str;
7188
7189     curr_offset = offset;
7190
7191     oct = tvb_get_guint8(tvb, curr_offset);
7192
7193     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7194
7195     switch ((oct & 0x70) >> 4)
7196     {
7197     case 0: str = "NSAP (X.213/ISO 8348 AD2)"; break;
7198     case 2: str = "User specified"; break;
7199     default:
7200         str = "Reserved";
7201         break;
7202     }
7203
7204     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
7205     proto_tree_add_text(tree,
7206         tvb, curr_offset, 1,
7207         "%s :  Type of subaddress: %s",
7208         a_bigbuf,
7209         str);
7210
7211     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
7212     proto_tree_add_text(tree,
7213         tvb, curr_offset, 1,
7214         "%s :  Odd/Even indicator: %s",
7215         a_bigbuf,
7216         (oct & 0x08) ?
7217             "odd number of address signals" : "even number of address signals");
7218
7219     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
7220     proto_tree_add_text(tree,
7221         tvb, curr_offset, 1,
7222         "%s :  Spare",
7223         a_bigbuf);
7224
7225     curr_offset++;
7226
7227     NO_MORE_DATA_CHECK(len);
7228
7229     proto_tree_add_text(tree,
7230         tvb, curr_offset, len - (curr_offset - offset),
7231         "Subaddress information");
7232
7233     curr_offset += len - (curr_offset - offset);
7234
7235     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7236
7237     return(curr_offset - offset);
7238 }
7239
7240 /* 3GPP TS 24.008
7241  * [3] 10.5.4.9
7242  */
7243 static guint8
7244 de_clg_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7245 {
7246     guint8      oct;
7247     guint8      *poctets;
7248     guint32     curr_offset;
7249     const gchar *str;
7250
7251     curr_offset = offset;
7252
7253     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7254         proto_tree_add_item(tree, hf_gsm_a_type_of_number , tvb, curr_offset, 1, FALSE);
7255         proto_tree_add_item(tree, hf_gsm_a_numbering_plan_id , tvb, curr_offset, 1, FALSE);
7256
7257     curr_offset++;
7258
7259     oct = tvb_get_guint8(tvb, curr_offset);
7260
7261     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7262
7263     switch ((oct & 0x60) >> 5)
7264     {
7265     case 0: str = "Presentation allowed"; break;
7266     case 1: str = "Presentation restricted"; break;
7267     case 2: str = "Number not available due to interworking"; break;
7268     default:
7269         str = "Reserved";
7270         break;
7271     }
7272
7273     other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
7274     proto_tree_add_text(tree,
7275         tvb, curr_offset, 1,
7276         "%s :  Presentation indicator: %s",
7277         a_bigbuf,
7278         str);
7279
7280     other_decode_bitfield_value(a_bigbuf, oct, 0x1c, 8);
7281     proto_tree_add_text(tree,
7282         tvb, curr_offset, 1,
7283         "%s :  Spare",
7284         a_bigbuf);
7285
7286     switch (oct & 0x03)
7287     {
7288     case 0: str = "User-provided, not screened"; break;
7289     case 1: str = "User-provided, verified and passed"; break;
7290     case 2: str = "User-provided, verified and failed"; break;
7291     default:
7292         str = "Network provided";
7293         break;
7294     }
7295
7296     other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
7297     proto_tree_add_text(tree,
7298         tvb, curr_offset, 1,
7299         "%s :  Screening indicator: %s",
7300         a_bigbuf,
7301         str);
7302
7303     curr_offset++;
7304
7305     NO_MORE_DATA_CHECK(len);
7306
7307     poctets = tvb_get_ephemeral_string(tvb, curr_offset, len - (curr_offset - offset));
7308
7309     my_dgt_tbcd_unpack(a_bigbuf, poctets, len - (curr_offset - offset),
7310         &Dgt_mbcd);
7311
7312     proto_tree_add_string_format(tree, hf_gsm_a_clg_party_bcd_num,
7313         tvb, curr_offset, len - (curr_offset - offset),
7314         a_bigbuf,
7315         "BCD Digits: %s",
7316         a_bigbuf);
7317
7318     curr_offset += len - (curr_offset - offset);
7319
7320     if (add_string)
7321         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
7322
7323     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7324
7325     return(curr_offset - offset);
7326 }
7327
7328 /*
7329  * [3] 10.5.4.10
7330  */
7331 static guint8
7332 de_clg_party_sub_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7333 {
7334     guint8      oct;
7335     guint32     curr_offset;
7336     const gchar *str;
7337
7338     curr_offset = offset;
7339
7340     oct = tvb_get_guint8(tvb, curr_offset);
7341
7342     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7343
7344     switch ((oct & 0x70) >> 4)
7345     {
7346     case 0: str = "NSAP (X.213/ISO 8348 AD2)"; break;
7347     case 2: str = "User specified"; break;
7348     default:
7349         str = "Reserved";
7350         break;
7351     }
7352
7353     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
7354     proto_tree_add_text(tree,
7355         tvb, curr_offset, 1,
7356         "%s :  Type of subaddress: %s",
7357         a_bigbuf,
7358         str);
7359
7360     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
7361     proto_tree_add_text(tree,
7362         tvb, curr_offset, 1,
7363         "%s :  Odd/Even indicator: %s",
7364         a_bigbuf,
7365         (oct & 0x08) ?
7366             "odd number of address signals" : "even number of address signals");
7367
7368     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
7369     proto_tree_add_text(tree,
7370         tvb, curr_offset, 1,
7371         "%s :  Spare",
7372         a_bigbuf);
7373
7374     curr_offset++;
7375
7376     NO_MORE_DATA_CHECK(len);
7377
7378     proto_tree_add_text(tree,
7379         tvb, curr_offset, len - (curr_offset - offset),
7380         "Subaddress information");
7381
7382     curr_offset += len - (curr_offset - offset);
7383
7384     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7385
7386     return(curr_offset - offset);
7387 }
7388
7389 /*
7390  * [3] 10.5.4.11
7391  */
7392 static guint8
7393 de_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7394 {
7395     guint8      oct;
7396     guint8      cause;
7397     guint32     curr_offset;
7398     const gchar *str;
7399
7400     curr_offset = offset;
7401
7402     oct = tvb_get_guint8(tvb, curr_offset);
7403
7404     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
7405     proto_tree_add_text(tree,
7406         tvb, curr_offset, 1,
7407         "%s :  Extension: %s",
7408         a_bigbuf,
7409         (oct & 0x80) ? "not extended" : "extended");
7410
7411     switch ((oct & 0x60) >> 5)
7412     {
7413     case 0: str = "Coding as specified in ITU-T Rec. Q.931"; break;
7414     case 1: str = "Reserved for other international standards"; break;
7415     case 2: str = "National standard"; break;
7416     default:
7417         str = "Standard defined for the GSM PLMNS";
7418         break;
7419     }
7420
7421     other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
7422     proto_tree_add_text(tree,
7423         tvb, curr_offset, 1,
7424         "%s :  Coding standard: %s",
7425         a_bigbuf,
7426         str);
7427
7428     other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
7429     proto_tree_add_text(tree,
7430         tvb, curr_offset, 1,
7431         "%s :  Spare",
7432         a_bigbuf);
7433
7434     switch (oct & 0x0f)
7435     {
7436     case 0: str = "User"; break;
7437     case 1: str = "Private network serving the local user"; break;
7438     case 2: str = "Public network serving the local user"; break;
7439     case 3: str = "Transit network"; break;
7440     case 4: str = "Public network serving the remote user"; break;
7441     case 5: str = "Private network serving the remote user"; break;
7442     case 7: str = "International network"; break;
7443     case 10: str = "Network beyond interworking point"; break;
7444     default:
7445         str = "Reserved";
7446         break;
7447     }
7448
7449     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
7450     proto_tree_add_text(tree,
7451         tvb, curr_offset, 1,
7452         "%s :  Location: %s",
7453         a_bigbuf,
7454         str);
7455
7456     curr_offset++;
7457
7458     oct = tvb_get_guint8(tvb, curr_offset);
7459
7460     if (!(oct & 0x80))
7461     {
7462         proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7463
7464         other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
7465         proto_tree_add_text(tree,
7466             tvb, curr_offset, 1,
7467             "%s :  Recommendation",
7468             a_bigbuf);
7469
7470         curr_offset++;
7471
7472         oct = tvb_get_guint8(tvb, curr_offset);
7473     }
7474
7475     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7476
7477     cause = oct & 0x7f;
7478     switch (cause)
7479     {
7480     case 1: str = "Unassigned (unallocated) number"; break;
7481     case 3: str = "No route to destination"; break;
7482     case 6: str = "Channel unacceptable"; break;
7483     case 8: str = "Operator determined barring"; break;
7484     case 16: str = "Normal call clearing"; break;
7485     case 17: str = "User busy"; break;
7486     case 18: str = "No user responding"; break;
7487     case 19: str = "User alerting, no answer"; break;
7488     case 21: str = "Call rejected"; break;
7489     case 22: str = "Number changed"; break;
7490     case 25: str = "Pre-emption"; break;
7491     case 26: str = "Non selected user clearing"; break;
7492     case 27: str = "Destination out of order"; break;
7493     case 28: str = "Invalid number format (incomplete number)"; break;
7494     case 29: str = "Facility rejected"; break;
7495     case 30: str = "Response to STATUS ENQUIRY"; break;
7496     case 31: str = "Normal, unspecified"; break;
7497     case 34: str = "No circuit/channel available"; break;
7498     case 38: str = "Network out of order"; break;
7499     case 41: str = "Temporary failure"; break;
7500     case 42: str = "Switching equipment congestion"; break;
7501     case 43: str = "Access information discarded"; break;
7502     case 44: str = "requested circuit/channel not available"; break;
7503     case 47: str = "Resources unavailable, unspecified"; break;
7504     case 49: str = "Quality of service unavailable"; break;
7505     case 50: str = "Requested facility not subscribed"; break;
7506     case 55: str = "Incoming calls barred within the CUG"; break;
7507     case 57: str = "Bearer capability not authorized"; break;
7508     case 58: str = "Bearer capability not presently available"; break;
7509     case 63: str = "Service or option not available, unspecified"; break;
7510     case 65: str = "Bearer service not implemented"; break;
7511     case 68: str = "ACM equal to or greater than ACMmax"; break;
7512     case 69: str = "Requested facility not implemented"; break;
7513     case 70: str = "Only restricted digital information bearer capability is available"; break;
7514     case 79: str = "Service or option not implemented, unspecified"; break;
7515     case 81: str = "Invalid transaction identifier value"; break;
7516     case 87: str = "User not member of CUG"; break;
7517     case 88: str = "Incompatible destination"; break;
7518     case 91: str = "Invalid transit network selection"; break;
7519     case 95: str = "Semantically incorrect message"; break;
7520     case 96: str = "Invalid mandatory information"; break;
7521     case 97: str = "Message type non-existent or not implemented"; break;
7522     case 98: str = "Message type not compatible with protocol state"; break;
7523     case 99: str = "Information element non-existent or not implemented"; break;
7524     case 100: str = "Conditional IE error"; break;
7525     case 101: str = "Message not compatible with protocol state"; break;
7526     case 102: str = "Recovery on timer expiry"; break;
7527     case 111: str = "Protocol error, unspecified"; break;
7528     case 127: str = "Interworking, unspecified"; break;
7529     default:
7530         if (cause <= 31) { str = "Treat as Normal, unspecified"; }
7531         else if ((cause >= 32) && (cause <= 47)) { str = "Treat as Resources unavailable, unspecified"; }
7532         else if ((cause >= 48) && (cause <= 63)) { str = "Treat as Service or option not available, unspecified"; }
7533         else if ((cause >= 64) && (cause <= 79)) { str = "Treat as Service or option not implemented, unspecified"; }
7534         else if ((cause >= 80) && (cause <= 95)) { str = "Treat as Semantically incorrect message"; }
7535         else if ((cause >= 96) && (cause <= 111)) { str = "Treat as Protocol error, unspecified"; }
7536         else if ((cause >= 112) && (cause <= 127)) { str = "Treat as Interworking, unspecified"; }
7537         break;
7538     }
7539
7540     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
7541     proto_tree_add_uint_format(tree, hf_gsm_a_dtap_cause,
7542         tvb, curr_offset, 1, cause,
7543         "%s :  Cause: (%u) %s",
7544         a_bigbuf,
7545         cause,
7546         str);
7547
7548     curr_offset++;
7549
7550     if (add_string)
7551         g_snprintf(add_string, string_len, " - (%u) %s", cause, str);
7552
7553     NO_MORE_DATA_CHECK(len);
7554
7555     proto_tree_add_text(tree,
7556         tvb, curr_offset, len - (curr_offset - offset),
7557         "Diagnostics");
7558
7559     curr_offset += len - (curr_offset - offset);
7560
7561     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7562
7563     return(curr_offset - offset);
7564 }
7565
7566 /*
7567  * 10.5.4.18 Low layer compatibility 
7568  */
7569 static guint8
7570 de_llc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7571 {
7572     guint32     curr_offset;
7573
7574     curr_offset = offset;
7575
7576         dissect_q931_bearer_capability_ie(tvb, offset, len, tree);
7577
7578         curr_offset = curr_offset + len;
7579     return(curr_offset - offset);
7580 }
7581
7582 /*
7583  * [6] 3.6
7584  */
7585  static int
7586 dissect_ROS_InvokeIdType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7587   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
7588                                   NULL);
7589
7590   return offset;
7591 }
7592 static int dissect_invokeID(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7593   return dissect_ROS_InvokeIdType(FALSE, tvb, offset, pinfo, tree, hf_ROS_invokeID);
7594 }
7595 static int dissect_linkedID_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7596   return dissect_ROS_InvokeIdType(TRUE, tvb, offset, pinfo, tree, hf_ROS_linkedID);
7597 }
7598 static int dissect_derivable(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7599   return dissect_ROS_InvokeIdType(FALSE, tvb, offset, pinfo, tree, hf_ROS_derivable);
7600 }
7601
7602
7603
7604 static int
7605 dissect_ROS_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7606   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
7607                                   &localValue);
7608
7609   return offset;
7610 }
7611 static int dissect_localValue(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7612   return dissect_ROS_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_ROS_localValue);
7613 }
7614 static int dissect_privateer_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7615   return dissect_ROS_INTEGER(TRUE, tvb, offset, pinfo, tree, hf_ROS_privateer);
7616 }
7617
7618
7619
7620 static int
7621 dissect_ROS_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7622   offset = dissect_ber_object_identifier(implicit_tag, pinfo, tree, tvb, offset, hf_index,
7623                                             NULL);
7624
7625   return offset;
7626 }
7627 static int dissect_globalValue(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7628   return dissect_ROS_OBJECT_IDENTIFIER(FALSE, tvb, offset, pinfo, tree, hf_ROS_globalValue);
7629 }
7630
7631
7632 static const value_string ROS_OPERATION_vals[] = {
7633   {   0, "localValue" },
7634   {   1, "globalValue" },
7635   { 0, NULL }
7636 };
7637
7638 static const ber_choice_t OPERATION_choice[] = {
7639   {   0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_localValue },
7640   {   1, BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_globalValue },
7641   { 0, 0, 0, 0, NULL }
7642 };
7643
7644 static int
7645 dissect_ROS_OPERATION(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7646   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
7647                               OPERATION_choice, hf_index, ett_ROS_OPERATION, NULL);
7648
7649   return offset;
7650 }
7651 static int dissect_opCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7652   return dissect_ROS_OPERATION(FALSE, tvb, offset, pinfo, tree, hf_ROS_opCode);
7653 }
7654
7655
7656
7657 static int
7658 dissect_ROS_Parameter(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7659   offset = gsm_ss_dissect(tvb, pinfo, tree, offset, localValue, comp_type_tag);
7660         
7661   return offset;
7662 }
7663 static int dissect_parameter(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7664   return dissect_ROS_Parameter(FALSE, tvb, offset, pinfo, tree, hf_ROS_parameter);
7665 }
7666
7667 static const ber_sequence_t Invoke_sequence[] = {
7668   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeID },
7669   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_linkedID_impl },
7670   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_opCode },
7671   { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_parameter },
7672   { 0, 0, 0, NULL }
7673 };
7674
7675 static int
7676 dissect_ROS_Invoke(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7677   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
7678                                 Invoke_sequence, hf_index, ett_ROS_Invoke);
7679
7680   return offset;
7681 }
7682 static int dissect_invoke_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7683   return dissect_ROS_Invoke(TRUE, tvb, offset, pinfo, tree, hf_ROS_invoke);
7684 }
7685
7686 static const ber_sequence_t T_resultretres_sequence[] = {
7687   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_opCode },
7688   { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_parameter },
7689   { 0, 0, 0, NULL }
7690 };
7691
7692 static int
7693 dissect_ROS_T_resultretres(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7694   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
7695                                 T_resultretres_sequence, hf_index, ett_ROS_T_resultretres);
7696
7697   return offset;
7698 }
7699 static int dissect_resultretres(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7700   return dissect_ROS_T_resultretres(FALSE, tvb, offset, pinfo, tree, hf_ROS_resultretres);
7701 }
7702
7703 static const ber_sequence_t ReturnResult_sequence[] = {
7704   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeID },
7705   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_resultretres },
7706   { 0, 0, 0, NULL }
7707 };
7708
7709 static int
7710 dissect_ROS_ReturnResult(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7711   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
7712                                 ReturnResult_sequence, hf_index, ett_ROS_ReturnResult);
7713
7714   return offset;
7715 }
7716 static int dissect_returnResultLast_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7717   return dissect_ROS_ReturnResult(TRUE, tvb, offset, pinfo, tree, hf_ROS_returnResultLast);
7718 }
7719
7720
7721
7722 static int
7723 dissect_ROS_INTEGER_M32768_32767(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7724   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
7725                                   NULL);
7726
7727   return offset;
7728 }
7729 static int dissect_nationaler_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7730   return dissect_ROS_INTEGER_M32768_32767(TRUE, tvb, offset, pinfo, tree, hf_ROS_nationaler);
7731 }
7732
7733
7734 static const value_string ROS_ErrorCode_vals[] = {
7735   {  19, "nationaler" },
7736   {  20, "privateer" },
7737   { 0, NULL }
7738 };
7739
7740 static const ber_choice_t ErrorCode_choice[] = {
7741   {  19, BER_CLASS_PRI, 19, BER_FLAGS_IMPLTAG, dissect_nationaler_impl },
7742   {  20, BER_CLASS_PRI, 20, BER_FLAGS_IMPLTAG, dissect_privateer_impl },
7743   { 0, 0, 0, 0, NULL }
7744 };
7745
7746 static int
7747 dissect_ROS_ErrorCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7748   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
7749                               ErrorCode_choice, hf_index, ett_ROS_ErrorCode, NULL);
7750
7751   return offset;
7752 }
7753 static int dissect_errorCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7754   return dissect_ROS_ErrorCode(FALSE, tvb, offset, pinfo, tree, hf_ROS_errorCode);
7755 }
7756
7757 static const ber_sequence_t ReturnError_sequence[] = {
7758   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeID },
7759   { BER_CLASS_PRI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_errorCode },
7760   { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_parameter },
7761   { 0, 0, 0, NULL }
7762 };
7763
7764 static int
7765 dissect_ROS_ReturnError(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7766   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
7767                                 ReturnError_sequence, hf_index, ett_ROS_ReturnError);
7768
7769   return offset;
7770 }
7771 static int dissect_returnError_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7772   return dissect_ROS_ReturnError(TRUE, tvb, offset, pinfo, tree, hf_ROS_returnError);
7773 }
7774
7775
7776
7777 static int
7778 dissect_ROS_NULL(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7779   offset = dissect_ber_null(implicit_tag, pinfo, tree, tvb, offset, hf_index);
7780
7781   return offset;
7782 }
7783 static int dissect_not_derivable(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7784   return dissect_ROS_NULL(FALSE, tvb, offset, pinfo, tree, hf_ROS_not_derivable);
7785 }
7786
7787
7788 static const value_string ROS_T_invokeIDRej_vals[] = {
7789   {   0, "derivable" },
7790   {   1, "not-derivable" },
7791   { 0, NULL }
7792 };
7793
7794 static const ber_choice_t T_invokeIDRej_choice[] = {
7795   {   0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_derivable },
7796   {   1, BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_not_derivable },
7797   { 0, 0, 0, 0, NULL }
7798 };
7799
7800 static int
7801 dissect_ROS_T_invokeIDRej(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7802   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
7803                               T_invokeIDRej_choice, hf_index, ett_ROS_T_invokeIDRej, NULL);
7804
7805   return offset;
7806 }
7807 static int dissect_invokeIDRej(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7808   return dissect_ROS_T_invokeIDRej(FALSE, tvb, offset, pinfo, tree, hf_ROS_invokeIDRej);
7809 }
7810
7811
7812 static const value_string ROS_GeneralProblem_vals[] = {
7813   {   0, "unrecognizedComponent" },
7814   {   1, "mistypedComponent" },
7815   {   2, "badlyStructuredComponent" },
7816   { 0, NULL }
7817 };
7818
7819
7820 static int
7821 dissect_ROS_GeneralProblem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7822   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
7823                                   NULL);
7824
7825   return offset;
7826 }
7827 static int dissect_generalProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7828   return dissect_ROS_GeneralProblem(TRUE, tvb, offset, pinfo, tree, hf_ROS_generalProblem);
7829 }
7830
7831
7832 static const value_string ROS_InvokeProblem_vals[] = {
7833   {   0, "duplicateInvokeID" },
7834   {   1, "unrecognizedOperation" },
7835   {   2, "mistypedParameter" },
7836   {   3, "resourceLimitation" },
7837   {   4, "initiatingRelease" },
7838   {   5, "unrecognizedLinkedID" },
7839   {   6, "linkedResponseUnexpected" },
7840   {   7, "unexpectedLinkedOperation" },
7841   { 0, NULL }
7842 };
7843
7844
7845 static int
7846 dissect_ROS_InvokeProblem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7847   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
7848                                   NULL);
7849
7850   return offset;
7851 }
7852 static int dissect_invokeProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7853   return dissect_ROS_InvokeProblem(TRUE, tvb, offset, pinfo, tree, hf_ROS_invokeProblem);
7854 }
7855
7856
7857 static const value_string ROS_ReturnResultProblem_vals[] = {
7858   {   0, "unrecognizedInvokeID" },
7859   {   1, "returnResultUnexpected" },
7860   {   2, "mistypedParameter" },
7861   { 0, NULL }
7862 };
7863
7864
7865 static int
7866 dissect_ROS_ReturnResultProblem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7867   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
7868                                   NULL);
7869
7870   return offset;
7871 }
7872 static int dissect_returnResultProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7873   return dissect_ROS_ReturnResultProblem(TRUE, tvb, offset, pinfo, tree, hf_ROS_returnResultProblem);
7874 }
7875
7876
7877 static const value_string ROS_ReturnErrorProblem_vals[] = {
7878   {   0, "unrecognizedInvokeID" },
7879   {   1, "returnErrorUnexpected" },
7880   {   2, "unrecognizedError" },
7881   {   3, "unexpectedError" },
7882   {   4, "mistypedParameter" },
7883   { 0, NULL }
7884 };
7885
7886
7887 static int
7888 dissect_ROS_ReturnErrorProblem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7889   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
7890                                   NULL);
7891
7892   return offset;
7893 }
7894 static int dissect_returnErrorProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7895   return dissect_ROS_ReturnErrorProblem(TRUE, tvb, offset, pinfo, tree, hf_ROS_returnErrorProblem);
7896 }
7897
7898
7899 static const value_string ROS_T_problem_vals[] = {
7900   {   0, "generalProblem" },
7901   {   1, "invokeProblem" },
7902   {   2, "returnResultProblem" },
7903   {   3, "returnErrorProblem" },
7904   { 0, NULL }
7905 };
7906
7907 static const ber_choice_t T_problem_choice[] = {
7908   {   0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_generalProblem_impl },
7909   {   1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_invokeProblem_impl },
7910   {   2, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_returnResultProblem_impl },
7911   {   3, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_returnErrorProblem_impl },
7912   { 0, 0, 0, 0, NULL }
7913 };
7914
7915 static int
7916 dissect_ROS_T_problem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7917   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
7918                               T_problem_choice, hf_index, ett_ROS_T_problem, NULL);
7919
7920   return offset;
7921 }
7922 static int dissect_problem(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7923   return dissect_ROS_T_problem(FALSE, tvb, offset, pinfo, tree, hf_ROS_problem);
7924 }
7925
7926 static const ber_sequence_t Reject_sequence[] = {
7927   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeIDRej },
7928   { BER_CLASS_CON, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_problem },
7929   { 0, 0, 0, NULL }
7930 };
7931
7932 static int
7933 dissect_ROS_Reject(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7934   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
7935                                 Reject_sequence, hf_index, ett_ROS_Reject);
7936
7937   return offset;
7938 }
7939 static int dissect_reject_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
7940   return dissect_ROS_Reject(TRUE, tvb, offset, pinfo, tree, hf_ROS_reject);
7941 }
7942
7943
7944 static const value_string ROS_Component_vals[] = {
7945   {   1, "invoke" },
7946   {   2, "returnResultLast" },
7947   {   3, "returnError" },
7948   {   4, "reject" },
7949   { 0, NULL }
7950 };
7951
7952 static const ber_choice_t Component_choice[] = {
7953   {   1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_invoke_impl },
7954   {   2, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_returnResultLast_impl },
7955   {   3, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_returnError_impl },
7956   {   4, BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_reject_impl },
7957   { 0, 0, 0, 0, NULL }
7958 };
7959
7960 static int
7961 dissect_ROS_Component(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7962
7963   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
7964                               Component_choice, hf_index, ett_ROS_Component, NULL);
7965   /* branch taken will be component type -1 */
7966
7967   return offset;
7968 }
7969
7970
7971 static const value_string ROS_ERROR_vals[] = {
7972   {   0, "localValue" },
7973   {   1, "globalValue" },
7974   { 0, NULL }
7975 };
7976
7977 static const ber_choice_t ERROR_choice[] = {
7978   {   0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_localValue },
7979   {   1, BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_globalValue },
7980   { 0, 0, 0, 0, NULL }
7981 };
7982
7983 static int
7984 dissect_ROS_ERROR(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
7985   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
7986                               ERROR_choice, hf_index, ett_ROS_ERROR, NULL);
7987
7988   return offset;
7989 }
7990
7991 static guint8
7992 de_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint fac_len, gchar *add_string _U_, int string_len _U_)
7993 {
7994     guint       saved_offset;
7995         gint8 class;
7996         gboolean pc;
7997         gboolean ind = FALSE;
7998         guint32 component_len = 0;
7999         guint32 header_end_offset;
8000         guint32 header_len;
8001
8002         
8003         saved_offset = offset;
8004         while ( fac_len > (offset - saved_offset)){ 
8005
8006                 /* Get the length of the component there can be more tnan one component in a facility message */
8007           
8008                 header_end_offset = get_ber_identifier(tvb, offset, &class, &pc, &comp_type_tag);
8009                 header_end_offset = get_ber_length(tree, tvb, header_end_offset, &component_len, &ind);
8010                 if (ind){
8011                         proto_tree_add_text(tree, tvb, offset+1, 1,
8012                                 "Indefinte length, ignoring component");
8013                         return (fac_len);
8014                 }
8015                 header_len = header_end_offset - offset;
8016                 component_len = header_len + component_len;
8017                 dissect_ROS_Component(FALSE, tvb, offset, g_pinfo, tree, hf_ROS_component);
8018                 offset = offset + component_len;
8019
8020         } 
8021         return(fac_len);
8022
8023
8024 }
8025
8026 /*
8027  * [3] 10.5.4.17
8028  */
8029 static guint8
8030 de_keypad_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
8031 {
8032     guint8      oct;
8033     guint32     curr_offset;
8034
8035     len = len;
8036     curr_offset = offset;
8037
8038     oct = tvb_get_guint8(tvb, curr_offset);
8039
8040     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
8041     proto_tree_add_text(tree,
8042         tvb, curr_offset, 1,
8043         "%s :  Spare",
8044         a_bigbuf);
8045
8046     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
8047     proto_tree_add_text(tree,
8048         tvb, curr_offset, 1,
8049         "%s :  Keypad information: %c",
8050         a_bigbuf,
8051         oct & 0x7f);
8052
8053     curr_offset++;
8054
8055     if (add_string)
8056         g_snprintf(add_string, string_len, " - %c", oct & 0x7f);
8057
8058     /* no length check possible */
8059
8060     return(curr_offset - offset);
8061 }
8062
8063 /*
8064  * [3] 10.5.4.21
8065  */
8066 static guint8
8067 de_prog_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
8068 {
8069     guint8      oct;
8070     guint32     curr_offset;
8071     const gchar *str;
8072
8073     len = len;
8074     curr_offset = offset;
8075
8076     oct = tvb_get_guint8(tvb, curr_offset);
8077
8078     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
8079     proto_tree_add_text(tree,
8080         tvb, curr_offset, 1,
8081         "%s :  Extension: %s",
8082         a_bigbuf,
8083         (oct & 0x80) ? "extended" : "not extended");
8084
8085     switch ((oct & 0x60) >> 5)
8086     {
8087     case 0: str = "Coding as specified in ITU-T Rec. Q.931"; break;
8088     case 1: str = "Reserved for other international standards"; break;
8089     case 2: str = "National standard"; break;
8090     default:
8091         str = "Standard defined for the GSM PLMNS";
8092         break;
8093     }
8094
8095     other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
8096     proto_tree_add_text(tree,
8097         tvb, curr_offset, 1,
8098         "%s :  Coding standard: %s",
8099         a_bigbuf,
8100         str);
8101
8102     other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
8103     proto_tree_add_text(tree,
8104         tvb, curr_offset, 1,
8105         "%s :  Spare",
8106         a_bigbuf);
8107
8108     switch (oct & 0x0f)
8109     {
8110     case 0: str = "User"; break;
8111     case 1: str = "Private network serving the local user"; break;
8112     case 2: str = "Public network serving the local user"; break;
8113     case 4: str = "Public network serving the remote user"; break;
8114     case 5: str = "Private network serving the remote user"; break;
8115     case 10: str = "Network beyond interworking point"; break;
8116     default:
8117         str = "Reserved";
8118         break;
8119     }
8120
8121     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
8122     proto_tree_add_text(tree,
8123         tvb, curr_offset, 1,
8124         "%s :  Location: %s",
8125         a_bigbuf,
8126         str);
8127
8128     curr_offset++;
8129
8130     oct = tvb_get_guint8(tvb, curr_offset);
8131
8132     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
8133     proto_tree_add_text(tree,
8134         tvb, curr_offset, 1,
8135         "%s :  Extension: %s",
8136         a_bigbuf,
8137         (oct & 0x80) ? "extended" : "not extended");
8138
8139     switch (oct & 0x7f)
8140     {
8141     case 1: str = "Call is not end-to-end PLMN/ISDN, further call progress information may be available in-band"; break;
8142     case 2: str = "Destination address in non-PLMN/ISDN"; break;
8143     case 3: str = "Origination address in non-PLMN/ISDN"; break;
8144     case 4: str = "Call has returned to the PLMN/ISDN"; break;
8145     case 8: str = "In-band information or appropriate pattern now available"; break;
8146     case 32: str = "Call is end-to-end PLMN/ISDN"; break;
8147     case 64: str = "Queueing"; break;
8148     default:
8149         str = "Unspecific";
8150         break;
8151     }
8152
8153     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
8154     proto_tree_add_text(tree,
8155         tvb, curr_offset, 1,
8156         "%s :  Progress Description: %s (%d)",
8157         a_bigbuf,
8158         str,
8159         oct & 0x7f);
8160
8161     if (add_string)
8162         g_snprintf(add_string, string_len, " - %d", oct & 0x7f);
8163
8164     curr_offset++;
8165
8166     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8167
8168     return(curr_offset - offset);
8169 }
8170
8171 /*
8172  * [3] 10.5.4.22
8173  */
8174 static guint8
8175 de_repeat_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8176 {
8177     guint8      oct;
8178     guint32     curr_offset;
8179     const gchar *str;
8180
8181     len = len;
8182     curr_offset = offset;
8183
8184     oct = tvb_get_guint8(tvb, curr_offset);
8185
8186     switch (oct & 0x0f)
8187     {
8188     case 1: str = "Circular for successive selection 'mode 1 alternate mode 2'"; break;
8189     case 2: str = "Support of fallback  mode 1 preferred, mode 2 selected if setup of mode 1 fails"; break;
8190     case 3: str = "Reserved: was allocated in earlier phases of the protocol"; break;
8191     default:
8192         str = "Reserved";
8193         break;
8194     }
8195
8196     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
8197     proto_tree_add_text(tree,
8198         tvb, curr_offset, 1,
8199         "%s :  %s",
8200         a_bigbuf,
8201         str);
8202
8203     curr_offset++;
8204
8205     /* no length check possible */
8206
8207     return(curr_offset - offset);
8208 }
8209
8210 /*
8211  * [6] 3.7.2
8212  */
8213 static guint8
8214 de_ss_ver_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8215 {
8216     guint8      oct;
8217     guint32     curr_offset;
8218     const gchar *str;
8219
8220     curr_offset = offset;
8221
8222     oct = tvb_get_guint8(tvb, curr_offset);
8223
8224     switch (oct)
8225     {
8226     case 0: str = "Phase 2 service, ellipsis notation, and phase 2 error handling is supported"; break;
8227     case 1: str = "SS-Protocol version 3 is supported, and phase 2 error handling is supported"; break;
8228     default:
8229         str = "Reserved";
8230         break;
8231     }
8232
8233     proto_tree_add_text(tree,
8234         tvb, curr_offset, 1,
8235         "%s",
8236         str);
8237
8238     curr_offset++;
8239
8240     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8241
8242     return(curr_offset - offset);
8243 }
8244
8245 /*
8246  * [5] 8.1.4.1 3GPP TS 24.011 version 6.1.0 Release 6
8247  */
8248 static guint8
8249 de_cp_user_data(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8250 {
8251     guint32     curr_offset;
8252     tvbuff_t    *rp_tvb;
8253
8254     curr_offset = offset;
8255
8256     proto_tree_add_text(tree, tvb, curr_offset, len,
8257         "RPDU (not displayed)");
8258
8259     /*
8260      * dissect the embedded RP message
8261      */
8262     rp_tvb = tvb_new_subset(tvb, curr_offset, len, len);
8263
8264     call_dissector(rp_handle, rp_tvb, g_pinfo, g_tree);
8265
8266     curr_offset += len;
8267
8268     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8269
8270     return(curr_offset - offset);
8271 }
8272
8273 /*
8274  * [5] 8.1.4.2
8275  */
8276 static guint8
8277 de_cp_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
8278 {
8279     guint8      oct;
8280     guint32     curr_offset;
8281     const gchar *str;
8282
8283     len = len;
8284     curr_offset = offset;
8285
8286     oct = tvb_get_guint8(tvb, curr_offset);
8287
8288     switch (oct)
8289     {
8290     case 17: str = "Network failure"; break;
8291     case 22: str = "Congestion"; break;
8292     case 81: str = "Invalid Transaction Identifier value"; break;
8293     case 95: str = "Semantically incorrect message"; break;
8294     case 96: str = "Invalid mandatory information"; break;
8295     case 97: str = "Message type non-existent or not implemented"; break;
8296     case 98: str = "Message not compatible with the short message protocol state"; break;
8297     case 99: str = "Information element non-existent or not implemented"; break;
8298     case 111: str = "Protocol error, unspecified"; break;
8299     default:
8300         str = "Reserved, treat as Protocol error, unspecified";
8301         break;
8302     }
8303
8304     proto_tree_add_text(tree,
8305         tvb, curr_offset, 1,
8306         "Cause: (%u) %s",
8307         oct,
8308         str);
8309
8310     curr_offset++;
8311
8312     if (add_string)
8313         g_snprintf(add_string, string_len, " - (%u) %s", oct, str);
8314
8315     /* no length check possible */
8316
8317     return(curr_offset - offset);
8318 }
8319
8320 /*
8321  * [5] 8.2.3
8322  */
8323 static guint8
8324 de_rp_message_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8325 {
8326     guint8      oct;
8327     guint32     curr_offset;
8328
8329     len = len;
8330     curr_offset = offset;
8331
8332     oct = tvb_get_guint8(tvb, curr_offset);
8333
8334     proto_tree_add_text(tree,
8335         tvb, curr_offset, 1,
8336         "RP-Message Reference: 0x%02x (%u)",
8337         oct,
8338         oct);
8339
8340     curr_offset++;
8341
8342     /* no length check possible */
8343
8344     return(curr_offset - offset);
8345 }
8346
8347 /*
8348  * [5] 8.2.5.1
8349  */
8350 static guint8
8351 de_rp_orig_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
8352 {
8353     return(de_cld_party_bcd_num(tvb, tree, offset, len, add_string, string_len));
8354 }
8355
8356 /*
8357  * [5] 8.2.5.2
8358  */
8359 static guint8
8360 de_rp_dest_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
8361 {
8362     return(de_cld_party_bcd_num(tvb, tree, offset, len, add_string, string_len));
8363 }
8364
8365 /*
8366  * [5] 8.2.5.3
8367  */
8368 static guint8
8369 de_rp_user_data(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8370 {
8371     guint32     curr_offset;
8372     tvbuff_t    *tpdu_tvb;
8373
8374     curr_offset = offset;
8375
8376     proto_tree_add_text(tree, tvb, curr_offset, len,
8377         "TPDU (not displayed)");
8378
8379     /*
8380      * dissect the embedded TPDU message
8381      */
8382     tpdu_tvb = tvb_new_subset(tvb, curr_offset, len, len);
8383
8384     dissector_try_port(sms_dissector_table, 0, tpdu_tvb, g_pinfo, g_tree);
8385
8386     curr_offset += len;
8387
8388     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8389
8390     return(curr_offset - offset);
8391 }
8392
8393 /*
8394  * [5] 8.2.5.4
8395  */
8396 static guint8
8397 de_rp_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
8398 {
8399     guint8      oct;
8400     guint32     curr_offset;
8401     const gchar *str;
8402
8403     curr_offset = offset;
8404
8405     oct = tvb_get_guint8(tvb, curr_offset);
8406
8407     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
8408     proto_tree_add_text(tree,
8409         tvb, curr_offset, 1,
8410         "%s :  Extension: %s",
8411         a_bigbuf,
8412         (oct & 0x80) ? "extended" : "not extended");
8413
8414     switch (oct & 0x7f)
8415     {
8416     case 1: str = "Unassigned (unallocated) number"; break;
8417     case 8: str = "Operator determined barring"; break;
8418     case 10: str = "Call barred"; break;
8419     case 11: str = "Reserved"; break;
8420     case 21: str = "Short message transfer rejected"; break;
8421     case 22: str = "Memory capacity exceeded"; break;
8422     case 27: str = "Destination out of order"; break;
8423     case 28: str = "Unidentified subscriber"; break;
8424     case 29: str = "Facility rejected"; break;
8425     case 30: str = "Unknown subscriber"; break;
8426     case 38: str = "Network out of order"; break;
8427     case 41: str = "Temporary failure"; break;
8428     case 42: str = "Congestion"; break;
8429     case 47: str = "Resources unavailable, unspecified"; break;
8430     case 50: str = "Requested facility not subscribed"; break;
8431     case 69: str = "Requested facility not implemented"; break;
8432     case 81: str = "Invalid short message transfer reference value"; break;
8433     case 95: str = "Semantically incorrect message"; break;
8434     case 96: str = "Invalid mandatory information"; break;
8435     case 97: str = "Message type non-existent or not implemented"; break;
8436     case 98: str = "Message not compatible with short message protocol state"; break;
8437     case 99: str = "Information element non-existent or not implemented"; break;
8438     case 111: str = "Protocol error, unspecified"; break;
8439     case 127: str = "Interworking, unspecified"; break;
8440     default:
8441         str = "Reserved";
8442         break;
8443     }
8444
8445     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
8446     proto_tree_add_text(tree,
8447         tvb, curr_offset, 1,
8448         "%s :  Cause: (%u) %s",
8449         a_bigbuf,
8450         oct & 0x7f,
8451         str);
8452
8453     curr_offset++;
8454
8455     if (add_string)
8456         g_snprintf(add_string, string_len, " - (%u) %s", oct & 0x7f, str);
8457
8458     NO_MORE_DATA_CHECK(len);
8459
8460     proto_tree_add_text(tree,
8461         tvb, curr_offset, len - (curr_offset - offset),
8462         "Diagnostic field");
8463
8464     curr_offset += len - (curr_offset - offset);
8465
8466     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8467
8468     return(curr_offset - offset);
8469 }
8470
8471 /*
8472  * [7] 10.5.5.1
8473  */
8474 static guint8
8475 de_gmm_attach_res(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8476 {
8477     guint8      oct;
8478     guint32     curr_offset;
8479     const gchar *str;
8480     
8481     len = len;
8482     curr_offset = offset;
8483
8484     oct = tvb_get_guint8(tvb, curr_offset);
8485
8486     switch(oct&7)
8487     {
8488         case 1: str="GPRS only attached"; break;
8489         case 3: str="Combined GPRS/IMSI attached";      break;
8490         default: str="reserved";
8491     }
8492
8493     proto_tree_add_text(tree,
8494         tvb, curr_offset, 1,
8495         "Attach Result: (%u) %s",
8496         oct&7,
8497         str);
8498
8499     curr_offset++;
8500
8501     /* no length check possible */
8502
8503     return(curr_offset - offset);
8504 }
8505
8506 /*
8507  * [7] 10.5.5.2
8508  */
8509 static guint8
8510 de_gmm_attach_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8511 {
8512     guint8      oct;
8513     guint8      oct_ciph;
8514     guint32     curr_offset;
8515     const gchar *str_follow;
8516     const gchar *str_attach;
8517     proto_item  *tf = NULL;
8518     proto_tree      *tf_tree = NULL;
8519     
8520     len = len;
8521     curr_offset = offset;
8522
8523     oct = tvb_get_guint8(tvb, curr_offset);
8524     oct_ciph = oct>>4;
8525
8526     oct &= 0x0f;
8527
8528     switch(oct&7)
8529     {
8530         case 1: str_attach="GPRS attach"; break;
8531         case 2: str_attach="GPRS attach while IMSI attached"; break;
8532         case 3: str_attach="Combined GPRS/IMSI attach"; break;
8533         default: str_attach="reserved";
8534     }
8535     switch(oct&8)
8536     {
8537         case 8: str_follow="Follow-on request pending"; break;
8538         default: str_follow="No follow-on request pending";
8539     }
8540
8541     tf = proto_tree_add_text(tree,
8542         tvb, curr_offset, 1,
8543         "Attach Type");
8544
8545     tf_tree = proto_item_add_subtree(tf, ett_gmm_attach_type );
8546
8547     proto_tree_add_text(tf_tree,
8548         tvb, curr_offset, 1,
8549         "Type: (%u) %s",
8550         oct&7,
8551         str_attach);
8552     proto_tree_add_text(tf_tree,
8553         tvb, curr_offset, 1,
8554         "Follow: (%u) %s",
8555         (oct>>3)&1,
8556         str_follow);
8557
8558     /* The ciphering key sequence number is added here */
8559     proto_tree_add_text(tree,
8560         tvb, curr_offset, 1,
8561         "Ciphering key sequence number: 0x%02x (%u)",
8562         oct_ciph,
8563         oct_ciph);
8564
8565     curr_offset++;
8566
8567     /* no length check possible */
8568
8569     return(curr_offset - offset);
8570 }
8571
8572 /*
8573  * [7] 10.5.5.3
8574  */
8575 static guint8
8576 de_gmm_ciph_alg(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8577 {
8578     guint8      oct;
8579     guint32     curr_offset;
8580     const gchar *str;
8581     
8582     len = len;
8583     curr_offset = offset;
8584
8585     oct = tvb_get_guint8(tvb, curr_offset);
8586
8587     switch(oct&7)
8588     {
8589         case 0: str="ciphering not used"; break;
8590         case 1: str="GPRS Encryption Algorithm GEA/1"; break;
8591         case 2: str="GPRS Encryption Algorithm GEA/2"; break;
8592         case 3: str="GPRS Encryption Algorithm GEA/3"; break;
8593         case 4: str="GPRS Encryption Algorithm GEA/4"; break;
8594         case 5: str="GPRS Encryption Algorithm GEA/5"; break;
8595         case 6: str="GPRS Encryption Algorithm GEA/6"; break;
8596         case 7: str="GPRS Encryption Algorithm GEA/7"; break;
8597         default: str="This should never happen";
8598     }
8599
8600     proto_tree_add_text(tree,
8601         tvb, curr_offset, 1,
8602         "Ciphering Algorithm: (%u) %s",
8603         oct&7,
8604         str);
8605
8606     curr_offset++;
8607
8608     /* no length check possible */
8609
8610     return(curr_offset - offset);
8611 }
8612
8613 /*
8614  * [7] 10.5.5.4
8615  */
8616 static guint8
8617 de_gmm_tmsi_stat(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8618 {
8619     guint8      oct;
8620     guint32     curr_offset;
8621     const gchar *str;
8622     
8623     len = len;
8624     curr_offset = offset;
8625
8626     oct = tvb_get_guint8(tvb, curr_offset);
8627
8628     switch(oct&1)
8629     {
8630         case 0: str="no valid TMSI available"; break;
8631         case 1: str="valid TMSI available"; break;
8632         default: str="This should never happen";
8633     }
8634
8635     proto_tree_add_text(tree,
8636         tvb, curr_offset, 1,
8637         "TMSI Status: (%u) %s",
8638         oct&1,
8639         str);
8640
8641     /* curr_offset++;  - It is encoded in the octed before */
8642
8643     /* no length check possible */
8644
8645     return(curr_offset - offset);
8646 }
8647
8648 /*
8649  * [7] 10.5.5.5
8650  */
8651 static guint8
8652 de_gmm_detach_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8653 {
8654     guint8      oct;
8655     guint32     curr_offset;
8656     const gchar *str;
8657     const gchar *str_power;
8658     proto_item  *tf = NULL;
8659     proto_tree      *tf_tree = NULL;
8660     
8661     len = len;
8662     curr_offset = offset;
8663
8664     oct = tvb_get_guint8(tvb, curr_offset);
8665
8666     switch(oct&7)
8667     {
8668         case 1: str="GPRS detach/re-attach required"; break;
8669         case 2: str="IMSI detach/re-attach not required"; break;
8670         case 3: str="Combined GPRS/IMSI detach/IMSI detach (after VLR failure)"; break;
8671         default: str="Combined GPRS/IMSI detach/re-attach not required";
8672     }
8673
8674     switch(oct&8)
8675     {
8676         case 8: str_power="power switched off"; break;
8677         default: str_power="normal detach"; break;
8678     }
8679
8680     tf = proto_tree_add_text(tree,
8681         tvb, curr_offset, 1,
8682         "Detach Type");
8683
8684     tf_tree = proto_item_add_subtree(tf, ett_gmm_detach_type );
8685
8686     proto_tree_add_text(tf_tree,
8687         tvb, curr_offset, 1,
8688         "Type: (%u) %s",
8689         oct&7,
8690         str);
8691
8692     proto_tree_add_text(tf_tree,
8693         tvb, curr_offset, 1,
8694         "Power: (%u) %s",
8695         (oct>>3)&1,
8696         str_power);
8697
8698     curr_offset++;
8699
8700     /* no length check possible */
8701
8702     return(curr_offset - offset);
8703 }
8704
8705 /*
8706  * [7] 10.5.5.6
8707  * 
8708  * SPLIT on CCCH, octet 3 (bit 4)
8709  * 0 Split pg cycle on CCCH is not supported by the mobile station
8710  * 1 Split pg cycle on CCCH is supported by the mobile station
8711  */
8712 static const true_false_string gsm_a_gmm_split_on_ccch_value  = {
8713   "Split pg cycle on CCCH is supported by the mobile station",
8714   "Split pg cycle on CCCH is not supported by the mobile station"
8715 };
8716
8717 /* non-DRX timer, octet 3
8718  * bit
8719  * 3 2 1
8720  */
8721 static const value_string gsm_a_gmm_non_drx_timer_strings[] = {
8722     { 0x00,     "no non-DRX mode after transfer state" },
8723     { 0x01,     "max. 1 sec non-DRX mode after transfer state" },
8724     { 0x02,     "max. 2 sec non-DRX mode after transfer state" },
8725     { 0x03,     "max. 4 sec non-DRX mode after transfer state" },
8726     { 0x04,     "max. 8 sec non-DRX mode after transfer state" },
8727     { 0x05,     "max. 16 sec non-DRX mode after transfer state" },
8728     { 0x06,     "max. 32 sec non-DRX mode after transfer state" },
8729     { 0x07,     "max. 64 sec non-DRX mode after transfer state" },
8730     { 0, NULL },
8731 };
8732 /*
8733  * CN Specific DRX cycle length coefficient, octet 3
8734  * bit
8735  * 8 7 6 5 Iu mode specific
8736  * 0 0 0 0 CN Specific DRX cycle length coefficient not specified by the MS, ie. the
8737  * system information value 'CN domain specific DRX cycle length' is used.
8738  * (Ref 3GPP TS 25.331)
8739  * 0 1 1 0 CN Specific DRX cycle length coefficient 6
8740  * 0 1 1 1 CN Specific DRX cycle length coefficient 7
8741  * 1 0 0 0 CN Specific DRX cycle length coefficient 8
8742  * 1 0 0 1 CN Specific DRX cycle length coefficient 9
8743  * All other values shall be interpreted as "CN Specific DRX cycle length coefficient not
8744  * specified by the MS " by this version of the protocol.
8745  * NOTE: In Iu mode this field (octet 3 bits 8 to 5) is used, but was spare in earlier
8746  * versions of this protocol.
8747  */
8748 static const value_string gsm_a_gmm_cn_spec_drs_cycle_len_coef_strings[] = {
8749     { 0x00,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8750     { 0x01,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8751     { 0x02,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8752     { 0x03,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8753     { 0x04,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8754     { 0x05,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8755     { 0x06,     "CN Specific DRX cycle length coefficient 6" },
8756     { 0x07,     "CN Specific DRX cycle length coefficient 7" },
8757     { 0x08,     "CN Specific DRX cycle length coefficient 8" },
8758     { 0x09,     "CN Specific DRX cycle length coefficient 9" },
8759     { 0x0a,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8760     { 0x0b,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8761     { 0x0c,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8762     { 0x0d,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8763     { 0x0e,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8764     { 0x0f,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8765     { 0, NULL },
8766 };
8767 guint8
8768 de_gmm_drx_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8769 {
8770     guint8      oct;
8771     guint32     curr_offset;
8772     const gchar *str;
8773     gchar       str_val[3];
8774     proto_item  *tf = NULL;
8775     proto_tree  *tf_tree = NULL;
8776     
8777     len = len;
8778     curr_offset = offset;
8779
8780     tf = proto_tree_add_text(tree,
8781         tvb, curr_offset, 2,
8782         "DRX Parameter");
8783
8784     tf_tree = proto_item_add_subtree(tf, ett_gmm_drx );
8785
8786     oct = tvb_get_guint8(tvb, curr_offset);
8787
8788     switch(oct)
8789     {
8790         case 0: str="704"; break;
8791         case 65: str="71"; break;
8792         case 66: str="72"; break;
8793         case 67: str="74"; break;
8794         case 68: str="75"; break;
8795         case 69: str="77"; break;
8796         case 70: str="79"; break;
8797         case 71: str="80"; break;
8798         case 72: str="83"; break;
8799         case 73: str="86"; break;
8800         case 74: str="88"; break;
8801         case 75: str="90"; break;
8802         case 76: str="92"; break;
8803         case 77: str="96"; break;
8804         case 78: str="101"; break;
8805         case 79: str="103"; break;
8806         case 80: str="107"; break;
8807         case 81: str="112"; break;
8808         case 82: str="116"; break;
8809         case 83: str="118"; break;
8810         case 84: str="128"; break;
8811         case 85: str="141"; break;
8812         case 86: str="144"; break;
8813         case 87: str="150"; break;
8814         case 88: str="160"; break;
8815         case 89: str="171"; break;
8816         case 90: str="176"; break;
8817         case 91: str="192"; break;
8818         case 92: str="214"; break;
8819         case 93: str="224"; break;
8820         case 94: str="235"; break;
8821         case 95: str="256"; break;
8822         case 96: str="288"; break;
8823         case 97: str="320"; break;
8824         case 98: str="352"; break;
8825         default:
8826                 str_val[0]=oct/10+'0';
8827                 str_val[1]=oct%10+'0';
8828                 str_val[2]=0;
8829                 str=str_val;
8830     }
8831
8832     proto_tree_add_text(tf_tree,
8833         tvb, curr_offset, 1,
8834         "Split PG Cycle Code: (%u) %s",
8835         oct,
8836         str);
8837
8838     curr_offset++;
8839         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef, tvb, curr_offset, 1, FALSE);
8840         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_split_on_ccch, tvb, curr_offset, 1, FALSE);
8841         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_non_drx_timer, tvb, curr_offset, 1, FALSE);
8842
8843     curr_offset++;
8844
8845     /* no length check possible */
8846
8847     return(curr_offset - offset);
8848 }
8849
8850 /*
8851  * [7] 10.5.5.7
8852  */
8853 static guint8
8854 de_gmm_ftostby(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8855 {
8856     guint8      oct;
8857     guint32     curr_offset;
8858     const gchar *str;
8859     
8860     len = len;
8861     curr_offset = offset;
8862
8863     oct = tvb_get_guint8(tvb, curr_offset);
8864
8865     switch(oct&7)
8866     {
8867         case 1: str="Force to standby indicated"; break;
8868         default: str="force to standby not indicated";
8869     }
8870
8871     proto_tree_add_text(tree,
8872         tvb, curr_offset, 1,
8873         "Force to Standby: (%u) %s",
8874         oct&7,
8875         str);
8876
8877     curr_offset++;
8878
8879     /* no length check possible */
8880
8881     return(curr_offset - offset);
8882 }
8883
8884 /*
8885  * [7] 10.5.5.7
8886  */
8887 static guint8
8888 de_gmm_ftostby_h(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8889 {
8890     guint8      oct;
8891     guint32     curr_offset;
8892     const gchar *str;
8893     
8894     len = len;
8895     curr_offset = offset;
8896
8897     oct = tvb_get_guint8(tvb, curr_offset);
8898
8899     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
8900     oct >>= 4;
8901
8902     switch(oct&7)
8903     {
8904         case 1: str="Force to standby indicated"; break;
8905         default: str="force to standby not indicated";
8906     }
8907
8908     proto_tree_add_text(tree,
8909         tvb, curr_offset, 1,
8910         "Force to Standby: (%u) %s",
8911         oct&7,
8912         str);
8913
8914     curr_offset++;
8915
8916     /* no length check possible */
8917
8918     return(curr_offset - offset);
8919 }
8920
8921 /*
8922  * [7] 10.5.5.8
8923  */
8924 static guint8
8925 de_gmm_ptmsi_sig(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8926 {
8927     guint32     curr_offset;
8928     proto_item  *curr_item;
8929     curr_offset = offset;
8930     curr_item= proto_tree_add_item(tree,hf_gsm_a_ptmsi_sig,tvb,curr_offset,3,FALSE);
8931     proto_item_append_text(curr_item,"%s",add_string ? add_string : "");
8932
8933     curr_offset+=3;
8934
8935     /* no length check possible */
8936
8937     return(curr_offset - offset);
8938 }
8939
8940 /*
8941  * [7] 10.5.5.8a
8942  */
8943 static guint8
8944 de_gmm_ptmsi_sig2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
8945 {
8946     guint32     curr_offset;
8947     proto_item  *curr_item;
8948     curr_offset = offset;
8949
8950     curr_item= proto_tree_add_item(tree,hf_gsm_a_ptmsi_sig2,tvb,curr_offset,3,FALSE);
8951     proto_item_append_text(curr_item,"%s",add_string ? add_string : "");
8952     curr_offset+=3;
8953
8954     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8955
8956     return(curr_offset - offset);
8957 }
8958
8959 /*
8960  * [7] 10.5.5.9
8961  */
8962 static guint8
8963 de_gmm_ident_type2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8964 {
8965     guint8      oct;
8966     guint32     curr_offset;
8967     const gchar *str;
8968     
8969     len = len;
8970     curr_offset = offset;
8971
8972     oct = tvb_get_guint8(tvb, curr_offset);
8973
8974     switch ( oct&7 )
8975     {
8976         case 2: str="IMEI"; break;
8977         case 3: str="IMEISV"; break;
8978         case 4: str="TMSI"; break;
8979         default: str="IMSI";
8980     }
8981     
8982     proto_tree_add_text(tree,
8983         tvb, curr_offset, 1,
8984         "Identity Type 2: (%u) %s",
8985         oct&7,
8986         str);
8987
8988     curr_offset++;
8989
8990     /* no length check possible */
8991
8992     return(curr_offset - offset);
8993 }
8994
8995 /*
8996  * [7] 10.5.5.10
8997  */
8998 static guint8
8999 de_gmm_imeisv_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
9000 {
9001     guint8      oct;
9002     guint32     curr_offset;
9003     const gchar *str;
9004     
9005     len = len;
9006     curr_offset = offset;
9007
9008     oct = tvb_get_guint8(tvb, curr_offset);
9009
9010     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
9011     oct >>= 4;
9012
9013     switch ( oct&7 )
9014     {
9015         case 1: str="IMEISV requested"; break;
9016         default: str="IMEISV not requested";
9017     }
9018     
9019     proto_tree_add_text(tree,
9020         tvb, curr_offset, 1,
9021         "IMEISV Request: (%u) %s",
9022         oct&7,
9023         str);
9024
9025     curr_offset++;
9026
9027     /* no length check possible */
9028
9029     return(curr_offset - offset);
9030 }
9031
9032 /*
9033  * [7] 10.5.5.11
9034  */
9035 static guint8
9036 de_gmm_rec_npdu_lst(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
9037 {
9038     guint32     curr_offset;
9039     guint       curr_len;
9040     
9041     curr_len = len;
9042     curr_offset = offset;
9043
9044     if ( len == 0 ) return 0;
9045
9046     do
9047     {
9048             guint32     oct;
9049             oct = tvb_get_guint8(tvb, curr_offset);
9050             oct <<=8;
9051             oct |= tvb_get_guint8(tvb, curr_offset+1);
9052             curr_len -= 2;
9053             oct <<=8;
9054
9055             proto_tree_add_text(tree,
9056                 tvb, curr_offset, 2,
9057                 "NSAPI %d: 0x%02x (%u)",
9058                 oct>>20,
9059                 (oct>>12)&0xff,
9060                 (oct>>12)&0xff);
9061             curr_offset+= 2;
9062
9063             if ( curr_len > 2 )
9064             {
9065                     oct |= tvb_get_guint8(tvb, curr_offset+2);
9066                     curr_len--;
9067                     oct <<= 12;
9068
9069                     proto_tree_add_text(tree,
9070                         tvb, curr_offset-1, 2,
9071                         "NSAPI %d: 0x%02x (%u)",
9072                         oct>>20,
9073                         (oct>>12)&0xff,
9074                         (oct>>12)&0xff);
9075                     curr_offset++;
9076             }
9077
9078
9079     } while ( curr_len > 1 );
9080
9081     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
9082
9083     return(curr_offset - offset);
9084 }
9085
9086 /*
9087  * [7] 10.5.5.12
9088  */
9089 guint8
9090 de_gmm_ms_net_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
9091 {
9092     guint8      oct;
9093     guint32     curr_offset;
9094     guint       curr_len;
9095     guint       gea_val;
9096     
9097     gchar answer_gea[2][40]={ "encryption algorithm not available",
9098                         "encryption algorithm available" };
9099     gchar answer_smdch[2][120]={ "Mobile station does not support mobile terminated point to point SMS via dedicated signalling channels",
9100                         "Mobile station supports mobile terminated point to point SMS via dedicated signalling channels" };
9101     gchar answer_smgprs[2][100]={ "Mobile station does not support mobile terminated point to point SMS via GPRS packet data channels",
9102                         "Mobile station supports mobile terminated point to point SMS via GPRS packet data channels" };
9103     gchar answer_ucs2[2][100]={ "the ME has a preference for the default alphabet (defined in 3GPP TS 23.038 [8b]) over UCS2",
9104                         "the ME has no preference between the use of the default alphabet and the use of UCS2" };
9105     
9106     gchar answer_ssid[4][80]={ "default value of phase 1",
9107                         "capability of handling of ellipsis notation and phase 2 error handling",
9108                         "capability of handling of ellipsis notation and phase 2 error handling",
9109                         "capability of handling of ellipsis notation and phase 2 error handling" };
9110
9111     gchar answer_solsa[2][40]={ "The ME does not support SoLSA",
9112                         "The ME supports SoLSA" };
9113                         
9114     gchar answer_rev[2][80]={ "used by a mobile station not supporting R99 or later versions of the protocol",
9115                         "used by a mobile station supporting R99 or later versions of the protocol" };
9116
9117     gchar answer_pfc[2][80]={ "Mobile station does not support BSS packet flow procedures",
9118                         "Mobile station does support BSS packet flow procedures" };
9119
9120     gchar answer_lcs[2][80]={ "LCS value added location request notification capability not supported" ,
9121                         "LCS value added location request notification capability supported" };
9122     
9123     curr_len = len;
9124     curr_offset = offset;
9125
9126     if ( curr_len == 0 ){ EXTRANEOUS_DATA_CHECK(len, curr_offset - offset); return(curr_offset - offset); }
9127     oct = tvb_get_guint8(tvb, curr_offset);
9128     curr_len--;
9129
9130         /* bit 8 */
9131     proto_tree_add_text(tree,
9132         tvb, curr_offset, 1,
9133         "GEA1: (%u) %s",
9134         oct>>7,
9135         answer_gea[oct>>7]);
9136     oct<<=1;
9137
9138         /* bit 7 */
9139     proto_tree_add_text(tree,
9140         tvb, curr_offset, 1,
9141         "SM capabilities via dedicated channels: (%u) %s",
9142         oct>>7,
9143         answer_smdch[oct>>7]);
9144     oct<<=1;
9145
9146         /* bit 6 */
9147     proto_tree_add_text(tree,
9148         tvb, curr_offset, 1,
9149         "SM capabilities via GPRS channels: (%u) %s",
9150         oct>>7,
9151         answer_smgprs[oct>>7]);
9152     oct<<=1;
9153
9154         /* bit 5 */
9155     proto_tree_add_text(tree,
9156         tvb, curr_offset, 1,
9157         "UCS2 support: (%u) %s",
9158         oct>>7,
9159         answer_ucs2[oct>>7]);
9160     oct<<=1;
9161         
9162         /* bit 4 3 */
9163     proto_tree_add_text(tree,
9164         tvb, curr_offset, 1,
9165         "SS Screening Indicator: (%u) %s",
9166         oct>>6,
9167         answer_ssid[oct>>6]);
9168     oct<<=2;
9169
9170         /* bit 2 */
9171     proto_tree_add_text(tree,
9172         tvb, curr_offset, 1,
9173         "SoLSA Capability: (%u) %s",
9174         oct>>7,
9175         answer_solsa[oct>>7]);
9176     oct<<=1;
9177
9178         /* bit 1 */
9179     proto_tree_add_text(tree,
9180         tvb, curr_offset, 1,
9181         "Revision level indicator: (%u) %s",
9182         oct>>7,
9183         answer_rev[oct>>7]);
9184
9185     curr_offset++;
9186
9187     if ( curr_len == 0 ){ EXTRANEOUS_DATA_CHECK(len, curr_offset - offset); return(curr_offset - offset); }
9188     oct = tvb_get_guint8(tvb, curr_offset);
9189     curr_len--;
9190
9191     proto_tree_add_text(tree,
9192         tvb, curr_offset, 1,
9193         "PFC feature mode: (%u) %s",
9194         oct>>7,
9195         answer_pfc[oct>>7]);
9196     oct<<=1;
9197
9198     for( gea_val=2; gea_val<8 ; gea_val++ )
9199     {
9200             proto_tree_add_text(tree,
9201                 tvb, curr_offset, 1,
9202                 "GEA%d: (%u) %s", gea_val,
9203                 oct>>7,
9204                 answer_gea[oct>>7]);
9205             oct<<=1;
9206     }
9207     
9208     proto_tree_add_text(tree,
9209         tvb, curr_offset, 1,
9210         "LCS VA capability:: (%u) %s",
9211         oct>>7,
9212         answer_lcs[oct>>7]);
9213     
9214     curr_offset++;         
9215                    
9216     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
9217
9218     return(curr_offset - offset);
9219 }
9220
9221 /*
9222  * [7] 10.5.5.12a
9223  */
9224 #define GET_DATA                                /* check if we have enough bits left */ \
9225                 if ( curr_bits_length < bits_needed ) \
9226                         continue; \
9227                 /* check if oct has enougth bits */ \
9228                 if ( bits_in_oct < bits_needed ) \
9229                 { \
9230                         guint32 tmp_oct; \
9231                         if ( curr_len == 0 ) \
9232                         { \
9233                                 proto_tree_add_text(tf_tree, \
9234                                 tvb, curr_offset, 1, \
9235                                 "Not enough data available"); \
9236                         } \
9237                         tmp_oct = tvb_get_guint8(tvb, curr_offset); \
9238                         oct |= tmp_oct<<(32-8-bits_in_oct); \
9239                         curr_len--; \
9240                         curr_offset++; \
9241                         if ( bits_in_oct != 0 ) \
9242                                 add_ocetets = 1; \
9243                         else \
9244                                 add_ocetets = 0; \
9245                         bits_in_oct += 8; \
9246                 } \
9247                 else \
9248                         add_ocetets = 0;
9249
9250
9251 guint8
9252 de_gmm_ms_radio_acc_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
9253 {
9254     guint32     curr_offset;
9255     guint       curr_len;
9256     proto_item  *tf = NULL;
9257     proto_tree      *tf_tree = NULL;
9258     guint32     oct;
9259     guchar      bits_in_oct;
9260     guchar      bits_needed;
9261     guint       bits_length;
9262     guint       add_ocetets;    /* octets which are covered by one element -1 */
9263     guint       curr_bits_length;
9264     guchar      acc_type;
9265     const gchar *str;
9266     gchar       multi_slot_str[64][230] = {
9267         "Not specified", /* 00 */
9268         "Max Rx-Slot/TDMA:1 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:2 Tta:3 Ttb:2 Tra:4 Trb:2 Type:1", /* 01 */
9269         "Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:3 Tta:3 Ttb:2 Tra:3 Trb:1 Type:1", /* 02 */
9270         "Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:3 Tta:3 Ttb:2 Tra:3 Trb:1 Type:1", /* 03 */
9271         "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:4 Tta:3 Ttb:1 Tra:3 Trb:1 Type:1", /* 04 */
9272         "Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:4 Tta:3 Ttb:1 Tra:3 Trb:1 Type:1", /* 05 */
9273         "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:4 Tta:3 Ttb:1 Tra:3 Trb:1 Type:1", /* 06 */
9274         "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:4 Tta:3 Ttb:1 Tra:3 Trb:1 Type:1", /* 07 */
9275         "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:5 Tta:3 Ttb:1 Tra:2 Trb:1 Type:1", /* 08 */
9276         "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:5 Tta:3 Ttb:1 Tra:2 Trb:1 Type:1", /* 09 */
9277         "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:5 Tta:3 Ttb:1 Tra:2 Trb:1 Type:1", /* 10 */
9278         "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:5 Tta:3 Ttb:1 Tra:2 Trb:1 Type:1", /* 11 */
9279         "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:5 Tta:2 Ttb:1 Tra:2 Trb:1 Type:1", /* 12 */
9280         "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:3 Trb:a) Type:2 (a: 1 with frequency hopping, 0 otherwise)", /* 13 */
9281         "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:3 Trb:a) Type:2 (a: 1 with frequency hopping, 0 otherwise)", /* 14 */
9282         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:5 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:3 Trb:a) Type:2 (a: 1 with frequency hopping, 0 otherwise)", /* 15 */
9283         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:6 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:2 Trb:a) Type:2 (a: 1 with frequency hopping, 0 otherwise)", /* 16 */
9284         "Max Rx-Slot/TDMA:7 Max Tx-Slot/TDMA:7 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:1 Trb:0 Type:2 (a: 1 with frequency hopping, 0 otherwise)", /* 17 */
9285         "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:8 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:0 Tra:0 Trb:0 Type:2", /* 18 */
9286         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 19 */     
9287         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 20 */
9288         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 21 */
9289         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 22 */
9290         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:6 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 23 */
9291         "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 24 */
9292         "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 25 */
9293         "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 26 */
9294         "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 27 */
9295         "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:6 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 28 */
9296         "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:8 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise", /* 29 */
9297         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1", /* 30 */
9298         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1", /* 31 */
9299         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1", /* 32 */
9300         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1", /* 33 */
9301         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:5 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1", /* 34 */
9302         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 35 */
9303         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 36 */
9304         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 37 */
9305         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 38 */
9306         "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:5 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 39 */
9307         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 40 */
9308         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 41 */
9309         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 42 */
9310         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 43 */
9311         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:5 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 44 */
9312         "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:6 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))", /* 45 */
9313         "Not specified", /* 46 */
9314         "Not specified", /* 47 */
9315         "Not specified", /* 48 */
9316         "Not specified", /* 49 */
9317         "Not specified", /* 50 */
9318         "Not specified", /* 51 */
9319         "Not specified", /* 52 */
9320         "Not specified", /* 53 */
9321         "Not specified", /* 54 */
9322         "Not specified", /* 55 */
9323         "Not specified", /* 56 */
9324         "Not specified", /* 57 */
9325         "Not specified", /* 58 */
9326         "Not specified", /* 59 */
9327         "Not specified", /* 60 */
9328         "Not specified", /* 61 */
9329         "Not specified", /* 62 */
9330         "Not specified", /* 63 */
9331         };
9332     guint index = 0;
9333     guchar dtm_gprs_mslot = 0;
9334     guchar dtm_egprs_mslot = 4;
9335     gboolean finished = TRUE;
9336     
9337     curr_len = len;
9338     curr_offset = offset;
9339
9340     bits_in_oct = 0;
9341     oct = 0;
9342
9343     do
9344     {
9345         /* check for a new round */
9346         if (( curr_len*8 + bits_in_oct ) < 11 )
9347                 break;
9348
9349         /* now read the first 11 bits */
9350         curr_bits_length = 11;  
9351         /*
9352          *
9353          */
9354         if ( curr_len != len )
9355         {
9356                 bits_needed = 1;
9357                 GET_DATA;
9358
9359                 if (( oct>>(32-bits_needed) ) == 1 )
9360                 {
9361                         curr_bits_length -= bits_needed;
9362                         oct <<= bits_needed;
9363                         bits_in_oct -= bits_needed;
9364                         
9365                         if (( curr_len*8 + bits_in_oct ) < 11 )
9366                                 break;
9367                         curr_bits_length = 11;
9368                 }
9369                 else
9370                 {
9371                         curr_bits_length -= bits_needed;
9372                         oct <<= bits_needed;
9373                         bits_in_oct -= bits_needed;
9374                         break;
9375                 }
9376         }
9377
9378         index++;
9379         tf = proto_tree_add_text(tree,
9380                 tvb, curr_offset, 1,
9381                 "MS RA capability %d",index);
9382
9383         tf_tree = proto_item_add_subtree(tf, ett_gmm_radio_cap );
9384
9385         /*
9386          * Access Technology
9387          */
9388         bits_needed = 4;
9389         GET_DATA;
9390         
9391         acc_type = oct>>(32-bits_needed);
9392         switch ( acc_type )
9393         {
9394                 case 0x00: str="GSM P"; break;
9395                 case 0x01: str="GSM E --note that GSM E covers GSM P"; break;
9396                 case 0x02: str="GSM R --note that GSM R covers GSM E and GSM P"; break;
9397                 case 0x03: str="GSM 1800"; break;
9398                 case 0x04: str="GSM 1900"; break;
9399                 case 0x05: str="GSM 450"; break;
9400                 case 0x06: str="GSM 480"; break;
9401                 case 0x07: str="GSM 850"; break;
9402                 case 0x08: str="GSM 700"; break;
9403                 case 0x0f: str="Indicates the presence of a list of Additional access technologies"; break;
9404                 default: str="unknown";
9405          }
9406
9407         proto_tree_add_text(tf_tree,
9408                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9409                 "Access Technology Type: (%u) %s",acc_type,str);
9410         curr_bits_length -= bits_needed;
9411         oct <<= bits_needed;
9412         bits_in_oct -= bits_needed;
9413         
9414         /*
9415          * get bits_length
9416          */
9417         bits_needed = 7;
9418         GET_DATA;
9419         
9420         bits_length = curr_bits_length = oct>>(32-bits_needed);
9421         proto_tree_add_text(tf_tree,
9422                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9423                 "Length: 0x%02x bits (%u)",bits_length,bits_length);
9424         /* This is already done - length doesn't contain this field
9425          curr_bits_length -= bits_needed;
9426         */
9427         oct <<= bits_needed;
9428         bits_in_oct -= bits_needed;
9429
9430         if ( acc_type == 0x0f )
9431         {
9432                 do 
9433                 {
9434                 /*
9435                  * Additional access technologies:
9436                  */
9437                         finished = TRUE; /* Break out of the loop unless proven unfinished */
9438
9439                         /*
9440                          * Presence bit
9441                          */
9442                         bits_needed = 1;
9443                         GET_DATA;
9444
9445                         /* analyse bits */
9446                         switch ( oct>>(32-bits_needed) )
9447                         {
9448                                 case 0x00: str="Not Present"; finished = TRUE; break;
9449                                 case 0x01: str="Present"; finished = FALSE; break;
9450                                 default: str="This should not happen";
9451                         }
9452
9453                         proto_tree_add_text(tf_tree,
9454                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9455                                 "Presence: (%u) %s",oct>>(32-bits_needed),str);
9456                         curr_bits_length -= bits_needed;
9457                         oct <<= bits_needed;
9458                         bits_in_oct -= bits_needed;
9459
9460                         if (finished)
9461                         {
9462                                 /*
9463                                  * No more valid data, get spare bits if any
9464                                  */
9465                                 while ( curr_bits_length > 0 )
9466                                 {
9467                                         if ( curr_bits_length > 8 )
9468                                                 bits_needed = 8;
9469                                         else
9470                                                 bits_needed = curr_bits_length;
9471                                         GET_DATA;
9472                                         curr_bits_length -= bits_needed;
9473                                         oct <<= bits_needed;
9474                                         bits_in_oct -= bits_needed;
9475                                 }
9476                                 continue;
9477                         }
9478
9479                 /*
9480                  * Access Technology
9481                  */
9482                 bits_needed = 4;
9483                 GET_DATA;
9484         
9485                 acc_type = oct>>(32-bits_needed);
9486                 switch ( acc_type )
9487                 {
9488                         case 0x00: str="GSM P"; break;
9489                         case 0x01: str="GSM E --note that GSM E covers GSM P"; break;
9490                         case 0x02: str="GSM R --note that GSM R covers GSM E and GSM P"; break;
9491                         case 0x03: str="GSM 1800"; break;
9492                         case 0x04: str="GSM 1900"; break;
9493                         case 0x05: str="GSM 450"; break;
9494                         case 0x06: str="GSM 480"; break;
9495                         case 0x07: str="GSM 850"; break;
9496                         case 0x08: str="GSM 700"; break;
9497                         case 0x0f: str="Indicates the presence of a list of Additional access technologies"; break;
9498                         default: str="unknown";
9499                  }
9500
9501                 proto_tree_add_text(tf_tree,
9502                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9503                         "Access Technology Type: (%u) %s",acc_type,str);
9504                 curr_bits_length -= bits_needed;
9505                 oct <<= bits_needed;
9506                 bits_in_oct -= bits_needed;
9507
9508                 /*
9509                  * RF Power
9510                  */
9511                 bits_needed = 3;
9512                 GET_DATA;
9513
9514                 /* analyse bits */
9515                 if ( acc_type == 0x04 ) /* GSM 1900 */
9516                 {
9517                         switch ( oct>>(32-bits_needed) )
9518                         {
9519                                 case 0x01: str="1 W (30 dBm)"; break;
9520                                 case 0x02: str="0,25 W (24 dBm)"; break;
9521                                 case 0x03: str="2 W (33 dBm)"; break;
9522                                 default: str="Not specified";
9523                         }
9524                 }
9525                 else if ( acc_type == 0x03 )
9526                 {
9527                         switch ( oct>>(32-bits_needed) )
9528                         {
9529                                 case 0x01: str="1 W (30 dBm)"; break;
9530                                 case 0x02: str="0,25 W (24 dBm)"; break;
9531                                 case 0x03: str="4 W (36 dBm)"; break;
9532                                 default: str="Not specified";
9533                         }
9534                 }
9535                 else if ( acc_type <= 0x08 )
9536                 {
9537                         switch ( oct>>(32-bits_needed) )
9538                         {
9539                                 case 0x02: str="8 W (39 dBm)"; break;
9540                                 case 0x03: str="5 W (37 dBm)"; break;
9541                                 case 0x04: str="2 W (33 dBm)"; break;
9542                                 case 0x05: str="0,8 W (29 dBm)"; break;
9543                                 default: str="Not specified";
9544                         }
9545                 }
9546                 else
9547                         str="Not specified??";
9548     
9549                 proto_tree_add_text(tf_tree,
9550                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9551                         "RF Power Capability, GMSK Power Class: (%u) %s",oct>>(32-bits_needed),str);
9552                 curr_bits_length -= bits_needed;
9553                 oct <<= bits_needed;
9554                 bits_in_oct -= bits_needed;
9555
9556                 /*
9557                  * 8PSK Power Class
9558                  */
9559                 bits_needed = 2;
9560                 GET_DATA;
9561
9562                 /* analyse bits */
9563                 switch ( oct>>(32-bits_needed) )
9564                 {
9565                         case 0x00: str="8PSK modulation not supported for uplink"; break;
9566                         case 0x01: str="Power class E1"; break;
9567                         case 0x02: str="Power class E2"; break;
9568                         case 0x03: str="Power class E3"; break;
9569                         default: str="This should not happen";
9570                 }
9571     
9572                 proto_tree_add_text(tf_tree,
9573                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9574                         "8PSK Power Class: (%u) %s",oct>>(32-bits_needed),str);
9575                 curr_bits_length -= bits_needed;
9576                 oct <<= bits_needed;
9577                 bits_in_oct -= bits_needed;
9578
9579                 } while (!finished);
9580                 
9581                 /* goto next one */
9582                 continue;
9583         }
9584         /*
9585          * RF Power
9586          */
9587         bits_needed = 3;
9588         GET_DATA;
9589
9590         /* analyse bits */
9591         if ( acc_type == 0x04 ) /* GSM 1900 */
9592         {
9593                 switch ( oct>>(32-bits_needed) )
9594                 {
9595                         case 0x01: str="1 W (30 dBm)"; break;
9596                         case 0x02: str="0,25 W (24 dBm)"; break;
9597                         case 0x03: str="2 W (33 dBm)"; break;
9598                         default: str="Not specified";
9599                 }
9600         }
9601         else if ( acc_type == 0x03 )
9602         {
9603                 switch ( oct>>(32-bits_needed) )
9604                 {
9605                         case 0x01: str="1 W (30 dBm)"; break;
9606                         case 0x02: str="0,25 W (24 dBm)"; break;
9607                         case 0x03: str="4 W (36 dBm)"; break;
9608                         default: str="Not specified";
9609                 }
9610         }
9611         else if ( acc_type <= 0x08 )
9612         {
9613                 switch ( oct>>(32-bits_needed) )
9614                 {
9615                         case 0x02: str="8 W (39 dBm)"; break;
9616                         case 0x03: str="5 W (37 dBm)"; break;
9617                         case 0x04: str="2 W (33 dBm)"; break;
9618                         case 0x05: str="0,8 W (29 dBm)"; break;
9619                         default: str="Not specified";
9620                 }
9621         }
9622         else
9623                 str="Not specified??";
9624     
9625         proto_tree_add_text(tf_tree,
9626                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9627                 "RF Power Capability, GMSK Power Class: (%u) %s",oct>>(32-bits_needed),str);
9628         curr_bits_length -= bits_needed;
9629         oct <<= bits_needed;
9630         bits_in_oct -= bits_needed;
9631
9632         /*
9633          * A5 Bits?
9634          */
9635         bits_needed = 1;
9636         GET_DATA;
9637
9638         /* analyse bits */
9639         if ((oct>>(32-bits_needed))==0)
9640         {
9641                 proto_tree_add_text(tf_tree,
9642                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9643                         "A5 Bits: (%u) same values apply for parameters as in the immediately preceding Access capabilities field within this IE",oct>>(32-bits_needed));
9644                 curr_bits_length -= bits_needed;
9645                 oct <<= bits_needed;
9646                 bits_in_oct -= bits_needed;
9647         }
9648         else
9649         {
9650                 int i;
9651
9652                 proto_tree_add_text(tf_tree,
9653                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9654                         "A5 Bits: (%u) A5 bits follows",oct>>(32-bits_needed));
9655
9656                 curr_bits_length -= bits_needed;
9657                 oct <<= bits_needed;
9658                 bits_in_oct -= bits_needed;
9659                 
9660                 for (i=1; i<= 7 ; i++ )
9661                 {
9662                         /*
9663                          * A5 Bits decoding
9664                          */
9665                         bits_needed = 1;
9666                         GET_DATA;
9667
9668                         /* analyse bits */
9669                         switch ( oct>>(32-bits_needed) )
9670                         {
9671                                 case 0x00: str="encryption algorithm not available"; break;
9672                                 case 0x01: str="encryption algorithm available"; break;
9673                                 default: str="This should not happen";
9674                         }
9675     
9676                         proto_tree_add_text(tf_tree,
9677                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9678                                 "A5/%d: (%u) %s",i,oct>>(32-bits_needed),str);
9679                         curr_bits_length -= bits_needed;
9680                         oct <<= bits_needed;
9681                         bits_in_oct -= bits_needed;
9682                 }
9683         }
9684     
9685         /*
9686          * ES IND
9687          */
9688         bits_needed = 1;
9689         GET_DATA;
9690
9691         /* analyse bits */
9692         switch ( oct>>(32-bits_needed) )
9693         {
9694                 case 0x00: str="controlled early Classmark Sending option is not implemented"; break;
9695                 case 0x01: str="controlled early Classmark Sending option is implemented"; break;
9696                 default: str="This should not happen";
9697         }
9698     
9699         proto_tree_add_text(tf_tree,
9700                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9701                 "Controlled early Classmark Sending: (%u) %s",oct>>(32-bits_needed),str);
9702         curr_bits_length -= bits_needed;
9703         oct <<= bits_needed;
9704         bits_in_oct -= bits_needed;
9705
9706         /*
9707          * PS
9708          */
9709         bits_needed = 1;
9710         GET_DATA;
9711
9712         /* analyse bits */
9713         switch ( oct>>(32-bits_needed) )
9714         {
9715                 case 0x00: str="PS capability not present"; break;
9716                 case 0x01: str="PS capability present"; break;
9717                 default: str="This should not happen";
9718         }
9719     
9720         proto_tree_add_text(tf_tree,
9721                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9722                 "Pseudo Synchronisation: (%u) %s",oct>>(32-bits_needed),str);
9723         curr_bits_length -= bits_needed;
9724         oct <<= bits_needed;
9725         bits_in_oct -= bits_needed;
9726
9727         /*
9728          * VGCS
9729          */
9730         bits_needed = 1;
9731         GET_DATA;
9732
9733         /* analyse bits */
9734         switch ( oct>>(32-bits_needed) )
9735         {
9736                 case 0x00: str="no VGCS capability or no notifications wanted"; break;
9737                 case 0x01: str="VGCS capability and notifications wanted"; break;
9738                 default: str="This should not happen";
9739         }
9740     
9741         proto_tree_add_text(tf_tree,
9742                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9743                 "Voice Group Call Service: (%u) %s",oct>>(32-bits_needed),str);
9744         curr_bits_length -= bits_needed;
9745         oct <<= bits_needed;
9746         bits_in_oct -= bits_needed;
9747
9748         /*
9749          * VBS
9750          */
9751         bits_needed = 1;
9752         GET_DATA;
9753
9754         /* analyse bits */
9755         switch ( oct>>(32-bits_needed) )
9756         {
9757                 case 0x00: str="no VBS capability or no notifications wanted"; break;
9758                 case 0x01: str="VBS capability and notifications wanted"; break;
9759                 default: str="This should not happen";
9760         }
9761     
9762         proto_tree_add_text(tf_tree,
9763                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9764                 "Voice Broadcast Service: (%u) %s",oct>>(32-bits_needed),str);
9765         curr_bits_length -= bits_needed;
9766         oct <<= bits_needed;
9767         bits_in_oct -= bits_needed;
9768
9769         /*
9770          * Multislot capability?
9771          */
9772         bits_needed = 1;
9773         GET_DATA;
9774
9775         /* analyse bits */
9776         if ((oct>>(32-bits_needed))==0)
9777         {
9778                 proto_tree_add_text(tf_tree,
9779                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9780                         "Multislot capability: (%u) same values apply for parameters as in the immediately preceding Access capabilities field within this IE",oct>>(32-bits_needed));
9781                 curr_bits_length -= bits_needed;
9782                 oct <<= bits_needed;
9783                 bits_in_oct -= bits_needed;
9784         }
9785         else
9786         {
9787                 proto_tree_add_text(tf_tree,
9788                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9789                         "Multislot capability: (%u) Multislot capability struct available",oct>>(32-bits_needed));
9790
9791                 curr_bits_length -= bits_needed;
9792                 oct <<= bits_needed;
9793                 bits_in_oct -= bits_needed;
9794
9795                 /*
9796                  * HSCSD multislot class?
9797                  */
9798                 bits_needed = 1;
9799                 GET_DATA;
9800
9801                 /* analyse bits */
9802                 if ((oct>>(32-bits_needed))==0)
9803                 {
9804                         proto_tree_add_text(tf_tree,
9805                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9806                                 "HSCSD multislot class: (%u) Bits are not available",oct>>(32-bits_needed));
9807                         curr_bits_length -= bits_needed;
9808                         oct <<= bits_needed;
9809                         bits_in_oct -= bits_needed;
9810                 }
9811                 else
9812                 {
9813                         curr_bits_length -= bits_needed;
9814                         oct <<= bits_needed;
9815                         bits_in_oct -= bits_needed;
9816
9817                         /*
9818                          * HSCSD multislot class
9819                          */
9820                         bits_needed = 5;
9821                         GET_DATA;
9822
9823                         /* analyse bits */
9824                         proto_tree_add_text(tf_tree,
9825                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9826                                 "HSCSD multislot class: (%u) %s",oct>>(32-bits_needed),multi_slot_str[oct>>(32-bits_needed)]);
9827                         curr_bits_length -= bits_needed;
9828                         oct <<= bits_needed;
9829                         bits_in_oct -= bits_needed;
9830                 }
9831
9832                 /*
9833                  * GPRS multislot class?
9834                  */
9835                 bits_needed = 1;
9836                 GET_DATA;
9837
9838                 /* analyse bits */
9839                 if ((oct>>(32-bits_needed))==0)
9840                 {
9841                         proto_tree_add_text(tf_tree,
9842                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9843                                 "GPRS multislot class: (%u) Bits are not available",oct>>(32-bits_needed));
9844                         curr_bits_length -= bits_needed;
9845                         oct <<= bits_needed;
9846                         bits_in_oct -= bits_needed;
9847                 }
9848                 else
9849                 {
9850                         curr_bits_length -= bits_needed;
9851                         oct <<= bits_needed;
9852                         bits_in_oct -= bits_needed;
9853
9854                         /*
9855                          * GPRS multislot class
9856                          */
9857                         bits_needed = 5;
9858                         GET_DATA;
9859
9860                         /* analyse bits */
9861                         proto_tree_add_text(tf_tree,
9862                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9863                                 "GPRS multislot class: (%u) %s",oct>>(32-bits_needed),multi_slot_str[oct>>(32-bits_needed)]);
9864                         curr_bits_length -= bits_needed;
9865                         oct <<= bits_needed;
9866                         bits_in_oct -= bits_needed;
9867
9868                         /*
9869                          * GPRS Extended Dynamic Allocation Capability
9870                          */
9871                         bits_needed = 1;
9872                         GET_DATA;
9873
9874                         /* analyse bits */
9875                         switch ( oct>>(32-bits_needed) )
9876                         {
9877                                 case 0x00: str="Extended Dynamic Allocation Capability for GPRS is not implemented"; break;
9878                                 case 0x01: str="Extended Dynamic Allocation Capability for GPRS is implemented"; break;
9879                                 default: str="This should not happen";
9880                         }
9881                         proto_tree_add_text(tf_tree,
9882                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9883                                 "GPRS Extended Dynamic Allocation Capability: (%u) %s",oct>>(32-bits_needed),str);
9884                         curr_bits_length -= bits_needed;
9885                         oct <<= bits_needed;
9886                         bits_in_oct -= bits_needed;
9887                 }
9888
9889                 /*
9890                  * SMS/SM values
9891                  */
9892                 bits_needed = 1;
9893                 GET_DATA;
9894
9895                 /* analyse bits */
9896                 if ((oct>>(32-bits_needed))==0)
9897                 {
9898                         proto_tree_add_text(tf_tree,
9899                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9900                                 "SMS/SM values: (%u) Bits are not available",oct>>(32-bits_needed));
9901                         curr_bits_length -= bits_needed;
9902                         oct <<= bits_needed;
9903                         bits_in_oct -= bits_needed;
9904                 }
9905                 else
9906                 {
9907                         curr_bits_length -= bits_needed;
9908                         oct <<= bits_needed;
9909                         bits_in_oct -= bits_needed;
9910
9911                         /*
9912                          * Switch-Measure-Switch value
9913                          */
9914                         bits_needed = 4;
9915                         GET_DATA;
9916
9917                         /* analyse bits */
9918                         proto_tree_add_text(tf_tree,
9919                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9920                                 "Switch-Measure-Switch value: (%u) %d/4 timeslot (~%d microseconds)",
9921                                 oct>>(32-bits_needed),oct>>(32-bits_needed),(oct>>(32-bits_needed))*144);
9922                         curr_bits_length -= bits_needed;
9923                         oct <<= bits_needed;
9924                         bits_in_oct -= bits_needed;
9925
9926                         /*
9927                          * Switch-Measure value
9928                          */
9929                         bits_needed = 4;
9930                         GET_DATA;
9931
9932                         /* analyse bits */
9933                         proto_tree_add_text(tf_tree,
9934                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9935                                 "Switch-Measure value: (%u) %d/4 timeslot (~%d microseconds)",
9936                                 oct>>(32-bits_needed),oct>>(32-bits_needed),(oct>>(32-bits_needed))*144);
9937                         curr_bits_length -= bits_needed;
9938                         oct <<= bits_needed;
9939                         bits_in_oct -= bits_needed;
9940                 }
9941
9942                 /*
9943                  * ECSD multislot class?
9944                  */
9945                 bits_needed = 1;
9946                 GET_DATA;
9947
9948                 /* analyse bits */
9949                 if ((oct>>(32-bits_needed))==0)
9950                 {
9951                         proto_tree_add_text(tf_tree,
9952                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9953                                 "ECSD multislot class: (%u) Bits are not available",oct>>(32-bits_needed));
9954                         curr_bits_length -= bits_needed;
9955                         oct <<= bits_needed;
9956                         bits_in_oct -= bits_needed;
9957                 }
9958                 else
9959                 {
9960                         curr_bits_length -= bits_needed;
9961                         oct <<= bits_needed;
9962                         bits_in_oct -= bits_needed;
9963
9964                         /*
9965                          * ECSD multislot class
9966                          */
9967                         bits_needed = 5;
9968                         GET_DATA;
9969
9970                         /* analyse bits */
9971                         proto_tree_add_text(tf_tree,
9972                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9973                                 "ECSD multislot class: (%u) %s",oct>>(32-bits_needed),multi_slot_str[oct>>(32-bits_needed)]);
9974                         curr_bits_length -= bits_needed;
9975                         oct <<= bits_needed;
9976                         bits_in_oct -= bits_needed;
9977                 }
9978
9979                 /*
9980                  * EGPRS multislot class?
9981                  */
9982                 bits_needed = 1;
9983                 GET_DATA;
9984
9985                 /* analyse bits */
9986                 if ((oct>>(32-bits_needed))==0)
9987                 {
9988                         proto_tree_add_text(tf_tree,
9989                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9990                                 "EGPRS multislot class: (%u) Bits are not available",oct>>(32-bits_needed));
9991                         curr_bits_length -= bits_needed;
9992                         oct <<= bits_needed;
9993                         bits_in_oct -= bits_needed;
9994                 }
9995                 else
9996                 {
9997                         curr_bits_length -= bits_needed;
9998                         oct <<= bits_needed;
9999                         bits_in_oct -= bits_needed;
10000
10001                         /*
10002                          * EGPRS multislot class
10003                          */
10004                         bits_needed = 5;
10005                         GET_DATA;
10006
10007                         /* analyse bits */
10008                         proto_tree_add_text(tf_tree,
10009                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10010                                 "EGPRS multislot class: (%u) %s",oct>>(32-bits_needed),multi_slot_str[oct>>(32-bits_needed)]);
10011                         curr_bits_length -= bits_needed;
10012                         oct <<= bits_needed;
10013                         bits_in_oct -= bits_needed;
10014
10015                         /*
10016                          * EGPRS Extended Dynamic Allocation Capability
10017                          */
10018                         bits_needed = 1;
10019                         GET_DATA;
10020
10021                         /* analyse bits */
10022                         switch ( oct>>(32-bits_needed) )
10023                         {
10024                                 case 0x00: str="Extended Dynamic Allocation Capability for EGPRS is not implemented"; break;
10025                                 case 0x01: str="Extended Dynamic Allocation Capability for EGPRS is implemented"; break;
10026                                 default: str="This should not happen";
10027                         }
10028                         proto_tree_add_text(tf_tree,
10029                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10030                                 "EGPRS Extended Dynamic Allocation Capability: (%u) %s",oct>>(32-bits_needed),str);
10031                         curr_bits_length -= bits_needed;
10032                         oct <<= bits_needed;
10033                         bits_in_oct -= bits_needed;
10034                 }
10035
10036                 /*
10037                  * DTM GPRS Multi Slot Class ?
10038                 */
10039                 bits_needed = 1;
10040                 GET_DATA;
10041
10042                 /* analyse bits */
10043                 if ((oct>>(32-bits_needed))==0)
10044                 {
10045                         proto_tree_add_text(tf_tree,
10046                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10047                                 "DTM GPRS Multi Slot Class: (%u) Bits are not available",oct>>(32-bits_needed));
10048                         curr_bits_length -= bits_needed;
10049                         oct <<= bits_needed;
10050                         bits_in_oct -= bits_needed;
10051                 }
10052                 else
10053                 {
10054                         curr_bits_length -= bits_needed;
10055                         oct <<= bits_needed;
10056                         bits_in_oct -= bits_needed;
10057
10058                         /*
10059                          * DTM GPRS Multi Slot Class
10060                          */
10061                         bits_needed = 2;
10062                         GET_DATA;
10063
10064                         /* analyse bits */
10065                         dtm_gprs_mslot = oct>>(32-bits_needed);
10066
10067                         switch ( oct>>(32-bits_needed) )
10068                         {
10069                                 case 0: str="Unused. If received, the network shall interpret this as Multislot class 5"; break;
10070                                 case 1: str="Multislot class 5 supported"; break;
10071                                 case 2: str="Multislot class 9 supported"; break;
10072                                 case 3: str="Multislot class 11 supported"; break;
10073                                 default: str="This should not happen";
10074                         }
10075                         
10076                         proto_tree_add_text(tf_tree,
10077                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10078                                 "DTM GPRS Multi Slot Class: (%u) %s",oct>>(32-bits_needed),str);
10079                         curr_bits_length -= bits_needed;
10080                         oct <<= bits_needed;
10081                         bits_in_oct -= bits_needed;
10082
10083                         /*
10084                          * Single Slot DTM
10085                          */
10086                         bits_needed = 1;
10087                         GET_DATA;
10088
10089                         /* analyse bits */
10090                         switch ( oct>>(32-bits_needed) )
10091                         {
10092                                 case 0x00: str="Single Slot DTM not supported"; break;
10093                                 case 0x01: str="Single Slot DTM supported"; break;
10094                                 default: str="This should not happen";
10095                         }
10096                         proto_tree_add_text(tf_tree,
10097                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10098                                 "Single Slot DTM: (%u) %s",oct>>(32-bits_needed),str);
10099                         curr_bits_length -= bits_needed;
10100                         oct <<= bits_needed;
10101                         bits_in_oct -= bits_needed;
10102
10103                         /*
10104                          * DTM EGPRS Multi Slot Class ?
10105                         */
10106                         bits_needed = 1;
10107                         GET_DATA;
10108
10109                         /* analyse bits */
10110                         dtm_egprs_mslot = oct>>(32-bits_needed);
10111
10112                         if ((oct>>(32-bits_needed))==0)
10113                         {
10114                                 proto_tree_add_text(tf_tree,
10115                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10116                                         "DTM EGPRS Multi Slot Class: (%u) Bits are not available",oct>>(32-bits_needed));
10117                                 curr_bits_length -= bits_needed;
10118                                 oct <<= bits_needed;
10119                                 bits_in_oct -= bits_needed;
10120                         }
10121                         else
10122                         {
10123                                 curr_bits_length -= bits_needed;
10124                                 oct <<= bits_needed;
10125                                 bits_in_oct -= bits_needed;
10126
10127                                 /*
10128                                  * DTM EGPRS Multi Slot Class
10129                                  */
10130                                 bits_needed = 2;
10131                                 GET_DATA;
10132
10133                                 /* analyse bits */
10134                                 switch ( oct>>(32-bits_needed) )
10135                                 {
10136                                         case 0: str="Unused. If received, the network shall interpret this as Multislot class 5"; break;
10137                                         case 1: str="Multislot class 5 supported"; break;
10138                                         case 2: str="Multislot class 9 supported"; break;
10139                                         case 3: str="Multislot class 11 supported"; break;
10140                                         default: str="This should not happen";
10141                                 }
10142                         
10143                                 proto_tree_add_text(tf_tree,
10144                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10145                                         "DTM EGPRS Multi Slot Class: (%u) %s",oct>>(32-bits_needed),str);
10146                                 curr_bits_length -= bits_needed;
10147                                 oct <<= bits_needed;
10148                                 bits_in_oct -= bits_needed;
10149                         }
10150                 }
10151         }
10152
10153         /*
10154          * 8PSK Power Capability?
10155          */
10156         bits_needed = 1;
10157         GET_DATA;
10158
10159         /* analyse bits */
10160         if ((oct>>(32-bits_needed))==0)
10161         {
10162                 proto_tree_add_text(tf_tree,
10163                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10164                         "8PSK Power Capability: (%u) Bits are not available",oct>>(32-bits_needed));
10165                 curr_bits_length -= bits_needed;
10166                 oct <<= bits_needed;
10167                 bits_in_oct -= bits_needed;
10168         }
10169         else
10170         {
10171                 curr_bits_length -= bits_needed;
10172                 oct <<= bits_needed;
10173                 bits_in_oct -= bits_needed;
10174
10175                 /*
10176                  * 8PSK Power Capability
10177                  */
10178                 bits_needed = 2;
10179                 GET_DATA;
10180
10181                 /* analyse bits */
10182                 switch ( oct>>(32-bits_needed) )
10183                 {
10184                         case 0x00: str="Reserved"; break;
10185                         case 0x01: str="Power class E1"; break;
10186                         case 0x02: str="Power class E2"; break;
10187                         case 0x03: str="Power class E3"; break;
10188                         default: str="This should not happen";
10189                 }
10190     
10191                 proto_tree_add_text(tf_tree,
10192                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10193                         "8PSK Power Capability: (%u) %s",oct>>(32-bits_needed),str);
10194                 curr_bits_length -= bits_needed;
10195                 oct <<= bits_needed;
10196                 bits_in_oct -= bits_needed;
10197         }
10198
10199         /*
10200          * COMPACT Interference Measurement Capability
10201          */
10202         bits_needed = 1;
10203         GET_DATA;
10204
10205         /* analyse bits */
10206         switch ( oct>>(32-bits_needed) )
10207         {
10208                 case 0x00: str="COMPACT Interference Measurement Capability is not implemented"; break;
10209                 case 0x01: str="COMPACT Interference Measurement Capability is implemented"; break;
10210                 default: str="This should not happen";
10211         }
10212     
10213         proto_tree_add_text(tf_tree,
10214                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10215                 "COMPACT Interference Measurement Capability: (%u) %s",oct>>(32-bits_needed),str);
10216         curr_bits_length -= bits_needed;
10217         oct <<= bits_needed;
10218         bits_in_oct -= bits_needed;
10219
10220         /*
10221          * Revision Level Indicator
10222          */
10223         bits_needed = 1;
10224         GET_DATA;
10225
10226         /* analyse bits */
10227         switch ( oct>>(32-bits_needed) )
10228         {
10229                 case 0x00: str="The ME is Release 98 or older"; break;
10230                 case 0x01: str="The ME is Release 99 onwards"; break;
10231                 default: str="This should not happen";
10232         }
10233     
10234         proto_tree_add_text(tf_tree,
10235                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10236                 "Revision Level Indicator: (%u) %s",oct>>(32-bits_needed),str);
10237         curr_bits_length -= bits_needed;
10238         oct <<= bits_needed;
10239         bits_in_oct -= bits_needed;
10240
10241         /*
10242          * UMTS FDD Radio Access Technology Capability
10243          */
10244         bits_needed = 1;
10245         GET_DATA;
10246
10247         /* analyse bits */
10248         switch ( oct>>(32-bits_needed) )
10249         {
10250                 case 0x00: str="UMTS FDD not supported"; break;
10251                 case 0x01: str="UMTS FDD supported"; break;
10252                 default: str="This should not happen";
10253         }
10254     
10255         proto_tree_add_text(tf_tree,
10256                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10257                 "UMTS FDD Radio Access Technology Capability: (%u) %s",oct>>(32-bits_needed),str);
10258         curr_bits_length -= bits_needed;
10259         oct <<= bits_needed;
10260         bits_in_oct -= bits_needed;
10261
10262         /*
10263          * UMTS 3.84 Mcps TDD Radio Access Technology Capability
10264          */
10265         bits_needed = 1;
10266         GET_DATA;
10267
10268         /* analyse bits */
10269         switch ( oct>>(32-bits_needed) )
10270         {
10271                 case 0x00: str="UMTS 3.84 Mcps TDD not supported"; break;
10272                 case 0x01: str="UMTS 3.84 Mcps TDD supported"; break;
10273                 default: str="This should not happen";
10274         }
10275     
10276         proto_tree_add_text(tf_tree,
10277                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10278                 "UMTS 3.84 Mcps TDD Radio Access Technology Capability: (%u) %s",oct>>(32-bits_needed),str);
10279         curr_bits_length -= bits_needed;
10280         oct <<= bits_needed;
10281         bits_in_oct -= bits_needed;
10282
10283         /*
10284          * CDMA 2000 Radio Access Technology Capability
10285          */
10286         bits_needed = 1;
10287         GET_DATA;
10288
10289         /* analyse bits */
10290         switch ( oct>>(32-bits_needed) )
10291         {
10292                 case 0x00: str="CDMA 2000 not supported"; break;
10293                 case 0x01: str="CDMA 2000 supported"; break;
10294                 default: str="This should not happen";
10295         }
10296     
10297         proto_tree_add_text(tf_tree,
10298                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10299                 "CDMA 2000 Radio Access Technology Capability: (%u) %s",oct>>(32-bits_needed),str);
10300         curr_bits_length -= bits_needed;
10301         oct <<= bits_needed;
10302         bits_in_oct -= bits_needed;
10303
10304         /*
10305          * UMTS 1.28 Mcps TDD Radio Access Technology Capability
10306          */
10307         bits_needed = 1;
10308         GET_DATA;
10309
10310         /* analyse bits */
10311         switch ( oct>>(32-bits_needed) )
10312         {
10313                 case 0x00: str="UMTS 1.28 Mcps TDD not supported"; break;
10314                 case 0x01: str="UMTS 1.28 Mcps TDD supported"; break;
10315                 default: str="This should not happen";
10316         }
10317     
10318         proto_tree_add_text(tf_tree,
10319                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10320                 "UMTS 1.28 Mcps TDD Radio Access Technology Capability: (%u) %s",oct>>(32-bits_needed),str);
10321         curr_bits_length -= bits_needed;
10322         oct <<= bits_needed;
10323         bits_in_oct -= bits_needed;
10324
10325         /*
10326          * GERAN Feature Package 1
10327          */
10328         bits_needed = 1;
10329         GET_DATA;
10330
10331         /* analyse bits */
10332         switch ( oct>>(32-bits_needed) )
10333         {
10334                 case 0x00: str="GERAN feature package 1 not supported"; break;
10335                 case 0x01: str="GERAN feature package 1 supported"; break;
10336                 default: str="This should not happen";
10337         }
10338     
10339         proto_tree_add_text(tf_tree,
10340                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10341                 "GERAN Feature Package 1: (%u) %s",oct>>(32-bits_needed),str);
10342         curr_bits_length -= bits_needed;
10343         oct <<= bits_needed;
10344         bits_in_oct -= bits_needed;
10345
10346         /*
10347          * Extended DTM (E)GPRS Multi Slot Class
10348          */
10349         bits_needed = 1;
10350         GET_DATA;
10351
10352         /* analyse bits */
10353         if ((oct>>(32-bits_needed))==0)
10354         {
10355                 proto_tree_add_text(tf_tree,
10356                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10357                         "Extended DTM (E)GPRS Multi Slot Class: (%u) Bits are not available",oct>>(32-bits_needed));
10358                 curr_bits_length -= bits_needed;
10359                 oct <<= bits_needed;
10360                 bits_in_oct -= bits_needed;
10361         }
10362         else
10363         {
10364                 curr_bits_length -= bits_needed;
10365                 oct <<= bits_needed;
10366                 bits_in_oct -= bits_needed;
10367
10368                 /*
10369                  * Extended DTM GPRS Multi Slot Class
10370                  */
10371                 bits_needed = 2;
10372                 GET_DATA;
10373
10374                 /* analyse bits */
10375                 switch ( (oct>>(32-bits_needed))|(dtm_gprs_mslot<<4) )
10376                 {
10377                         case 0x00: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10378                         case 0x01: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10379                         case 0x02: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10380                         case 0x03: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10381                         case 0x10: str="Multislot class 5 supported"; break;
10382                         case 0x11: str="Multislot class 6 supported"; break;
10383                         case 0x12: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10384                         case 0x13: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10385                         case 0x20: str="Multislot class 9 supported"; break;
10386                         case 0x21: str="Multislot class 10 supported"; break;
10387                         case 0x22: str="Unused. If received, it shall be interpreted as Multislot class 9 supported"; break;
10388                         case 0x23: str="Unused. If received, it shall be interpreted as Multislot class 9 supported"; break;
10389                         case 0x30: str="Multislot class 11 supported"; break;
10390                         case 0x31: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10391                         case 0x32: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10392                         case 0x33: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10393                         default: str="This should not happen";
10394                 }
10395     
10396                 proto_tree_add_text(tf_tree,
10397                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10398                         "Extended DTM GPRS Multi Slot Class: (%u) %s",oct>>(32-bits_needed),str);
10399                 curr_bits_length -= bits_needed;
10400                 oct <<= bits_needed;
10401                 bits_in_oct -= bits_needed;
10402
10403                 if ( dtm_egprs_mslot <= 3 )
10404                 {
10405                         /*
10406                          * Extended DTM EGPRS Multi Slot Class
10407                          */
10408                         bits_needed = 2;
10409                         GET_DATA;
10410
10411                         /* analyse bits */
10412                         switch ( (oct>>(32-bits_needed))|(dtm_egprs_mslot<<4) )
10413                         {
10414                                 case 0x00: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10415                                 case 0x01: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10416                                 case 0x02: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10417                                 case 0x03: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10418                                 case 0x10: str="Multislot class 5 supported"; break;
10419                                 case 0x11: str="Multislot class 6 supported"; break;
10420                                 case 0x12: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10421                                 case 0x13: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10422                                 case 0x20: str="Multislot class 9 supported"; break;
10423                                 case 0x21: str="Multislot class 10 supported"; break;
10424                                 case 0x22: str="Unused. If received, it shall be interpreted as Multislot class 9 supported"; break;
10425                                 case 0x23: str="Unused. If received, it shall be interpreted as Multislot class 9 supported"; break;
10426                                 case 0x30: str="Multislot class 11 supported"; break;
10427                                 case 0x31: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10428                                 case 0x32: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10429                                 case 0x33: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10430                                 default: str="This should not happen";
10431                         }
10432     
10433                         proto_tree_add_text(tf_tree,
10434                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10435                                 "Extended DTM EGPRS Multi Slot Class: (%u) %s",oct>>(32-bits_needed),str);
10436                         curr_bits_length -= bits_needed;
10437                         oct <<= bits_needed;
10438                         bits_in_oct -= bits_needed;
10439                 }
10440         }
10441
10442         /*
10443          * Modulation based multislot class support
10444          */
10445         bits_needed = 1;
10446         GET_DATA;
10447
10448         /* analyse bits */
10449         switch ( oct>>(32-bits_needed) )
10450         {
10451                 case 0x00: str="Modulation based multislot class not supported"; break;
10452                 case 0x01: str="Modulation based multislot class supported"; break;
10453                 default: str="This should not happen";
10454         }
10455     
10456         proto_tree_add_text(tf_tree,
10457                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10458                 "Modulation based multislot class support: (%u) %s",oct>>(32-bits_needed),str);
10459         curr_bits_length -= bits_needed;
10460         oct <<= bits_needed;
10461         bits_in_oct -= bits_needed;
10462
10463         /*
10464          * High Multislot Capability
10465          */
10466         bits_needed = 1;
10467         GET_DATA;
10468
10469         /* analyse bits */
10470         if ((oct>>(32-bits_needed))==0)
10471         {
10472                 proto_tree_add_text(tf_tree,
10473                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10474                         "High Multislot Capability: (%u) Bits are not available",oct>>(32-bits_needed));
10475                 curr_bits_length -= bits_needed;
10476                 oct <<= bits_needed;
10477                 bits_in_oct -= bits_needed;
10478         }
10479         else
10480         {
10481                 curr_bits_length -= bits_needed;
10482                 oct <<= bits_needed;
10483                 bits_in_oct -= bits_needed;
10484
10485                 /*
10486                  * High Multislot Capability
10487                  */
10488                 bits_needed = 2;
10489                 GET_DATA;
10490
10491                 /* analyse bits */
10492                 proto_tree_add_text(tf_tree,
10493                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10494                         "High Multislot Capability: 0x%02x (%u) - This field effect all other multislot fields. To understand the value please read TS 24.008 5.6.0 Release 5 Chap 10.5.5.12 Page 406",oct>>(32-bits_needed),oct>>(32-bits_needed));
10495                 curr_bits_length -= bits_needed;
10496                 oct <<= bits_needed;
10497                 bits_in_oct -= bits_needed;
10498
10499         }
10500
10501         /*
10502          * GERAN Iu Mode Capability
10503          */
10504         bits_needed = 1;
10505         GET_DATA;
10506
10507         /* analyse bits */
10508         switch ( oct>>(32-bits_needed) )
10509         {
10510                 case 0x00: str="GERAN Iu mode not supported"; break;
10511                 case 0x01: str="GERAN Iu mode supported"; break;
10512                 default: str="This should not happen";
10513         }
10514     
10515         proto_tree_add_text(tf_tree,
10516                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10517                 "GERAN Iu Mode Capability: (%u) %s",oct>>(32-bits_needed),str);
10518         curr_bits_length -= bits_needed;
10519         oct <<= bits_needed;
10520         bits_in_oct -= bits_needed;
10521
10522         /*
10523          * GMSK/8-PSK Multislot Power Profile
10524          */
10525         bits_needed = 1;
10526         GET_DATA;
10527
10528         /* analyse bits */
10529         if ((oct>>(32-bits_needed))==0)
10530         {
10531                 proto_tree_add_text(tf_tree,
10532                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10533                         "GMSK/8-PSK Multislot Power Profile: (%u) Bits are not available",oct>>(32-bits_needed));
10534                 curr_bits_length -= bits_needed;
10535                 oct <<= bits_needed;
10536                 bits_in_oct -= bits_needed;
10537         }
10538         else
10539         {
10540                 curr_bits_length -= bits_needed;
10541                 oct <<= bits_needed;
10542                 bits_in_oct -= bits_needed;
10543
10544                 /*
10545                  * GMSK Multislot Power Profile
10546                  */
10547                 bits_needed = 2;
10548                 GET_DATA;
10549
10550                 /* analyse bits */
10551                 switch ( oct>>(32-bits_needed) )
10552                 {
10553                         case 0x00: str="GMSK_MULTISLOT_POWER_PROFILE 0"; break;
10554                         case 0x01: str="GMSK_MULTISLOT_POWER_PROFILE 1"; break;
10555                         case 0x02: str="GMSK_MULTISLOT_POWER_PROFILE 2"; break;
10556                         case 0x03: str="GMSK_MULTISLOT_POWER_PROFILE 3"; break;
10557                         default: str="This should not happen";
10558                 }
10559                 
10560                 proto_tree_add_text(tf_tree,
10561                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10562                         "GMSK Multislot Power Profile: (%u) %s",oct>>(32-bits_needed),str);
10563                 curr_bits_length -= bits_needed;
10564                 oct <<= bits_needed;
10565                 bits_in_oct -= bits_needed;
10566
10567                 /*
10568                  * 8-PSK Multislot Power Profile
10569                  */
10570                 bits_needed = 2;
10571                 GET_DATA;
10572
10573                 /* analyse bits */
10574                 switch ( oct>>(32-bits_needed) )
10575                 {
10576                         case 0x00: str="8-PSK_MULTISLOT_POWER_PROFILE 0"; break;
10577                         case 0x01: str="8-PSK_MULTISLOT_POWER_PROFILE 1"; break;
10578                         case 0x02: str="8-PSK_MULTISLOT_POWER_PROFILE 2"; break;
10579                         case 0x03: str="8-PSK_MULTISLOT_POWER_PROFILE 3"; break;
10580                         default: str="This should not happen";
10581                 }
10582                 
10583                 proto_tree_add_text(tf_tree,
10584                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10585                         "8-PSK Multislot Power Profile: (%u) %s",oct>>(32-bits_needed),str);
10586                 curr_bits_length -= bits_needed;
10587                 oct <<= bits_needed;
10588                 bits_in_oct -= bits_needed;
10589
10590         }
10591
10592         /*
10593          * we are too long ... so jump over it
10594          */
10595         while ( curr_bits_length > 0 )
10596         {
10597                 if ( curr_bits_length > 8 )
10598                         bits_needed = 8;
10599                 else
10600                         bits_needed = curr_bits_length;
10601                 GET_DATA;
10602                 curr_bits_length -= bits_needed;
10603                 oct <<= bits_needed;
10604                 bits_in_oct -= bits_needed;
10605         }        
10606         
10607     } while ( 1 );
10608     
10609     curr_offset+= curr_len;        
10610                    
10611     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
10612
10613     return(curr_offset - offset);
10614 }
10615
10616 /*
10617  * [7] 10.5.5.13
10618  */
10619 static guint8
10620 de_gc_spare(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10621 {
10622     guint32     curr_offset;
10623     
10624     len = len;
10625     curr_offset = offset;
10626
10627     proto_tree_add_text(tree,
10628         tvb, curr_offset, 1,
10629         "Spare Nibble");
10630
10631     curr_offset++;
10632
10633     /* no length check possible */
10634
10635     return(curr_offset - offset);
10636 }
10637
10638 /*
10639  * [7] 10.5.5.14
10640  */
10641 static guint8
10642 de_gmm_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10643 {
10644     guint8      oct;
10645     guint32     curr_offset;
10646     const gchar *str;
10647     
10648     len = len;
10649     curr_offset = offset;
10650
10651     oct = tvb_get_guint8(tvb, curr_offset);
10652
10653     switch ( oct )
10654     {
10655         /* additional causes can be found in annex g */
10656         case 0x02: str="IMSI unknown in HLR"; break;
10657         case 0x03: str="Illegal MS"; break;
10658         case 0x04: str="IMSI unknown in VLR"; break;
10659         case 0x05: str="IMEI not accepted"; break;
10660         case 0x06: str="Illegal ME"; break;
10661         case 0x07: str="GPRS services not allowed"; break;
10662         case 0x08: str="GPRS services and non-GPRS services not allowed"; break;
10663         case 0x09: str="MS identity cannot be derived by the network"; break;
10664         case 0x0a: str="Implicitly detached"; break;
10665         case 0x0b: str="PLMN not allowed"; break;
10666         case 0x0c: str="Location Area not allowed"; break;
10667         case 0x0d: str="Roaming not allowed in this location area"; break;
10668         case 0x0e: str="GPRS services not allowed in this PLMN"; break;
10669         case 0x0f: str="No Suitable Cells In Location Area"; break;
10670         case 0x10: str="MSC temporarily not reachable"; break;
10671         case 0x11: str="Network failure"; break;
10672         case 0x14: str="MAC failure"; break;
10673         case 0x15: str="Synch failure"; break;
10674         case 0x16: str="Congestion"; break;
10675         case 0x17: str="GSM authentication unacceptable"; break;
10676         case 0x20: str="Service option not supported"; break;
10677         case 0x21: str="Requested service option not subscribed"; break;
10678         case 0x22: str="Service option temporarily out of order"; break;
10679         case 0x26: str="Call cannot be identified"; break;
10680         case 0x28: str="No PDP context activated"; break;
10681         case 0x30: str="retry upon entry into a new cell"; break;
10682         case 0x31: str="retry upon entry into a new cell"; break;
10683         case 0x32: str="retry upon entry into a new cell"; break;
10684         case 0x33: str="retry upon entry into a new cell"; break;
10685         case 0x34: str="retry upon entry into a new cell"; break;
10686         case 0x35: str="retry upon entry into a new cell"; break;
10687         case 0x36: str="retry upon entry into a new cell"; break;
10688         case 0x37: str="retry upon entry into a new cell"; break;
10689         case 0x38: str="retry upon entry into a new cell"; break;
10690         case 0x39: str="retry upon entry into a new cell"; break;
10691         case 0x3a: str="retry upon entry into a new cell"; break;
10692         case 0x3b: str="retry upon entry into a new cell"; break;
10693         case 0x3c: str="retry upon entry into a new cell"; break;
10694         case 0x3d: str="retry upon entry into a new cell"; break;
10695         case 0x3e: str="retry upon entry into a new cell"; break;
10696         case 0x3f: str="retry upon entry into a new cell"; break;
10697         case 0x5f: str="Semantically incorrect message"; break;
10698         case 0x60: str="Invalid mandatory information"; break;
10699         case 0x61: str="Message type non-existent or not implemented"; break;
10700         case 0x62: str="Message type not compatible with the protocol state"; break;
10701         case 0x63: str="Information element non-existent or not implemented"; break;
10702         case 0x64: str="Conditional IE error"; break;
10703         case 0x65: str="Message not compatible with the protocol state"; break;
10704         case 0x6f: str="Protocol error, unspecified"; break;
10705         default: str="Protocol error, unspecified";
10706     }
10707     
10708     proto_tree_add_text(tree,
10709         tvb, curr_offset, 1,
10710         "gmm Cause: (%u) %s",
10711         oct,
10712         str);
10713
10714     curr_offset++;
10715
10716     /* no length check possible */
10717
10718     return(curr_offset - offset);
10719 }
10720
10721 /*
10722  * [7] 10.5.5.15 Routing area identification
10723  */
10724 guint8
10725 de_gmm_rai(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10726 {
10727     guint32     mcc;
10728     guint32     mnc;
10729     guint32     lac;
10730     guint32     rac;
10731     guint32     curr_offset;
10732     
10733     len = len;
10734     curr_offset = offset;
10735
10736     mcc = (tvb_get_guint8(tvb, curr_offset) & 0x0f) <<8;
10737         mcc |= (tvb_get_guint8(tvb, curr_offset) & 0xf0);
10738         mcc |= (tvb_get_guint8(tvb, curr_offset+1) & 0x0f);
10739         mnc = (tvb_get_guint8(tvb, curr_offset+2) & 0x0f) <<8;
10740         mnc |= (tvb_get_guint8(tvb, curr_offset+2) & 0xf0);
10741         mnc |= (tvb_get_guint8(tvb, curr_offset+1) & 0xf0) >>4;
10742         if ((mnc&0x000f) == 0x000f) 
10743                  mnc = mnc>>4;
10744
10745     lac = tvb_get_guint8(tvb, curr_offset+3);
10746     lac <<= 8;
10747     lac |= tvb_get_guint8(tvb, curr_offset+4);
10748     rac = tvb_get_guint8(tvb, curr_offset+5);
10749
10750         proto_tree_add_text(tree,
10751                 tvb, curr_offset, 6,
10752                 "Routing area identification: %x-%x-%x-%x",
10753                 mcc,mnc,lac,rac);
10754
10755     curr_offset+=6;
10756
10757     /* no length check possible */
10758
10759     return(curr_offset - offset);
10760 }
10761
10762 /*
10763  * [7] 10.5.5.17
10764  */
10765 static guint8
10766 de_gmm_update_res(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10767 {
10768     guint8      oct;
10769     guint32     curr_offset;
10770     const gchar *str;
10771     
10772     len = len;
10773     curr_offset = offset;
10774
10775     oct = tvb_get_guint8(tvb, curr_offset);
10776
10777     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
10778     oct >>= 4;
10779
10780     switch(oct&7)
10781     {
10782         case 0: str="RA updated"; break;
10783         case 1: str="combined RA/LA updated";   break;
10784         default: str="reserved";
10785     }
10786
10787     proto_tree_add_text(tree,
10788         tvb, curr_offset, 1,
10789         "Update Result: (%u) %s",
10790         oct&7,
10791         str);
10792
10793     curr_offset++;
10794
10795     /* no length check possible */
10796
10797     return(curr_offset - offset);
10798 }
10799
10800 /*
10801  * [7] 10.5.5.18
10802  */
10803 static guint8
10804 de_gmm_update_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10805 {
10806     guint8      oct;
10807     guint8      oct_ciph;
10808     guint32     curr_offset;
10809     const gchar *str_follow;
10810     const gchar *str_update;
10811     proto_item  *tf = NULL;
10812     proto_tree      *tf_tree = NULL;
10813     
10814     len = len;
10815     curr_offset = offset;
10816
10817     oct = tvb_get_guint8(tvb, curr_offset);
10818     oct_ciph = oct>>4;
10819
10820     oct &= 0x0f;
10821
10822     switch(oct&7)
10823     {
10824         case 0: str_update="RA updating"; break;
10825         case 1: str_update="combined RA/LA updating"; break;
10826         case 2: str_update="combined RA/LA updating with IMSI attach"; break;
10827         case 3: str_update="Periodic updating"; break;
10828         default: str_update="reserved";
10829     }
10830     switch(oct&8)
10831     {
10832         case 8: str_follow="Follow-on request pending"; break;
10833         default: str_follow="No follow-on request pending";
10834     }
10835
10836     tf = proto_tree_add_text(tree,
10837         tvb, curr_offset, 1,
10838         "Update Type");
10839
10840     tf_tree = proto_item_add_subtree(tf, ett_gmm_update_type );
10841
10842     proto_tree_add_text(tf_tree,
10843         tvb, curr_offset, 1,
10844         "Type: (%u) %s",
10845         oct&7,
10846         str_update);
10847     proto_tree_add_text(tf_tree,
10848         tvb, curr_offset, 1,
10849         "Follow: (%u) %s",
10850         (oct>>3)&1,
10851         str_follow);
10852
10853     /* The ciphering key sequence number is added here */
10854     proto_tree_add_text(tree,
10855         tvb, curr_offset, 1,
10856         "Ciphering key sequence number: 0x%02x (%u)",
10857         oct_ciph,
10858         oct_ciph);
10859
10860     curr_offset++;
10861
10862     /* no length check possible */
10863
10864     return(curr_offset - offset);
10865 }
10866
10867 /*
10868  * [7] 10.5.5.19
10869  */
10870 static guint8
10871 de_gmm_ac_ref_nr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10872 {
10873     guint8      oct;
10874     guint32     curr_offset;
10875     
10876     len = len;
10877     curr_offset = offset;
10878
10879     oct = tvb_get_guint8(tvb, curr_offset);
10880
10881     proto_tree_add_text(tree,
10882         tvb, curr_offset, 1,
10883         "A&C reference number: 0x%02x (%u)",
10884         oct&0xf,
10885         oct&0xf);
10886
10887     curr_offset++;
10888
10889     /* no length check possible */
10890
10891     return(curr_offset - offset);
10892 }
10893
10894 /*
10895  * [7] 10.5.5.19
10896  */
10897 static guint8
10898 de_gmm_ac_ref_nr_h(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10899 {
10900     guint8      oct;
10901     guint32     curr_offset;
10902     
10903     len = len;
10904     curr_offset = offset;
10905
10906     oct = tvb_get_guint8(tvb, curr_offset);
10907
10908     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
10909     oct >>= 4;
10910
10911     proto_tree_add_text(tree,
10912         tvb, curr_offset, 1,
10913         "A&C reference number: 0x%02x (%u)",
10914         oct,
10915         oct);
10916
10917     curr_offset++;
10918
10919     /* no length check possible */
10920
10921     return(curr_offset - offset);
10922 }
10923
10924 /*
10925  * [8] 10.5.5.20
10926  */
10927 static guint8
10928 de_gmm_service_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10929 {
10930     guint8      oct;
10931     guint8      oct_ciph;
10932     guint32     curr_offset;
10933     const gchar *str;
10934     
10935     len = len;
10936     curr_offset = offset;
10937
10938     oct = tvb_get_guint8(tvb, curr_offset);
10939     oct_ciph = oct;
10940     oct_ciph &= 7;
10941
10942     oct = oct >> 4;
10943
10944     switch ( oct&7 )
10945     {
10946         case 0: str="Signalling"; break;
10947         case 1: str="Data"; break;
10948         case 2: str="Paging Response"; break;
10949         case 3: str="MBMS Notification Response"; break;/* reponse->response*/
10950         default: str="reserved";
10951     }
10952
10953     /* The ciphering key sequence number is added here */
10954     proto_tree_add_text(tree,
10955         tvb, curr_offset, 1,
10956         "Ciphering key sequence number: 0x%02x (%u)",
10957         oct_ciph,
10958         oct_ciph);
10959
10960     proto_tree_add_text(tree,
10961         tvb, curr_offset, 1,
10962         "Service Type: (%u) %s",
10963         oct&7,
10964         str);
10965
10966     curr_offset++;
10967
10968     /* no length check possible */
10969
10970     return(curr_offset - offset);
10971 }
10972
10973 /*
10974  * [7] 10.5.5.21
10975  */
10976 static guint8
10977 de_gmm_cell_notfi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10978 {
10979     guint32     curr_offset;
10980
10981     len = len;
10982     curr_offset = offset;
10983
10984     proto_tree_add_text(tree,
10985         tvb, curr_offset, 0,
10986         "Cell Notification");
10987
10988     /* no length check possible */
10989
10990     return(curr_offset - offset);
10991 }
10992
10993 /*
10994  * [7] 10.5.5.22
10995  */
10996 static guint8
10997 de_gmm_ps_lcs_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10998 {
10999     guint8      oct;
11000     guint32     curr_offset;
11001     
11002     gchar       str_otd[2][40]={ "MS assisted E-OTD not supported",
11003                         "MS assisted E-OTD supported" };
11004     gchar       str_gps[2][40]={ "MS assisted GPS not supported",
11005                         "MS assisted GPS supported" };
11006     
11007     len = len;
11008     curr_offset = offset;
11009
11010     oct = tvb_get_guint8(tvb, curr_offset);
11011
11012     oct <<=3;   /* move away the spare bits */
11013
11014     proto_tree_add_text(tree,
11015         tvb, curr_offset, 1,
11016         "OTD-A: (%u) %s",
11017         oct>>7,
11018         str_otd[oct>>7]);
11019     oct <<=1;
11020     proto_tree_add_text(tree,
11021         tvb, curr_offset, 1,
11022         "OTD-B: (%u) %s",
11023         oct>>7,
11024         str_otd[oct>>7]);
11025     oct <<=1;
11026
11027     proto_tree_add_text(tree,
11028         tvb, curr_offset, 1,
11029         "GPS-A: (%u) %s",
11030         oct>>7,
11031         str_gps[oct>>7]);
11032     oct <<=1;
11033     proto_tree_add_text(tree,
11034         tvb, curr_offset, 1,
11035         "GPS-B: (%u) %s",
11036         oct>>7,
11037         str_gps[oct>>7]);
11038     oct <<=1;
11039     proto_tree_add_text(tree,
11040         tvb, curr_offset, 1,
11041         "GPS-C: (%u) %s",
11042         oct>>7,
11043         str_gps[oct>>7]);
11044
11045     curr_offset++;
11046
11047     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11048
11049     return(curr_offset - offset);
11050 }
11051
11052 /*
11053  * [7] 10.5.5.23
11054  */
11055 static guint8
11056 de_gmm_net_feat_supp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11057 {
11058     guint8      oct;
11059     guint32     curr_offset;
11060     const gchar *str;
11061     
11062     len = len;
11063     curr_offset = offset;
11064
11065     oct = tvb_get_guint8(tvb, curr_offset);
11066
11067     switch(oct&8)
11068     {
11069         case 8: str="LCS-MOLR via PS domain not supported"; break;
11070         default: str="LCS-MOLR via PS domain supported";
11071     }
11072
11073     proto_tree_add_text(tree,
11074         tvb, curr_offset, 1,
11075         "Network Feature Support: (%u) %s",
11076         (oct>>3)&1,
11077         str);
11078
11079     curr_offset++;
11080
11081     /* no length check possible */
11082
11083     return(curr_offset - offset);
11084 }
11085
11086 /* [7] 10.5.24 Inter RAT information container */
11087 static guint8
11088 de_gmm_rat_info_container(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11089 {
11090         guint32 curr_offset;
11091
11092         len = len;
11093     curr_offset = offset;
11094
11095 /* The value part of the Inter RAT information container information element is the INTER RAT HANDOVER INFO as
11096 defined in 3GPP TS 25.331 [23c]. If this field includes padding bits, they are defined in 3GPP TS 25.331 [23c].*/
11097         proto_tree_add_text(tree, tvb, curr_offset, len,"INTER RAT HANDOVER INFO - Not decoded");
11098
11099         return len;
11100
11101 }
11102
11103 /*
11104  * [7] 10.5.7.1
11105  */
11106 static guint8
11107 de_gc_context_stat(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11108 {
11109     guint8      oct;
11110     guint16     pdp_nr;
11111     guint32     curr_offset;
11112     proto_item  *tf = NULL;
11113     proto_tree      *tf_tree = NULL;
11114
11115     gchar       str[2][20]={ "PDP-INACTIVE", "PDP-ACTIVE" };
11116     
11117     len = len;
11118     curr_offset = offset;
11119
11120     oct = tvb_get_guint8(tvb, curr_offset);
11121
11122     tf = proto_tree_add_text(tree,
11123         tvb, curr_offset, 1,
11124         "PDP Context Status");
11125
11126     tf_tree = proto_item_add_subtree(tf, ett_gmm_context_stat );
11127     
11128     oct = tvb_get_guint8(tvb, curr_offset);
11129
11130     for ( pdp_nr=0;pdp_nr<16; pdp_nr++ )
11131     {
11132             if ( pdp_nr == 8 )
11133             {
11134                 curr_offset++;
11135                 oct = tvb_get_guint8(tvb, curr_offset);
11136             }
11137             proto_tree_add_text(tf_tree,
11138                 tvb, curr_offset, 1,
11139                 "NSAPI %d: (%u) %s",pdp_nr,
11140                 oct&1,
11141                 str[oct&1]);
11142             oct>>=1;
11143     }
11144
11145     curr_offset++;
11146
11147     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11148
11149     return(curr_offset - offset);
11150 }
11151
11152 /*
11153  * [7] 10.5.7.2
11154  */
11155 static guint8
11156 de_gc_radio_prio(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11157 {
11158     guint8      oct;
11159     guint32     curr_offset;
11160     const gchar *str;
11161     
11162     len = len;
11163     curr_offset = offset;
11164
11165     oct = tvb_get_guint8(tvb, curr_offset);
11166
11167     switch ( oct&7 )
11168     {
11169         case 1: str="priority level 1 (highest)"; break;
11170         case 2: str="priority level 2"; break;
11171         case 3: str="priority level 3"; break;
11172         case 4: str="priority level 4 (lowest)"; break;
11173         default: str="priority level 4 (lowest)";
11174     }
11175
11176     proto_tree_add_text(tree,
11177         tvb, curr_offset, 1,
11178         "Radio Priority (PDP or SMS): (%u) %s",
11179         oct&7,
11180         str);
11181
11182     curr_offset++;
11183
11184     return(curr_offset - offset);
11185 }
11186
11187 /*
11188  * [7] 10.5.7.3
11189  */
11190 static guint8
11191 de_gc_timer(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11192 {
11193     guint8      oct;
11194     guint16     val;
11195     guint32     curr_offset;
11196     const gchar *str;
11197     
11198     len = len;
11199     curr_offset = offset;
11200
11201     oct = tvb_get_guint8(tvb, curr_offset);
11202
11203     val = oct&0x1f;
11204
11205     switch(oct>>5)
11206     {
11207         case 0: str="sec"; val*=2; break;
11208         case 1: str="min"; break;
11209         case 2: str="min"; val*=6; break;
11210         case 7:
11211             proto_tree_add_text(tree,
11212                 tvb, curr_offset, 1,
11213                 "GPRS Timer: timer is deactivated");
11214
11215         default: str="min";
11216     }
11217
11218     proto_tree_add_text(tree,
11219         tvb, curr_offset, 1,
11220         "GPRS Timer: (%u) %u %s",
11221         oct, val,
11222         str);
11223
11224     curr_offset++;
11225
11226     /* no length check possible */
11227
11228     return(curr_offset - offset);
11229 }
11230
11231 /*
11232  * [7] 10.5.7.4
11233  */
11234 static guint8
11235 de_gc_timer2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
11236 {
11237     guint8      oct;
11238     guint16     val;
11239     guint32     curr_offset;
11240     const gchar *str;
11241     
11242     len = len;
11243     curr_offset = offset;
11244
11245     oct = tvb_get_guint8(tvb, curr_offset);
11246
11247     val = oct&0x1f;
11248
11249     switch(oct>>5)
11250     {
11251         case 0: str="sec"; val*=2; break;
11252         case 1: str="min"; break;
11253         case 2: str="min"; val*=6; break;
11254         case 7:
11255             proto_tree_add_text(tree,
11256                 tvb, curr_offset, 1,
11257                 "GPRS Timer: timer is deactivated");
11258
11259         default: str="min";
11260     }
11261
11262     proto_tree_add_text(tree,
11263         tvb, curr_offset, 1,
11264         "GPRS Timer: (%u) %u %s %s",
11265         oct, val,
11266         str, add_string ? add_string : "");
11267
11268     curr_offset++;
11269
11270     return(curr_offset - offset);
11271 }
11272
11273
11274 /*
11275  * [7] 10.5.7.5
11276  */
11277 static guint8
11278 de_gc_radio_prio2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11279 {
11280     guint8      oct;
11281     guint32     curr_offset;
11282     const gchar *str;
11283     
11284     len = len;
11285     curr_offset = offset;
11286
11287     oct = tvb_get_guint8(tvb, curr_offset);
11288
11289     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
11290     oct >>= 4;
11291
11292     switch ( oct&7 )
11293     {
11294         case 1: str="priority level 1 (highest)"; break;
11295         case 2: str="priority level 2"; break;
11296         case 3: str="priority level 3"; break;
11297         case 4: str="priority level 4 (lowest)"; break;
11298         default: str="priority level 4 (lowest)";
11299     }
11300
11301     proto_tree_add_text(tree,
11302         tvb, curr_offset, 1,
11303         "Radio Priority (TOM8): (%u) %s",
11304         oct&7,
11305         str);
11306
11307     curr_offset++;
11308
11309     return(curr_offset - offset);
11310 }
11311
11312 /*
11313  * [8] 10.5.7.6 MBMS context status
11314  */
11315 static guint8
11316 de_gc_mbms_context_stat(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11317 {
11318     guint32     curr_offset;
11319     
11320     len = len;
11321     curr_offset = offset;
11322  
11323         proto_tree_add_text(tree,tvb, curr_offset, len, "MBMS context status - Not decoded");
11324
11325     return(len);
11326 }
11327 /*
11328  * [7] 10.5.6.1
11329  */
11330 #define MAX_APN_LENGTH          50
11331
11332 guint8
11333 de_sm_apn(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
11334 {
11335     guint32     curr_offset;
11336     guint       curr_len;
11337     const guint8        *cptr;
11338     guint8      str[MAX_APN_LENGTH+1];
11339
11340     cptr = tvb_get_ptr(tvb, offset, len);
11341
11342     
11343     curr_offset = offset;
11344
11345     /* init buffer and copy it */
11346     memset ( str , 0 , MAX_APN_LENGTH );
11347     memcpy ( str , cptr , len<MAX_APN_LENGTH?len:MAX_APN_LENGTH );
11348
11349     curr_len = 0;
11350     while (( curr_len < len ) && ( curr_len < MAX_APN_LENGTH ))
11351     {
11352         guint step = str[curr_len];
11353         str[curr_len]='.';
11354         curr_len += step+1;
11355     }
11356     
11357     proto_tree_add_text(tree,
11358         tvb, curr_offset, len,
11359         "APN: %s %s", str+1 , add_string ? add_string : "");
11360
11361     curr_offset+= len;
11362
11363     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11364
11365     return(curr_offset - offset);
11366 }
11367
11368 /*
11369  * [7] 10.5.6.2
11370  */
11371 static guint8
11372 de_sm_nsapi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
11373 {
11374     guint8      oct;
11375     guint32     curr_offset;
11376     
11377     len = len;
11378     curr_offset = offset;
11379
11380     oct = tvb_get_guint8(tvb, curr_offset);
11381
11382     proto_tree_add_text(tree,
11383         tvb, curr_offset, 1,
11384         "NSAPI: 0x%02x (%u) %s",
11385         oct&0x0f, oct&0x0f,add_string ? add_string : "");
11386
11387     curr_offset++;
11388
11389     return(curr_offset - offset);
11390 }
11391
11392 /*
11393  * [7] 10.5.6.3
11394  */
11395 static guint8
11396 de_sm_pco(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11397 {
11398     guint32     curr_offset;
11399     guint       curr_len;
11400     guchar      oct;
11401     struct e_in6_addr ipv6_addr;
11402     
11403     curr_len = len;
11404     curr_offset = offset;
11405
11406     oct = tvb_get_guint8(tvb, curr_offset);
11407     curr_len--;
11408     curr_offset++;
11409
11410     proto_tree_add_text(tree,tvb, curr_offset, 1, "Ext: 0x%02x (%u)",oct>>7,oct>>7);
11411     proto_tree_add_text(tree,tvb, curr_offset, 1, "Configuration Protocol: PPP (%u)",oct&0x0f);
11412
11413     while ( curr_len > 0 )
11414     {
11415         guchar e_len;
11416         guint16 prot;
11417         tvbuff_t *l3_tvb;
11418         dissector_handle_t handle = NULL;
11419         static packet_info p_info;
11420         
11421         prot = tvb_get_guint8(tvb, curr_offset);
11422         prot <<= 8;
11423         prot |= tvb_get_guint8(tvb, curr_offset+1);
11424         e_len = tvb_get_guint8(tvb, curr_offset+2);
11425         curr_len-=3;
11426         curr_offset+=3;
11427
11428         switch ( prot )
11429         {
11430                 case 0x0001:
11431                 {
11432                     proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) P-CSCF Address" , prot );
11433                     proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11434
11435                     tvb_get_ipv6(tvb, curr_offset, &ipv6_addr);
11436                     proto_tree_add_text(tree,
11437                         tvb, curr_offset, 16,
11438                         "IPv6: %s", ip6_to_str(&ipv6_addr));
11439                     break;
11440                 }
11441                 case 0x0002:
11442                     proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) IM CN Subsystem Signaling Flag" , prot );
11443                     proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11444                     break;
11445                 case 0x0003:
11446                 {
11447                     proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) DNS Server Address" , prot );
11448                     proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11449
11450                     tvb_get_ipv6(tvb, curr_offset, &ipv6_addr);
11451                     proto_tree_add_text(tree,
11452                         tvb, curr_offset, 16,
11453                         "IPv6: %s", ip6_to_str(&ipv6_addr));
11454                     break;
11455                 }
11456                 case 0x0004:
11457                     proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) Policy Control rejection code" , prot );
11458                     proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11459                     oct = tvb_get_guint8(tvb, curr_offset);
11460                     proto_tree_add_text(tree,tvb, curr_offset, 1, "Reject Code: 0x%02x (%u)", e_len , e_len);
11461                     break;
11462                 default:
11463                         handle = dissector_get_port_handle ( gprs_sm_pco_subdissector_table , prot );
11464                         if ( handle != NULL )
11465                         {
11466                                 proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Protocol: (%u) %s" , 
11467                                         prot , val_to_str(prot, ppp_vals, "Unknown"));
11468                                 proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11469                                 /*
11470                                  * dissect the embedded message
11471                                  */
11472                                 l3_tvb = tvb_new_subset(tvb, curr_offset, e_len, e_len);
11473                                 call_dissector(handle, l3_tvb ,  &p_info  , tree );
11474                         }
11475                         else
11476                         {
11477                                 proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Protocol/Parameter: (%u) unknwown" , prot );
11478                                 proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11479                                 /*
11480                                 * dissect the embedded DATA message
11481                                 */
11482                                 l3_tvb = tvb_new_subset(tvb, curr_offset, e_len, e_len);
11483                                 call_dissector(data_handle, l3_tvb, &p_info , tree);
11484                         }
11485         }
11486
11487         curr_len-= e_len;
11488         curr_offset+= e_len;
11489     }    
11490     curr_offset+= curr_len;        
11491                    
11492     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11493
11494     return(curr_offset - offset);
11495 }
11496
11497 /*
11498  * [7] 10.5.6.4
11499  */
11500 static guint8
11501 de_sm_pdp_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11502 {
11503     guint32     curr_offset;
11504     guint       curr_len;
11505     const gchar *str;
11506     guchar      oct;
11507     guchar      oct2;
11508     struct e_in6_addr ipv6_addr;
11509
11510     curr_len = len;
11511     curr_offset = offset;
11512
11513     oct = tvb_get_guint8(tvb, curr_offset);
11514
11515     switch ( oct&0x0f )
11516     {
11517         case 0x00: str="ETSI allocated address"; break;
11518         case 0x01: str="IETF allocated address"; break;
11519         case 0x0f: str="Empty PDP type";
11520         default: str="reserved";
11521     }
11522
11523     proto_tree_add_text(tree,
11524         tvb, curr_offset, 1,
11525         "PDP type organisation: (%u) %s",oct&0x0f,str);
11526
11527     oct2 = tvb_get_guint8(tvb, curr_offset+1);
11528
11529     if (( oct&0x0f ) == 0 )
11530     {
11531             switch ( oct2 )
11532             {
11533                 case 0x00: str="Reserved, used in earlier version of this protocol"; break;
11534                 case 0x01: str="PDP-type PPP"; break;
11535                 default: str="reserved";
11536             }
11537     }
11538     else if (( oct&0x0f) == 1 )
11539     {
11540             switch ( oct2 )
11541             {
11542                 case 0x21: str="IPv4 address"; break;
11543                 case 0x57: str="IPv6 address"; break;
11544                 default: str="IPv4 address";
11545             }
11546     }
11547     else if ((oct2==0) && (( oct&0x0f) == 0x0f ))    
11548             str="Empty"; 
11549     else
11550             str="Not specified";        
11551     
11552     proto_tree_add_text(tree,
11553         tvb, curr_offset+1, 1,
11554         "PDP type number: (%u) %s",oct2,str);
11555
11556     if (( len == 2 ) && (( oct2 == 0x21 ) || ( oct2 == 0x57 )))
11557     {
11558             proto_tree_add_text(tree,
11559                 tvb, curr_offset+1, 1,
11560                 "Dynamic addressing");
11561         
11562             curr_offset+= curr_len;        
11563
11564             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11565
11566            return(curr_offset - offset);
11567     }
11568     else if ( len == 2 )
11569     {
11570             proto_tree_add_text(tree,
11571                 tvb, curr_offset+1, 1,
11572                 "No PDP address is included");
11573         
11574             curr_offset+= curr_len;        
11575
11576             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11577
11578            return(curr_offset - offset);
11579     }
11580     else if ( len < 2 )
11581     {
11582             proto_tree_add_text(tree,
11583                 tvb, curr_offset+1, 1,
11584                 "Length is bogus - should be >= 2");
11585         
11586             curr_offset+= curr_len;        
11587
11588             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11589
11590            return(curr_offset - offset);
11591     }
11592
11593     if ((( oct2 == 0x21 ) && ( len != 6 )) ||
11594        (( oct2 == 0x57 ) && ( len != 18 )))
11595     {
11596             proto_tree_add_text(tree,
11597                 tvb, curr_offset+2, len-2,
11598                 "Can't display address");
11599     }
11600
11601
11602     switch ( oct2 )
11603     {
11604         case 0x21:
11605             if (len-2 != 4) {
11606                 proto_tree_add_text(tree,
11607                     tvb, curr_offset+2, 0,
11608                     "IPv4: length is wrong");
11609             } else {
11610                 proto_tree_add_text(tree,
11611                     tvb, curr_offset+2, len-2,
11612                     "IPv4: %s", ip_to_str(tvb_get_ptr(tvb, offset+2, 4)));
11613             }
11614             break;
11615
11616         case 0x57:
11617             if (len-2 != 16) {
11618                 proto_tree_add_text(tree,
11619                     tvb, curr_offset+2, 0,
11620                     "IPv6: length is wrong");
11621             } else {
11622                 tvb_get_ipv6(tvb, curr_offset+2, &ipv6_addr);
11623                 proto_tree_add_text(tree,
11624                     tvb, curr_offset+2, len-2,
11625                     "IPv6: %s", ip6_to_str(&ipv6_addr));
11626             }
11627             break;
11628     }
11629     
11630     curr_offset+= curr_len;        
11631                    
11632     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11633
11634     return(curr_offset - offset);
11635 }
11636
11637 /*
11638  * [7] 10.5.6.5
11639  */
11640  /* Delivery of erroneous SDUs, octet 6 (see 3GPP TS 23.107) Bits 3 2 1 */
11641 const value_string gsm_a_qos_del_of_err_sdu_vals[] = {
11642         { 0, "Subscribed delivery of erroneous SDUs/Reserved" },
11643         { 1, "No detect('-')" },
11644         { 2, "Erroneous SDUs are delivered('yes')" },
11645         { 3, "Erroneous SDUs are not delivered('No')" },
11646         { 7, "Reserved" },
11647         { 0, NULL }
11648 };
11649
11650  /* Delivery order, octet 6 (see 3GPP TS 23.107) Bits 5 4 3 */
11651 const value_string gsm_a_qos_del_order_vals[] = {
11652         { 0, "Subscribed delivery order/Reserved" },
11653         { 1, "With delivery order ('yes')" },
11654         { 2, "Without delivery order ('no')" },
11655         { 3, "Reserved" },
11656         { 0, NULL }
11657 };
11658 /* Traffic class, octet 6 (see 3GPP TS 23.107) Bits 8 7 6 */
11659 const value_string gsm_a_qos_traffic_cls_vals[] = {
11660         { 0, "Subscribed traffic class/Reserved" },
11661         { 1, "Conversational class" },
11662         { 2, "Streaming class" },
11663         { 3, "Interactive class" },
11664         { 4, "Background class" },
11665         { 7, "Reserved" },
11666         { 0, NULL }
11667 };
11668
11669 /* Residual Bit Error Rate (BER), octet 10 (see 3GPP TS 23.107) Bits 8 7 6 5 */
11670 const value_string gsm_a_qos_ber_vals[] = {
11671         { 0, "Subscribed residual BER/Reserved" },
11672         { 1, "5*10-2" },
11673         { 2, "1*10-2" },
11674         { 3, "5*10-3" },
11675         { 4, "4*10-3" },
11676         { 5, "1*10-3" },
11677         { 6, "1*10-4" },
11678         { 7, "1*10-5" },
11679         { 8, "1*10-6" },
11680         { 9, "6*10-8" },
11681         { 10, "Reserved" },
11682         { 0, NULL }
11683 };
11684
11685 /* SDU error ratio, octet 10 (see 3GPP TS 23.107) Bits 4 3 2 1 */
11686 const value_string gsm_a_qos_sdu_err_rat_vals[] = {
11687         { 0, "Subscribed SDU error ratio/Reserved" },
11688         { 1, "1*10-2" },
11689         { 2, "7*10-3" },
11690         { 3, "1*10-3" },
11691         { 4, "1*10-4" },
11692         { 5, "1*10-5" },
11693         { 6, "1*10-6" },
11694         { 7, "1*10-1" },
11695         { 15, "Reserved" },
11696         { 0, NULL }
11697 };
11698
11699 /* Traffic handling priority, octet 11 (see 3GPP TS 23.107) Bits 2 1 */
11700 const value_string gsm_a_qos_traff_hdl_pri_vals[] = {
11701         { 0, "Subscribed traffic handling priority/Reserved" },
11702         { 1, "Priority level 1" },
11703         { 2, "Priority level 2" },
11704         { 3, "Priority level 3" },
11705         { 0, NULL }
11706 };
11707
11708  guint8
11709 de_sm_qos(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11710 {
11711     guint32     curr_offset;
11712     guint       curr_len;
11713     guchar       oct, tmp_oct;
11714     const gchar *str;
11715     
11716     curr_len = len;
11717     curr_offset = offset;
11718
11719     oct = tvb_get_guint8(tvb, curr_offset);
11720
11721     switch ( (oct>>3)&7 )
11722     {
11723         case 0x00: str="Subscribed delay class/reserved"; break;
11724         case 0x01: str="Delay class 1"; break;
11725         case 0x02: str="Delay class 2"; break;
11726         case 0x03: str="Delay class 3"; break;
11727         case 0x04: str="Delay class 4 (best effort)"; break;
11728         case 0x07: str="Reserved"; break;
11729         default: str="Delay class 4 (best effort)";
11730     }
11731
11732     proto_tree_add_text(tree,
11733         tvb, curr_offset, 1,
11734         "Delay class: (%u) %s",(oct>>3)&7,str);
11735
11736     switch ( oct&0x7 )
11737     {
11738         case 0x00: str="Subscribed reliability class/reserved"; break;
11739         case 0x01: str="Acknowledged GTP, LLC, and RLC; Protected data"; break;
11740         case 0x02: str="Unacknowledged GTP; Acknowledged LLC and RLC, Protected data"; break;
11741         case 0x03: str="Unacknowledged GTP and LLC; Acknowledged RLC, Protected data"; break;
11742         case 0x04: str="Unacknowledged GTP, LLC, and RLC, Protected data"; break;
11743         case 0x05: str="Unacknowledged GTP, LLC, and RLC, Unprotected data"; break;
11744         case 0x07: str="Reserved"; break;
11745         default: str="Unacknowledged GTP and LLC; Acknowledged RLC, Protected data";
11746     }
11747
11748     proto_tree_add_text(tree,
11749         tvb, curr_offset, 1,
11750         "Reliability class: (%u) %s",oct&7,str);
11751
11752     curr_offset+= 1;       
11753     curr_len-= 1;
11754     
11755     if ( curr_len == 0 )
11756     {
11757             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11758
11759             return(curr_offset - offset);
11760     }
11761
11762     oct = tvb_get_guint8(tvb, curr_offset);
11763
11764     switch ( oct>>4 )
11765     {
11766         case 0x00: str="Subscribed peak throughput/reserved"; break;
11767         case 0x01: str="Up to 1 000 octet/s"; break;
11768         case 0x02: str="Up to 2 000 octet/s"; break;
11769         case 0x03: str="Up to 4 000 octet/s"; break;
11770         case 0x04: str="Up to 8 000 octet/s"; break;
11771         case 0x05: str="Up to 16 000 octet/s"; break;
11772         case 0x06: str="Up to 32 000 octet/s"; break;
11773         case 0x07: str="Up to 64 000 octet/s"; break;
11774         case 0x08: str="Up to 128 000 octet/s"; break;
11775         case 0x09: str="Up to 256 000 octet/s"; break;
11776         case 0x0f: str="Reserved"; break;
11777         default: str="Up to 1 000 octet/s";
11778     }
11779
11780     proto_tree_add_text(tree,
11781         tvb, curr_offset, 1,
11782         "Peak throughput: (%u) %s",oct>>4,str);
11783
11784     switch ( oct&0x7 )
11785     {
11786         case 0x00: str="Subscribed precedence/reserved"; break;
11787         case 0x01: str="High priority"; break;
11788         case 0x02: str="Normal priority"; break;
11789         case 0x03: str="Low priority"; break;
11790         case 0x07: str="Reserved"; break;
11791         default: str="Normal priority";
11792     }
11793
11794     proto_tree_add_text(tree,
11795         tvb, curr_offset, 1,
11796         "Precedence class: (%u) %s",oct&7,str);
11797
11798     curr_offset+= 1;       
11799     curr_len-= 1;
11800     
11801     if ( curr_len == 0 )
11802     {
11803             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11804
11805             return(curr_offset - offset);
11806     }
11807
11808     oct = tvb_get_guint8(tvb, curr_offset);
11809
11810     switch ( oct&0x1f )
11811     {
11812         case 0x00: str="Subscribed peak throughput/reserved"; break;
11813         case 0x01: str="100 octet/h"; break;
11814         case 0x02: str="200 octet/h"; break;
11815         case 0x03: str="500 octet/h"; break;
11816         case 0x04: str="1 000 octet/h"; break;
11817         case 0x05: str="2 000 octet/h"; break;
11818         case 0x06: str="5 000 octet/h"; break;
11819         case 0x07: str="10 000 octet/h"; break;
11820         case 0x08: str="20 000 octet/h"; break;
11821         case 0x09: str="50 000 octet/h"; break;
11822         case 0x0a: str="100 000 octet/h"; break;
11823         case 0x0b: str="200 000 octet/h"; break;
11824         case 0x0c: str="500 000 octet/h"; break;
11825         case 0x0d: str="1 000 000 octet/h"; break;
11826         case 0x0e: str="2 000 000 octet/h"; break;
11827         case 0x0f: str="5 000 000 octet/h"; break;
11828         case 0x10: str="10 000 000 octet/h"; break;
11829         case 0x11: str="20 000 000 octet/h"; break;
11830         case 0x12: str="50 000 000 octet/h"; break;
11831         case 0x1e: str="Reserved"; break;
11832         case 0x1f: str="Best effort"; break;
11833         default: str="Best effort";
11834     }
11835
11836     proto_tree_add_text(tree,
11837         tvb, curr_offset, 1,
11838         "Mean throughput: (%u) %s",oct&0x1f,str);
11839
11840     curr_offset+= 1;       
11841     curr_len-= 1;
11842     
11843     if ( curr_len == 0 )
11844     {
11845             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11846
11847             return(curr_offset - offset);
11848     }
11849
11850     proto_tree_add_item(tree, hf_gsm_a_qos_traffic_cls, tvb, curr_offset, 1, FALSE);
11851         proto_tree_add_item(tree, hf_gsm_a_qos_del_order, tvb, curr_offset, 1, FALSE);
11852     proto_tree_add_item(tree, hf_gsm_a_qos_del_of_err_sdu, tvb, curr_offset, 1, FALSE);
11853
11854     curr_offset+= 1;       
11855     curr_len-= 1;
11856     
11857     if ( curr_len == 0 )
11858     {
11859             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11860
11861             return(curr_offset - offset);
11862     }
11863
11864     oct = tvb_get_guint8(tvb, curr_offset);
11865
11866     switch ( oct )
11867     {
11868         case 0x00: str="Subscribed maximum SDU size/reserved"; break;
11869         case 0x97: str="1502 octets"; break;
11870         case 0x98: str="1510 octets"; break;
11871         case 0x99: str="1520 octets"; break;
11872         case 0xff: str="Reserved"; break;
11873         default: str="Unspecified";
11874     }
11875
11876     if (( oct >= 1 ) && ( oct <= 0x96 ))
11877             proto_tree_add_text(tree,
11878                 tvb, curr_offset, 1,
11879                 "Maximum SDU size: (%u) %u octets",oct,oct*10);
11880     else
11881             proto_tree_add_text(tree,
11882                 tvb, curr_offset, 1,
11883                 "Maximum SDU size: (%u) %s",oct,str);
11884
11885     curr_offset+= 1;       
11886     curr_len-= 1;
11887     
11888     if ( curr_len == 0 )
11889     {
11890             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11891
11892             return(curr_offset - offset);
11893     }
11894
11895     oct = tvb_get_guint8(tvb, curr_offset);
11896
11897     switch ( oct )
11898     {
11899         case 0x00: str="Subscribed maximum bit rate for uplink/reserved"; break;
11900         case 0xff: str="0kbps"; break;
11901         default: str="This should not happen - BUG";
11902     }
11903
11904     if (( oct >= 1 ) && ( oct <= 0x3f ))
11905             proto_tree_add_text(tree,
11906                 tvb, curr_offset, 1,
11907                 "Maximum bit rate for uplink: (%u) %ukbps",oct,oct);
11908     else if (( oct >= 0x40 ) && ( oct <= 0x7f ))
11909             proto_tree_add_text(tree,
11910                 tvb, curr_offset, 1,
11911                 "Maximum bit rate for uplink: (%u) %ukbps",oct,(oct-0x40)*8+64); /* - was (oct-0x40)*8  */
11912     else if (( oct >= 0x80 ) && ( oct <= 0xfe ))
11913             proto_tree_add_text(tree,
11914                 tvb, curr_offset, 1,
11915                 "Maximum bit rate for uplink: (%u) %ukbps",oct,(oct-0x80)*64+576); /* - was (oct-0x80)*64 */
11916     else
11917             proto_tree_add_text(tree,
11918                 tvb, curr_offset, 1,
11919                 "Maximum bit rate for uplink: (%u) %s",oct,str);
11920
11921     curr_offset+= 1;       
11922     curr_len-= 1;
11923     
11924     if ( curr_len == 0 )
11925     {
11926             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11927
11928             return(curr_offset - offset);
11929     }
11930
11931     oct = tvb_get_guint8(tvb, curr_offset);
11932
11933     switch ( oct )
11934     {
11935         case 0x00: str="Subscribed maximum bit rate for uplink/reserved"; break;
11936         case 0xff: str="0kbps"; break;
11937         default: str="This should not happen - BUG";
11938     }
11939
11940     if (( oct >= 1 ) && ( oct <= 0x3f ))
11941             proto_tree_add_text(tree,
11942                 tvb, curr_offset, 1,
11943                 "Maximum bit rate for downlink: (%u) %ukbps",oct,oct);
11944     else if (( oct >= 0x40 ) && ( oct <= 0x7f ))
11945             proto_tree_add_text(tree,
11946                 tvb, curr_offset, 1,
11947                 "Maximum bit rate for downlink: (%u) %ukbps",oct,(oct-0x40)*8+64);/*same as above*/
11948     else if (( oct >= 0x80 ) && ( oct <= 0xfe ))
11949             proto_tree_add_text(tree,
11950                 tvb, curr_offset, 1,
11951                 "Maximum bit rate for downlink: (%u) %ukbps",oct,(oct-0x80)*64+576);/*same as above*/
11952     else
11953             proto_tree_add_text(tree,
11954                 tvb, curr_offset, 1,
11955                 "Maximum bit rate for downlink: (%u) %s",oct,str);
11956
11957     curr_offset+= 1;       
11958     curr_len-= 1;
11959     
11960     if ( curr_len == 0 )
11961     {
11962             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11963
11964             return(curr_offset - offset);
11965     }
11966
11967     proto_tree_add_item(tree, hf_gsm_a_qos_ber, tvb, curr_offset, 1, FALSE);
11968         proto_tree_add_item(tree, hf_gsm_a_qos_sdu_err_rat, tvb, curr_offset, 1, FALSE);
11969
11970     curr_offset+= 1;       
11971     curr_len-= 1;
11972     
11973     if ( curr_len == 0 )
11974     {
11975             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11976
11977             return(curr_offset - offset);
11978     }
11979
11980     oct = tvb_get_guint8(tvb, curr_offset);
11981
11982     switch ( oct>>2 )
11983     {
11984         case 0x00: str="Subscribed transfer delay/reserved"; break;
11985         case 0x3f: str="Reserved"; break;
11986         default: str="This should not happen - BUG";
11987     }
11988
11989     tmp_oct = oct>>2;
11990
11991     if (( tmp_oct >= 1 ) && ( tmp_oct <= 0x0f ))
11992             proto_tree_add_text(tree,
11993                 tvb, curr_offset, 1,
11994                 "Transfer Delay: (%u) %ums",oct>>2,(oct>>2)*10);
11995     else if (( tmp_oct >= 0x10 ) && ( tmp_oct <= 0x1f ))
11996             proto_tree_add_text(tree,
11997                 tvb, curr_offset, 1,
11998                 "Transfer Delay: (%u) %ums",oct>>2,((oct>>2)-0x10)*50+200);
11999     else if (( tmp_oct >= 0x20 ) && ( tmp_oct <= 0x3e ))
12000             proto_tree_add_text(tree,
12001                 tvb, curr_offset, 1,
12002                 "Transfer Delay: (%u) %ums",oct>>2,((oct>>2)-0x20)*100+1000);
12003     else
12004             proto_tree_add_text(tree,
12005                 tvb, curr_offset, 1,
12006                 "Transfer Delay: (%u) %s",oct>>2,str);
12007
12008     switch ( oct&0x03 )
12009     {
12010         case 0x00: str="Subscribed traffic handling priority/reserved"; break;
12011         case 0x01: str="Priority level 1"; break;
12012         case 0x02: str="Priority level 2"; break;
12013         case 0x03: str="Priority level 3"; break;
12014         default: str="This should not happen - BUG";
12015     }
12016
12017     proto_tree_add_text(tree,
12018         tvb, curr_offset, 1,
12019         "Traffic Handling priority: (%u) %s",oct&0x03,str);
12020
12021     curr_offset+= 1;       
12022     curr_len-= 1;
12023     
12024     if ( curr_len == 0 )
12025     {
12026             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
12027
12028             return(curr_offset - offset);
12029     }
12030
12031     oct = tvb_get_guint8(tvb, curr_offset);
12032
12033     switch ( oct )
12034     {
12035         case 0x00: str="Subscribed guaranteed bit rate for uplink/reserved"; break;
12036         case 0xff: str="0kbps"; break;
12037         default: str="This should not happen - BUG";
12038     }
12039
12040     if (( oct >= 1 ) && ( oct <= 0x3f ))
12041             proto_tree_add_text(tree,
12042                 tvb, curr_offset, 1,
12043                 "Guaranteed bit rate for uplink: (%u) %ukbps",oct,oct);
12044     else if (( oct >= 0x40 ) && ( oct <= 0x7f ))
12045             proto_tree_add_text(tree,
12046                 tvb, curr_offset, 1,
12047                 "Guaranteed bit rate for uplink: (%u) %ukbps",oct,(oct-0x40)*8+64);/*same as for max bit rate*/
12048     else if (( oct >= 0x80 ) && ( oct <= 0xfe ))
12049             proto_tree_add_text(tree,
12050                 tvb, curr_offset, 1,
12051                 "Guaranteed bit rate for uplink: (%u) %ukbps",oct,(oct-0x80)*64+576);/*same as for max bit rate*/
12052     else
12053             proto_tree_add_text(tree,
12054                 tvb, curr_offset, 1,
12055                 "Guaranteed bit rate for uplink: (%u) %s",oct,str);
12056
12057     curr_offset+= 1;       
12058     curr_len-= 1;
12059     
12060     if ( curr_len == 0 )
12061     {
12062             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
12063
12064             return(curr_offset - offset);
12065     }
12066
12067     oct = tvb_get_guint8(tvb, curr_offset);
12068
12069     switch ( oct )
12070     {
12071         case 0x00: str="Subscribed guaranteed bit rate for uplink/reserved"; break;
12072         case 0xff: str="0kbps"; break;
12073         default: str="This should not happen - BUG";
12074     }
12075
12076     if (( oct >= 1 ) && ( oct <= 0x3f ))
12077             proto_tree_add_text(tree,
12078                 tvb, curr_offset, 1,
12079                 "Guaranteed bit rate for downlink: (%u) %ukbps",oct,oct);
12080     else if (( oct >= 0x40 ) && ( oct <= 0x7f ))
12081             proto_tree_add_text(tree,
12082                 tvb, curr_offset, 1,
12083                 "Guaranteed bit rate for downlink: (%u) %ukbps",oct,(oct-0x40)*8+64);/*same as above*/
12084     else if (( oct >= 0x80 ) && ( oct <= 0xfe ))
12085             proto_tree_add_text(tree,
12086                 tvb, curr_offset, 1,
12087                 "Guaranteed bit rate for downlink: (%u) %ukbps",oct,(oct-0x80)*64+576);/*same as above*/
12088     else
12089             proto_tree_add_text(tree,
12090                 tvb, curr_offset, 1,
12091                 "Guaranteed bit rate for downlink: (%u) %s",oct,str);
12092
12093     curr_offset+= 1;       
12094     curr_len-= 1;
12095     
12096     if ( curr_len == 0 )
12097     {
12098             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
12099
12100             return(curr_offset - offset);
12101     }
12102
12103     oct = tvb_get_guint8(tvb, curr_offset);
12104
12105     switch ( (oct>>4)&1 )
12106     {
12107         case 0x00: str="Not optimised for signalling traffic"; break;
12108         case 0x01: str="Optimised for signalling traffic"; break;
12109         default: str="This should not happen - BUG";
12110     }
12111
12112     proto_tree_add_text(tree,
12113         tvb, curr_offset, 1,
12114         "Signalling Indication: (%u) %s",(oct>>4)&1,str);
12115
12116     switch ( oct&7 )
12117     {
12118         case 0x00: str="unknown"; break;
12119         case 0x01: str="speech"; break;
12120         default: str="unknown";
12121     }
12122
12123     proto_tree_add_text(tree,
12124         tvb, curr_offset, 1,
12125         "Source Statistics Descriptor: (%u) %s",oct&7,str);
12126
12127     curr_offset+= 1;       
12128     curr_len-= 1;
12129     
12130     if ( curr_len == 0 )
12131     {
12132             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
12133
12134             return(curr_offset - offset);
12135     }
12136
12137
12138     oct = tvb_get_guint8(tvb, curr_offset);
12139
12140     switch ( oct )
12141     {
12142         case 0x00: str="Use the value indicated by the Maximum bit rate for downlink"; break;
12143         default: str="Unspecified";
12144     }
12145
12146     if (( oct >= 1 ) && ( oct <= 0x3f ))
12147             proto_tree_add_text(tree,
12148                 tvb, curr_offset, 1,
12149                 "Maximum bit rate for downlink (extended): (%u) %ukbps",oct,oct*100);
12150     else
12151             proto_tree_add_text(tree,
12152                 tvb, curr_offset, 1,
12153                 "Maximum bit rate for downlink (extended): (%u) %s",oct,str);
12154
12155     curr_offset+= 1;       
12156     curr_len-= 1;
12157     
12158     if ( curr_len == 0 )
12159     {
12160             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
12161
12162             return(curr_offset - offset);
12163     }
12164
12165     oct = tvb_get_guint8(tvb, curr_offset);
12166
12167     switch ( oct )
12168     {
12169         case 0x00: str="Use the value indicated by the Guaranteed bit rate for downlink"; break;
12170         default: str="Unspecified";
12171     }
12172
12173     if (( oct >= 1 ) && ( oct <= 0x4a ))
12174             proto_tree_add_text(tree,
12175                 tvb, curr_offset, 1,
12176                 "Guaranteed bit rate for downlink (extended): (%u) %ukbps",oct,oct*100);
12177     else
12178             proto_tree_add_text(tree,
12179                 tvb, curr_offset, 1,
12180                 "Guaranteed bit rate for downlink (extended): (%u) %s",oct,str);
12181
12182     curr_offset+= 1;       
12183     curr_len-= 1;
12184     
12185     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
12186
12187     return(curr_offset - offset);
12188 }
12189
12190 /*
12191  * [8] 10.5.6.6 SM cause
12192  */
12193 static guint8
12194 de_sm_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
12195 {
12196     guint8      oct;
12197     guint32     curr_offset;
12198     const gchar *str;
12199     
12200     len = len;
12201     curr_offset = offset;
12202
12203     oct = tvb_get_guint8(tvb, curr_offset);
12204
12205     switch ( oct )
12206     {
12207         case 0x08: str="Operator Determined Barring"; break;
12208         case 0x18: str="MBMS bearer capabilities insufficient for the service"; break;
12209         case 0x19: str="LLC or SNDCP failure(GSM only)"; break;
12210         case 0x1a: str="Insufficient resources"; break;
12211         case 0x1b: str="Missing or unknown APN"; break;
12212         case 0x1c: str="Unknown PDP address or PDP type"; break;
12213         case 0x1d: str="User Aauthentication failed"; break;
12214         case 0x1e: str="Activation rejected by GGSN"; break;
12215         case 0x1f: str="Activation rejected, unspecified"; break;
12216         case 0x20: str="Service option not supported"; break;
12217         case 0x21: str="Requested service option not subscribed"; break;
12218         case 0x22: str="Service option temporarily out of order"; break;
12219         case 0x23: str="NSAPI already used (not sent)"; break;
12220         case 0x24: str="Regular deactivation"; break;
12221         case 0x25: str="QoS not accepted"; break;
12222         case 0x26: str="Network failure"; break;
12223         case 0x27: str="Reactivation required"; break;
12224         case 0x28: str="Feature not supported"; break;
12225         case 0x29: str="Semantic error in the TFT operation"; break;
12226         case 0x2a: str="Syntactical error in the TFT operation"; break;
12227         case 0x2b: str="Unknown PDP context"; break;
12228         case 0x2e: str="PDP context without TFT already activated"; break;
12229         case 0x2f: str="Multicast group membership time-out"; break;
12230         case 0x2c: str="Semantic errors in packet filter(s)"; break;
12231         case 0x2d: str="Syntactical errors in packet filter(s)"; break;
12232         case 0x51: str="Invalid transaction identifier value"; break;
12233         case 0x5f: str="Semantically incorrect message"; break;
12234         case 0x60: str="Invalid mandatory information"; break;
12235         case 0x61: str="Message type non-existent or not implemented"; break;
12236         case 0x62: str="Message type not compatible with the protocol state"; break;
12237         case 0x63: str="Information element non-existent or not implemented"; break;
12238         case 0x64: str="Conditional IE error"; break;
12239         case 0x65: str="Message not compatible with the protocol state"; break;
12240         case 0x6f: str="Protocol error, unspecified"; break;
12241         case 0x70: str="APN restriction value incompatible with active PDP context"; break;
12242         default: str="Protocol error, unspecified"; break;
12243     }
12244
12245     proto_tree_add_text(tree,
12246         tvb, curr_offset, 1,
12247         "Cause: (%u) %s %s",
12248         oct, str,add_string ? add_string : "");
12249
12250     curr_offset++;
12251
12252     return(curr_offset - offset);
12253 }
12254
12255 /*
12256  * [7] 10.5.6.7
12257  */
12258 static guint8
12259 de_sm_linked_ti(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
12260 {
12261     guint32     curr_offset;
12262     guint       curr_len;
12263     gchar       oct;
12264
12265     gchar       ti_flag[2][80]={ "The message is sent from the side that originates the TI" ,
12266                         "The message is sent to the side that originates the TI" };
12267     
12268     curr_len = len;
12269     curr_offset = offset;
12270
12271     oct = tvb_get_guint8(tvb, curr_offset);
12272
12273     proto_tree_add_text(tree,
12274         tvb, curr_offset, 1,
12275         "TI flag: (%u) %s",oct>>7,ti_flag[oct>>7]);
12276
12277     if ( curr_len > 1 )
12278     {
12279         oct = tvb_get_guint8(tvb, curr_offset);
12280         
12281         proto_tree_add_text(tree,
12282         tvb, curr_offset, 1,
12283         "TI value: 0x%02x (%u)",oct&0x7f,oct&0x7f);
12284
12285         proto_tree_add_text(tree,
12286         tvb, curr_offset, 1,
12287         "ext: 0x%02x (%u)",oct>>7,oct>>7);
12288
12289     }
12290     else
12291     {
12292         proto_tree_add_text(tree,
12293         tvb, curr_offset, 1,
12294         "TI value: 0x%02x (%u)",(oct>>4)&7,(oct>>4)&7);
12295     }
12296
12297     curr_offset+= curr_len;        
12298                    
12299     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
12300
12301     return(curr_offset - offset);
12302 }
12303
12304 /*
12305  * [7] 10.5.6.9
12306  */
12307 static guint8
12308 de_sm_sapi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
12309 {
12310     guint8      oct;
12311     guint32     curr_offset;
12312     
12313     len = len;
12314     curr_offset = offset;
12315
12316     oct = tvb_get_guint8(tvb, curr_offset);
12317
12318     proto_tree_add_text(tree,
12319         tvb, curr_offset, 1,
12320         "LLC SAPI: 0x%02x (%u) %s",
12321         oct&0x0f, oct&0x0f,add_string ? add_string : "");
12322
12323     curr_offset++;
12324
12325     return(curr_offset - offset);
12326 }
12327
12328 /*
12329  * [7] 10.5.6.10
12330  */
12331 static guint8
12332 de_sm_tear_down(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
12333 {
12334     guint8      oct;
12335     guint32     curr_offset;
12336     gchar       str[2][30] = { "tear down not requested" , "tear down requested" };
12337     
12338     len = len;
12339     curr_offset = offset;
12340
12341     oct = tvb_get_guint8(tvb, curr_offset);
12342
12343     proto_tree_add_text(tree,
12344         tvb, curr_offset, 1,
12345         "Tear Down Indicator: (%u) %s %s",
12346         oct&1, str[oct&1],add_string ? add_string : "");
12347
12348     curr_offset++;
12349
12350     return(curr_offset - offset);
12351 }
12352
12353 /*
12354  * [7] 10.5.6.11
12355  */
12356 /* Packet Flow Identifier value (octet 3) */
12357 static const value_string gsm_a_packet_flow_id_vals[] = {
12358         { 0,            "Best Effort"},
12359         { 1,            "Signaling"},
12360         { 2,            "SMS"},
12361         { 3,            "TOM8"},
12362         { 4,            "reserved"},
12363         { 5,            "reserved"},
12364         { 6,            "reserved"},
12365         { 7,            "reserved"},
12366         { 0,    NULL }
12367 };
12368 guint8
12369 de_sm_pflow_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
12370 {
12371     guint32     curr_offset;
12372     guint       curr_len;
12373     guchar      oct;
12374     
12375     curr_len = len;
12376     curr_offset = offset;
12377
12378     oct = tvb_get_guint8(tvb, curr_offset);
12379
12380     proto_tree_add_text(tree,
12381         tvb, curr_offset, 1,
12382         "Packet Flow Identifier: (%u) %s",oct&0x7f,
12383                 val_to_str(oct&0x7f, gsm_a_packet_flow_id_vals, "dynamically assigned (%u)"));
12384
12385     curr_offset+= curr_len;        
12386                    
12387     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
12388
12389     return(curr_offset - offset);
12390 }
12391
12392 /*
12393  * [7] 10.5.6.12     TFT - Traffic Flow Template
12394  */
12395 /* TFT operation code (octet 3) */
12396 static const value_string gsm_a_tft_op_code_vals[] = {
12397         { 0,            "Spare"},
12398         { 1,            "Create new TFT"},
12399         { 2,            "Delete existing TFT"},
12400         { 3,            "Add packet filters to existing TFT"},
12401         { 4,            "Replace packet filters in existing TFT"},
12402         { 5,            "Delete packet filters from existing TFT"},
12403         { 6,            "No TFT operation"},
12404         { 7,            "Reserved"},
12405         { 0,    NULL }
12406 };
12407
12408 static const true_false_string gsm_a_tft_e_bit  = {
12409   "parameters list is included",
12410   "parameters list is not included"
12411 };
12412
12413
12414 static guint8
12415 de_sm_tflow_temp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
12416 {
12417     guint32     curr_offset;
12418     guint       curr_len;
12419     proto_item  *tf = NULL;
12420     proto_tree      *tf_tree = NULL;
12421     proto_tree  *comp_tree = NULL;
12422     guchar      op_code;
12423     guchar      pkt_fil_count;
12424     guchar      e_bit;
12425     const gchar *str;
12426     guchar      count;
12427     guchar      oct;
12428     gint pf_length;
12429     gint pf_identifier;
12430     gint pack_component_type;
12431     
12432     curr_len = len;
12433     curr_offset = offset;
12434
12435     /*
12436      * parse first octet. It contain TFT operation code, E bit and Number of packet filters
12437      */
12438     oct = tvb_get_guint8(tvb, curr_offset);
12439
12440     op_code = oct>>5;
12441     pkt_fil_count = oct&0x0f;
12442     e_bit = (oct>>4)&1;
12443
12444         proto_tree_add_item(tree,hf_gsm_a_tft_op_code,tvb,curr_offset,1,FALSE);
12445         proto_tree_add_item(tree,hf_gsm_a_tft_e_bit,tvb,curr_offset,1,FALSE);
12446         proto_tree_add_item(tree,hf_gsm_a_tft_pkt_flt,tvb,curr_offset,1,FALSE);
12447
12448     curr_offset++;
12449     curr_len--;
12450
12451     /* Packet filter list dissect */
12452
12453     count = 0;
12454     if ( op_code == 2 )                 /* delete TFT contains no packet filters. so we will jump over it */
12455         count = pkt_fil_count;
12456     while ( count < pkt_fil_count )
12457     {
12458         tf = proto_tree_add_text(tree,
12459                 tvb, curr_offset, 1,
12460                 "Packet filter %d",count);   /* 0-> 7 */
12461
12462         tf_tree = proto_item_add_subtree(tf, ett_sm_tft );
12463
12464         if ( op_code == 5 )  /* Delete packet filters from existing TFT - just a list of identifiers */
12465
12466         {
12467                 if ((curr_offset-offset)<1) { 
12468                         proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
12469                         return(curr_offset-offset);
12470                 }
12471                 oct = tvb_get_guint8(tvb, curr_offset);
12472                 curr_offset++;
12473                 curr_len--;
12474
12475                 proto_tree_add_text(tf_tree,
12476                         tvb, curr_offset-1, 1,
12477                         "Packet filter identifier: 0x%02x (%u)",oct,oct );              
12478         }
12479         else                            /* create new, Add packet filters or Replace packet filters */
12480         {
12481                 
12482                 if ((curr_offset-offset)<1) { 
12483                         proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); 
12484                         return(curr_offset-offset);
12485                 }
12486                 pf_identifier = tvb_get_guint8(tvb, curr_offset);
12487                 curr_offset++;
12488                 curr_len--;
12489
12490                 proto_tree_add_text(tf_tree,
12491                         tvb, curr_offset-1, 1,
12492                         "Packet filter identifier: %u (%u)",pf_identifier, pf_identifier);              
12493
12494                 if ((curr_offset-offset)<1) { 
12495                         proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); 
12496                         return(curr_offset-offset);
12497                 }
12498                 oct = tvb_get_guint8(tvb, curr_offset);
12499                 curr_offset++;
12500                 curr_len--;
12501
12502                 proto_tree_add_text(tf_tree,
12503                         tvb, curr_offset-1, 1,
12504                         "Packet evaluation precedence: 0x%02x (%u)",oct,oct );          
12505
12506                 if ((curr_offset-offset)<1) { proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); return(curr_offset-offset);}
12507                 pf_length = tvb_get_guint8(tvb, curr_offset);
12508                 curr_offset++;
12509                 curr_len--;
12510
12511                 proto_tree_add_text(tf_tree,
12512                         tvb, curr_offset-1, 1,
12513                         "Packet filter length: 0x%02x (%u)",pf_length,pf_length );              
12514                 /* New tree for component */
12515
12516         /* Dissect Packet filter Component */
12517                 /* while ( filter_len > 1 ) */
12518                 /* packet filter component type identifier: */
12519
12520                 if (pf_length > 0 ){
12521                         if ((curr_offset-offset)<1) {
12522                                 proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); 
12523                                 return(curr_offset-offset);
12524                         }
12525                         pack_component_type = tvb_get_guint8(tvb, curr_offset);
12526                         curr_offset++;
12527                         curr_len--;
12528
12529                         tf=proto_tree_add_text(tf_tree,tvb, curr_offset-1, 1,"Packet filter component type identifier: ");
12530                 comp_tree = proto_item_add_subtree(tf, ett_sm_tft );
12531                         
12532                         switch ( pack_component_type ){
12533                                 
12534                                 case 0x10: 
12535                                         str="IPv4 source address type";
12536                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_ip4_address,tvb,curr_offset,4,FALSE);
12537                         curr_offset+=4;
12538                         curr_len-=4;
12539                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_ip4_mask,tvb,curr_offset,4,FALSE);
12540                         curr_offset+=4;
12541                         curr_len-=4;
12542                                         break;
12543  
12544         
12545                                 case 0x20: 
12546                                         str="IPv6 source address type"; 
12547                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_ip6_address,tvb,curr_offset,16,FALSE);
12548                                         curr_offset+=16;
12549                                         curr_len-=16;
12550                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_ip6_mask,tvb,curr_offset,16,FALSE);
12551                                         curr_offset+=16;
12552                                         curr_len-=16;
12553                                         break;
12554
12555                                 case 0x30: 
12556                                         str="Protocol identifier/Next header type";
12557                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_protocol_header,tvb,curr_offset,1,FALSE);
12558                                         curr_offset+=1;
12559                                         curr_len-=1;
12560                                         break;
12561
12562                                 case 0x40: 
12563                                         str="Single destination port type";
12564                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port,tvb,curr_offset,2,FALSE);
12565                                         curr_offset+=2;
12566                                         curr_len-=2;
12567
12568                                 case 0x41: 
12569                                         str="Destination port range type";
12570                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_low,tvb,curr_offset,2,FALSE);
12571                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_high,tvb,curr_offset,2,FALSE);
12572                                         curr_offset+=4;
12573                                         curr_len-=4;
12574                                         break;
12575
12576                                 case 0x50: 
12577                                         str="Single source port type";
12578                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port,tvb,curr_offset,2,FALSE);
12579                                         curr_offset+=2;
12580                                         curr_len-=2;
12581                                         break;
12582
12583                                 case 0x51: 
12584                                         str="Source port range type";
12585                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_low,tvb,curr_offset,2,FALSE);
12586                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_high,tvb,curr_offset,2,FALSE);
12587                                         curr_offset+=4;
12588                                         curr_len-=4;
12589                                         break;
12590
12591                                 case 0x60: 
12592                                         str="Security parameter index type";
12593                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_security,tvb,curr_offset,4,FALSE);
12594                                         curr_offset+=4;
12595                                         curr_len-=4;
12596                                         break;
12597
12598
12599                                 case 0x70: 
12600                                         str="Type of service/Traffic class type";
12601                                         proto_tree_add_item(comp_tree,hf_gsm_a_qos_traffic_cls,tvb,curr_offset,1,FALSE);
12602                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_traffic_mask,tvb,curr_offset,1,FALSE);
12603                                         curr_offset+=2;
12604                                         curr_len-=2;
12605                                         break;
12606
12607                                 case 0x80: 
12608                                         str="Flow label type";
12609                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_traffic_mask,tvb,curr_offset,1,FALSE);
12610                                         curr_offset+=3;
12611                                         curr_len-=3;
12612                                         break;
12613
12614                                 default: 
12615                                         str="not specified";
12616                         }
12617                         proto_item_append_text(tf, "(%u) %s", pack_component_type, str );
12618             count++;
12619                         }
12620                 }
12621         }
12622
12623
12624         /* The parameters list contains a variable number of parameters that might need to be
12625          * transferred in addition to the packet filters. If the parameters list is included, the E
12626          * bit is set to 1; otherwise, the E bit is set to 0.
12627          */
12628          if (e_bit == 1){
12629                  proto_tree_add_text(tf_tree, tvb, curr_offset, 1, "Note: Possible Authorizaton Token/Flow Identifier not decoded yet");
12630          }
12631  return(curr_offset - offset);
12632 }
12633
12634 static guint8 (*bssmap_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len) = {
12635     be_cic,     /* Circuit Identity Code */
12636     NULL,       /* Reserved */
12637     NULL,       /* Resource Available */
12638     be_cause,   /* Cause */
12639     be_cell_id, /* Cell Identifier */
12640     be_prio,    /* Priority */
12641     be_l3_header_info,  /* Layer 3 Header Information */
12642     de_mid,     /* IMSI */
12643     be_tmsi,    /* TMSI */
12644     be_enc_info,        /* Encryption Information */
12645     be_chan_type,       /* Channel Type */
12646     NULL,       /* Periodicity */
12647     NULL,       /* Extended Resource Indicator */
12648     NULL,       /* Number Of MSs */
12649     NULL,       /* Reserved */
12650     NULL,       /* Reserved */
12651     NULL,       /* Reserved */
12652     de_ms_cm_2, /* Classmark Information Type 2 */
12653     NULL,       /* Classmark Information Type 3 */
12654     NULL,       /* Interference Band To Be Used */
12655     de_rr_cause,        /* RR Cause */
12656     NULL,       /* Reserved */
12657     be_l3_info, /* Layer 3 Information */
12658     be_dlci,    /* DLCI */
12659     be_down_dtx_flag,   /* Downlink DTX Flag */
12660     be_cell_id_list,    /* Cell Identifier List */
12661     NULL /* no associated data */,      /* Response Request */
12662     NULL,       /* Resource Indication Method */
12663     de_ms_cm_1, /* Classmark Information Type 1 */
12664     NULL,       /* Circuit Identity Code List */
12665     NULL,       /* Diagnostic */
12666     be_l3_msg,  /* Layer 3 Message Contents */
12667     be_chosen_chan,     /* Chosen Channel */
12668     NULL,       /* Total Resource Accessible */
12669     be_ciph_resp_mode,  /* Cipher Response Mode */
12670     be_cha_needed,      /* Channel Needed */
12671     NULL,       /* Trace Type */
12672     NULL,       /* TriggerID */
12673     NULL,       /* Trace Reference */
12674     NULL,       /* TransactionID */
12675     de_mid,     /* Mobile Identity */
12676     NULL,       /* OMCID */
12677     be_for_ind, /* Forward Indicator */
12678     be_chosen_enc_alg,  /* Chosen Encryption Algorithm */
12679     be_cct_pool,        /* Circuit Pool */
12680     NULL,       /* Circuit Pool List */
12681     NULL,       /* Time Indication */
12682     NULL,       /* Resource Situation */
12683     be_curr_chan_1,     /* Current Channel Type 1 */
12684     be_que_ind, /* Queueing Indicator */
12685     be_speech_ver,      /* Speech Version */
12686     NULL,       /* Assignment Requirement */
12687     NULL /* no associated data */,      /* Talker Flag */
12688     NULL /* no associated data */,      /* Connection Release Requested */
12689     NULL,       /* Group Call Reference */
12690     NULL,       /* eMLPP Priority */
12691     NULL,       /* Configuration Evolution Indication */
12692     NULL /* no decode required */,      /* Old BSS to New BSS Information */
12693     NULL,       /* LSA Identifier */
12694     NULL,       /* LSA Identifier List */
12695     NULL,       /* LSA Information */
12696     NULL,       /* LCS QoS */
12697     NULL,       /* LSA access control suppression */
12698     NULL,       /* LCS Priority */
12699     NULL,       /* Location Type */
12700     NULL,       /* Location Estimate */
12701     NULL,       /* Positioning Data */
12702     NULL,       /* LCS Cause */
12703     NULL,       /* LCS Client Type */
12704     be_apdu,    /* APDU */
12705     NULL,       /* Network Element Identity */
12706     NULL,       /* GPS Assistance Data */
12707     NULL,       /* Deciphering Keys */
12708     NULL,       /* Return Error Request */
12709     NULL,       /* Return Error Cause */
12710     NULL,       /* Segmentation */
12711     NULL,       /* NONE */
12712 };
12713
12714 static guint8 (*dtap_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len) = {
12715     /* Common Information Elements 10.5.1 */
12716     de_cell_id, /* Cell Identity */
12717     NULL /* handled inline */,  /* Ciphering Key Sequence Number */
12718     de_lai,     /* Location Area Identification */
12719     de_mid,     /* Mobile Identity */
12720     de_ms_cm_1, /* Mobile Station Classmark 1 */
12721     de_ms_cm_2, /* Mobile Station Classmark 2 */
12722     NULL,               /* Mobile Station Classmark 3 */
12723     de_d_gb_call_ref,   /* Descriptive group or broadcast call reference */
12724     NULL /* handled inline */,  /* Group Cipher Key Number */
12725     de_pd_sapi, /* PD and SAPI $(CCBS)$ */
12726         /* Pos 10 */
12727     de_prio /* handled inline */,       /* Priority Level */
12728     de_plmn_list,       /* PLMN List */
12729     /* Radio Resource Management  Information Elements 10.5.2, most are from 10.5.1 */
12730 /*
12731  * [3]  10.5.2.1a       BA Range
12732  */
12733         de_rr_cell_ch_dsc,                              /* [3]  10.5.2.1b       Cell Channel Description        */
12734 /* [3]  10.5.2.1c       BA List Pref
12735  * [3]  10.5.2.1d       UTRAN Frequency List
12736  * [3]  10.5.2.1e       Cell selection indicator after release of all TCH and SDCCH IE
12737  */
12738         de_rr_cell_dsc,                                 /* 10.5.2.2   RR Cell Description                               */
12739 /*
12740  * [3]  10.5.2.3        Cell Options (BCCH)     
12741  * [3]  10.5.2.3a       Cell Options (SACCH)
12742  * [3]  10.5.2.4        Cell Selection Parameters
12743  * [3]  10.5.2.4a       (void)
12744  */
12745         de_rr_ch_dsc,                                   /* [3]  10.5.2.5        Channel Description                     */
12746         de_rr_ch_dsc2,                                  /* [3]  10.5.2.5a   RR Channel Description 2    */
12747         de_rr_ch_mode,                                  /* [3]  10.5.2.6        Channel Mode                            */
12748         de_rr_ch_mode2,                                 /* [3]  10.5.2.7        Channel Mode 2                          */
12749 /*
12750  * [3]  10.5.2.7a       UTRAN predefined configuration status information / START-CS / UE CapabilityUTRAN Classmark information element 218
12751  * [3]  10.5.2.7b       (void) */
12752
12753         de_rr_cm_enq_mask,                              /* [3]  10.5.2.7c       Classmark Enquiry Mask          */
12754 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element                                             */
12755         de_rr_chnl_needed,                              /* [3]  10.5.2.8        Channel Needed
12756  * [3]  10.5.2.8a       (void)  
12757  * [3]  10.5.2.8b       Channel Request Description 2 */
12758         /* Pos 20 */
12759         de_rr_cip_mode_set,                                     /* [3]  10.5.2.9        Cipher Mode Setting             */
12760 /* [3]  10.5.2.10       Cipher Response
12761  * [3]  10.5.2.11       Control Channel Description
12762  * [3]  10.5.2.11a      DTM Information Details */
12763         de_rr_dyn_arfcn_map,                            /* [3]  10.5.2.11b      Dynamic ARFCN Mapping           */
12764         de_rr_freq_ch_seq,                                      /* [3]  10.5.2.12       Frequency Channel Sequence      */
12765         de_rr_freq_list,                                        /* [3]  10.5.2.13       Frequency List                          */
12766         de_rr_freq_short_list,                          /* [3]  10.5.2.14       Frequency Short List            */
12767         de_rr_freq_short_list2,                         /* [3]  10.5.2.14a      Frequency Short List 2          */
12768 /* [3]  10.5.2.14b      Group Channel Description
12769  * [3]  10.5.2.14c      GPRS Resumption
12770  * [3]  10.5.2.14d      GPRS broadcast information
12771  * [3]  10.5.2.14e      Enhanced DTM CS Release Indication
12772  */
12773         de_rr_ho_ref,                                   /* 10.5.2.15  Handover Reference                                */
12774 /*
12775  * [3] 10.5.2.16 IA Rest Octets
12776  * [3] 10.5.2.17 IAR Rest Octets
12777  * [3] 10.5.2.18 IAX Rest Octets
12778  * [3] 10.5.2.19 L2 Pseudo Length
12779  * [3] 10.5.2.20 Measurement Results
12780  * [3] 10.5.2.20a GPRS Measurement Results
12781  */
12782         de_rr_mob_all,                                  /* [3] 10.5.2.21 Mobile Allocation                              */
12783         de_rr_mob_time_diff,                    /* [3] 10.5.2.21a Mobile Time Difference                */
12784         de_rr_multirate_conf,                   /* [3] 10.5.2.21aa MultiRate configuration              */
12785         /* Pos 30 */
12786         de_rr_mult_all,                                 /* [3] 10.5.2.21b Multislot Allocation                  */
12787 /*
12788  * [3] 10.5.2.21c NC mode
12789  * [3] 10.5.2.22 Neighbour Cell Description
12790  * [3] 10.5.2.22a Neighbour Cell Description 2
12791  * [3] 10.5.2.22b (void)
12792  * [3] 10.5.2.22c NT/N Rest Octets
12793  * [3] 10.5.2.23 P1 Rest Octets
12794  * [3] 10.5.2.24 P2 Rest Octets
12795  * [3] 10.5.2.25 P3 Rest Octets
12796  * [3] 10.5.2.25a Packet Channel Description
12797  * [3] 10.5.2.25b Dedicated mode or TBF
12798  * [3] 10.5.2.25c RR Packet Uplink Assignment
12799  * [3] 10.5.2.25d RR Packet Downlink Assignment
12800  * [3] 10.5.2.26 Page Mode
12801  * [3] 10.5.2.26a (void)
12802  * [3] 10.5.2.26b (void)
12803  * [3] 10.5.2.26c (void)
12804  * [3] 10.5.2.26d (void)
12805  * [3] 10.5.2.27 NCC Permitted
12806  */
12807         de_rr_pow_cmd,                                  /* 10.5.2.28  Power Command                                             */
12808         de_rr_pow_cmd_and_acc_type,             /* 10.5.2.28a Power Command and access type             */
12809 /*
12810  * [3] 10.5.2.29 RACH Control Parameters
12811  * [3] 10.5.2.30 Request Reference
12812  */
12813     de_rr_cause,                                        /* 10.5.2.31  RR Cause                                                  */
12814         de_rr_sync_ind,                                 /* 10.5.2.39  Synchronization Indication                */
12815 /* [3] 10.5.2.32 SI 1 Rest Octets
12816  * [3] 10.5.2.33 SI 2bis Rest Octets 
12817  * [3] 10.5.2.33a SI 2ter Rest Octets
12818  * [3] 10.5.2.33b SI 2quater Rest Octets
12819  * [3] 10.5.2.34 SI 3 Rest Octets
12820  * [3] 10.5.2.35 SI 4 Rest Octets
12821  * [3] 10.5.2.35a SI 6 Rest Octets
12822  * [3] 10.5.2.36 SI 7 Rest Octets
12823  * [3] 10.5.2.37 SI 8 Rest Octets
12824  * [3] 10.5.2.37a SI 9 Rest Octets
12825  * [3] 10.5.2.37b SI 13 Rest Octets
12826  * [3] 10.5.2.37c (void)
12827  * [3] 10.5.2.37d (void)
12828  * [3] 10.5.2.37e SI 16 Rest Octets
12829  * [3] 10.5.2.37f SI 17 Rest Octets
12830  * [3] 10.5.2.37g SI 19 Rest Octets
12831  * [3] 10.5.2.37h SI 18 Rest Octets
12832  * [3] 10.5.2.37i SI 20 Rest Octets */
12833         de_rr_starting_time,                            /* [3] 10.5.2.38 Starting Time                                  */
12834         de_rr_timing_adv,                                       /* [3] 10.5.2.40 Timing Advance                                 */ 
12835         de_rr_time_diff,                                        /* [3] 10.5.2.41 Time Difference                                */
12836         de_rr_tlli,                                                     /* [3] 10.5.2.41a TLLI                                                  */
12837 /*
12838  * [3] 10.5.2.42 TMSI/P-TMSI */
12839         de_rr_vgcs_tar_mode_ind,                        /* [3] 10.5.2.42a VGCS target mode Indication   */
12840         /* Pos 40 */
12841         de_rr_vgcs_cip_par,                                     /* [3] 10.5.2.42b       VGCS Ciphering Parameters       */
12842 /* [3] 10.5.2.43 Wait Indication
12843  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
12844  * [3] 10.5.2.45 EXTENDED MEASUREMENT RESULTS
12845  * [3] 10.5.2.46 Extended Measurement Frequency List */
12846         de_rr_sus_cau,                                          /* [3] 10.5.2.47 Suspension Cause                               */
12847 /* [3] 10.5.2.48 APDU ID 
12848  * [3] 10.5.2.49 APDU Flags
12849  * [3] 10.5.2.50 APDU Data
12850  * [3] 10.5.2.51 Handover To UTRAN Command
12851  * [3] 10.5.2.52 Handover To cdma2000 Command 
12852  * [3] 10.5.2.53 (void)
12853  * [3] 10.5.2.54 (void)
12854  * [3] 10.5.2.55 (void)
12855  * [3] 10.5.2.56 3G Target Cell
12856 */
12857         de_rr_ded_serv_inf,                                     /* [3] 10.5.2.59        Dedicated Service Information */
12858
12859         /* Mobility Management Information Elements 10.5.3 */
12860     de_auth_param_rand, /* Authentication Parameter RAND */
12861     de_auth_param_autn, /* Authentication Parameter AUTN (UMTS authentication challenge only) */
12862     de_auth_resp_param, /* Authentication Response Parameter */
12863     de_auth_resp_param_ext,     /* Authentication Response Parameter (extension) (UMTS authentication challenge only) */
12864     de_auth_fail_param, /* Authentication Failure Parameter (UMTS authentication challenge only) */
12865     NULL /* handled inline */,  /* CM Service Type */
12866     NULL /* handled inline */,  /* Identity Type */
12867         /* Pos 50 */
12868     NULL /* handled inline */,  /* Location Updating Type */
12869     de_network_name,    /* Network Name */
12870     de_rej_cause,       /* Reject Cause */
12871     NULL /* no associated data */,      /* Follow-on Proceed */
12872     de_time_zone,       /* Time Zone */
12873     de_time_zone_time,  /* Time Zone and Time */
12874     NULL /* no associated data */,      /* CTS Permission */
12875     de_lsa_id,  /* LSA Identifier */
12876     de_day_saving_time, /* Daylight Saving Time */
12877     NULL, /* Emergency Number List */
12878     /* Call Control Information Elements 10.5.4 */
12879         /* Pos 60 */
12880     de_aux_states,      /* Auxiliary States */
12881     de_bearer_cap,      /* Bearer Capability */
12882     de_cc_cap,  /* Call Control Capabilities */
12883     de_call_state,      /* Call State */
12884     de_cld_party_bcd_num,       /* Called Party BCD Number */
12885     de_cld_party_sub_addr,      /* Called Party Subaddress */
12886     de_clg_party_bcd_num,       /* Calling Party BCD Number */
12887     de_clg_party_sub_addr,      /* Calling Party Subaddress */
12888     de_cause,   /* Cause */
12889     NULL /* no associated data */,      /* CLIR Suppression */
12890     NULL /* no associated data */,      /* CLIR Invocation */
12891     NULL /* handled inline */,  /* Congestion Level */
12892     NULL,       /* Connected Number */
12893     NULL,       /* Connected Subaddress */
12894     de_facility,        /* Facility */
12895     NULL,       /* High Layer Compatibility */
12896     de_keypad_facility, /* Keypad Facility */
12897     de_llc,                                                     /* 10.5.4.18 Low layer compatibility */
12898     NULL,       /* More Data */
12899     NULL,       /* Notification Indicator */
12900     de_prog_ind,        /* Progress Indicator */
12901     NULL,       /* Recall type $(CCBS)$ */
12902     NULL,       /* Redirecting Party BCD Number */
12903     NULL,       /* Redirecting Party Subaddress */
12904     de_repeat_ind,      /* Repeat Indicator */
12905     NULL /* no associated data */,      /* Reverse Call Setup Direction */
12906     NULL,       /* SETUP Container $(CCBS)$ */
12907     NULL,       /* Signal */
12908     de_ss_ver_ind,      /* SS Version Indicator */
12909     NULL,       /* User-user */
12910     NULL,       /* Alerting Pattern $(NIA)$ */
12911     NULL,       /* Allowed Actions $(CCBS)$ */
12912     NULL,       /* Stream Identifier */
12913     NULL,       /* Network Call Control Capabilities */
12914     NULL,       /* Cause of No CLI */
12915     NULL,       /* Immediate Modification Indicator */
12916     NULL,       /* Supported Codec List */
12917     NULL,       /* Service Category */
12918     /* GPRS Mobility Management Information Elements 10.5.5 */
12919     de_gmm_attach_res,  /* Attach Result */
12920     de_gmm_attach_type, /* Attach Type */
12921     de_gmm_ciph_alg,    /* Cipher Algorithm */
12922     de_gmm_tmsi_stat,   /* TMSI Status */
12923     de_gmm_detach_type, /* Detach Type */
12924     de_gmm_drx_param,   /* DRX Parameter */
12925     de_gmm_ftostby,     /* Force to Standby */
12926     de_gmm_ftostby_h,   /* Force to Standby - Info is in the high nibble */
12927     de_gmm_ptmsi_sig,   /* P-TMSI Signature */
12928     de_gmm_ptmsi_sig2,  /* P-TMSI Signature 2 */
12929     de_gmm_ident_type2, /* Identity Type 2 */
12930     de_gmm_imeisv_req,  /* IMEISV Request */
12931     de_gmm_rec_npdu_lst,        /* Receive N-PDU Numbers List */
12932     de_gmm_ms_net_cap,  /* MS Network Capability */
12933     de_gmm_ms_radio_acc_cap,    /* MS Radio Access Capability */
12934     de_gmm_cause,       /* GMM Cause */
12935     de_gmm_rai, /* Routing Area Identification */
12936     de_gmm_update_res,  /* Update Result */
12937     de_gmm_update_type, /* Update Type */
12938     de_gmm_ac_ref_nr,   /* A&C Reference Number */
12939     de_gmm_ac_ref_nr_h, /* A&C Reference Numer - Info is in the high nibble */
12940     de_gmm_service_type,        /* Service Type */
12941     de_gmm_cell_notfi,  /* Cell Notification */
12942     de_gmm_ps_lcs_cap,  /* PS LCS Capability */
12943     de_gmm_net_feat_supp,       /* Network Feature Support */
12944         de_gmm_rat_info_container, /* Inter RAT information container */
12945     /* Short Message Service Information Elements [5] 8.1.4 */
12946     de_cp_user_data,    /* CP-User Data */
12947     de_cp_cause,        /* CP-Cause */
12948     /* Short Message Service Information Elements [5] 8.2 */
12949     de_rp_message_ref,  /* RP-Message Reference */
12950     de_rp_orig_addr,    /* RP-Origination Address */
12951     de_rp_dest_addr,    /* RP-Destination Address */
12952     de_rp_user_data,    /* RP-User Data */
12953     de_rp_cause,        /* RP-Cause */
12954     /* Session Management Information Elements 10.5.6 */
12955     de_sm_apn,  /* Access Point Name */
12956     de_sm_nsapi,        /* Network Service Access Point Identifier */
12957     de_sm_pco,  /* Protocol Configuration Options */
12958     de_sm_pdp_addr,     /* Packet Data Protocol Address */
12959     de_sm_qos,  /* Quality Of Service */
12960     de_sm_cause,        /* SM Cause */
12961     de_sm_linked_ti,    /* Linked TI */
12962     de_sm_sapi, /* LLC Service Access Point Identifier */
12963     de_sm_tear_down,    /* Tear Down Indicator */
12964     de_sm_pflow_id,     /* Packet Flow Identifier */
12965     de_sm_tflow_temp,   /* Traffic Flow Template */
12966     /* GPRS Common Information Elements 10.5.7 */
12967     de_gc_context_stat, /* PDP Context Status */
12968     de_gc_radio_prio,   /* Radio Priority */
12969     de_gc_timer,        /* GPRS Timer */
12970     de_gc_timer2,       /* GPRS Timer 2 */
12971     de_gc_radio_prio2,  /* Radio Priority 2 */
12972         de_gc_mbms_context_stat, /* 10.5.7.6 MBMS context status */
12973     de_gc_spare,        /* Spare Nibble */
12974     NULL,       /* NONE */
12975 };
12976
12977 #define SET_ELEM_VARS(SEV_pdu_type, SEV_elem_names, SEV_elem_ett, SEV_elem_funcs) \
12978     switch (SEV_pdu_type) \
12979     { \
12980     case BSSAP_PDU_TYPE_BSSMAP: \
12981         SEV_elem_names = gsm_bssmap_elem_strings; \
12982         SEV_elem_ett = ett_gsm_bssmap_elem; \
12983         SEV_elem_funcs = bssmap_elem_fcn; \
12984         break; \
12985     case BSSAP_PDU_TYPE_DTAP: \
12986         SEV_elem_names = gsm_dtap_elem_strings; \
12987         SEV_elem_ett = ett_gsm_dtap_elem; \
12988         SEV_elem_funcs = dtap_elem_fcn; \
12989         break; \
12990     default: \
12991         proto_tree_add_text(tree, \
12992             tvb, curr_offset, -1, \
12993             "Unknown PDU type (%u)", SEV_pdu_type); \
12994         return(consumed); \
12995     }
12996
12997 /*
12998  * Type Length Value (TLV) element dissector
12999  */
13000 static guint8
13001 elem_tlv(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, guint len, const gchar *name_add)
13002 {
13003     guint8              oct, parm_len;
13004     guint8              consumed;
13005     guint32             curr_offset;
13006     proto_tree          *subtree;
13007     proto_item          *item;
13008     const value_string  *elem_names;
13009     gint                *elem_ett;
13010     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
13011
13012     len = len;
13013     curr_offset = offset;
13014     consumed = 0;
13015
13016     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
13017
13018     oct = tvb_get_guint8(tvb, curr_offset);
13019
13020     if (oct == iei)
13021     {
13022         parm_len = tvb_get_guint8(tvb, curr_offset + 1);
13023
13024         item =
13025             proto_tree_add_text(tree,
13026                 tvb, curr_offset, parm_len + 2,
13027                 "%s%s",
13028                 elem_names[idx].strptr,
13029                 (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
13030
13031         subtree = proto_item_add_subtree(item, elem_ett[idx]);
13032
13033         proto_tree_add_uint(subtree,
13034             (BSSAP_PDU_TYPE_BSSMAP == pdu_type) ? hf_gsm_a_bssmap_elem_id : hf_gsm_a_dtap_elem_id, tvb,
13035             curr_offset, 1, oct);
13036
13037         proto_tree_add_uint(subtree, hf_gsm_a_length, tvb,
13038             curr_offset + 1, 1, parm_len);
13039
13040         if (parm_len > 0)
13041         {
13042             if (elem_funcs[idx] == NULL)
13043             {
13044                 proto_tree_add_text(subtree,
13045                     tvb, curr_offset + 2, parm_len,
13046                     "Element Value");
13047
13048                 consumed = parm_len;
13049             }
13050             else
13051             {
13052                 gchar *a_add_string;
13053
13054                 a_add_string=ep_alloc(1024);
13055                 a_add_string[0] = '\0';
13056                 consumed =
13057                     (*elem_funcs[idx])(tvb, subtree, curr_offset + 2,
13058                         parm_len, a_add_string, 1024);
13059
13060                 if (a_add_string[0] != '\0')
13061                 {
13062                     proto_item_append_text(item, "%s", a_add_string);
13063                 }
13064             }
13065         }
13066
13067         consumed += 2;
13068     }
13069
13070     return(consumed);
13071 }
13072
13073 /*
13074  * Type Value (TV) element dissector
13075  *
13076  * Length cannot be used in these functions, big problem if a element dissector
13077  * is not defined for these.
13078  */
13079 static guint8
13080 elem_tv(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add)
13081 {
13082     guint8              oct;
13083     guint8              consumed;
13084     guint32             curr_offset;
13085     proto_tree          *subtree;
13086     proto_item          *item;
13087     const value_string  *elem_names;
13088     gint                *elem_ett;
13089     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
13090
13091     curr_offset = offset;
13092     consumed = 0;
13093
13094     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
13095
13096     oct = tvb_get_guint8(tvb, curr_offset);
13097
13098     if (oct == iei)
13099     {
13100         item =
13101             proto_tree_add_text(tree,
13102                 tvb, curr_offset, -1,
13103                 "%s%s",
13104                 elem_names[idx].strptr,
13105                 (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
13106
13107         subtree = proto_item_add_subtree(item, elem_ett[idx]);
13108
13109         proto_tree_add_uint(subtree,
13110             (BSSAP_PDU_TYPE_BSSMAP == pdu_type) ? hf_gsm_a_bssmap_elem_id : hf_gsm_a_dtap_elem_id, tvb,
13111             curr_offset, 1, oct);
13112
13113         if (elem_funcs[idx] == NULL)
13114         {
13115             /* BAD THING, CANNOT DETERMINE LENGTH */
13116
13117             proto_tree_add_text(subtree,
13118                 tvb, curr_offset + 1, 1,
13119                 "No element dissector, rest of dissection may be incorrect");
13120
13121             consumed = 1;
13122         }
13123         else
13124         {
13125             gchar *a_add_string;
13126
13127             a_add_string=ep_alloc(1024);
13128             a_add_string[0] = '\0';
13129             consumed = (*elem_funcs[idx])(tvb, subtree, curr_offset + 1, -1, a_add_string, 1024);
13130
13131             if (a_add_string[0] != '\0')
13132             {
13133                 proto_item_append_text(item, "%s", a_add_string);
13134             }
13135         }
13136
13137         consumed++;
13138
13139         proto_item_set_len(item, consumed);
13140     }
13141
13142     return(consumed);
13143 }
13144
13145 /*
13146  * Type Value (TV) element dissector
13147  * Where top half nibble is IEI and bottom half nibble is value.
13148  *
13149  * Length cannot be used in these functions, big problem if a element dissector
13150  * is not defined for these.
13151  */
13152 static guint8
13153 elem_tv_short(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add)
13154 {
13155     guint8              oct;
13156     guint8              consumed;
13157     guint32             curr_offset;
13158     proto_tree          *subtree;
13159     proto_item          *item;
13160     const value_string  *elem_names;
13161     gint                *elem_ett;
13162     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
13163
13164     curr_offset = offset;
13165     consumed = 0;
13166
13167     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
13168
13169     oct = tvb_get_guint8(tvb, curr_offset);
13170
13171     if ((oct & 0xf0) == (iei & 0xf0))
13172     {
13173         item =
13174             proto_tree_add_text(tree,
13175                 tvb, curr_offset, -1,
13176                 "%s%s",
13177                 elem_names[idx].strptr,
13178                 (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
13179
13180         subtree = proto_item_add_subtree(item, elem_ett[idx]);
13181
13182         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
13183         proto_tree_add_text(subtree,
13184             tvb, curr_offset, 1,
13185             "%s :  Element ID",
13186             a_bigbuf);
13187
13188         if (elem_funcs[idx] == NULL)
13189         {
13190             /* BAD THING, CANNOT DETERMINE LENGTH */
13191
13192             proto_tree_add_text(subtree,
13193                 tvb, curr_offset, 1,
13194                 "No element dissector, rest of dissection may be incorrect");
13195
13196             consumed++;
13197         }
13198         else
13199         {
13200             gchar *a_add_string;
13201
13202             a_add_string=ep_alloc(1024);
13203             a_add_string[0] = '\0';
13204             consumed = (*elem_funcs[idx])(tvb, subtree, curr_offset, -1, a_add_string, 1024);
13205
13206             if (a_add_string[0] != '\0')
13207             {
13208                 proto_item_append_text(item, "%s", a_add_string);
13209             }
13210         }
13211
13212         proto_item_set_len(item, consumed);
13213     }
13214
13215     return(consumed);
13216 }
13217
13218 /*
13219  * Type (T) element dissector
13220  */
13221 static guint8
13222 elem_t(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add)
13223 {
13224     guint8              oct;
13225     guint32             curr_offset;
13226     guint8              consumed;
13227     const value_string  *elem_names;
13228     gint                *elem_ett;
13229     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
13230
13231     curr_offset = offset;
13232     consumed = 0;
13233
13234     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
13235
13236     oct = tvb_get_guint8(tvb, curr_offset);
13237
13238     if (oct == iei)
13239     {
13240         proto_tree_add_uint_format(tree,
13241             (BSSAP_PDU_TYPE_BSSMAP == pdu_type) ? hf_gsm_a_bssmap_elem_id : hf_gsm_a_dtap_elem_id, tvb,
13242             curr_offset, 1, oct,
13243             "%s%s",
13244             elem_names[idx].strptr,
13245             (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
13246
13247         consumed = 1;
13248     }
13249
13250     return(consumed);
13251 }
13252
13253 /*
13254  * Length Value (LV) element dissector
13255  */
13256 static guint8
13257 elem_lv(tvbuff_t *tvb, proto_tree *tree, gint pdu_type, int idx, guint32 offset, guint len, const gchar *name_add)
13258 {
13259     guint8              parm_len;
13260     guint8              consumed;
13261     guint32             curr_offset;
13262     proto_tree          *subtree;
13263     proto_item          *item;
13264     const value_string  *elem_names;
13265     gint                *elem_ett;
13266     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
13267
13268     len = len;
13269     curr_offset = offset;
13270     consumed = 0;
13271
13272     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
13273
13274     parm_len = tvb_get_guint8(tvb, curr_offset);
13275
13276     item =
13277         proto_tree_add_text(tree,
13278             tvb, curr_offset, parm_len + 1,
13279             "%s%s",
13280             elem_names[idx].strptr,
13281             (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
13282
13283     subtree = proto_item_add_subtree(item, elem_ett[idx]);
13284
13285     proto_tree_add_uint(subtree, hf_gsm_a_length, tvb,
13286         curr_offset, 1, parm_len);
13287
13288     if (parm_len > 0)
13289     {
13290         if (elem_funcs[idx] == NULL)
13291         {
13292             proto_tree_add_text(subtree,
13293                 tvb, curr_offset + 1, parm_len,
13294                 "Element Value");
13295
13296             consumed = parm_len;
13297         }
13298         else
13299         {
13300             gchar *a_add_string;
13301
13302             a_add_string=ep_alloc(1024);
13303             a_add_string[0] = '\0';
13304             consumed =
13305                 (*elem_funcs[idx])(tvb, subtree, curr_offset + 1,
13306                     parm_len, a_add_string, 1024);
13307
13308             if (a_add_string[0] != '\0')
13309             {
13310                 proto_item_append_text(item, "%s", a_add_string);
13311             }
13312         }
13313     }
13314
13315     return(consumed + 1);
13316 }
13317
13318 /*
13319  * Value (V) element dissector
13320  *
13321  * Length cannot be used in these functions, big problem if a element dissector
13322  * is not defined for these.
13323  */
13324 static guint8
13325 elem_v(tvbuff_t *tvb, proto_tree *tree, gint pdu_type, int idx, guint32 offset)
13326 {
13327     guint8              consumed;
13328     guint32             curr_offset;
13329     const value_string  *elem_names;
13330     gint                *elem_ett;
13331     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
13332
13333     curr_offset = offset;
13334     consumed = 0;
13335
13336     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
13337
13338     if (elem_funcs[idx] == NULL)
13339     {
13340         /* BAD THING, CANNOT DETERMINE LENGTH */
13341
13342         proto_tree_add_text(tree,
13343             tvb, curr_offset, 1,
13344             "No element dissector, rest of dissection may be incorrect");
13345
13346         consumed = 1;
13347     }
13348     else
13349     {
13350         gchar *a_add_string;
13351
13352         a_add_string=ep_alloc(1024);
13353         a_add_string[0] = '\0';
13354         consumed = (*elem_funcs[idx])(tvb, tree, curr_offset, -1, a_add_string, 1024);
13355     }
13356
13357     return(consumed);
13358 }
13359
13360 #define ELEM_MAND_TLV(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition) \
13361 {\
13362     if ((consumed = elem_tlv(tvb, tree, (guint8) EMT_iei, EMT_pdu_type, EMT_elem_idx, curr_offset, curr_len, EMT_elem_name_addition)) > 0) \
13363     { \
13364         curr_offset += consumed; \
13365         curr_len -= consumed; \
13366     } \
13367     else \
13368     { \
13369         proto_tree_add_text(tree, \
13370             tvb, curr_offset, 0, \
13371             "Missing Mandatory element (0x%02x) %s%s, rest of dissection is suspect", \
13372                 EMT_iei, \
13373                 (EMT_pdu_type == BSSAP_PDU_TYPE_BSSMAP) ? \
13374                     gsm_bssmap_elem_strings[EMT_elem_idx].strptr : gsm_dtap_elem_strings[EMT_elem_idx].strptr, \
13375                 (EMT_elem_name_addition == NULL) || (EMT_elem_name_addition[0] == '\0') ? "" : EMT_elem_name_addition \
13376             ); \
13377     } \
13378     if (curr_len <= 0) return; \
13379 }
13380
13381 #define ELEM_OPT_TLV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
13382 {\
13383     if ((consumed = elem_tlv(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, curr_len, EOT_elem_name_addition)) > 0) \
13384     { \
13385         curr_offset += consumed; \
13386         curr_len -= consumed; \
13387     } \
13388     if (curr_len <= 0) return; \
13389 }
13390
13391 #define ELEM_MAND_TV(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition) \
13392 {\
13393     if ((consumed = elem_tv(tvb, tree, (guint8) EMT_iei, EMT_pdu_type, EMT_elem_idx, curr_offset, EMT_elem_name_addition)) > 0) \
13394     { \
13395         curr_offset += consumed; \
13396         curr_len -= consumed; \
13397     } \
13398     else \
13399     { \
13400         proto_tree_add_text(tree, \
13401             tvb, curr_offset, 0, \
13402             "Missing Mandatory element (0x%02x) %s%s, rest of dissection is suspect", \
13403                 EMT_iei, \
13404                 (EMT_pdu_type == BSSAP_PDU_TYPE_BSSMAP) ? \
13405                     gsm_bssmap_elem_strings[EMT_elem_idx].strptr : gsm_dtap_elem_strings[EMT_elem_idx].strptr, \
13406                 (EMT_elem_name_addition == NULL) || (EMT_elem_name_addition[0] == '\0') ? "" : EMT_elem_name_addition \
13407             ); \
13408     } \
13409     if (curr_len <= 0) return; \
13410 }
13411
13412 #define ELEM_OPT_TV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
13413 {\
13414     if ((consumed = elem_tv(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
13415     { \
13416         curr_offset += consumed; \
13417         curr_len -= consumed; \
13418     } \
13419     if (curr_len <= 0) return; \
13420 }
13421
13422 #define ELEM_OPT_TV_SHORT(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
13423 {\
13424     if ((consumed = elem_tv_short(tvb, tree, EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
13425     { \
13426         curr_offset += consumed; \
13427         curr_len -= consumed; \
13428     } \
13429     if (curr_len <= 0) return; \
13430 }
13431
13432 #define ELEM_OPT_T(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
13433 {\
13434     if ((consumed = elem_t(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
13435     { \
13436         curr_offset += consumed; \
13437         curr_len -= consumed; \
13438     } \
13439     if (curr_len <= 0) return; \
13440 }
13441
13442 #define ELEM_MAND_LV(EML_pdu_type, EML_elem_idx, EML_elem_name_addition) \
13443 {\
13444     if ((consumed = elem_lv(tvb, tree, EML_pdu_type, EML_elem_idx, curr_offset, curr_len, EML_elem_name_addition)) > 0) \
13445     { \
13446         curr_offset += consumed; \
13447         curr_len -= consumed; \
13448     } \
13449     else \
13450     { \
13451         /* Mandatory, but nothing we can do */ \
13452     } \
13453     if (curr_len <= 0) return; \
13454 }
13455
13456 #define ELEM_MAND_V(EMV_pdu_type, EMV_elem_idx) \
13457 {\
13458     if ((consumed = elem_v(tvb, tree, EMV_pdu_type, EMV_elem_idx, curr_offset)) > 0) \
13459     { \
13460         curr_offset += consumed; \
13461         curr_len -= consumed; \
13462     } \
13463     else \
13464     { \
13465         /* Mandatory, but nothing we can do */ \
13466     } \
13467     if (curr_len <= 0) return; \
13468 }
13469
13470
13471 /* MESSAGE FUNCTIONS */
13472
13473 /*
13474  *  [2] 3.2.1.1
13475  */
13476 static void
13477 bssmap_ass_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13478 {
13479     guint32     curr_offset;
13480     guint32     consumed;
13481     guint       curr_len;
13482
13483     curr_offset = offset;
13484     curr_len = len;
13485
13486     is_uplink = IS_UPLINK_FALSE;
13487
13488     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CHAN_TYPE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHAN_TYPE, "");
13489
13490     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_L3_HEADER_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_HEADER_INFO, "");
13491
13492     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_PRIO].value, BSSAP_PDU_TYPE_BSSMAP, BE_PRIO, "");
13493
13494     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13495
13496     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_DOWN_DTX_FLAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_DOWN_DTX_FLAG, "");
13497
13498     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_INT_BAND].value, BSSAP_PDU_TYPE_BSSMAP, BE_INT_BAND, "");
13499
13500     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_2].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_2, "");
13501
13502     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_GROUP_CALL_REF].value, BSSAP_PDU_TYPE_BSSMAP, BE_GROUP_CALL_REF, "");
13503
13504     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_TALKER_FLAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_TALKER_FLAG, "");
13505
13506     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_LSA_ACC_CTRL].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ACC_CTRL, "");
13507
13508     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13509 }
13510
13511 /*
13512  *  [2] 3.2.1.2
13513  */
13514 static void
13515 bssmap_ass_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13516 {
13517     guint32     curr_offset;
13518     guint32     consumed;
13519     guint       curr_len;
13520
13521     curr_offset = offset;
13522     curr_len = len;
13523
13524     is_uplink = IS_UPLINK_TRUE;
13525
13526     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_RR_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_RR_CAUSE, "");
13527
13528     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13529
13530     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13531
13532     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_CHAN].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, "");
13533
13534     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, "");
13535
13536     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CCT_POOL].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL, "");
13537
13538     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Chosen)");
13539
13540     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ID, "");
13541
13542     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13543 }
13544
13545 /*
13546  *  [2] 3.2.1.3
13547  */
13548 static void
13549 bssmap_ass_failure(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13550 {
13551     guint32     curr_offset;
13552     guint32     consumed;
13553     guint       curr_len;
13554
13555     curr_offset = offset;
13556     curr_len = len;
13557
13558     is_uplink = IS_UPLINK_TRUE;
13559
13560     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13561
13562     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_RR_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_RR_CAUSE, "");
13563
13564     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CCT_POOL].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL, "");
13565
13566     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CCT_POOL_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL_LIST, "");
13567
13568     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13569 }
13570
13571 /*
13572  *  [2] 3.2.1.4
13573  */
13574 static void
13575 bssmap_block(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13576 {
13577     guint32     curr_offset;
13578     guint32     consumed;
13579     guint       curr_len;
13580
13581     curr_offset = offset;
13582     curr_len = len;
13583
13584     is_uplink = IS_UPLINK_TRUE;
13585
13586     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13587
13588     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13589
13590     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_CONN_REL_REQ].value, BSSAP_PDU_TYPE_BSSMAP, BE_CONN_REL_REQ, "");
13591
13592     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13593 }
13594
13595 /*
13596  *  [2] 3.2.1.5
13597  */
13598 static void
13599 bssmap_block_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13600 {
13601     guint32     curr_offset;
13602     guint32     consumed;
13603     guint       curr_len;
13604
13605     curr_offset = offset;
13606     curr_len = len;
13607
13608     is_uplink = IS_UPLINK_TRUE;
13609
13610     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13611
13612     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13613 }
13614
13615 /*
13616  *  [2] 3.2.1.6
13617  */
13618 static void
13619 bssmap_unblock(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13620 {
13621     guint32     curr_offset;
13622     guint32     consumed;
13623     guint       curr_len;
13624
13625     curr_offset = offset;
13626     curr_len = len;
13627
13628     is_uplink = IS_UPLINK_TRUE;
13629
13630     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13631
13632     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_CONN_REL_REQ].value, BSSAP_PDU_TYPE_BSSMAP, BE_CONN_REL_REQ, "");
13633
13634     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13635 }
13636
13637 /*
13638  *  [2] 3.2.1.7
13639  */
13640 static void
13641 bssmap_unblock_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13642 {
13643     guint32     curr_offset;
13644     guint32     consumed;
13645     guint       curr_len;
13646
13647     curr_offset = offset;
13648     curr_len = len;
13649
13650     is_uplink = IS_UPLINK_TRUE;
13651
13652     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13653
13654     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13655 }
13656
13657 /*
13658  *  [2] 3.2.1.8
13659  */
13660 static void
13661 bssmap_ho_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13662 {
13663     guint32     curr_offset;
13664     guint32     consumed;
13665     guint       curr_len;
13666
13667     curr_offset = offset;
13668     curr_len = len;
13669
13670     is_uplink = IS_UPLINK_FALSE;
13671
13672     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CHAN_TYPE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHAN_TYPE, "");
13673
13674     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_ENC_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_ENC_INFO, "");
13675
13676     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CM_INFO_1].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_1, "");
13677
13678     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_2].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_2, "");
13679
13680     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, " (Serving)");
13681
13682     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_PRIO].value, BSSAP_PDU_TYPE_BSSMAP, BE_PRIO, "");
13683
13684     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13685
13686     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_DOWN_DTX_FLAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_DOWN_DTX_FLAG, "");
13687
13688     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, " (Target)");
13689
13690     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_INT_BAND].value, BSSAP_PDU_TYPE_BSSMAP, BE_INT_BAND, "");
13691
13692     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13693
13694     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_3].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_3, "");
13695
13696     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CURR_CHAN_1].value, BSSAP_PDU_TYPE_BSSMAP, BE_CURR_CHAN_1, "");
13697
13698     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Used)");
13699
13700     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_GROUP_CALL_REF].value, BSSAP_PDU_TYPE_BSSMAP, BE_GROUP_CALL_REF, "");
13701
13702     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_TALKER_FLAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_TALKER_FLAG, "");
13703
13704     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CONF_EVO_IND].value, BSSAP_PDU_TYPE_BSSMAP, BE_CONF_EVO_IND, "");
13705
13706     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, " (Serving)");
13707
13708     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_OLD2NEW_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_OLD2NEW_INFO, "");
13709
13710     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_INFO, "");
13711
13712     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_LSA_ACC_CTRL].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ACC_CTRL, "");
13713
13714     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13715 }
13716
13717 /*
13718  *  [2] 3.2.1.9
13719  */
13720 static void
13721 bssmap_ho_reqd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13722 {
13723     guint32     curr_offset;
13724     guint32     consumed;
13725     guint       curr_len;
13726
13727     curr_offset = offset;
13728     curr_len = len;
13729
13730     is_uplink = IS_UPLINK_TRUE;
13731
13732     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13733
13734     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_RESP_REQ].value, BSSAP_PDU_TYPE_BSSMAP, BE_RESP_REQ, "");
13735
13736     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID_LIST, " (Preferred)");
13737
13738     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CCT_POOL_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL_LIST, "");
13739
13740     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CURR_CHAN_1].value, BSSAP_PDU_TYPE_BSSMAP, BE_CURR_CHAN_1, "");
13741
13742     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Used)");
13743
13744     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_QUE_IND].value, BSSAP_PDU_TYPE_BSSMAP, BE_QUE_IND, "");
13745
13746     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_OLD2NEW_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_OLD2NEW_INFO, "");
13747
13748     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13749 }
13750
13751 /*
13752  *  [2] 3.2.1.10
13753  */
13754 static void
13755 bssmap_ho_req_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13756 {
13757     guint32     curr_offset;
13758     guint32     consumed;
13759     guint       curr_len;
13760
13761     curr_offset = offset;
13762     curr_len = len;
13763
13764     is_uplink = IS_UPLINK_TRUE;
13765
13766     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_L3_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_INFO, "");
13767
13768     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_CHAN].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, "");
13769
13770     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, "");
13771
13772     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CCT_POOL].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL, "");
13773
13774     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Chosen)");
13775
13776     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13777
13778     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ID, "");
13779
13780     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13781 }
13782
13783 /*
13784  *  [2] 3.2.1.11
13785  */
13786 static void
13787 bssmap_ho_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13788 {
13789     guint32     curr_offset;
13790     guint32     consumed;
13791     guint       curr_len;
13792
13793     curr_offset = offset;
13794     curr_len = len;
13795
13796     is_uplink = IS_UPLINK_FALSE;
13797
13798     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_L3_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_INFO, "");
13799
13800     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13801
13802     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13803 }
13804
13805 /*
13806  *  [2] 3.2.1.12
13807  */
13808 static void
13809 bssmap_ho_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13810 {
13811     guint32     curr_offset;
13812     guint32     consumed;
13813     guint       curr_len;
13814
13815     curr_offset = offset;
13816     curr_len = len;
13817
13818     is_uplink = IS_UPLINK_TRUE;
13819
13820     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_RR_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_RR_CAUSE, "");
13821
13822     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13823 }
13824
13825 /*
13826  *  [2] 3.2.1.14
13827  */
13828 static void
13829 bssmap_ho_cand_enq(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13830 {
13831     guint32     curr_offset;
13832     guint32     consumed;
13833     guint       curr_len;
13834
13835     curr_offset = offset;
13836     curr_len = len;
13837
13838     is_uplink = IS_UPLINK_FALSE;
13839
13840     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_NUM_MS].value, BSSAP_PDU_TYPE_BSSMAP, BE_NUM_MS, "");
13841
13842     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID_LIST, "");
13843
13844     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13845
13846     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13847 }
13848
13849 /*
13850  *  [2] 3.2.1.15
13851  */
13852 static void
13853 bssmap_ho_cand_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13854 {
13855     guint32     curr_offset;
13856     guint32     consumed;
13857     guint       curr_len;
13858
13859     curr_offset = offset;
13860     curr_len = len;
13861
13862     is_uplink = IS_UPLINK_TRUE;
13863
13864     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_NUM_MS].value, BSSAP_PDU_TYPE_BSSMAP, BE_NUM_MS, "");
13865
13866     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13867
13868     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13869 }
13870
13871 /*
13872  *  [2] 3.2.1.16
13873  */
13874 static void
13875 bssmap_ho_failure(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13876 {
13877     guint32     curr_offset;
13878     guint32     consumed;
13879     guint       curr_len;
13880
13881     curr_offset = offset;
13882     curr_len = len;
13883
13884     is_uplink = IS_UPLINK_TRUE;
13885
13886     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13887
13888     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_RR_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_RR_CAUSE, "");
13889
13890     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CCT_POOL].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL, "");
13891
13892     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CCT_POOL_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL_LIST, "");
13893
13894     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13895 }
13896
13897 /*
13898  *  [2] 3.2.1.19
13899  */
13900 static void
13901 bssmap_paging(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13902 {
13903     guint32     curr_offset;
13904     guint32     consumed;
13905     guint       curr_len;
13906
13907     curr_offset = offset;
13908     curr_len = len;
13909
13910     is_uplink = IS_UPLINK_FALSE;
13911
13912     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_IMSI].value, BSSAP_PDU_TYPE_BSSMAP, BE_IMSI, "");
13913
13914     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_TMSI].value, BSSAP_PDU_TYPE_BSSMAP, BE_TMSI, "");
13915
13916     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID_LIST, "");
13917
13918     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHAN_NEEDED].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHAN_NEEDED, "");
13919
13920     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_EMLPP_PRIO].value, BSSAP_PDU_TYPE_BSSMAP, BE_EMLPP_PRIO, "");
13921
13922     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13923 }
13924
13925 /*
13926  *  [2] 3.2.1.20
13927  */
13928 static void
13929 bssmap_clear_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13930 {
13931     guint32     curr_offset;
13932     guint32     consumed;
13933     guint       curr_len;
13934
13935     curr_offset = offset;
13936     curr_len = len;
13937
13938     is_uplink = IS_UPLINK_TRUE;
13939
13940     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13941
13942     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13943 }
13944
13945 /*
13946  *  [2] 3.2.1.21
13947  */
13948 static void
13949 bssmap_clear_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13950 {
13951     guint32     curr_offset;
13952     guint32     consumed;
13953     guint       curr_len;
13954
13955     curr_offset = offset;
13956     curr_len = len;
13957
13958     is_uplink = IS_UPLINK_FALSE;
13959
13960     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_L3_HEADER_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_HEADER_INFO, "");
13961
13962     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13963
13964     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13965 }
13966
13967 /*
13968  *  [2] 3.2.1.23
13969  */
13970 static void
13971 bssmap_reset(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13972 {
13973     guint32     curr_offset;
13974     guint32     consumed;
13975     guint       curr_len;
13976
13977     curr_offset = offset;
13978     curr_len = len;
13979
13980     is_uplink = IS_UPLINK_UNKNOWN;
13981
13982     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13983
13984     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13985 }
13986
13987 /*
13988  *  [2] 3.2.1.25
13989  */
13990 static void
13991 bssmap_ho_performed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13992 {
13993     guint32     curr_offset;
13994     guint32     consumed;
13995     guint       curr_len;
13996
13997     curr_offset = offset;
13998     curr_len = len;
13999
14000     is_uplink = IS_UPLINK_TRUE;
14001
14002     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14003
14004     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
14005
14006     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_CHAN].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, "");
14007
14008     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, "");
14009
14010     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Chosen)");
14011
14012     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ID, "");
14013
14014     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14015 }
14016
14017 /*
14018  *  [2] 3.2.1.26
14019  */
14020 static void
14021 bssmap_overload(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14022 {
14023     guint32     curr_offset;
14024     guint32     consumed;
14025     guint       curr_len;
14026
14027     curr_offset = offset;
14028     curr_len = len;
14029
14030     is_uplink = IS_UPLINK_TRUE;
14031
14032     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14033
14034     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
14035
14036     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14037 }
14038
14039 /*
14040  *  [2] 3.2.1.29
14041  */
14042 static void
14043 bssmap_cm_upd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14044 {
14045     guint32     curr_offset;
14046     guint32     consumed;
14047     guint       curr_len;
14048
14049     curr_offset = offset;
14050     curr_len = len;
14051
14052     is_uplink = IS_UPLINK_FALSE;
14053
14054     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_2].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_2, "");
14055
14056     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_3].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_3, "");
14057
14058     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14059 }
14060
14061 /*
14062  *  [2] 3.2.1.30
14063  */
14064 static void
14065 bssmap_ciph_mode_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14066 {
14067     guint32     curr_offset;
14068     guint32     consumed;
14069     guint       curr_len;
14070
14071     curr_offset = offset;
14072     curr_len = len;
14073
14074     is_uplink = IS_UPLINK_FALSE;
14075
14076     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_L3_HEADER_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_HEADER_INFO, "");
14077
14078     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_ENC_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_ENC_INFO, "");
14079
14080     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIPH_RESP_MODE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIPH_RESP_MODE, "");
14081
14082     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14083 }
14084
14085 /*
14086  *  [2] 3.2.1.31
14087  */
14088 static void
14089 bssmap_ciph_mode_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14090 {
14091     guint32     curr_offset;
14092     guint32     consumed;
14093     guint       curr_len;
14094
14095     curr_offset = offset;
14096     curr_len = len;
14097
14098     is_uplink = IS_UPLINK_TRUE;
14099
14100     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_L3_MSG].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_MSG, "");
14101
14102     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, "");
14103
14104     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14105 }
14106
14107 /*
14108  * [2] 3.2.1.32
14109  */
14110 static void
14111 bssmap_cl3_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14112 {
14113     guint8      consumed;
14114     guint32     curr_offset;
14115     guint       curr_len;
14116
14117     curr_offset = offset;
14118     curr_len = len;
14119
14120     is_uplink = IS_UPLINK_TRUE;
14121
14122     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
14123
14124     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_L3_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_INFO, "");
14125
14126     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_CHAN].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, "");
14127
14128     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ID_LIST, "");
14129
14130     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_APDU].value, BSSAP_PDU_TYPE_BSSMAP, BE_APDU, "");
14131
14132     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14133 }
14134
14135 /*
14136  * [2] 3.2.1.34
14137  */
14138 static void
14139 bssmap_sapi_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14140 {
14141     guint8      consumed;
14142     guint32     curr_offset;
14143     guint       curr_len;
14144
14145     curr_offset = offset;
14146     curr_len = len;
14147
14148     is_uplink = IS_UPLINK_TRUE;
14149
14150     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_DLCI].value, BSSAP_PDU_TYPE_BSSMAP, BE_DLCI, "");
14151
14152     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14153
14154     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14155 }
14156
14157 /*
14158  *  [2] 3.2.1.37
14159  */
14160 static void
14161 bssmap_ho_reqd_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14162 {
14163     guint32     curr_offset;
14164     guint32     consumed;
14165     guint       curr_len;
14166
14167     curr_offset = offset;
14168     curr_len = len;
14169
14170     is_uplink = IS_UPLINK_FALSE;
14171
14172     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14173
14174     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14175 }
14176
14177 /*
14178  *  [2] 3.2.1.38
14179  */
14180 static void
14181 bssmap_reset_cct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14182 {
14183     guint32     curr_offset;
14184     guint32     consumed;
14185     guint       curr_len;
14186
14187     curr_offset = offset;
14188     curr_len = len;
14189
14190     is_uplink = IS_UPLINK_TRUE;
14191
14192     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14193
14194     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14195
14196     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14197 }
14198
14199 /*
14200  *  [2] 3.2.1.39
14201  */
14202 static void
14203 bssmap_reset_cct_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14204 {
14205     guint32     curr_offset;
14206     guint32     consumed;
14207     guint       curr_len;
14208
14209     curr_offset = offset;
14210     curr_len = len;
14211
14212     is_uplink = IS_UPLINK_TRUE;
14213
14214     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14215
14216     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14217 }
14218
14219 /*
14220  *  [2] 3.2.1.41
14221  */
14222 static void
14223 bssmap_cct_group_block(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14224 {
14225     guint32     curr_offset;
14226     guint32     consumed;
14227     guint       curr_len;
14228
14229     curr_offset = offset;
14230     curr_len = len;
14231
14232     is_uplink = IS_UPLINK_TRUE;
14233
14234     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14235
14236     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14237
14238     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
14239
14240     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14241 }
14242
14243 /*
14244  *  [2] 3.2.1.42
14245  */
14246 static void
14247 bssmap_cct_group_block_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14248 {
14249     guint32     curr_offset;
14250     guint32     consumed;
14251     guint       curr_len;
14252
14253     curr_offset = offset;
14254     curr_len = len;
14255
14256     is_uplink = IS_UPLINK_TRUE;
14257
14258     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14259
14260     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
14261
14262     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14263 }
14264
14265 /*
14266  *  [2] 3.2.1.43
14267  */
14268 static void
14269 bssmap_cct_group_unblock(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14270 {
14271     guint32     curr_offset;
14272     guint32     consumed;
14273     guint       curr_len;
14274
14275     curr_offset = offset;
14276     curr_len = len;
14277
14278     is_uplink = IS_UPLINK_TRUE;
14279
14280     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14281
14282     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
14283
14284     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14285 }
14286
14287 /*
14288  *  [2] 3.2.1.44
14289  */
14290 static void
14291 bssmap_cct_group_unblock_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14292 {
14293     guint32     curr_offset;
14294     guint32     consumed;
14295     guint       curr_len;
14296
14297     curr_offset = offset;
14298     curr_len = len;
14299
14300     is_uplink = IS_UPLINK_TRUE;
14301
14302     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14303
14304     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
14305
14306     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14307 }
14308
14309 /*
14310  *  [2] 3.2.1.45
14311  */
14312 static void
14313 bssmap_confusion(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14314 {
14315     guint32     curr_offset;
14316     guint32     consumed;
14317     guint       curr_len;
14318
14319     curr_offset = offset;
14320     curr_len = len;
14321
14322     is_uplink = IS_UPLINK_TRUE;
14323
14324     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14325
14326     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_DIAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_DIAG, "");
14327
14328     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14329 }
14330
14331 /*
14332  *  [2] 3.2.1.47
14333  */
14334 static void
14335 bssmap_unequipped_cct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14336 {
14337     guint32     curr_offset;
14338     guint32     consumed;
14339     guint       curr_len;
14340
14341     curr_offset = offset;
14342     curr_len = len;
14343
14344     is_uplink = IS_UPLINK_TRUE;
14345
14346     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14347
14348     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
14349
14350     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14351 }
14352
14353 /*
14354  *  [2] 3.2.1.48
14355  */
14356 static void
14357 bssmap_ciph_mode_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14358 {
14359     guint32     curr_offset;
14360     guint32     consumed;
14361     guint       curr_len;
14362
14363     curr_offset = offset;
14364     curr_len = len;
14365
14366     is_uplink = IS_UPLINK_TRUE;
14367
14368     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14369
14370     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14371 }
14372
14373 /*
14374  *  [2] 3.2.1.49
14375  */
14376 static void
14377 bssmap_load_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14378 {
14379     guint32     curr_offset;
14380     guint32     consumed;
14381     guint       curr_len;
14382
14383     curr_offset = offset;
14384     curr_len = len;
14385
14386     is_uplink = IS_UPLINK_TRUE;
14387
14388     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_TIME_IND].value, BSSAP_PDU_TYPE_BSSMAP, BE_TIME_IND, "");
14389
14390     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
14391
14392     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID_LIST, " (Target)");
14393
14394     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_RES_SIT].value, BSSAP_PDU_TYPE_BSSMAP, BE_RES_SIT, "");
14395
14396     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14397
14398     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14399 }
14400
14401 /*
14402  *  [2] 3.2.1.66
14403  */
14404 static void
14405 bssmap_change_cct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14406 {
14407     guint32     curr_offset;
14408     guint32     consumed;
14409     guint       curr_len;
14410
14411     curr_offset = offset;
14412     curr_len = len;
14413
14414     is_uplink = IS_UPLINK_FALSE;
14415
14416     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14417
14418     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14419 }
14420
14421 /*
14422  *  [2] 3.2.1.67
14423  */
14424 static void
14425 bssmap_change_cct_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14426 {
14427     guint32     curr_offset;
14428     guint32     consumed;
14429     guint       curr_len;
14430
14431     curr_offset = offset;
14432     curr_len = len;
14433
14434     is_uplink = IS_UPLINK_TRUE;
14435
14436     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14437
14438     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14439 }
14440
14441 /*
14442  *  [2] 3.2.1.68
14443  */
14444 static void
14445 bssmap_common_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14446 {
14447     guint32     curr_offset;
14448     guint32     consumed;
14449     guint       curr_len;
14450
14451     curr_offset = offset;
14452     curr_len = len;
14453
14454     is_uplink = IS_UPLINK_FALSE;
14455
14456     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_IMSI].value, BSSAP_PDU_TYPE_BSSMAP, BE_IMSI, "");
14457
14458     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14459 }
14460
14461 /*
14462  *  [2] 3.2.1.69
14463  */
14464 static void
14465 bssmap_lsa_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14466 {
14467     guint32     curr_offset;
14468     guint32     consumed;
14469     guint       curr_len;
14470
14471     curr_offset = offset;
14472     curr_len = len;
14473
14474     is_uplink = IS_UPLINK_FALSE;
14475
14476     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_LSA_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_INFO, "");
14477
14478     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14479 }
14480
14481 /*
14482  *  [2] 3.2.1.70
14483  */
14484 static void
14485 bssmap_conn_oriented(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14486 {
14487     guint32     curr_offset;
14488     guint32     consumed;
14489     guint       curr_len;
14490
14491     curr_offset = offset;
14492     curr_len = len;
14493
14494     is_uplink = IS_UPLINK_FALSE;
14495
14496     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_APDU].value, BSSAP_PDU_TYPE_BSSMAP, BE_APDU, "");
14497
14498     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_SEG].value, BSSAP_PDU_TYPE_BSSMAP, BE_SEG, "");
14499
14500     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14501 }
14502
14503
14504 #define NUM_GSM_BSSMAP_MSG (sizeof(gsm_a_bssmap_msg_strings)/sizeof(value_string))
14505 static gint ett_gsm_bssmap_msg[NUM_GSM_BSSMAP_MSG];
14506 static void (*bssmap_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
14507     bssmap_ass_req,     /* Assignment Request */
14508     bssmap_ass_complete,        /* Assignment Complete */
14509     bssmap_ass_failure, /* Assignment Failure */
14510     bssmap_ho_req,      /* Handover Request */
14511     bssmap_ho_reqd,     /* Handover Required */
14512     bssmap_ho_req_ack,  /* Handover Request Acknowledge */
14513     bssmap_ho_cmd,      /* Handover Command */
14514     bssmap_ho_complete, /* Handover Complete */
14515     NULL /* no associated data */,      /* Handover Succeeded */
14516     bssmap_ho_failure,  /* Handover Failure */
14517     bssmap_ho_performed,        /* Handover Performed */
14518     bssmap_ho_cand_enq, /* Handover Candidate Enquire */
14519     bssmap_ho_cand_resp,        /* Handover Candidate Response */
14520     bssmap_ho_reqd_rej, /* Handover Required Reject */
14521     NULL /* no associated data */,      /* Handover Detect */
14522     bssmap_clear_cmd,   /* Clear Command */
14523     NULL /* no associated data */,      /* Clear Complete */
14524     bssmap_clear_req,   /* Clear Request */
14525     NULL,       /* Reserved */
14526     NULL,       /* Reserved */
14527     bssmap_sapi_rej,    /* SAPI 'n' Reject */
14528     bssmap_confusion,   /* Confusion */
14529     NULL,       /* Suspend */
14530     NULL,       /* Resume */
14531     bssmap_conn_oriented,       /* Connection Oriented Information */
14532     NULL,       /* Perform Location Request */
14533     bssmap_lsa_info,    /* LSA Information */
14534     NULL,       /* Perform Location Response */
14535     NULL,       /* Perform Location Abort */
14536     bssmap_common_id,   /* Common Id */
14537     bssmap_reset,       /* Reset */
14538     NULL /* no associated data */,      /* Reset Acknowledge */
14539     bssmap_overload,    /* Overload */
14540     NULL,       /* Reserved */
14541     bssmap_reset_cct,   /* Reset Circuit */
14542     bssmap_reset_cct_ack,       /* Reset Circuit Acknowledge */
14543     NULL,       /* MSC Invoke Trace */
14544     NULL,       /* BSS Invoke Trace */
14545     NULL,       /* Connectionless Information */
14546     bssmap_block,       /* Block */
14547     bssmap_block_ack,   /* Blocking Acknowledge */
14548     bssmap_unblock,     /* Unblock */
14549     bssmap_unblock_ack, /* Unblocking Acknowledge */
14550     bssmap_cct_group_block,     /* Circuit Group Block */
14551     bssmap_cct_group_block_ack, /* Circuit Group Blocking Acknowledge */
14552     bssmap_cct_group_unblock,   /* Circuit Group Unblock */
14553     bssmap_cct_group_unblock_ack,       /* Circuit Group Unblocking Acknowledge */
14554     bssmap_unequipped_cct,      /* Unequipped Circuit */
14555     bssmap_change_cct,  /* Change Circuit */
14556     bssmap_change_cct_ack,      /* Change Circuit Acknowledge */
14557     NULL,       /* Resource Request */
14558     NULL,       /* Resource Indication */
14559     bssmap_paging,      /* Paging */
14560     bssmap_ciph_mode_cmd,       /* Cipher Mode Command */
14561     bssmap_cm_upd,      /* Classmark Update */
14562     bssmap_ciph_mode_complete,  /* Cipher Mode Complete */
14563     NULL /* no associated data */,      /* Queuing Indication */
14564     bssmap_cl3_info,    /* Complete Layer 3 Information */
14565     NULL /* no associated data */,      /* Classmark Request */
14566     bssmap_ciph_mode_rej,       /* Cipher Mode Reject */
14567     bssmap_load_ind,    /* Load Indication */
14568     NULL,       /* VGCS/VBS Setup */
14569     NULL,       /* VGCS/VBS Setup Ack */
14570     NULL,       /* VGCS/VBS Setup Refuse */
14571     NULL,       /* VGCS/VBS Assignment Request */
14572     NULL,       /* VGCS/VBS Assignment Result */
14573     NULL,       /* VGCS/VBS Assignment Failure */
14574     NULL,       /* VGCS/VBS Queuing Indication */
14575     NULL,       /* Uplink Request */
14576     NULL,       /* Uplink Request Acknowledge */
14577     NULL,       /* Uplink Request Confirmation */
14578     NULL,       /* Uplink Release Indication */
14579     NULL,       /* Uplink Reject Command */
14580     NULL,       /* Uplink Release Command */
14581     NULL,       /* Uplink Seized Command */
14582     NULL,       /* NONE */
14583 };
14584
14585 /*
14586  * [4] 9.2.2
14587  */
14588 static void
14589 dtap_mm_auth_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14590 {
14591     guint32     curr_offset;
14592     guint32     consumed;
14593     guint       curr_len;
14594     guint8      oct;
14595     proto_tree  *subtree;
14596     proto_item  *item;
14597
14598     curr_offset = offset;
14599     curr_len = len;
14600
14601     is_uplink = IS_UPLINK_FALSE;
14602
14603     /*
14604      * special dissection for Cipher Key Sequence Number
14605      */
14606     oct = tvb_get_guint8(tvb, curr_offset);
14607
14608     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
14609     proto_tree_add_text(tree,
14610         tvb, curr_offset, 1,
14611         "%s :  Spare",
14612         a_bigbuf);
14613
14614     item =
14615         proto_tree_add_text(tree,
14616             tvb, curr_offset, 1,
14617             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
14618
14619     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
14620
14621     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
14622     proto_tree_add_text(subtree,
14623         tvb, curr_offset, 1,
14624         "%s :  Spare",
14625         a_bigbuf);
14626
14627     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
14628
14629     switch (oct & 0x07)
14630     {
14631     case 0x07:
14632         proto_tree_add_text(subtree,
14633             tvb, curr_offset, 1,
14634             "%s :  Ciphering Key Sequence Number: No key is available",
14635             a_bigbuf);
14636         break;
14637
14638     default:
14639         proto_tree_add_text(subtree,
14640             tvb, curr_offset, 1,
14641             "%s :  Ciphering Key Sequence Number: %u",
14642             a_bigbuf,
14643             oct & 0x07);
14644         break;
14645     }
14646
14647     curr_offset++;
14648     curr_len--;
14649
14650     if (curr_len <= 0) return;
14651
14652     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_AUTH_PARAM_RAND);
14653
14654     ELEM_OPT_TLV(0x20, BSSAP_PDU_TYPE_DTAP, DE_AUTH_PARAM_AUTN, "");
14655
14656     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14657 }
14658
14659 /*
14660  * [4] 9.2.3
14661  */
14662 static void
14663 dtap_mm_auth_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14664 {
14665     guint32     curr_offset;
14666     guint32     consumed;
14667     guint       curr_len;
14668
14669     curr_offset = offset;
14670     curr_len = len;
14671
14672     is_uplink = IS_UPLINK_TRUE;
14673
14674     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM);
14675
14676     ELEM_OPT_TLV(0x21, BSSAP_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM_EXT, "");
14677
14678     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14679 }
14680
14681 /*
14682  * [4] 9.2.3a
14683  */
14684 static void
14685 dtap_mm_auth_fail(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14686 {
14687     guint32     curr_offset;
14688     guint32     consumed;
14689     guint       curr_len;
14690
14691     curr_offset = offset;
14692     curr_len = len;
14693
14694     is_uplink = IS_UPLINK_TRUE;
14695
14696     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
14697
14698     ELEM_OPT_TLV(0x22, BSSAP_PDU_TYPE_DTAP, DE_AUTH_FAIL_PARAM, "");
14699
14700     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14701 }
14702
14703 /*
14704  * [3] 9.2.4
14705  */
14706 static void
14707 dtap_mm_cm_reestab_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14708 {
14709     guint32     curr_offset;
14710     guint32     consumed;
14711     guint       curr_len;
14712     guint8      oct;
14713     proto_tree  *subtree;
14714     proto_item  *item;
14715
14716     curr_offset = offset;
14717     curr_len = len;
14718
14719     is_uplink = IS_UPLINK_TRUE;
14720
14721     /*
14722      * special dissection for Cipher Key Sequence Number
14723      */
14724     oct = tvb_get_guint8(tvb, curr_offset);
14725
14726     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
14727     proto_tree_add_text(tree,
14728         tvb, curr_offset, 1,
14729         "%s :  Spare",
14730         a_bigbuf);
14731
14732     item =
14733         proto_tree_add_text(tree,
14734             tvb, curr_offset, 1,
14735             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
14736
14737     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
14738
14739     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
14740     proto_tree_add_text(subtree,
14741         tvb, curr_offset, 1,
14742         "%s :  Spare",
14743         a_bigbuf);
14744
14745     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
14746
14747     switch (oct & 0x07)
14748     {
14749     case 0x07:
14750         proto_tree_add_text(subtree,
14751             tvb, curr_offset, 1,
14752             "%s :  Ciphering Key Sequence Number: No key is available",
14753             a_bigbuf);
14754         break;
14755
14756     default:
14757         proto_tree_add_text(subtree,
14758             tvb, curr_offset, 1,
14759             "%s :  Ciphering Key Sequence Number: %u",
14760             a_bigbuf,
14761             oct & 0x07);
14762         break;
14763     }
14764
14765     curr_offset++;
14766     curr_len--;
14767
14768     if (curr_len <= 0) return;
14769
14770     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_2, "");
14771
14772     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14773
14774     ELEM_OPT_TV(0x13, BSSAP_PDU_TYPE_DTAP, DE_LAI, "");
14775
14776     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14777 }
14778
14779 /*
14780  * [3] 9.2.5a
14781  */
14782 static void
14783 dtap_mm_cm_srvc_prompt(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14784 {
14785     guint32     curr_offset;
14786     guint32     consumed;
14787     guint       curr_len;
14788
14789     curr_offset = offset;
14790     curr_len = len;
14791
14792     is_uplink = IS_UPLINK_FALSE;
14793
14794     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_PD_SAPI);
14795
14796     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14797 }
14798
14799 /*
14800  * [4] 9.2.6
14801  */
14802 static void
14803 dtap_mm_cm_srvc_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14804 {
14805     guint32     curr_offset;
14806     guint32     consumed;
14807     guint       curr_len;
14808
14809     curr_offset = offset;
14810     curr_len = len;
14811
14812     is_uplink = IS_UPLINK_FALSE;
14813
14814     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
14815
14816     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14817 }
14818
14819 /*
14820  * [4] 9.2.8
14821  */
14822 static void
14823 dtap_mm_abort(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14824 {
14825     guint32     curr_offset;
14826     guint32     consumed;
14827     guint       curr_len;
14828
14829     curr_offset = offset;
14830     curr_len = len;
14831
14832     is_uplink = IS_UPLINK_FALSE;
14833
14834     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
14835
14836     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14837 }
14838
14839 /*
14840  * [3] 9.2.9
14841  */
14842 static void
14843 dtap_mm_cm_srvc_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14844 {
14845     guint32     curr_offset;
14846     guint32     consumed;
14847     guint       curr_len;
14848     guint8      oct;
14849     proto_tree  *subtree;
14850     proto_item  *item;
14851     const gchar *str;
14852
14853     curr_offset = offset;
14854     curr_len = len;
14855
14856     is_uplink = IS_UPLINK_TRUE;
14857
14858     /*
14859      * special dissection for CM Service Type
14860      */
14861     oct = tvb_get_guint8(tvb, curr_offset);
14862
14863     item =
14864         proto_tree_add_text(tree,
14865             tvb, curr_offset, 1,
14866             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
14867
14868     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
14869
14870     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
14871     proto_tree_add_text(subtree,
14872         tvb, curr_offset, 1,
14873         "%s :  Spare",
14874         a_bigbuf);
14875
14876     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
14877
14878     switch ((oct & 0x70) >> 4)
14879     {
14880     case 0x07:
14881         proto_tree_add_text(subtree,
14882             tvb, curr_offset, 1,
14883             "%s :  Ciphering Key Sequence Number: No key is available",
14884             a_bigbuf);
14885         break;
14886
14887     default:
14888         proto_tree_add_text(subtree,
14889             tvb, curr_offset, 1,
14890             "%s :  Ciphering Key Sequence Number: %u",
14891             a_bigbuf,
14892             (oct & 0x70) >> 4);
14893         break;
14894     }
14895
14896     item =
14897         proto_tree_add_text(tree,
14898             tvb, curr_offset, 1,
14899             gsm_dtap_elem_strings[DE_CM_SRVC_TYPE].strptr);
14900
14901     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CM_SRVC_TYPE]);
14902
14903     switch (oct & 0x0f)
14904     {
14905     case 0x01: str = "Mobile originating call establishment or packet mode connection establishment"; break;
14906     case 0x02: str = "Emergency call establishment"; break;
14907     case 0x04: str = "Short message service"; break;
14908     case 0x08: str = "Supplementary service activation"; break;
14909     case 0x09: str = "Voice group call establishment"; break;
14910     case 0x0a: str = "Voice broadcast call establishment"; break;
14911     case 0x0b: str = "Location Services"; break;
14912     default:
14913         str = "Reserved";
14914         break;
14915     }
14916
14917     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
14918     proto_tree_add_text(subtree,
14919         tvb, curr_offset, 1,
14920         "%s :  Service Type: (%u) %s",
14921         a_bigbuf,
14922         oct & 0x0f,
14923         str);
14924
14925     curr_offset++;
14926     curr_len--;
14927
14928     if (curr_len <= 0) return;
14929
14930     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_2, "");
14931
14932     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14933
14934     ELEM_OPT_TV_SHORT(0x80, BSSAP_PDU_TYPE_DTAP, DE_PRIO, "");
14935
14936     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14937 }
14938
14939 /*
14940  * [3] 9.2.10
14941  */
14942 static void
14943 dtap_mm_id_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14944 {
14945     guint8      oct;
14946     guint32     curr_offset;
14947     guint       curr_len;
14948     proto_tree  *subtree;
14949     proto_item  *item;
14950     const gchar *str;
14951
14952     curr_offset = offset;
14953     curr_len = len;
14954
14955     is_uplink = IS_UPLINK_FALSE;
14956
14957     /*
14958      * special dissection for Identity Type
14959      */
14960     oct = tvb_get_guint8(tvb, curr_offset);
14961
14962     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
14963     proto_tree_add_text(tree,
14964         tvb, curr_offset, 1,
14965         "%s :  Spare",
14966         a_bigbuf);
14967
14968     item =
14969         proto_tree_add_text(tree,
14970             tvb, curr_offset, 1,
14971             gsm_dtap_elem_strings[DE_ID_TYPE].strptr);
14972
14973     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_ID_TYPE]);
14974
14975     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
14976     proto_tree_add_text(subtree,
14977         tvb, curr_offset, 1,
14978         "%s :  Spare",
14979         a_bigbuf);
14980
14981     switch (oct & 0x07)
14982     {
14983     case 1: str = "IMSI"; break;
14984     case 2: str = "IMEI"; break;
14985     case 3: str = "IMEISV"; break;
14986     case 4: str = "TMSI"; break;
14987     default:
14988         str = "Reserved";
14989         break;
14990     }
14991
14992     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
14993     proto_tree_add_text(subtree,
14994         tvb, curr_offset, 1,
14995         "%s :  Type of identity: %s",
14996         a_bigbuf,
14997         str);
14998
14999     curr_offset++;
15000     curr_len--;
15001
15002     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15003 }
15004
15005 /*
15006  * [3] 9.2.11
15007  */
15008 static void
15009 dtap_mm_id_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15010 {
15011     guint32     curr_offset;
15012     guint32     consumed;
15013     guint       curr_len;
15014
15015     curr_offset = offset;
15016     curr_len = len;
15017
15018     is_uplink = IS_UPLINK_TRUE;
15019
15020     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
15021
15022     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15023 }
15024
15025 /*
15026  * [3] 9.2.12
15027  */
15028 static void
15029 dtap_mm_imsi_det_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15030 {
15031     guint32     curr_offset;
15032     guint32     consumed;
15033     guint       curr_len;
15034
15035     curr_offset = offset;
15036     curr_len = len;
15037
15038     is_uplink = IS_UPLINK_TRUE;
15039
15040     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_1);
15041
15042     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
15043
15044     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15045 }
15046
15047 /*
15048  * [3] 9.2.13
15049  */
15050 static void
15051 dtap_mm_loc_upd_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15052 {
15053     guint32     curr_offset;
15054     guint32     consumed;
15055     guint       curr_len;
15056
15057     curr_offset = offset;
15058     curr_len = len;
15059
15060     is_uplink = IS_UPLINK_FALSE;
15061
15062     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LAI);
15063
15064     ELEM_OPT_TLV(0x17, BSSAP_PDU_TYPE_DTAP, DE_MID, "");
15065
15066     ELEM_OPT_T(0xa1, BSSAP_PDU_TYPE_DTAP, DE_FOP, "");
15067
15068     ELEM_OPT_T(0xa2, BSSAP_PDU_TYPE_DTAP, DE_CTS_PERM, "");
15069
15070     ELEM_OPT_TLV(0x4a, BSSAP_PDU_TYPE_DTAP, DE_PLMN_LIST, " Equivalent");
15071
15072     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15073 }
15074
15075 /*
15076  * [3] 9.2.14
15077  */
15078 static void
15079 dtap_mm_loc_upd_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15080 {
15081     guint32     curr_offset;
15082     guint32     consumed;
15083     guint       curr_len;
15084
15085     curr_offset = offset;
15086     curr_len = len;
15087
15088     is_uplink = IS_UPLINK_FALSE;
15089
15090     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
15091
15092     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15093 }
15094
15095 /*
15096  * [3] 9.2.15
15097  */
15098 static void
15099 dtap_mm_loc_upd_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15100 {
15101     guint32     curr_offset;
15102     guint32     consumed;
15103     guint       curr_len;
15104     guint8      oct;
15105     proto_tree  *subtree;
15106     proto_item  *item;
15107     const gchar *str;
15108
15109     curr_offset = offset;
15110     curr_len = len;
15111
15112     is_uplink = IS_UPLINK_TRUE;
15113
15114     /*
15115      * special dissection for Location Updating Type
15116      */
15117     oct = tvb_get_guint8(tvb, curr_offset);
15118
15119     item =
15120         proto_tree_add_text(tree,
15121             tvb, curr_offset, 1,
15122             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
15123
15124     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
15125
15126     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
15127     proto_tree_add_text(subtree,
15128         tvb, curr_offset, 1,
15129         "%s :  Spare",
15130         a_bigbuf);
15131
15132     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
15133
15134     switch ((oct & 0x70) >> 4)
15135     {
15136     case 0x07:
15137         proto_tree_add_text(subtree,
15138             tvb, curr_offset, 1,
15139             "%s :  Ciphering Key Sequence Number: No key is available",
15140             a_bigbuf);
15141         break;
15142
15143     default:
15144         proto_tree_add_text(subtree,
15145             tvb, curr_offset, 1,
15146             "%s :  Ciphering Key Sequence Number: %u",
15147             a_bigbuf,
15148             (oct & 0x70) >> 4);
15149         break;
15150     }
15151
15152     item =
15153         proto_tree_add_text(tree,
15154             tvb, curr_offset, 1,
15155             gsm_dtap_elem_strings[DE_LOC_UPD_TYPE].strptr);
15156
15157     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_LOC_UPD_TYPE]);
15158
15159     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
15160     proto_tree_add_text(subtree,
15161         tvb, curr_offset, 1,
15162         "%s :  Follow-On Request (FOR): %s",
15163         a_bigbuf,
15164         (oct & 0x08) ? "Follow-on request pending" : "No follow-on request pending");
15165
15166     other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
15167     proto_tree_add_text(subtree,
15168         tvb, curr_offset, 1,
15169         "%s :  Spare",
15170         a_bigbuf);
15171
15172     switch (oct & 0x03)
15173     {
15174     case 0: str = "Normal"; break;
15175     case 1: str = "Periodic"; break;
15176     case 2: str = "IMSI attach"; break;
15177     default:
15178         str = "Reserved";
15179         break;
15180     }
15181
15182     other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
15183     proto_tree_add_text(subtree,
15184         tvb, curr_offset, 1,
15185         "%s :  Updating Type: %s",
15186         a_bigbuf,
15187         str);
15188
15189     proto_item_append_text(item, " - %s", str);
15190
15191     curr_offset++;
15192     curr_len--;
15193
15194     if (curr_len <= 0) return;
15195
15196     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LAI);
15197
15198     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_1);
15199
15200     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
15201
15202     ELEM_OPT_TLV(0x33, BSSAP_PDU_TYPE_DTAP, DE_MS_CM_2, "");
15203
15204     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15205 }
15206
15207 /*
15208  * [4] 9.1.15a
15209  */
15210 void
15211 dtap_mm_mm_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15212 {
15213     guint32     curr_offset;
15214     guint32     consumed;
15215     guint       curr_len;
15216
15217     curr_offset = offset;
15218     curr_len = len;
15219
15220     is_uplink = IS_UPLINK_TRUE;
15221
15222     ELEM_OPT_TLV(0x43, BSSAP_PDU_TYPE_DTAP, DE_NETWORK_NAME, " - Full Name");
15223
15224     ELEM_OPT_TLV(0x45, BSSAP_PDU_TYPE_DTAP, DE_NETWORK_NAME, " - Short Name");
15225
15226     ELEM_OPT_TV(0x46, BSSAP_PDU_TYPE_DTAP, DE_TIME_ZONE, " - Local");
15227
15228     ELEM_OPT_TV(0x47, BSSAP_PDU_TYPE_DTAP, DE_TIME_ZONE_TIME, " - Universal Time and Local Time Zone");
15229
15230     ELEM_OPT_TLV(0x48, BSSAP_PDU_TYPE_DTAP, DE_LSA_ID, "");
15231
15232     ELEM_OPT_TLV(0x49, BSSAP_PDU_TYPE_DTAP, DE_DAY_SAVING_TIME, "");
15233
15234     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15235 }
15236
15237 /*
15238  * [4] 9.1.16
15239  */
15240 static void
15241 dtap_mm_mm_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15242 {
15243     guint32     curr_offset;
15244     guint32     consumed;
15245     guint       curr_len;
15246
15247     curr_offset = offset;
15248     curr_len = len;
15249
15250     is_uplink = IS_UPLINK_TRUE;
15251
15252     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
15253
15254     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15255 }
15256
15257 /*
15258  * [3] 9.2.17
15259  */
15260 static void
15261 dtap_mm_tmsi_realloc_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15262 {
15263     guint32     curr_offset;
15264     guint32     consumed;
15265     guint       curr_len;
15266
15267     curr_offset = offset;
15268     curr_len = len;
15269
15270     is_uplink = IS_UPLINK_FALSE;
15271
15272     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LAI);
15273
15274     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
15275
15276     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15277 }
15278 /* 3GPP TS 24.008 version 4.7.0 Release 4
15279  * [3] 9.1.15
15280  */
15281 void
15282 dtap_rr_ho_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15283 {
15284     guint32     curr_offset;
15285     guint32     consumed;
15286     guint       curr_len;
15287     curr_offset = offset;
15288     curr_len = len;
15289
15290         /* Mandatory Elemets
15291          * Cell description 10.5.2.2 
15292          */
15293         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_CELL_DSC);
15294
15295         /* Description of the first channel,after time
15296          * Channel Description 2 10.5.2.5a
15297          */
15298         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_CH_DSC2);
15299
15300         /* Handover Reference 10.5.2.15 */
15301         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_HO_REF);
15302
15303         /* Power Command and Access type 10.5.2.28a */
15304         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_POW_CMD_AND_ACC_TYPE);
15305
15306         /* optional elements */
15307
15308         /* Synchronization Indication 10.5.2.39 */
15309         ELEM_OPT_TV_SHORT(0xD0,BSSAP_PDU_TYPE_DTAP, DE_RR_SYNC_IND,"");
15310
15311         /* Frequency Short List 10.5.2.14 */
15312         ELEM_OPT_TV(0x02,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_SHORT_LIST," - Frequency Short List, after time");
15313
15314         /* Frequency List 10.5.2.13 */
15315         ELEM_OPT_TLV(0x05, BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_LIST, " - Frequency List, after time");
15316
15317         /* Cell Channel Description 10.5.2.1b */
15318         ELEM_OPT_TV(0x62,BSSAP_PDU_TYPE_DTAP, DE_RR_CELL_CH_DSC, "");
15319
15320         /* Multislot Allocation 10.5.2.21b */
15321         ELEM_OPT_TLV(0x10,BSSAP_PDU_TYPE_DTAP, DE_RR_MULT_ALL, "");
15322
15323         /* Mode of the First Channel(Channel Set 1)) Channel Mode 10.5.2.6*/
15324         ELEM_OPT_TV(0x63,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of the First Channel(Channel Set 1))");
15325
15326         /* Mode of Channel Set 2 Channel Mode 10.5.2.6*/
15327         ELEM_OPT_TV(0x11,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 2");
15328
15329         /* Mode of Channel Set 3 Channel Mode 10.5.2.6*/        
15330         ELEM_OPT_TV(0x13,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 3");
15331
15332         /* Mode of Channel Set 4 Channel Mode 10.5.2.6*/
15333         ELEM_OPT_TV(0x14,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 4");
15334
15335         /* Mode of Channel Set 5 Channel Mode 10.5.2.6*/
15336         ELEM_OPT_TV(0x15,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 5");
15337
15338         /* Mode of Channel Set 6 Channel Mode 10.5.2.6*/
15339         ELEM_OPT_TV(0x16,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 6");
15340
15341         /* Mode of Channel Set 7 Channel Mode 10.5.2.6*/
15342         ELEM_OPT_TV(0x17,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 7");
15343
15344         /* Mode of Channel Set 8 Channel Mode 10.5.2.6*/
15345         ELEM_OPT_TV(0x18,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 8");
15346
15347         /* Description of the Second Channel, after time, Channel Description 10.5.2.5 */
15348         ELEM_OPT_TV(0x64,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_DSC, " - Description of the Second Channel, after time");
15349
15350         /* Mode of the Second Channel, Channel Mode 2 10.5.2.7 */
15351         ELEM_OPT_TV(0x66,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE2, " - Mode of the Second Channel");
15352
15353         /* Frequency Channel Sequence, after time, Frequency Channel Sequence 10.5.2.12 */
15354         ELEM_OPT_TV(0x69,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_CH_SEQ, " - Frequency Channel Sequence, after time");
15355
15356         /* Mobile Allocation, after time, Mobile Allocation 10.5.2.21 */
15357         ELEM_OPT_TLV(0x72,BSSAP_PDU_TYPE_DTAP, DE_RR_MOB_ALL, " - Mobile Allocation, after time");
15358         
15359         /* Starting Time 10.5.2.38 */
15360         ELEM_OPT_TV(0x7C,BSSAP_PDU_TYPE_DTAP, DE_RR_STARTING_TIME, "");
15361
15362         /* Real Time Difference, Time Difference 10.5.2.41 */
15363         ELEM_OPT_TV(0x7B,BSSAP_PDU_TYPE_DTAP, DE_RR_TIME_DIFF, " - Real Time Difference");
15364
15365         /* Timing Advance, Timing Advance 10.5.2.40 */
15366         ELEM_OPT_TV(0x7D,BSSAP_PDU_TYPE_DTAP, DE_RR_TIMING_ADV, "");
15367
15368         /* Frequency Short List, before time, Frequency Short List 10.5.2.14 */
15369         ELEM_OPT_TLV(0x19,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_SHORT_LIST, " - Frequency Short List, before time");
15370
15371         /* Frequency List, before time, Frequency List 10.5.2.13 */
15372         ELEM_OPT_TV(0x12,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_LIST, " - Frequency List, before time");
15373
15374         /* Description of the First Channel, before time,       Channel Description 2 10.5.2.5a*/
15375         ELEM_OPT_TV(0x1c,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_DSC2, " - Description of the First Channel, before time");
15376
15377         /* Description of the Second Channel, before time,      Channel Description 10.5.2.5*/
15378         ELEM_OPT_TV(0x1d,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_DSC, " - Description of the Second Channel, before time");
15379
15380         /* Frequency channel sequence before time,      Frequency channel sequence 10.5.2.12*/
15381         ELEM_OPT_TV(0x1e,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_CH_SEQ, " - Frequency channel sequence before time");
15382
15383         /* Mobile Allocation, before time,      Mobile Allocation 10.5.2.21*/
15384         ELEM_OPT_TLV(0x21,BSSAP_PDU_TYPE_DTAP, DE_RR_MOB_ALL, " - Mobile Allocation, before time");
15385
15386         /* Cipher Mode Setting, Cipher Mode Setting 10.5.2.9*/
15387         ELEM_OPT_TV_SHORT(0x90,BSSAP_PDU_TYPE_DTAP, DE_RR_CIP_MODE_SET, "");
15388
15389         /* VGCS target mode Indication, VGCS target mode Indication 10.5.2.42a*/
15390         ELEM_OPT_TLV(0x01,BSSAP_PDU_TYPE_DTAP, DE_RR_VGCS_TAR_MODE_IND, "");
15391
15392         /* Multi-Rate configuration,    MultiRate configuration 10.5.2.21aa*/
15393         ELEM_OPT_TLV(0x03,BSSAP_PDU_TYPE_DTAP, DE_RR_MULTIRATE_CONF, "");
15394
15395         /* Dynamic ARFCN Mapping,       Dynamic ARFCN Mapping 10.5.2.11b*/
15396         ELEM_OPT_TLV(0x76,BSSAP_PDU_TYPE_DTAP, DE_RR_DYN_ARFCN_MAP, "");
15397
15398         /* VGCS Ciphering Parameters,   VGCS Ciphering Parameters 10.5.2.42b*/
15399         ELEM_OPT_TLV(0x04,BSSAP_PDU_TYPE_DTAP, DE_RR_VGCS_CIP_PAR, "");
15400
15401         /* Dedicated Service Information,       Dedicated Service Information 10.5.2.59*/
15402         ELEM_OPT_TV(0x51,BSSAP_PDU_TYPE_DTAP, DE_RR_DED_SERV_INF, "");
15403
15404         EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
15405
15406 }
15407 /*
15408  * [4] 9.1.25
15409  */
15410 static void
15411 dtap_rr_paging_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15412 {
15413     guint32     curr_offset;
15414     guint32     consumed;
15415     guint       curr_len;
15416     guint8      oct;
15417     proto_tree  *subtree;
15418     proto_item  *item;
15419
15420     curr_offset = offset;
15421     curr_len = len;
15422
15423     is_uplink = IS_UPLINK_TRUE;
15424
15425     /*
15426      * special dissection for Cipher Key Sequence Number
15427      */
15428     oct = tvb_get_guint8(tvb, curr_offset);
15429
15430     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
15431     proto_tree_add_text(tree,
15432         tvb, curr_offset, 1,
15433         "%s :  Spare",
15434         a_bigbuf);
15435
15436     item =
15437         proto_tree_add_text(tree,
15438             tvb, curr_offset, 1,
15439             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
15440
15441     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
15442
15443     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
15444     proto_tree_add_text(subtree,
15445         tvb, curr_offset, 1,
15446         "%s :  Spare",
15447         a_bigbuf);
15448
15449     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
15450
15451     switch (oct & 0x07)
15452     {
15453     case 0x07:
15454         proto_tree_add_text(subtree,
15455             tvb, curr_offset, 1,
15456             "%s :  Ciphering Key Sequence Number: No key is available",
15457             a_bigbuf);
15458         break;
15459
15460     default:
15461         proto_tree_add_text(subtree,
15462             tvb, curr_offset, 1,
15463             "%s :  Ciphering Key Sequence Number: %u",
15464             a_bigbuf,
15465             oct & 0x07);
15466         break;
15467     }
15468
15469     curr_offset++;
15470     curr_len--;
15471
15472     if (curr_len <= 0) return;
15473
15474     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_2, "");
15475
15476     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
15477
15478     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15479 }
15480
15481 /*
15482  * [4] 9.1.29
15483  */
15484 static void
15485 dtap_rr_rr_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15486 {
15487     guint32     curr_offset;
15488     guint32     consumed;
15489     guint       curr_len;
15490
15491     curr_offset = offset;
15492     curr_len = len;
15493
15494     is_uplink = IS_UPLINK_TRUE;
15495
15496     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_CAUSE);
15497
15498     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15499 }
15500
15501 /*
15502  * [4] 9.3.1
15503  */
15504 static void
15505 dtap_cc_alerting(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15506 {
15507     guint32     curr_offset;
15508     guint32     consumed;
15509     guint       curr_len;
15510
15511     curr_offset = offset;
15512     curr_len = len;
15513
15514     is_uplink = IS_UPLINK_TRUE;
15515
15516     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15517
15518     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15519
15520     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15521
15522     /* uplink only */
15523
15524     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15525
15526     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15527 }
15528
15529 /*
15530  * [4] 9.3.2
15531  */
15532 static void
15533 dtap_cc_call_conf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15534 {
15535     guint32     curr_offset;
15536     guint32     consumed;
15537     guint       curr_len;
15538
15539     curr_offset = offset;
15540     curr_len = len;
15541
15542     is_uplink = IS_UPLINK_TRUE;
15543
15544     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
15545
15546     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
15547
15548     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
15549
15550     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15551
15552     ELEM_OPT_TLV(0x15, BSSAP_PDU_TYPE_DTAP, DE_CC_CAP, "");
15553
15554     ELEM_OPT_TLV(0x2d, BSSAP_PDU_TYPE_DTAP, DE_SI, "");
15555
15556     ELEM_OPT_TLV(0x40, BSSAP_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, "");
15557
15558     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15559 }
15560
15561 /*
15562  * [4] 9.3.3
15563  */
15564 static void
15565 dtap_cc_call_proceed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15566 {
15567     guint32     curr_offset;
15568     guint32     consumed;
15569     guint       curr_len;
15570
15571     curr_offset = offset;
15572     curr_len = len;
15573
15574     is_uplink = IS_UPLINK_FALSE;
15575
15576     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
15577
15578     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
15579
15580     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
15581
15582     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15583
15584     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15585
15586     ELEM_OPT_TV_SHORT(0x80, BSSAP_PDU_TYPE_DTAP, DE_PRIO, "");
15587
15588     ELEM_OPT_TLV(0x2f, BSSAP_PDU_TYPE_DTAP, DE_NET_CC_CAP, "");
15589
15590     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15591 }
15592
15593 /*
15594  * [4] 9.3.4
15595  */
15596 static void
15597 dtap_cc_congestion_control(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15598 {
15599     guint32     curr_offset;
15600     guint32     consumed;
15601     guint       curr_len;
15602     guint8      oct;
15603     proto_tree  *subtree;
15604     proto_item  *item;
15605     const gchar *str;
15606
15607     curr_offset = offset;
15608     curr_len = len;
15609
15610     is_uplink = IS_UPLINK_FALSE;
15611
15612     /*
15613      * special dissection for Congestion Level
15614      */
15615     oct = tvb_get_guint8(tvb, curr_offset);
15616
15617     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
15618     proto_tree_add_text(tree,
15619         tvb, curr_offset, 1,
15620         "%s :  Spare",
15621         a_bigbuf);
15622
15623     item =
15624         proto_tree_add_text(tree,
15625             tvb, curr_offset, 1,
15626             gsm_dtap_elem_strings[DE_CONGESTION].strptr);
15627
15628     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CONGESTION]);
15629
15630     switch (oct & 0x0f)
15631     {
15632     case 0: str = "Receiver ready"; break;
15633     case 15: str = "Receiver not ready"; break;
15634     default:
15635         str = "Reserved";
15636         break;
15637     }
15638
15639     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
15640     proto_tree_add_text(subtree,
15641         tvb, curr_offset, 1,
15642         "%s :  Congestion level: %s",
15643         a_bigbuf,
15644         str);
15645
15646     curr_offset++;
15647     curr_len--;
15648
15649     if (curr_len <= 0) return;
15650
15651     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15652
15653     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15654 }
15655
15656 /*
15657  * [4] 9.3.5
15658  */
15659 static void
15660 dtap_cc_connect(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15661 {
15662     guint32     curr_offset;
15663     guint32     consumed;
15664     guint       curr_len;
15665
15666     curr_offset = offset;
15667     curr_len = len;
15668
15669     is_uplink = IS_UPLINK_TRUE;
15670
15671     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15672
15673     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15674
15675     ELEM_OPT_TLV(0x4c, BSSAP_PDU_TYPE_DTAP, DE_CONN_NUM, "");
15676
15677     ELEM_OPT_TLV(0x4d, BSSAP_PDU_TYPE_DTAP, DE_CONN_SUB_ADDR, "");
15678
15679     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15680
15681     /* uplink only */
15682
15683     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15684
15685     ELEM_OPT_TLV(0x2d, BSSAP_PDU_TYPE_DTAP, DE_SI, "");
15686
15687     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15688 }
15689
15690 /*
15691  * [4] 9.3.7
15692  */
15693 static void
15694 dtap_cc_disconnect(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15695 {
15696     guint32     curr_offset;
15697     guint32     consumed;
15698     guint       curr_len;
15699
15700     curr_offset = offset;
15701     curr_len = len;
15702
15703     is_uplink = IS_UPLINK_TRUE;
15704
15705     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15706
15707     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15708
15709     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15710
15711     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15712
15713     ELEM_OPT_TLV(0x7b, BSSAP_PDU_TYPE_DTAP, DE_ALLOWED_ACTIONS, "");
15714
15715     /* uplink only */
15716
15717     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15718
15719     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15720 }
15721
15722 /*
15723  * [4] 9.3.8
15724  */
15725 static void
15726 dtap_cc_emerg_setup(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15727 {
15728     guint32     curr_offset;
15729     guint32     consumed;
15730     guint       curr_len;
15731
15732     curr_offset = offset;
15733     curr_len = len;
15734
15735     is_uplink = IS_UPLINK_TRUE;
15736
15737     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15738
15739     ELEM_OPT_TLV(0x2d, BSSAP_PDU_TYPE_DTAP, DE_SI, "");
15740
15741     ELEM_OPT_TLV(0x40, BSSAP_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, "");
15742
15743     ELEM_OPT_TLV(0x2e, BSSAP_PDU_TYPE_DTAP, DE_SRVC_CAT, " Emergency");
15744
15745     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15746 }
15747
15748 /*
15749  * [4] 9.3.9
15750  */
15751 static void
15752 dtap_cc_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15753 {
15754     guint32     curr_offset;
15755     guint32     consumed;
15756     guint       curr_len;
15757
15758     curr_offset = offset;
15759     curr_len = len;
15760
15761     is_uplink = IS_UPLINK_TRUE;
15762
15763     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15764
15765     /* uplink only */
15766
15767     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15768
15769     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15770 }
15771
15772 /*
15773  * [4] 9.3.12
15774  */
15775 static void
15776 dtap_cc_hold_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15777 {
15778     guint32     curr_offset;
15779     guint32     consumed;
15780     guint       curr_len;
15781
15782     curr_offset = offset;
15783     curr_len = len;
15784
15785     is_uplink = IS_UPLINK_FALSE;
15786
15787     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15788
15789     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15790 }
15791
15792 /*
15793  * [4] 9.3.13
15794  */
15795 static void
15796 dtap_cc_modify(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15797 {
15798     guint32     curr_offset;
15799     guint32     consumed;
15800     guint       curr_len;
15801
15802     curr_offset = offset;
15803     curr_len = len;
15804
15805     is_uplink = IS_UPLINK_TRUE;
15806
15807     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15808
15809     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, "");
15810
15811     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, "");
15812
15813     ELEM_OPT_T(0xa3, BSSAP_PDU_TYPE_DTAP, DE_REV_CALL_SETUP_DIR, "");
15814
15815     ELEM_OPT_T(0xa4, BSSAP_PDU_TYPE_DTAP, DE_IMM_MOD_IND, "");
15816
15817     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15818 }
15819
15820 /*
15821  * [4] 9.3.14
15822  */
15823 static void
15824 dtap_cc_modify_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15825 {
15826     guint32     curr_offset;
15827     guint32     consumed;
15828     guint       curr_len;
15829
15830     curr_offset = offset;
15831     curr_len = len;
15832
15833     is_uplink = IS_UPLINK_TRUE;
15834
15835     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15836
15837     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, "");
15838
15839     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, "");
15840
15841     ELEM_OPT_T(0xa3, BSSAP_PDU_TYPE_DTAP, DE_REV_CALL_SETUP_DIR, "");
15842
15843     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15844 }
15845
15846 /*
15847  * [4] 9.3.15
15848  */
15849 static void
15850 dtap_cc_modify_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15851 {
15852     guint32     curr_offset;
15853     guint32     consumed;
15854     guint       curr_len;
15855
15856     curr_offset = offset;
15857     curr_len = len;
15858
15859     is_uplink = IS_UPLINK_FALSE;
15860
15861     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15862
15863     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15864
15865     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, "");
15866
15867     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, "");
15868
15869     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15870 }
15871
15872 /*
15873  * [4] 9.3.16
15874  */
15875 static void
15876 dtap_cc_notify(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15877 {
15878     guint32     curr_offset;
15879     guint32     consumed;
15880     guint       curr_len;
15881
15882     curr_offset = offset;
15883     curr_len = len;
15884
15885     is_uplink = IS_UPLINK_FALSE;
15886
15887     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_NOT_IND);
15888
15889     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15890 }
15891
15892 /*
15893  * [4] 9.3.17
15894  */
15895 static void
15896 dtap_cc_progress(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15897 {
15898     guint32     curr_offset;
15899     guint32     consumed;
15900     guint       curr_len;
15901
15902     curr_offset = offset;
15903     curr_len = len;
15904
15905     is_uplink = IS_UPLINK_FALSE;
15906
15907     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15908
15909     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15910
15911     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15912 }
15913
15914 /*
15915  * [4] 9.3.17a
15916  */
15917 static void
15918 dtap_cc_cc_est(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15919 {
15920     guint32     curr_offset;
15921     guint32     consumed;
15922     guint       curr_len;
15923
15924     curr_offset = offset;
15925     curr_len = len;
15926
15927     is_uplink = IS_UPLINK_FALSE;
15928
15929     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_SETUP_CONTAINER, "");
15930
15931     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15932 }
15933
15934 /*
15935  * [4] 9.3.17b
15936  */
15937 static void
15938 dtap_cc_cc_est_conf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15939 {
15940     guint32     curr_offset;
15941     guint32     consumed;
15942     guint       curr_len;
15943
15944     curr_offset = offset;
15945     curr_len = len;
15946
15947     is_uplink = IS_UPLINK_TRUE;
15948
15949     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " Repeat indicator");
15950
15951     ELEM_MAND_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
15952
15953     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
15954
15955     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15956
15957     ELEM_OPT_TLV(0x40, BSSAP_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, "");
15958
15959     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15960 }
15961
15962 /*
15963  * [4] 9.3.18
15964  */
15965 static void
15966 dtap_cc_release(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15967 {
15968     guint32     curr_offset;
15969     guint32     consumed;
15970     guint       curr_len;
15971
15972     curr_offset = offset;
15973     curr_len = len;
15974
15975     is_uplink = IS_UPLINK_TRUE;
15976
15977     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15978
15979     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, " 2");
15980
15981     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15982
15983     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15984
15985     /* uplink only */
15986
15987     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15988
15989     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15990 }
15991
15992 /*
15993  * [4] 9.3.18a
15994  */
15995 static void
15996 dtap_cc_recall(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15997 {
15998     guint32     curr_offset;
15999     guint32     consumed;
16000     guint       curr_len;
16001
16002     curr_offset = offset;
16003     curr_len = len;
16004
16005     is_uplink = IS_UPLINK_FALSE;
16006
16007     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RECALL_TYPE);
16008
16009     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
16010
16011     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16012 }
16013
16014 /*
16015  * [4] 9.3.19
16016  */
16017 static void
16018 dtap_cc_release_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16019 {
16020     guint32     curr_offset;
16021     guint32     consumed;
16022     guint       curr_len;
16023
16024     curr_offset = offset;
16025     curr_len = len;
16026
16027     is_uplink = IS_UPLINK_FALSE;
16028
16029     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
16030
16031     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
16032
16033     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
16034
16035     /* uplink only */
16036
16037     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
16038
16039     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16040 }
16041
16042 /*
16043  * [4] 9.3.22
16044  */
16045 static void
16046 dtap_cc_retrieve_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16047 {
16048     guint32     curr_offset;
16049     guint32     consumed;
16050     guint       curr_len;
16051
16052     curr_offset = offset;
16053     curr_len = len;
16054
16055     is_uplink = IS_UPLINK_FALSE;
16056
16057     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
16058
16059     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16060 }
16061
16062 /*
16063  * [4] 9.3.23
16064  * 3GPP TS 24.008 version 7.5.0 Release 7
16065  */
16066 static void
16067 dtap_cc_setup(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16068 {
16069     guint32     curr_offset;
16070     guint32     consumed;
16071     guint       curr_len;
16072
16073     curr_offset = offset;
16074     curr_len = len;
16075
16076     is_uplink = IS_UPLINK_TRUE;
16077
16078     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
16079
16080     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
16081
16082     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
16083
16084     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
16085
16086     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
16087
16088     ELEM_OPT_TV(0x34, BSSAP_PDU_TYPE_DTAP, DE_SIGNAL, "");
16089
16090     ELEM_OPT_TLV(0x5c, BSSAP_PDU_TYPE_DTAP, DE_CLG_PARTY_BCD_NUM, "");
16091
16092     ELEM_OPT_TLV(0x5d, BSSAP_PDU_TYPE_DTAP, DE_CLG_PARTY_SUB_ADDR, "");
16093
16094     ELEM_OPT_TLV(0x5e, BSSAP_PDU_TYPE_DTAP, DE_CLD_PARTY_BCD_NUM, "");
16095
16096     ELEM_OPT_TLV(0x6d, BSSAP_PDU_TYPE_DTAP, DE_CLD_PARTY_SUB_ADDR, "");
16097
16098     ELEM_OPT_TLV(0x74, BSSAP_PDU_TYPE_DTAP, DE_RED_PARTY_BCD_NUM, "");
16099
16100     ELEM_OPT_TLV(0x75, BSSAP_PDU_TYPE_DTAP, DE_RED_PARTY_SUB_ADDR, "");
16101
16102     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " LLC repeat indicator");
16103
16104     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, " 1");
16105
16106     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, " 2");
16107
16108     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " HLC repeat indicator");
16109
16110     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, " 1");
16111
16112     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, " 2");
16113
16114     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
16115
16116     /* downlink only */
16117
16118     ELEM_OPT_TV_SHORT(0x80, BSSAP_PDU_TYPE_DTAP, DE_PRIO, "");
16119
16120     ELEM_OPT_TLV(0x19, BSSAP_PDU_TYPE_DTAP, DE_ALERT_PATTERN, "");
16121
16122     ELEM_OPT_TLV(0x2f, BSSAP_PDU_TYPE_DTAP, DE_NET_CC_CAP, "");
16123
16124     ELEM_OPT_TLV(0x3a, BSSAP_PDU_TYPE_DTAP, DE_CAUSE_NO_CLI, "");
16125
16126         /* Backup bearer capability O TLV 3-15 10.5.4.4a */
16127         ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
16128
16129     /* uplink only */
16130
16131     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
16132
16133     ELEM_OPT_T(0xa1, BSSAP_PDU_TYPE_DTAP, DE_CLIR_SUP, "");
16134
16135     ELEM_OPT_T(0xa2, BSSAP_PDU_TYPE_DTAP, DE_CLIR_INV, "");
16136
16137     ELEM_OPT_TLV(0x15, BSSAP_PDU_TYPE_DTAP, DE_CC_CAP, "");
16138
16139     ELEM_OPT_TLV(0x1d, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, " $(CCBS)$ (advanced recall alignment)");
16140
16141     ELEM_OPT_TLV(0x1b, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, " (recall alignment Not essential) $(CCBS)$");
16142
16143     ELEM_OPT_TLV(0x2d, BSSAP_PDU_TYPE_DTAP, DE_SI, "");
16144
16145     ELEM_OPT_TLV(0x40, BSSAP_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, "");
16146
16147         /*A3 Redial Redial O T 1 10.5.4.34 
16148         /* TODO add this element 
16149         ELEM_OPT_T(0xA3, BSSAP_PDU_TYPE_DTAP, DE_REDIAL, "");
16150         */
16151
16152     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16153 }
16154
16155 /*
16156  * [4] 9.3.23a
16157  */
16158 static void
16159 dtap_cc_start_cc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16160 {
16161     guint32     curr_offset;
16162     guint32     consumed;
16163     guint       curr_len;
16164
16165     curr_offset = offset;
16166     curr_len = len;
16167
16168     is_uplink = IS_UPLINK_FALSE;
16169
16170     ELEM_OPT_TLV(0x15, BSSAP_PDU_TYPE_DTAP, DE_CC_CAP, "");
16171
16172     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16173 }
16174
16175 /*
16176  * [4] 9.3.24
16177  */
16178 static void
16179 dtap_cc_start_dtmf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16180 {
16181     guint32     curr_offset;
16182     guint32     consumed;
16183     guint       curr_len;
16184
16185     curr_offset = offset;
16186     curr_len = len;
16187
16188     is_uplink = IS_UPLINK_TRUE;
16189
16190     ELEM_MAND_TV(0x2c, BSSAP_PDU_TYPE_DTAP, DE_KEYPAD_FACILITY, "");
16191
16192     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16193 }
16194
16195 /*
16196  * [4] 9.3.25
16197  */
16198 static void
16199 dtap_cc_start_dtmf_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16200 {
16201     guint32     curr_offset;
16202     guint32     consumed;
16203     guint       curr_len;
16204
16205     curr_offset = offset;
16206     curr_len = len;
16207
16208     is_uplink = IS_UPLINK_FALSE;
16209
16210     ELEM_MAND_TV(0x2c, BSSAP_PDU_TYPE_DTAP, DE_KEYPAD_FACILITY, "");
16211
16212     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16213 }
16214
16215 /*
16216  * [4] 9.3.26
16217  */
16218 static void
16219 dtap_cc_start_dtmf_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16220 {
16221     guint32     curr_offset;
16222     guint32     consumed;
16223     guint       curr_len;
16224
16225     curr_offset = offset;
16226     curr_len = len;
16227
16228     is_uplink = IS_UPLINK_FALSE;
16229
16230     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
16231
16232     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16233 }
16234
16235 /*
16236  * [4] 9.3.27
16237  */
16238 static void
16239 dtap_cc_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16240 {
16241     guint32     curr_offset;
16242     guint32     consumed;
16243     guint       curr_len;
16244
16245     curr_offset = offset;
16246     curr_len = len;
16247
16248     is_uplink = IS_UPLINK_FALSE;
16249
16250     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
16251
16252     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CALL_STATE);
16253
16254     ELEM_OPT_TLV(0x24, BSSAP_PDU_TYPE_DTAP, DE_AUX_STATES, "");
16255
16256     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16257 }
16258
16259 /*
16260  * [4] 9.3.31
16261  */
16262 static void
16263 dtap_cc_user_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16264 {
16265     guint32     curr_offset;
16266     guint32     consumed;
16267     guint       curr_len;
16268
16269     curr_offset = offset;
16270     curr_len = len;
16271
16272     is_uplink = IS_UPLINK_TRUE;
16273
16274     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
16275
16276     ELEM_OPT_T(0xa0, BSSAP_PDU_TYPE_DTAP, DE_MORE_DATA, "");
16277
16278     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16279 }
16280
16281 /*
16282  * [6] 2.4.2
16283  */
16284 static void
16285 dtap_ss_register(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16286 {
16287     guint32     curr_offset;
16288     guint32     consumed;
16289     guint       curr_len;
16290
16291     curr_offset = offset;
16292     curr_len = len;
16293
16294     is_uplink = IS_UPLINK_TRUE;
16295
16296     ELEM_MAND_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
16297
16298     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
16299
16300     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16301 }
16302
16303 /*
16304  * [5] 7.2.1
16305  */
16306 static void
16307 dtap_sms_cp_data(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16308 {
16309     guint32     curr_offset;
16310     guint32     consumed;
16311     guint       curr_len;
16312
16313     curr_offset = offset;
16314     curr_len = len;
16315
16316     is_uplink = IS_UPLINK_TRUE;
16317
16318     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CP_USER_DATA, "");
16319
16320     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16321 }
16322
16323 /*
16324  * [5] 7.2.3
16325  */
16326 static void
16327 dtap_sms_cp_error(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16328 {
16329     guint32     curr_offset;
16330     guint32     consumed;
16331     guint       curr_len;
16332
16333     curr_offset = offset;
16334     curr_len = len;
16335
16336     is_uplink = IS_UPLINK_TRUE;
16337
16338     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CP_CAUSE);
16339
16340     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16341 }
16342
16343 /*
16344  * [5] 7.3.1.1
16345  */
16346 static void
16347 rp_data_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16348 {
16349     guint32     curr_offset;
16350     guint32     consumed;
16351     guint       curr_len;
16352
16353     curr_offset = offset;
16354     curr_len = len;
16355
16356     is_uplink = IS_UPLINK_FALSE;
16357     g_pinfo->p2p_dir = P2P_DIR_SENT;
16358
16359     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16360
16361     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_ORIG_ADDR, "");
16362
16363     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_DEST_ADDR, "");
16364
16365     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16366
16367     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16368 }
16369
16370 /*
16371  * [5] 7.3.1.2
16372  */
16373 static void
16374 rp_data_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16375 {
16376     guint32     curr_offset;
16377     guint32     consumed;
16378     guint       curr_len;
16379
16380     curr_offset = offset;
16381     curr_len = len;
16382
16383     is_uplink = IS_UPLINK_TRUE;
16384     g_pinfo->p2p_dir = P2P_DIR_RECV;
16385
16386     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16387
16388     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_ORIG_ADDR, "");
16389
16390     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_DEST_ADDR, "");
16391
16392     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16393
16394     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16395 }
16396
16397 /*
16398  * [5] 7.3.2
16399  */
16400 static void
16401 rp_smma(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16402 {
16403     guint32     curr_offset;
16404     guint32     consumed;
16405     guint       curr_len;
16406
16407     curr_offset = offset;
16408     curr_len = len;
16409
16410     is_uplink = IS_UPLINK_TRUE;
16411
16412     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16413
16414     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16415 }
16416
16417 /*
16418  * [5] 7.3.3
16419  */
16420 static void
16421 rp_ack_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16422 {
16423     guint32     curr_offset;
16424     guint32     consumed;
16425     guint       curr_len;
16426
16427     curr_offset = offset;
16428     curr_len = len;
16429
16430     is_uplink = IS_UPLINK_FALSE;
16431     g_pinfo->p2p_dir = P2P_DIR_SENT;
16432
16433     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16434
16435     ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16436
16437     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16438 }
16439
16440 /*
16441  * [5] 7.3.3
16442  */
16443 static void
16444 rp_ack_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16445 {
16446     guint32     curr_offset;
16447     guint32     consumed;
16448     guint       curr_len;
16449
16450     curr_offset = offset;
16451     curr_len = len;
16452
16453     is_uplink = IS_UPLINK_TRUE;
16454     g_pinfo->p2p_dir = P2P_DIR_RECV;
16455
16456     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16457
16458     ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16459
16460     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16461 }
16462
16463 /*
16464  * [5] 7.3.4
16465  */
16466 static void
16467 rp_error_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16468 {
16469     guint32     curr_offset;
16470     guint32     consumed;
16471     guint       curr_len;
16472
16473     curr_offset = offset;
16474     curr_len = len;
16475
16476     is_uplink = IS_UPLINK_FALSE;
16477     g_pinfo->p2p_dir = P2P_DIR_SENT;
16478
16479     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16480
16481     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_CAUSE, "");
16482
16483     ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16484
16485     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16486 }
16487
16488 /*
16489  * [5] 7.3.4
16490  */
16491 static void
16492 rp_error_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16493 {
16494     guint32     curr_offset;
16495     guint32     consumed;
16496     guint       curr_len;
16497
16498     curr_offset = offset;
16499     curr_len = len;
16500
16501     is_uplink = IS_UPLINK_TRUE;
16502     g_pinfo->p2p_dir = P2P_DIR_RECV;
16503
16504     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16505
16506     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_CAUSE, "");
16507
16508     ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16509
16510     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16511 }
16512
16513 /*
16514  * [7] 9.4.1
16515  */
16516 static void
16517 dtap_gmm_attach_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16518 {
16519     guint32     curr_offset;
16520     guint32     consumed;
16521     guint       curr_len;
16522
16523     curr_offset = offset;
16524     curr_len = len;
16525
16526     is_uplink = IS_UPLINK_TRUE;
16527     g_pinfo->p2p_dir = P2P_DIR_RECV;
16528
16529     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_NET_CAP, "");
16530     
16531     /* Included in attach type
16532     
16533     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CIPH_KEY_SEQ_NUM );
16534     curr_offset--;
16535     curr_len++;
16536     */
16537     
16538     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_ATTACH_TYPE );
16539     
16540     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_DRX_PARAM );
16541     
16542     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID , "" );
16543     
16544     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16545     
16546     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_RAD_ACC_CAP , "" );
16547
16548     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG, " - Old P-TMSI Signature");
16549     
16550     ELEM_OPT_TV( 0x17 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER , " - Ready Timer" );
16551     
16552     ELEM_OPT_TV_SHORT( 0x90 , BSSAP_PDU_TYPE_DTAP, DE_TMSI_STAT , "" );
16553
16554     ELEM_OPT_TLV( 0x33 , BSSAP_PDU_TYPE_DTAP, DE_PS_LCS_CAP , "" );
16555
16556     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16557 }
16558
16559 /*
16560  * [7] 9.4.2
16561  */
16562 static void
16563 dtap_gmm_attach_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16564 {
16565     guint32     curr_offset;
16566     guint32     consumed;
16567     guint       curr_len;
16568
16569     curr_offset = offset;
16570     curr_len = len;
16571
16572     is_uplink = IS_UPLINK_FALSE;
16573     g_pinfo->p2p_dir = P2P_DIR_SENT;
16574
16575     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND_H );
16576     curr_len++;
16577     curr_offset--;    
16578
16579     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_ATTACH_RES );
16580     
16581     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER );
16582     
16583     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAD_PRIO_2 );
16584     curr_len++;
16585     curr_offset--;
16586     
16587     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAD_PRIO );
16588     
16589     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16590     
16591     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG, "" );
16592     
16593     ELEM_OPT_TV( 0x17 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER , " - Negotiated Ready Timer" );
16594     
16595     ELEM_OPT_TLV( 0x18 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - Allocated P-TMSI" );
16596     
16597     ELEM_OPT_TLV( 0x23 , BSSAP_PDU_TYPE_DTAP, DE_MID , "" );
16598     
16599     ELEM_OPT_TV( 0x25 , BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE , "" );
16600     
16601     ELEM_OPT_TLV( 0x2A , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER_2 , " - T3302" );
16602     
16603     ELEM_OPT_T( 0x8C , BSSAP_PDU_TYPE_DTAP, DE_CELL_NOT , "" );
16604     
16605     ELEM_OPT_TLV( 0x4A , BSSAP_PDU_TYPE_DTAP, DE_PLMN_LIST , "" );
16606
16607     ELEM_OPT_TV_SHORT( 0xB0 , BSSAP_PDU_TYPE_DTAP, DE_NET_FEAT_SUP , "" );
16608     
16609     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST , "" );
16610
16611     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16612 }
16613
16614 /*
16615  * [7] 9.4.3
16616  */
16617 static void
16618 dtap_gmm_attach_com(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16619 {
16620
16621     guint32     curr_offset;
16622 /*    guint32   consumed; */
16623     guint       curr_len;
16624
16625     curr_offset = offset;
16626     curr_len = len;
16627
16628     is_uplink = IS_UPLINK_TRUE;
16629     g_pinfo->p2p_dir = P2P_DIR_RECV;
16630
16631     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16632 }
16633
16634 /*
16635  * [7] 9.4.4
16636  */
16637 static void
16638 dtap_gmm_attach_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16639 {
16640     guint32     curr_offset;
16641     guint32     consumed;
16642     guint       curr_len;
16643
16644     curr_offset = offset;
16645     curr_len = len;
16646
16647     is_uplink = IS_UPLINK_FALSE;
16648     g_pinfo->p2p_dir = P2P_DIR_SENT;
16649
16650     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
16651
16652     ELEM_OPT_TLV( 0x2A , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER_2 , " - T3302" );
16653
16654     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16655 }
16656
16657 /*
16658  * [7] 9.4.5
16659  */
16660 static void
16661 dtap_gmm_detach_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16662 {
16663     guint32     curr_offset;
16664     guint32     consumed;
16665     guint       curr_len;
16666
16667     curr_offset = offset;
16668     curr_len = len;
16669
16670     is_uplink = IS_UPLINK_FALSE;
16671     g_pinfo->p2p_dir = P2P_DIR_SENT;
16672
16673     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND_H );
16674     /* Force to standy might be wrong - To decode it correct, we need the direction */
16675     curr_len++;
16676     curr_offset--;
16677     
16678     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_DETACH_TYPE );
16679     
16680     ELEM_OPT_TV( 0x25 , BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE , "" );
16681     
16682     ELEM_OPT_TLV( 0x18 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - P-TMSI" );
16683
16684     ELEM_OPT_TLV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG , "" );
16685     
16686     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16687 }
16688
16689 /*
16690  * [7] 9.4.6
16691  */
16692 static void
16693 dtap_gmm_detach_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16694 {
16695     guint32     curr_offset;
16696     guint32     consumed;
16697     guint       curr_len;
16698
16699     curr_offset = offset;
16700     curr_len = len;
16701
16702     is_uplink = IS_UPLINK_TRUE;
16703     g_pinfo->p2p_dir = P2P_DIR_RECV;
16704
16705     if ( curr_len != 0 )
16706     {
16707         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE_NIBBLE );
16708         curr_len++;
16709         curr_offset--;
16710         
16711         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
16712     }
16713
16714     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16715 }
16716
16717 /*
16718  * [7] 9.4.7
16719  */
16720 static void
16721 dtap_gmm_ptmsi_realloc_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16722 {
16723     guint32     curr_offset;
16724     guint32     consumed;
16725     guint       curr_len;
16726
16727     curr_offset = offset;
16728     curr_len = len;
16729
16730     is_uplink = IS_UPLINK_FALSE;
16731     g_pinfo->p2p_dir = P2P_DIR_SENT;
16732
16733     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID , " - Allocated P-TMSI" );
16734
16735     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16736
16737     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE_NIBBLE );
16738     curr_len++;
16739     curr_offset--;
16740     
16741     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
16742
16743     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - P-TMSI Signature" );    
16744
16745     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16746 }
16747
16748 /*
16749  * [7] 9.4.8
16750  */
16751 static void
16752 dtap_gmm_ptmsi_realloc_com(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16753 {
16754     guint32     curr_offset;
16755 /*    guint32   consumed; */
16756     guint       curr_len;
16757
16758     curr_offset = offset;
16759     curr_len = len;
16760
16761     is_uplink = IS_UPLINK_TRUE;
16762     g_pinfo->p2p_dir = P2P_DIR_RECV;
16763
16764     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16765 }
16766
16767 /*
16768  * [7] 9.4.9
16769  */
16770 static void
16771 dtap_gmm_auth_ciph_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16772 {
16773     guint32     curr_offset;
16774     guint32     consumed;
16775     guint       curr_len;
16776     guint8      oct;
16777     
16778     curr_offset = offset;
16779     curr_len = len;
16780
16781     is_uplink = IS_UPLINK_FALSE;
16782     g_pinfo->p2p_dir = P2P_DIR_SENT;
16783
16784     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_IMEISV_REQ );
16785     curr_offset--;
16786     curr_len++;
16787     
16788     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CIPH_ALG );
16789     
16790     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_AC_REF_NUM_H );
16791     curr_offset--;
16792     curr_len++;
16793     
16794     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
16795     
16796     ELEM_OPT_TV( 0x21 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_PARAM_RAND , "" );
16797
16798 #if 0    
16799     ELEM_OPT_TV_SHORT( 0x08 , BSSAP_PDU_TYPE_DTAP, DE_CIPH_KEY_SEQ_NUM , "" );
16800 #else
16801     if ( curr_len > 0 )
16802     {
16803             oct = tvb_get_guint8(tvb, curr_offset);
16804             if (( oct & 0xf0 ) == 0x80 )
16805             {
16806                 /* The ciphering key sequence number is added here */
16807                 proto_tree_add_text(tree,
16808                         tvb, curr_offset, 1,
16809                         "Ciphering key sequence number: 0x%02x (%u)",
16810                         oct&7,
16811                         oct&7);
16812                 curr_offset++;
16813                 curr_len--;
16814             }
16815     }
16816 #endif
16817
16818     if ( curr_len == 0  )
16819     {
16820         EXTRANEOUS_DATA_CHECK(curr_len, 0);
16821         return;
16822     }
16823         
16824     ELEM_OPT_TLV( 0x28 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_PARAM_AUTN , "" );
16825
16826     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16827 }
16828
16829 /*
16830  * [7] 9.4.10
16831  */
16832 static void
16833 dtap_gmm_auth_ciph_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16834 {
16835     guint32     curr_offset;
16836     guint32     consumed;
16837     guint       curr_len;
16838
16839     curr_offset = offset;
16840     curr_len = len;
16841
16842     is_uplink = IS_UPLINK_TRUE;
16843     g_pinfo->p2p_dir = P2P_DIR_RECV;
16844
16845     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE_NIBBLE );
16846     curr_offset--;
16847     curr_len++;
16848     
16849     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_AC_REF_NUM );
16850     
16851     ELEM_OPT_TV( 0x22 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM , "" );
16852     
16853     ELEM_OPT_TLV( 0x23 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - IMEISV" );
16854     
16855     ELEM_OPT_TLV( 0x29 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM_EXT , "" );
16856
16857     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16858 }
16859
16860 /*
16861  * [7] 9.4.11
16862  */
16863 static void
16864 dtap_gmm_auth_ciph_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16865 {
16866     guint32     curr_offset;
16867 /*    guint32   consumed; */
16868     guint       curr_len;
16869
16870     curr_offset = offset;
16871     curr_len = len;
16872
16873     is_uplink = IS_UPLINK_FALSE;
16874     g_pinfo->p2p_dir = P2P_DIR_SENT;
16875
16876     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16877 }
16878
16879 /*
16880  * [7] 9.4.10a
16881  */
16882 static void
16883 dtap_gmm_auth_ciph_fail(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16884 {
16885     guint32     curr_offset;
16886     guint32     consumed;
16887     guint       curr_len;
16888
16889     curr_offset = offset;
16890     curr_len = len;
16891
16892     is_uplink = IS_UPLINK_TRUE;
16893     g_pinfo->p2p_dir = P2P_DIR_RECV;
16894
16895     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
16896     
16897     ELEM_OPT_TLV( 0x30 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_FAIL_PARAM , "" );
16898
16899     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16900 }
16901
16902 /*
16903  * [7] 9.4.12
16904  */
16905 static void
16906 dtap_gmm_ident_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16907 {
16908     guint32     curr_offset;
16909     guint       curr_len;
16910
16911     curr_offset = offset;
16912     curr_len = len;
16913
16914     is_uplink = IS_UPLINK_FALSE;
16915     g_pinfo->p2p_dir = P2P_DIR_SENT;
16916
16917 /*  If the half octect that are about to get decoded is the LAST in the octetstream, the macro will call return BEFORE we get a chance to fix the index. The end result will be that the first half-octet will be decoded but not the last. */
16918 /*    ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_ID_TYPE_2 );
16919     curr_offset--;
16920     curr_len++;
16921     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND_H );*/
16922     
16923     elem_v(tvb, tree, BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND_H, curr_offset);
16924     elem_v(tvb, tree, BSSAP_PDU_TYPE_DTAP, DE_ID_TYPE_2, curr_offset);
16925
16926     curr_offset+=1;
16927     curr_len-=1;
16928
16929     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16930 }
16931
16932 /*
16933  * [7] 9.4.13
16934  */
16935 static void
16936 dtap_gmm_ident_res(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16937 {
16938     guint32     curr_offset;
16939     guint32     consumed;
16940     guint       curr_len;
16941
16942     curr_offset = offset;
16943     curr_len = len;
16944
16945     is_uplink = IS_UPLINK_TRUE;
16946     g_pinfo->p2p_dir = P2P_DIR_RECV;
16947
16948     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID , "" );
16949
16950     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16951 }
16952
16953 /*
16954  * [7] 9.4.14
16955  */
16956 static void
16957 dtap_gmm_rau_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16958 {
16959     guint32     curr_offset;
16960     guint32     consumed;
16961     guint       curr_len;
16962
16963     curr_offset = offset;
16964     curr_len = len;
16965
16966     is_uplink = IS_UPLINK_TRUE;
16967     g_pinfo->p2p_dir = P2P_DIR_RECV;
16968
16969     /* is included in update type
16970     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CIPH_KEY_SEQ_NUM );
16971     curr_offset--;
16972     curr_len++;
16973     
16974     */
16975     
16976     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_UPD_TYPE );
16977     
16978     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16979     
16980     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_RAD_ACC_CAP , "" );
16981     
16982     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG , " - Old P-TMSI Signature" ); 
16983     
16984     ELEM_OPT_TV( 0x17 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER , " - Requested Ready Timer" );
16985
16986     ELEM_OPT_TV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_DRX_PARAM , "" );
16987     
16988     ELEM_OPT_TV_SHORT( 0x90 , BSSAP_PDU_TYPE_DTAP, DE_TMSI_STAT , "" );
16989     
16990     ELEM_OPT_TLV( 0x18 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - P-TMSI" );
16991     
16992     ELEM_OPT_TLV( 0x31 , BSSAP_PDU_TYPE_DTAP, DE_MS_NET_CAP , "" );
16993     
16994     ELEM_OPT_TLV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_PDP_CONTEXT_STAT , "" );
16995     
16996     ELEM_OPT_TLV( 0x33 , BSSAP_PDU_TYPE_DTAP, DE_PS_LCS_CAP , "" );
16997     
16998     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16999 }
17000
17001 /*
17002  * [7] 9.4.15
17003  */
17004 static void
17005 dtap_gmm_rau_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17006 {
17007     guint32     curr_offset;
17008     guint32     consumed;
17009     guint       curr_len;
17010
17011     curr_offset = offset;
17012     curr_len = len;
17013
17014     is_uplink = IS_UPLINK_FALSE;
17015     g_pinfo->p2p_dir = P2P_DIR_SENT;
17016
17017     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_UPD_RES );
17018     curr_offset--;
17019     curr_len++;
17020     
17021     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
17022     
17023     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER );
17024     
17025     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
17026     
17027     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG , "" ); 
17028     
17029     ELEM_OPT_TLV( 0x18 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - Allocated P-TMSI");
17030     
17031     ELEM_OPT_TLV( 0x23 , BSSAP_PDU_TYPE_DTAP, DE_MID , "" );
17032     
17033     ELEM_OPT_TLV( 0x26 , BSSAP_PDU_TYPE_DTAP, DE_REC_N_PDU_NUM_LIST , "" );
17034     
17035     ELEM_OPT_TV( 0x17 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER , " - Negotiated Ready Timer" );
17036     
17037     ELEM_OPT_TV( 0x25 , BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE , "" );
17038     
17039     ELEM_OPT_TLV( 0x2A , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER_2 , " - T3302" );
17040     
17041     ELEM_OPT_T( 0x8C , BSSAP_PDU_TYPE_DTAP, DE_CELL_NOT , "" );
17042     
17043     ELEM_OPT_TLV( 0x4A , BSSAP_PDU_TYPE_DTAP, DE_PLMN_LIST , "" );
17044     
17045     ELEM_OPT_TLV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_PDP_CONTEXT_STAT , "" );
17046     
17047     ELEM_OPT_TV_SHORT ( 0xB0 , BSSAP_PDU_TYPE_DTAP, DE_NET_FEAT_SUP , "" );
17048     
17049     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST , "" );
17050
17051     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17052 }
17053
17054 /*
17055  * [7] 9.4.16
17056  */
17057 static void
17058 dtap_gmm_rau_com(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17059 {
17060     guint32     curr_offset;
17061     guint32     consumed;
17062     guint       curr_len;
17063
17064     curr_offset = offset;
17065     curr_len = len;
17066
17067     is_uplink = IS_UPLINK_TRUE;
17068     g_pinfo->p2p_dir = P2P_DIR_RECV;
17069         /* [7] 10.5.5.11 */
17070     ELEM_OPT_TLV( 0x26 , BSSAP_PDU_TYPE_DTAP, DE_REC_N_PDU_NUM_LIST , "" );
17071         /* Inter RAT information container 10.5.5.24 TS 24.008 version 6.8.0 Release 6 */
17072         /*TO DO: Implement */
17073         ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_RAT_INFO_CONTAINER , "" );
17074     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17075 }
17076
17077 /*
17078  * [7] 9.4.17
17079  */
17080 static void
17081 dtap_gmm_rau_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17082 {
17083     guint32     curr_offset;
17084     guint32     consumed;
17085     guint       curr_len;
17086
17087     curr_offset = offset;
17088     curr_len = len;
17089
17090     is_uplink = IS_UPLINK_FALSE;
17091     g_pinfo->p2p_dir = P2P_DIR_SENT;
17092
17093     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
17094     
17095     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE_NIBBLE );
17096     curr_offset--;
17097     curr_len++;
17098     
17099     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
17100     
17101     ELEM_OPT_TLV( 0x26 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER_2 , " - T3302" );
17102
17103     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17104 }
17105
17106 /*
17107  * [7] 9.4.18
17108  */
17109 static void
17110 dtap_gmm_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17111 {
17112     guint32     curr_offset;
17113     guint32     consumed;
17114     guint       curr_len;
17115
17116     curr_offset = offset;
17117     curr_len = len;
17118
17119      is_uplink = IS_UPLINK_UNKNOWN;
17120     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17121
17122     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
17123
17124     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17125 }
17126
17127 /*
17128  * [8] 9.4.19 GMM Information
17129  */
17130 static void
17131 dtap_gmm_information(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17132 {
17133     guint32     curr_offset;
17134     guint32     consumed;
17135     guint       curr_len;
17136
17137     curr_offset = offset;
17138     curr_len = len;
17139
17140     is_uplink = IS_UPLINK_FALSE;
17141     g_pinfo->p2p_dir = P2P_DIR_SENT;
17142
17143     ELEM_OPT_TLV( 0x43 , BSSAP_PDU_TYPE_DTAP, DE_NETWORK_NAME , " - Full Name" );
17144     
17145     ELEM_OPT_TLV( 0x45 , BSSAP_PDU_TYPE_DTAP, DE_NETWORK_NAME , " - Short Name" );
17146     
17147     ELEM_OPT_TV( 0x46 , BSSAP_PDU_TYPE_DTAP, DE_TIME_ZONE , "" );
17148     
17149     ELEM_OPT_TV( 0x47 , BSSAP_PDU_TYPE_DTAP, DE_TIME_ZONE_TIME , "" );
17150     
17151     ELEM_OPT_TLV( 0x48 , BSSAP_PDU_TYPE_DTAP, DE_LSA_ID , "" );
17152     
17153     ELEM_OPT_TLV( 0x49 , BSSAP_PDU_TYPE_DTAP, DE_DAY_SAVING_TIME , "" );
17154
17155     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17156 }
17157
17158 /*
17159  * [7] 9.4.20
17160  */
17161 static void
17162 dtap_gmm_service_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17163 {
17164     guint32     curr_offset;
17165     guint32     consumed;
17166     guint       curr_len;
17167
17168     curr_offset = offset;
17169     curr_len = len;
17170
17171     is_uplink = IS_UPLINK_TRUE;
17172     g_pinfo->p2p_dir = P2P_DIR_RECV;
17173
17174     /* Is included in SRVC TYPE
17175     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CIPH_KEY_SEQ_NUM );
17176     curr_offset--;
17177     curr_len++;
17178     */
17179     
17180     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SRVC_TYPE );
17181     
17182         /* P-TMSI Mobile station identity 10.5.1.4 M LV 6 */
17183     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
17184     
17185     ELEM_OPT_TLV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_PDP_CONTEXT_STAT , "" );
17186
17187         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
17188         ELEM_OPT_TLV( 0x35 , BSSAP_PDU_TYPE_DTAP, DE_MBMS_CTX_STATUS , "" );
17189
17190     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17191 }
17192
17193 /*
17194  * [7] 9.4.21
17195  */
17196 static void
17197 dtap_gmm_service_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17198 {
17199     guint32     curr_offset;
17200     guint32     consumed;
17201     guint       curr_len;
17202
17203     curr_offset = offset;
17204     curr_len = len;
17205
17206     is_uplink = IS_UPLINK_FALSE;
17207     g_pinfo->p2p_dir = P2P_DIR_SENT;
17208
17209     ELEM_OPT_TLV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_PDP_CONTEXT_STAT , "" );
17210
17211         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
17212         ELEM_OPT_TLV( 0x35 , BSSAP_PDU_TYPE_DTAP, DE_MBMS_CTX_STATUS , "" );
17213
17214     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17215 }
17216
17217 /*
17218  * [7] 9.4.22
17219  */
17220 static void
17221 dtap_gmm_service_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17222 {
17223     guint32     curr_offset;
17224     guint32     consumed;
17225     guint       curr_len;
17226
17227     curr_offset = offset;
17228     curr_len = len;
17229
17230     is_uplink = IS_UPLINK_FALSE;
17231     g_pinfo->p2p_dir = P2P_DIR_SENT;
17232
17233     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
17234
17235     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17236 }
17237
17238 /*
17239  * [8] 9.5.1 Activate PDP context request
17240  */
17241 static void
17242 dtap_sm_act_pdp_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17243 {
17244     guint32     curr_offset;
17245     guint32     consumed;
17246     guint       curr_len;
17247
17248     curr_offset = offset;
17249     curr_len = len;
17250
17251     is_uplink = IS_UPLINK_UNKNOWN;
17252     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17253
17254     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_NET_SAPI );
17255
17256     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
17257
17258     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Requested QoS" );
17259
17260     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_PD_PRO_ADDR , " - Requested PDP address" );
17261
17262     ELEM_OPT_TLV( 0x28 , BSSAP_PDU_TYPE_DTAP, DE_ACC_POINT_NAME , "" );
17263
17264     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17265
17266     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17267 }
17268
17269 /*
17270  * [8] 9.5.2 Activate PDP context accept
17271  */
17272 static void
17273 dtap_sm_act_pdp_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17274 {
17275     guint32     curr_offset;
17276     guint32     consumed;
17277     guint       curr_len;
17278
17279     curr_offset = offset;
17280     curr_len = len;
17281
17282     is_uplink = IS_UPLINK_UNKNOWN;
17283     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17284
17285     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
17286
17287     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Negotiated QoS" );
17288
17289 #if 0   
17290     /* This is done automatically */
17291     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE );
17292     curr_offset--;
17293     curr_len++;
17294 #endif
17295
17296     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAD_PRIO );
17297
17298     ELEM_OPT_TLV( 0x2B , BSSAP_PDU_TYPE_DTAP, DE_PD_PRO_ADDR , "" );
17299
17300     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17301
17302     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_PACKET_FLOW_ID , "" );
17303
17304     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17305 }
17306
17307 /*
17308  * [8] 9.5.3 Activate PDP context reject
17309  */
17310 static void
17311 dtap_sm_act_pdp_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17312 {
17313     guint32     curr_offset;
17314     guint32     consumed;
17315     guint       curr_len;
17316
17317     curr_offset = offset;
17318     curr_len = len;
17319
17320     is_uplink = IS_UPLINK_UNKNOWN;
17321     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17322
17323     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17324
17325     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17326
17327     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17328 }
17329
17330 /*
17331  * [8] 9.5.4 Activate Secondary PDP Context Request
17332  */
17333 static void
17334 dtap_sm_act_sec_pdp_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17335 {
17336     guint32     curr_offset;
17337     guint32     consumed;
17338     guint       curr_len;
17339
17340     curr_offset = offset;
17341     curr_len = len;
17342
17343     is_uplink = IS_UPLINK_UNKNOWN;
17344     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17345
17346     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_NET_SAPI );
17347
17348     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
17349
17350     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Requested QoS" );
17351
17352     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_LINKED_TI , "" );
17353
17354         /* 3GPP TS 24.008 version 6.8.0 Release 6, 36 TFT Traffic Flow Template 10.5.6.12 O TLV 3-257 */
17355     ELEM_OPT_TLV( 0x36 , BSSAP_PDU_TYPE_DTAP, DE_TRAFFIC_FLOW_TEMPLATE , "" );
17356
17357     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17358
17359     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17360 }
17361
17362 /*
17363  * [7] 9.5.5
17364  */
17365 static void
17366 dtap_sm_act_sec_pdp_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17367 {
17368     guint32     curr_offset;
17369     guint32     consumed;
17370     guint       curr_len;
17371
17372     curr_offset = offset;
17373     curr_len = len;
17374
17375     is_uplink = IS_UPLINK_UNKNOWN;
17376     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17377
17378     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
17379
17380     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Negotiated QoS" );
17381
17382     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAD_PRIO);
17383
17384 #if 0   
17385     /* This is done automatically */
17386     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE );
17387     curr_offset--;
17388     curr_len++;
17389 #endif
17390
17391     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_PACKET_FLOW_ID , "" );
17392
17393     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17394
17395     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17396 }
17397
17398 /*
17399  * [8] 9.5.6 Activate Secondary PDP Context Reject
17400  */
17401 static void
17402 dtap_sm_act_sec_pdp_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17403 {
17404     guint32     curr_offset;
17405     guint32     consumed;
17406     guint       curr_len;
17407
17408     curr_offset = offset;
17409     curr_len = len;
17410
17411     is_uplink = IS_UPLINK_UNKNOWN;
17412     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17413
17414     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17415
17416     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17417
17418     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17419 }
17420
17421 /*
17422  * [8] 9.5.7 Request PDP context activation
17423  */
17424 static void
17425 dtap_sm_req_pdp_act(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17426 {
17427     guint32     curr_offset;
17428     guint32     consumed;
17429     guint       curr_len;
17430
17431     curr_offset = offset;
17432     curr_len = len;
17433
17434     is_uplink = IS_UPLINK_UNKNOWN;
17435     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17436
17437     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_PD_PRO_ADDR , " - Offered PDP address" );
17438
17439     ELEM_OPT_TLV( 0x28 , BSSAP_PDU_TYPE_DTAP, DE_ACC_POINT_NAME , "" );
17440
17441     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17442
17443     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17444 }
17445
17446 /*
17447  * [8] 9.5.8 Request PDP context activation reject
17448  */
17449 static void
17450 dtap_sm_req_pdp_act_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17451 {
17452     guint32     curr_offset;
17453     guint32     consumed;
17454     guint       curr_len;
17455
17456     curr_offset = offset;
17457     curr_len = len;
17458
17459     is_uplink = IS_UPLINK_UNKNOWN;
17460     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17461
17462     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17463
17464     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17465
17466     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17467 }
17468
17469 /*
17470  * [8] 9.5.9 Modify PDP context request (Network to MS direction)
17471  */
17472 static void
17473 dtap_sm_mod_pdp_req_net(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17474 {
17475     guint32     curr_offset;
17476     guint32     consumed;
17477     guint       curr_len;
17478
17479     curr_offset = offset;
17480     curr_len = len;
17481
17482     is_uplink = IS_UPLINK_UNKNOWN;
17483     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17484
17485         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP,DE_RAD_PRIO);
17486 #if 0   
17487     /* This is done automatically */
17488     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE );
17489     curr_offset--;
17490     curr_len++;
17491 #endif
17492
17493     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
17494
17495     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - New QoS" );
17496
17497     ELEM_OPT_TLV( 0x2B , BSSAP_PDU_TYPE_DTAP, DE_PD_PRO_ADDR , "" );
17498
17499     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_PACKET_FLOW_ID , "" );
17500
17501     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17502
17503     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17504 }
17505
17506 /*
17507  * [8] 9.5.10 Modify PDP context request (MS to network direction)
17508  */
17509 static void
17510 dtap_sm_mod_pdp_req_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17511 {
17512     guint32     curr_offset;
17513     guint32     consumed;
17514     guint       curr_len;
17515
17516     curr_offset = offset;
17517     curr_len = len;
17518
17519     is_uplink = IS_UPLINK_UNKNOWN;
17520     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17521
17522     ELEM_OPT_TV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI , " - Requested LLC SAPI" );
17523
17524     ELEM_OPT_TLV( 0x30 , BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Requested new QoS" );
17525
17526     ELEM_OPT_TLV( 0x31 , BSSAP_PDU_TYPE_DTAP, DE_TRAFFIC_FLOW_TEMPLATE , " - New TFT" );
17527
17528     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17529
17530     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17531 }
17532
17533 /*
17534  * [8] 9.5.11 Modify PDP context accept (MS to network direction)
17535  */
17536 static void
17537 dtap_sm_mod_pdp_acc_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17538 {
17539     guint32     curr_offset;
17540     guint32     consumed;
17541     guint       curr_len;
17542
17543     curr_offset = offset;
17544     curr_len = len;
17545
17546     is_uplink = IS_UPLINK_UNKNOWN;
17547     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17548
17549     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17550
17551     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17552 }
17553
17554 /*
17555  * [8] 9.5.12 Modify PDP context accept (Network to MS direction)
17556  */
17557 static void
17558 dtap_sm_mod_pdp_acc_net(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17559 {
17560     guint32     curr_offset;
17561     guint32     consumed;
17562     guint       curr_len;
17563
17564     curr_offset = offset;
17565     curr_len = len;
17566
17567     is_uplink = IS_UPLINK_UNKNOWN;
17568     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17569
17570     ELEM_OPT_TLV( 0x30 , BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Negotiated QoS" );
17571
17572     ELEM_OPT_TV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI , " - Negotiated LLC SAPI" );
17573
17574     ELEM_OPT_TV_SHORT ( 0x80 , BSSAP_PDU_TYPE_DTAP , DE_RAD_PRIO , " - New radio priority" );
17575
17576     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_PACKET_FLOW_ID , "" );
17577
17578     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17579
17580     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17581 }
17582
17583 /*
17584  * [8] 9.5.13 Modify PDP Context Reject
17585  */
17586 static void
17587 dtap_sm_mod_pdp_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17588 {
17589     guint32     curr_offset;
17590     guint32     consumed;
17591     guint       curr_len;
17592
17593     curr_offset = offset;
17594     curr_len = len;
17595
17596     is_uplink = IS_UPLINK_UNKNOWN;
17597     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17598
17599     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17600
17601     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17602
17603     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17604 }
17605
17606 /*
17607  * [8] 9.5.14 Deactivate PDP context request
17608  */
17609 static void
17610 dtap_sm_deact_pdp_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17611 {
17612     guint32     curr_offset;
17613     guint32     consumed;
17614     guint       curr_len;
17615
17616     curr_offset = offset;
17617     curr_len = len;
17618
17619     is_uplink = IS_UPLINK_UNKNOWN;
17620     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17621
17622     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17623
17624     ELEM_OPT_TV_SHORT( 0x90 , BSSAP_PDU_TYPE_DTAP , DE_TEAR_DOWN_IND , "" );
17625
17626     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17627
17628         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
17629         ELEM_OPT_TLV( 0x35 , BSSAP_PDU_TYPE_DTAP, DE_MBMS_CTX_STATUS , "" );
17630
17631     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17632 }
17633
17634
17635 /*
17636  * [8] 9.5.15 Deactivate PDP context accept
17637  */
17638 static void
17639 dtap_sm_deact_pdp_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17640 {
17641     guint32     curr_offset;
17642     guint32     consumed;
17643     guint       curr_len;
17644
17645     curr_offset = offset;
17646     curr_len = len;
17647
17648      is_uplink = IS_UPLINK_UNKNOWN;
17649     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17650
17651     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17652
17653         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
17654         ELEM_OPT_TLV( 0x35 , BSSAP_PDU_TYPE_DTAP, DE_MBMS_CTX_STATUS , "" );
17655
17656     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17657 }
17658
17659 /*
17660  * [8] 9.5.21 SM Status
17661  */
17662 static void
17663 dtap_sm_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17664 {
17665     guint32     curr_offset;
17666     guint32     consumed;
17667     guint       curr_len;
17668
17669     curr_offset = offset;
17670     curr_len = len;
17671
17672      is_uplink = IS_UPLINK_UNKNOWN;
17673     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17674
17675     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17676
17677     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17678 }
17679
17680 /*
17681  * [8] 9.5.22 Activate MBMS Context Request
17682  */
17683
17684         /* Requested MBMS NSAPI Enhanced Network service access point identifier 10.5.6.15 M V */
17685         /* Requested LLC SAPI LLC service access point identifier 10.5.6.9 M V 1 */
17686         /* Supported MBMS bearer capabilities MBMS bearer capabilities 10.5.6.14 M LV 2 - 3 */
17687         /* Requested multicast address Packet data protocol address 10.5.6.4 M LV 3 - 19 */
17688         /* Access point name Access point name 10.5.6.1 M LV 2 - 101 */
17689         /* 35 MBMS protocol configuration options MBMS protocol configuration options 10.5.6.15 O TLV 3 - 253 */
17690
17691 /*
17692  * [8] 9.5.23 Activate MBMS Context Accept
17693  */
17694
17695 /*
17696  * [8] 9.5.24 Activate MBMS Context Reject
17697  */
17698
17699 /*
17700  * [8] 9.5.25 Request MBMS Context Activation
17701  */
17702
17703 /*
17704  * [8] 9.5.26 Request MBMS Context Activation Reject
17705  */
17706
17707 #define NUM_GSM_DTAP_MSG_MM (sizeof(gsm_a_dtap_msg_mm_strings)/sizeof(value_string))
17708 static gint ett_gsm_dtap_msg_mm[NUM_GSM_DTAP_MSG_MM];
17709 static void (*dtap_msg_mm_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17710     dtap_mm_imsi_det_ind,       /* IMSI Detach Indication */
17711     dtap_mm_loc_upd_acc,        /* Location Updating Accept */
17712     dtap_mm_loc_upd_rej,        /* Location Updating Reject */
17713     dtap_mm_loc_upd_req,        /* Location Updating Request */
17714     NULL /* no associated data */,      /* Authentication Reject */
17715     dtap_mm_auth_req,   /* Authentication Request */
17716     dtap_mm_auth_resp,  /* Authentication Response */
17717     dtap_mm_auth_fail,  /* Authentication Failure */
17718     dtap_mm_id_req,     /* Identity Request */
17719     dtap_mm_id_resp,    /* Identity Response */
17720     dtap_mm_tmsi_realloc_cmd,   /* TMSI Reallocation Command */
17721     NULL /* no associated data */,      /* TMSI Reallocation Complete */
17722     NULL /* no associated data */,      /* CM Service Accept */
17723     dtap_mm_cm_srvc_rej,        /* CM Service Reject */
17724     NULL /* no associated data */,      /* CM Service Abort */
17725     dtap_mm_cm_srvc_req,        /* CM Service Request */
17726     dtap_mm_cm_srvc_prompt,     /* CM Service Prompt */
17727     NULL,       /* Reserved: was allocated in earlier phases of the protocol */
17728     dtap_mm_cm_reestab_req,     /* CM Re-establishment Request */
17729     dtap_mm_abort,      /* Abort */
17730     NULL /* no associated data */,      /* MM Null */
17731     dtap_mm_mm_status,  /* MM Status */
17732     dtap_mm_mm_info,    /* MM Information */
17733     NULL,       /* NONE */
17734 };
17735
17736 #define NUM_GSM_DTAP_MSG_RR (sizeof(gsm_a_dtap_msg_rr_strings)/sizeof(value_string))
17737 static gint ett_gsm_dtap_msg_rr[NUM_GSM_DTAP_MSG_RR];
17738 static void (*dtap_msg_rr_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17739     NULL,       /* RR Initialisation Request */
17740     NULL,       /* Additional Assignment */
17741     NULL,       /* Immediate Assignment */
17742     NULL,       /* Immediate Assignment Extended */
17743     NULL,       /* Immediate Assignment Reject */
17744
17745     NULL,       /* DTM Assignment Failure */
17746     NULL,       /* DTM Reject */
17747     NULL,       /* DTM Request */
17748     NULL,       /* Main DCCH Assignment Command */
17749     NULL,       /* Packet Assignment Command */
17750
17751     NULL,       /* Ciphering Mode Command */
17752     NULL,       /* Ciphering Mode Complete */
17753
17754     NULL,       /* Configuration Change Command */
17755     NULL,       /* Configuration Change Ack. */
17756     NULL,       /* Configuration Change Reject */
17757
17758     NULL,       /* Assignment Command */
17759     NULL,       /* Assignment Complete */
17760     NULL,       /* Assignment Failure */
17761     dtap_rr_ho_cmd,     /* Handover Command */
17762     NULL,       /* Handover Complete */
17763     NULL,       /* Handover Failure */
17764     NULL,       /* Physical Information */
17765     NULL,       /* DTM Assignment Command */
17766
17767     NULL,       /* RR-cell Change Order */
17768     NULL,       /* PDCH Assignment Command */
17769
17770     NULL,       /* Channel Release */
17771     NULL,       /* Partial Release */
17772     NULL,       /* Partial Release Complete */
17773
17774     NULL,       /* Paging Request Type 1 */
17775     NULL,       /* Paging Request Type 2 */
17776     NULL,       /* Paging Request Type 3 */
17777     dtap_rr_paging_resp,        /* Paging Response */
17778     NULL,       /* Notification/NCH */
17779     NULL,       /* Reserved */
17780     NULL,       /* Notification/Response */
17781
17782     NULL,       /* Reserved */
17783
17784     NULL,       /* Utran Classmark Change  */
17785     NULL,       /* UE RAB Preconfiguration */
17786     NULL,       /* cdma2000 Classmark Change */
17787     NULL,       /* Inter System to UTRAN Handover Command */
17788     NULL,       /* Inter System to cdma2000 Handover Command */
17789
17790     NULL,       /* System Information Type 8 */
17791     NULL,       /* System Information Type 1 */
17792     NULL,       /* System Information Type 2 */
17793     NULL,       /* System Information Type 3 */
17794     NULL,       /* System Information Type 4 */
17795     NULL,       /* System Information Type 5 */
17796     NULL,       /* System Information Type 6 */
17797     NULL,       /* System Information Type 7 */
17798
17799     NULL,       /* System Information Type 2bis */
17800     NULL,       /* System Information Type 2ter */
17801     NULL,       /* System Information Type 2quater */
17802     NULL,       /* System Information Type 5bis */
17803     NULL,       /* System Information Type 5ter */
17804     NULL,       /* System Information Type 9 */
17805     NULL,       /* System Information Type 13 */
17806
17807     NULL,       /* System Information Type 16 */
17808     NULL,       /* System Information Type 17 */
17809
17810     NULL,       /* System Information Type 18 */
17811     NULL,       /* System Information Type 19 */
17812     NULL,       /* System Information Type 20 */
17813
17814     NULL,       /* Channel Mode Modify */
17815     dtap_rr_rr_status,  /* RR Status */
17816     NULL,       /* Channel Mode Modify Acknowledge */
17817     NULL,       /* Frequency Redefinition */
17818     NULL,       /* Measurement Report */
17819     NULL,       /* Classmark Change */
17820     NULL,       /* Classmark Enquiry */
17821     NULL,       /* Extended Measurement Report */
17822     NULL,       /* Extended Measurement Order */
17823     NULL,       /* GPRS Suspension Request */
17824
17825     NULL,       /* VGCS Uplink Grant */
17826     NULL,       /* Uplink Release */
17827     NULL,       /* Reserved */
17828     NULL,       /* Uplink Busy */
17829     NULL,       /* Talker Indication */
17830
17831     NULL,       /* UTRAN Classmark Change/Handover To UTRAN Command */  /* spec conflict */
17832
17833     NULL,       /* Application Information */
17834
17835     NULL,       /* NONE */
17836 };
17837
17838 #define NUM_GSM_DTAP_MSG_CC (sizeof(gsm_a_dtap_msg_cc_strings)/sizeof(value_string))
17839 static gint ett_gsm_dtap_msg_cc[NUM_GSM_DTAP_MSG_CC];
17840 static void (*dtap_msg_cc_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17841     dtap_cc_alerting,   /* Alerting */
17842     dtap_cc_call_conf,  /* Call Confirmed */
17843     dtap_cc_call_proceed,       /* Call Proceeding */
17844     dtap_cc_connect,    /* Connect */
17845     NULL /* no associated data */,      /* Connect Acknowledge */
17846     dtap_cc_emerg_setup,        /* Emergency Setup */
17847     dtap_cc_progress,   /* Progress */
17848     dtap_cc_cc_est,     /* CC-Establishment */
17849     dtap_cc_cc_est_conf,        /* CC-Establishment Confirmed */
17850     dtap_cc_recall,     /* Recall */
17851     dtap_cc_start_cc,   /* Start CC */
17852     dtap_cc_setup,      /* Setup */
17853     dtap_cc_modify,     /* Modify */
17854     dtap_cc_modify_complete,    /* Modify Complete */
17855     dtap_cc_modify_rej, /* Modify Reject */
17856     dtap_cc_user_info,  /* User Information */
17857     NULL /* no associated data */,      /* Hold */
17858     NULL /* no associated data */,      /* Hold Acknowledge */
17859     dtap_cc_hold_rej,   /* Hold Reject */
17860     NULL /* no associated data */,      /* Retrieve */
17861     NULL /* no associated data */,      /* Retrieve Acknowledge */
17862     dtap_cc_retrieve_rej,       /* Retrieve Reject */
17863     dtap_cc_disconnect, /* Disconnect */
17864     dtap_cc_release,    /* Release */
17865     dtap_cc_release_complete,   /* Release Complete */
17866     dtap_cc_congestion_control, /* Congestion Control */
17867     dtap_cc_notify,     /* Notify */
17868     dtap_cc_status,     /* Status */
17869     NULL /* no associated data */,      /* Status Enquiry */
17870     dtap_cc_start_dtmf, /* Start DTMF */
17871     NULL /* no associated data */,      /* Stop DTMF */
17872     NULL /* no associated data */,      /* Stop DTMF Acknowledge */
17873     dtap_cc_start_dtmf_ack,     /* Start DTMF Acknowledge */
17874     dtap_cc_start_dtmf_rej,     /* Start DTMF Reject */
17875     dtap_cc_facility,   /* Facility */
17876     NULL,       /* NONE */
17877 };
17878
17879 #define NUM_GSM_DTAP_MSG_GMM (sizeof(gsm_a_dtap_msg_gmm_strings)/sizeof(value_string))
17880 static gint ett_gsm_dtap_msg_gmm[NUM_GSM_DTAP_MSG_GMM];
17881 static void (*dtap_msg_gmm_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17882     dtap_gmm_attach_req,                /* Attach Request */
17883     dtap_gmm_attach_acc,                /* Attach Accept */
17884     dtap_gmm_attach_com,                /* Attach Complete */
17885     dtap_gmm_attach_rej,                /* Attach Reject */
17886     dtap_gmm_detach_req,                /* Detach Request */
17887     dtap_gmm_detach_acc,                /* Detach Accept */
17888     dtap_gmm_rau_req,                   /* Routing Area Update Request */
17889     dtap_gmm_rau_acc,                   /* Routing Area Update Accept */
17890     dtap_gmm_rau_com,                   /* Routing Area Update Complete */
17891     dtap_gmm_rau_rej,                   /* Routing Area Update Reject */
17892     dtap_gmm_service_req,               /* Service Request */
17893     dtap_gmm_service_acc,               /* Service Accept */
17894     dtap_gmm_service_rej,               /* Service Reject */
17895     dtap_gmm_ptmsi_realloc_cmd, /* P-TMSI Reallocation Command */
17896     dtap_gmm_ptmsi_realloc_com, /* P-TMSI Reallocation Complete */
17897     dtap_gmm_auth_ciph_req,             /* Authentication and Ciphering Req */
17898     dtap_gmm_auth_ciph_resp,    /* Authentication and Ciphering Resp */
17899     dtap_gmm_auth_ciph_rej,             /* Authentication and Ciphering Rej */
17900     dtap_gmm_auth_ciph_fail,    /* Authentication and Ciphering Failure */
17901     dtap_gmm_ident_req,                 /* Identity Request */
17902     dtap_gmm_ident_res,                 /* Identity Response */
17903     dtap_gmm_status,                    /* GMM Status */
17904     dtap_gmm_information,               /* GMM Information */
17905     NULL,       /* NONE */
17906 };
17907
17908 #define NUM_GSM_DTAP_MSG_SMS (sizeof(gsm_a_dtap_msg_sms_strings)/sizeof(value_string))
17909 static gint ett_gsm_dtap_msg_sms[NUM_GSM_DTAP_MSG_SMS];
17910 static void (*dtap_msg_sms_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17911     dtap_sms_cp_data,   /* CP-DATA */
17912     NULL /* no associated data */,      /* CP-ACK */
17913     dtap_sms_cp_error,  /* CP-ERROR */
17914     NULL,       /* NONE */
17915 };
17916
17917 #define NUM_GSM_DTAP_MSG_SM (sizeof(gsm_a_dtap_msg_sm_strings)/sizeof(value_string))
17918 static gint ett_gsm_dtap_msg_sm[NUM_GSM_DTAP_MSG_SM];
17919 static void (*dtap_msg_sm_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17920     dtap_sm_act_pdp_req,                /* Activate PDP Context Request */
17921     dtap_sm_act_pdp_acc,                /* Activate PDP Context Accept */
17922     dtap_sm_act_pdp_rej,                /* Activate PDP Context Reject */
17923     dtap_sm_req_pdp_act,                /* Request PDP Context Activation */
17924     dtap_sm_req_pdp_act_rej,    /* Request PDP Context Activation rej. */
17925     dtap_sm_deact_pdp_req,              /* Deactivate PDP Context Request */
17926     dtap_sm_deact_pdp_acc,              /* Deactivate PDP Context Accept */
17927     dtap_sm_mod_pdp_req_net,    /* Modify PDP Context Request(Network to MS direction) */
17928     dtap_sm_mod_pdp_acc_ms,             /* Modify PDP Context Accept (MS to network direction) */
17929     dtap_sm_mod_pdp_req_ms,             /* Modify PDP Context Request(MS to network direction) */
17930     dtap_sm_mod_pdp_acc_net,    /* Modify PDP Context Accept (Network to MS direction) */
17931     dtap_sm_mod_pdp_rej,                /* Modify PDP Context Reject */
17932     dtap_sm_act_sec_pdp_req,    /* Activate Secondary PDP Context Request */
17933     dtap_sm_act_sec_pdp_acc,    /* Activate Secondary PDP Context Accept */
17934     dtap_sm_act_sec_pdp_rej,    /* Activate Secondary PDP Context Reject */
17935     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17936     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17937     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17938     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17939     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17940     dtap_sm_status,                             /* SM Status */
17941                                                                 /* Activate MBMS Context Request */
17942                                                                 /* Activate MBMS Context Accept */
17943                                                                 /* Activate MBMS Context Reject */
17944                                                                 /* Request MBMS Context Activation */
17945                                                                 /* Request MBMS Context Activation Reject */
17946     NULL,       /* NONE */
17947 };
17948
17949 #define NUM_GSM_DTAP_MSG_SS (sizeof(gsm_a_dtap_msg_ss_strings)/sizeof(value_string))
17950 static gint ett_gsm_dtap_msg_ss[NUM_GSM_DTAP_MSG_SS];
17951 static void (*dtap_msg_ss_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17952     dtap_cc_release_complete,   /* Release Complete */
17953     dtap_cc_facility,   /* Facility */
17954     dtap_ss_register,   /* Register */
17955     NULL,       /* NONE */
17956 };
17957
17958 #define NUM_GSM_RP_MSG (sizeof(gsm_rp_msg_strings)/sizeof(value_string))
17959 static gint ett_gsm_rp_msg[NUM_GSM_RP_MSG];
17960 static void (*rp_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17961     rp_data_ms_n,       /* RP-DATA (MS to Network) */
17962     rp_data_n_ms,       /* RP-DATA (Network to MS */
17963     rp_ack_ms_n,        /* RP-ACK (MS to Network) */
17964     rp_ack_n_ms,        /* RP-ACK (Network to MS) */
17965     rp_error_ms_n,      /* RP-ERROR (MS to Network) */
17966     rp_error_n_ms,      /* RP-ERROR (Network to MS) */
17967     rp_smma,    /* RP-SMMA (MS to Network) */
17968     NULL,       /* NONE */
17969 };
17970
17971 /* GENERIC DISSECTOR FUNCTIONS */
17972
17973 static void
17974 dissect_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
17975 {
17976     guint8      oct;
17977     guint32     offset, saved_offset;
17978     guint32     len;
17979     gint        idx;
17980     proto_item  *rp_item = NULL;
17981     proto_tree  *rp_tree = NULL;
17982     const gchar *str;
17983
17984
17985     if (check_col(pinfo->cinfo, COL_INFO))
17986     {
17987         col_append_str(pinfo->cinfo, COL_INFO, "(RP) ");
17988     }
17989
17990     /*
17991      * In the interest of speed, if "tree" is NULL, don't do any work
17992      * not necessary to generate protocol tree items.
17993      */
17994     if (!tree)
17995     {
17996         return;
17997     }
17998
17999     offset = 0;
18000     saved_offset = offset;
18001
18002     g_pinfo = pinfo;
18003     g_tree = tree;
18004
18005     len = tvb_length(tvb);
18006
18007     /*
18008      * add RP message name
18009      */
18010     oct = tvb_get_guint8(tvb, offset++);
18011
18012     str = match_strval_idx((guint32) oct, gsm_rp_msg_strings, &idx);
18013
18014     /*
18015      * create the protocol tree
18016      */
18017     if (str == NULL)
18018     {
18019         rp_item =
18020             proto_tree_add_protocol_format(tree, proto_a_rp, tvb, 0, len,
18021                 "GSM A-I/F RP - Unknown RP Message Type (0x%02x)",
18022                 oct);
18023
18024         rp_tree = proto_item_add_subtree(rp_item, ett_rp_msg);
18025     }
18026     else
18027     {
18028         rp_item =
18029             proto_tree_add_protocol_format(tree, proto_a_rp, tvb, 0, -1,
18030                 "GSM A-I/F RP - %s",
18031                 str);
18032
18033         rp_tree = proto_item_add_subtree(rp_item, ett_gsm_rp_msg[idx]);
18034
18035         if (check_col(pinfo->cinfo, COL_INFO))
18036         {
18037             col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", str);
18038         }
18039     }
18040
18041     /*
18042      * add RP message name
18043      */
18044     proto_tree_add_uint_format(rp_tree, hf_gsm_a_rp_msg_type,
18045                 tvb, saved_offset, 1, oct, "Message Type %s", str ? str : "(Unknown)");
18046
18047     if (str == NULL) return;
18048
18049     if ((len - offset) <= 0) return;
18050
18051     /*
18052      * decode elements
18053      */
18054     if (rp_msg_fcn[idx] == NULL)
18055     {
18056         proto_tree_add_text(rp_tree,
18057             tvb, offset, len - offset,
18058             "Message Elements");
18059     }
18060     else
18061     {
18062         (*rp_msg_fcn[idx])(tvb, rp_tree, offset, len - offset);
18063     }
18064 }
18065
18066
18067 void
18068 dissect_bssmap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
18069 {
18070     static gsm_a_tap_rec_t      tap_rec[4];
18071     static gsm_a_tap_rec_t      *tap_p;
18072     static int                  tap_current=0;
18073     guint8      oct;
18074     guint32     offset, saved_offset;
18075     guint32     len;
18076     gint        idx;
18077     proto_item  *bssmap_item = NULL;
18078     proto_tree  *bssmap_tree = NULL;
18079     const gchar *str;
18080
18081
18082     if (check_col(pinfo->cinfo, COL_INFO))
18083     {
18084         col_append_str(pinfo->cinfo, COL_INFO, "(BSSMAP) ");
18085     }
18086
18087     /*
18088      * set tap record pointer
18089      */
18090     tap_current++;
18091     if (tap_current == 4)
18092     {
18093         tap_current = 0;
18094     }
18095     tap_p = &tap_rec[tap_current];
18096
18097
18098     offset = 0;
18099     saved_offset = offset;
18100
18101     g_pinfo = pinfo;
18102     g_tree = tree;
18103
18104     len = tvb_length(tvb);
18105
18106     /*
18107      * add BSSMAP message name
18108      */
18109     oct = tvb_get_guint8(tvb, offset++);
18110
18111     str = match_strval_idx((guint32) oct, gsm_a_bssmap_msg_strings, &idx);
18112
18113     /*
18114      * create the protocol tree
18115      */
18116     if (str == NULL)
18117     {
18118         bssmap_item =
18119             proto_tree_add_protocol_format(tree, proto_a_bssmap, tvb, 0, len,
18120                 "GSM A-I/F BSSMAP - Unknown BSSMAP Message Type (0x%02x)",
18121                 oct);
18122
18123         bssmap_tree = proto_item_add_subtree(bssmap_item, ett_bssmap_msg);
18124     }
18125     else
18126     {
18127         bssmap_item =
18128             proto_tree_add_protocol_format(tree, proto_a_bssmap, tvb, 0, -1,
18129                 "GSM A-I/F BSSMAP - %s",
18130                 str);
18131
18132         bssmap_tree = proto_item_add_subtree(bssmap_item, ett_gsm_bssmap_msg[idx]);
18133
18134         if (check_col(pinfo->cinfo, COL_INFO))
18135         {
18136             col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", str);
18137         }
18138
18139     /*
18140      * add BSSMAP message name
18141      */
18142     proto_tree_add_uint_format(bssmap_tree, hf_gsm_a_bssmap_msg_type,
18143         tvb, saved_offset, 1, oct, "Message Type %s",str);
18144     }
18145
18146     tap_p->pdu_type = BSSAP_PDU_TYPE_BSSMAP;
18147     tap_p->message_type = oct;
18148
18149     tap_queue_packet(gsm_a_tap, pinfo, tap_p);
18150
18151     if (str == NULL) return;
18152
18153     if ((len - offset) <= 0) return;
18154
18155     /*
18156      * decode elements
18157      */
18158     if (bssmap_msg_fcn[idx] == NULL)
18159     {
18160         proto_tree_add_text(bssmap_tree,
18161             tvb, offset, len - offset,
18162             "Message Elements");
18163     }
18164     else
18165     {
18166         (*bssmap_msg_fcn[idx])(tvb, bssmap_tree, offset, len - offset);
18167     }
18168 }
18169
18170
18171 static void
18172 dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
18173 {
18174     static gsm_a_tap_rec_t      tap_rec[4];
18175     static gsm_a_tap_rec_t      *tap_p;
18176     static int                  tap_current=0;
18177     void                        (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
18178     guint8                      oct;
18179     guint8                      pd;
18180     guint32                     offset;
18181     guint32                     len;
18182     guint32                     oct_1, oct_2;
18183     gint                        idx;
18184     proto_item                  *dtap_item = NULL;
18185     proto_tree                  *dtap_tree = NULL;
18186     proto_item                  *oct_1_item = NULL;
18187     proto_tree                  *pd_tree = NULL;
18188     const gchar                 *msg_str;
18189     gint                        ett_tree;
18190     gint                        ti;
18191     int                         hf_idx;
18192     gboolean                    nsd;
18193
18194
18195     len = tvb_length(tvb);
18196
18197     if (len < 2)
18198     {
18199         /*
18200          * too short to be DTAP
18201          */
18202         call_dissector(data_handle, tvb, pinfo, tree);
18203         return;
18204     }
18205
18206     if (check_col(pinfo->cinfo, COL_INFO))
18207     {
18208         col_append_str(pinfo->cinfo, COL_INFO, "(DTAP) ");
18209     }
18210
18211     /*
18212      * set tap record pointer
18213      */
18214     tap_current++;
18215     if (tap_current == 4)
18216     {
18217         tap_current = 0;
18218     }
18219     tap_p = &tap_rec[tap_current];
18220
18221
18222     offset = 0;
18223     oct_2 = 0;
18224
18225     g_pinfo = pinfo;
18226     g_tree = tree;
18227
18228     /*
18229      * get protocol discriminator
18230      */
18231     oct_1 = tvb_get_guint8(tvb, offset++);
18232
18233     if ((((oct_1 & DTAP_TI_MASK) >> 4) & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
18234     {
18235         /*
18236          * eventhough we don't know if a TI should be in the message yet
18237          * we rely on the TI/SKIP indicator to be 0 to avoid taking this
18238          * octet
18239          */
18240         oct_2 = tvb_get_guint8(tvb, offset++);
18241     }
18242
18243     oct = tvb_get_guint8(tvb, offset);
18244
18245     pd = oct_1 & DTAP_PD_MASK;
18246     ti = -1;
18247     msg_str = NULL;
18248     ett_tree = -1;
18249     hf_idx = -1;
18250     msg_fcn = NULL;
18251     nsd = FALSE;
18252     if (check_col(pinfo->cinfo, COL_INFO))
18253     {
18254         col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",val_to_str(pd,gsm_a_pd_short_str_vals,"unknown"));
18255     }
18256
18257     /*
18258      * octet 1
18259      */
18260     switch (pd)
18261     {
18262     case 3:
18263         msg_str = match_strval_idx((guint32) (oct & DTAP_CC_IEI_MASK), gsm_a_dtap_msg_cc_strings, &idx);
18264         ett_tree = ett_gsm_dtap_msg_cc[idx];
18265         hf_idx = hf_gsm_a_dtap_msg_cc_type;
18266         msg_fcn = dtap_msg_cc_fcn[idx];
18267         ti = (oct_1 & DTAP_TI_MASK) >> 4;
18268         nsd = TRUE;
18269         break;
18270
18271     case 5:
18272         msg_str = match_strval_idx((guint32) (oct & DTAP_MM_IEI_MASK), gsm_a_dtap_msg_mm_strings, &idx);
18273         ett_tree = ett_gsm_dtap_msg_mm[idx];
18274         hf_idx = hf_gsm_a_dtap_msg_mm_type;
18275         msg_fcn = dtap_msg_mm_fcn[idx];
18276         nsd = TRUE;
18277         break;
18278
18279     case 6:
18280         msg_str = match_strval_idx((guint32) (oct & DTAP_RR_IEI_MASK), gsm_a_dtap_msg_rr_strings, &idx);
18281         ett_tree = ett_gsm_dtap_msg_rr[idx];
18282         hf_idx = hf_gsm_a_dtap_msg_rr_type;
18283         msg_fcn = dtap_msg_rr_fcn[idx];
18284         break;
18285
18286     case 8:
18287         msg_str = match_strval_idx((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx);
18288         ett_tree = ett_gsm_dtap_msg_gmm[idx];
18289         hf_idx = hf_gsm_a_dtap_msg_gmm_type;
18290         msg_fcn = dtap_msg_gmm_fcn[idx];
18291         break;
18292
18293     case 9:
18294         msg_str = match_strval_idx((guint32) (oct & DTAP_SMS_IEI_MASK), gsm_a_dtap_msg_sms_strings, &idx);
18295         ett_tree = ett_gsm_dtap_msg_sms[idx];
18296         hf_idx = hf_gsm_a_dtap_msg_sms_type;
18297         msg_fcn = dtap_msg_sms_fcn[idx];
18298         ti = (oct_1 & DTAP_TI_MASK) >> 4;
18299         break;
18300
18301     case 10:
18302         msg_str = match_strval_idx((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx);
18303         ett_tree = ett_gsm_dtap_msg_sm[idx];
18304         hf_idx = hf_gsm_a_dtap_msg_sm_type;
18305         msg_fcn = dtap_msg_sm_fcn[idx];
18306         ti = (oct_1 & DTAP_TI_MASK) >> 4;
18307         break;
18308
18309     case 11:
18310         msg_str = match_strval_idx((guint32) (oct & DTAP_SS_IEI_MASK), gsm_a_dtap_msg_ss_strings, &idx);
18311         ett_tree = ett_gsm_dtap_msg_ss[idx];
18312         hf_idx = hf_gsm_a_dtap_msg_ss_type;
18313         msg_fcn = dtap_msg_ss_fcn[idx];
18314         ti = (oct_1 & DTAP_TI_MASK) >> 4;
18315         nsd = TRUE;
18316         break;
18317
18318     default:
18319     /* 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 */
18320     return;
18321         break;
18322     }
18323
18324     /*
18325      * create the protocol tree
18326      */
18327     if (msg_str == NULL)
18328     {
18329         dtap_item =
18330             proto_tree_add_protocol_format(tree, proto_a_dtap, tvb, 0, len,
18331                 "GSM A-I/F DTAP - Unknown DTAP Message Type (0x%02x)",
18332                 oct);
18333
18334         dtap_tree = proto_item_add_subtree(dtap_item, ett_dtap_msg);
18335     }
18336     else
18337     {
18338         dtap_item =
18339             proto_tree_add_protocol_format(tree, proto_a_dtap, tvb, 0, -1,
18340                 "GSM A-I/F DTAP - %s",
18341                 msg_str);
18342
18343         dtap_tree = proto_item_add_subtree(dtap_item, ett_tree);
18344
18345         if (check_col(pinfo->cinfo, COL_INFO))
18346         {
18347             col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
18348         }
18349     }
18350
18351     oct_1_item =
18352         proto_tree_add_text(dtap_tree,
18353             tvb, 0, 1,
18354             "Protocol Discriminator: %s",
18355             val_to_str(pd, protocol_discriminator_vals, "Unknown (%u)"));
18356
18357     pd_tree = proto_item_add_subtree(oct_1_item, ett_dtap_oct_1);
18358
18359     if (ti == -1)
18360     {
18361         proto_tree_add_item(pd_tree, hf_gsm_a_skip_ind, tvb, 0, 1, FALSE);
18362     }
18363     else
18364     {
18365         other_decode_bitfield_value(a_bigbuf, oct_1, 0x80, 8);
18366         proto_tree_add_text(pd_tree,
18367             tvb, 0, 1,
18368             "%s :  TI flag: %s",
18369             a_bigbuf,
18370             ((oct_1 & 0x80) ?  "allocated by receiver" : "allocated by sender"));
18371
18372         if ((ti & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
18373         {
18374             /* ti is extended to next octet */
18375
18376             other_decode_bitfield_value(a_bigbuf, oct_1, 0x70, 8);
18377             proto_tree_add_text(pd_tree,
18378                 tvb, 0, 1,
18379                 "%s :  TIO: The TI value is given by the TIE in octet 2",
18380                 a_bigbuf);
18381         }
18382         else
18383         {
18384             other_decode_bitfield_value(a_bigbuf, oct_1, 0x70, 8);
18385             proto_tree_add_text(pd_tree,
18386                 tvb, 0, 1,
18387                 "%s :  TIO: %u",
18388                 a_bigbuf,
18389                 ti & DTAP_TIE_PRES_MASK);
18390         }
18391     }
18392
18393     proto_tree_add_item(pd_tree, hf_gsm_a_L3_protocol_discriminator, tvb, 0, 1, FALSE);
18394
18395     if ((ti != -1) &&
18396         (ti & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
18397     {
18398         proto_tree_add_item(tree, hf_gsm_a_extension, tvb, 1, 1, FALSE);
18399
18400         other_decode_bitfield_value(a_bigbuf, oct_2, DTAP_TIE_MASK, 8);
18401         proto_tree_add_text(pd_tree,
18402             tvb, 1, 1,
18403             "%s :  TIE: %u",
18404             a_bigbuf,
18405             oct_2 & DTAP_TIE_MASK);
18406     }
18407
18408     /*
18409      * N(SD)
18410      */
18411     if ((pinfo->p2p_dir == P2P_DIR_RECV) &&
18412         nsd)
18413     {
18414         /* XXX */
18415     }
18416
18417     /*
18418      * add DTAP message name
18419      */
18420     proto_tree_add_uint_format(dtap_tree, hf_idx,
18421         tvb, offset, 1, oct,
18422         "Message Type %s",msg_str ? msg_str : "(Unknown)");
18423
18424     offset++;
18425
18426     tap_p->pdu_type = BSSAP_PDU_TYPE_DTAP;
18427     tap_p->message_type = (nsd ? (oct & 0x3f) : oct);
18428     tap_p->protocol_disc = pd;
18429
18430     tap_queue_packet(gsm_a_tap, pinfo, tap_p);
18431
18432     if (msg_str == NULL) return;
18433
18434     if ((len - offset) <= 0) return;
18435
18436     /*
18437      * decode elements
18438      */
18439     if (msg_fcn == NULL)
18440     {
18441         proto_tree_add_text(dtap_tree,
18442             tvb, offset, len - offset,
18443             "Message Elements");
18444     }
18445     else
18446     {
18447         (*msg_fcn)(tvb, dtap_tree, offset, len - offset);
18448     }
18449 }
18450
18451
18452 /* Register the protocol with Wireshark */
18453 void
18454 proto_register_gsm_a(void)
18455 {
18456     guint               i;
18457     guint               last_offset;
18458
18459     /* Setup list of header fields */
18460
18461     static hf_register_info hf[] =
18462     {
18463         { &hf_gsm_a_bssmap_msg_type,
18464             { "BSSMAP Message Type",    "gsm_a.bssmap_msgtype",
18465             FT_UINT8, BASE_HEX, VALS(gsm_a_bssmap_msg_strings), 0x0,
18466             "", HFILL }
18467         },
18468         { &hf_gsm_a_dtap_msg_mm_type,
18469             { "DTAP Mobility Management Message Type",  "gsm_a.dtap_msg_mm_type",
18470             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_mm_strings), 0x0,
18471             "", HFILL }
18472         },
18473         { &hf_gsm_a_dtap_msg_rr_type,
18474             { "DTAP Radio Resources Management Message Type",   "gsm_a.dtap_msg_rr_type",
18475             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_rr_strings), 0x0,
18476             "", HFILL }
18477         },
18478         { &hf_gsm_a_dtap_msg_cc_type,
18479             { "DTAP Call Control Message Type", "gsm_a.dtap_msg_cc_type",
18480             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_cc_strings), 0x0,
18481             "", HFILL }
18482         },
18483         { &hf_gsm_a_dtap_msg_gmm_type,
18484             { "DTAP GPRS Mobility Management Message Type",     "gsm_a.dtap_msg_gmm_type",
18485             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_gmm_strings), 0x0,
18486             "", HFILL }
18487         },
18488         { &hf_gsm_a_dtap_msg_sms_type,
18489             { "DTAP Short Message Service Message Type",        "gsm_a.dtap_msg_sms_type",
18490             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_sms_strings), 0x0,
18491             "", HFILL }
18492         },
18493         { &hf_gsm_a_dtap_msg_sm_type,
18494             { "DTAP GPRS Session Management Message Type",      "gsm_a.dtap_msg_sm_type",
18495             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_sm_strings), 0x0,
18496             "", HFILL }
18497         },
18498         { &hf_gsm_a_dtap_msg_ss_type,
18499             { "DTAP Non call Supplementary Service Message Type",       "gsm_a.dtap_msg_ss_type",
18500             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_ss_strings), 0x0,
18501             "", HFILL }
18502         },
18503         { &hf_gsm_a_rp_msg_type,
18504             { "RP Message Type",        "gsm_a.rp_msg_type",
18505             FT_UINT8, BASE_HEX, VALS(gsm_rp_msg_strings), 0x0,
18506             "", HFILL }
18507         },
18508         { &hf_gsm_a_bssmap_elem_id,
18509             { "Element ID",     "gsm_a_bssmap.elem_id",
18510             FT_UINT8, BASE_DEC, NULL, 0,
18511             "", HFILL }
18512         },
18513         { &hf_gsm_a_dtap_elem_id,
18514             { "Element ID",     "gsm_a_dtap.elem_id",
18515             FT_UINT8, BASE_DEC, NULL, 0,
18516             "", HFILL }
18517         },
18518         { &hf_gsm_a_length,
18519             { "Length",         "gsm_a.len",
18520             FT_UINT8, BASE_DEC, NULL, 0,
18521             "", HFILL }
18522         },
18523         { &hf_gsm_a_none,
18524             { "Sub tree",       "gsm_a.none",
18525             FT_NONE, 0, 0, 0,
18526             "", HFILL }
18527         },
18528         { &hf_gsm_a_imsi,
18529             { "IMSI",   "gsm_a.imsi",
18530             FT_STRING, BASE_DEC, 0, 0,
18531             "", HFILL }
18532         },
18533         { &hf_gsm_a_tmsi,
18534             { "TMSI/P-TMSI",    "gsm_a.tmsi",
18535             FT_UINT32, BASE_HEX, 0, 0x0,
18536             "", HFILL }
18537         },
18538         { &hf_gsm_a_imei,
18539             { "IMEI",   "gsm_a.imei",
18540             FT_STRING, BASE_DEC, 0, 0,
18541             "", HFILL }
18542         },
18543         { &hf_gsm_a_imeisv,
18544             { "IMEISV", "gsm_a.imeisv",
18545             FT_STRING, BASE_DEC, 0, 0,
18546             "", HFILL }
18547         },
18548         { &hf_gsm_a_cld_party_bcd_num,
18549             { "Called Party BCD Number",        "gsm_a.cld_party_bcd_num",
18550             FT_STRING, BASE_DEC, 0, 0,
18551             "", HFILL }
18552         },
18553         { &hf_gsm_a_clg_party_bcd_num,
18554             { "Calling Party BCD Number",       "gsm_a.clg_party_bcd_num",
18555             FT_STRING, BASE_DEC, 0, 0,
18556             "", HFILL }
18557         },
18558         { &hf_gsm_a_cell_ci,
18559             { "Cell CI",        "gsm_a.cell_ci",
18560             FT_UINT16, BASE_HEX_DEC, 0, 0x0,
18561             "", HFILL }
18562         },
18563         { &hf_gsm_a_cell_lac,
18564             { "Cell LAC",       "gsm_a.cell_lac",
18565             FT_UINT16, BASE_HEX_DEC, 0, 0x0,
18566             "", HFILL }
18567         },
18568         { &hf_gsm_a_dlci_cc,
18569             { "Control Channel", "bssap.dlci.cc",
18570             FT_UINT8, BASE_HEX, VALS(bssap_cc_values), 0xc0,
18571             "", HFILL}
18572         },
18573         { &hf_gsm_a_dlci_spare,
18574             { "Spare", "bssap.dlci.spare",
18575             FT_UINT8, BASE_HEX, NULL, 0x38,
18576             "", HFILL}
18577         },
18578         { &hf_gsm_a_dlci_sapi,
18579             { "SAPI", "bssap.dlci.sapi",
18580             FT_UINT8, BASE_HEX, VALS(bssap_sapi_values), 0x07,
18581             "", HFILL}
18582         },
18583         { &hf_gsm_a_bssmap_cause,
18584             { "BSSMAP Cause",   "gsm_a_bssmap.cause",
18585             FT_UINT8, BASE_HEX, 0, 0x0,
18586             "", HFILL }
18587         },
18588         { &hf_gsm_a_dtap_cause,
18589             { "DTAP Cause",     "gsm_a_dtap.cause",
18590             FT_UINT8, BASE_HEX, 0, 0x0,
18591             "", HFILL }
18592         },
18593         { &hf_gsm_a_MSC_rev,
18594                 { "Revision Level","gsm_a.MSC2_rev",
18595                 FT_UINT8,BASE_DEC,  VALS(gsm_a_msc_rev_vals), 0x60,          
18596                 "Revision level", HFILL }
18597         },
18598         { &hf_gsm_a_ES_IND,
18599                 { "ES IND","gsm_a.MSC2_rev",
18600                 FT_UINT8,BASE_DEC,  VALS(ES_IND_vals), 0x10,          
18601                         "ES IND", HFILL }
18602         },
18603     { &hf_gsm_a_qos_traffic_cls,
18604       { "Traffic class", "gsm_a.qos.traffic_cls",
18605         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0xe0,
18606         "Traffic class", HFILL }},
18607     { &hf_gsm_a_qos_del_order,
18608       { "Delivery order", "gsm_a.qos.del_order",
18609         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0x18,
18610         "Delivery order", HFILL }},
18611     { &hf_gsm_a_qos_del_of_err_sdu,
18612       { "Delivery of erroneous SDUs", "gsm_a.qos.del_of_err_sdu",
18613         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_del_of_err_sdu_vals), 0x03,
18614         "Delivery of erroneous SDUs", HFILL }},
18615     { &hf_gsm_a_qos_ber,
18616       { "Residual Bit Error Rate (BER)", "gsm_a.qos.ber",
18617         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_ber_vals), 0xf0,
18618         "Residual Bit Error Rate (BER)", HFILL }},
18619     { &hf_gsm_a_qos_sdu_err_rat,
18620       { "SDU error ratio", "gsm_a.qos.sdu_err_rat",
18621         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_sdu_err_rat_vals), 0x0f,
18622         "SDU error ratio", HFILL }},
18623     { &hf_gsm_a_qos_traff_hdl_pri,
18624       { "Traffic handling priority", "gsm_a.qos.traff_hdl_pri",
18625         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traff_hdl_pri_vals), 0x03,
18626         "Traffic handling priority", HFILL }},
18627         { &hf_gsm_a_A5_1_algorithm_sup,
18628                 { "A5/1 algorithm supported","gsm_a.MSC2_rev",
18629                 FT_UINT8,BASE_DEC,  VALS(A5_1_algorithm_sup_vals), 0x08,          
18630                 "A5/1 algorithm supported ", HFILL }
18631         },
18632         { &hf_gsm_a_RF_power_capability,
18633                 { "RF Power Capability","gsm_a.MSC2_rev",
18634                 FT_UINT8,BASE_DEC,  VALS(RF_power_capability_vals), 0x07,          
18635                 "RF Power Capability", HFILL }
18636         },
18637         { &hf_gsm_a_ps_sup_cap,
18638                 { "PS capability (pseudo-synchronization capability)","gsm_a.ps_sup_cap",
18639                 FT_UINT8,BASE_DEC,  VALS(ps_sup_cap_vals), 0x40,          
18640                 "PS capability (pseudo-synchronization capability)", HFILL }
18641         },
18642         { &hf_gsm_a_SS_screening_indicator,
18643                 { "SS Screening Indicator","gsm_a.SS_screening_indicator",
18644                 FT_UINT8,BASE_DEC,  VALS(SS_screening_indicator_vals), 0x30,          
18645                 "SS Screening Indicator", HFILL }
18646         },
18647         { &hf_gsm_a_SM_capability,
18648                 { "SM capability (MT SMS pt to pt capability)","gsm_a.SM_cap",
18649                 FT_UINT8,BASE_DEC,  VALS(SM_capability_vals), 0x08,          
18650                 "SM capability (MT SMS pt to pt capability)", HFILL }
18651         },
18652         { &hf_gsm_a_VBS_notification_rec,
18653                 { "VBS notification reception ","gsm_a.VBS_notification_rec",
18654                 FT_UINT8,BASE_DEC,  VALS(VBS_notification_rec_vals), 0x04,          
18655                 "VBS notification reception ", HFILL }
18656         },
18657         { &hf_gsm_a_VGCS_notification_rec,
18658                 { "VGCS notification reception ","gsm_a.VGCS_notification_rec",
18659                 FT_UINT8,BASE_DEC,  VALS(VGCS_notification_rec_vals), 0x02,          
18660                 "VGCS notification reception", HFILL }
18661         },
18662         { &hf_gsm_a_FC_frequency_cap,
18663                 { "FC Frequency Capability","gsm_a.FC_frequency_cap",
18664                 FT_UINT8,BASE_DEC,  VALS(FC_frequency_cap_vals), 0x01,          
18665                 "FC Frequency Capability", HFILL }
18666         },
18667         { &hf_gsm_a_CM3,
18668                 { "CM3","gsm_a.CM3",
18669                 FT_UINT8,BASE_DEC,  VALS(CM3_vals), 0x80,          
18670                 "CM3", HFILL }
18671         },
18672         { &hf_gsm_a_LCS_VA_cap,
18673                 { "LCS VA capability (LCS value added location request notification capability) ","gsm_a.LCS_VA_cap",
18674                 FT_UINT8,BASE_DEC,  VALS(LCS_VA_cap_vals), 0x20,          
18675                 "LCS VA capability (LCS value added location request notification capability) ", HFILL }
18676         },
18677         { &hf_gsm_a_UCS2_treatment,
18678                 { "UCS2 treatment ","gsm_a.UCS2_treatment",
18679                 FT_UINT8,BASE_DEC,  VALS(UCS2_treatment_vals), 0x10,          
18680                 "UCS2 treatment ", HFILL }
18681         },
18682         { &hf_gsm_a_SoLSA,
18683                 { "SoLSA","gsm_a.SoLSA",
18684                 FT_UINT8,BASE_DEC,  VALS(SoLSA_vals), 0x08,          
18685                 "SoLSA", HFILL }
18686         },
18687         { &hf_gsm_a_CMSP,
18688                 { "CMSP: CM Service Prompt","gsm_a.CMSP",
18689                 FT_UINT8,BASE_DEC,  VALS(CMSP_vals), 0x04,          
18690                 "CMSP: CM Service Prompt", HFILL }
18691         },
18692         { &hf_gsm_a_A5_3_algorithm_sup,
18693                 { "A5/3 algorithm supported","gsm_a.A5_3_algorithm_sup",
18694                 FT_UINT8,BASE_DEC,  VALS(A5_3_algorithm_sup_vals), 0x02,          
18695                 "A5/3 algorithm supported", HFILL }
18696         },
18697         { &hf_gsm_a_A5_2_algorithm_sup,
18698                 { "A5/2 algorithm supported","gsm_a.A5_2_algorithm_sup",
18699                 FT_UINT8,BASE_DEC,  VALS(A5_2_algorithm_sup_vals), 0x01,          
18700                 "A5/2 algorithm supported", HFILL }
18701         },
18702         { &hf_gsm_a_mobile_identity_type,
18703                 { "Mobile Identity Type","gsm_a.ie.mobileid.type",
18704                 FT_UINT8, BASE_DEC, VALS(mobile_identity_type_vals), 0x07,          
18705                 "Mobile Identity Type", HFILL }
18706         },
18707         { &hf_gsm_a_odd_even_ind,
18708                 { "Odd/even indication","gsm_a.oddevenind",
18709                 FT_UINT8, BASE_DEC, oddevenind_vals, 0x08,          
18710                 "Mobile Identity", HFILL }
18711         },
18712         { &hf_gsm_a_L3_protocol_discriminator,
18713                 { "Protocol discriminator","gsm_a.L3_protocol_discriminator",
18714                 FT_UINT8,BASE_DEC,  VALS(protocol_discriminator_vals), 0x0f,          
18715                 "Protocol discriminator", HFILL }
18716         },
18717         { &hf_gsm_a_skip_ind,
18718                 { "Skip Indicator",           "gsm_a.skip.ind",
18719                 FT_UINT8, BASE_DEC, NULL, 0xf0,          
18720                 "Skip Indicator", HFILL }
18721         },
18722         { &hf_gsm_a_bcc,
18723                 { "BCC","gsm_a.bcc",
18724                 FT_UINT8,BASE_DEC,  NULL, 0x07,          
18725                 "BCC", HFILL }
18726         },
18727         { &hf_gsm_a_ncc,
18728                 { "NCC","gsm_a.ncc",
18729                 FT_UINT8,BASE_DEC,  NULL, 0x38,          
18730                 "NCC", HFILL }
18731         },
18732         { &hf_gsm_a_bcch_arfcn,
18733                 { "BCCH ARFCN(RF channel number)","gsm_a.bcch_arfcn",
18734                 FT_UINT16,BASE_DEC,  NULL, 0x0,          
18735                 "BCCH ARFCN", HFILL }
18736         },
18737         { &hf_gsm_a_rr_ho_ref_val,
18738                 { "Handover reference value","gsm_a.rr.ho_ref_val",
18739                 FT_UINT8,BASE_DEC,  NULL, 0x0,          
18740                 "Handover reference value", HFILL }
18741         },
18742         { &hf_gsm_a_b7spare,
18743                 { "Spare","gsm_a.spareb7",
18744                 FT_UINT8,BASE_DEC,  NULL, 0x40,
18745                 "Spare", HFILL }
18746         },
18747         { &hf_gsm_a_b8spare,
18748                 { "Spare","gsm_a.spareb8",
18749                 FT_UINT8,BASE_DEC,  NULL, 0x80,          
18750                 "Spare", HFILL }
18751         },
18752         { &hf_gsm_a_rr_pow_cmd_atc,
18753                 { "Spare","gsm_a.rr.pow_cmd_atc",
18754                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_atc_value), 0x80,          
18755                 "Spare", HFILL }
18756         },
18757         { &hf_gsm_a_rr_pow_cmd_epc,
18758                 { "EPC_mode","gsm_a.rr.pow_cmd_epc",
18759                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_epc_value), 0x40,          
18760                 "EPC_mode", HFILL }
18761         },
18762         { &hf_gsm_a_rr_pow_cmd_fpcepc,
18763                 { "FPC_EPC","gsm_a.rr.pow_cmd_fpcepc",
18764                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_fpcepc_value), 0x20,          
18765                 "FPC_EPC", HFILL }
18766         },
18767         { &hf_gsm_a_rr_pow_cmd_powlev,
18768                 { "POWER LEVEL","sm_a.rr.pow_cmd_pow",
18769                 FT_UINT8,BASE_DEC,  NULL, 0x1f,          
18770                 "POWER LEVEL", HFILL }
18771         },
18772         { &hf_gsm_a_rr_sync_ind_nci,
18773                 { "Normal cell indication(NCI)","gsm_a.rr.sync_ind_nci",
18774                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_sync_ind_nci_value), 0x08,          
18775                 "Normal cell indication(NCI)", HFILL }
18776         },
18777         { &hf_gsm_a_rr_sync_ind_rot,
18778                 { "Report Observed Time Difference(ROT)","gsm_a.rr.sync_ind_rot",
18779                 FT_BOOLEAN,8,  TFS(&sm_a_rr_sync_ind_rot_value), 0x04,          
18780                 "Report Observed Time Difference(ROT)", HFILL }
18781         },
18782         { &hf_gsm_a_rr_sync_ind_si,
18783                 { "Synchronization indication(SI)","gsm_a.rr_sync_ind_si",
18784                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_sync_ind_si_vals), 0x03,          
18785                 "Synchronization indication(SI)", HFILL }
18786         },
18787         { &hf_gsm_a_rr_format_id,
18788                 { "Format Identifier","gsm_a.rr_format_id",
18789                 FT_UINT8,BASE_HEX,  VALS(gsm_a_rr_freq_list_format_id_vals), 0xce,          
18790                 "Format Identifier", HFILL }
18791         },
18792         { &hf_gsm_a_rr_channel_mode,
18793                 { "Channel Mode","gsm_a.rr.channel_mode",
18794                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_mode_vals), 0x0,          
18795                 "Channel Mode", HFILL }
18796         },
18797         { &hf_gsm_a_rr_channel_mode2,
18798                 { "Channel Mode 2","gsm_a.rr.channel_mode2",
18799                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_mode2_vals), 0x0,          
18800                 "Channel Mode 2", HFILL }
18801         },
18802         { &hf_gsm_a_rr_sc,
18803                 { "SC","gsm_a.rr.SC",
18804                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_sc_vals), 0x1,          
18805                 "SC", HFILL }
18806         },
18807         { &hf_gsm_a_algorithm_id,
18808                 { "Algorithm identifier","gsm_a.algorithm_identifier",
18809                 FT_UINT8,BASE_DEC,  VALS(gsm_a_algorithm_identifier_vals), 0xe,          
18810                 "Algorithm_identifier", HFILL }
18811         },
18812
18813         { &hf_gsm_a_rr_multirate_speech_ver,
18814                 { "Multirate speech version","gsm_a.rr.multirate_speech_ver",
18815                 FT_UINT8,BASE_DEC,  VALS(multirate_speech_ver_vals), 0xe0,          
18816                 "Multirate speech version", HFILL }
18817         },
18818         { &hf_gsm_a_rr_NCSB,
18819                 { "NSCB: Noise Suppression Control Bit","gsm_a.rr.NCSB",
18820                 FT_UINT8,BASE_DEC,  VALS(NSCB_vals), 0x10,          
18821                 "NSCB: Noise Suppression Control Bit", HFILL }
18822         },
18823         { &hf_gsm_a_rr_ICMI,
18824                 { "ICMI: Initial Codec Mode Indicator","gsm_a.rr.ICMI",
18825                 FT_UINT8,BASE_DEC,  VALS(ICMI_vals), 0x8,          
18826                 "ICMI: Initial Codec Mode Indicator", HFILL }
18827         },
18828         { &hf_gsm_a_rr_start_mode,
18829                 { "Start Mode","gsm_a.rr.start_mode",
18830                 FT_UINT8,BASE_DEC,  NULL, 0x3,          
18831                 "Start Mode", HFILL }
18832         },
18833         { &hf_gsm_a_rr_timing_adv,
18834                 { "Timing advance value","gsm_a.rr.timing_adv",
18835                 FT_UINT8,BASE_DEC,  NULL, 0x0,          
18836                 "Timing advance value", HFILL }
18837         },
18838         { &hf_gsm_a_rr_time_diff,
18839                 { "Time difference value","gsm_a.rr.time_diff",
18840                 FT_UINT8,BASE_DEC,  NULL, 0x0,          
18841                 "Time difference value", HFILL }
18842         },
18843         { &hf_gsm_a_rr_tlli,
18844                 { "TLLI","gsm_a.rr.tlli",
18845                 FT_UINT32,BASE_HEX,  NULL, 0x0,          
18846                 "TLLI", HFILL }
18847         },
18848         { &hf_gsm_a_rr_target_mode,
18849                 { "Target mode","gsm_a.rr.target_mode",
18850                 FT_UINT8,BASE_DEC,  NULL, 0xc0,          
18851                 "Target mode", HFILL }
18852         },
18853         { &hf_gsm_a_rr_group_cipher_key_number,
18854                 { "Group cipher key number","gsm_a.rr.Group_cipher_key_number",
18855                 FT_UINT8,BASE_DEC,  NULL, 0x3c,          
18856                 "Group cipher key number", HFILL }
18857         },
18858         { &hf_gsm_a_rr_last_segment,
18859                 { "Last Segment","gsm_a.rr.last_segment",
18860                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_last_segment_value), 0x01,          
18861                 "Last Segment", HFILL }
18862         },
18863         { &hf_gsm_a_gmm_split_on_ccch,
18864                 { "SPLIT on CCCH","gsm_a.gmm.split_on_ccch",
18865                 FT_BOOLEAN,8,  TFS(&gsm_a_gmm_split_on_ccch_value), 0x08,          
18866                 "SPLIT on CCCH", HFILL }
18867         },
18868         { &hf_gsm_a_gmm_non_drx_timer,
18869                 { "Non-DRX timer","gsm_a.gmm.non_drx_timer",
18870                 FT_UINT8,BASE_DEC,  VALS(gsm_a_gmm_non_drx_timer_strings), 0x07,          
18871                 "Non-DRX timer", HFILL }
18872         },
18873         { &hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef,
18874                 { "CN Specific DRX cycle length coefficient","gsm_a.gmm.cn_spec_drs_cycle_len_coef",
18875                 FT_UINT8,BASE_DEC,  VALS(gsm_a_gmm_cn_spec_drs_cycle_len_coef_strings), 0xf0,          
18876                 "CN Specific DRX cycle length coefficient", HFILL }
18877         },
18878         { &hf_gsm_a_rr_RR_cause,
18879                 { "RR cause value","gsm_a.rr.RRcause",
18880                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_RR_cause_vals), 0x0,          
18881                 "RR cause value", HFILL }
18882                 },
18883         { &hf_gsm_a_be_cell_id_disc,
18884                 { "Cell identification discriminator","gsm_a.be.cell_id_disc",
18885                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_cell_id_disc_vals), 0x0f,          
18886                 "Cell identificationdiscriminator", HFILL }
18887         },
18888         { &hf_gsm_a_be_rnc_id,
18889                 { "RNC-ID","gsm_a.be.rnc_id",
18890                 FT_UINT16,BASE_DEC,  NULL, 0x0,          
18891                 "RNC-ID", HFILL }
18892         },
18893         { &hf_gsm_a_rr_cm_cng_msg_req, 
18894                 { "CLASSMARK CHANGE","gsm_a.rr_cm_cng_msg_req",
18895                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x80,          
18896                 "CLASSMARK CHANGE ", HFILL }
18897         },
18898         { &hf_gsm_a_rr_utran_cm_cng_msg_req,
18899                 { "UTRAN CLASSMARK CHANGE","gsm_a.rr_utran_cm_cng_msg_req",
18900                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_utran_cm_cng_msg_req_vals), 0x70,          
18901                 "UTRAN CLASSMARK CHANGE", HFILL }
18902         },
18903         { &hf_gsm_a_rr_cdma200_cm_cng_msg_req,
18904                 { "CDMA2000 CLASSMARK CHANGE ","gsm_a.rr_cdma200_cm_cng_msg_req",
18905                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x08,          
18906                 "CDMA2000 CLASSMARK CHANGE ", HFILL }
18907         },
18908         { &hf_gsm_a_rr_geran_iu_cm_cng_msg_req,
18909                 { "GERAN IU MODE CLASSMARK CHANGE","gsm_a.rr_geran_iu_cm_cng_msg_req",
18910                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x04,          
18911                 "GERAN IU MODE CLASSMARK CHANGE", HFILL }
18912         },
18913         { &hf_gsm_a_rr_chnl_needed_ch1,
18914                 { "Channel 1","gsm_a.rr_chnl_needed_ch1",
18915                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_needed_vals), 0x03,          
18916                 "Channel 1", HFILL }
18917         },
18918         { &hf_gsm_a_rr_chnl_needed_ch2,
18919                 { "Channel 2","gsm_a.rr_chnl_needed_ch1",
18920                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_needed_vals), 0x0c,          
18921                 "Channel 2", HFILL }
18922         },
18923         { &hf_gsm_a_rr_suspension_cause,
18924                 { "Suspension cause value","gsm_a.rr.suspension_cause",
18925                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_suspension_cause_vals), 0x0,          
18926                 "Suspension cause value", HFILL }
18927         },
18928     { &hf_ROS_component,
18929       { "component", "ROS.component",
18930         FT_UINT8, BASE_DEC, VALS(ROS_Component_vals), 0,
18931         "Component", HFILL }},
18932     { &hf_ROS_invoke,
18933       { "invoke", "ROS.invoke",
18934         FT_NONE, BASE_NONE, NULL, 0,
18935         "Component/invoke", HFILL }},
18936     { &hf_ROS_returnResultLast,
18937       { "returnResultLast", "ROS.returnResultLast",
18938         FT_NONE, BASE_NONE, NULL, 0,
18939         "Component/returnResultLast", HFILL }},
18940     { &hf_ROS_returnError,
18941       { "returnError", "ROS.returnError",
18942         FT_NONE, BASE_NONE, NULL, 0,
18943         "Component/returnError", HFILL }},
18944     { &hf_ROS_reject,
18945       { "reject", "ROS.reject",
18946         FT_NONE, BASE_NONE, NULL, 0,
18947         "Component/reject", HFILL }},
18948     { &hf_ROS_invokeID,
18949       { "invokeID", "ROS.invokeID",
18950         FT_UINT32, BASE_DEC, NULL, 0,
18951         "", HFILL }},
18952     { &hf_ROS_linkedID,
18953       { "linkedID", "ROS.linkedID",
18954         FT_UINT32, BASE_DEC, NULL, 0,
18955         "Invoke/linkedID", HFILL }},
18956     { &hf_ROS_opCode,
18957       { "opCode", "ROS.opCode",
18958         FT_UINT32, BASE_DEC, VALS(ROS_OPERATION_vals), 0,
18959         "", HFILL }},
18960     { &hf_ROS_parameter,
18961       { "parameter", "ROS.parameter",
18962         FT_NONE, BASE_NONE, NULL, 0,
18963         "", HFILL }},
18964     { &hf_ROS_resultretres,
18965       { "resultretres", "ROS.resultretres",
18966         FT_NONE, BASE_NONE, NULL, 0,
18967         "ReturnResult/resultretres", HFILL }},
18968     { &hf_ROS_errorCode,
18969       { "errorCode", "ROS.errorCode",
18970         FT_UINT32, BASE_DEC, VALS(ROS_ErrorCode_vals), 0,
18971         "ReturnError/errorCode", HFILL }},
18972     { &hf_ROS_invokeIDRej,
18973       { "invokeIDRej", "ROS.invokeIDRej",
18974         FT_UINT32, BASE_DEC, VALS(ROS_T_invokeIDRej_vals), 0,
18975         "Reject/invokeIDRej", HFILL }},
18976     { &hf_ROS_derivable,
18977       { "derivable", "ROS.derivable",
18978         FT_UINT32, BASE_DEC, NULL, 0,
18979         "Reject/invokeIDRej/derivable", HFILL }},
18980     { &hf_ROS_not_derivable,
18981       { "not-derivable", "ROS.not_derivable",
18982         FT_NONE, BASE_NONE, NULL, 0,
18983         "Reject/invokeIDRej/not-derivable", HFILL }},
18984     { &hf_ROS_problem,
18985       { "problem", "ROS.problem",
18986         FT_UINT32, BASE_DEC, VALS(ROS_T_problem_vals), 0,
18987         "Reject/problem", HFILL }},
18988     { &hf_ROS_generalProblem,
18989       { "generalProblem", "ROS.generalProblem",
18990         FT_INT32, BASE_DEC, VALS(ROS_GeneralProblem_vals), 0,
18991         "Reject/problem/generalProblem", HFILL }},
18992     { &hf_ROS_invokeProblem,
18993       { "invokeProblem", "ROS.invokeProblem",
18994         FT_INT32, BASE_DEC, VALS(ROS_InvokeProblem_vals), 0,
18995         "Reject/problem/invokeProblem", HFILL }},
18996     { &hf_ROS_returnResultProblem,
18997       { "returnResultProblem", "ROS.returnResultProblem",
18998         FT_INT32, BASE_DEC, VALS(ROS_ReturnResultProblem_vals), 0,
18999         "Reject/problem/returnResultProblem", HFILL }},
19000     { &hf_ROS_returnErrorProblem,
19001       { "returnErrorProblem", "ROS.returnErrorProblem",
19002         FT_INT32, BASE_DEC, VALS(ROS_ReturnErrorProblem_vals), 0,
19003         "Reject/problem/returnErrorProblem", HFILL }},
19004     { &hf_ROS_localValue,
19005       { "localValue", "ROS.localValue",
19006         FT_INT32, BASE_DEC, VALS(gsm_ss_opr_code_strings), 0,
19007         "", HFILL }},
19008     { &hf_ROS_globalValue,
19009       { "globalValue", "ROS.globalValue",
19010         FT_STRING, BASE_NONE, NULL, 0,
19011         "", HFILL }},
19012     { &hf_ROS_nationaler,
19013       { "nationaler", "ROS.nationaler",
19014         FT_UINT32, BASE_DEC, NULL, 0,
19015         "ErrorCode/nationaler", HFILL }},
19016     { &hf_ROS_privateer,
19017       { "privateer", "ROS.privateer",
19018         FT_INT32, BASE_DEC, NULL, 0,
19019         "ErrorCode/privateer", HFILL }},
19020         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8,
19021       { "12,2 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b8",
19022                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x80,          
19023                 "12,2 kbit/s codec rate", HFILL }
19024         },
19025         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7,
19026       { "10,2 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b7",
19027                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x40,          
19028                 "10,2 kbit/s codec rate", HFILL }
19029         },
19030         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6,
19031       { "7,95 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b6",
19032                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x20,          
19033                 "7,95 kbit/s codec rate", HFILL }
19034         },
19035         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5,
19036       { "7,40 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b5",
19037                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x10,          
19038                 "7,40 kbit/s codec rate", HFILL }
19039         },
19040         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4,
19041       { "6,70 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b4",
19042                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x08,          
19043                 "6,70 kbit/s codec rate", HFILL }
19044         },
19045         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3,
19046       { "5,90 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b3",
19047                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x04,          
19048                 "5,90 kbit/s codec rate", HFILL }
19049         },
19050         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2,
19051       { "5,15 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b2",
19052                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x02,          
19053                 "5,15 kbit/s codec rate", HFILL }
19054         },
19055         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1,
19056       { "4,75 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b1",
19057                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x01,          
19058                 "4,75 kbit/s codec rate", HFILL }
19059         },
19060         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5,
19061       { "23,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b5",
19062                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x10,          
19063                 "23,85 kbit/s codec rate", HFILL }
19064         },
19065         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4,
19066       { "15,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b4",
19067                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x08,          
19068                 "15,85 kbit/s codec rate", HFILL }
19069         },
19070         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3,
19071       { "12,65 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b3",
19072                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x04,          
19073                 "12,65 kbit/s codec rate", HFILL }
19074         },
19075         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2,
19076       { "8,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b2",
19077                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x02,          
19078                 "8,85 kbit/s codec rate", HFILL }
19079         },
19080         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1,
19081       { "6,60 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b1",
19082                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x01,          
19083                 "6,60 kbit/s codec rate", HFILL }
19084         },
19085        { &hf_gsm_a_extension,
19086       { "Extension", "gsm_a.extension",
19087         FT_BOOLEAN, 8, TFS(&gsm_a_extension_value), 0x80,
19088         "Extension", HFILL }},
19089        { &hf_gsm_a_type_of_number,
19090       { "Type of number", "gsm_a.type_of_number",
19091         FT_UINT8, BASE_HEX, VALS(gsm_a_type_of_number_values), 0x70,
19092         "Type of number", HFILL }},
19093        { &hf_gsm_a_numbering_plan_id,
19094       { "Numbering plan identification", "gsm_a.numbering_plan_id",
19095         FT_UINT8, BASE_HEX, VALS(gsm_a_numbering_plan_id_values), 0x0f,
19096         "Numbering plan identification", HFILL }},
19097         { &hf_gsm_a_tft_op_code,
19098                 { "TFT operation code", "gsm_a.tft.op_code", 
19099                 FT_UINT8, BASE_DEC, VALS(gsm_a_tft_op_code_vals), 0xe0,
19100                 "TFT operation code", HFILL }
19101         },
19102         { &hf_gsm_a_tft_e_bit,
19103                 { "E bit","gsm_a.tft.e_bit",
19104                 FT_BOOLEAN,8,  TFS(&gsm_a_tft_e_bit), 0x10,          
19105                 "E bit", HFILL }
19106         },
19107         { &hf_gsm_a_tft_pkt_flt,
19108                 { "Number of packet filters", "gsm_a.tft.pkt_flt", 
19109                 FT_UINT8, BASE_DEC, NULL, 0x0f,
19110                 "Number of packet filters", HFILL }
19111         },
19112
19113        { &hf_gsm_a_tft_ip4_address,
19114       { "IPv4 adress", "gsm_a.tft.ip4_address", FT_IPv4, BASE_NONE, NULL, 0x0,
19115                 "IPv4 address", HFILL }},
19116         { &hf_gsm_a_tft_ip4_mask,
19117       { "IPv4 address mask", "gsm_a.tft.ip4_mask", FT_IPv4, BASE_NONE, NULL, 0x0,
19118                 "IPv4 address mask", HFILL }},
19119         { &hf_gsm_a_tft_ip6_address,
19120       { "IPv6 adress", "gsm_a.tft.ip6_address", FT_IPv6, BASE_NONE, NULL, 0x0,
19121                 "IPv6 address", HFILL }},
19122         { &hf_gsm_a_tft_ip6_mask,
19123         { "IPv6 adress mask", "gsm_a.tft.ip6_mask", FT_IPv6, BASE_NONE, NULL, 0x0,
19124                 "IPv6 address mask", HFILL }},
19125         { &hf_gsm_a_tft_protocol_header,
19126         { "Protocol/header", "gsm_a.tft.protocol_header", FT_UINT8, BASE_HEX, NULL, 0x0,
19127                 "Protocol/header", HFILL }},
19128         { &hf_gsm_a_tft_port,
19129         { "Port", "gsm_a.tft.port", FT_UINT16, BASE_DEC, NULL, 0x0,
19130                 "Port", HFILL }},
19131         { &hf_gsm_a_tft_port_low,
19132         { "Low limit port", "gsm_a.tft.port_low", FT_UINT16, BASE_DEC, NULL, 0x0,
19133                 "Low limit port", HFILL }},
19134         { &hf_gsm_a_tft_port_high,
19135         { "High limit port", "gsm_a.tft.port_high", FT_UINT16, BASE_DEC, NULL, 0x0,
19136                 "High limit port", HFILL }},
19137         { &hf_gsm_a_tft_security,
19138         { "IPSec security parameter index", "gsm_a.tft.security", FT_UINT32, BASE_HEX, NULL, 0x0,
19139                 "IPSec security parameter index", HFILL }},
19140         { &hf_gsm_a_tft_traffic_mask,
19141         { "Mask field", "gsm_a.tft.traffic_mask", FT_UINT8, BASE_HEX, NULL, 0x0,
19142                 "Mask field", HFILL }},
19143         { &hf_gsm_a_tft_flow,
19144         { "IPv6 flow label", "gsm_a.tft.flow", FT_UINT24, BASE_HEX, NULL, 0x0FFFFF,
19145                 "IPv6 flow label", HFILL }},
19146
19147         { &hf_gsm_a_ptmsi_sig,
19148         { "P-TMSI Signature", "gsm_a.ptmsi_sig", FT_UINT24, BASE_HEX, NULL, 0x0,
19149                 "P-TMSI Signature", HFILL }},
19150         { &hf_gsm_a_ptmsi_sig2,
19151         { "P-TMSI Signature 2", "gsm_a.ptmsi_sig2", FT_UINT24, BASE_HEX, NULL, 0x0,
19152                 "P-TMSI Signature 2", HFILL }},
19153
19154         { &hf_gsm_a_apdu_protocol_id,
19155                 { "Protocol ID", "gsm_a.apdu_protocol_id", 
19156                 FT_UINT8, BASE_DEC, VALS(gsm_a_apdu_protocol_id_strings), 0x0,
19157                 "APDU embedded protocol id", HFILL }
19158         },
19159         { &hf_gsm_a_lsa_id,
19160                 { "LSA Identifier", "gsm_a.lsa_id", 
19161                 FT_UINT24, BASE_HEX, NULL, 0x0,
19162                 "LSA Identifier", HFILL }
19163         },
19164     };
19165
19166     /* Setup protocol subtree array */
19167 #define NUM_INDIVIDUAL_ELEMS    50
19168     static gint *ett[NUM_INDIVIDUAL_ELEMS + NUM_GSM_BSSMAP_MSG +
19169                         NUM_GSM_DTAP_MSG_MM + NUM_GSM_DTAP_MSG_RR + NUM_GSM_DTAP_MSG_CC +
19170                         NUM_GSM_DTAP_MSG_GMM + NUM_GSM_DTAP_MSG_SMS +
19171                         NUM_GSM_DTAP_MSG_SM + NUM_GSM_DTAP_MSG_SS + NUM_GSM_RP_MSG +
19172                         NUM_GSM_BSSMAP_ELEM + NUM_GSM_DTAP_ELEM];
19173
19174     ett[0] = &ett_bssmap_msg;
19175     ett[1] = &ett_dtap_msg;
19176     ett[2] = &ett_rp_msg;
19177     ett[3] = &ett_elems;
19178     ett[4] = &ett_elem;
19179     ett[5] = &ett_dtap_oct_1;
19180     ett[6] = &ett_cm_srvc_type;
19181     ett[7] = &ett_gsm_enc_info;
19182     ett[8] = &ett_cell_list;
19183     ett[9] = &ett_dlci;
19184     ett[10] = &ett_bc_oct_3a;
19185     ett[11] = &ett_bc_oct_4;
19186     ett[12] = &ett_bc_oct_5;
19187     ett[13] = &ett_bc_oct_5a;
19188     ett[14] = &ett_bc_oct_5b;
19189     ett[15] = &ett_bc_oct_6;
19190     ett[16] = &ett_bc_oct_6a;
19191     ett[17] = &ett_bc_oct_6b;
19192     ett[18] = &ett_bc_oct_6c;
19193     ett[19] = &ett_bc_oct_6d;
19194     ett[20] = &ett_bc_oct_6e;
19195     ett[21] = &ett_bc_oct_6f;
19196     ett[22] = &ett_bc_oct_6g;
19197     ett[23] = &ett_bc_oct_7;
19198
19199     ett[24] = &ett_tc_component;
19200     ett[25] = &ett_tc_invoke_id;
19201     ett[26] = &ett_tc_linked_id;
19202     ett[27] = &ett_tc_opr_code;
19203     ett[28] = &ett_tc_err_code;
19204     ett[29] = &ett_tc_prob_code;
19205     ett[30] = &ett_tc_sequence;
19206     
19207     ett[31] = &ett_gmm_drx;
19208     ett[32] = &ett_gmm_detach_type;
19209     ett[33] = &ett_gmm_attach_type;
19210     ett[34] = &ett_gmm_context_stat;
19211     ett[35] = &ett_gmm_update_type;
19212     ett[36] = &ett_gmm_radio_cap;
19213
19214     ett[37] = &ett_sm_tft;
19215
19216     ett[38] = &ett_ros,
19217     ett[39] = &ett_ROS_Component,
19218     ett[40] = &ett_ROS_Invoke,
19219     ett[41] = &ett_ROS_ReturnResult,
19220     ett[42] = &ett_ROS_T_resultretres,
19221     ett[43] = &ett_ROS_ReturnError,
19222     ett[44] = &ett_ROS_Reject,
19223     ett[45] = &ett_ROS_T_invokeIDRej,
19224     ett[46] = &ett_ROS_T_problem,
19225     ett[47] = &ett_ROS_OPERATION,
19226     ett[48] = &ett_ROS_ERROR,
19227     ett[49] = &ett_ROS_ErrorCode,
19228
19229     last_offset = NUM_INDIVIDUAL_ELEMS;
19230
19231     for (i=0; i < NUM_GSM_BSSMAP_MSG; i++, last_offset++)
19232     {
19233         ett_gsm_bssmap_msg[i] = -1;
19234         ett[last_offset] = &ett_gsm_bssmap_msg[i];
19235     }
19236
19237     for (i=0; i < NUM_GSM_DTAP_MSG_MM; i++, last_offset++)
19238     {
19239         ett_gsm_dtap_msg_mm[i] = -1;
19240         ett[last_offset] = &ett_gsm_dtap_msg_mm[i];
19241     }
19242
19243     for (i=0; i < NUM_GSM_DTAP_MSG_RR; i++, last_offset++)
19244     {
19245         ett_gsm_dtap_msg_rr[i] = -1;
19246         ett[last_offset] = &ett_gsm_dtap_msg_rr[i];
19247     }
19248
19249     for (i=0; i < NUM_GSM_DTAP_MSG_CC; i++, last_offset++)
19250     {
19251         ett_gsm_dtap_msg_cc[i] = -1;
19252         ett[last_offset] = &ett_gsm_dtap_msg_cc[i];
19253     }
19254
19255     for (i=0; i < NUM_GSM_DTAP_MSG_GMM; i++, last_offset++)
19256     {
19257         ett_gsm_dtap_msg_gmm[i] = -1;
19258         ett[last_offset] = &ett_gsm_dtap_msg_gmm[i];
19259     }
19260
19261     for (i=0; i < NUM_GSM_DTAP_MSG_SMS; i++, last_offset++)
19262     {
19263         ett_gsm_dtap_msg_sms[i] = -1;
19264         ett[last_offset] = &ett_gsm_dtap_msg_sms[i];
19265     }
19266
19267     for (i=0; i < NUM_GSM_DTAP_MSG_SM; i++, last_offset++)
19268     {
19269         ett_gsm_dtap_msg_sm[i] = -1;
19270         ett[last_offset] = &ett_gsm_dtap_msg_sm[i];
19271     }
19272
19273     for (i=0; i < NUM_GSM_DTAP_MSG_SS; i++, last_offset++)
19274     {
19275         ett_gsm_dtap_msg_ss[i] = -1;
19276         ett[last_offset] = &ett_gsm_dtap_msg_ss[i];
19277     }
19278
19279     for (i=0; i < NUM_GSM_RP_MSG; i++, last_offset++)
19280     {
19281         ett_gsm_rp_msg[i] = -1;
19282         ett[last_offset] = &ett_gsm_rp_msg[i];
19283     }
19284
19285     for (i=0; i < NUM_GSM_BSSMAP_ELEM; i++, last_offset++)
19286     {
19287         ett_gsm_bssmap_elem[i] = -1;
19288         ett[last_offset] = &ett_gsm_bssmap_elem[i];
19289     }
19290
19291     for (i=0; i < NUM_GSM_DTAP_ELEM; i++, last_offset++)
19292     {
19293         ett_gsm_dtap_elem[i] = -1;
19294         ett[last_offset] = &ett_gsm_dtap_elem[i];
19295     }
19296
19297
19298     /* Register the protocol name and description */
19299
19300     proto_a_bssmap =
19301         proto_register_protocol("GSM A-I/F BSSMAP", "GSM BSSMAP", "gsm_a_bssmap");
19302
19303     proto_register_field_array(proto_a_bssmap, hf, array_length(hf));
19304
19305     proto_a_dtap =
19306         proto_register_protocol("GSM A-I/F DTAP", "GSM DTAP", "gsm_a_dtap");
19307
19308     proto_a_rp =
19309         proto_register_protocol("GSM A-I/F RP", "GSM RP", "gsm_a_rp");
19310
19311     sms_dissector_table =
19312         register_dissector_table("gsm_a.sms_tpdu", "GSM SMS TPDU",
19313         FT_UINT8, BASE_DEC);
19314
19315     proto_register_subtree_array(ett, array_length(ett));
19316
19317     /* subdissector code */
19318     gprs_sm_pco_subdissector_table = register_dissector_table("sm_pco.protocol",
19319         "GPRS SM PCO PPP protocol", FT_UINT16, BASE_HEX);
19320
19321     gsm_a_tap = register_tap("gsm_a");
19322         
19323         register_dissector("gsm_a_dtap", dissect_dtap, proto_a_dtap);
19324         register_dissector("gsm_a_rp", dissect_rp, proto_a_rp);
19325         register_dissector("gsm_a_bssmap", dissect_bssmap, proto_a_bssmap);
19326 }
19327
19328
19329 void
19330 proto_reg_handoff_gsm_a(void)
19331 {
19332
19333     bssmap_handle = create_dissector_handle(dissect_bssmap, proto_a_bssmap);
19334     dtap_handle = find_dissector("gsm_a_dtap");
19335     rp_handle = create_dissector_handle(dissect_rp, proto_a_rp);
19336
19337     dissector_add("bssap.pdu_type",  BSSAP_PDU_TYPE_BSSMAP, bssmap_handle);
19338     dissector_add("bssap.pdu_type",  BSSAP_PDU_TYPE_DTAP, dtap_handle);
19339     dissector_add("ranap.nas_pdu",  BSSAP_PDU_TYPE_DTAP, dtap_handle);
19340     dissector_add("llcgprs.sapi", 1 , dtap_handle);
19341     data_handle = find_dissector("data");
19342 }
19343